mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
extensions-api -- expose public apis to extension via "module-alias" package
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
a6a0a6eddf
commit
a5533a5eb1
10 files changed
+31
-21
No files matched your search
+8
-2
@@ -2,6 +2,7 @@
|
||||
import path from "path";
|
||||
import packageInfo from "../../package.json"
|
||||
import { defineGlobal } from "./utils/defineGlobal";
|
||||
import { addAlias } from "module-alias";
|
||||
|
||||
export const isMac = process.platform === "darwin"
|
||||
export const isWindows = process.platform === "win32"
|
||||
@@ -11,7 +12,6 @@ export const isDevelopment = isDebugging || !isProduction;
|
||||
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
||||
|
||||
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`
|
||||
export const extensionApiLibName = `${appName}-extensions.api`
|
||||
export const publicPath = "/build/"
|
||||
|
||||
// Webpack build paths
|
||||
@@ -19,10 +19,16 @@ export const contextDir = process.cwd();
|
||||
export const buildDir = path.join(contextDir, "static", publicPath);
|
||||
export const mainDir = path.join(contextDir, "src/main");
|
||||
export const rendererDir = path.join(contextDir, "src/renderer");
|
||||
export const extensionsDir = path.join(contextDir, "src/extensions");
|
||||
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||
|
||||
// Extensions
|
||||
export const extensionsLibName = `${appName}-extensions.api`
|
||||
export const extensionsDir = path.join(contextDir, "src/extensions");
|
||||
|
||||
// Special dynamic module aliases
|
||||
addAlias("@lens/extensions", path.resolve(buildDir, `${extensionsLibName}.js`)); // fixme: provide path in prod
|
||||
|
||||
// Special runtime paths
|
||||
defineGlobal("__static", {
|
||||
get() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// fixme: provide runtime import / webpack.resolve.alias / require.extensions (?)
|
||||
import { LensExtension } from "@lens/extensions";
|
||||
|
||||
export default class ExampleExtension extends LensExtension {
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"resolveJsonModule": true
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": [
|
||||
"../extension-api.mock.d.ts",
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
// todo: auto-generate from ./extension-api.ts
|
||||
// todo: remove when npm-available (with generated types)
|
||||
|
||||
declare module "@lens/extensions" {
|
||||
export = LensExtensions
|
||||
|
||||
@@ -1,4 +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
|
||||
// Lens-extensions.api.js developer kit
|
||||
// todo: generate types instead of extension-api.mock.d.ts
|
||||
|
||||
export * from "./extension"
|
||||
@@ -4,14 +4,6 @@ import { action, observable, when } from "mobx";
|
||||
import extensionManifest from "./example-extension/package.json"
|
||||
import logger from "../main/logger";
|
||||
|
||||
// TODO: extensions api
|
||||
// * 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"
|
||||
// -- 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 ExtensionVersion = string | number;
|
||||
export type ExtensionManifest = typeof extensionManifest & ExtensionModel;
|
||||
@@ -49,7 +41,8 @@ export class LensExtension implements ExtensionModel {
|
||||
}
|
||||
|
||||
async init() {
|
||||
// todo
|
||||
// todo: add more app/extension lifecycle hooks? e.g. onAppExit(), etc.
|
||||
// todo: provide runtime dependencies
|
||||
}
|
||||
|
||||
async install() {
|
||||
|
||||
Whitespace-only changes.
Reference in new issue
Block a user