diff --git a/package.json b/package.json index 710fa47d..3e4bfe2d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "type-check": "tsc", "build": "node scripts/build.js", "build:watch": "nodemon", - "lint": "eslint ." + "lint": "eslint .", + "format": "prettier --write ." }, "keywords": [ "Lvce Editor", @@ -119,7 +120,7 @@ "coverageThreshold": { "global": { "branches": 47, - "functions": 43, + "functions": 40, "lines": 60 } } diff --git a/rollup.config.js b/rollup.config.js index 3076e45d..fb0a81e6 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -8,11 +8,7 @@ import pluginTypeScript from '@babel/preset-typescript' const options = { input: 'src/previewProcessMain.ts', preserveEntrySignatures: 'strict', - external: [ - '@lvce-editor/ipc', - '@lvce-editor/json-rpc', - '@lvce-editor/verror', - ], + external: ['@lvce-editor/ipc', '@lvce-editor/json-rpc', '@lvce-editor/verror'], treeshake: { propertyReadSideEffects: false, }, diff --git a/src/parts/CommandMap/CommandMap.ts b/src/parts/CommandMap/CommandMap.ts index 0def620d..877f1817 100644 --- a/src/parts/CommandMap/CommandMap.ts +++ b/src/parts/CommandMap/CommandMap.ts @@ -1,5 +1,6 @@ import * as CreateWebViewServer from '../CreateWebViewServer/CreateWebViewServer.ts' import * as HandleElectronMessagePort from '../HandleElectronMessagePort/HandleElectronMessagePort.ts' +import * as SetInfo from '../SetInfo/SetInfo.ts' import * as SetWebViewServerHandler from '../SetWebViewServerHandler/SetWebViewServerHandler.ts' import * as StartWebViewServer from '../StartWebViewServer/StartWebViewServer.ts' import * as WebViewProtocol from '../WebViewProtocol/WebViewProtocol.ts' @@ -10,4 +11,5 @@ export const commandMap = { 'WebViewServer.create': CreateWebViewServer.createWebViewServer, 'WebViewServer.setHandler': SetWebViewServerHandler.setWebViewServerHandler, 'WebViewServer.start': StartWebViewServer.startWebViewServer, + 'WebViewServer.setInfo': SetInfo.setInfo, } diff --git a/src/parts/Info.ts b/src/parts/Info.ts new file mode 100644 index 00000000..b5b80c86 --- /dev/null +++ b/src/parts/Info.ts @@ -0,0 +1,4 @@ +export interface Info { + readonly webViewRoot: string + readonly webViewId: string +} diff --git a/src/parts/InfoRegistry/InfoRegistry.ts b/src/parts/InfoRegistry/InfoRegistry.ts new file mode 100644 index 00000000..b271a7aa --- /dev/null +++ b/src/parts/InfoRegistry/InfoRegistry.ts @@ -0,0 +1,17 @@ +import type { Info } from '../Info.ts' + +interface State { + [key: string]: Info +} + +export const state: State = { + infos: Object.create(null), +} + +export const set = (webViewId: string, info: Info): void => { + state[webViewId] = info +} + +export const get = (webViewId: string): Info => { + return state[webViewId] +} diff --git a/src/parts/SetInfo/SetInfo.ts b/src/parts/SetInfo/SetInfo.ts new file mode 100644 index 00000000..4dcc29aa --- /dev/null +++ b/src/parts/SetInfo/SetInfo.ts @@ -0,0 +1,10 @@ +import * as CreateWebViewServerHandler from '../CreateWebViewServerHandler/CreateWebViewServerHandler.ts' +import * as InfoRegistry from '../InfoRegistry/InfoRegistry.ts' +import * as WebViewServerState from '../WebViewServerState/WebViewServerState.ts' + +export const setInfo = (id: number, webViewId: string, webViewRoot: string): void => { + InfoRegistry.set(webViewId, { + webViewId, + webViewRoot, + }) +}