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-02 17:54:18 +03:00
parent e93c53ff0c
commit a6a0a6eddf
7 changed files with 22 additions and 15 deletions

View File

@ -15,11 +15,11 @@
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
"dev:main": "yarn compile:main --watch",
"dev:renderer": "yarn compile:renderer --watch",
"dev:extensions": "tsc --project src/extensions/example-extension --watch",
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
"compile:main": "webpack --config webpack.main.ts",
"compile:renderer": "webpack --config webpack.renderer.ts",
"compile:i18n": "lingui compile",
"compile-extensions": "tsc --project src/extensions --watch",
"build:linux": "yarn compile && electron-builder --linux --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",

View File

@ -11,6 +11,7 @@ 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
@ -18,6 +19,7 @@ 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");

View File

@ -1,5 +1,4 @@
// fixme: hook up generated types from extension-api.ts (tsc --declaration)
// fixme: provide compile or runtime import
// fixme: provide runtime import / webpack.resolve.alias / require.extensions (?)
import { LensExtension } from "@lens/extensions";
export default class ExampleExtension extends LensExtension {
@ -8,7 +7,3 @@ export default class ExampleExtension extends LensExtension {
return super.init();
}
}
export const someData = {
title: "it works"
}

View File

@ -11,10 +11,10 @@
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"declaration": true
"resolveJsonModule": true
},
"include": [
"./example-extension/example-extension.ts"
"../extension-api.mock.d.ts",
"./example-extension.ts"
]
}

12
src/extensions/extension-api.mock.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
// todo: auto-generate from ./extension-api.ts
// todo: remove when npm-available (with generated types)
declare module "@lens/extensions" {
export = LensExtensions
}
declare namespace LensExtensions {
export {
LensExtension, ExtensionManifest, ExtensionVersion, ExtensionId,
} from "./extension-api"
}

1
types/mocks.d.ts vendored
View File

@ -3,7 +3,6 @@ declare module "mac-ca"
declare module "win-ca"
declare module "@hapi/call"
declare module "@hapi/subtext"
declare module "@lens/extensions" // todo: provide types
// Global path to static assets
declare const __static: string;

View File

@ -1,4 +1,4 @@
import { appName, htmlTemplate, isDevelopment, isProduction, buildDir, rendererDir, sassCommonVars, publicPath } from "./src/common/vars";
import { extensionApiLibName, appName, buildDir, extensionsDir, htmlTemplate, isDevelopment, isProduction, publicPath, rendererDir, sassCommonVars } from "./src/common/vars";
import path from "path";
import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
@ -16,6 +16,7 @@ export default function (): webpack.Configuration {
cache: isDevelopment,
entry: {
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
[extensionApiLibName]: path.resolve(extensionsDir, "extension-api.ts"), // todo: use separated tsconfig.json?
},
output: {
publicPath: publicPath,
@ -25,9 +26,6 @@ export default function (): webpack.Configuration {
libraryTarget: "commonjs2",
},
resolve: {
alias: {
// "@lens/extensions": "" // todo: replace in runtime to "build/LensExtensionApi.js"?
},
extensions: [
'.js', '.jsx', '.json',
'.ts', '.tsx',
@ -154,6 +152,7 @@ export default function (): webpack.Configuration {
filename: `${appName}.html`,
template: htmlTemplate,
inject: true,
excludeChunks: [extensionApiLibName],
}),
new MiniCssExtractPlugin({