@lvce-editor/test-worker 7.6.0 → 7.8.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
@@ -236,6 +236,7 @@ interface Explorer {
236
236
  readonly handleDragOver: (x: number, y: number) => Promise<void>;
237
237
  readonly handleDragOverIndex: (index: number) => Promise<void>;
238
238
  readonly handleDrop: (x: number, y: number, fileIds: readonly number[], fileList: FileList | readonly File[]) => Promise<void>;
239
+ readonly handleEscape: () => Promise<void>;
239
240
  readonly handleInputBlur: () => Promise<void>;
240
241
  readonly handlePaste: () => Promise<void>;
241
242
  readonly newFile: () => Promise<void>;
@@ -280,6 +281,7 @@ interface ExtensionDetail {
280
281
  }
281
282
 
282
283
  interface FileSystem {
284
+ readonly addFileHandle: (file: File) => Promise<void>;
283
285
  readonly chmod: (uri: string, permissions: any) => Promise<void>;
284
286
  readonly createDroppedFileHandle: () => Promise<DroppedFileHandle>;
285
287
  readonly createExecutable: (content: string) => Promise<string>;
@@ -2220,6 +2220,10 @@ const handleDragLeave = async () => {
2220
2220
  const handleBlur = async () => {
2221
2221
  await invoke$1('Explorer.handleBlur');
2222
2222
  };
2223
+ const handleEscape = async () => {
2224
+ // @ts-ignore
2225
+ await invoke$1('Explorer.handleEscape');
2226
+ };
2223
2227
  const handleInputBlur = async () => {
2224
2228
  await invoke$1('Explorer.handleInputBlur');
2225
2229
  };
@@ -2352,6 +2356,7 @@ const Explorer = {
2352
2356
  handleDragOver,
2353
2357
  handleDragOverIndex,
2354
2358
  handleDrop,
2359
+ handleEscape,
2355
2360
  handleInputBlur,
2356
2361
  handlePaste,
2357
2362
  newFile,
@@ -2543,6 +2548,14 @@ const getFileMapWeb = async url => {
2543
2548
  return fileMap;
2544
2549
  };
2545
2550
 
2551
+ const loadFixtureToMemFs = async fileMap => {
2552
+ for (const [path, content] of Object.entries(fileMap)) {
2553
+ const memfsPath = `memfs:///fixture/${path}`;
2554
+ await invoke$1('FileSystem.writeFile', memfsPath, content);
2555
+ }
2556
+ return `memfs:///fixture`;
2557
+ };
2558
+
2546
2559
  const Backslash = '\\';
2547
2560
  const Slash$1 = '/';
2548
2561
 
@@ -2560,6 +2573,7 @@ const stringifyJson = data => {
2560
2573
  return JSON.stringify(data, null, 2) + '\n';
2561
2574
  };
2562
2575
 
2576
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
2563
2577
  const writeFile = async (uri, content) => {
2564
2578
  await invoke$1('FileSystem.writeFile', uri, content);
2565
2579
  };
@@ -2570,6 +2584,10 @@ const writeJson = async (uri, data) => {
2570
2584
  const readFile = async uri => {
2571
2585
  return invoke$1('FileSystem.readFile', uri);
2572
2586
  };
2587
+ const addFileHandle = async file => {
2588
+ // @ts-ignore
2589
+ await invoke$1('FileSystem.addFileHandle', file);
2590
+ };
2573
2591
  const mkdir = async uri => {
2574
2592
  await invoke$1('FileSystem.mkdir', uri);
2575
2593
  };
@@ -2634,14 +2652,13 @@ const loadFixture = async (platform, url) => {
2634
2652
  }
2635
2653
  const fn = platform === Web ? getFileMapWeb : getFileMapNode;
2636
2654
  const fileMap = await fn(url);
2637
- for (const [key, value] of Object.entries(fileMap)) {
2638
- await writeFile(`memfs:///${key}`, value);
2639
- }
2640
- return 'memfs://';
2655
+ const filePath = await loadFixtureToMemFs(fileMap);
2656
+ return filePath;
2641
2657
  };
2642
2658
 
2643
2659
  const FileSystem = {
2644
2660
  __proto__: null,
2661
+ addFileHandle,
2645
2662
  chmod,
2646
2663
  createDroppedFileHandle,
2647
2664
  createExecutable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "7.6.0",
3
+ "version": "7.8.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",