@lvce-editor/renderer-process 7.0.1 → 7.1.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 +123 -91
- package/package.json +1 -1
|
@@ -740,67 +740,6 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
740
740
|
}
|
|
741
741
|
throw new JsonRpcError('unexpected response message');
|
|
742
742
|
};
|
|
743
|
-
const isMessagePort$1 = value => {
|
|
744
|
-
return typeof MessagePort !== 'undefined' && value instanceof MessagePort;
|
|
745
|
-
};
|
|
746
|
-
const isInstanceOf = (value, constructorName) => {
|
|
747
|
-
return value?.constructor?.name === constructorName;
|
|
748
|
-
};
|
|
749
|
-
const isMessagePortMain = value => {
|
|
750
|
-
return isInstanceOf(value, 'MessagePortMain');
|
|
751
|
-
};
|
|
752
|
-
const isOffscreenCanvas = value => {
|
|
753
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
754
|
-
};
|
|
755
|
-
const isSocket = value => {
|
|
756
|
-
return isInstanceOf(value, 'Socket');
|
|
757
|
-
};
|
|
758
|
-
const transferrables = [isMessagePort$1, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
759
|
-
const isTransferrable$1 = value => {
|
|
760
|
-
for (const fn of transferrables) {
|
|
761
|
-
if (fn(value)) {
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
return false;
|
|
766
|
-
};
|
|
767
|
-
const walkValue$1 = (value, transferrables) => {
|
|
768
|
-
if (!value) {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
if (isTransferrable$1(value)) {
|
|
772
|
-
transferrables.push(value);
|
|
773
|
-
}
|
|
774
|
-
if (Array.isArray(value)) {
|
|
775
|
-
for (const item of value) {
|
|
776
|
-
walkValue$1(item, transferrables);
|
|
777
|
-
}
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
if (typeof value === 'object') {
|
|
781
|
-
for (const property of Object.values(value)) {
|
|
782
|
-
walkValue$1(property, transferrables);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
const getTransferrables = value => {
|
|
787
|
-
const transferrables = [];
|
|
788
|
-
walkValue$1(value, transferrables);
|
|
789
|
-
return transferrables;
|
|
790
|
-
};
|
|
791
|
-
const isSingleTransferrable = value => {
|
|
792
|
-
return isSocket(value);
|
|
793
|
-
};
|
|
794
|
-
const getTransferrableParams = value => {
|
|
795
|
-
const transferrables = getTransferrables(value);
|
|
796
|
-
if (transferrables.length === 0) {
|
|
797
|
-
return undefined;
|
|
798
|
-
}
|
|
799
|
-
if (isSingleTransferrable(transferrables[0])) {
|
|
800
|
-
return transferrables[0];
|
|
801
|
-
}
|
|
802
|
-
return transferrables;
|
|
803
|
-
};
|
|
804
743
|
const create$1$1 = (message, error) => {
|
|
805
744
|
return {
|
|
806
745
|
jsonrpc: Two,
|
|
@@ -927,17 +866,15 @@ const invoke$2 = async (ipc, method, ...params) => {
|
|
|
927
866
|
// TODO deprecated old typings,
|
|
928
867
|
// always use automatic transferrable detection
|
|
929
868
|
const invokeAndTransfer$1 = async (ipc, handle, method, ...params) => {
|
|
930
|
-
let transfer = handle;
|
|
931
869
|
if (typeof handle === 'string') {
|
|
932
870
|
params = [method, ...params];
|
|
933
871
|
method = handle;
|
|
934
|
-
transfer = getTransferrableParams(params);
|
|
935
872
|
}
|
|
936
873
|
const {
|
|
937
874
|
message,
|
|
938
875
|
promise
|
|
939
876
|
} = create$2$1(method, params);
|
|
940
|
-
ipc.sendAndTransfer(message
|
|
877
|
+
ipc.sendAndTransfer(message);
|
|
941
878
|
const responseMessage = await promise;
|
|
942
879
|
const result = unwrapJsonRpcResult(responseMessage);
|
|
943
880
|
return result;
|
|
@@ -1008,6 +945,49 @@ const create$L = async ({
|
|
|
1008
945
|
return module.create(options);
|
|
1009
946
|
};
|
|
1010
947
|
|
|
948
|
+
const transferrables$1 = [];
|
|
949
|
+
if (typeof MessagePort !== 'undefined') {
|
|
950
|
+
transferrables$1.push(MessagePort);
|
|
951
|
+
}
|
|
952
|
+
if (typeof OffscreenCanvas !== 'undefined') {
|
|
953
|
+
transferrables$1.push(OffscreenCanvas);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
const isTransferrable$1 = value => {
|
|
957
|
+
for (const fn of transferrables$1) {
|
|
958
|
+
if (value instanceof fn) {
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return false;
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
const walkValue$1 = (value, transferrables) => {
|
|
966
|
+
if (!value) {
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
if (isTransferrable$1(value)) {
|
|
970
|
+
transferrables.push(value);
|
|
971
|
+
}
|
|
972
|
+
if (Array.isArray(value)) {
|
|
973
|
+
for (const item of value) {
|
|
974
|
+
walkValue$1(item, transferrables);
|
|
975
|
+
}
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
if (typeof value === 'object') {
|
|
979
|
+
for (const property of Object.values(value)) {
|
|
980
|
+
walkValue$1(property, transferrables);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
const getTransfer = value => {
|
|
986
|
+
const transferrables = [];
|
|
987
|
+
walkValue$1(value, transferrables);
|
|
988
|
+
return transferrables;
|
|
989
|
+
};
|
|
990
|
+
|
|
1011
991
|
const getData$2 = event => {
|
|
1012
992
|
// TODO why are some events not instance of message event?
|
|
1013
993
|
if (event instanceof MessageEvent) {
|
|
@@ -1031,9 +1011,10 @@ const launchWorker = async ({
|
|
|
1031
1011
|
// @ts-ignore
|
|
1032
1012
|
this.worker.postMessage(message);
|
|
1033
1013
|
},
|
|
1034
|
-
sendAndTransfer(message
|
|
1014
|
+
sendAndTransfer(message) {
|
|
1015
|
+
const transfer = getTransfer(message);
|
|
1035
1016
|
// @ts-ignore
|
|
1036
|
-
this.worker.postMessage(message,
|
|
1017
|
+
this.worker.postMessage(message, transfer);
|
|
1037
1018
|
},
|
|
1038
1019
|
get onmessage() {
|
|
1039
1020
|
return this.handleMessage;
|
|
@@ -1109,9 +1090,9 @@ const send = (method, ...params) => {
|
|
|
1109
1090
|
const invoke$1 = (method, ...params) => {
|
|
1110
1091
|
return invoke$2(state$9.ipc, method, ...params);
|
|
1111
1092
|
};
|
|
1112
|
-
const sendAndTransfer =
|
|
1093
|
+
const sendAndTransfer = message => {
|
|
1113
1094
|
// @ts-expect-error
|
|
1114
|
-
state$9.ipc.sendAndTransfer(message
|
|
1095
|
+
state$9.ipc.sendAndTransfer(message);
|
|
1115
1096
|
};
|
|
1116
1097
|
const invokeAndTransfer = (method, ...params) => {
|
|
1117
1098
|
return invokeAndTransfer$1(state$9.ipc, method, ...params);
|
|
@@ -5482,6 +5463,58 @@ const ModuleWorkerAndMessagePort = 8;
|
|
|
5482
5463
|
const getData$1 = event => {
|
|
5483
5464
|
return event.data;
|
|
5484
5465
|
};
|
|
5466
|
+
const isMessagePort$1 = value => {
|
|
5467
|
+
return value && value instanceof MessagePort;
|
|
5468
|
+
};
|
|
5469
|
+
const isMessagePortMain = value => {
|
|
5470
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
5471
|
+
};
|
|
5472
|
+
const isOffscreenCanvas = value => {
|
|
5473
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
5474
|
+
};
|
|
5475
|
+
const isInstanceOf = (value, constructorName) => {
|
|
5476
|
+
return value?.constructor?.name === constructorName;
|
|
5477
|
+
};
|
|
5478
|
+
const isSocket = value => {
|
|
5479
|
+
return isInstanceOf(value, 'Socket');
|
|
5480
|
+
};
|
|
5481
|
+
const transferrables = [isMessagePort$1, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
5482
|
+
const isTransferrable = value => {
|
|
5483
|
+
for (const fn of transferrables) {
|
|
5484
|
+
if (fn(value)) {
|
|
5485
|
+
return true;
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
return false;
|
|
5489
|
+
};
|
|
5490
|
+
const walkValue = (value, transferrables) => {
|
|
5491
|
+
if (!value) {
|
|
5492
|
+
return value;
|
|
5493
|
+
}
|
|
5494
|
+
if (isTransferrable(value)) {
|
|
5495
|
+
transferrables.push(value);
|
|
5496
|
+
return;
|
|
5497
|
+
}
|
|
5498
|
+
if (Array.isArray(value)) {
|
|
5499
|
+
for (const item of value) {
|
|
5500
|
+
walkValue(item, transferrables);
|
|
5501
|
+
}
|
|
5502
|
+
return;
|
|
5503
|
+
}
|
|
5504
|
+
if (typeof value === 'object') {
|
|
5505
|
+
const newObject = Object.create(null);
|
|
5506
|
+
for (const property of Object.values(value)) {
|
|
5507
|
+
walkValue(property, transferrables);
|
|
5508
|
+
}
|
|
5509
|
+
return newObject;
|
|
5510
|
+
}
|
|
5511
|
+
return value;
|
|
5512
|
+
};
|
|
5513
|
+
const getTransferrables = value => {
|
|
5514
|
+
const transferrables = [];
|
|
5515
|
+
walkValue(value, transferrables);
|
|
5516
|
+
return transferrables;
|
|
5517
|
+
};
|
|
5485
5518
|
const attachEvents$a = that => {
|
|
5486
5519
|
const handleMessage = (...args) => {
|
|
5487
5520
|
const data = that.getData(...args);
|
|
@@ -5521,7 +5554,8 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
5521
5554
|
// @ts-ignore
|
|
5522
5555
|
this._rawIpc.postMessage(message);
|
|
5523
5556
|
}
|
|
5524
|
-
sendAndTransfer(message
|
|
5557
|
+
sendAndTransfer(message) {
|
|
5558
|
+
const transfer = getTransferrables(message);
|
|
5525
5559
|
// @ts-ignore
|
|
5526
5560
|
this._rawIpc.postMessage(message, transfer);
|
|
5527
5561
|
}
|
|
@@ -5786,7 +5820,8 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
5786
5820
|
send(message) {
|
|
5787
5821
|
this._rawIpc.postMessage(message);
|
|
5788
5822
|
}
|
|
5789
|
-
sendAndTransfer(message
|
|
5823
|
+
sendAndTransfer(message) {
|
|
5824
|
+
const transfer = getTransferrables(message);
|
|
5790
5825
|
this._rawIpc.postMessage(message, transfer);
|
|
5791
5826
|
}
|
|
5792
5827
|
dispose() {
|
|
@@ -5810,30 +5845,25 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
5810
5845
|
listen: listen$3,
|
|
5811
5846
|
wrap: wrap$5
|
|
5812
5847
|
};
|
|
5813
|
-
const
|
|
5814
|
-
return value instanceof MessagePort;
|
|
5815
|
-
};
|
|
5816
|
-
const walkValue = (value, transferrables) => {
|
|
5848
|
+
const removeValues = (value, toRemove) => {
|
|
5817
5849
|
if (!value) {
|
|
5818
5850
|
return value;
|
|
5819
5851
|
}
|
|
5820
|
-
if (isTransferrable(value)) {
|
|
5821
|
-
transferrables.push(value);
|
|
5822
|
-
return undefined;
|
|
5823
|
-
}
|
|
5824
5852
|
if (Array.isArray(value)) {
|
|
5825
5853
|
const newItems = [];
|
|
5826
5854
|
for (const item of value) {
|
|
5827
|
-
|
|
5828
|
-
|
|
5855
|
+
if (!toRemove.includes(item)) {
|
|
5856
|
+
newItems.push(removeValues(item, toRemove));
|
|
5857
|
+
}
|
|
5829
5858
|
}
|
|
5830
5859
|
return newItems;
|
|
5831
5860
|
}
|
|
5832
5861
|
if (typeof value === 'object') {
|
|
5833
5862
|
const newObject = Object.create(null);
|
|
5834
5863
|
for (const [key, property] of Object.entries(value)) {
|
|
5835
|
-
|
|
5836
|
-
|
|
5864
|
+
if (!toRemove.includes(property)) {
|
|
5865
|
+
newObject[key] = removeValues(property, toRemove);
|
|
5866
|
+
}
|
|
5837
5867
|
}
|
|
5838
5868
|
return newObject;
|
|
5839
5869
|
}
|
|
@@ -5844,8 +5874,8 @@ const walkValue = (value, transferrables) => {
|
|
|
5844
5874
|
// as parameters. If the transferrable object is a parameter, in electron
|
|
5845
5875
|
// only an empty objected is received in the main process
|
|
5846
5876
|
const fixElectronParameters = value => {
|
|
5847
|
-
const transfer =
|
|
5848
|
-
const newValue =
|
|
5877
|
+
const transfer = getTransferrables(value);
|
|
5878
|
+
const newValue = removeValues(value, transfer);
|
|
5849
5879
|
return {
|
|
5850
5880
|
newValue,
|
|
5851
5881
|
transfer
|
|
@@ -5857,14 +5887,14 @@ const listen$1 = () => {
|
|
|
5857
5887
|
const signal$1 = global => {
|
|
5858
5888
|
global.postMessage(readyMessage);
|
|
5859
5889
|
};
|
|
5860
|
-
class
|
|
5890
|
+
class IpcChildWithElectronWindow extends Ipc {
|
|
5861
5891
|
getData(event) {
|
|
5862
5892
|
return getData$1(event);
|
|
5863
5893
|
}
|
|
5864
5894
|
send(message) {
|
|
5865
5895
|
this._rawIpc.postMessage(message);
|
|
5866
5896
|
}
|
|
5867
|
-
sendAndTransfer(message
|
|
5897
|
+
sendAndTransfer(message) {
|
|
5868
5898
|
const {
|
|
5869
5899
|
newValue,
|
|
5870
5900
|
transfer
|
|
@@ -5892,9 +5922,9 @@ class IpcChildWithWindow extends Ipc {
|
|
|
5892
5922
|
}
|
|
5893
5923
|
}
|
|
5894
5924
|
const wrap$3 = window => {
|
|
5895
|
-
return new
|
|
5925
|
+
return new IpcChildWithElectronWindow(window);
|
|
5896
5926
|
};
|
|
5897
|
-
const IpcChildWithElectronWindow = {
|
|
5927
|
+
const IpcChildWithElectronWindow$1 = {
|
|
5898
5928
|
__proto__: null,
|
|
5899
5929
|
listen: listen$1,
|
|
5900
5930
|
signal: signal$1,
|
|
@@ -5918,7 +5948,8 @@ class IpcChildWithMessagePort extends Ipc {
|
|
|
5918
5948
|
send(message) {
|
|
5919
5949
|
this._rawIpc.postMessage(message);
|
|
5920
5950
|
}
|
|
5921
|
-
sendAndTransfer(message
|
|
5951
|
+
sendAndTransfer(message) {
|
|
5952
|
+
const transfer = getTransferrables(message);
|
|
5922
5953
|
this._rawIpc.postMessage(message, transfer);
|
|
5923
5954
|
}
|
|
5924
5955
|
dispose() {
|
|
@@ -6134,7 +6165,8 @@ const wrap = worker => {
|
|
|
6134
6165
|
send(message) {
|
|
6135
6166
|
worker.postMessage(message);
|
|
6136
6167
|
},
|
|
6137
|
-
sendAndTransfer(message
|
|
6168
|
+
sendAndTransfer(message) {
|
|
6169
|
+
const transfer = getTransfer(message);
|
|
6138
6170
|
worker.postMessage(message, transfer);
|
|
6139
6171
|
}
|
|
6140
6172
|
};
|
|
@@ -6240,7 +6272,7 @@ const create$x = async ({
|
|
|
6240
6272
|
if (!isElectron) {
|
|
6241
6273
|
throw new Error('Electron api was requested but is not available');
|
|
6242
6274
|
}
|
|
6243
|
-
const windowIpc = IpcChildWithElectronWindow.wrap(window);
|
|
6275
|
+
const windowIpc = IpcChildWithElectronWindow$1.wrap(window);
|
|
6244
6276
|
handleIpcOnce(windowIpc);
|
|
6245
6277
|
const webContentsIds = await invokeAndTransfer$1(windowIpc, 'CreateMessagePort.createMessagePort', ipcId, port);
|
|
6246
6278
|
return webContentsIds;
|