@lvce-editor/renderer-process 10.24.0 → 10.26.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.
@@ -458,57 +458,21 @@ const create$4$1 = (method, params) => {
458
458
  params
459
459
  };
460
460
  };
461
- let AssertionError$2 = class AssertionError extends Error {
462
- constructor(message) {
463
- super(message);
464
- this.name = 'AssertionError';
465
- }
466
- };
467
- const getType$1 = value => {
468
- switch (typeof value) {
469
- case 'number':
470
- return 'number';
471
- case 'function':
472
- return 'function';
473
- case 'string':
474
- return 'string';
475
- case 'object':
476
- if (value === null) {
477
- return 'null';
478
- }
479
- if (Array.isArray(value)) {
480
- return 'array';
481
- }
482
- return 'object';
483
- case 'boolean':
484
- return 'boolean';
485
- default:
486
- return 'unknown';
487
- }
488
- };
489
- const number$1 = value => {
490
- const type = getType$1(value);
491
- if (type !== 'number') {
492
- throw new AssertionError$2('expected value to be of type number');
493
- }
494
- };
495
- const state$1$1 = {
461
+ const state$a = {
496
462
  callbacks: Object.create(null)
497
463
  };
498
464
  const set$6 = (id, fn) => {
499
- state$1$1.callbacks[id] = fn;
465
+ state$a.callbacks[id] = fn;
500
466
  };
501
467
  const get$7 = id => {
502
- return state$1$1.callbacks[id];
468
+ return state$a.callbacks[id];
503
469
  };
504
470
  const remove$3 = id => {
505
- delete state$1$1.callbacks[id];
506
- };
507
- const state$a = {
508
- id: 0
471
+ delete state$a.callbacks[id];
509
472
  };
473
+ let id = 0;
510
474
  const create$3$1 = () => {
511
- return ++state$a.id;
475
+ return ++id;
512
476
  };
513
477
  const warn$1 = (...args) => {
514
478
  console.warn(...args);
@@ -525,15 +489,14 @@ const registerPromise = () => {
525
489
  promise
526
490
  };
527
491
  };
528
- const resolve = (id, args) => {
529
- number$1(id);
492
+ const resolve = (id, response) => {
530
493
  const fn = get$7(id);
531
494
  if (!fn) {
532
- console.log(args);
495
+ console.log(response);
533
496
  warn$1(`callback ${id} may already be disposed`);
534
497
  return;
535
498
  }
536
- fn(args);
499
+ fn(response);
537
500
  remove$3(id);
538
501
  };
539
502
  const create$2$1 = (method, params) => {
@@ -755,32 +718,42 @@ const defaultRequiresSocket = () => {
755
718
  return false;
756
719
  };
757
720
  const defaultResolve = resolve;
758
- const handleJsonRpcMessage = async (...args) => {
759
- let message;
760
- let ipc;
761
- let execute;
762
- let preparePrettyError;
763
- let logError;
764
- let resolve;
765
- let requiresSocket;
721
+
722
+ // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
723
+ const normalizeParams = args => {
766
724
  if (args.length === 1) {
767
- const arg = args[0];
768
- message = arg.message;
769
- ipc = arg.ipc;
770
- execute = arg.execute;
771
- preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
772
- logError = arg.logError || defaultLogError;
773
- requiresSocket = arg.requiresSocket || defaultRequiresSocket;
774
- resolve = arg.resolve || defaultResolve;
775
- } else {
776
- ipc = args[0];
777
- message = args[1];
778
- execute = args[2];
779
- resolve = args[3];
780
- preparePrettyError = args[4];
781
- logError = args[5];
782
- requiresSocket = args[6];
725
+ const options = args[0];
726
+ return {
727
+ ipc: options.ipc,
728
+ message: options.message,
729
+ execute: options.execute,
730
+ resolve: options.resolve || defaultResolve,
731
+ preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
732
+ logError: options.logError || defaultLogError,
733
+ requiresSocket: options.requiresSocket || defaultRequiresSocket
734
+ };
783
735
  }
736
+ return {
737
+ ipc: args[0],
738
+ message: args[1],
739
+ execute: args[2],
740
+ resolve: args[3],
741
+ preparePrettyError: args[4],
742
+ logError: args[5],
743
+ requiresSocket: args[6]
744
+ };
745
+ };
746
+ const handleJsonRpcMessage = async (...args) => {
747
+ const options = normalizeParams(args);
748
+ const {
749
+ message,
750
+ ipc,
751
+ execute,
752
+ resolve,
753
+ preparePrettyError,
754
+ logError,
755
+ requiresSocket
756
+ } = options;
784
757
  if ('id' in message) {
785
758
  if ('method' in message) {
786
759
  const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
@@ -801,29 +774,28 @@ const handleJsonRpcMessage = async (...args) => {
801
774
  }
802
775
  throw new JsonRpcError('unexpected message');
803
776
  };
804
- const send$1 = (transport, method, ...params) => {
805
- const message = create$4$1(method, params);
806
- transport.send(message);
807
- };
808
- const invoke$2 = async (ipc, method, ...params) => {
777
+ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
809
778
  const {
810
779
  message,
811
780
  promise
812
781
  } = create$2$1(method, params);
813
- ipc.send(message);
782
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
783
+ ipc.sendAndTransfer(message);
784
+ } else {
785
+ ipc.send(message);
786
+ }
814
787
  const responseMessage = await promise;
815
- const result = unwrapJsonRpcResult(responseMessage);
816
- return result;
788
+ return unwrapJsonRpcResult(responseMessage);
817
789
  };
818
- const invokeAndTransfer$1 = async (ipc, method, ...params) => {
819
- const {
820
- message,
821
- promise
822
- } = create$2$1(method, params);
823
- ipc.sendAndTransfer(message);
824
- const responseMessage = await promise;
825
- const result = unwrapJsonRpcResult(responseMessage);
826
- return result;
790
+ const send$1 = (transport, method, ...params) => {
791
+ const message = create$4$1(method, params);
792
+ transport.send(message);
793
+ };
794
+ const invoke$2 = (ipc, method, ...params) => {
795
+ return invokeHelper(ipc, method, params, false);
796
+ };
797
+ const invokeAndTransfer$1 = (ipc, method, ...params) => {
798
+ return invokeHelper(ipc, method, params, true);
827
799
  };
828
800
 
829
801
  const requiresSocket = () => {
@@ -3440,6 +3412,27 @@ const handleIpcOnce = ipc => {
3440
3412
  const getData$1 = event => {
3441
3413
  return event.data;
3442
3414
  };
3415
+ const attachEvents$9 = that => {
3416
+ const handleMessage = (...args) => {
3417
+ const data = that.getData(...args);
3418
+ that.dispatchEvent(new MessageEvent('message', {
3419
+ data
3420
+ }));
3421
+ };
3422
+ that.onMessage(handleMessage);
3423
+ const handleClose = event => {
3424
+ that.dispatchEvent(new Event('close'));
3425
+ };
3426
+ that.onClose(handleClose);
3427
+ };
3428
+ class Ipc extends EventTarget {
3429
+ constructor(rawIpc) {
3430
+ super();
3431
+ this._rawIpc = rawIpc;
3432
+ attachEvents$9(this);
3433
+ }
3434
+ }
3435
+ const readyMessage = 'ready';
3443
3436
  const walkValue = (value, transferrables, isTransferrable) => {
3444
3437
  if (!value) {
3445
3438
  return;
@@ -3490,35 +3483,141 @@ const getTransferrables = value => {
3490
3483
  walkValue(value, transferrables, isTransferrable);
3491
3484
  return transferrables;
3492
3485
  };
3493
- const attachEvents$9 = that => {
3494
- const handleMessage = (...args) => {
3495
- const data = that.getData(...args);
3496
- that.dispatchEvent(new MessageEvent('message', {
3497
- data
3498
- }));
3499
- };
3500
- that.onMessage(handleMessage);
3501
- const handleClose = event => {
3502
- that.dispatchEvent(new Event('close'));
3486
+ const removeValues = (value, toRemove) => {
3487
+ if (!value) {
3488
+ return value;
3489
+ }
3490
+ if (Array.isArray(value)) {
3491
+ const newItems = [];
3492
+ for (const item of value) {
3493
+ if (!toRemove.includes(item)) {
3494
+ newItems.push(removeValues(item, toRemove));
3495
+ }
3496
+ }
3497
+ return newItems;
3498
+ }
3499
+ if (typeof value === 'object') {
3500
+ const newObject = Object.create(null);
3501
+ for (const [key, property] of Object.entries(value)) {
3502
+ if (!toRemove.includes(property)) {
3503
+ newObject[key] = removeValues(property, toRemove);
3504
+ }
3505
+ }
3506
+ return newObject;
3507
+ }
3508
+ return value;
3509
+ };
3510
+
3511
+ // workaround for electron not supporting transferrable objects
3512
+ // as parameters. If the transferrable object is a parameter, in electron
3513
+ // only an empty objected is received in the main process
3514
+ const fixElectronParameters = value => {
3515
+ const transfer = getTransferrables(value);
3516
+ const newValue = removeValues(value, transfer);
3517
+ return {
3518
+ newValue,
3519
+ transfer
3503
3520
  };
3504
- that.onClose(handleClose);
3505
3521
  };
3506
- class Ipc extends EventTarget {
3507
- constructor(rawIpc) {
3508
- super();
3509
- this._rawIpc = rawIpc;
3510
- attachEvents$9(this);
3522
+ const listen$4 = () => {
3523
+ return window;
3524
+ };
3525
+ const signal$4 = global => {
3526
+ global.postMessage(readyMessage);
3527
+ };
3528
+ class IpcChildWithElectronWindow extends Ipc {
3529
+ getData(event) {
3530
+ return getData$1(event);
3531
+ }
3532
+ send(message) {
3533
+ this._rawIpc.postMessage(message);
3534
+ }
3535
+ sendAndTransfer(message) {
3536
+ const {
3537
+ newValue,
3538
+ transfer
3539
+ } = fixElectronParameters(message);
3540
+ this._rawIpc.postMessage(newValue, location.origin, transfer);
3541
+ }
3542
+ dispose() {
3543
+ // ignore
3544
+ }
3545
+ onClose(callback) {
3546
+ // ignore
3547
+ }
3548
+ onMessage(callback) {
3549
+ const wrapped = event => {
3550
+ const {
3551
+ ports
3552
+ } = event;
3553
+ if (ports.length) {
3554
+ return;
3555
+ }
3556
+ callback(event);
3557
+ this._rawIpc.removeEventListener('message', wrapped);
3558
+ };
3559
+ this._rawIpc.addEventListener('message', wrapped);
3511
3560
  }
3512
3561
  }
3513
- const readyMessage = 'ready';
3514
- const listen$4 = () => {
3562
+ const wrap$7 = window => {
3563
+ return new IpcChildWithElectronWindow(window);
3564
+ };
3565
+ const IpcChildWithElectronWindow$1 = {
3566
+ __proto__: null,
3567
+ listen: listen$4,
3568
+ signal: signal$4,
3569
+ wrap: wrap$7
3570
+ };
3571
+ const listen$3 = ({
3572
+ port
3573
+ }) => {
3574
+ return port;
3575
+ };
3576
+ const signal$3 = port => {
3577
+ port.postMessage(readyMessage);
3578
+ };
3579
+ class IpcChildWithMessagePort extends Ipc {
3580
+ constructor(port) {
3581
+ super(port);
3582
+ }
3583
+ getData(event) {
3584
+ return getData$1(event);
3585
+ }
3586
+ send(message) {
3587
+ this._rawIpc.postMessage(message);
3588
+ }
3589
+ sendAndTransfer(message) {
3590
+ const transfer = getTransferrables(message);
3591
+ this._rawIpc.postMessage(message, transfer);
3592
+ }
3593
+ dispose() {
3594
+ // ignore
3595
+ }
3596
+ onClose(callback) {
3597
+ // ignore
3598
+ }
3599
+ onMessage(callback) {
3600
+ this._rawIpc.addEventListener('message', callback);
3601
+ this._rawIpc.start();
3602
+ }
3603
+ }
3604
+ const wrap$6 = port => {
3605
+ return new IpcChildWithMessagePort(port);
3606
+ };
3607
+ const IpcChildWithMessagePort$1 = {
3608
+ __proto__: null,
3609
+ listen: listen$3,
3610
+ signal: signal$3,
3611
+ wrap: wrap$6
3612
+ };
3613
+ const listen$2 = () => {
3515
3614
  // @ts-ignore
3516
3615
  if (typeof WorkerGlobalScope === 'undefined') {
3517
3616
  throw new TypeError('module is not in web worker scope');
3518
3617
  }
3519
3618
  return globalThis;
3520
3619
  };
3521
- const signal$3 = global => {
3620
+ const signal$2 = global => {
3522
3621
  global.postMessage(readyMessage);
3523
3622
  };
3524
3623
  class IpcChildWithModuleWorker extends Ipc {
@@ -3544,14 +3643,14 @@ class IpcChildWithModuleWorker extends Ipc {
3544
3643
  this._rawIpc.addEventListener('message', callback);
3545
3644
  }
3546
3645
  }
3547
- const wrap$6 = global => {
3646
+ const wrap$5 = global => {
3548
3647
  return new IpcChildWithModuleWorker(global);
3549
3648
  };
3550
3649
  const IpcChildWithModuleWorker$1 = {
3551
3650
  __proto__: null,
3552
- listen: listen$4,
3553
- signal: signal$3,
3554
- wrap: wrap$6
3651
+ listen: listen$2,
3652
+ signal: signal$2,
3653
+ wrap: wrap$5
3555
3654
  };
3556
3655
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
3557
3656
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
@@ -3668,10 +3767,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
3668
3767
  };
3669
3768
  const normalizeLine = line => {
3670
3769
  if (line.startsWith('Error: ')) {
3671
- return line.slice(`Error: `.length);
3770
+ return line.slice('Error: '.length);
3672
3771
  }
3673
3772
  if (line.startsWith('VError: ')) {
3674
- return line.slice(`VError: `.length);
3773
+ return line.slice('VError: '.length);
3675
3774
  }
3676
3775
  return line;
3677
3776
  };
@@ -3769,10 +3868,10 @@ const waitForFirstMessage = async port => {
3769
3868
  // @ts-ignore
3770
3869
  return event.data;
3771
3870
  };
3772
- const listen$3 = async () => {
3773
- const parentIpcRaw = listen$4();
3774
- signal$3(parentIpcRaw);
3775
- const parentIpc = wrap$6(parentIpcRaw);
3871
+ const listen$1 = async () => {
3872
+ const parentIpcRaw = listen$2();
3873
+ signal$2(parentIpcRaw);
3874
+ const parentIpc = wrap$5(parentIpcRaw);
3776
3875
  const firstMessage = await waitForFirstMessage(parentIpc);
3777
3876
  if (firstMessage.method !== 'initialize') {
3778
3877
  throw new IpcError('unexpected first message');
@@ -3817,140 +3916,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
3817
3916
  this._rawIpc.start();
3818
3917
  }
3819
3918
  }
3820
- const wrap$5 = port => {
3919
+ const wrap$4 = port => {
3821
3920
  return new IpcChildWithModuleWorkerAndMessagePort(port);
3822
3921
  };
3823
3922
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
3824
- __proto__: null,
3825
- listen: listen$3,
3826
- wrap: wrap$5
3827
- };
3828
- const removeValues = (value, toRemove) => {
3829
- if (!value) {
3830
- return value;
3831
- }
3832
- if (Array.isArray(value)) {
3833
- const newItems = [];
3834
- for (const item of value) {
3835
- if (!toRemove.includes(item)) {
3836
- newItems.push(removeValues(item, toRemove));
3837
- }
3838
- }
3839
- return newItems;
3840
- }
3841
- if (typeof value === 'object') {
3842
- const newObject = Object.create(null);
3843
- for (const [key, property] of Object.entries(value)) {
3844
- if (!toRemove.includes(property)) {
3845
- newObject[key] = removeValues(property, toRemove);
3846
- }
3847
- }
3848
- return newObject;
3849
- }
3850
- return value;
3851
- };
3852
-
3853
- // workaround for electron not supporting transferrable objects
3854
- // as parameters. If the transferrable object is a parameter, in electron
3855
- // only an empty objected is received in the main process
3856
- const fixElectronParameters = value => {
3857
- const transfer = getTransferrables(value);
3858
- const newValue = removeValues(value, transfer);
3859
- return {
3860
- newValue,
3861
- transfer
3862
- };
3863
- };
3864
- const listen$1 = () => {
3865
- return window;
3866
- };
3867
- const signal$1 = global => {
3868
- global.postMessage(readyMessage);
3869
- };
3870
- class IpcChildWithElectronWindow extends Ipc {
3871
- getData(event) {
3872
- return getData$1(event);
3873
- }
3874
- send(message) {
3875
- this._rawIpc.postMessage(message);
3876
- }
3877
- sendAndTransfer(message) {
3878
- const {
3879
- newValue,
3880
- transfer
3881
- } = fixElectronParameters(message);
3882
- this._rawIpc.postMessage(newValue, location.origin, transfer);
3883
- }
3884
- dispose() {
3885
- // ignore
3886
- }
3887
- onClose(callback) {
3888
- // ignore
3889
- }
3890
- onMessage(callback) {
3891
- const wrapped = event => {
3892
- const {
3893
- ports
3894
- } = event;
3895
- if (ports.length) {
3896
- return;
3897
- }
3898
- callback(event);
3899
- this._rawIpc.removeEventListener('message', wrapped);
3900
- };
3901
- this._rawIpc.addEventListener('message', wrapped);
3902
- }
3903
- }
3904
- const wrap$3 = window => {
3905
- return new IpcChildWithElectronWindow(window);
3906
- };
3907
- const IpcChildWithElectronWindow$1 = {
3908
3923
  __proto__: null,
3909
3924
  listen: listen$1,
3910
- signal: signal$1,
3911
- wrap: wrap$3
3912
- };
3913
- const listen$2 = ({
3914
- port
3915
- }) => {
3916
- return port;
3917
- };
3918
- const signal = port => {
3919
- port.postMessage(readyMessage);
3920
- };
3921
- class IpcChildWithMessagePort extends Ipc {
3922
- constructor(port) {
3923
- super(port);
3924
- }
3925
- getData(event) {
3926
- return getData$1(event);
3927
- }
3928
- send(message) {
3929
- this._rawIpc.postMessage(message);
3930
- }
3931
- sendAndTransfer(message) {
3932
- const transfer = getTransferrables(message);
3933
- this._rawIpc.postMessage(message, transfer);
3934
- }
3935
- dispose() {
3936
- // ignore
3937
- }
3938
- onClose(callback) {
3939
- // ignore
3940
- }
3941
- onMessage(callback) {
3942
- this._rawIpc.addEventListener('message', callback);
3943
- this._rawIpc.start();
3944
- }
3945
- }
3946
- const wrap$2 = port => {
3947
- return new IpcChildWithMessagePort(port);
3948
- };
3949
- const IpcChildWithMessagePort$1 = {
3950
- __proto__: null,
3951
- listen: listen$2,
3952
- signal,
3953
- wrap: wrap$2
3925
+ wrap: wrap$4
3954
3926
  };
3955
3927
 
3956
3928
  // TODO use handleIncomingIpc function
@@ -10249,11 +10221,25 @@ const handleHeaderClick$1 = event => {
10249
10221
  return ['replaceAll'];
10250
10222
  case 'Match Whole Word':
10251
10223
  return ['toggleMatchWholeWord'];
10224
+ case 'Preserve Case':
10225
+ return ['togglePreserveCase'];
10226
+ case 'Toggle Search Details':
10227
+ return ['toggleSearchDetails'];
10252
10228
  default:
10253
10229
  return [];
10254
10230
  }
10255
10231
  // TODO better way to determine which button was clicked
10256
10232
  };
10233
+ const handleSharedInput = event => {
10234
+ const {
10235
+ target
10236
+ } = event;
10237
+ const {
10238
+ value,
10239
+ name
10240
+ } = target;
10241
+ return ['handleSharedInput', name, value];
10242
+ };
10257
10243
  const handleReplaceInput = event => {
10258
10244
  const {
10259
10245
  target
@@ -10311,6 +10297,7 @@ const ViewletSearchEvents = {
10311
10297
  handleScrollBarPointerDown: handleScrollBarPointerDown$1,
10312
10298
  handleScrollBarPointerUp,
10313
10299
  handleScrollBarThumbPointerMove,
10300
+ handleSharedInput,
10314
10301
  handleToggleButtonClick,
10315
10302
  handleWheel,
10316
10303
  returnValue: returnValue$5
@@ -10320,7 +10307,14 @@ const focus$5 = state => {
10320
10307
  object(state);
10321
10308
  state.$ViewletSearchInput.focus();
10322
10309
  };
10323
- const setValue = (state, value) => {
10310
+ const setValue = (state, value, key) => {
10311
+ if (key) {
10312
+ const $Element = state.$Viewlet.querySelector(key);
10313
+ if ($Element) {
10314
+ $Element.value = value;
10315
+ }
10316
+ return;
10317
+ }
10324
10318
  const {
10325
10319
  $ViewletSearchInput
10326
10320
  } = state;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "10.24.0",
3
+ "version": "10.26.0",
4
4
  "description": "",
5
5
  "main": "dist/rendererProcessMain.js",
6
6
  "type": "module",