1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

extensions-api -- in-progress

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-09-04 14:54:56 +03:00
parent 76f8263baf
commit 57d6f8f933
10 changed files with 25 additions and 35 deletions

4
.gitignore vendored
View File

@ -1,11 +1,11 @@
dist/ dist/
out/
node_modules/ node_modules/
.DS_Store .DS_Store
yarn-error.log yarn-error.log
coverage/ coverage/
tmp/ tmp/
static/build/** static/build
static/types
binaries/client/ binaries/client/
binaries/server/ binaries/server/
src/extensions/*/*.js src/extensions/*/*.js

View File

@ -20,6 +20,7 @@
"compile:main": "webpack --config webpack.main.ts", "compile:main": "webpack --config webpack.main.ts",
"compile:renderer": "webpack --config webpack.renderer.ts", "compile:renderer": "webpack --config webpack.renderer.ts",
"compile:i18n": "lingui compile", "compile:i18n": "lingui compile",
"compile:extension-api.d.ts": "tsc --project src/extensions",
"build:linux": "yarn compile && electron-builder --linux --dir -c.productName=Lens", "build:linux": "yarn compile && electron-builder --linux --dir -c.productName=Lens",
"build:mac": "yarn compile && electron-builder --mac --dir -c.productName=Lens", "build:mac": "yarn compile && electron-builder --mac --dir -c.productName=Lens",
"build:win": "yarn compile && electron-builder --win --dir -c.productName=Lens", "build:win": "yarn compile && electron-builder --win --dir -c.productName=Lens",

View File

@ -1,10 +1,6 @@
import { LensExtension, LensRendererRuntimeEnv } from "@lens/extensions"; import { LensExtension, LensRendererRuntimeEnv } from "@lens/extensions"; // fixme: map to generated types from "extension-api.d.ts"
export default class ExampleExtension extends LensExtension { export default class ExampleExtension extends LensExtension {
todo(){
console.log(this.runtime.apiManager); // fixme: incorrect types import, "runtime" doesn't exists
}
async activate(runtime: LensRendererRuntimeEnv): Promise<any> { async activate(runtime: LensRendererRuntimeEnv): Promise<any> {
await super.activate(runtime); await super.activate(runtime);
console.log('Example extension: activate'); console.log('Example extension: activate');

View File

@ -1,21 +1,11 @@
{ {
"extends": "../../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"jsx": "react",
"target": "ES2017",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"module": "CommonJS", "module": "CommonJS",
"moduleResolution": "Node", "sourceMap": false,
"noImplicitAny": true, "declaration": false
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"skipLibCheck": true
}, },
"include": [ "include": [
"../extension-api.mock.d.ts",
"./example-extension.ts" "./example-extension.ts"
] ]
} }

View File

@ -1,9 +0,0 @@
declare module "@lens/extensions" {
export = LensExtensions
}
declare namespace LensExtensions {
export {
LensExtension, ExtensionManifest, ExtensionVersion, ExtensionId, LensRendererRuntimeEnv
} from "./extension-api"
}

View File

@ -5,7 +5,7 @@ export interface LensRendererRuntimeEnv {
apiManager: ApiManager; apiManager: ApiManager;
} }
// todo: expose more renderer runtime variables, stores, etc. // todo: expose more public runtime apis: stores, managers, etc.
export function getExtensionRuntime(): LensRendererRuntimeEnv { export function getExtensionRuntime(): LensRendererRuntimeEnv {
return { return {
apiManager, apiManager,

View File

@ -1,5 +1,4 @@
// Lens-extensions.api.js developer kit // Lens-extensions api developer's kit
// todo: generate types instead of extension-api.mock.d.ts
export { LensRendererRuntimeEnv } from "./extension-api.runtime"; export type { LensRendererRuntimeEnv } from "./extension-api.runtime";
export * from "./extension" export * from "./extension"

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "AMD",
"declaration": true,
"emitDeclarationOnly": true,
"outFile": "./../../static/types/extension-api.d.ts"
},
"include": [
"../../types",
"./extension-api.ts"
]
}

View File

@ -73,10 +73,9 @@ export function buildMenu(windowManager: WindowManager) {
navigate(preferencesURL()) navigate(preferencesURL())
} }
}, },
{ type: 'separator' },
{ {
label: 'Extensions', label: 'Extensions',
accelerator: 'CmdOrCtrl+Shift+E', accelerator: 'CmdOrCtrl+E',
click() { click() {
navigate(extensionsURL()) navigate(extensionsURL())
} }

1
types/mocks.d.ts vendored
View File

@ -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" // fixme: provide generated types from "extension-api.ts"
// Global path to static assets // Global path to static assets
declare const __static: string; declare const __static: string;