@lvce-editor/test-worker 13.4.0 → 13.6.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 CHANGED
@@ -86,6 +86,8 @@ export interface SelectItem2Options {
86
86
  readonly label: string;
87
87
  }
88
88
 
89
+ export type TokenRow = readonly string[];
90
+
89
91
  export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
90
92
 
91
93
  interface Workspace {
@@ -238,6 +240,7 @@ interface Editor {
238
240
  readonly shouldHaveDiagnostics: (expectedDiagnostics: readonly Diagnostic[]) => Promise<void>;
239
241
  readonly shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
240
242
  readonly shouldHaveText: (expectedText: string) => Promise<void>;
243
+ readonly shouldHaveTokens: (expectedTokens: readonly TokenRow[]) => Promise<void>;
241
244
  readonly showHover: () => Promise<void>;
242
245
  readonly sortImports: () => Promise<void>;
243
246
  readonly sourceActionsSelectCurrent: () => Promise<void>;
@@ -491,6 +494,9 @@ interface Preview {
491
494
  readonly handleClick: (hdId: string) => Promise<void>;
492
495
  readonly handleInput: (hdId: string, value: string) => Promise<void>;
493
496
  readonly handleKeyDown: (hdId: string, key: string, code: string) => Promise<void>;
497
+ readonly handleMouseDown: (hdId: string, clientX: number, clientY: number) => Promise<void>;
498
+ readonly handleMouseMove: (hdId: string, value: string, clientX: number, clientY: number) => Promise<void>;
499
+ readonly handleMouseUp: (hdId: string, value: string, clientX: number, clientY: number) => Promise<void>;
494
500
  readonly open: (uri: string) => Promise<void>;
495
501
  readonly setUri: (uri: string) => Promise<void>;
496
502
  readonly waitForClick: () => Promise<void>;
@@ -2138,6 +2138,33 @@ const shouldHaveText = async expectedText => {
2138
2138
  throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
2139
2139
  }
2140
2140
  };
2141
+ const areTokensEqual = (actual, expected) => {
2142
+ if (actual.length !== expected.length) {
2143
+ return false;
2144
+ }
2145
+ for (let i = 0; i < actual.length; i++) {
2146
+ const actualRow = actual[i];
2147
+ const expectedRow = expected[i];
2148
+ if (actualRow.length !== expectedRow.length) {
2149
+ return false;
2150
+ }
2151
+ for (let j = 0; j < actualRow.length; j++) {
2152
+ if (actualRow[j] !== expectedRow[j]) {
2153
+ return false;
2154
+ }
2155
+ }
2156
+ }
2157
+ return true;
2158
+ };
2159
+ const shouldHaveTokens = async expectedTokens => {
2160
+ const key = await getEditorKey();
2161
+ const text = await invoke$1('Editor.getTokens', key);
2162
+ if (!areTokensEqual(text, expectedTokens)) {
2163
+ const stringifiedActual = JSON.stringify(text);
2164
+ const stringifiedExpected = JSON.stringify(expectedTokens);
2165
+ throw new Error(`Expected editor to have tokens ${stringifiedExpected} but was ${stringifiedActual}`);
2166
+ }
2167
+ };
2141
2168
  const shouldHaveSelections = async expectedSelections => {
2142
2169
  const key = await getEditorKey();
2143
2170
  const selections = await invoke$1('Editor.getSelections', key);
@@ -2259,6 +2286,7 @@ const Editor = {
2259
2286
  shouldHaveDiagnostics,
2260
2287
  shouldHaveSelections,
2261
2288
  shouldHaveText,
2289
+ shouldHaveTokens,
2262
2290
  showHover,
2263
2291
  sortImports,
2264
2292
  sourceActionsSelectCurrent,
@@ -3293,6 +3321,15 @@ const handleClick = async hdId => {
3293
3321
  const handleInput$3 = async (hdId, value) => {
3294
3322
  await invoke('Preview.handleInput', hdId, value);
3295
3323
  };
3324
+ const handleMouseDown = async (hdId, clientX, clientY) => {
3325
+ await invoke('Preview.handleMouseDown', hdId, clientX, clientY);
3326
+ };
3327
+ const handleMouseUp = async (hdId, value, clientX, clientY) => {
3328
+ await invoke('Preview.handleMouseUp', hdId, value, clientX, clientY);
3329
+ };
3330
+ const handleMouseMove = async (hdId, value, clientX, clientY) => {
3331
+ await invoke('Preview.handleMouseMove', hdId, value, clientX, clientY);
3332
+ };
3296
3333
  const handleKeyDown = async (hdId, key, code) => {
3297
3334
  await invoke('Preview.handleKeyDown', hdId, key, code);
3298
3335
  };
@@ -3307,6 +3344,9 @@ const Preview = {
3307
3344
  handleClick,
3308
3345
  handleInput: handleInput$3,
3309
3346
  handleKeyDown,
3347
+ handleMouseDown,
3348
+ handleMouseMove,
3349
+ handleMouseUp,
3310
3350
  open: open$2,
3311
3351
  setUri,
3312
3352
  waitForClick
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "13.4.0",
3
+ "version": "13.6.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",