From 4602c71d172bc8822b7229dc0d7c036fc964791b Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 13 Nov 2023 15:53:43 +0100 Subject: [PATCH 1/6] clarification --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74cc575..15da970 100644 --- a/README.md +++ b/README.md @@ -352,7 +352,9 @@ You can use `.env` files, e.g., `.env.local` to configure development options: NODE_ENV=development # Set the library's log level (ALL, DEBUG, INFO, WARN, ERROR, OFF) -# Logging is OFF by default. +# Logging is OFF by default. +# Note, if the level is not set or it is OFF, no console outputs +# are suppressed while unit tests are run. VITE_LOG_LEVEL=ALL ``` From 5123811e9e499332556a0bed452595d382893542 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 13 Nov 2023 15:54:17 +0100 Subject: [PATCH 2/6] fix naming typos --- src/framework/core/extension-context/impl.ts | 29 ++++++++++++-------- src/framework/core/extension/activate.ts | 1 + src/framework/core/types.ts | 10 +++---- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/framework/core/extension-context/impl.ts b/src/framework/core/extension-context/impl.ts index f76fc25..5f4571f 100644 --- a/src/framework/core/extension-context/impl.ts +++ b/src/framework/core/extension-context/impl.ts @@ -37,13 +37,12 @@ export class ExtensionContextImpl implements ExtensionContext, DisposableLike { private _subscriptions: DisposableLike[] = []; private _module: ExtensionModule | undefined = undefined; private _modulePath: string | undefined = undefined; - private _moduleResolver: ExtensionPathResolver | undefined = undefined; + private _pathResolver: ExtensionPathResolver | undefined = undefined; constructor(readonly extensionId: string) {} resolveModulePath(path: string): string { - const resolveModulePath = - this.moduleResolver ?? frameworkConfig.pathResolver; + const resolveModulePath = this.pathResolver; if (resolveModulePath instanceof Function) { return resolveModulePath(path); } @@ -62,16 +61,12 @@ export class ExtensionContextImpl implements ExtensionContext, DisposableLike { return this._subscriptions; } - get moduleResolver() { - return this._moduleResolver; + get pathResolver() { + return this._pathResolver ?? frameworkConfig.pathResolver; } - setPathResolver(moduleResolver: ExtensionPathResolver) { - this._moduleResolver = moduleResolver; - } - - get builtIn(): boolean { - return !this._modulePath; + setPathResolver(pathResolver: ExtensionPathResolver) { + this._pathResolver = pathResolver; } get modulePath(): string { @@ -90,6 +85,18 @@ export class ExtensionContextImpl implements ExtensionContext, DisposableLike { this._module = module; } + /** + * Returns `true` if this is a built-in extension. + * Built-in extensions have no module path. + * @internal + */ + get builtIn(): boolean { + return !this._modulePath; + } + + /** + * Disposes all resources associated with the extension. + */ dispose(): void { this._subscriptions.forEach((d) => { d.dispose(); diff --git a/src/framework/core/extension/activate.ts b/src/framework/core/extension/activate.ts index 14b86b0..2f8a862 100644 --- a/src/framework/core/extension/activate.ts +++ b/src/framework/core/extension/activate.ts @@ -95,6 +95,7 @@ async function getExtensionDependencies(extension: Extension) { async function importModule(ctx: ExtensionContextImpl, path: string) { const resolvedPath = ctx.resolveModulePath(path); + LOG.debug("Importing extension module", resolvedPath); const module: ExtensionModule = (await import( /*@vite-ignore*/ resolvedPath )) as ExtensionModule; diff --git a/src/framework/core/types.ts b/src/framework/core/types.ts index 93bb35a..48173e7 100644 --- a/src/framework/core/types.ts +++ b/src/framework/core/types.ts @@ -97,6 +97,11 @@ export interface Extension { * @category Extension API */ export interface ExtensionContext { + /** + * The current {@link Extension} instance. + */ + readonly extension: Extension; + /** * An array to which disposables can be added. When this * extension is deactivated the disposables will be disposed. @@ -105,11 +110,6 @@ export interface ExtensionContext { */ readonly subscriptions: DisposableLike[]; - /** - * The current `Extension` instance. - */ - readonly extension: Extension; - /** * The resolved module path. */ From ac7cfca5062ccbb31bce2fef98fe4ed3b7eb5218 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Mon, 13 Nov 2023 15:55:29 +0100 Subject: [PATCH 3/6] using package.json files for extensions --- src/demo/AvailableExtensions.tsx | 9 +- src/demo/CommandPalette.tsx | 3 +- src/demo/InstalledExtensions.tsx | 16 +-- src/demo/app-store.ts | 38 ++--- src/demo/extensions/index.tsx | 133 +----------------- .../Ex1View.tsx} | 2 +- .../activator.tsx} | 4 +- .../extensions/my-extension-1/package.json | 40 ++++++ .../Ex2View.tsx} | 2 +- .../activator.tsx} | 4 +- .../extensions/my-extension-2/package.json | 40 ++++++ .../Ex3View.tsx} | 2 +- .../activator.tsx} | 4 +- .../extensions/my-extension-3/package.json | 40 ++++++ src/demo/main.tsx | 2 +- 15 files changed, 166 insertions(+), 173 deletions(-) rename src/demo/extensions/{MyEx1View.tsx => my-extension-1/Ex1View.tsx} (94%) rename src/demo/extensions/{my-extension-1.tsx => my-extension-1/activator.tsx} (85%) create mode 100644 src/demo/extensions/my-extension-1/package.json rename src/demo/extensions/{MyEx2View.tsx => my-extension-2/Ex2View.tsx} (94%) rename src/demo/extensions/{my-extension-2.tsx => my-extension-2/activator.tsx} (85%) create mode 100644 src/demo/extensions/my-extension-2/package.json rename src/demo/extensions/{MyEx3View.tsx => my-extension-3/Ex3View.tsx} (94%) rename src/demo/extensions/{my-extension-3.tsx => my-extension-3/activator.tsx} (85%) create mode 100644 src/demo/extensions/my-extension-3/package.json diff --git a/src/demo/AvailableExtensions.tsx b/src/demo/AvailableExtensions.tsx index 84c9caa..27776e4 100644 --- a/src/demo/AvailableExtensions.tsx +++ b/src/demo/AvailableExtensions.tsx @@ -24,12 +24,17 @@ function AvailableExtensions() {

Available Extensions

Click to install

- {availableExtensions.map((manifest) => { + {availableExtensions.map(([dirPath, manifest]) => { return (