@lvce-editor/renderer-process 30.75.0 → 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 +53 -7
- 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.
|
|
@@ -4526,6 +4526,16 @@ const openFolder = async () => {
|
|
|
4526
4526
|
title: 'Open Folder'
|
|
4527
4527
|
});
|
|
4528
4528
|
};
|
|
4529
|
+
const openUrl$1 = async url => {
|
|
4530
|
+
const tauriWindow = window;
|
|
4531
|
+
const core = tauriWindow.__TAURI__?.core;
|
|
4532
|
+
if (!core) {
|
|
4533
|
+
throw new Error('Tauri is not available');
|
|
4534
|
+
}
|
|
4535
|
+
await core.invoke('open_external', {
|
|
4536
|
+
url
|
|
4537
|
+
});
|
|
4538
|
+
};
|
|
4529
4539
|
|
|
4530
4540
|
const getConfiguredDragAndDropWorkerUrl = () => {
|
|
4531
4541
|
const workerUrls = getConfiguredWorkerUrl('workerUrls');
|
|
@@ -5111,6 +5121,33 @@ const hydrate$2 = async () => {
|
|
|
5111
5121
|
return success(undefined);
|
|
5112
5122
|
};
|
|
5113
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
|
+
|
|
5114
5151
|
const getConfiguredSyntaxHighlightingWorkerUrl = () => {
|
|
5115
5152
|
const syntaxHighlightingWorkerUrl = getConfiguredWorkerUrl('syntaxHighlightingWorkerUrl');
|
|
5116
5153
|
if (syntaxHighlightingWorkerUrl) {
|
|
@@ -5153,14 +5190,19 @@ const hydrate$1 = async () => {
|
|
|
5153
5190
|
return success(undefined);
|
|
5154
5191
|
};
|
|
5155
5192
|
|
|
5156
|
-
const
|
|
5157
|
-
const additionalWorkerFns =
|
|
5158
|
-
|
|
5159
|
-
|
|
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
|
|
5160
5199
|
};
|
|
5161
5200
|
const launchWorkers = async () => {
|
|
5162
|
-
const
|
|
5163
|
-
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())]);
|
|
5164
5206
|
const firstError = results.find(isError);
|
|
5165
5207
|
if (firstError) {
|
|
5166
5208
|
return firstError;
|
|
@@ -11345,11 +11387,15 @@ const redirectToUrl = url => {
|
|
|
11345
11387
|
window.location.assign(url);
|
|
11346
11388
|
};
|
|
11347
11389
|
const openUrl = (url, useRedirect = false) => {
|
|
11390
|
+
if (isAvailable()) {
|
|
11391
|
+
return openUrl$1(url);
|
|
11392
|
+
}
|
|
11348
11393
|
if (useRedirect) {
|
|
11349
11394
|
redirectToUrl(url);
|
|
11350
|
-
return;
|
|
11395
|
+
return undefined;
|
|
11351
11396
|
}
|
|
11352
11397
|
window.open(url);
|
|
11398
|
+
return undefined;
|
|
11353
11399
|
};
|
|
11354
11400
|
|
|
11355
11401
|
const isElectronUserAgentSpecificMemoryError = error => {
|