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:
parent
e93c53ff0c
commit
a6a0a6eddf
@ -15,11 +15,11 @@
|
|||||||
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
|
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
|
||||||
"dev:main": "yarn compile:main --watch",
|
"dev:main": "yarn compile:main --watch",
|
||||||
"dev:renderer": "yarn compile:renderer --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": "env NODE_ENV=production concurrently yarn:compile:*",
|
||||||
"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-extensions": "tsc --project src/extensions --watch",
|
|
||||||
"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",
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export const isDevelopment = isDebugging || !isProduction;
|
|||||||
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
||||||
|
|
||||||
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`
|
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`
|
||||||
|
export const extensionApiLibName = `${appName}-extensions.api`
|
||||||
export const publicPath = "/build/"
|
export const publicPath = "/build/"
|
||||||
|
|
||||||
// Webpack build paths
|
// Webpack build paths
|
||||||
@ -18,6 +19,7 @@ export const contextDir = process.cwd();
|
|||||||
export const buildDir = path.join(contextDir, "static", publicPath);
|
export const buildDir = path.join(contextDir, "static", publicPath);
|
||||||
export const mainDir = path.join(contextDir, "src/main");
|
export const mainDir = path.join(contextDir, "src/main");
|
||||||
export const rendererDir = path.join(contextDir, "src/renderer");
|
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 htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
// fixme: hook up generated types from extension-api.ts (tsc --declaration)
|
// fixme: provide runtime import / webpack.resolve.alias / require.extensions (?)
|
||||||
// fixme: provide compile or runtime import
|
|
||||||
import { LensExtension } from "@lens/extensions";
|
import { LensExtension } from "@lens/extensions";
|
||||||
|
|
||||||
export default class ExampleExtension extends LensExtension {
|
export default class ExampleExtension extends LensExtension {
|
||||||
@ -8,7 +7,3 @@ export default class ExampleExtension extends LensExtension {
|
|||||||
return super.init();
|
return super.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const someData = {
|
|
||||||
title: "it works"
|
|
||||||
}
|
|
||||||
@ -11,10 +11,10 @@
|
|||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true
|
||||||
"declaration": true
|
|
||||||
},
|
},
|
||||||
"include": [
|
"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
12
src/extensions/extension-api.mock.d.ts
vendored
Normal 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
1
types/mocks.d.ts
vendored
@ -3,7 +3,6 @@ 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;
|
||||||
|
|||||||
@ -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 path from "path";
|
||||||
import webpack from "webpack";
|
import webpack from "webpack";
|
||||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||||
@ -16,6 +16,7 @@ export default function (): webpack.Configuration {
|
|||||||
cache: isDevelopment,
|
cache: isDevelopment,
|
||||||
entry: {
|
entry: {
|
||||||
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
||||||
|
[extensionApiLibName]: path.resolve(extensionsDir, "extension-api.ts"), // todo: use separated tsconfig.json?
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
publicPath: publicPath,
|
publicPath: publicPath,
|
||||||
@ -25,9 +26,6 @@ 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',
|
||||||
@ -154,6 +152,7 @@ export default function (): webpack.Configuration {
|
|||||||
filename: `${appName}.html`,
|
filename: `${appName}.html`,
|
||||||
template: htmlTemplate,
|
template: htmlTemplate,
|
||||||
inject: true,
|
inject: true,
|
||||||
|
excludeChunks: [extensionApiLibName],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user