Skip to content

Commit

Permalink
Added app://cache/extension-types for extension type sharing (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil authored Dec 1, 2023
2 parents f84e389 + a24d009 commit 8d33e3a
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 86 deletions.
59 changes: 57 additions & 2 deletions lib/papi-dts/papi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4290,7 +4290,7 @@ declare module 'node/utils/util' {
}
declare module 'node/services/node-file-system.service' {
/** File system calls from Node */
import { BigIntStats } from 'fs';
import fs, { BigIntStats } from 'fs';
import { Uri } from 'shared/data/file-system.model';
/**
* Read a text file
Expand All @@ -4314,6 +4314,21 @@ declare module 'node/services/node-file-system.service' {
* @returns Promise that resolves after writing the file
*/
export function writeFile(uri: Uri, fileContents: string | Buffer): Promise<void>;
/**
* Copies a file from one location to another. Creates the path to the destination if it does not
* exist
*
* @param sourceUri The location of the file to copy
* @param destinationUri The uri to the file to create as a copy of the source file
* @param mode Bitwise modifiers that affect how the copy works. See
* [`fsPromises.copyFile`](https://nodejs.org/api/fs.html#fspromisescopyfilesrc-dest-mode) for
* more information
*/
export function copyFile(
sourceUri: Uri,
destinationUri: Uri,
mode?: Parameters<typeof fs.promises.copyFile>[2],
): Promise<void>;
/**
* Delete a file if it exists
*
Expand Down Expand Up @@ -4359,7 +4374,7 @@ declare module 'node/services/node-file-system.service' {
entryFilter?: (entryName: string) => boolean,
): Promise<DirectoryEntries>;
/**
* Create a directory in the file system
* Create a directory in the file system if it does not exist. Does not throw if it already exists.
*
* @param uri URI of directory
* @returns Promise that resolves once the directory has been created
Expand Down Expand Up @@ -4750,3 +4765,43 @@ declare module 'extension-host/extension-types/extension.interface' {
deactivate?: UnsubscriberAsync;
}
}
declare module 'extension-host/extension-types/extension-manifest.model' {
/** Information about an extension provided by the extension developer. */
export type ExtensionManifest = {
/** Name of the extension */
name: string;
/**
* Extension version - expected to be [semver](https://semver.org/) like `"0.1.3"`.
*
* Note: semver may become a hard requirement in the future, so we recommend using it now.
*/
version: string;
/**
* Path to the JavaScript file to run in the extension host. Relative to the extension's root
* folder.
*
* Must be specified. Can be `null` if the extension does not have any JavaScript to run.
*/
main: string | null;
/**
* Path to the TypeScript type declaration file that describes this extension and its interactions
* on the PAPI. Relative to the extension's root folder.
*
* If not provided, Platform.Bible will look in the following locations:
*
* 1. `<extension_name>.d.ts`
* 2. `<extension_name><other_stuff>.d.ts`
* 3. `index.d.ts`
*
* See [Extension Anatomy - Type Declaration
* Files](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#type-declaration-files-dts)
* for more information about extension type declaration files.
*/
types?: string;
/**
* List of events that occur that should cause this extension to be activated. Not yet
* implemented.
*/
activationEvents: string[];
};
}
3 changes: 2 additions & 1 deletion lib/papi-dts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"../../src/renderer/services/papi-frontend.service.ts",
"../../src/renderer/services/papi-frontend-react.service.ts",
"../../src/extension-host/services/papi-backend.service.ts",
"../../src/extension-host/extension-types/extension.interface.ts"
"../../src/extension-host/extension-types/extension.interface.ts",
"../../src/extension-host/extension-types/extension-manifest.model.ts"
],
"exclude": ["node_modules"],
"ts-node": {
Expand Down
38 changes: 38 additions & 0 deletions src/extension-host/extension-types/extension-manifest.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/** Information about an extension provided by the extension developer. */
export type ExtensionManifest = {
/** Name of the extension */
name: string;
/**
* Extension version - expected to be [semver](https://semver.org/) like `"0.1.3"`.
*
* Note: semver may become a hard requirement in the future, so we recommend using it now.
*/
version: string;
/**
* Path to the JavaScript file to run in the extension host. Relative to the extension's root
* folder.
*
* Must be specified. Can be `null` if the extension does not have any JavaScript to run.
*/
main: string | null;
/**
* Path to the TypeScript type declaration file that describes this extension and its interactions
* on the PAPI. Relative to the extension's root folder.
*
* If not provided, Platform.Bible will look in the following locations:
*
* 1. `<extension_name>.d.ts`
* 2. `<extension_name><other_stuff>.d.ts`
* 3. `index.d.ts`
*
* See [Extension Anatomy - Type Declaration
* Files](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#type-declaration-files-dts)
* for more information about extension type declaration files.
*/
types?: string;
/**
* List of events that occur that should cause this extension to be activated. Not yet
* implemented.
*/
activationEvents: string[];
};
Loading

0 comments on commit 8d33e3a

Please sign in to comment.