@lvce-editor/renderer-process 30.12.3 → 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.
- package/dist/rendererProcessMain.js +167 -34
- package/package.json +1 -1
|
@@ -118,25 +118,25 @@ const confirm = message => {
|
|
|
118
118
|
return window.confirm(message);
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
const state$
|
|
121
|
+
const state$b = {
|
|
122
122
|
styleSheets: Object.create(null),
|
|
123
123
|
texts: Object.create(null)
|
|
124
124
|
};
|
|
125
|
-
const set$
|
|
126
|
-
state$
|
|
125
|
+
const set$b = (id, sheet) => {
|
|
126
|
+
state$b.styleSheets[id] = sheet;
|
|
127
127
|
};
|
|
128
128
|
const get$b = id => {
|
|
129
|
-
return state$
|
|
129
|
+
return state$b.styleSheets[id];
|
|
130
130
|
};
|
|
131
131
|
const setText$2 = (id, text) => {
|
|
132
|
-
state$
|
|
132
|
+
state$b.texts[id] = text;
|
|
133
133
|
};
|
|
134
134
|
const getText = id => {
|
|
135
|
-
return state$
|
|
135
|
+
return state$b.texts[id];
|
|
136
136
|
};
|
|
137
|
-
const remove$
|
|
138
|
-
delete state$
|
|
139
|
-
delete state$
|
|
137
|
+
const remove$5 = id => {
|
|
138
|
+
delete state$b.styleSheets[id];
|
|
139
|
+
delete state$b.texts[id];
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
const addCssStyleSheet = (id, text) => {
|
|
@@ -147,7 +147,7 @@ const addCssStyleSheet = (id, text) => {
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
const sheet = new CSSStyleSheet({});
|
|
150
|
-
set$
|
|
150
|
+
set$b(id, sheet);
|
|
151
151
|
setText$2(id, text);
|
|
152
152
|
sheet.replaceSync(text);
|
|
153
153
|
document.adoptedStyleSheets.push(sheet);
|
|
@@ -177,7 +177,7 @@ const removeCssStyleSheet = id => {
|
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(candidate => candidate !== sheet);
|
|
180
|
-
remove$
|
|
180
|
+
remove$5(id);
|
|
181
181
|
};
|
|
182
182
|
const getSelectionText = () => {
|
|
183
183
|
return document.getSelection()?.toString() || '';
|
|
@@ -338,10 +338,10 @@ const createIdGenerator = () => {
|
|
|
338
338
|
};
|
|
339
339
|
const create$L = createIdGenerator();
|
|
340
340
|
|
|
341
|
-
const state$
|
|
341
|
+
const state$a = Object.create(null);
|
|
342
342
|
const acquire$1 = id => {
|
|
343
|
-
const promise = state$
|
|
344
|
-
delete state$
|
|
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$
|
|
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$
|
|
531
|
+
const state$9 = {
|
|
532
532
|
ipc: undefined
|
|
533
533
|
};
|
|
534
534
|
const getIpc = () => {
|
|
535
|
-
return state$
|
|
535
|
+
return state$9.ipc;
|
|
536
536
|
};
|
|
537
537
|
const setIpc = value => {
|
|
538
|
-
state$
|
|
538
|
+
state$9.ipc = value;
|
|
539
539
|
};
|
|
540
540
|
|
|
541
541
|
const nameAnonymousFunction$1 = (fn, name) => {
|
|
@@ -1261,7 +1261,7 @@ const instances = Object.create(null);
|
|
|
1261
1261
|
const get$a = viewletId => {
|
|
1262
1262
|
return instances[viewletId];
|
|
1263
1263
|
};
|
|
1264
|
-
const set$
|
|
1264
|
+
const set$a = (viewletId, instance) => {
|
|
1265
1265
|
instances[viewletId] = instance;
|
|
1266
1266
|
};
|
|
1267
1267
|
|
|
@@ -1290,7 +1290,7 @@ const cache = new Map();
|
|
|
1290
1290
|
const has$1 = listener => {
|
|
1291
1291
|
return cache.has(listener);
|
|
1292
1292
|
};
|
|
1293
|
-
const set$
|
|
1293
|
+
const set$9 = (listener, value) => {
|
|
1294
1294
|
cache.set(listener, value);
|
|
1295
1295
|
};
|
|
1296
1296
|
const get$9 = listener => {
|
|
@@ -1313,7 +1313,7 @@ const getWrappedListener = (listener, returnValue) => {
|
|
|
1313
1313
|
ipc.send('Viewlet.executeViewletCommand', uid, ...result);
|
|
1314
1314
|
};
|
|
1315
1315
|
nameAnonymousFunction$1(wrapped, listener.name);
|
|
1316
|
-
set$
|
|
1316
|
+
set$9(listener, wrapped);
|
|
1317
1317
|
}
|
|
1318
1318
|
return get$9(listener);
|
|
1319
1319
|
};
|
|
@@ -2820,7 +2820,7 @@ const callbacks = Object.create(null);
|
|
|
2820
2820
|
const get$7 = id => {
|
|
2821
2821
|
return callbacks[id];
|
|
2822
2822
|
};
|
|
2823
|
-
const remove$
|
|
2823
|
+
const remove$4 = id => {
|
|
2824
2824
|
delete callbacks[id];
|
|
2825
2825
|
};
|
|
2826
2826
|
class JsonRpcError extends Error {
|
|
@@ -3014,7 +3014,7 @@ const resolve = (id, response) => {
|
|
|
3014
3014
|
return;
|
|
3015
3015
|
}
|
|
3016
3016
|
fn(response);
|
|
3017
|
-
remove$
|
|
3017
|
+
remove$4(id);
|
|
3018
3018
|
};
|
|
3019
3019
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
3020
3020
|
const getErrorType = prettyError => {
|
|
@@ -3376,18 +3376,33 @@ const create$z = async ({
|
|
|
3376
3376
|
});
|
|
3377
3377
|
};
|
|
3378
3378
|
|
|
3379
|
-
|
|
3379
|
+
const workers = Object.create(null);
|
|
3380
|
+
const set$8 = (id, worker) => {
|
|
3381
|
+
workers[id] = worker;
|
|
3382
|
+
};
|
|
3383
|
+
const remove$3 = id => {
|
|
3384
|
+
const worker = workers[id];
|
|
3385
|
+
delete workers[id];
|
|
3386
|
+
return worker;
|
|
3387
|
+
};
|
|
3388
|
+
|
|
3380
3389
|
const create$y = async ({
|
|
3390
|
+
id,
|
|
3381
3391
|
name,
|
|
3382
3392
|
port,
|
|
3393
|
+
raw,
|
|
3383
3394
|
url
|
|
3384
|
-
}) => {
|
|
3385
|
-
await
|
|
3395
|
+
}, createRpc = create$A) => {
|
|
3396
|
+
const rpc = await createRpc({
|
|
3386
3397
|
commandMap: {},
|
|
3387
3398
|
name,
|
|
3388
3399
|
port,
|
|
3389
3400
|
url
|
|
3390
3401
|
});
|
|
3402
|
+
const worker = rpc.ipc?._rawIpc;
|
|
3403
|
+
if (typeof id === 'number' && raw && worker) {
|
|
3404
|
+
set$8(id, worker);
|
|
3405
|
+
}
|
|
3391
3406
|
return undefined;
|
|
3392
3407
|
};
|
|
3393
3408
|
|
|
@@ -3565,6 +3580,109 @@ const launchRendererWorker = async () => {
|
|
|
3565
3580
|
});
|
|
3566
3581
|
};
|
|
3567
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
|
+
|
|
3568
3686
|
const state$7 = {
|
|
3569
3687
|
rpc: undefined
|
|
3570
3688
|
};
|
|
@@ -3575,35 +3693,42 @@ const hydrate$3 = async () => {
|
|
|
3575
3693
|
return result;
|
|
3576
3694
|
}
|
|
3577
3695
|
state$7.rpc = result.value;
|
|
3696
|
+
listen(result.value);
|
|
3578
3697
|
return success(undefined);
|
|
3579
3698
|
};
|
|
3580
3699
|
|
|
3581
3700
|
// TODO needed?
|
|
3582
|
-
const dispose$
|
|
3701
|
+
const dispose$k = () => {
|
|
3583
3702
|
if (state$7.rpc) {
|
|
3584
3703
|
state$7.rpc.dispose();
|
|
3585
3704
|
}
|
|
3586
3705
|
};
|
|
3587
3706
|
const send = (method, ...params) => {
|
|
3707
|
+
record('sent', method, params);
|
|
3588
3708
|
// @ts-ignore
|
|
3589
3709
|
state$7.rpc.send(method, ...params);
|
|
3590
3710
|
};
|
|
3591
3711
|
const invoke$1 = (method, ...params) => {
|
|
3712
|
+
record('sent', method, params);
|
|
3592
3713
|
// @ts-ignore
|
|
3593
3714
|
return state$7.rpc.invoke(method, ...params);
|
|
3594
3715
|
};
|
|
3595
3716
|
const sendAndTransfer = message => {
|
|
3717
|
+
if (Array.isArray(message) && typeof message[0] === 'string') {
|
|
3718
|
+
record('sent', message[0], message.slice(1));
|
|
3719
|
+
}
|
|
3596
3720
|
// @ts-expect-error
|
|
3597
3721
|
state$7.rpc.sendAndTransfer(message);
|
|
3598
3722
|
};
|
|
3599
3723
|
const invokeAndTransfer = (method, ...params) => {
|
|
3724
|
+
record('sent', method, params);
|
|
3600
3725
|
// @ts-ignore
|
|
3601
3726
|
return state$7.rpc.invokeAndTransfer(method, ...params);
|
|
3602
3727
|
};
|
|
3603
3728
|
|
|
3604
3729
|
const RendererWorker = {
|
|
3605
3730
|
__proto__: null,
|
|
3606
|
-
dispose: dispose$
|
|
3731
|
+
dispose: dispose$k,
|
|
3607
3732
|
hydrate: hydrate$3,
|
|
3608
3733
|
invoke: invoke$1,
|
|
3609
3734
|
invokeAndTransfer,
|
|
@@ -3631,6 +3756,10 @@ const create$w = async ({
|
|
|
3631
3756
|
// @ts-ignore
|
|
3632
3757
|
return module.create(options);
|
|
3633
3758
|
};
|
|
3759
|
+
const dispose$j = id => {
|
|
3760
|
+
const worker = remove$3(id);
|
|
3761
|
+
worker?.terminate();
|
|
3762
|
+
};
|
|
3634
3763
|
|
|
3635
3764
|
const getElementHeight = $Element => {
|
|
3636
3765
|
document.body.append($Element);
|
|
@@ -3811,7 +3940,7 @@ const create2 = async (canvasId, objectId, width, height) => {
|
|
|
3811
3940
|
}
|
|
3812
3941
|
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
3813
3942
|
canvas.dataset.id = canvasId;
|
|
3814
|
-
set$
|
|
3943
|
+
set$a(canvasId, {
|
|
3815
3944
|
factory: {},
|
|
3816
3945
|
state: {
|
|
3817
3946
|
$Viewlet: canvas
|
|
@@ -4946,6 +5075,7 @@ const showOverlay = (state, background, text, actions = []) => {
|
|
|
4946
5075
|
const $actions = actions.map(createAction);
|
|
4947
5076
|
$TestOverlay.append(span, ...$actions);
|
|
4948
5077
|
document.body.append($TestOverlay);
|
|
5078
|
+
scheduleExport();
|
|
4949
5079
|
};
|
|
4950
5080
|
const showTestResults = text => {
|
|
4951
5081
|
const existing = document.querySelector('.TestResults');
|
|
@@ -4956,6 +5086,7 @@ const showTestResults = text => {
|
|
|
4956
5086
|
if (!existing) {
|
|
4957
5087
|
document.body.append($TestResults);
|
|
4958
5088
|
}
|
|
5089
|
+
scheduleExport();
|
|
4959
5090
|
};
|
|
4960
5091
|
const performAction = async (locator, fnName, options) => {
|
|
4961
5092
|
object(locator);
|
|
@@ -8573,7 +8704,7 @@ const create$4 = (id, uid = id) => {
|
|
|
8573
8704
|
if (module.attachEvents) {
|
|
8574
8705
|
module.attachEvents(instanceState);
|
|
8575
8706
|
}
|
|
8576
|
-
set$
|
|
8707
|
+
set$a(uid, {
|
|
8577
8708
|
factory: module,
|
|
8578
8709
|
state: instanceState
|
|
8579
8710
|
});
|
|
@@ -8593,7 +8724,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
|
|
|
8593
8724
|
const instanceState = {
|
|
8594
8725
|
$Viewlet: document.createElement('div')
|
|
8595
8726
|
};
|
|
8596
|
-
set$
|
|
8727
|
+
set$a(uid, {
|
|
8597
8728
|
factory: module,
|
|
8598
8729
|
state: instanceState
|
|
8599
8730
|
});
|
|
@@ -8774,7 +8905,7 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
|
|
|
8774
8905
|
const parentInstance = get$a(parentId);
|
|
8775
8906
|
const $Parent = parentInstance.state.$Viewlet;
|
|
8776
8907
|
$Parent.append($Placeholder);
|
|
8777
|
-
set$
|
|
8908
|
+
set$a(viewletId, {
|
|
8778
8909
|
state: {
|
|
8779
8910
|
$Viewlet: $Placeholder
|
|
8780
8911
|
}
|
|
@@ -8819,7 +8950,7 @@ const setDom2 = (viewletId, dom) => {
|
|
|
8819
8950
|
// @ts-ignore
|
|
8820
8951
|
set$3($NewViewlet, uid);
|
|
8821
8952
|
}
|
|
8822
|
-
set$
|
|
8953
|
+
set$a(viewletId, {
|
|
8823
8954
|
...instance,
|
|
8824
8955
|
state: {
|
|
8825
8956
|
...instance.state,
|
|
@@ -8905,7 +9036,7 @@ const dispose$4 = id => {
|
|
|
8905
9036
|
instance.state.$Viewlet.remove();
|
|
8906
9037
|
}
|
|
8907
9038
|
removeCssStyleSheet(id);
|
|
8908
|
-
set$
|
|
9039
|
+
set$a(id, undefined);
|
|
8909
9040
|
} catch {
|
|
8910
9041
|
throw new Error(`Failed to dispose ${id}`);
|
|
8911
9042
|
}
|
|
@@ -9358,6 +9489,7 @@ const commandMap = {
|
|
|
9358
9489
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9359
9490
|
'InitData.getInitData': getInitData,
|
|
9360
9491
|
'IpcParent.create': create$w,
|
|
9492
|
+
'IpcParent.dispose': dispose$j,
|
|
9361
9493
|
'KeyBindings.setIdentifiers': setIdentifiers,
|
|
9362
9494
|
'Layout.getBounds': getBounds,
|
|
9363
9495
|
'Location.getHref': getHref,
|
|
@@ -9918,6 +10050,7 @@ const enable = async window => {
|
|
|
9918
10050
|
};
|
|
9919
10051
|
|
|
9920
10052
|
const main = async () => {
|
|
10053
|
+
initialize(location.search);
|
|
9921
10054
|
Object.assign(commandMapRef, commandMap);
|
|
9922
10055
|
enable(window);
|
|
9923
10056
|
state$1.modules[ColorPicker] = ViewletColorPicker;
|