@lvce-editor/renderer-process 30.75.1 → 30.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/rendererProcessMain.js +38 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
1
|
# Renderer Process
|
|
2
|
+
|
|
3
|
+
Set `preloadWorkers` in the HTML `Config` JSON to select workers to create early:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"preloadWorkers": ["rendererWorker", "editorWorker", "syntaxHighlightingWorker", "extensionManagementWorker", "fileSystemWorker"]
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
These five workers are the default when the field is absent or is not an array. An empty array disables optional preloading. Renderer Worker always starts because it bootstraps the application. Unknown IDs are ignored and duplicates are created once. Omitted workers remain available on demand. Precreated workers use the existing port handoff, so initialization still runs through their normal parent worker. Worker URLs can be overridden with `workerUrls` in the same config.
|
|
@@ -5121,6 +5121,33 @@ const hydrate$2 = async () => {
|
|
|
5121
5121
|
return success(undefined);
|
|
5122
5122
|
};
|
|
5123
5123
|
|
|
5124
|
+
const preloadWorker = async (name, packageName, fileName, settingName) => {
|
|
5125
|
+
const {
|
|
5126
|
+
port1,
|
|
5127
|
+
port2
|
|
5128
|
+
} = new MessageChannel();
|
|
5129
|
+
const workerUrls = getConfiguredWorkerUrl('workerUrls');
|
|
5130
|
+
const url = workerUrls?.[settingName] || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/${packageName}/dist/${fileName}`;
|
|
5131
|
+
try {
|
|
5132
|
+
const pending = create$t({
|
|
5133
|
+
method: ModuleWorkerWithMessagePort,
|
|
5134
|
+
name,
|
|
5135
|
+
parentName: 'Renderer Worker',
|
|
5136
|
+
port: port1,
|
|
5137
|
+
url
|
|
5138
|
+
});
|
|
5139
|
+
// Start creation before caching, so our own request cannot consume this port.
|
|
5140
|
+
set$8(name, port2);
|
|
5141
|
+
await pending;
|
|
5142
|
+
return success(undefined);
|
|
5143
|
+
} catch (error) {
|
|
5144
|
+
remove$4(name);
|
|
5145
|
+
port1.close();
|
|
5146
|
+
port2.close();
|
|
5147
|
+
return error$1(error);
|
|
5148
|
+
}
|
|
5149
|
+
};
|
|
5150
|
+
|
|
5124
5151
|
const getConfiguredSyntaxHighlightingWorkerUrl = () => {
|
|
5125
5152
|
const syntaxHighlightingWorkerUrl = getConfiguredWorkerUrl('syntaxHighlightingWorkerUrl');
|
|
5126
5153
|
if (syntaxHighlightingWorkerUrl) {
|
|
@@ -5163,14 +5190,19 @@ const hydrate$1 = async () => {
|
|
|
5163
5190
|
return success(undefined);
|
|
5164
5191
|
};
|
|
5165
5192
|
|
|
5166
|
-
const
|
|
5167
|
-
const additionalWorkerFns =
|
|
5168
|
-
|
|
5169
|
-
|
|
5193
|
+
const defaultPreloadWorkers = ['rendererWorker', 'editorWorker', 'syntaxHighlightingWorker', 'extensionManagementWorker', 'fileSystemWorker'];
|
|
5194
|
+
const additionalWorkerFns = {
|
|
5195
|
+
editorWorker: hydrate$2,
|
|
5196
|
+
extensionManagementWorker: () => preloadWorker('Extension Management Worker', 'extension-management-worker', 'extensionManagementWorkerMain.js', 'develop.extensionManagementWorkerPath'),
|
|
5197
|
+
fileSystemWorker: () => preloadWorker('File System Worker', 'file-system-worker', 'fileSystemWorkerMain.js', 'develop.fileSystemWorkerPath'),
|
|
5198
|
+
syntaxHighlightingWorker: hydrate$1
|
|
5170
5199
|
};
|
|
5171
5200
|
const launchWorkers = async () => {
|
|
5172
|
-
const
|
|
5173
|
-
const
|
|
5201
|
+
const configured = getConfiguredWorkerUrl('preloadWorkers');
|
|
5202
|
+
const preloadWorkers = Array.isArray(configured) ? configured : defaultPreloadWorkers;
|
|
5203
|
+
// Renderer Worker is the application bootstrap and always starts. Unknown IDs are ignored.
|
|
5204
|
+
const optionalWorkers = [...new Set(preloadWorkers)].filter(id => Object.hasOwn(additionalWorkerFns, id)).map(id => additionalWorkerFns[id]) ;
|
|
5205
|
+
const results = await Promise.all([hydrate$4(), ...optionalWorkers.map(fn => fn())]);
|
|
5174
5206
|
const firstError = results.find(isError);
|
|
5175
5207
|
if (firstError) {
|
|
5176
5208
|
return firstError;
|