@lvce-editor/renderer-process 13.15.0 → 13.16.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/dist/rendererProcessMain.js +99 -33
- package/package.json +1 -1
|
@@ -297,9 +297,9 @@ const initializeModule = module => {
|
|
|
297
297
|
for (const [key, value] of Object.entries(module.Commands)) {
|
|
298
298
|
if (module.name) {
|
|
299
299
|
const actualKey = `${module.name}.${key}`;
|
|
300
|
-
register(actualKey, value);
|
|
300
|
+
register$1(actualKey, value);
|
|
301
301
|
} else {
|
|
302
|
-
register(key, value);
|
|
302
|
+
register$1(key, value);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
return;
|
|
@@ -327,7 +327,7 @@ const getOrLoadModule = moduleId => {
|
|
|
327
327
|
const loadCommand = async command => {
|
|
328
328
|
await getOrLoadModule(getModuleId(command));
|
|
329
329
|
};
|
|
330
|
-
const register = (commandId, listener) => {
|
|
330
|
+
const register$1 = (commandId, listener) => {
|
|
331
331
|
state$a.commands[commandId] = listener;
|
|
332
332
|
};
|
|
333
333
|
const hasThrown = new Set();
|
|
@@ -344,9 +344,9 @@ const executeCommandAsync = async (command, ...args) => {
|
|
|
344
344
|
hasThrown.add(command);
|
|
345
345
|
throw new Error(`Command did not register "${command}"`);
|
|
346
346
|
}
|
|
347
|
-
return execute(command, ...args);
|
|
347
|
+
return execute$1(command, ...args);
|
|
348
348
|
};
|
|
349
|
-
const execute = (command, ...args) => {
|
|
349
|
+
const execute$1 = (command, ...args) => {
|
|
350
350
|
if (command in state$a.commands) {
|
|
351
351
|
const fn = state$a.commands[command];
|
|
352
352
|
if (typeof fn !== 'function') {
|
|
@@ -839,30 +839,30 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
839
839
|
return invokeHelper(ipc, method, params, true);
|
|
840
840
|
};
|
|
841
841
|
|
|
842
|
-
const requiresSocket = () => {
|
|
842
|
+
const requiresSocket$1 = () => {
|
|
843
843
|
return false;
|
|
844
844
|
};
|
|
845
|
-
const preparePrettyError = error => {
|
|
845
|
+
const preparePrettyError$1 = error => {
|
|
846
846
|
return error;
|
|
847
847
|
};
|
|
848
|
-
const logError$
|
|
848
|
+
const logError$2 = error => {
|
|
849
849
|
// error is logged in renderer worker
|
|
850
850
|
};
|
|
851
|
-
const handleMessage = event => {
|
|
852
|
-
return handleJsonRpcMessage(event.target, event.data, execute, resolve, preparePrettyError, logError$
|
|
851
|
+
const handleMessage$1 = event => {
|
|
852
|
+
return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError$1, logError$2, requiresSocket$1);
|
|
853
853
|
};
|
|
854
854
|
|
|
855
|
-
const handleIpc = ipc => {
|
|
855
|
+
const handleIpc$1 = ipc => {
|
|
856
856
|
if ('addEventListener' in ipc) {
|
|
857
|
-
ipc.addEventListener('message', handleMessage);
|
|
857
|
+
ipc.addEventListener('message', handleMessage$1);
|
|
858
858
|
} else {
|
|
859
859
|
// deprevated
|
|
860
|
-
ipc.onmessage = handleMessage;
|
|
860
|
+
ipc.onmessage = handleMessage$1;
|
|
861
861
|
}
|
|
862
862
|
};
|
|
863
863
|
const unhandleIpc = ipc => {
|
|
864
864
|
if ('removeEventListener' in ipc) {
|
|
865
|
-
ipc.removeEventListener('message', handleMessage);
|
|
865
|
+
ipc.removeEventListener('message', handleMessage$1);
|
|
866
866
|
} else {
|
|
867
867
|
// deprecated
|
|
868
868
|
ipc.onmessage = null;
|
|
@@ -992,7 +992,7 @@ const state$9 = {
|
|
|
992
992
|
};
|
|
993
993
|
const hydrate$4 = async () => {
|
|
994
994
|
const ipc = await launchRendererWorker();
|
|
995
|
-
handleIpc(ipc);
|
|
995
|
+
handleIpc$1(ipc);
|
|
996
996
|
// @ts-expect-error
|
|
997
997
|
state$9.ipc = ipc;
|
|
998
998
|
};
|
|
@@ -3489,14 +3489,14 @@ const getMessage = error => {
|
|
|
3489
3489
|
return `Error: ${error}`;
|
|
3490
3490
|
};
|
|
3491
3491
|
|
|
3492
|
-
const logError = async (error, prefix = '') => {
|
|
3492
|
+
const logError$1 = async (error, prefix = '') => {
|
|
3493
3493
|
const prettyError = await prepare(error);
|
|
3494
3494
|
print(prettyError, prefix);
|
|
3495
3495
|
return prettyError;
|
|
3496
3496
|
};
|
|
3497
3497
|
const handleError$6 = async (error, notify = true, prefix = '') => {
|
|
3498
3498
|
try {
|
|
3499
|
-
const prettyError = await logError(error, prefix);
|
|
3499
|
+
const prettyError = await logError$1(error, prefix);
|
|
3500
3500
|
if (notify) {
|
|
3501
3501
|
alert(getMessage(prettyError));
|
|
3502
3502
|
}
|
|
@@ -3780,7 +3780,7 @@ const create$z = async ({
|
|
|
3780
3780
|
throw new IpcError$1(`worker must be of type Worker`);
|
|
3781
3781
|
}
|
|
3782
3782
|
const ipc = wrap(worker);
|
|
3783
|
-
handleIpc(ipc);
|
|
3783
|
+
handleIpc$1(ipc);
|
|
3784
3784
|
// TODO await promise
|
|
3785
3785
|
// TODO call separate method HandleMessagePort.handleMessagePort or
|
|
3786
3786
|
// HandleIncomingIpc.handleIncomingIpc
|
|
@@ -3794,17 +3794,6 @@ const IpcParentWithModuleWorkerWithMessagePort = {
|
|
|
3794
3794
|
create: create$z
|
|
3795
3795
|
};
|
|
3796
3796
|
|
|
3797
|
-
const handleIpcOnce = ipc => {
|
|
3798
|
-
if (ipc.addEventListener) {
|
|
3799
|
-
ipc.addEventListener('message', handleMessage, {
|
|
3800
|
-
once: true
|
|
3801
|
-
});
|
|
3802
|
-
} else {
|
|
3803
|
-
// deprecated
|
|
3804
|
-
ipc.onmessage = handleMessage;
|
|
3805
|
-
}
|
|
3806
|
-
};
|
|
3807
|
-
|
|
3808
3797
|
const normalizeLine = line => {
|
|
3809
3798
|
if (line.startsWith('Error: ')) {
|
|
3810
3799
|
return line.slice('Error: '.length);
|
|
@@ -4306,6 +4295,81 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
4306
4295
|
wrap: wrap$e
|
|
4307
4296
|
};
|
|
4308
4297
|
|
|
4298
|
+
const commands = Object.create(null);
|
|
4299
|
+
const register = commandMap => {
|
|
4300
|
+
Object.assign(commands, commandMap);
|
|
4301
|
+
};
|
|
4302
|
+
const getCommand = key => {
|
|
4303
|
+
return commands[key];
|
|
4304
|
+
};
|
|
4305
|
+
const execute = (command, ...args) => {
|
|
4306
|
+
const fn = getCommand(command);
|
|
4307
|
+
if (!fn) {
|
|
4308
|
+
throw new Error(`command not found ${command}`);
|
|
4309
|
+
}
|
|
4310
|
+
return fn(...args);
|
|
4311
|
+
};
|
|
4312
|
+
|
|
4313
|
+
const createRpc = ipc => {
|
|
4314
|
+
const rpc = {
|
|
4315
|
+
// @ts-ignore
|
|
4316
|
+
ipc,
|
|
4317
|
+
/**
|
|
4318
|
+
* @deprecated
|
|
4319
|
+
*/
|
|
4320
|
+
send(method, ...params) {
|
|
4321
|
+
send$1(ipc, method, ...params);
|
|
4322
|
+
},
|
|
4323
|
+
invoke(method, ...params) {
|
|
4324
|
+
return invoke$2(ipc, method, ...params);
|
|
4325
|
+
},
|
|
4326
|
+
invokeAndTransfer(method, ...params) {
|
|
4327
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
4328
|
+
},
|
|
4329
|
+
async dispose() {
|
|
4330
|
+
await ipc?.dispose();
|
|
4331
|
+
}
|
|
4332
|
+
};
|
|
4333
|
+
return rpc;
|
|
4334
|
+
};
|
|
4335
|
+
const requiresSocket = () => {
|
|
4336
|
+
return false;
|
|
4337
|
+
};
|
|
4338
|
+
const preparePrettyError = error => {
|
|
4339
|
+
return error;
|
|
4340
|
+
};
|
|
4341
|
+
const logError = () => {
|
|
4342
|
+
// handled by renderer worker
|
|
4343
|
+
};
|
|
4344
|
+
const handleMessage = event => {
|
|
4345
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
4346
|
+
const actualExecute = event?.target?.execute || execute;
|
|
4347
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
4348
|
+
};
|
|
4349
|
+
const handleIpc = ipc => {
|
|
4350
|
+
if ('addEventListener' in ipc) {
|
|
4351
|
+
ipc.addEventListener('message', handleMessage);
|
|
4352
|
+
} else if ('on' in ipc) {
|
|
4353
|
+
// deprecated
|
|
4354
|
+
ipc.on('message', handleMessage);
|
|
4355
|
+
}
|
|
4356
|
+
};
|
|
4357
|
+
const create$f$1 = async ({
|
|
4358
|
+
commandMap,
|
|
4359
|
+
window
|
|
4360
|
+
}) => {
|
|
4361
|
+
// TODO create a commandMap per rpc instance
|
|
4362
|
+
register(commandMap);
|
|
4363
|
+
const ipc = IpcChildWithElectronWindow$1.wrap(window);
|
|
4364
|
+
handleIpc(ipc);
|
|
4365
|
+
const rpc = createRpc(ipc);
|
|
4366
|
+
return rpc;
|
|
4367
|
+
};
|
|
4368
|
+
const ElectronWindowRpcClient = {
|
|
4369
|
+
__proto__: null,
|
|
4370
|
+
create: create$f$1
|
|
4371
|
+
};
|
|
4372
|
+
|
|
4309
4373
|
// TODO use handleIncomingIpc function
|
|
4310
4374
|
const create$y = async ({
|
|
4311
4375
|
port,
|
|
@@ -4315,9 +4379,11 @@ const create$y = async ({
|
|
|
4315
4379
|
if (!isElectron) {
|
|
4316
4380
|
throw new Error('Electron api was requested but is not available');
|
|
4317
4381
|
}
|
|
4318
|
-
const
|
|
4319
|
-
|
|
4320
|
-
|
|
4382
|
+
const rpc = await ElectronWindowRpcClient.create({
|
|
4383
|
+
commandMap: {},
|
|
4384
|
+
window
|
|
4385
|
+
});
|
|
4386
|
+
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
4321
4387
|
return webContentsIds;
|
|
4322
4388
|
};
|
|
4323
4389
|
|
|
@@ -11113,7 +11179,7 @@ const handleMessagePort = async port => {
|
|
|
11113
11179
|
method: MessagePort$1,
|
|
11114
11180
|
port
|
|
11115
11181
|
});
|
|
11116
|
-
handleIpc(ipc);
|
|
11182
|
+
handleIpc$1(ipc);
|
|
11117
11183
|
};
|
|
11118
11184
|
|
|
11119
11185
|
const name$1 = 'HandleMessagePort';
|