@lvce-editor/renderer-process 7.0.0 → 7.0.1
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 +70 -25
- package/package.json +1 -1
|
@@ -756,7 +756,7 @@ const isSocket = value => {
|
|
|
756
756
|
return isInstanceOf(value, 'Socket');
|
|
757
757
|
};
|
|
758
758
|
const transferrables = [isMessagePort$1, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
759
|
-
const isTransferrable = value => {
|
|
759
|
+
const isTransferrable$1 = value => {
|
|
760
760
|
for (const fn of transferrables) {
|
|
761
761
|
if (fn(value)) {
|
|
762
762
|
return true;
|
|
@@ -764,28 +764,28 @@ const isTransferrable = value => {
|
|
|
764
764
|
}
|
|
765
765
|
return false;
|
|
766
766
|
};
|
|
767
|
-
const walkValue = (value, transferrables) => {
|
|
767
|
+
const walkValue$1 = (value, transferrables) => {
|
|
768
768
|
if (!value) {
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
|
-
if (isTransferrable(value)) {
|
|
771
|
+
if (isTransferrable$1(value)) {
|
|
772
772
|
transferrables.push(value);
|
|
773
773
|
}
|
|
774
774
|
if (Array.isArray(value)) {
|
|
775
775
|
for (const item of value) {
|
|
776
|
-
walkValue(item, transferrables);
|
|
776
|
+
walkValue$1(item, transferrables);
|
|
777
777
|
}
|
|
778
778
|
return;
|
|
779
779
|
}
|
|
780
780
|
if (typeof value === 'object') {
|
|
781
781
|
for (const property of Object.values(value)) {
|
|
782
|
-
walkValue(property, transferrables);
|
|
782
|
+
walkValue$1(property, transferrables);
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
785
|
};
|
|
786
786
|
const getTransferrables = value => {
|
|
787
787
|
const transferrables = [];
|
|
788
|
-
walkValue(value, transferrables);
|
|
788
|
+
walkValue$1(value, transferrables);
|
|
789
789
|
return transferrables;
|
|
790
790
|
};
|
|
791
791
|
const isSingleTransferrable = value => {
|
|
@@ -5503,14 +5503,14 @@ class Ipc extends EventTarget {
|
|
|
5503
5503
|
}
|
|
5504
5504
|
}
|
|
5505
5505
|
const readyMessage = 'ready';
|
|
5506
|
-
const listen$
|
|
5506
|
+
const listen$4 = () => {
|
|
5507
5507
|
// @ts-ignore
|
|
5508
5508
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
5509
5509
|
throw new TypeError('module is not in web worker scope');
|
|
5510
5510
|
}
|
|
5511
5511
|
return globalThis;
|
|
5512
5512
|
};
|
|
5513
|
-
const signal$
|
|
5513
|
+
const signal$3 = global => {
|
|
5514
5514
|
global.postMessage(readyMessage);
|
|
5515
5515
|
};
|
|
5516
5516
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -5535,14 +5535,14 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
5535
5535
|
this._rawIpc.addEventListener('message', callback);
|
|
5536
5536
|
}
|
|
5537
5537
|
}
|
|
5538
|
-
const wrap$
|
|
5538
|
+
const wrap$6 = global => {
|
|
5539
5539
|
return new IpcChildWithModuleWorker(global);
|
|
5540
5540
|
};
|
|
5541
5541
|
const IpcChildWithModuleWorker$1 = {
|
|
5542
5542
|
__proto__: null,
|
|
5543
|
-
listen: listen$
|
|
5544
|
-
signal: signal$
|
|
5545
|
-
wrap: wrap$
|
|
5543
|
+
listen: listen$4,
|
|
5544
|
+
signal: signal$3,
|
|
5545
|
+
wrap: wrap$6
|
|
5546
5546
|
};
|
|
5547
5547
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
5548
5548
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
@@ -5760,10 +5760,10 @@ const waitForFirstMessage = async port => {
|
|
|
5760
5760
|
// @ts-ignore
|
|
5761
5761
|
return event.data;
|
|
5762
5762
|
};
|
|
5763
|
-
const listen$
|
|
5764
|
-
const parentIpcRaw = listen$
|
|
5765
|
-
signal$
|
|
5766
|
-
const parentIpc = wrap$
|
|
5763
|
+
const listen$3 = async () => {
|
|
5764
|
+
const parentIpcRaw = listen$4();
|
|
5765
|
+
signal$3(parentIpcRaw);
|
|
5766
|
+
const parentIpc = wrap$6(parentIpcRaw);
|
|
5767
5767
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
5768
5768
|
if (firstMessage.method !== 'initialize') {
|
|
5769
5769
|
throw new IpcError$1('unexpected first message');
|
|
@@ -5802,13 +5802,54 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
5802
5802
|
this._rawIpc.start();
|
|
5803
5803
|
}
|
|
5804
5804
|
}
|
|
5805
|
-
const wrap$
|
|
5805
|
+
const wrap$5 = port => {
|
|
5806
5806
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
5807
5807
|
};
|
|
5808
5808
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
5809
5809
|
__proto__: null,
|
|
5810
|
-
listen: listen$
|
|
5811
|
-
wrap: wrap$
|
|
5810
|
+
listen: listen$3,
|
|
5811
|
+
wrap: wrap$5
|
|
5812
|
+
};
|
|
5813
|
+
const isTransferrable = value => {
|
|
5814
|
+
return value instanceof MessagePort;
|
|
5815
|
+
};
|
|
5816
|
+
const walkValue = (value, transferrables) => {
|
|
5817
|
+
if (!value) {
|
|
5818
|
+
return value;
|
|
5819
|
+
}
|
|
5820
|
+
if (isTransferrable(value)) {
|
|
5821
|
+
transferrables.push(value);
|
|
5822
|
+
return undefined;
|
|
5823
|
+
}
|
|
5824
|
+
if (Array.isArray(value)) {
|
|
5825
|
+
const newItems = [];
|
|
5826
|
+
for (const item of value) {
|
|
5827
|
+
const newItem = walkValue(item, transferrables);
|
|
5828
|
+
newItems.push(newItem);
|
|
5829
|
+
}
|
|
5830
|
+
return newItems;
|
|
5831
|
+
}
|
|
5832
|
+
if (typeof value === 'object') {
|
|
5833
|
+
const newObject = Object.create(null);
|
|
5834
|
+
for (const [key, property] of Object.entries(value)) {
|
|
5835
|
+
const newValue = walkValue(property, transferrables);
|
|
5836
|
+
newObject[key] = newValue;
|
|
5837
|
+
}
|
|
5838
|
+
return newObject;
|
|
5839
|
+
}
|
|
5840
|
+
return value;
|
|
5841
|
+
};
|
|
5842
|
+
|
|
5843
|
+
// workaround for electron not supporting transferrable objects
|
|
5844
|
+
// as parameters. If the transferrable object is a parameter, in electron
|
|
5845
|
+
// only an empty objected is received in the main process
|
|
5846
|
+
const fixElectronParameters = value => {
|
|
5847
|
+
const transfer = [];
|
|
5848
|
+
const newValue = walkValue(value, transfer);
|
|
5849
|
+
return {
|
|
5850
|
+
newValue,
|
|
5851
|
+
transfer
|
|
5852
|
+
};
|
|
5812
5853
|
};
|
|
5813
5854
|
const listen$1 = () => {
|
|
5814
5855
|
return window;
|
|
@@ -5823,8 +5864,12 @@ class IpcChildWithWindow extends Ipc {
|
|
|
5823
5864
|
send(message) {
|
|
5824
5865
|
this._rawIpc.postMessage(message);
|
|
5825
5866
|
}
|
|
5826
|
-
sendAndTransfer(message,
|
|
5827
|
-
|
|
5867
|
+
sendAndTransfer(message, _transfer) {
|
|
5868
|
+
const {
|
|
5869
|
+
newValue,
|
|
5870
|
+
transfer
|
|
5871
|
+
} = fixElectronParameters(message);
|
|
5872
|
+
this._rawIpc.postMessage(newValue, location.origin, transfer);
|
|
5828
5873
|
}
|
|
5829
5874
|
dispose() {
|
|
5830
5875
|
// ignore
|
|
@@ -5849,13 +5894,13 @@ class IpcChildWithWindow extends Ipc {
|
|
|
5849
5894
|
const wrap$3 = window => {
|
|
5850
5895
|
return new IpcChildWithWindow(window);
|
|
5851
5896
|
};
|
|
5852
|
-
const
|
|
5897
|
+
const IpcChildWithElectronWindow = {
|
|
5853
5898
|
__proto__: null,
|
|
5854
5899
|
listen: listen$1,
|
|
5855
5900
|
signal: signal$1,
|
|
5856
5901
|
wrap: wrap$3
|
|
5857
5902
|
};
|
|
5858
|
-
const listen$
|
|
5903
|
+
const listen$2 = ({
|
|
5859
5904
|
port
|
|
5860
5905
|
}) => {
|
|
5861
5906
|
return port;
|
|
@@ -5892,7 +5937,7 @@ const wrap$2 = port => {
|
|
|
5892
5937
|
};
|
|
5893
5938
|
const IpcChildWithMessagePort$1 = {
|
|
5894
5939
|
__proto__: null,
|
|
5895
|
-
listen: listen$
|
|
5940
|
+
listen: listen$2,
|
|
5896
5941
|
signal,
|
|
5897
5942
|
wrap: wrap$2
|
|
5898
5943
|
};
|
|
@@ -6195,7 +6240,7 @@ const create$x = async ({
|
|
|
6195
6240
|
if (!isElectron) {
|
|
6196
6241
|
throw new Error('Electron api was requested but is not available');
|
|
6197
6242
|
}
|
|
6198
|
-
const windowIpc =
|
|
6243
|
+
const windowIpc = IpcChildWithElectronWindow.wrap(window);
|
|
6199
6244
|
handleIpcOnce(windowIpc);
|
|
6200
6245
|
const webContentsIds = await invokeAndTransfer$1(windowIpc, 'CreateMessagePort.createMessagePort', ipcId, port);
|
|
6201
6246
|
return webContentsIds;
|