@lvce-editor/test-worker 7.2.0 → 7.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 +13 -0
- package/dist/testWorkerMain.js +61 -16
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ interface LocatorConstructor {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
export interface Diagnostic {
|
|
50
|
+
readonly rowIndex: number;
|
|
51
|
+
readonly columnIndex: number;
|
|
52
|
+
readonly endRowIndex: number;
|
|
53
|
+
readonly endColumnIndex: number;
|
|
54
|
+
readonly message: string;
|
|
55
|
+
readonly type: "error" | "warning";
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
export interface DroppedFileHandle {
|
|
50
59
|
readonly id: number;
|
|
51
60
|
readonly file: File;
|
|
@@ -168,6 +177,7 @@ interface Editor {
|
|
|
168
177
|
readonly setCursor: (rowIndex: number, columnIndex: number) => Promise<void>;
|
|
169
178
|
readonly setDeltaY: (deltaY: number) => Promise<void>;
|
|
170
179
|
readonly setSelections: (selections: any) => Promise<void>;
|
|
180
|
+
readonly shouldHaveDiagnostics: (expectedDiagnostics: readonly Diagnostic[]) => Promise<void>;
|
|
171
181
|
readonly shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
|
|
172
182
|
readonly shouldHaveText: (expectedText: string) => Promise<void>;
|
|
173
183
|
readonly showHover: () => Promise<void>;
|
|
@@ -182,6 +192,7 @@ interface Editor {
|
|
|
182
192
|
|
|
183
193
|
interface EditorCompletion {
|
|
184
194
|
readonly close: () => Promise<void>;
|
|
195
|
+
readonly handlePointerdown: (clientX: number, clientY: number) => Promise<void>;
|
|
185
196
|
readonly handleWheel: (deltaMode: number, deltaY: number) => Promise<void>;
|
|
186
197
|
readonly selectCurrentIndex: () => Promise<void>;
|
|
187
198
|
readonly selectIndex: (index: number) => Promise<void>;
|
|
@@ -450,6 +461,8 @@ interface Search {
|
|
|
450
461
|
}
|
|
451
462
|
|
|
452
463
|
interface Settings {
|
|
464
|
+
readonly disableDiagnostics: () => Promise<void>;
|
|
465
|
+
readonly enableDiagnostics: () => Promise<void>;
|
|
453
466
|
readonly update: (settings: any) => Promise<void>;
|
|
454
467
|
}
|
|
455
468
|
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -1809,6 +1809,22 @@ const Dialog = {
|
|
|
1809
1809
|
showSaveFilePicker
|
|
1810
1810
|
};
|
|
1811
1811
|
|
|
1812
|
+
const isDiagnosticEqual = (actual, expected) => {
|
|
1813
|
+
return actual.rowIndex === expected.rowIndex && actual.columnIndex === expected.columnIndex && actual.endRowIndex === expected.endRowIndex && actual.endColumnIndex === expected.endColumnIndex && actual.message === expected.message && actual.type === expected.type;
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
const areDiagnosticsEqual = (actual, expected) => {
|
|
1817
|
+
if (actual.length !== expected.length) {
|
|
1818
|
+
return false;
|
|
1819
|
+
}
|
|
1820
|
+
for (let i = 0; i < actual.length; i++) {
|
|
1821
|
+
if (!isDiagnosticEqual(actual[i], expected[i])) {
|
|
1822
|
+
return false;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
return true;
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1812
1828
|
const areSelectionsEqual = (a, b) => {
|
|
1813
1829
|
if (a.length !== b.length) {
|
|
1814
1830
|
return false;
|
|
@@ -1821,10 +1837,21 @@ const areSelectionsEqual = (a, b) => {
|
|
|
1821
1837
|
return true;
|
|
1822
1838
|
};
|
|
1823
1839
|
|
|
1840
|
+
const lazyRpc = createLazyRpc(EditorWorker);
|
|
1824
1841
|
const {
|
|
1825
1842
|
invoke,
|
|
1826
1843
|
setFactory
|
|
1827
|
-
} =
|
|
1844
|
+
} = lazyRpc;
|
|
1845
|
+
|
|
1846
|
+
const getEditorKey = async () => {
|
|
1847
|
+
const keys = await invoke('Editor.getKeys');
|
|
1848
|
+
if (keys.length === 0) {
|
|
1849
|
+
throw new Error(`no editor found`);
|
|
1850
|
+
}
|
|
1851
|
+
const key = keys.at(-1);
|
|
1852
|
+
const numeric = Number.parseInt(key);
|
|
1853
|
+
return numeric;
|
|
1854
|
+
};
|
|
1828
1855
|
|
|
1829
1856
|
const Script = 2;
|
|
1830
1857
|
|
|
@@ -2005,30 +2032,19 @@ const growSelection = async () => {
|
|
|
2005
2032
|
await invoke$1('Editor.selectionGrow');
|
|
2006
2033
|
};
|
|
2007
2034
|
const getSelections = async () => {
|
|
2008
|
-
const
|
|
2009
|
-
const key = keys.at(-1);
|
|
2010
|
-
const numeric = Number.parseInt(key);
|
|
2035
|
+
const key = await getEditorKey();
|
|
2011
2036
|
// @ts-ignore
|
|
2012
|
-
return invoke('Editor.getSelections',
|
|
2013
|
-
};
|
|
2014
|
-
const getKey = async () => {
|
|
2015
|
-
const keys = await invoke('Editor.getKeys');
|
|
2016
|
-
if (keys.length === 0) {
|
|
2017
|
-
throw new Error(`no editor found`);
|
|
2018
|
-
}
|
|
2019
|
-
const key = keys.at(-1);
|
|
2020
|
-
const numeric = Number.parseInt(key);
|
|
2021
|
-
return numeric;
|
|
2037
|
+
return invoke('Editor.getSelections', key);
|
|
2022
2038
|
};
|
|
2023
2039
|
const shouldHaveText = async expectedText => {
|
|
2024
|
-
const key = await
|
|
2040
|
+
const key = await getEditorKey();
|
|
2025
2041
|
const text = await invoke('Editor.getText', key);
|
|
2026
2042
|
if (text !== expectedText) {
|
|
2027
2043
|
throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
|
|
2028
2044
|
}
|
|
2029
2045
|
};
|
|
2030
2046
|
const shouldHaveSelections = async expectedSelections => {
|
|
2031
|
-
const key = await
|
|
2047
|
+
const key = await getEditorKey();
|
|
2032
2048
|
const selections = await invoke('Editor.getSelections', key);
|
|
2033
2049
|
if (!areSelectionsEqual(selections, expectedSelections)) {
|
|
2034
2050
|
throw new Error(`Expected editor to have selections ${expectedSelections} but was ${selections}`);
|
|
@@ -2042,6 +2058,15 @@ const redo = async () => {
|
|
|
2042
2058
|
// @ts-ignore
|
|
2043
2059
|
await invoke('Editor.redo');
|
|
2044
2060
|
};
|
|
2061
|
+
const shouldHaveDiagnostics = async expectedDiagnostics => {
|
|
2062
|
+
const key = await getEditorKey();
|
|
2063
|
+
const diagnostics = await invoke('Editor.getDiagnostics', key);
|
|
2064
|
+
if (!areDiagnosticsEqual(diagnostics, expectedDiagnostics)) {
|
|
2065
|
+
const stringifiedActual = JSON.stringify(diagnostics);
|
|
2066
|
+
const stringifiedExpected = JSON.stringify(expectedDiagnostics);
|
|
2067
|
+
throw new Error(`Expected editor to have diagnostics ${stringifiedExpected} but was ${stringifiedActual}`);
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2045
2070
|
|
|
2046
2071
|
const Editor = {
|
|
2047
2072
|
__proto__: null,
|
|
@@ -2094,6 +2119,7 @@ const Editor = {
|
|
|
2094
2119
|
setCursor,
|
|
2095
2120
|
setDeltaY,
|
|
2096
2121
|
setSelections,
|
|
2122
|
+
shouldHaveDiagnostics,
|
|
2097
2123
|
shouldHaveSelections,
|
|
2098
2124
|
shouldHaveText,
|
|
2099
2125
|
showHover,
|
|
@@ -2120,10 +2146,15 @@ const handleWheel$2 = async (deltaMode, deltaY) => {
|
|
|
2120
2146
|
// @ts-ignore
|
|
2121
2147
|
await invoke$1('EditorCompletion.handleWheel', deltaMode, deltaY);
|
|
2122
2148
|
};
|
|
2149
|
+
const handlePointerdown = async (clientX, clientY) => {
|
|
2150
|
+
// @ts-ignore
|
|
2151
|
+
await invoke$1('EditorCompletion.handlePointerdown', clientX, clientY);
|
|
2152
|
+
};
|
|
2123
2153
|
|
|
2124
2154
|
const EditorCompletion = {
|
|
2125
2155
|
__proto__: null,
|
|
2126
2156
|
close: close$2,
|
|
2157
|
+
handlePointerdown,
|
|
2127
2158
|
handleWheel: handleWheel$2,
|
|
2128
2159
|
selectCurrentIndex: selectCurrentIndex$2,
|
|
2129
2160
|
selectIndex: selectIndex$6
|
|
@@ -3326,9 +3357,23 @@ const update$1 = settings => {
|
|
|
3326
3357
|
// @ts-ignore
|
|
3327
3358
|
return invoke$1('Preferences.update', settings);
|
|
3328
3359
|
};
|
|
3360
|
+
const enableDiagnostics = () => {
|
|
3361
|
+
// @ts-ignore
|
|
3362
|
+
return invoke$1('Preferences.update', {
|
|
3363
|
+
'editor.diagnostics': true
|
|
3364
|
+
});
|
|
3365
|
+
};
|
|
3366
|
+
const disableDiagnostics = () => {
|
|
3367
|
+
// @ts-ignore
|
|
3368
|
+
return invoke$1('Preferences.update', {
|
|
3369
|
+
'editor.diagnostics': false
|
|
3370
|
+
});
|
|
3371
|
+
};
|
|
3329
3372
|
|
|
3330
3373
|
const Settings = {
|
|
3331
3374
|
__proto__: null,
|
|
3375
|
+
disableDiagnostics,
|
|
3376
|
+
enableDiagnostics,
|
|
3332
3377
|
update: update$1
|
|
3333
3378
|
};
|
|
3334
3379
|
|