@lvce-editor/renderer-process 10.35.0 → 10.36.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.
@@ -865,7 +865,7 @@ const getTransfer = value => {
865
865
  return transferrables;
866
866
  };
867
867
 
868
- const getData$2 = event => {
868
+ const getData$1 = event => {
869
869
  // TODO why are some events not instance of message event?
870
870
  if (event instanceof MessageEvent) {
871
871
  return event.data;
@@ -900,7 +900,7 @@ const launchWorker = async ({
900
900
  if (listener) {
901
901
  // @ts-ignore
902
902
  this.handleMessage = event => {
903
- const data = getData$2(event);
903
+ const data = getData$1(event);
904
904
  // @ts-ignore
905
905
  listener({
906
906
  data,
@@ -2872,10 +2872,6 @@ const state$6 = {
2872
2872
  modules: Object.create(null)
2873
2873
  };
2874
2874
 
2875
- const handleBeforeInstallPrompt = event => {
2876
- preventDefault(event);
2877
- };
2878
-
2879
2875
  const handleContentSecurityPolicyViolation = event => {
2880
2876
  };
2881
2877
 
@@ -3197,11 +3193,6 @@ const enable = async window => {
3197
3193
  if ('SecurityPolicyViolationEvent' in self) {
3198
3194
  window.addEventListener('securitypolicyviolation', handleContentSecurityPolicyViolation);
3199
3195
  }
3200
- if (platform === Web) {
3201
- // disable prompt to download app as pwa
3202
- // @ts-expect-error
3203
- window.onbeforeinstallprompt = handleBeforeInstallPrompt;
3204
- }
3205
3196
  };
3206
3197
 
3207
3198
  const main = async () => {
@@ -3307,6 +3298,12 @@ ${relevant}`;
3307
3298
 
3308
3299
  const Module = 'module';
3309
3300
 
3301
+ const getWorkerDisplayName = name => {
3302
+ if (name && name.endsWith('Worker')) {
3303
+ return name;
3304
+ }
3305
+ return `${name} worker`;
3306
+ };
3310
3307
  const create$G = async ({
3311
3308
  url,
3312
3309
  name
@@ -3330,7 +3327,8 @@ const create$G = async ({
3330
3327
  if (isErrorEvent(event)) {
3331
3328
  throw new WorkerError(event);
3332
3329
  }
3333
- throw new Error(`Failed to start ${name} worker`);
3330
+ const displayName = getWorkerDisplayName(name);
3331
+ throw new IpcError$1(`Failed to start ${displayName}`);
3334
3332
  }
3335
3333
  return worker;
3336
3334
  };
@@ -3462,30 +3460,62 @@ const handleIpcOnce = ipc => {
3462
3460
  }
3463
3461
  };
3464
3462
 
3465
- const getData$1 = event => {
3466
- return event.data;
3463
+ const normalizeLine = line => {
3464
+ if (line.startsWith('Error: ')) {
3465
+ return line.slice('Error: '.length);
3466
+ }
3467
+ if (line.startsWith('VError: ')) {
3468
+ return line.slice('VError: '.length);
3469
+ }
3470
+ return line;
3467
3471
  };
3468
- const attachEvents$9 = that => {
3469
- const handleMessage = (...args) => {
3470
- const data = that.getData(...args);
3471
- that.dispatchEvent(new MessageEvent('message', {
3472
- data
3473
- }));
3474
- };
3475
- that.onMessage(handleMessage);
3476
- const handleClose = event => {
3477
- that.dispatchEvent(new Event('close'));
3478
- };
3479
- that.onClose(handleClose);
3472
+ const getCombinedMessage = (error, message) => {
3473
+ const stringifiedError = normalizeLine(`${error}`);
3474
+ if (message) {
3475
+ return `${message}: ${stringifiedError}`;
3476
+ }
3477
+ return stringifiedError;
3480
3478
  };
3481
- class Ipc extends EventTarget {
3482
- constructor(rawIpc) {
3483
- super();
3484
- this._rawIpc = rawIpc;
3485
- attachEvents$9(this);
3479
+ const NewLine$1 = '\n';
3480
+ const getNewLineIndex = (string, startIndex = undefined) => {
3481
+ return string.indexOf(NewLine$1, startIndex);
3482
+ };
3483
+ const mergeStacks = (parent, child) => {
3484
+ if (!child) {
3485
+ return parent;
3486
+ }
3487
+ const parentNewLineIndex = getNewLineIndex(parent);
3488
+ const childNewLineIndex = getNewLineIndex(child);
3489
+ if (childNewLineIndex === -1) {
3490
+ return parent;
3491
+ }
3492
+ const parentFirstLine = parent.slice(0, parentNewLineIndex);
3493
+ const childRest = child.slice(childNewLineIndex);
3494
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
3495
+ if (parentFirstLine.includes(childFirstLine)) {
3496
+ return parentFirstLine + childRest;
3497
+ }
3498
+ return child;
3499
+ };
3500
+ class VError extends Error {
3501
+ constructor(error, message) {
3502
+ const combinedMessage = getCombinedMessage(error, message);
3503
+ super(combinedMessage);
3504
+ this.name = 'VError';
3505
+ if (error instanceof Error) {
3506
+ this.stack = mergeStacks(this.stack, error.stack);
3507
+ }
3508
+ if (error.codeFrame) {
3509
+ // @ts-ignore
3510
+ this.codeFrame = error.codeFrame;
3511
+ }
3512
+ if (error.code) {
3513
+ // @ts-ignore
3514
+ this.code = error.code;
3515
+ }
3486
3516
  }
3487
3517
  }
3488
- const readyMessage = 'ready';
3518
+
3489
3519
  const walkValue = (value, transferrables, isTransferrable) => {
3490
3520
  if (!value) {
3491
3521
  return;
@@ -3572,148 +3602,35 @@ const fixElectronParameters = value => {
3572
3602
  transfer
3573
3603
  };
3574
3604
  };
3575
- const listen$4 = () => {
3576
- return window;
3577
- };
3578
- const signal$4 = global => {
3579
- global.postMessage(readyMessage);
3580
- };
3581
- class IpcChildWithElectronWindow extends Ipc {
3582
- getData(event) {
3583
- return getData$1(event);
3584
- }
3585
- send(message) {
3586
- this._rawIpc.postMessage(message);
3587
- }
3588
- sendAndTransfer(message) {
3589
- const {
3590
- newValue,
3591
- transfer
3592
- } = fixElectronParameters(message);
3593
- this._rawIpc.postMessage(newValue, location.origin, transfer);
3594
- }
3595
- dispose() {
3596
- // ignore
3597
- }
3598
- onClose(callback) {
3599
- // ignore
3600
- }
3601
- onMessage(callback) {
3602
- const wrapped = event => {
3603
- const {
3604
- ports
3605
- } = event;
3606
- if (ports.length) {
3607
- return;
3608
- }
3609
- callback(event);
3610
- this._rawIpc.removeEventListener('message', wrapped);
3611
- };
3612
- this._rawIpc.addEventListener('message', wrapped);
3613
- }
3614
- }
3615
- const wrap$7 = window => {
3616
- return new IpcChildWithElectronWindow(window);
3617
- };
3618
- const IpcChildWithElectronWindow$1 = {
3619
- __proto__: null,
3620
- listen: listen$4,
3621
- signal: signal$4,
3622
- wrap: wrap$7
3623
- };
3624
- const listen$3 = ({
3625
- port
3626
- }) => {
3627
- return port;
3628
- };
3629
- const signal$3 = port => {
3630
- port.postMessage(readyMessage);
3631
- };
3632
- class IpcChildWithMessagePort extends Ipc {
3633
- constructor(port) {
3634
- super(port);
3635
- }
3636
- getData(event) {
3637
- return getData$1(event);
3638
- }
3639
- send(message) {
3640
- this._rawIpc.postMessage(message);
3641
- }
3642
- sendAndTransfer(message) {
3643
- const transfer = getTransferrables(message);
3644
- this._rawIpc.postMessage(message, transfer);
3645
- }
3646
- dispose() {
3647
- // ignore
3648
- }
3649
- onClose(callback) {
3650
- // ignore
3651
- }
3652
- onMessage(callback) {
3653
- this._rawIpc.addEventListener('message', callback);
3654
- this._rawIpc.start();
3655
- }
3656
- }
3657
- const wrap$6 = port => {
3658
- return new IpcChildWithMessagePort(port);
3659
- };
3660
- const IpcChildWithMessagePort$1 = {
3661
- __proto__: null,
3662
- listen: listen$3,
3663
- signal: signal$3,
3664
- wrap: wrap$6
3665
- };
3666
- const listen$2 = () => {
3667
- // @ts-ignore
3668
- if (typeof WorkerGlobalScope === 'undefined') {
3669
- throw new TypeError('module is not in web worker scope');
3670
- }
3671
- return globalThis;
3672
- };
3673
- const signal$2 = global => {
3674
- global.postMessage(readyMessage);
3605
+ const attachEvents$9 = that => {
3606
+ const handleMessage = (...args) => {
3607
+ const data = that.getData(...args);
3608
+ that.dispatchEvent(new MessageEvent('message', {
3609
+ data
3610
+ }));
3611
+ };
3612
+ that.onMessage(handleMessage);
3613
+ const handleClose = event => {
3614
+ that.dispatchEvent(new Event('close'));
3615
+ };
3616
+ that.onClose(handleClose);
3675
3617
  };
3676
- class IpcChildWithModuleWorker extends Ipc {
3677
- getData(event) {
3678
- return getData$1(event);
3679
- }
3680
- send(message) {
3681
- // @ts-ignore
3682
- this._rawIpc.postMessage(message);
3683
- }
3684
- sendAndTransfer(message) {
3685
- const transfer = getTransferrables(message);
3686
- // @ts-ignore
3687
- this._rawIpc.postMessage(message, transfer);
3688
- }
3689
- dispose() {
3690
- // ignore
3691
- }
3692
- onClose(callback) {
3693
- // ignore
3694
- }
3695
- onMessage(callback) {
3696
- this._rawIpc.addEventListener('message', callback);
3618
+ class Ipc extends EventTarget {
3619
+ constructor(rawIpc) {
3620
+ super();
3621
+ this._rawIpc = rawIpc;
3622
+ attachEvents$9(this);
3697
3623
  }
3698
3624
  }
3699
- const wrap$5 = global => {
3700
- return new IpcChildWithModuleWorker(global);
3701
- };
3702
- const IpcChildWithModuleWorker$1 = {
3703
- __proto__: null,
3704
- listen: listen$2,
3705
- signal: signal$2,
3706
- wrap: wrap$5
3707
- };
3708
3625
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
3709
3626
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
3710
3627
  const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
3711
- const NewLine$1 = '\n';
3628
+ const NewLine = '\n';
3712
3629
  const joinLines = lines => {
3713
- return lines.join(NewLine$1);
3630
+ return lines.join(NewLine);
3714
3631
  };
3715
3632
  const splitLines = lines => {
3716
- return lines.split(NewLine$1);
3633
+ return lines.split(NewLine);
3717
3634
  };
3718
3635
  const isModuleNotFoundMessage = line => {
3719
3636
  return line.includes('[ERR_MODULE_NOT_FOUND]');
@@ -3818,61 +3735,6 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
3818
3735
  stack: rest
3819
3736
  };
3820
3737
  };
3821
- const normalizeLine = line => {
3822
- if (line.startsWith('Error: ')) {
3823
- return line.slice('Error: '.length);
3824
- }
3825
- if (line.startsWith('VError: ')) {
3826
- return line.slice('VError: '.length);
3827
- }
3828
- return line;
3829
- };
3830
- const getCombinedMessage = (error, message) => {
3831
- const stringifiedError = normalizeLine(`${error}`);
3832
- if (message) {
3833
- return `${message}: ${stringifiedError}`;
3834
- }
3835
- return stringifiedError;
3836
- };
3837
- const NewLine = '\n';
3838
- const getNewLineIndex = (string, startIndex = undefined) => {
3839
- return string.indexOf(NewLine, startIndex);
3840
- };
3841
- const mergeStacks = (parent, child) => {
3842
- if (!child) {
3843
- return parent;
3844
- }
3845
- const parentNewLineIndex = getNewLineIndex(parent);
3846
- const childNewLineIndex = getNewLineIndex(child);
3847
- if (childNewLineIndex === -1) {
3848
- return parent;
3849
- }
3850
- const parentFirstLine = parent.slice(0, parentNewLineIndex);
3851
- const childRest = child.slice(childNewLineIndex);
3852
- const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
3853
- if (parentFirstLine.includes(childFirstLine)) {
3854
- return parentFirstLine + childRest;
3855
- }
3856
- return child;
3857
- };
3858
- class VError extends Error {
3859
- constructor(error, message) {
3860
- const combinedMessage = getCombinedMessage(error, message);
3861
- super(combinedMessage);
3862
- this.name = 'VError';
3863
- if (error instanceof Error) {
3864
- this.stack = mergeStacks(this.stack, error.stack);
3865
- }
3866
- if (error.codeFrame) {
3867
- // @ts-ignore
3868
- this.codeFrame = error.codeFrame;
3869
- }
3870
- if (error.code) {
3871
- // @ts-ignore
3872
- this.code = error.code;
3873
- }
3874
- }
3875
- }
3876
3738
  class IpcError extends VError {
3877
3739
  // @ts-ignore
3878
3740
  constructor(betterMessage, stdout = '', stderr = '') {
@@ -3899,6 +3761,143 @@ class IpcError extends VError {
3899
3761
  this.stderr = stderr;
3900
3762
  }
3901
3763
  }
3764
+ const readyMessage = 'ready';
3765
+ const getData$2 = event => {
3766
+ return event.data;
3767
+ };
3768
+ const listen$9 = () => {
3769
+ return window;
3770
+ };
3771
+ const signal$9 = global => {
3772
+ global.postMessage(readyMessage);
3773
+ };
3774
+ class IpcChildWithElectronWindow extends Ipc {
3775
+ getData(event) {
3776
+ return getData$2(event);
3777
+ }
3778
+ send(message) {
3779
+ this._rawIpc.postMessage(message);
3780
+ }
3781
+ sendAndTransfer(message) {
3782
+ const {
3783
+ newValue,
3784
+ transfer
3785
+ } = fixElectronParameters(message);
3786
+ this._rawIpc.postMessage(newValue, location.origin, transfer);
3787
+ }
3788
+ dispose() {
3789
+ // ignore
3790
+ }
3791
+ onClose(callback) {
3792
+ // ignore
3793
+ }
3794
+ onMessage(callback) {
3795
+ const wrapped = event => {
3796
+ const {
3797
+ ports
3798
+ } = event;
3799
+ if (ports.length) {
3800
+ return;
3801
+ }
3802
+ callback(event);
3803
+ this._rawIpc.removeEventListener('message', wrapped);
3804
+ };
3805
+ this._rawIpc.addEventListener('message', wrapped);
3806
+ }
3807
+ }
3808
+ const wrap$g = window => {
3809
+ return new IpcChildWithElectronWindow(window);
3810
+ };
3811
+ const IpcChildWithElectronWindow$1 = {
3812
+ __proto__: null,
3813
+ listen: listen$9,
3814
+ signal: signal$9,
3815
+ wrap: wrap$g
3816
+ };
3817
+ const listen$8 = ({
3818
+ port
3819
+ }) => {
3820
+ return port;
3821
+ };
3822
+ const signal$8 = port => {
3823
+ port.postMessage(readyMessage);
3824
+ };
3825
+ class IpcChildWithMessagePort extends Ipc {
3826
+ constructor(port) {
3827
+ super(port);
3828
+ }
3829
+ getData(event) {
3830
+ return getData$2(event);
3831
+ }
3832
+ send(message) {
3833
+ this._rawIpc.postMessage(message);
3834
+ }
3835
+ sendAndTransfer(message) {
3836
+ const transfer = getTransferrables(message);
3837
+ this._rawIpc.postMessage(message, transfer);
3838
+ }
3839
+ dispose() {
3840
+ // ignore
3841
+ }
3842
+ onClose(callback) {
3843
+ // ignore
3844
+ }
3845
+ onMessage(callback) {
3846
+ this._rawIpc.addEventListener('message', callback);
3847
+ this._rawIpc.start();
3848
+ }
3849
+ }
3850
+ const wrap$f = port => {
3851
+ return new IpcChildWithMessagePort(port);
3852
+ };
3853
+ const IpcChildWithMessagePort$1 = {
3854
+ __proto__: null,
3855
+ listen: listen$8,
3856
+ signal: signal$8,
3857
+ wrap: wrap$f
3858
+ };
3859
+ const listen$7 = () => {
3860
+ // @ts-ignore
3861
+ if (typeof WorkerGlobalScope === 'undefined') {
3862
+ throw new TypeError('module is not in web worker scope');
3863
+ }
3864
+ return globalThis;
3865
+ };
3866
+ const signal$7 = global => {
3867
+ global.postMessage(readyMessage);
3868
+ };
3869
+ class IpcChildWithModuleWorker extends Ipc {
3870
+ getData(event) {
3871
+ return getData$2(event);
3872
+ }
3873
+ send(message) {
3874
+ // @ts-ignore
3875
+ this._rawIpc.postMessage(message);
3876
+ }
3877
+ sendAndTransfer(message) {
3878
+ const transfer = getTransferrables(message);
3879
+ // @ts-ignore
3880
+ this._rawIpc.postMessage(message, transfer);
3881
+ }
3882
+ dispose() {
3883
+ // ignore
3884
+ }
3885
+ onClose(callback) {
3886
+ // ignore
3887
+ }
3888
+ onMessage(callback) {
3889
+ this._rawIpc.addEventListener('message', callback);
3890
+ }
3891
+ }
3892
+ const wrap$e = global => {
3893
+ return new IpcChildWithModuleWorker(global);
3894
+ };
3895
+ const IpcChildWithModuleWorker$1 = {
3896
+ __proto__: null,
3897
+ listen: listen$7,
3898
+ signal: signal$7,
3899
+ wrap: wrap$e
3900
+ };
3902
3901
  const withResolvers = () => {
3903
3902
  let _resolve;
3904
3903
  const promise = new Promise(resolve => {
@@ -3921,10 +3920,10 @@ const waitForFirstMessage = async port => {
3921
3920
  // @ts-ignore
3922
3921
  return event.data;
3923
3922
  };
3924
- const listen$1 = async () => {
3925
- const parentIpcRaw = listen$2();
3926
- signal$2(parentIpcRaw);
3927
- const parentIpc = wrap$5(parentIpcRaw);
3923
+ const listen$6 = async () => {
3924
+ const parentIpcRaw = listen$7();
3925
+ signal$7(parentIpcRaw);
3926
+ const parentIpc = wrap$e(parentIpcRaw);
3928
3927
  const firstMessage = await waitForFirstMessage(parentIpc);
3929
3928
  if (firstMessage.method !== 'initialize') {
3930
3929
  throw new IpcError('unexpected first message');
@@ -3947,7 +3946,7 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
3947
3946
  super(port);
3948
3947
  }
3949
3948
  getData(event) {
3950
- return getData$1(event);
3949
+ return getData$2(event);
3951
3950
  }
3952
3951
  send(message) {
3953
3952
  this._rawIpc.postMessage(message);
@@ -3969,13 +3968,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
3969
3968
  this._rawIpc.start();
3970
3969
  }
3971
3970
  }
3972
- const wrap$4 = port => {
3971
+ const wrap$d = port => {
3973
3972
  return new IpcChildWithModuleWorkerAndMessagePort(port);
3974
3973
  };
3975
3974
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
3976
3975
  __proto__: null,
3977
- listen: listen$1,
3978
- wrap: wrap$4
3976
+ listen: listen$6,
3977
+ wrap: wrap$d
3979
3978
  };
3980
3979
 
3981
3980
  // TODO use handleIncomingIpc function
@@ -6545,7 +6544,9 @@ const listen = async ({
6545
6544
  }) => {
6546
6545
  const module = await getModule(method);
6547
6546
  const rawIpc = await module.listen(options);
6547
+ // @ts-ignore
6548
6548
  if (module.signal) {
6549
+ // @ts-ignore
6549
6550
  module.signal(rawIpc);
6550
6551
  }
6551
6552
  const ipc = module.wrap(rawIpc);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "10.35.0",
3
+ "version": "10.36.0",
4
4
  "description": "",
5
5
  "main": "dist/rendererProcessMain.js",
6
6
  "type": "module",