@lvce-editor/settings-view 2.21.0 → 2.23.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/settingsViewWorkerMain.js +175 -12
- package/package.json +1 -1
|
@@ -368,6 +368,100 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
368
368
|
listen: listen$6,
|
|
369
369
|
wrap: wrap$e
|
|
370
370
|
};
|
|
371
|
+
const addListener = (emitter, type, callback) => {
|
|
372
|
+
if ('addEventListener' in emitter) {
|
|
373
|
+
emitter.addEventListener(type, callback);
|
|
374
|
+
} else {
|
|
375
|
+
emitter.on(type, callback);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const removeListener = (emitter, type, callback) => {
|
|
379
|
+
if ('removeEventListener' in emitter) {
|
|
380
|
+
emitter.removeEventListener(type, callback);
|
|
381
|
+
} else {
|
|
382
|
+
emitter.off(type, callback);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
386
|
+
const {
|
|
387
|
+
promise,
|
|
388
|
+
resolve
|
|
389
|
+
} = Promise.withResolvers();
|
|
390
|
+
const listenerMap = Object.create(null);
|
|
391
|
+
const cleanup = value => {
|
|
392
|
+
for (const event of Object.keys(eventMap)) {
|
|
393
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
394
|
+
}
|
|
395
|
+
resolve(value);
|
|
396
|
+
};
|
|
397
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
398
|
+
const listener = event => {
|
|
399
|
+
cleanup({
|
|
400
|
+
event,
|
|
401
|
+
type
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
addListener(eventEmitter, event, listener);
|
|
405
|
+
listenerMap[event] = listener;
|
|
406
|
+
}
|
|
407
|
+
return promise;
|
|
408
|
+
};
|
|
409
|
+
const Message$1 = 3;
|
|
410
|
+
const create$5 = async ({
|
|
411
|
+
isMessagePortOpen,
|
|
412
|
+
messagePort
|
|
413
|
+
}) => {
|
|
414
|
+
if (!isMessagePort(messagePort)) {
|
|
415
|
+
throw new IpcError('port must be of type MessagePort');
|
|
416
|
+
}
|
|
417
|
+
if (isMessagePortOpen) {
|
|
418
|
+
return messagePort;
|
|
419
|
+
}
|
|
420
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
421
|
+
message: Message$1
|
|
422
|
+
});
|
|
423
|
+
messagePort.start();
|
|
424
|
+
const {
|
|
425
|
+
event,
|
|
426
|
+
type
|
|
427
|
+
} = await eventPromise;
|
|
428
|
+
if (type !== Message$1) {
|
|
429
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
430
|
+
}
|
|
431
|
+
if (event.data !== readyMessage) {
|
|
432
|
+
throw new IpcError('unexpected first message');
|
|
433
|
+
}
|
|
434
|
+
return messagePort;
|
|
435
|
+
};
|
|
436
|
+
const signal$1 = messagePort => {
|
|
437
|
+
messagePort.start();
|
|
438
|
+
};
|
|
439
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
440
|
+
getData = getData$2;
|
|
441
|
+
send(message) {
|
|
442
|
+
this._rawIpc.postMessage(message);
|
|
443
|
+
}
|
|
444
|
+
sendAndTransfer(message) {
|
|
445
|
+
const transfer = getTransferrables(message);
|
|
446
|
+
this._rawIpc.postMessage(message, transfer);
|
|
447
|
+
}
|
|
448
|
+
dispose() {
|
|
449
|
+
this._rawIpc.close();
|
|
450
|
+
}
|
|
451
|
+
onMessage(callback) {
|
|
452
|
+
this._rawIpc.addEventListener('message', callback);
|
|
453
|
+
}
|
|
454
|
+
onClose(callback) {}
|
|
455
|
+
}
|
|
456
|
+
const wrap$5 = messagePort => {
|
|
457
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
458
|
+
};
|
|
459
|
+
const IpcParentWithMessagePort$1 = {
|
|
460
|
+
__proto__: null,
|
|
461
|
+
create: create$5,
|
|
462
|
+
signal: signal$1,
|
|
463
|
+
wrap: wrap$5
|
|
464
|
+
};
|
|
371
465
|
|
|
372
466
|
const Two$1 = '2.0';
|
|
373
467
|
const callbacks = Object.create(null);
|
|
@@ -820,6 +914,27 @@ const listen$1 = async (module, options) => {
|
|
|
820
914
|
const ipc = module.wrap(rawIpc);
|
|
821
915
|
return ipc;
|
|
822
916
|
};
|
|
917
|
+
const create$4 = async ({
|
|
918
|
+
commandMap,
|
|
919
|
+
isMessagePortOpen = true,
|
|
920
|
+
messagePort
|
|
921
|
+
}) => {
|
|
922
|
+
// TODO create a commandMap per rpc instance
|
|
923
|
+
register(commandMap);
|
|
924
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
925
|
+
isMessagePortOpen,
|
|
926
|
+
messagePort
|
|
927
|
+
});
|
|
928
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
929
|
+
handleIpc(ipc);
|
|
930
|
+
const rpc = createRpc(ipc);
|
|
931
|
+
messagePort.start();
|
|
932
|
+
return rpc;
|
|
933
|
+
};
|
|
934
|
+
const PlainMessagePortRpc = {
|
|
935
|
+
__proto__: null,
|
|
936
|
+
create: create$4
|
|
937
|
+
};
|
|
823
938
|
const create$1$1 = async ({
|
|
824
939
|
commandMap
|
|
825
940
|
}) => {
|
|
@@ -1080,7 +1195,7 @@ const {
|
|
|
1080
1195
|
get: get$1,
|
|
1081
1196
|
getCommandIds,
|
|
1082
1197
|
registerCommands,
|
|
1083
|
-
set: set$
|
|
1198
|
+
set: set$5,
|
|
1084
1199
|
wrapCommand,
|
|
1085
1200
|
wrapGetter
|
|
1086
1201
|
} = create$2();
|
|
@@ -1121,7 +1236,7 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
1121
1236
|
x,
|
|
1122
1237
|
y
|
|
1123
1238
|
};
|
|
1124
|
-
set$
|
|
1239
|
+
set$5(id, state, state);
|
|
1125
1240
|
};
|
|
1126
1241
|
|
|
1127
1242
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -1675,6 +1790,7 @@ const SettingsFilter = 94;
|
|
|
1675
1790
|
|
|
1676
1791
|
const None$1 = 0;
|
|
1677
1792
|
|
|
1793
|
+
const RendererProcess = 1670;
|
|
1678
1794
|
const RendererWorker = 1;
|
|
1679
1795
|
|
|
1680
1796
|
const SetCss = 'Viewlet.setCss';
|
|
@@ -2916,7 +3032,7 @@ const getName = () => {
|
|
|
2916
3032
|
};
|
|
2917
3033
|
|
|
2918
3034
|
const rpcs = Object.create(null);
|
|
2919
|
-
const set$
|
|
3035
|
+
const set$4 = (id, rpc) => {
|
|
2920
3036
|
rpcs[id] = rpc;
|
|
2921
3037
|
};
|
|
2922
3038
|
const get = id => {
|
|
@@ -2949,7 +3065,7 @@ const create = rpcId => {
|
|
|
2949
3065
|
const mockRpc = createMockRpc({
|
|
2950
3066
|
commandMap
|
|
2951
3067
|
});
|
|
2952
|
-
set$
|
|
3068
|
+
set$4(rpcId, mockRpc);
|
|
2953
3069
|
// @ts-ignore
|
|
2954
3070
|
mockRpc[Symbol.dispose] = () => {
|
|
2955
3071
|
remove(rpcId);
|
|
@@ -2958,11 +3074,16 @@ const create = rpcId => {
|
|
|
2958
3074
|
return mockRpc;
|
|
2959
3075
|
},
|
|
2960
3076
|
set(rpc) {
|
|
2961
|
-
set$
|
|
3077
|
+
set$4(rpcId, rpc);
|
|
2962
3078
|
}
|
|
2963
3079
|
};
|
|
2964
3080
|
};
|
|
2965
3081
|
|
|
3082
|
+
const {
|
|
3083
|
+
invoke: invoke$2,
|
|
3084
|
+
set: set$3
|
|
3085
|
+
} = create(RendererProcess);
|
|
3086
|
+
|
|
2966
3087
|
class AssertionError extends Error {
|
|
2967
3088
|
constructor(message) {
|
|
2968
3089
|
super(message);
|
|
@@ -3007,8 +3128,8 @@ const number = value => {
|
|
|
3007
3128
|
};
|
|
3008
3129
|
|
|
3009
3130
|
const {
|
|
3010
|
-
invoke,
|
|
3011
|
-
set: set$
|
|
3131
|
+
invoke: invoke$1,
|
|
3132
|
+
set: set$2
|
|
3012
3133
|
} = create(RendererWorker);
|
|
3013
3134
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
3014
3135
|
number(uid);
|
|
@@ -3016,11 +3137,11 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
3016
3137
|
number(x);
|
|
3017
3138
|
number(y);
|
|
3018
3139
|
// @ts-ignore
|
|
3019
|
-
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
3140
|
+
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
3020
3141
|
};
|
|
3021
3142
|
const getAllPreferences = async () => {
|
|
3022
3143
|
// @ts-ignore
|
|
3023
|
-
return invoke('Preferences.getAll');
|
|
3144
|
+
return invoke$1('Preferences.getAll');
|
|
3024
3145
|
};
|
|
3025
3146
|
|
|
3026
3147
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -3222,6 +3343,39 @@ const handleInputFocus = state => {
|
|
|
3222
3343
|
};
|
|
3223
3344
|
};
|
|
3224
3345
|
|
|
3346
|
+
const state = {
|
|
3347
|
+
connected: false
|
|
3348
|
+
};
|
|
3349
|
+
const isConnected = () => {
|
|
3350
|
+
const {
|
|
3351
|
+
connected
|
|
3352
|
+
} = state;
|
|
3353
|
+
return connected;
|
|
3354
|
+
};
|
|
3355
|
+
const invoke = (method, ...params) => invoke$2(method, ...params);
|
|
3356
|
+
const set$1 = rpc => {
|
|
3357
|
+
set$3(rpc);
|
|
3358
|
+
state.connected = true;
|
|
3359
|
+
};
|
|
3360
|
+
|
|
3361
|
+
const handleMessagePort = async (port, viewletCommandMap) => {
|
|
3362
|
+
const executeViewletCommand = async (uid, command, ...args) => {
|
|
3363
|
+
const fn = viewletCommandMap[`Settings.${command}`];
|
|
3364
|
+
if (typeof fn !== 'function') {
|
|
3365
|
+
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
3366
|
+
}
|
|
3367
|
+
await fn(uid, ...args);
|
|
3368
|
+
await invoke$1('Viewlet.requestRender', uid);
|
|
3369
|
+
};
|
|
3370
|
+
const rpc = await PlainMessagePortRpc.create({
|
|
3371
|
+
commandMap: {
|
|
3372
|
+
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
3373
|
+
},
|
|
3374
|
+
messagePort: port
|
|
3375
|
+
});
|
|
3376
|
+
set$1(rpc);
|
|
3377
|
+
};
|
|
3378
|
+
|
|
3225
3379
|
const handleResizerPointerDown = (state, eventX, eventY) => {
|
|
3226
3380
|
return state;
|
|
3227
3381
|
};
|
|
@@ -5277,9 +5431,16 @@ const render2 = (uid, diffResult) => {
|
|
|
5277
5431
|
newState,
|
|
5278
5432
|
oldState
|
|
5279
5433
|
} = get$1(uid);
|
|
5280
|
-
set$
|
|
5434
|
+
set$5(uid, newState, newState);
|
|
5281
5435
|
const commands = applyRender(oldState, newState, diffResult);
|
|
5282
|
-
return commands;
|
|
5436
|
+
if (!isConnected()) return commands;
|
|
5437
|
+
return renderDirect(uid, commands);
|
|
5438
|
+
};
|
|
5439
|
+
const renderDirect = async (uid, commands) => {
|
|
5440
|
+
const rendererWorkerCommands = commands.filter(command => command[0] === 'Viewlet.setFocusContext');
|
|
5441
|
+
const rendererProcessCommands = commands.filter(command => command[0] !== 'Viewlet.setFocusContext');
|
|
5442
|
+
const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
|
|
5443
|
+
return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
|
|
5283
5444
|
};
|
|
5284
5445
|
|
|
5285
5446
|
const renderActions = () => {
|
|
@@ -5407,6 +5568,7 @@ const usePreviousSearchValue = state => {
|
|
|
5407
5568
|
};
|
|
5408
5569
|
};
|
|
5409
5570
|
|
|
5571
|
+
const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
|
|
5410
5572
|
const commandMap = {
|
|
5411
5573
|
'Initialize.initialize': initialize,
|
|
5412
5574
|
'Settings.clear': wrapCommand(clear$1),
|
|
@@ -5423,6 +5585,7 @@ const commandMap = {
|
|
|
5423
5585
|
'Settings.handleInput': wrapCommand(handleInput),
|
|
5424
5586
|
'Settings.handleInputBlur': wrapCommand(handleInputBlur),
|
|
5425
5587
|
'Settings.handleInputFocus': wrapCommand(handleInputFocus),
|
|
5588
|
+
'Settings.handleMessagePort': handleDirectMessagePort,
|
|
5426
5589
|
'Settings.handleResizerPointerDown': wrapCommand(handleResizerPointerDown),
|
|
5427
5590
|
'Settings.handleResizerPointerMove': wrapCommand(handleResizerPointerMove),
|
|
5428
5591
|
'Settings.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
|
|
@@ -5443,7 +5606,7 @@ const commandMap = {
|
|
|
5443
5606
|
};
|
|
5444
5607
|
|
|
5445
5608
|
const set = rpc => {
|
|
5446
|
-
set$
|
|
5609
|
+
set$2(rpc);
|
|
5447
5610
|
};
|
|
5448
5611
|
|
|
5449
5612
|
const listen = async () => {
|