@lvce-editor/ipc 11.0.0 → 11.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/electron.js +43 -35
- package/dist/index.js +69 -58
- package/package.json +1 -1
package/dist/electron.js
CHANGED
|
@@ -540,7 +540,7 @@ class ChildProcessError extends Error {
|
|
|
540
540
|
// workaround for node not supporting transferrable objects
|
|
541
541
|
// as parameters. If the transferrable object is a parameter,
|
|
542
542
|
// it is received as a plain object is received in the receiving process
|
|
543
|
-
const
|
|
543
|
+
const fixNodeChildProcessParameters = value => {
|
|
544
544
|
const transfer = getTransferrables(value);
|
|
545
545
|
if (transfer.length === 0) {
|
|
546
546
|
throw new IpcError('no transferrables found');
|
|
@@ -680,7 +680,7 @@ class IpcParentWithNodeForkedProcess extends Ipc {
|
|
|
680
680
|
const {
|
|
681
681
|
newValue,
|
|
682
682
|
transfer
|
|
683
|
-
} =
|
|
683
|
+
} = fixNodeChildProcessParameters(message);
|
|
684
684
|
this._rawIpc.send(newValue, transfer);
|
|
685
685
|
}
|
|
686
686
|
dispose() {
|
|
@@ -703,6 +703,17 @@ const IpcParentWithNodeForkedProcess$1 = {
|
|
|
703
703
|
wrap: wrap$2
|
|
704
704
|
};
|
|
705
705
|
|
|
706
|
+
const fixNodeWorkerParameters = value => {
|
|
707
|
+
const transfer = getTransferrables(value);
|
|
708
|
+
if (transfer.length === 0) {
|
|
709
|
+
throw new IpcError('no transferrables found');
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
newValue: value,
|
|
713
|
+
transfer: transfer
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
|
|
706
717
|
const addListener = (emitter, type, callback) => {
|
|
707
718
|
if ('addEventListener' in emitter) {
|
|
708
719
|
emitter.addEventListener(type, callback);
|
|
@@ -790,41 +801,38 @@ const create$1 = async ({
|
|
|
790
801
|
}
|
|
791
802
|
return worker;
|
|
792
803
|
};
|
|
793
|
-
|
|
794
|
-
|
|
804
|
+
class IpcParentWithNodeWorker extends Ipc {
|
|
805
|
+
constructor(worker) {
|
|
806
|
+
super(worker);
|
|
807
|
+
}
|
|
808
|
+
getData(message) {
|
|
809
|
+
return message;
|
|
810
|
+
}
|
|
811
|
+
send(message) {
|
|
812
|
+
this._rawIpc.postMessage(message);
|
|
813
|
+
}
|
|
814
|
+
sendAndTransfer(message) {
|
|
815
|
+
const {
|
|
816
|
+
newValue,
|
|
817
|
+
transfer
|
|
818
|
+
} = fixNodeWorkerParameters(message);
|
|
819
|
+
this._rawIpc.postMessage(newValue, transfer);
|
|
820
|
+
}
|
|
821
|
+
dispose() {
|
|
822
|
+
this._rawIpc.terminate();
|
|
823
|
+
}
|
|
824
|
+
onClose(callback) {
|
|
825
|
+
this._rawIpc.on('exit', callback);
|
|
826
|
+
}
|
|
827
|
+
onMessage(callback) {
|
|
828
|
+
this._rawIpc.on('message', callback);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
795
831
|
const wrap$1 = worker => {
|
|
796
|
-
return
|
|
797
|
-
worker,
|
|
798
|
-
// @ts-ignore
|
|
799
|
-
on(event, listener) {
|
|
800
|
-
const wrappedListener = message => {
|
|
801
|
-
const syntheticEvent = {
|
|
802
|
-
data: message,
|
|
803
|
-
target: this
|
|
804
|
-
};
|
|
805
|
-
listener(syntheticEvent);
|
|
806
|
-
};
|
|
807
|
-
this.worker.on(event, wrappedListener);
|
|
808
|
-
},
|
|
809
|
-
// @ts-ignore
|
|
810
|
-
send(message) {
|
|
811
|
-
this.worker.postMessage(message);
|
|
812
|
-
},
|
|
813
|
-
// @ts-ignore
|
|
814
|
-
sendAndTransfer(message) {
|
|
815
|
-
const {
|
|
816
|
-
newValue,
|
|
817
|
-
transfer
|
|
818
|
-
} = fixNodeParameters(message);
|
|
819
|
-
this.worker.postMessage(newValue, transfer);
|
|
820
|
-
},
|
|
821
|
-
dispose() {
|
|
822
|
-
this.worker.terminate();
|
|
823
|
-
}
|
|
824
|
-
};
|
|
832
|
+
return new IpcParentWithNodeWorker(worker);
|
|
825
833
|
};
|
|
826
834
|
|
|
827
|
-
const IpcParentWithNodeWorker = {
|
|
835
|
+
const IpcParentWithNodeWorker$1 = {
|
|
828
836
|
__proto__: null,
|
|
829
837
|
create: create$1,
|
|
830
838
|
wrap: wrap$1
|
|
@@ -891,4 +899,4 @@ const IpcParentWithElectronMessagePort$1 = {
|
|
|
891
899
|
wrap
|
|
892
900
|
};
|
|
893
901
|
|
|
894
|
-
export { IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|
|
902
|
+
export { IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker };
|
package/dist/index.js
CHANGED
|
@@ -641,32 +641,35 @@ const listen$2 = async () => {
|
|
|
641
641
|
const signal$2 = parentPort => {
|
|
642
642
|
parentPort.postMessage(readyMessage);
|
|
643
643
|
};
|
|
644
|
+
class IpcChildWithNodeWorker extends Ipc {
|
|
645
|
+
constructor(port) {
|
|
646
|
+
super(port);
|
|
647
|
+
}
|
|
648
|
+
getData(data) {
|
|
649
|
+
return data;
|
|
650
|
+
}
|
|
651
|
+
onClose(callback) {
|
|
652
|
+
this._rawIpc.on('close', callback);
|
|
653
|
+
}
|
|
654
|
+
send(message) {
|
|
655
|
+
this._rawIpc.postMessage(message);
|
|
656
|
+
}
|
|
657
|
+
onMessage(callback) {
|
|
658
|
+
this._rawIpc.on('message', callback);
|
|
659
|
+
}
|
|
660
|
+
sendAndTransfer(message) {
|
|
661
|
+
const transfer = getTransferrablesNode(message);
|
|
662
|
+
this._rawIpc.postMessage(message, transfer);
|
|
663
|
+
}
|
|
664
|
+
dispose() {
|
|
665
|
+
this._rawIpc.close();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
644
668
|
const wrap$6 = parentPort => {
|
|
645
|
-
return
|
|
646
|
-
parentPort,
|
|
647
|
-
on(event, listener) {
|
|
648
|
-
const wrappedListener = (message, handle) => {
|
|
649
|
-
const event = {
|
|
650
|
-
data: getActualData(message, handle),
|
|
651
|
-
target: this
|
|
652
|
-
};
|
|
653
|
-
listener(event);
|
|
654
|
-
};
|
|
655
|
-
this.parentPort.on(event, wrappedListener);
|
|
656
|
-
},
|
|
657
|
-
off(event, listener) {
|
|
658
|
-
this.parentPort.off(event, listener);
|
|
659
|
-
},
|
|
660
|
-
send(message) {
|
|
661
|
-
this.parentPort.postMessage(message);
|
|
662
|
-
},
|
|
663
|
-
dispose() {
|
|
664
|
-
this.parentPort.close();
|
|
665
|
-
}
|
|
666
|
-
};
|
|
669
|
+
return new IpcChildWithNodeWorker(parentPort);
|
|
667
670
|
};
|
|
668
671
|
|
|
669
|
-
const IpcChildWithNodeWorker = {
|
|
672
|
+
const IpcChildWithNodeWorker$1 = {
|
|
670
673
|
__proto__: null,
|
|
671
674
|
listen: listen$2,
|
|
672
675
|
signal: signal$2,
|
|
@@ -1121,7 +1124,7 @@ class ChildProcessError extends Error {
|
|
|
1121
1124
|
// workaround for node not supporting transferrable objects
|
|
1122
1125
|
// as parameters. If the transferrable object is a parameter,
|
|
1123
1126
|
// it is received as a plain object is received in the receiving process
|
|
1124
|
-
const
|
|
1127
|
+
const fixNodeChildProcessParameters = value => {
|
|
1125
1128
|
const transfer = getTransferrables(value);
|
|
1126
1129
|
if (transfer.length === 0) {
|
|
1127
1130
|
throw new IpcError('no transferrables found');
|
|
@@ -1261,7 +1264,7 @@ class IpcParentWithNodeForkedProcess extends Ipc {
|
|
|
1261
1264
|
const {
|
|
1262
1265
|
newValue,
|
|
1263
1266
|
transfer
|
|
1264
|
-
} =
|
|
1267
|
+
} = fixNodeChildProcessParameters(message);
|
|
1265
1268
|
this._rawIpc.send(newValue, transfer);
|
|
1266
1269
|
}
|
|
1267
1270
|
dispose() {
|
|
@@ -1284,6 +1287,17 @@ const IpcParentWithNodeForkedProcess$1 = {
|
|
|
1284
1287
|
wrap: wrap$1
|
|
1285
1288
|
};
|
|
1286
1289
|
|
|
1290
|
+
const fixNodeWorkerParameters = value => {
|
|
1291
|
+
const transfer = getTransferrables(value);
|
|
1292
|
+
if (transfer.length === 0) {
|
|
1293
|
+
throw new IpcError('no transferrables found');
|
|
1294
|
+
}
|
|
1295
|
+
return {
|
|
1296
|
+
newValue: value,
|
|
1297
|
+
transfer: transfer
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1287
1301
|
const getFirstNodeWorkerEvent = worker => {
|
|
1288
1302
|
return getFirstEvent(worker, {
|
|
1289
1303
|
message: Message,
|
|
@@ -1330,44 +1344,41 @@ const create = async ({
|
|
|
1330
1344
|
}
|
|
1331
1345
|
return worker;
|
|
1332
1346
|
};
|
|
1333
|
-
|
|
1334
|
-
|
|
1347
|
+
class IpcParentWithNodeWorker extends Ipc {
|
|
1348
|
+
constructor(worker) {
|
|
1349
|
+
super(worker);
|
|
1350
|
+
}
|
|
1351
|
+
getData(message) {
|
|
1352
|
+
return message;
|
|
1353
|
+
}
|
|
1354
|
+
send(message) {
|
|
1355
|
+
this._rawIpc.postMessage(message);
|
|
1356
|
+
}
|
|
1357
|
+
sendAndTransfer(message) {
|
|
1358
|
+
const {
|
|
1359
|
+
newValue,
|
|
1360
|
+
transfer
|
|
1361
|
+
} = fixNodeWorkerParameters(message);
|
|
1362
|
+
this._rawIpc.postMessage(newValue, transfer);
|
|
1363
|
+
}
|
|
1364
|
+
dispose() {
|
|
1365
|
+
this._rawIpc.terminate();
|
|
1366
|
+
}
|
|
1367
|
+
onClose(callback) {
|
|
1368
|
+
this._rawIpc.on('exit', callback);
|
|
1369
|
+
}
|
|
1370
|
+
onMessage(callback) {
|
|
1371
|
+
this._rawIpc.on('message', callback);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1335
1374
|
const wrap = worker => {
|
|
1336
|
-
return
|
|
1337
|
-
worker,
|
|
1338
|
-
// @ts-ignore
|
|
1339
|
-
on(event, listener) {
|
|
1340
|
-
const wrappedListener = message => {
|
|
1341
|
-
const syntheticEvent = {
|
|
1342
|
-
data: message,
|
|
1343
|
-
target: this
|
|
1344
|
-
};
|
|
1345
|
-
listener(syntheticEvent);
|
|
1346
|
-
};
|
|
1347
|
-
this.worker.on(event, wrappedListener);
|
|
1348
|
-
},
|
|
1349
|
-
// @ts-ignore
|
|
1350
|
-
send(message) {
|
|
1351
|
-
this.worker.postMessage(message);
|
|
1352
|
-
},
|
|
1353
|
-
// @ts-ignore
|
|
1354
|
-
sendAndTransfer(message) {
|
|
1355
|
-
const {
|
|
1356
|
-
newValue,
|
|
1357
|
-
transfer
|
|
1358
|
-
} = fixNodeParameters(message);
|
|
1359
|
-
this.worker.postMessage(newValue, transfer);
|
|
1360
|
-
},
|
|
1361
|
-
dispose() {
|
|
1362
|
-
this.worker.terminate();
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1375
|
+
return new IpcParentWithNodeWorker(worker);
|
|
1365
1376
|
};
|
|
1366
1377
|
|
|
1367
|
-
const IpcParentWithNodeWorker = {
|
|
1378
|
+
const IpcParentWithNodeWorker$1 = {
|
|
1368
1379
|
__proto__: null,
|
|
1369
1380
|
create,
|
|
1370
1381
|
wrap
|
|
1371
1382
|
};
|
|
1372
1383
|
|
|
1373
|
-
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess$1 as IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|
|
1384
|
+
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess$1 as IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker$1 as IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker };
|