-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add function to launch iframe worker (#55)
* feature: add function to launch iframe worker * move code * move code * remove code * move code * use ts * add get * update preferences * register command * lint
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ension-host-worker/src/parts/GetConfiguredIframeWorkerUrl/GetConfiguredIframeWorkerUrl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as IframeWorkerUrl from '../IframeWorkerUrl/IframeWorkerUrl.ts' | ||
import * as IsProduction from '../IsProduction/IsProduction.ts' | ||
import * as Preferences from '../Preferences/Preferences.ts' | ||
|
||
export const getConfiguredIframeWorkerUrl = async () => { | ||
let configuredWorkerUrl = (await Preferences.get('develop.iframeWorkerPath')) || '' | ||
if (configuredWorkerUrl) { | ||
configuredWorkerUrl = '/remote' + configuredWorkerUrl | ||
} | ||
configuredWorkerUrl = configuredWorkerUrl || IframeWorkerUrl.iframeWorkerUrl | ||
if (IsProduction.isProduction) { | ||
configuredWorkerUrl = IframeWorkerUrl.iframeWorkerUrl | ||
} | ||
return configuredWorkerUrl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const state = { | ||
id: 0, | ||
} | ||
|
||
export const create = () => { | ||
return ++state.id | ||
} |
1 change: 1 addition & 0 deletions
1
packages/extension-host-worker/src/parts/IsProduction/IsProduction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const isProduction = false |
19 changes: 19 additions & 0 deletions
19
packages/extension-host-worker/src/parts/LaunchIframeWorker/LaunchIframeWorker.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as GetConfiguredIframeWorkerUrl from '../GetConfiguredIframeWorkerUrl/GetConfiguredIframeWorkerUrl.ts' | ||
import * as HandleIpc from '../HandleIpc/HandleIpc.ts' | ||
import * as Id from '../Id/Id.ts' | ||
import * as IpcParent from '../IpcParent/IpcParent.ts' | ||
import * as IpcParentType from '../IpcParentType/IpcParentType.ts' | ||
|
||
export const launchIframeWorker = async () => { | ||
const configuredWorkerUrl = GetConfiguredIframeWorkerUrl.getConfiguredIframeWorkerUrl() | ||
const name = 'Iframe Worker' | ||
const id = Id.create() | ||
const ipc = await IpcParent.create({ | ||
method: IpcParentType.ModuleWorkerAndWorkaroundForChromeDevtoolsBug, | ||
name, | ||
url: configuredWorkerUrl, | ||
id, | ||
}) | ||
HandleIpc.handleIpc(ipc) | ||
return ipc | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/extension-host-worker/src/parts/Preferences/Preferences.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as ParentRpc from '../Rpc/Rpc.ts' | ||
|
||
export const get = (key: string): Promise<string> => { | ||
return ParentRpc.invoke('Preferences.get', key) | ||
} |