mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
extensions-api -- loading extension modules -- part 2
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
b2414542b8
commit
e93c53ff0c
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,6 +8,6 @@ tmp/
|
|||||||
static/build/**
|
static/build/**
|
||||||
binaries/client/
|
binaries/client/
|
||||||
binaries/server/
|
binaries/server/
|
||||||
src/extensions/**/*.js
|
src/extensions/*/*.js
|
||||||
src/extensions/**/*.d.ts
|
src/extensions/*/*.d.ts
|
||||||
locales/**/**.js
|
locales/**/**.js
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
// import { LensExtension } from "@lens"; // fixme: provide runtime import
|
// fixme: hook up generated types from extension-api.ts (tsc --declaration)
|
||||||
|
// fixme: provide compile or runtime import
|
||||||
|
import { LensExtension } from "@lens/extensions";
|
||||||
|
|
||||||
export default class ExampleExtension /*extends LensExtension*/ {
|
export default class ExampleExtension extends LensExtension {
|
||||||
async init(): Promise<any> {
|
async init(): Promise<any> {
|
||||||
console.log('Example extension: init')
|
console.log('Example extension: init')
|
||||||
// return super.init();
|
return super.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"declaration": true
|
"declaration": true
|
||||||
},
|
},
|
||||||
"files": [
|
"include": [
|
||||||
"./example-extension/example-extension.ts"
|
"./example-extension/example-extension.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
4
src/extensions/extension-api.ts
Normal file
4
src/extensions/extension-api.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// LensExtensions.api.js developer kit (Lens common components)
|
||||||
|
// Should be published to npm (with types declarations) and also available as built-in dependency
|
||||||
|
|
||||||
|
export * from "./extension"
|
||||||
@ -5,9 +5,12 @@ import extensionManifest from "./example-extension/package.json"
|
|||||||
import logger from "../main/logger";
|
import logger from "../main/logger";
|
||||||
|
|
||||||
// TODO: extensions api
|
// TODO: extensions api
|
||||||
// - figure out how to expose/inject lens apis to extension:
|
// * figure out how to expose/inject lens apis to extension:
|
||||||
// -- replace import "@lens" to real path to "build/Lens.js" or maybe "build/Lens-extensions.api.js"
|
// -- replace import "@lens" to real path to "build/Lens.js" or maybe "build/Lens-extensions.api.js"
|
||||||
// -- load extension via NodeJS.require() / webContents.executeJavaScript()
|
// -- load extension via NodeJS.require() / webContents.executeJavaScript()
|
||||||
|
// * figure out how to re-use/provide-access from extension to its:
|
||||||
|
// -- npm dependencies
|
||||||
|
// -- folder assets/resources
|
||||||
|
|
||||||
export type ExtensionId = string;
|
export type ExtensionId = string;
|
||||||
export type ExtensionVersion = string | number;
|
export type ExtensionVersion = string | number;
|
||||||
|
|||||||
6
src/extensions/lens-app.d.ts
vendored
6
src/extensions/lens-app.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
// todo: re-export / expose more apis
|
|
||||||
// todo: generate as Lens.d.js + add real runtime exports
|
|
||||||
|
|
||||||
declare module "@lens" {
|
|
||||||
export { LensExtension, ExtensionId, ExtensionVersion } from "./extension";
|
|
||||||
}
|
|
||||||
1
types/mocks.d.ts
vendored
1
types/mocks.d.ts
vendored
@ -3,6 +3,7 @@ declare module "mac-ca"
|
|||||||
declare module "win-ca"
|
declare module "win-ca"
|
||||||
declare module "@hapi/call"
|
declare module "@hapi/call"
|
||||||
declare module "@hapi/subtext"
|
declare module "@hapi/subtext"
|
||||||
|
declare module "@lens/extensions" // todo: provide types
|
||||||
|
|
||||||
// Global path to static assets
|
// Global path to static assets
|
||||||
declare const __static: string;
|
declare const __static: string;
|
||||||
|
|||||||
@ -25,6 +25,9 @@ export default function (): webpack.Configuration {
|
|||||||
libraryTarget: "commonjs2",
|
libraryTarget: "commonjs2",
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
// "@lens/extensions": "" // todo: replace in runtime to "build/LensExtensionApi.js"?
|
||||||
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
'.js', '.jsx', '.json',
|
'.js', '.jsx', '.json',
|
||||||
'.ts', '.tsx',
|
'.ts', '.tsx',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user