add router

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2020-12-09 11:00:07 -05:00
1 parent 24b5352614
commit 62df81d955
7 files changed
+183 -3

No files matched your search

+7
View File
@@ -2,6 +2,7 @@ import type { InstalledExtension } from "./extension-discovery";
import { action, observable, reaction } from "mobx";
import { filesystemProvisionerStore } from "../main/extension-filesystem";
import logger from "../main/logger";
import { LensProtocolRouter, RouteHandler } from "../main/protocol-handler";
export type LensExtensionId = string; // path to manifest (package.json)
export type LensExtensionConstructor = new (...args: ConstructorParameters<typeof LensExtension>) => LensExtension;
@@ -49,6 +50,12 @@ export class LensExtension {
return filesystemProvisionerStore.requestDirectory(this.id);
}
onProtocolRequest(pathSchema: string, handler: RouteHandler): void {
const lpr = LensProtocolRouter.getInstance<LensProtocolRouter>();
lpr.extensionOn(this.id, pathSchema, handler);
}
get description() {
return this.manifest.description;
}