@lvce-editor/renderer-process 30.12.4 → 30.13.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.
@@ -118,25 +118,25 @@ const confirm = message => {
118
118
  return window.confirm(message);
119
119
  };
120
120
 
121
- const state$a = {
121
+ const state$b = {
122
122
  styleSheets: Object.create(null),
123
123
  texts: Object.create(null)
124
124
  };
125
125
  const set$b = (id, sheet) => {
126
- state$a.styleSheets[id] = sheet;
126
+ state$b.styleSheets[id] = sheet;
127
127
  };
128
128
  const get$b = id => {
129
- return state$a.styleSheets[id];
129
+ return state$b.styleSheets[id];
130
130
  };
131
131
  const setText$2 = (id, text) => {
132
- state$a.texts[id] = text;
132
+ state$b.texts[id] = text;
133
133
  };
134
134
  const getText = id => {
135
- return state$a.texts[id];
135
+ return state$b.texts[id];
136
136
  };
137
137
  const remove$5 = id => {
138
- delete state$a.styleSheets[id];
139
- delete state$a.texts[id];
138
+ delete state$b.styleSheets[id];
139
+ delete state$b.texts[id];
140
140
  };
141
141
 
142
142
  const addCssStyleSheet = (id, text) => {
@@ -338,10 +338,10 @@ const createIdGenerator = () => {
338
338
  };
339
339
  const create$L = createIdGenerator();
340
340
 
341
- const state$9 = Object.create(null);
341
+ const state$a = Object.create(null);
342
342
  const acquire$1 = id => {
343
- const promise = state$9[id];
344
- delete state$9[id];
343
+ const promise = state$a[id];
344
+ delete state$a[id];
345
345
  return promise;
346
346
  };
347
347
  const getFileHandles$1 = async ids => {
@@ -351,7 +351,7 @@ const getFileHandles$1 = async ids => {
351
351
  };
352
352
  const add$1 = promise => {
353
353
  const id = create$L();
354
- state$9[id] = promise;
354
+ state$a[id] = promise;
355
355
  return id;
356
356
  };
357
357
  const addFileHandle$1 = fileHandle => {
@@ -528,14 +528,14 @@ const getEventListenerArgs = (params, event) => {
528
528
  return serialized;
529
529
  };
530
530
 
531
- const state$8 = {
531
+ const state$9 = {
532
532
  ipc: undefined
533
533
  };
534
534
  const getIpc = () => {
535
- return state$8.ipc;
535
+ return state$9.ipc;
536
536
  };
537
537
  const setIpc = value => {
538
- state$8.ipc = value;
538
+ state$9.ipc = value;
539
539
  };
540
540
 
541
541
  const nameAnonymousFunction$1 = (fn, name) => {
@@ -3580,6 +3580,109 @@ const launchRendererWorker = async () => {
3580
3580
  });
3581
3581
  };
3582
3582
 
3583
+ const selector = 'script.RendererWorkerTrace';
3584
+ const state$8 = {
3585
+ enabled: false,
3586
+ entries: []
3587
+ };
3588
+ const serialize = value => {
3589
+ const seen = new WeakSet();
3590
+ const text = JSON.stringify(value, (_key, currentValue) => {
3591
+ if (typeof currentValue === 'bigint') {
3592
+ return `${currentValue}n`;
3593
+ }
3594
+ if (typeof currentValue !== 'object' || currentValue === null) {
3595
+ return currentValue;
3596
+ }
3597
+ if (seen.has(currentValue)) {
3598
+ return '[Circular]';
3599
+ }
3600
+ seen.add(currentValue);
3601
+ if (currentValue instanceof ArrayBuffer) {
3602
+ return {
3603
+ byteLength: currentValue.byteLength,
3604
+ type: 'ArrayBuffer'
3605
+ };
3606
+ }
3607
+ if (ArrayBuffer.isView(currentValue)) {
3608
+ return {
3609
+ byteLength: currentValue.byteLength,
3610
+ type: currentValue.constructor.name
3611
+ };
3612
+ }
3613
+ if (currentValue instanceof Error) {
3614
+ return {
3615
+ message: currentValue.message,
3616
+ name: currentValue.name,
3617
+ stack: currentValue.stack
3618
+ };
3619
+ }
3620
+ if (currentValue.constructor?.name === 'MessagePort') {
3621
+ return {
3622
+ type: 'MessagePort'
3623
+ };
3624
+ }
3625
+ return currentValue;
3626
+ });
3627
+ return JSON.parse(text);
3628
+ };
3629
+ const isCommand = value => {
3630
+ return typeof value === 'object' && value !== null && 'method' in value && typeof value.method === 'string';
3631
+ };
3632
+ const initialize = search => {
3633
+ const searchParams = new URLSearchParams(search);
3634
+ state$8.enabled = searchParams.has('traceRendererWorker');
3635
+ state$8.entries = [];
3636
+ };
3637
+ const record = (direction, method, params) => {
3638
+ if (!state$8.enabled) {
3639
+ return;
3640
+ }
3641
+ state$8.entries.push({
3642
+ direction,
3643
+ method,
3644
+ params: serialize(params),
3645
+ timestamp: performance.now()
3646
+ });
3647
+ };
3648
+ const listen = rpc => {
3649
+ if (!state$8.enabled) {
3650
+ return;
3651
+ }
3652
+ const ipc = rpc.ipc;
3653
+ if (!ipc) {
3654
+ return;
3655
+ }
3656
+ ipc.addEventListener('message', event => {
3657
+ const message = ipc.getData(event);
3658
+ if (isCommand(message)) {
3659
+ record('received', message.method, message.params || []);
3660
+ }
3661
+ });
3662
+ };
3663
+ const exportToDom = () => {
3664
+ if (!state$8.enabled) {
3665
+ return;
3666
+ }
3667
+ const existing = document.querySelector(selector);
3668
+ const script = existing || document.createElement('script');
3669
+ script.className = 'RendererWorkerTrace';
3670
+ script.type = 'application/json';
3671
+ script.textContent = JSON.stringify({
3672
+ entries: state$8.entries,
3673
+ version: 1
3674
+ });
3675
+ if (!existing) {
3676
+ document.body.append(script);
3677
+ }
3678
+ };
3679
+ const scheduleExport = () => {
3680
+ if (!state$8.enabled) {
3681
+ return;
3682
+ }
3683
+ queueMicrotask(exportToDom);
3684
+ };
3685
+
3583
3686
  const state$7 = {
3584
3687
  rpc: undefined
3585
3688
  };
@@ -3590,6 +3693,7 @@ const hydrate$3 = async () => {
3590
3693
  return result;
3591
3694
  }
3592
3695
  state$7.rpc = result.value;
3696
+ listen(result.value);
3593
3697
  return success(undefined);
3594
3698
  };
3595
3699
 
@@ -3600,18 +3704,24 @@ const dispose$k = () => {
3600
3704
  }
3601
3705
  };
3602
3706
  const send = (method, ...params) => {
3707
+ record('sent', method, params);
3603
3708
  // @ts-ignore
3604
3709
  state$7.rpc.send(method, ...params);
3605
3710
  };
3606
3711
  const invoke$1 = (method, ...params) => {
3712
+ record('sent', method, params);
3607
3713
  // @ts-ignore
3608
3714
  return state$7.rpc.invoke(method, ...params);
3609
3715
  };
3610
3716
  const sendAndTransfer = message => {
3717
+ if (Array.isArray(message) && typeof message[0] === 'string') {
3718
+ record('sent', message[0], message.slice(1));
3719
+ }
3611
3720
  // @ts-expect-error
3612
3721
  state$7.rpc.sendAndTransfer(message);
3613
3722
  };
3614
3723
  const invokeAndTransfer = (method, ...params) => {
3724
+ record('sent', method, params);
3615
3725
  // @ts-ignore
3616
3726
  return state$7.rpc.invokeAndTransfer(method, ...params);
3617
3727
  };
@@ -4965,6 +5075,7 @@ const showOverlay = (state, background, text, actions = []) => {
4965
5075
  const $actions = actions.map(createAction);
4966
5076
  $TestOverlay.append(span, ...$actions);
4967
5077
  document.body.append($TestOverlay);
5078
+ scheduleExport();
4968
5079
  };
4969
5080
  const showTestResults = text => {
4970
5081
  const existing = document.querySelector('.TestResults');
@@ -4975,6 +5086,7 @@ const showTestResults = text => {
4975
5086
  if (!existing) {
4976
5087
  document.body.append($TestResults);
4977
5088
  }
5089
+ scheduleExport();
4978
5090
  };
4979
5091
  const performAction = async (locator, fnName, options) => {
4980
5092
  object(locator);
@@ -9938,6 +10050,7 @@ const enable = async window => {
9938
10050
  };
9939
10051
 
9940
10052
  const main = async () => {
10053
+ initialize(location.search);
9941
10054
  Object.assign(commandMapRef, commandMap);
9942
10055
  enable(window);
9943
10056
  state$1.modules[ColorPicker] = ViewletColorPicker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.12.4",
3
+ "version": "30.13.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"