@lvce-editor/ipc 11.7.0 → 12.0.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/index.js CHANGED
@@ -279,7 +279,7 @@ class IpcError extends VError {
279
279
  }
280
280
  }
281
281
 
282
- const listen$8 = ({
282
+ const listen$b = ({
283
283
  messagePort
284
284
  }) => {
285
285
  if (!isMessagePortMain(messagePort)) {
@@ -287,7 +287,7 @@ const listen$8 = ({
287
287
  }
288
288
  return messagePort;
289
289
  };
290
- const signal$8 = messagePort => {
290
+ const signal$b = messagePort => {
291
291
  messagePort.start();
292
292
  };
293
293
  class IpcChildWithElectronMessagePort extends Ipc {
@@ -315,15 +315,15 @@ class IpcChildWithElectronMessagePort extends Ipc {
315
315
  this._rawIpc.on('close', callback);
316
316
  }
317
317
  }
318
- const wrap$f = messagePort => {
318
+ const wrap$i = messagePort => {
319
319
  return new IpcChildWithElectronMessagePort(messagePort);
320
320
  };
321
321
 
322
322
  const IpcChildWithElectronMessagePort$1 = {
323
323
  __proto__: null,
324
- listen: listen$8,
325
- signal: signal$8,
326
- wrap: wrap$f
324
+ listen: listen$b,
325
+ signal: signal$b,
326
+ wrap: wrap$i
327
327
  };
328
328
 
329
329
  // @ts-ignore
@@ -343,7 +343,7 @@ const getUtilityProcessPortData = event => {
343
343
 
344
344
  const readyMessage = 'ready';
345
345
 
346
- const listen$7 = () => {
346
+ const listen$a = () => {
347
347
  // @ts-ignore
348
348
  const {
349
349
  parentPort
@@ -353,7 +353,7 @@ const listen$7 = () => {
353
353
  }
354
354
  return parentPort;
355
355
  };
356
- const signal$7 = parentPort => {
356
+ const signal$a = parentPort => {
357
357
  parentPort.postMessage(readyMessage);
358
358
  };
359
359
  class IpcChildWithElectronUtilityProcess extends Ipc {
@@ -380,29 +380,124 @@ class IpcChildWithElectronUtilityProcess extends Ipc {
380
380
  this._rawIpc.on('message', callback);
381
381
  }
382
382
  }
383
- const wrap$e = parentPort => {
383
+ const wrap$h = parentPort => {
384
384
  return new IpcChildWithElectronUtilityProcess(parentPort);
385
385
  };
386
386
 
387
387
  const IpcChildWithElectronUtilityProcess$1 = {
388
388
  __proto__: null,
389
- listen: listen$7,
390
- signal: signal$7,
391
- wrap: wrap$e
389
+ listen: listen$a,
390
+ signal: signal$a,
391
+ wrap: wrap$h
392
392
  };
393
393
 
394
394
  const getData$2 = event => {
395
395
  return event.data;
396
396
  };
397
397
 
398
- const listen$6 = () => {
398
+ const listen$9 = () => {
399
+ return window;
400
+ };
401
+ const signal$9 = global => {
402
+ global.postMessage(readyMessage);
403
+ };
404
+ class IpcChildWithElectronWindow extends Ipc {
405
+ getData(event) {
406
+ return getData$2(event);
407
+ }
408
+ send(message) {
409
+ this._rawIpc.postMessage(message);
410
+ }
411
+ sendAndTransfer(message) {
412
+ const {
413
+ newValue,
414
+ transfer
415
+ } = fixElectronParameters(message);
416
+ this._rawIpc.postMessage(newValue, location.origin, transfer);
417
+ }
418
+ dispose() {
419
+ // ignore
420
+ }
421
+ onClose(callback) {
422
+ // ignore
423
+ }
424
+ onMessage(callback) {
425
+ const wrapped = event => {
426
+ const {
427
+ ports
428
+ } = event;
429
+ if (ports.length) {
430
+ return;
431
+ }
432
+ callback(event);
433
+ this._rawIpc.removeEventListener('message', wrapped);
434
+ };
435
+ this._rawIpc.addEventListener('message', wrapped);
436
+ }
437
+ }
438
+ const wrap$g = window => {
439
+ return new IpcChildWithElectronWindow(window);
440
+ };
441
+
442
+ const IpcChildWithElectronWindow$1 = {
443
+ __proto__: null,
444
+ listen: listen$9,
445
+ signal: signal$9,
446
+ wrap: wrap$g
447
+ };
448
+
449
+ const listen$8 = ({
450
+ port
451
+ }) => {
452
+ return port;
453
+ };
454
+ const signal$8 = port => {
455
+ port.postMessage(readyMessage);
456
+ };
457
+ class IpcChildWithMessagePort extends Ipc {
458
+ constructor(port) {
459
+ super(port);
460
+ }
461
+ getData(event) {
462
+ return getData$2(event);
463
+ }
464
+ send(message) {
465
+ this._rawIpc.postMessage(message);
466
+ }
467
+ sendAndTransfer(message) {
468
+ const transfer = getTransferrables(message);
469
+ this._rawIpc.postMessage(message, transfer);
470
+ }
471
+ dispose() {
472
+ // ignore
473
+ }
474
+ onClose(callback) {
475
+ // ignore
476
+ }
477
+ onMessage(callback) {
478
+ this._rawIpc.addEventListener('message', callback);
479
+ this._rawIpc.start();
480
+ }
481
+ }
482
+ const wrap$f = port => {
483
+ return new IpcChildWithMessagePort(port);
484
+ };
485
+
486
+ const IpcChildWithMessagePort$1 = {
487
+ __proto__: null,
488
+ listen: listen$8,
489
+ signal: signal$8,
490
+ wrap: wrap$f
491
+ };
492
+
493
+ const listen$7 = () => {
399
494
  // @ts-ignore
400
495
  if (typeof WorkerGlobalScope === 'undefined') {
401
496
  throw new TypeError('module is not in web worker scope');
402
497
  }
403
498
  return globalThis;
404
499
  };
405
- const signal$6 = global => {
500
+ const signal$7 = global => {
406
501
  global.postMessage(readyMessage);
407
502
  };
408
503
  class IpcChildWithModuleWorker extends Ipc {
@@ -428,15 +523,15 @@ class IpcChildWithModuleWorker extends Ipc {
428
523
  this._rawIpc.addEventListener('message', callback);
429
524
  }
430
525
  }
431
- const wrap$d = global => {
526
+ const wrap$e = global => {
432
527
  return new IpcChildWithModuleWorker(global);
433
528
  };
434
529
 
435
530
  const IpcChildWithModuleWorker$1 = {
436
531
  __proto__: null,
437
- listen: listen$6,
438
- signal: signal$6,
439
- wrap: wrap$d
532
+ listen: listen$7,
533
+ signal: signal$7,
534
+ wrap: wrap$e
440
535
  };
441
536
 
442
537
  const withResolvers = () => {
@@ -463,10 +558,10 @@ const waitForFirstMessage = async port => {
463
558
  return event.data;
464
559
  };
465
560
 
466
- const listen$5 = async () => {
467
- const parentIpcRaw = listen$6();
468
- signal$6(parentIpcRaw);
469
- const parentIpc = wrap$d(parentIpcRaw);
561
+ const listen$6 = async () => {
562
+ const parentIpcRaw = listen$7();
563
+ signal$7(parentIpcRaw);
564
+ const parentIpc = wrap$e(parentIpcRaw);
470
565
  const firstMessage = await waitForFirstMessage(parentIpc);
471
566
  if (firstMessage.method !== 'initialize') {
472
567
  throw new IpcError('unexpected first message');
@@ -511,14 +606,14 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
511
606
  this._rawIpc.start();
512
607
  }
513
608
  }
514
- const wrap$c = port => {
609
+ const wrap$d = port => {
515
610
  return new IpcChildWithModuleWorkerAndMessagePort(port);
516
611
  };
517
612
 
518
613
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
519
614
  __proto__: null,
520
- listen: listen$5,
521
- wrap: wrap$c
615
+ listen: listen$6,
616
+ wrap: wrap$d
522
617
  };
523
618
 
524
619
  const getTransferrablesNode = value => {
@@ -539,13 +634,13 @@ const getActualData = (message, handle) => {
539
634
  return message;
540
635
  };
541
636
 
542
- const listen$4 = async () => {
637
+ const listen$5 = async () => {
543
638
  if (!process.send) {
544
639
  throw new Error('process.send must be defined');
545
640
  }
546
641
  return process;
547
642
  };
548
- const signal$5 = process => {
643
+ const signal$6 = process => {
549
644
  process.send(readyMessage);
550
645
  };
551
646
  class IpcChildWithNodeForkedProcess extends Ipc {
@@ -572,18 +667,18 @@ class IpcChildWithNodeForkedProcess extends Ipc {
572
667
  // ignore
573
668
  }
574
669
  }
575
- const wrap$b = process => {
670
+ const wrap$c = process => {
576
671
  return new IpcChildWithNodeForkedProcess(process);
577
672
  };
578
673
 
579
674
  const IpcChildWithNodeForkedProcess$1 = {
580
675
  __proto__: null,
581
- listen: listen$4,
582
- signal: signal$5,
583
- wrap: wrap$b
676
+ listen: listen$5,
677
+ signal: signal$6,
678
+ wrap: wrap$c
584
679
  };
585
680
 
586
- const listen$3 = async ({
681
+ const listen$4 = async ({
587
682
  messagePort
588
683
  }) => {
589
684
  if (!isMessagePort(messagePort)) {
@@ -591,10 +686,10 @@ const listen$3 = async ({
591
686
  }
592
687
  return messagePort;
593
688
  };
594
- const signal$4 = messagePort => {
689
+ const signal$5 = messagePort => {
595
690
  messagePort.start();
596
691
  };
597
- const wrap$a = port => {
692
+ const wrap$b = port => {
598
693
  return {
599
694
  port,
600
695
  on(event, listener) {
@@ -624,12 +719,12 @@ const wrap$a = port => {
624
719
 
625
720
  const IpcChildWithNodeMessagePort = {
626
721
  __proto__: null,
627
- listen: listen$3,
628
- signal: signal$4,
629
- wrap: wrap$a
722
+ listen: listen$4,
723
+ signal: signal$5,
724
+ wrap: wrap$b
630
725
  };
631
726
 
632
- const listen$2 = async () => {
727
+ const listen$3 = async () => {
633
728
  const {
634
729
  parentPort
635
730
  } = await import('node:worker_threads');
@@ -638,7 +733,7 @@ const listen$2 = async () => {
638
733
  }
639
734
  return parentPort;
640
735
  };
641
- const signal$3 = parentPort => {
736
+ const signal$4 = parentPort => {
642
737
  parentPort.postMessage(readyMessage);
643
738
  };
644
739
  class IpcChildWithNodeWorker extends Ipc {
@@ -665,19 +760,19 @@ class IpcChildWithNodeWorker extends Ipc {
665
760
  this._rawIpc.close();
666
761
  }
667
762
  }
668
- const wrap$9 = parentPort => {
763
+ const wrap$a = parentPort => {
669
764
  return new IpcChildWithNodeWorker(parentPort);
670
765
  };
671
766
 
672
767
  const IpcChildWithNodeWorker$1 = {
673
768
  __proto__: null,
674
- listen: listen$2,
675
- signal: signal$3,
676
- wrap: wrap$9
769
+ listen: listen$3,
770
+ signal: signal$4,
771
+ wrap: wrap$a
677
772
  };
678
773
 
679
774
  const preloadChannelType = 'port';
680
- const listen$1 = ({
775
+ const listen$2 = ({
681
776
  webContents
682
777
  }) => {
683
778
  return webContents;
@@ -714,14 +809,14 @@ class IpcChildWithRendererProcess2 extends Ipc {
714
809
  this._rawIpc.on('destroyed', callback);
715
810
  }
716
811
  }
717
- const wrap$8 = webContents => {
812
+ const wrap$9 = webContents => {
718
813
  return new IpcChildWithRendererProcess2(webContents);
719
814
  };
720
815
 
721
816
  const IpcChildWithRendererProcess2$1 = {
722
817
  __proto__: null,
723
- listen: listen$1,
724
- wrap: wrap$8
818
+ listen: listen$2,
819
+ wrap: wrap$9
725
820
  };
726
821
 
727
822
  const Open = 1;
@@ -825,7 +920,7 @@ const handleUpgrade = async (...args) => {
825
920
  };
826
921
 
827
922
  // @ts-ignore
828
- const listen = async ({
923
+ const listen$1 = async ({
829
924
  request,
830
925
  handle
831
926
  }) => {
@@ -842,12 +937,12 @@ const listen = async ({
842
937
  }
843
938
  return webSocket;
844
939
  };
845
- const signal$2 = webSocket => {
940
+ const signal$3 = webSocket => {
846
941
  webSocket.resume();
847
942
  };
848
943
 
849
944
  // @ts-ignore
850
- const wrap$7 = webSocket => {
945
+ const wrap$8 = webSocket => {
851
946
  return {
852
947
  webSocket,
853
948
  /**
@@ -895,6 +990,54 @@ const wrap$7 = webSocket => {
895
990
  };
896
991
 
897
992
  const IpcChildWithWebSocket = {
993
+ __proto__: null,
994
+ listen: listen$1,
995
+ signal: signal$3,
996
+ wrap: wrap$8
997
+ };
998
+
999
+ const listen = () => {
1000
+ return window;
1001
+ };
1002
+ const signal$2 = global => {
1003
+ global.postMessage(readyMessage);
1004
+ };
1005
+ class IpcChildWithWindow extends Ipc {
1006
+ getData(event) {
1007
+ return getData$2(event);
1008
+ }
1009
+ send(message) {
1010
+ this._rawIpc.postMessage(message);
1011
+ }
1012
+ sendAndTransfer(message) {
1013
+ const transfer = getTransferrables(message);
1014
+ this._rawIpc.postMessage(message, location.origin, transfer);
1015
+ }
1016
+ dispose() {
1017
+ // ignore
1018
+ }
1019
+ onClose(callback) {
1020
+ // ignore
1021
+ }
1022
+ onMessage(callback) {
1023
+ const wrapped = event => {
1024
+ const {
1025
+ ports
1026
+ } = event;
1027
+ if (ports.length) {
1028
+ return;
1029
+ }
1030
+ callback(event);
1031
+ this._rawIpc.removeEventListener('message', wrapped);
1032
+ };
1033
+ this._rawIpc.addEventListener('message', wrapped);
1034
+ }
1035
+ }
1036
+ const wrap$7 = window => {
1037
+ return new IpcChildWithWindow(window);
1038
+ };
1039
+
1040
+ const IpcChildWithWindow$1 = {
898
1041
  __proto__: null,
899
1042
  listen,
900
1043
  signal: signal$2,
@@ -1608,4 +1751,4 @@ const IpcParentWithWebSocket$1 = {
1608
1751
  wrap
1609
1752
  };
1610
1753
 
1611
- 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, IpcParentWithMessagePort$1 as IpcParentWithMessagePort, IpcParentWithModuleWorker$1 as IpcParentWithModuleWorker, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker, IpcParentWithWebSocket$1 as IpcParentWithWebSocket };
1754
+ export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithElectronWindow$1 as IpcChildWithElectronWindow, IpcChildWithMessagePort$1 as IpcChildWithMessagePort, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess$1 as IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker$1 as IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcChildWithWindow$1 as IpcChildWithWindow, IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithMessagePort$1 as IpcParentWithMessagePort, IpcParentWithModuleWorker$1 as IpcParentWithModuleWorker, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker, IpcParentWithWebSocket$1 as IpcParentWithWebSocket };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/ipc",
3
- "version": "11.7.0",
3
+ "version": "12.0.0",
4
4
  "description": "Inter Process Communication for Lvce Editor",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",