@lvce-editor/renderer-process 7.0.2 → 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 +117 -90
- 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,24 +5845,15 @@ 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 UntransferrableValue = {};
|
|
5817
|
-
const walkValue = (value, transferrables) => {
|
|
5848
|
+
const removeValues = (value, toRemove) => {
|
|
5818
5849
|
if (!value) {
|
|
5819
5850
|
return value;
|
|
5820
5851
|
}
|
|
5821
|
-
if (isTransferrable(value)) {
|
|
5822
|
-
transferrables.push(value);
|
|
5823
|
-
return UntransferrableValue;
|
|
5824
|
-
}
|
|
5825
5852
|
if (Array.isArray(value)) {
|
|
5826
5853
|
const newItems = [];
|
|
5827
5854
|
for (const item of value) {
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
newItems.push(newItem);
|
|
5855
|
+
if (!toRemove.includes(item)) {
|
|
5856
|
+
newItems.push(removeValues(item, toRemove));
|
|
5831
5857
|
}
|
|
5832
5858
|
}
|
|
5833
5859
|
return newItems;
|
|
@@ -5835,9 +5861,8 @@ const walkValue = (value, transferrables) => {
|
|
|
5835
5861
|
if (typeof value === 'object') {
|
|
5836
5862
|
const newObject = Object.create(null);
|
|
5837
5863
|
for (const [key, property] of Object.entries(value)) {
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
newObject[key] = newValue;
|
|
5864
|
+
if (!toRemove.includes(property)) {
|
|
5865
|
+
newObject[key] = removeValues(property, toRemove);
|
|
5841
5866
|
}
|
|
5842
5867
|
}
|
|
5843
5868
|
return newObject;
|
|
@@ -5849,8 +5874,8 @@ const walkValue = (value, transferrables) => {
|
|
|
5849
5874
|
// as parameters. If the transferrable object is a parameter, in electron
|
|
5850
5875
|
// only an empty objected is received in the main process
|
|
5851
5876
|
const fixElectronParameters = value => {
|
|
5852
|
-
const transfer =
|
|
5853
|
-
const newValue =
|
|
5877
|
+
const transfer = getTransferrables(value);
|
|
5878
|
+
const newValue = removeValues(value, transfer);
|
|
5854
5879
|
return {
|
|
5855
5880
|
newValue,
|
|
5856
5881
|
transfer
|
|
@@ -5869,7 +5894,7 @@ class IpcChildWithElectronWindow extends Ipc {
|
|
|
5869
5894
|
send(message) {
|
|
5870
5895
|
this._rawIpc.postMessage(message);
|
|
5871
5896
|
}
|
|
5872
|
-
sendAndTransfer(message
|
|
5897
|
+
sendAndTransfer(message) {
|
|
5873
5898
|
const {
|
|
5874
5899
|
newValue,
|
|
5875
5900
|
transfer
|
|
@@ -5923,7 +5948,8 @@ class IpcChildWithMessagePort extends Ipc {
|
|
|
5923
5948
|
send(message) {
|
|
5924
5949
|
this._rawIpc.postMessage(message);
|
|
5925
5950
|
}
|
|
5926
|
-
sendAndTransfer(message
|
|
5951
|
+
sendAndTransfer(message) {
|
|
5952
|
+
const transfer = getTransferrables(message);
|
|
5927
5953
|
this._rawIpc.postMessage(message, transfer);
|
|
5928
5954
|
}
|
|
5929
5955
|
dispose() {
|
|
@@ -6139,7 +6165,8 @@ const wrap = worker => {
|
|
|
6139
6165
|
send(message) {
|
|
6140
6166
|
worker.postMessage(message);
|
|
6141
6167
|
},
|
|
6142
|
-
sendAndTransfer(message
|
|
6168
|
+
sendAndTransfer(message) {
|
|
6169
|
+
const transfer = getTransfer(message);
|
|
6143
6170
|
worker.postMessage(message, transfer);
|
|
6144
6171
|
}
|
|
6145
6172
|
};
|