@lvce-editor/test-worker 16.2.0 → 16.4.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/api.d.ts +11 -0
- package/dist/testWorkerMain.js +159 -86
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -268,6 +268,7 @@ export type SelectItemWaitUntil = "done" | "quickPick" | "none";
|
|
|
268
268
|
export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
|
|
269
269
|
|
|
270
270
|
interface Workspace {
|
|
271
|
+
readonly close: () => Promise<void>;
|
|
271
272
|
readonly openTmpDir: () => Promise<string>;
|
|
272
273
|
readonly setPath: (path: string) => Promise<void>;
|
|
273
274
|
}
|
|
@@ -505,9 +506,13 @@ interface Editor {
|
|
|
505
506
|
readonly goToDefinition: () => Promise<void>;
|
|
506
507
|
readonly goToTypeDefinition: () => Promise<void>;
|
|
507
508
|
readonly growSelection: () => Promise<void>;
|
|
509
|
+
readonly handleTab: () => Promise<void>;
|
|
510
|
+
readonly indentLess: () => Promise<void>;
|
|
511
|
+
readonly indentMore: () => Promise<void>;
|
|
508
512
|
readonly insertLineBreak: () => Promise<void>;
|
|
509
513
|
readonly invokeBraceCompletion: (text: string) => Promise<void>;
|
|
510
514
|
readonly invokeTabCompletion: () => Promise<void>;
|
|
515
|
+
readonly moveLineDown: () => Promise<void>;
|
|
511
516
|
readonly openColorPicker: () => Promise<void>;
|
|
512
517
|
readonly openCompletion: () => Promise<void>;
|
|
513
518
|
readonly openCompletionDetails: () => Promise<void>;
|
|
@@ -519,6 +524,7 @@ interface Editor {
|
|
|
519
524
|
readonly openRename: () => Promise<void>;
|
|
520
525
|
readonly openSourceActions: () => Promise<void>;
|
|
521
526
|
readonly organizeImports: () => Promise<void>;
|
|
527
|
+
readonly pasteText: (text: string) => Promise<void>;
|
|
522
528
|
readonly redo: () => Promise<void>;
|
|
523
529
|
readonly rename: () => Promise<void>;
|
|
524
530
|
readonly rename2: (newName: string) => Promise<void>;
|
|
@@ -533,6 +539,8 @@ interface Editor {
|
|
|
533
539
|
readonly selectNextOccurrence: () => Promise<void>;
|
|
534
540
|
readonly selectPreviousOccurrence: () => Promise<void>;
|
|
535
541
|
readonly selectUp: () => Promise<void>;
|
|
542
|
+
readonly selectWordLeft: () => Promise<void>;
|
|
543
|
+
readonly selectWordRight: () => Promise<void>;
|
|
536
544
|
readonly selectionGrow: () => Promise<void>;
|
|
537
545
|
readonly setCursor: (rowIndex: number, columnIndex: number) => Promise<void>;
|
|
538
546
|
readonly setDeltaY: (deltaY: number) => Promise<void>;
|
|
@@ -545,11 +553,13 @@ interface Editor {
|
|
|
545
553
|
readonly shouldHaveTokens: (expectedTokens: readonly TokenRow[]) => Promise<void>;
|
|
546
554
|
readonly showHover: () => Promise<void>;
|
|
547
555
|
readonly sortImports: () => Promise<void>;
|
|
556
|
+
readonly sortLinesAscending: () => Promise<void>;
|
|
548
557
|
readonly sourceActionsSelectCurrent: () => Promise<void>;
|
|
549
558
|
readonly toggleBlockComment: () => Promise<void>;
|
|
550
559
|
readonly toggleCompletionDetails: () => Promise<void>;
|
|
551
560
|
readonly toggleLineComment: () => Promise<void>;
|
|
552
561
|
readonly type: (text: string) => Promise<void>;
|
|
562
|
+
readonly typeWithAutoClosing: (text: string) => Promise<void>;
|
|
553
563
|
readonly unIndent: () => Promise<void>;
|
|
554
564
|
readonly undo: () => Promise<void>;
|
|
555
565
|
}
|
|
@@ -686,6 +696,7 @@ interface FileSystem {
|
|
|
686
696
|
readonly shouldHaveFile: (uri: string, expectedContent: string) => Promise<void>;
|
|
687
697
|
readonly shouldHaveFolder: (uri: string) => Promise<void>;
|
|
688
698
|
readonly writeFile: (uri: string, content: string) => Promise<void>;
|
|
699
|
+
readonly writeFiles: (files: readonly FileItem[]) => Promise<void>;
|
|
689
700
|
readonly writeJson: (uri: string, data: any) => Promise<void>;
|
|
690
701
|
}
|
|
691
702
|
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -1265,15 +1265,17 @@ const initializeOpenerWorker = async () => {
|
|
|
1265
1265
|
set$3(rpc);
|
|
1266
1266
|
};
|
|
1267
1267
|
|
|
1268
|
-
|
|
1268
|
+
const state$3 = {
|
|
1269
|
+
autoFixError: undefined
|
|
1270
|
+
};
|
|
1269
1271
|
const get$1 = () => {
|
|
1270
|
-
return autoFixError;
|
|
1272
|
+
return state$3.autoFixError;
|
|
1271
1273
|
};
|
|
1272
1274
|
const set$1 = value => {
|
|
1273
|
-
autoFixError = value;
|
|
1275
|
+
state$3.autoFixError = value;
|
|
1274
1276
|
};
|
|
1275
1277
|
const clear$3 = () => {
|
|
1276
|
-
autoFixError = undefined;
|
|
1278
|
+
state$3.autoFixError = undefined;
|
|
1277
1279
|
};
|
|
1278
1280
|
|
|
1279
1281
|
class AssertionError extends Error {
|
|
@@ -1316,7 +1318,7 @@ const printLocator = locator => {
|
|
|
1316
1318
|
result = part.selector;
|
|
1317
1319
|
continue;
|
|
1318
1320
|
}
|
|
1319
|
-
result
|
|
1321
|
+
result += ` >> ${part.selector}`;
|
|
1320
1322
|
continue;
|
|
1321
1323
|
}
|
|
1322
1324
|
if (part.type === 'text') {
|
|
@@ -1324,14 +1326,14 @@ const printLocator = locator => {
|
|
|
1324
1326
|
result = `text=${part.text}`;
|
|
1325
1327
|
continue;
|
|
1326
1328
|
}
|
|
1327
|
-
result
|
|
1329
|
+
result += ` text=${part.text}`;
|
|
1328
1330
|
continue;
|
|
1329
1331
|
}
|
|
1330
1332
|
if (part.type === 'has-text') {
|
|
1331
|
-
result
|
|
1333
|
+
result += ` "${part.text}"`;
|
|
1332
1334
|
continue;
|
|
1333
1335
|
}
|
|
1334
|
-
result
|
|
1336
|
+
result += `:nth(${part.index})`;
|
|
1335
1337
|
}
|
|
1336
1338
|
return result;
|
|
1337
1339
|
};
|
|
@@ -1618,7 +1620,7 @@ const nameAnonymousFunction = (fn, name) => {
|
|
|
1618
1620
|
|
|
1619
1621
|
// @ts-nocheck
|
|
1620
1622
|
|
|
1621
|
-
const state = {
|
|
1623
|
+
const state$2 = {
|
|
1622
1624
|
mockRpcs: Object.create(null),
|
|
1623
1625
|
/**
|
|
1624
1626
|
* @type {any[]}
|
|
@@ -1626,7 +1628,7 @@ const state = {
|
|
|
1626
1628
|
pendingTests: []
|
|
1627
1629
|
};
|
|
1628
1630
|
const addTest = (name, fn) => {
|
|
1629
|
-
state.pendingTests.push({
|
|
1631
|
+
state$2.pendingTests.push({
|
|
1630
1632
|
fn,
|
|
1631
1633
|
name
|
|
1632
1634
|
});
|
|
@@ -1634,7 +1636,7 @@ const addTest = (name, fn) => {
|
|
|
1634
1636
|
const setMockRpc = mockRpc => {
|
|
1635
1637
|
object(mockRpc);
|
|
1636
1638
|
string$1(mockRpc.name);
|
|
1637
|
-
state.mockRpcs[mockRpc.name] = mockRpc;
|
|
1639
|
+
state$2.mockRpcs[mockRpc.name] = mockRpc;
|
|
1638
1640
|
};
|
|
1639
1641
|
|
|
1640
1642
|
class CssParsingError extends Error {
|
|
@@ -1922,6 +1924,7 @@ const execute$1 = async (id, ...args) => {
|
|
|
1922
1924
|
return invoke(id, ...args);
|
|
1923
1925
|
};
|
|
1924
1926
|
const executeExtensionCommand = async (commandId, ...args) => {
|
|
1927
|
+
// TODO maybe ask extension-management-worker instead
|
|
1925
1928
|
return invoke('ExtensionHost.executeCommand', commandId, ...args);
|
|
1926
1929
|
};
|
|
1927
1930
|
|
|
@@ -2235,11 +2238,11 @@ const assertObjectMatches = (actual, expected, path) => {
|
|
|
2235
2238
|
if (!isObject$3(actual)) {
|
|
2236
2239
|
throw new TypeError(`Expected ${path} to be an object but got ${formatValue(actual)}`);
|
|
2237
2240
|
}
|
|
2238
|
-
for (const key of Object.
|
|
2241
|
+
for (const [key, expectedValue] of Object.entries(expected)) {
|
|
2239
2242
|
if (!Object.hasOwn(actual, key)) {
|
|
2240
2243
|
throw new Error(`Expected ${path}.${key} to exist`);
|
|
2241
2244
|
}
|
|
2242
|
-
assertPayloadMatches(actual[key],
|
|
2245
|
+
assertPayloadMatches(actual[key], expectedValue, `${path}.${key}`);
|
|
2243
2246
|
}
|
|
2244
2247
|
};
|
|
2245
2248
|
const assertPrimitiveMatches = (actual, expected, path) => {
|
|
@@ -2608,6 +2611,9 @@ const directionMap = {
|
|
|
2608
2611
|
horizontal: 1,
|
|
2609
2612
|
vertical: 2
|
|
2610
2613
|
};
|
|
2614
|
+
const isLayoutDirectionName = value => {
|
|
2615
|
+
return value === 'horizontal' || value === 'vertical';
|
|
2616
|
+
};
|
|
2611
2617
|
const isObject$2 = value => {
|
|
2612
2618
|
return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof RegExp);
|
|
2613
2619
|
};
|
|
@@ -2637,8 +2643,11 @@ const matchesExpectedObject = (actual, expected) => {
|
|
|
2637
2643
|
return true;
|
|
2638
2644
|
};
|
|
2639
2645
|
const matchesExpected = (actual, expected, key = '') => {
|
|
2640
|
-
if (key === 'direction' && typeof expected === 'string' && expected
|
|
2641
|
-
|
|
2646
|
+
if (key === 'direction' && typeof expected === 'string' && isLayoutDirectionName(expected)) {
|
|
2647
|
+
if (expected === 'horizontal') {
|
|
2648
|
+
return Object.is(actual, directionMap.horizontal);
|
|
2649
|
+
}
|
|
2650
|
+
return Object.is(actual, directionMap.vertical);
|
|
2642
2651
|
}
|
|
2643
2652
|
if (expected instanceof RegExp) {
|
|
2644
2653
|
return typeof actual === 'string' && expected.test(actual);
|
|
@@ -2830,13 +2839,32 @@ const areSelectionsEqual = (a, b) => {
|
|
|
2830
2839
|
return true;
|
|
2831
2840
|
};
|
|
2832
2841
|
|
|
2842
|
+
const areTokensEqual = (actual, expected) => {
|
|
2843
|
+
if (actual.length !== expected.length) {
|
|
2844
|
+
return false;
|
|
2845
|
+
}
|
|
2846
|
+
for (let i = 0; i < actual.length; i++) {
|
|
2847
|
+
const actualRow = actual[i];
|
|
2848
|
+
const expectedRow = expected[i];
|
|
2849
|
+
if (actualRow.length !== expectedRow.length) {
|
|
2850
|
+
return false;
|
|
2851
|
+
}
|
|
2852
|
+
for (let j = 0; j < actualRow.length; j++) {
|
|
2853
|
+
if (actualRow[j] !== expectedRow[j]) {
|
|
2854
|
+
return false;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
return true;
|
|
2859
|
+
};
|
|
2860
|
+
|
|
2833
2861
|
const getEditorKey = async () => {
|
|
2834
2862
|
const keys = await invoke$4('Editor.getKeys');
|
|
2835
2863
|
if (keys.length === 0) {
|
|
2836
2864
|
throw new Error(`no editor found`);
|
|
2837
2865
|
}
|
|
2838
2866
|
const key = keys.at(-1);
|
|
2839
|
-
const numeric = Number
|
|
2867
|
+
const numeric = Number(key);
|
|
2840
2868
|
return numeric;
|
|
2841
2869
|
};
|
|
2842
2870
|
|
|
@@ -2925,6 +2953,12 @@ const cursorUp = async () => {
|
|
|
2925
2953
|
const cursorWordLeft = async () => {
|
|
2926
2954
|
await invoke('Editor.cursorWordLeft');
|
|
2927
2955
|
};
|
|
2956
|
+
const selectWordLeft = async () => {
|
|
2957
|
+
await invoke('Editor.selectWordLeft');
|
|
2958
|
+
};
|
|
2959
|
+
const selectWordRight = async () => {
|
|
2960
|
+
await invoke('Editor.selectWordRight');
|
|
2961
|
+
};
|
|
2928
2962
|
const setText = async text => {
|
|
2929
2963
|
await invoke('Editor.setText', text);
|
|
2930
2964
|
};
|
|
@@ -2997,6 +3031,27 @@ const setDeltaY$1 = async deltaY => {
|
|
|
2997
3031
|
const format = async () => {
|
|
2998
3032
|
await invoke('Editor.format');
|
|
2999
3033
|
};
|
|
3034
|
+
const indentMore = async () => {
|
|
3035
|
+
await invoke('Editor.indentMore');
|
|
3036
|
+
};
|
|
3037
|
+
const indentLess = async () => {
|
|
3038
|
+
await invoke('Editor.indentLess');
|
|
3039
|
+
};
|
|
3040
|
+
const moveLineDown = async () => {
|
|
3041
|
+
await invoke('Editor.moveLineDown');
|
|
3042
|
+
};
|
|
3043
|
+
const pasteText = async text => {
|
|
3044
|
+
await invoke('Editor.pasteText', text);
|
|
3045
|
+
};
|
|
3046
|
+
const sortLinesAscending = async () => {
|
|
3047
|
+
await invoke('Editor.sortLinesAscending');
|
|
3048
|
+
};
|
|
3049
|
+
const typeWithAutoClosing = async text => {
|
|
3050
|
+
await invoke('Editor.typeWithAutoClosing', text);
|
|
3051
|
+
};
|
|
3052
|
+
const handleTab = async () => {
|
|
3053
|
+
await invoke('Editor.handleTab');
|
|
3054
|
+
};
|
|
3000
3055
|
const unIndent = async () => {
|
|
3001
3056
|
await invoke('Editor.unIndent');
|
|
3002
3057
|
};
|
|
@@ -3106,24 +3161,6 @@ const shouldHaveText = async expectedText => {
|
|
|
3106
3161
|
throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
|
|
3107
3162
|
}
|
|
3108
3163
|
};
|
|
3109
|
-
const areTokensEqual = (actual, expected) => {
|
|
3110
|
-
if (actual.length !== expected.length) {
|
|
3111
|
-
return false;
|
|
3112
|
-
}
|
|
3113
|
-
for (let i = 0; i < actual.length; i++) {
|
|
3114
|
-
const actualRow = actual[i];
|
|
3115
|
-
const expectedRow = expected[i];
|
|
3116
|
-
if (actualRow.length !== expectedRow.length) {
|
|
3117
|
-
return false;
|
|
3118
|
-
}
|
|
3119
|
-
for (let j = 0; j < actualRow.length; j++) {
|
|
3120
|
-
if (actualRow[j] !== expectedRow[j]) {
|
|
3121
|
-
return false;
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
return true;
|
|
3126
|
-
};
|
|
3127
3164
|
const shouldHaveTokens = async expectedTokens => {
|
|
3128
3165
|
const key = await getEditorKey();
|
|
3129
3166
|
const text = await invoke$4('Editor.getTokens', key);
|
|
@@ -3226,9 +3263,13 @@ const Editor = {
|
|
|
3226
3263
|
goToDefinition,
|
|
3227
3264
|
goToTypeDefinition,
|
|
3228
3265
|
growSelection,
|
|
3266
|
+
handleTab,
|
|
3267
|
+
indentLess,
|
|
3268
|
+
indentMore,
|
|
3229
3269
|
insertLineBreak,
|
|
3230
3270
|
invokeBraceCompletion,
|
|
3231
3271
|
invokeTabCompletion,
|
|
3272
|
+
moveLineDown,
|
|
3232
3273
|
openColorPicker,
|
|
3233
3274
|
openCompletion,
|
|
3234
3275
|
openCompletionDetails,
|
|
@@ -3240,6 +3281,7 @@ const Editor = {
|
|
|
3240
3281
|
openRename,
|
|
3241
3282
|
openSourceActions,
|
|
3242
3283
|
organizeImports,
|
|
3284
|
+
pasteText,
|
|
3243
3285
|
redo,
|
|
3244
3286
|
rename: rename$1,
|
|
3245
3287
|
rename2,
|
|
@@ -3254,6 +3296,8 @@ const Editor = {
|
|
|
3254
3296
|
selectNextOccurrence,
|
|
3255
3297
|
selectPreviousOccurrence,
|
|
3256
3298
|
selectUp: selectUp$1,
|
|
3299
|
+
selectWordLeft,
|
|
3300
|
+
selectWordRight,
|
|
3257
3301
|
selectionGrow,
|
|
3258
3302
|
setCursor,
|
|
3259
3303
|
setDeltaY: setDeltaY$1,
|
|
@@ -3266,11 +3310,13 @@ const Editor = {
|
|
|
3266
3310
|
shouldHaveTokens,
|
|
3267
3311
|
showHover,
|
|
3268
3312
|
sortImports,
|
|
3313
|
+
sortLinesAscending,
|
|
3269
3314
|
sourceActionsSelectCurrent,
|
|
3270
3315
|
toggleBlockComment,
|
|
3271
3316
|
toggleCompletionDetails,
|
|
3272
3317
|
toggleLineComment,
|
|
3273
3318
|
type,
|
|
3319
|
+
typeWithAutoClosing,
|
|
3274
3320
|
unIndent,
|
|
3275
3321
|
undo
|
|
3276
3322
|
};
|
|
@@ -3281,7 +3327,7 @@ const selectIndex$6 = async index => {
|
|
|
3281
3327
|
const selectCurrentIndex$2 = async () => {
|
|
3282
3328
|
await invoke('EditorCompletion.selectCurrentIndex');
|
|
3283
3329
|
};
|
|
3284
|
-
const close$
|
|
3330
|
+
const close$3 = async () => {
|
|
3285
3331
|
await invoke('EditorCompletion.close');
|
|
3286
3332
|
};
|
|
3287
3333
|
const handleWheel$2 = async (deltaMode, deltaY) => {
|
|
@@ -3292,7 +3338,7 @@ const handlePointerdown = async (clientX, clientY) => {
|
|
|
3292
3338
|
};
|
|
3293
3339
|
|
|
3294
3340
|
const EditorCompletion = {
|
|
3295
|
-
close: close$
|
|
3341
|
+
close: close$3,
|
|
3296
3342
|
handlePointerdown,
|
|
3297
3343
|
handleWheel: handleWheel$2,
|
|
3298
3344
|
selectCurrentIndex: selectCurrentIndex$2,
|
|
@@ -3302,12 +3348,12 @@ const EditorCompletion = {
|
|
|
3302
3348
|
const show$6 = async () => {
|
|
3303
3349
|
await invoke('Editor.showHover2');
|
|
3304
3350
|
};
|
|
3305
|
-
const close$
|
|
3351
|
+
const close$2 = async () => {
|
|
3306
3352
|
await invoke('EditorHover.close');
|
|
3307
3353
|
};
|
|
3308
3354
|
|
|
3309
3355
|
const EditorHover = {
|
|
3310
|
-
close: close$
|
|
3356
|
+
close: close$2,
|
|
3311
3357
|
show: show$6
|
|
3312
3358
|
};
|
|
3313
3359
|
|
|
@@ -3721,11 +3767,11 @@ const getFileMapNode = async url => {
|
|
|
3721
3767
|
const contents = await Promise.all(allFiles.map(filePath => {
|
|
3722
3768
|
return readFile$1(filePath);
|
|
3723
3769
|
}));
|
|
3724
|
-
allFiles.
|
|
3770
|
+
for (const [index, filePath] of allFiles.entries()) {
|
|
3725
3771
|
const content = contents[index];
|
|
3726
3772
|
const relativePaths = filePath.slice(fileUrl.length + 1);
|
|
3727
3773
|
fileMap[relativePaths] = content;
|
|
3728
|
-
}
|
|
3774
|
+
}
|
|
3729
3775
|
return fileMap;
|
|
3730
3776
|
};
|
|
3731
3777
|
|
|
@@ -3805,12 +3851,13 @@ const addFileHandle = async file => {
|
|
|
3805
3851
|
const mkdir = async uri => {
|
|
3806
3852
|
return invoke('FileSystem.mkdir', uri);
|
|
3807
3853
|
};
|
|
3808
|
-
const
|
|
3854
|
+
const writeFiles = async files => {
|
|
3809
3855
|
// TODO maybe have a method to send all the files to file system worker directly
|
|
3810
3856
|
await Promise.all(files.map(file => {
|
|
3811
3857
|
return writeFile(file.uri, file.content);
|
|
3812
3858
|
}));
|
|
3813
3859
|
};
|
|
3860
|
+
const setFiles = writeFiles;
|
|
3814
3861
|
const readDir = async uri => {
|
|
3815
3862
|
return invoke('FileSystem.readDirWithFileTypes', uri);
|
|
3816
3863
|
};
|
|
@@ -3819,7 +3866,7 @@ const getParentUri = uri => {
|
|
|
3819
3866
|
const pathSegments = url.pathname.split('/').filter(Boolean);
|
|
3820
3867
|
pathSegments.pop();
|
|
3821
3868
|
url.pathname = pathSegments.length === 0 ? '/' : `/${pathSegments.join('/')}`;
|
|
3822
|
-
return url.
|
|
3869
|
+
return url.href;
|
|
3823
3870
|
};
|
|
3824
3871
|
const getBaseName = uri => {
|
|
3825
3872
|
const url = new URL(uri);
|
|
@@ -3938,6 +3985,7 @@ const FileSystem = {
|
|
|
3938
3985
|
shouldHaveFile,
|
|
3939
3986
|
shouldHaveFolder,
|
|
3940
3987
|
writeFile,
|
|
3988
|
+
writeFiles,
|
|
3941
3989
|
writeJson
|
|
3942
3990
|
};
|
|
3943
3991
|
|
|
@@ -3947,7 +3995,7 @@ const focusNext$5 = async () => {
|
|
|
3947
3995
|
const focusPrevious$5 = async () => {
|
|
3948
3996
|
await invoke('FindWidget.focusPrevious');
|
|
3949
3997
|
};
|
|
3950
|
-
const close = async () => {
|
|
3998
|
+
const close$1 = async () => {
|
|
3951
3999
|
await invoke('FindWidget.close');
|
|
3952
4000
|
};
|
|
3953
4001
|
const setReplaceValue$1 = async value => {
|
|
@@ -3988,7 +4036,7 @@ const focusPreviousElement = async () => {
|
|
|
3988
4036
|
};
|
|
3989
4037
|
|
|
3990
4038
|
const FindWidget = {
|
|
3991
|
-
close,
|
|
4039
|
+
close: close$1,
|
|
3992
4040
|
focusElement,
|
|
3993
4041
|
focusNext: focusNext$5,
|
|
3994
4042
|
focusNextElement,
|
|
@@ -4323,33 +4371,41 @@ const Control = 'Control';
|
|
|
4323
4371
|
const Space = 'Space';
|
|
4324
4372
|
const Alt = 'Alt';
|
|
4325
4373
|
|
|
4374
|
+
const applyKeyPart = (part, options) => {
|
|
4375
|
+
switch (part) {
|
|
4376
|
+
case Alt:
|
|
4377
|
+
{
|
|
4378
|
+
options.altKey = true;
|
|
4379
|
+
return;
|
|
4380
|
+
}
|
|
4381
|
+
case Control:
|
|
4382
|
+
{
|
|
4383
|
+
options.ctrlKey = true;
|
|
4384
|
+
return;
|
|
4385
|
+
}
|
|
4386
|
+
case Space:
|
|
4387
|
+
{
|
|
4388
|
+
options.key = ' ';
|
|
4389
|
+
return;
|
|
4390
|
+
}
|
|
4391
|
+
default:
|
|
4392
|
+
{
|
|
4393
|
+
options.key = part;
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
};
|
|
4326
4397
|
const getKeyOptions = rawKey => {
|
|
4327
4398
|
if (rawKey.includes('+')) {
|
|
4328
4399
|
const parts = rawKey.split('+');
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4400
|
+
const options = {
|
|
4401
|
+
altKey: false,
|
|
4402
|
+
ctrlKey: false,
|
|
4403
|
+
key: ''
|
|
4404
|
+
};
|
|
4332
4405
|
for (const part of parts) {
|
|
4333
|
-
|
|
4334
|
-
case Alt:
|
|
4335
|
-
altKey = true;
|
|
4336
|
-
break;
|
|
4337
|
-
case Control:
|
|
4338
|
-
ctrlKey = true;
|
|
4339
|
-
break;
|
|
4340
|
-
case Space:
|
|
4341
|
-
key = ' ';
|
|
4342
|
-
break;
|
|
4343
|
-
default:
|
|
4344
|
-
key = part;
|
|
4345
|
-
break;
|
|
4346
|
-
}
|
|
4406
|
+
applyKeyPart(part, options);
|
|
4347
4407
|
}
|
|
4348
|
-
return
|
|
4349
|
-
altKey,
|
|
4350
|
-
ctrlKey,
|
|
4351
|
-
key
|
|
4352
|
-
};
|
|
4408
|
+
return options;
|
|
4353
4409
|
}
|
|
4354
4410
|
return {
|
|
4355
4411
|
altKey: false,
|
|
@@ -4487,11 +4543,12 @@ const getIsFirefox = () => {
|
|
|
4487
4543
|
if (typeof navigator === 'undefined') {
|
|
4488
4544
|
return false;
|
|
4489
4545
|
}
|
|
4490
|
-
if (
|
|
4491
4546
|
// @ts-expect-error
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4547
|
+
const {
|
|
4548
|
+
userAgentData
|
|
4549
|
+
} = navigator;
|
|
4550
|
+
if (userAgentData?.brands) {
|
|
4551
|
+
return userAgentData.brands.includes('Firefox');
|
|
4495
4552
|
}
|
|
4496
4553
|
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
4497
4554
|
};
|
|
@@ -4647,6 +4704,13 @@ const focusIndex$2 = async index => {
|
|
|
4647
4704
|
const focusPrevious$2 = async () => {
|
|
4648
4705
|
await invoke('QuickPick.focusPrevious');
|
|
4649
4706
|
};
|
|
4707
|
+
const ignoreSelectionFailure = async promise => {
|
|
4708
|
+
try {
|
|
4709
|
+
await promise;
|
|
4710
|
+
} catch {
|
|
4711
|
+
// ignore selection failures for fire-and-forget selection flows
|
|
4712
|
+
}
|
|
4713
|
+
};
|
|
4650
4714
|
const selectItem = async (label, {
|
|
4651
4715
|
waitUntil = 'done'
|
|
4652
4716
|
} = {}) => {
|
|
@@ -4657,10 +4721,10 @@ const selectItem = async (label, {
|
|
|
4657
4721
|
const visiblePromise = waitUntil === 'quickPick' ? invoke('QuickPick.waitUntilVisible') : undefined;
|
|
4658
4722
|
const promise = Promise.resolve(invoke('QuickPick.selectItem', label));
|
|
4659
4723
|
if (waitUntil === 'none') {
|
|
4660
|
-
void promise
|
|
4724
|
+
void ignoreSelectionFailure(promise);
|
|
4661
4725
|
return;
|
|
4662
4726
|
}
|
|
4663
|
-
void promise
|
|
4727
|
+
void ignoreSelectionFailure(promise);
|
|
4664
4728
|
await visiblePromise;
|
|
4665
4729
|
};
|
|
4666
4730
|
const selectIndex$3 = async index => {
|
|
@@ -5089,12 +5153,15 @@ const TitleBarMenuBar = {
|
|
|
5089
5153
|
toggleMenu
|
|
5090
5154
|
};
|
|
5091
5155
|
|
|
5092
|
-
|
|
5156
|
+
const state$1 = {
|
|
5157
|
+
url: ''
|
|
5158
|
+
};
|
|
5093
5159
|
const setUrl = newUrl => {
|
|
5094
|
-
url = newUrl;
|
|
5160
|
+
state$1.url = newUrl;
|
|
5095
5161
|
};
|
|
5096
5162
|
const resolve = relativePath => {
|
|
5097
|
-
|
|
5163
|
+
const resolvedUrl = new URL(relativePath, state$1.url);
|
|
5164
|
+
return resolvedUrl.href;
|
|
5098
5165
|
};
|
|
5099
5166
|
|
|
5100
5167
|
const Url = {
|
|
@@ -5186,8 +5253,12 @@ const openTmpDir = async () => {
|
|
|
5186
5253
|
await setPath(tmpDir);
|
|
5187
5254
|
return tmpDir;
|
|
5188
5255
|
};
|
|
5256
|
+
const close = async () => {
|
|
5257
|
+
await invoke('Workspace.close');
|
|
5258
|
+
};
|
|
5189
5259
|
|
|
5190
5260
|
const Workspace = {
|
|
5261
|
+
close,
|
|
5191
5262
|
openTmpDir,
|
|
5192
5263
|
setPath
|
|
5193
5264
|
};
|
|
@@ -5410,7 +5481,7 @@ const importScript = async url => {
|
|
|
5410
5481
|
} catch (error) {
|
|
5411
5482
|
throw error;
|
|
5412
5483
|
// TODO
|
|
5413
|
-
// const actualErrorMessage = await TryToGetactualImportErrorMessage.tryToGetActualImportErrorMessage(
|
|
5484
|
+
// const actualErrorMessage = await TryToGetactualImportErrorMessage.tryToGetActualImportErrorMessage(URL, error)
|
|
5414
5485
|
// throw new Error(actualErrorMessage)
|
|
5415
5486
|
}
|
|
5416
5487
|
};
|
|
@@ -5423,12 +5494,14 @@ const importTest = async url => {
|
|
|
5423
5494
|
}
|
|
5424
5495
|
};
|
|
5425
5496
|
|
|
5426
|
-
|
|
5497
|
+
const state = {
|
|
5498
|
+
items: []
|
|
5499
|
+
};
|
|
5427
5500
|
const push = item => {
|
|
5428
|
-
items = [...items, item];
|
|
5501
|
+
state.items = [...state.items, item];
|
|
5429
5502
|
};
|
|
5430
5503
|
const maybeLast = () => {
|
|
5431
|
-
return items.at(-1);
|
|
5504
|
+
return state.items.at(-1);
|
|
5432
5505
|
};
|
|
5433
5506
|
|
|
5434
5507
|
const getFileUri = href => {
|
|
@@ -5463,7 +5536,7 @@ const execute = async (href, platform, assetDir) => {
|
|
|
5463
5536
|
const globals = createApi(platform, assetDir);
|
|
5464
5537
|
// TODO
|
|
5465
5538
|
// 0. wait for page to be ready
|
|
5466
|
-
// 1. get script to import from renderer process (
|
|
5539
|
+
// 1. get script to import from renderer process (URL or from HTML)
|
|
5467
5540
|
const scriptUrl = href;
|
|
5468
5541
|
setUrl(scriptUrl); // TODO avoid side effect
|
|
5469
5542
|
try {
|
|
@@ -5518,8 +5591,8 @@ const doHotReload = async (url, platform, assetDir) => {
|
|
|
5518
5591
|
|
|
5519
5592
|
const createUrlWithQueryParameter = (url, locationHref, time) => {
|
|
5520
5593
|
const parsedUrl = new URL(url, locationHref);
|
|
5521
|
-
parsedUrl.searchParams.set('time',
|
|
5522
|
-
const string = parsedUrl.
|
|
5594
|
+
parsedUrl.searchParams.set('time', String(time));
|
|
5595
|
+
const string = parsedUrl.href;
|
|
5523
5596
|
return string;
|
|
5524
5597
|
};
|
|
5525
5598
|
|
|
@@ -5630,7 +5703,7 @@ const consumeComment = (inBlockComment, inLineComment, character, nextCharacter)
|
|
|
5630
5703
|
};
|
|
5631
5704
|
|
|
5632
5705
|
const isStringDelimiter = character => {
|
|
5633
|
-
return
|
|
5706
|
+
return [`'`, '"', '`'].includes(character);
|
|
5634
5707
|
};
|
|
5635
5708
|
|
|
5636
5709
|
const consumeString = (stringDelimiter, character) => {
|
|
@@ -5757,11 +5830,11 @@ const projectActualOntoExpected = (actualValue, expectedValue) => {
|
|
|
5757
5830
|
return actualValue;
|
|
5758
5831
|
}
|
|
5759
5832
|
const result = {};
|
|
5760
|
-
for (const key of Object.
|
|
5833
|
+
for (const [key, nestedExpectedValue] of Object.entries(expectedValue)) {
|
|
5761
5834
|
if (!Object.hasOwn(actualValue, key)) {
|
|
5762
5835
|
continue;
|
|
5763
5836
|
}
|
|
5764
|
-
result[key] = projectActualOntoExpected(actualValue[key],
|
|
5837
|
+
result[key] = projectActualOntoExpected(actualValue[key], nestedExpectedValue);
|
|
5765
5838
|
}
|
|
5766
5839
|
return result;
|
|
5767
5840
|
}
|
|
@@ -5873,7 +5946,7 @@ const toFileUrl = (url, locationHref) => {
|
|
|
5873
5946
|
if (parsedUrl.protocol === 'file:') {
|
|
5874
5947
|
parsedUrl.hash = '';
|
|
5875
5948
|
parsedUrl.search = '';
|
|
5876
|
-
return parsedUrl.
|
|
5949
|
+
return parsedUrl.href;
|
|
5877
5950
|
}
|
|
5878
5951
|
return getFileUrlFromRemotePath(parsedUrl.pathname);
|
|
5879
5952
|
};
|