mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce clearer boundry between extensions (#7164)
- Bundled extensions are always enabled, and are always compatible - Have bundled extensions be loaded asyncronously to support typescript dynamic import (which is typed) as opposed to require Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
351f9d492f
commit
058494bc73
29 files changed
+440
-550
No files matched your search
@@ -1,13 +1,13 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type {
|
||||
LensExtensionConstructor,
|
||||
LensExtensionManifest,
|
||||
BundledLensExtensionConstructor,
|
||||
BundledLensExtensionManifest,
|
||||
} from "./lens-extension";
|
||||
|
||||
export interface BundledExtension {
|
||||
readonly manifest: LensExtensionManifest;
|
||||
main: () => LensExtensionConstructor | null;
|
||||
renderer: () => LensExtensionConstructor | null;
|
||||
readonly manifest: BundledLensExtensionManifest;
|
||||
main: () => Promise<BundledLensExtensionConstructor | null>;
|
||||
renderer: () => Promise<BundledLensExtensionConstructor | null>;
|
||||
}
|
||||
|
||||
export const bundledExtensionInjectionToken =
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
export type LensExtensionId = string;
|
||||
|
||||
export type LensExtensionConstructor = new (
|
||||
ext: InstalledExtension
|
||||
) => LegacyLensExtension;
|
||||
export type BundledLensExtensionConstructor = new (
|
||||
ext: BundledInstalledExtension
|
||||
) => LegacyLensExtension;
|
||||
|
||||
export interface InstalledExtension {
|
||||
id: LensExtensionId;
|
||||
|
||||
readonly manifest: LensExtensionManifest;
|
||||
|
||||
export interface BaseInstalledExtension {
|
||||
readonly id: LensExtensionId;
|
||||
// Absolute path to the non-symlinked source folder,
|
||||
// e.g. "/Users/user/.k8slens/extensions/helloworld"
|
||||
readonly absolutePath: string;
|
||||
|
||||
/**
|
||||
* Absolute to the symlinked package.json file
|
||||
*/
|
||||
// Absolute to the symlinked package.json file
|
||||
readonly manifestPath: string;
|
||||
readonly isBundled: boolean;
|
||||
}
|
||||
|
||||
export interface BundledInstalledExtension extends BaseInstalledExtension {
|
||||
readonly manifest: BundledLensExtensionManifest;
|
||||
readonly isBundled: true;
|
||||
readonly isCompatible: true;
|
||||
readonly isEnabled: true;
|
||||
}
|
||||
|
||||
export interface ExternalInstalledExtension extends BaseInstalledExtension {
|
||||
readonly manifest: LensExtensionManifest;
|
||||
readonly isBundled: false;
|
||||
readonly isCompatible: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
export type InstalledExtension =
|
||||
| BundledInstalledExtension
|
||||
| ExternalInstalledExtension;
|
||||
|
||||
export interface LegacyLensExtension {
|
||||
readonly id: LensExtensionId;
|
||||
readonly manifest: LensExtensionManifest;
|
||||
@@ -38,22 +51,11 @@ export interface LegacyLensExtension {
|
||||
activate(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface LensExtensionManifest {
|
||||
export interface BundledLensExtensionManifest {
|
||||
name: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
|
||||
main?: string; // path to %ext/dist/main.js
|
||||
renderer?: string; // path to %ext/dist/renderer.js
|
||||
/**
|
||||
* Supported Lens version engine by extension could be defined in `manifest.engines.lens`
|
||||
* Only MAJOR.MINOR version is taken in consideration.
|
||||
*/
|
||||
engines: {
|
||||
lens: string; // "semver"-package format
|
||||
npm?: string;
|
||||
node?: string;
|
||||
};
|
||||
publishConfig?: Partial<Record<string, string>>;
|
||||
|
||||
/**
|
||||
* Specify extension name used for persisting data.
|
||||
@@ -61,3 +63,17 @@ export interface LensExtensionManifest {
|
||||
*/
|
||||
storeName?: string;
|
||||
}
|
||||
|
||||
export interface LensExtensionManifest extends BundledLensExtensionManifest {
|
||||
main?: string; // path to %ext/dist/main.js
|
||||
renderer?: string; // path to %ext/dist/renderer.js
|
||||
|
||||
/**
|
||||
* Supported Lens version engine by extension could be defined in `manifest.engines.lens`
|
||||
* Only MAJOR.MINOR version is taken in consideration.
|
||||
*/
|
||||
engines: {
|
||||
lens: string; // "semver"-package format
|
||||
[x: string]: string | undefined;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user