@lvce-editor/settings-view 2.20.0 → 2.22.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 +177 -14
- 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
|
}) => {
|
|
@@ -966,12 +1081,22 @@ const computeVisibleItems = (items, height, scrollOffset, itemHeight) => {
|
|
|
966
1081
|
};
|
|
967
1082
|
};
|
|
968
1083
|
|
|
1084
|
+
const normalizeSearchText = value => {
|
|
1085
|
+
return value.replaceAll(/([a-z\d])([A-Z])/g, '$1 $2').toLowerCase().replaceAll(/[^a-z\d]+/g, ' ').trim();
|
|
1086
|
+
};
|
|
1087
|
+
const matchesSearch = (item, searchValue) => {
|
|
1088
|
+
const searchTargets = [item.heading, item.id, ...(item.aliases ?? [])];
|
|
1089
|
+
return searchTargets.some(target => normalizeSearchText(target).includes(searchValue));
|
|
1090
|
+
};
|
|
969
1091
|
const filterBySearch = (items, searchValue) => {
|
|
970
1092
|
if (!searchValue || !searchValue.trim()) {
|
|
971
1093
|
return items;
|
|
972
1094
|
}
|
|
973
|
-
const normalizedSearchValue = searchValue
|
|
974
|
-
|
|
1095
|
+
const normalizedSearchValue = normalizeSearchText(searchValue);
|
|
1096
|
+
if (!normalizedSearchValue) {
|
|
1097
|
+
return [];
|
|
1098
|
+
}
|
|
1099
|
+
return items.filter(item => matchesSearch(item, normalizedSearchValue));
|
|
975
1100
|
};
|
|
976
1101
|
|
|
977
1102
|
const filterByTab = (items, tabs) => {
|
|
@@ -1070,7 +1195,7 @@ const {
|
|
|
1070
1195
|
get: get$1,
|
|
1071
1196
|
getCommandIds,
|
|
1072
1197
|
registerCommands,
|
|
1073
|
-
set: set$
|
|
1198
|
+
set: set$5,
|
|
1074
1199
|
wrapCommand,
|
|
1075
1200
|
wrapGetter
|
|
1076
1201
|
} = create$2();
|
|
@@ -1111,7 +1236,7 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
1111
1236
|
x,
|
|
1112
1237
|
y
|
|
1113
1238
|
};
|
|
1114
|
-
set$
|
|
1239
|
+
set$5(id, state, state);
|
|
1115
1240
|
};
|
|
1116
1241
|
|
|
1117
1242
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -1665,6 +1790,7 @@ const SettingsFilter = 94;
|
|
|
1665
1790
|
|
|
1666
1791
|
const None$1 = 0;
|
|
1667
1792
|
|
|
1793
|
+
const RendererProcess = 1670;
|
|
1668
1794
|
const RendererWorker = 1;
|
|
1669
1795
|
|
|
1670
1796
|
const SetCss = 'Viewlet.setCss';
|
|
@@ -2906,7 +3032,7 @@ const getName = () => {
|
|
|
2906
3032
|
};
|
|
2907
3033
|
|
|
2908
3034
|
const rpcs = Object.create(null);
|
|
2909
|
-
const set$
|
|
3035
|
+
const set$4 = (id, rpc) => {
|
|
2910
3036
|
rpcs[id] = rpc;
|
|
2911
3037
|
};
|
|
2912
3038
|
const get = id => {
|
|
@@ -2939,7 +3065,7 @@ const create = rpcId => {
|
|
|
2939
3065
|
const mockRpc = createMockRpc({
|
|
2940
3066
|
commandMap
|
|
2941
3067
|
});
|
|
2942
|
-
set$
|
|
3068
|
+
set$4(rpcId, mockRpc);
|
|
2943
3069
|
// @ts-ignore
|
|
2944
3070
|
mockRpc[Symbol.dispose] = () => {
|
|
2945
3071
|
remove(rpcId);
|
|
@@ -2948,11 +3074,16 @@ const create = rpcId => {
|
|
|
2948
3074
|
return mockRpc;
|
|
2949
3075
|
},
|
|
2950
3076
|
set(rpc) {
|
|
2951
|
-
set$
|
|
3077
|
+
set$4(rpcId, rpc);
|
|
2952
3078
|
}
|
|
2953
3079
|
};
|
|
2954
3080
|
};
|
|
2955
3081
|
|
|
3082
|
+
const {
|
|
3083
|
+
invoke: invoke$2,
|
|
3084
|
+
set: set$3
|
|
3085
|
+
} = create(RendererProcess);
|
|
3086
|
+
|
|
2956
3087
|
class AssertionError extends Error {
|
|
2957
3088
|
constructor(message) {
|
|
2958
3089
|
super(message);
|
|
@@ -2997,8 +3128,8 @@ const number = value => {
|
|
|
2997
3128
|
};
|
|
2998
3129
|
|
|
2999
3130
|
const {
|
|
3000
|
-
invoke,
|
|
3001
|
-
set: set$
|
|
3131
|
+
invoke: invoke$1,
|
|
3132
|
+
set: set$2
|
|
3002
3133
|
} = create(RendererWorker);
|
|
3003
3134
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
3004
3135
|
number(uid);
|
|
@@ -3006,11 +3137,11 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
3006
3137
|
number(x);
|
|
3007
3138
|
number(y);
|
|
3008
3139
|
// @ts-ignore
|
|
3009
|
-
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
3140
|
+
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
3010
3141
|
};
|
|
3011
3142
|
const getAllPreferences = async () => {
|
|
3012
3143
|
// @ts-ignore
|
|
3013
|
-
return invoke('Preferences.getAll');
|
|
3144
|
+
return invoke$1('Preferences.getAll');
|
|
3014
3145
|
};
|
|
3015
3146
|
|
|
3016
3147
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -3212,6 +3343,29 @@ const handleInputFocus = state => {
|
|
|
3212
3343
|
};
|
|
3213
3344
|
};
|
|
3214
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 => {
|
|
3362
|
+
const rpc = await PlainMessagePortRpc.create({
|
|
3363
|
+
commandMap: {},
|
|
3364
|
+
messagePort: port
|
|
3365
|
+
});
|
|
3366
|
+
set$1(rpc);
|
|
3367
|
+
};
|
|
3368
|
+
|
|
3215
3369
|
const handleResizerPointerDown = (state, eventX, eventY) => {
|
|
3216
3370
|
return state;
|
|
3217
3371
|
};
|
|
@@ -3448,6 +3602,7 @@ const getSettingItemsEditor = () => {
|
|
|
3448
3602
|
},
|
|
3449
3603
|
value: 15
|
|
3450
3604
|
}, {
|
|
3605
|
+
aliases: ['editor font family'],
|
|
3451
3606
|
category: TextEditorTab,
|
|
3452
3607
|
description: fontFamilyDescription(),
|
|
3453
3608
|
heading: fontFamily(),
|
|
@@ -5266,9 +5421,16 @@ const render2 = (uid, diffResult) => {
|
|
|
5266
5421
|
newState,
|
|
5267
5422
|
oldState
|
|
5268
5423
|
} = get$1(uid);
|
|
5269
|
-
set$
|
|
5424
|
+
set$5(uid, newState, newState);
|
|
5270
5425
|
const commands = applyRender(oldState, newState, diffResult);
|
|
5271
|
-
return commands;
|
|
5426
|
+
if (!isConnected()) return commands;
|
|
5427
|
+
return renderDirect(uid, commands);
|
|
5428
|
+
};
|
|
5429
|
+
const renderDirect = async (uid, commands) => {
|
|
5430
|
+
const rendererWorkerCommands = commands.filter(command => command[0] === 'Viewlet.setFocusContext');
|
|
5431
|
+
const rendererProcessCommands = commands.filter(command => command[0] !== 'Viewlet.setFocusContext');
|
|
5432
|
+
const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
|
|
5433
|
+
return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
|
|
5272
5434
|
};
|
|
5273
5435
|
|
|
5274
5436
|
const renderActions = () => {
|
|
@@ -5412,6 +5574,7 @@ const commandMap = {
|
|
|
5412
5574
|
'Settings.handleInput': wrapCommand(handleInput),
|
|
5413
5575
|
'Settings.handleInputBlur': wrapCommand(handleInputBlur),
|
|
5414
5576
|
'Settings.handleInputFocus': wrapCommand(handleInputFocus),
|
|
5577
|
+
'Settings.handleMessagePort': handleMessagePort,
|
|
5415
5578
|
'Settings.handleResizerPointerDown': wrapCommand(handleResizerPointerDown),
|
|
5416
5579
|
'Settings.handleResizerPointerMove': wrapCommand(handleResizerPointerMove),
|
|
5417
5580
|
'Settings.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
|
|
@@ -5432,7 +5595,7 @@ const commandMap = {
|
|
|
5432
5595
|
};
|
|
5433
5596
|
|
|
5434
5597
|
const set = rpc => {
|
|
5435
|
-
set$
|
|
5598
|
+
set$2(rpc);
|
|
5436
5599
|
};
|
|
5437
5600
|
|
|
5438
5601
|
const listen = async () => {
|