mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rework extension API into parts (#2879)
* `Main`, `Common`, and `Renderer` * move registry types to Common.Types Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
db54a658a2
commit
df1f6e128e
28 files changed
+227
-161
No files matched your search
File renamed without changes.
@@ -25,6 +25,7 @@ import { catalogEntityRegistry as registry } from "../../main/catalog";
|
||||
|
||||
export { catalogCategoryRegistry as catalogCategories } from "../../common/catalog/catalog-category-registry";
|
||||
export * from "../../common/catalog-entities";
|
||||
export * from "../../common/catalog/catalog-entity";
|
||||
|
||||
export class CatalogEntityRegistry {
|
||||
getItemsForApiKind<T extends CatalogEntity>(apiVersion: string, kind: string): T[] {
|
||||
File renamed without changes.
@@ -19,27 +19,19 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Lens-extensions api developer's kit
|
||||
export { LensMainExtension } from "../lens-main-extension";
|
||||
export { LensRendererExtension } from "../lens-renderer-extension";
|
||||
|
||||
// APIs
|
||||
import * as App from "./app";
|
||||
import * as EventBus from "./event-bus";
|
||||
import * as Store from "./stores";
|
||||
import * as Util from "./utils";
|
||||
import * as Interface from "../interfaces";
|
||||
import * as Catalog from "./catalog";
|
||||
import * as Types from "./types";
|
||||
import * as Ipc from "./ipc";
|
||||
|
||||
export {
|
||||
App,
|
||||
EventBus,
|
||||
Catalog,
|
||||
Interface,
|
||||
Store,
|
||||
Types,
|
||||
Util,
|
||||
Ipc,
|
||||
};
|
||||
File renamed without changes.
File renamed without changes.
@@ -22,3 +22,5 @@
|
||||
export type IpcMainInvokeEvent = Electron.IpcMainInvokeEvent;
|
||||
export type IpcRendererEvent = Electron.IpcRendererEvent;
|
||||
export type IpcMainEvent = Electron.IpcMainEvent;
|
||||
|
||||
export * from "./registrations";
|
||||
File renamed without changes.
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export { IpcMain as Main } from "../ipc/ipc-main";
|
||||
export { IpcRegistrar as Registrar } from "../ipc/ipc-registrar";
|
||||
@@ -22,5 +22,12 @@
|
||||
// Extensions-api types bundle (main + renderer)
|
||||
// Available for lens-extensions via NPM-package "@k8slens/extensions"
|
||||
|
||||
export * from "./core-api";
|
||||
export * from "./renderer-api";
|
||||
import * as Common from "./common-api";
|
||||
import * as Renderer from "./renderer-api";
|
||||
import * as Main from "./main-api";
|
||||
|
||||
export {
|
||||
Common,
|
||||
Renderer,
|
||||
Main,
|
||||
};
|
||||
@@ -337,7 +337,11 @@ export class ExtensionLoader extends Singleton {
|
||||
try {
|
||||
return __non_webpack_require__(extAbsolutePath).default;
|
||||
} catch (error) {
|
||||
logger.error(`${logModule}: can't load extension main at ${extAbsolutePath}: ${error}`, { extension, error });
|
||||
if (ipcRenderer) {
|
||||
console.error(`${logModule}: can't load ${entryPointName} for "${extension.manifest.name}": ${error.stack || error}`, extension);
|
||||
} else {
|
||||
logger.error(`${logModule}: can't load ${entryPointName} for "${extension.manifest.name}": ${error}`, { extension });
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export * from "../../common/catalog/catalog-entity";
|
||||
@@ -19,5 +19,10 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export * from "./registrations";
|
||||
export * from "./catalog";
|
||||
import { IpcMain as Ipc } from "../ipc/ipc-main";
|
||||
import { LensMainExtension as LensExtension } from "../lens-main-extension";
|
||||
|
||||
export {
|
||||
Ipc,
|
||||
LensExtension,
|
||||
};
|
||||
@@ -26,10 +26,14 @@ import * as Component from "./components";
|
||||
import * as K8sApi from "./k8s-api";
|
||||
import * as Navigation from "./navigation";
|
||||
import * as Theme from "./theming";
|
||||
import { IpcRenderer as Ipc } from "../ipc/ipc-renderer";
|
||||
import { LensRendererExtension as LensExtension } from "../lens-renderer-extension";
|
||||
|
||||
export {
|
||||
Component,
|
||||
K8sApi,
|
||||
Navigation,
|
||||
Theme,
|
||||
Ipc,
|
||||
LensExtension,
|
||||
};
|
||||
+4
-2
@@ -23,7 +23,8 @@
|
||||
|
||||
import "../common/system-ca";
|
||||
import * as Mobx from "mobx";
|
||||
import * as LensExtensionsCoreApi from "../extensions/core-api";
|
||||
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
||||
import * as LensExtensionsMainApi from "../extensions/main-api";
|
||||
import { app, autoUpdater, ipcMain, dialog, powerMonitor } from "electron";
|
||||
import { appName, isMac, productName } from "../common/vars";
|
||||
import path from "path";
|
||||
@@ -279,7 +280,8 @@ app.on("open-url", (event, rawUrl) => {
|
||||
* e.g. global.Mobx, global.LensExtensions
|
||||
*/
|
||||
const LensExtensions = {
|
||||
...LensExtensionsCoreApi,
|
||||
Common: LensExtensionsCommonApi,
|
||||
Main: LensExtensionsMainApi,
|
||||
};
|
||||
|
||||
export {
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as uuid from "uuid";
|
||||
import { broadcastMessage } from "../../../common/ipc";
|
||||
import { ProtocolHandlerExtension, ProtocolHandlerInternal } from "../../../common/protocol-handler";
|
||||
import { noop } from "../../../common/utils";
|
||||
import { LensMainExtension } from "../../../extensions/core-api";
|
||||
import { LensExtension } from "../../../extensions/main-api";
|
||||
import { ExtensionLoader } from "../../../extensions/extension-loader";
|
||||
import { ExtensionsStore } from "../../../extensions/extensions-store";
|
||||
import { LensProtocolRouterMain } from "../router";
|
||||
@@ -78,7 +78,7 @@ describe("protocol router tests", () => {
|
||||
|
||||
it.only("should not throw when has valid host", async () => {
|
||||
const extId = uuid.v4();
|
||||
const ext = new LensMainExtension({
|
||||
const ext = new LensExtension({
|
||||
id: extId,
|
||||
manifestPath: "/foo/bar",
|
||||
manifest: {
|
||||
@@ -155,7 +155,7 @@ describe("protocol router tests", () => {
|
||||
|
||||
const lpr = LensProtocolRouterMain.getInstance();
|
||||
const extId = uuid.v4();
|
||||
const ext = new LensMainExtension({
|
||||
const ext = new LensExtension({
|
||||
id: extId,
|
||||
manifestPath: "/foo/bar",
|
||||
manifest: {
|
||||
@@ -195,7 +195,7 @@ describe("protocol router tests", () => {
|
||||
|
||||
{
|
||||
const extId = uuid.v4();
|
||||
const ext = new LensMainExtension({
|
||||
const ext = new LensExtension({
|
||||
id: extId,
|
||||
manifestPath: "/foo/bar",
|
||||
manifest: {
|
||||
@@ -219,7 +219,7 @@ describe("protocol router tests", () => {
|
||||
|
||||
{
|
||||
const extId = uuid.v4();
|
||||
const ext = new LensMainExtension({
|
||||
const ext = new LensExtension({
|
||||
id: extId,
|
||||
manifestPath: "/foo/bar",
|
||||
manifest: {
|
||||
|
||||
@@ -26,7 +26,7 @@ import * as Mobx from "mobx";
|
||||
import * as MobxReact from "mobx-react";
|
||||
import * as ReactRouter from "react-router";
|
||||
import * as ReactRouterDom from "react-router-dom";
|
||||
import * as LensExtensionsCoreApi from "../extensions/core-api";
|
||||
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
||||
import * as LensExtensionsRendererApi from "../extensions/renderer-api";
|
||||
import { render, unmountComponentAtNode } from "react-dom";
|
||||
import { delay } from "../common/utils";
|
||||
@@ -123,8 +123,8 @@ bootstrap(process.isMainFrame ? LensApp : App);
|
||||
* e.g. Devtools -> Console -> window.LensExtensions (renderer)
|
||||
*/
|
||||
const LensExtensions = {
|
||||
...LensExtensionsCoreApi,
|
||||
...LensExtensionsRendererApi,
|
||||
Common: LensExtensionsCommonApi,
|
||||
Renderer: LensExtensionsRendererApi,
|
||||
};
|
||||
|
||||
export {
|
||||
|
||||
Reference in new issue
Block a user