@lvce-editor/extension-host-worker 4.11.0 → 4.12.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.
@@ -89,7 +89,7 @@ const fn = value => {
89
89
  }
90
90
  };
91
91
 
92
- const state$e = {
92
+ const state$d = {
93
93
  /** @type{any[]} */
94
94
  onWillChangeEditorListeners: [],
95
95
  /** @type{any[]} */
@@ -99,19 +99,19 @@ const state$e = {
99
99
  textDocuments: Object.create(null)
100
100
  };
101
101
  const setDocument = (textDocumentId, textDocument) => {
102
- state$e.textDocuments[textDocumentId] = textDocument;
102
+ state$d.textDocuments[textDocumentId] = textDocument;
103
103
  };
104
104
  const getDidOpenListeners = () => {
105
- return state$e.onDidSaveTextDocumentListeners;
105
+ return state$d.onDidSaveTextDocumentListeners;
106
106
  };
107
107
  const getWillChangeListeners = () => {
108
- return state$e.onWillChangeEditorListeners;
108
+ return state$d.onWillChangeEditorListeners;
109
109
  };
110
110
  const getDidChangeListeners = () => {
111
- return state$e.onDidChangeTextDocumentListeners;
111
+ return state$d.onDidChangeTextDocumentListeners;
112
112
  };
113
113
  const getDocument = textDocumentId => {
114
- return state$e.textDocuments[textDocumentId];
114
+ return state$d.textDocuments[textDocumentId];
115
115
  };
116
116
 
117
117
  const getOffset$1 = (textDocument, position) => {
@@ -352,6 +352,7 @@ const getType = value => {
352
352
  return 'unknown';
353
353
  }
354
354
  };
355
+
355
356
  const validateResultObject = (result, resultShape) => {
356
357
  if (!resultShape.properties) {
357
358
  return undefined;
@@ -671,7 +672,7 @@ const executeOrganizeImports = async uid => {
671
672
  return edits;
672
673
  };
673
674
 
674
- const state$d = {
675
+ const state$c = {
675
676
  commands: Object.create(null)
676
677
  };
677
678
  const getCommandDisplay = command => {
@@ -694,10 +695,10 @@ const registerCommand = command => {
694
695
  if (!command.execute) {
695
696
  throw new Error('command is missing execute function');
696
697
  }
697
- if (command.id in state$d.commands) {
698
+ if (command.id in state$c.commands) {
698
699
  throw new Error(`command cannot be registered multiple times`);
699
700
  }
700
- state$d.commands[command.id] = command;
701
+ state$c.commands[command.id] = command;
701
702
  } catch (error) {
702
703
  const commandDisplayId = getCommandDisplay(command);
703
704
  throw new VError(error, `Failed to register command${commandDisplayId}`);
@@ -705,7 +706,7 @@ const registerCommand = command => {
705
706
  };
706
707
  const executeCommand = async (id, ...args) => {
707
708
  try {
708
- const command = state$d.commands[id];
709
+ const command = state$c.commands[id];
709
710
  if (!command) {
710
711
  throw new Error(`command ${id} not found`);
711
712
  }
@@ -744,14 +745,14 @@ const {
744
745
  }]
745
746
  });
746
747
 
747
- const state$c = {
748
+ const state$b = {
748
749
  configuration: Object.create(null)
749
750
  };
750
751
  const getConfiguration = key => {
751
- return state$c.configuration[key] ?? '';
752
+ return state$b.configuration[key] ?? '';
752
753
  };
753
754
  const setConfigurations = preferences => {
754
- state$c.configuration = preferences;
755
+ state$b.configuration = preferences;
755
756
  };
756
757
 
757
758
  const RendererWorker = 1;
@@ -777,11 +778,11 @@ const invokeAndTransfer$1 = (method, ...params) => {
777
778
  return rpc.invokeAndTransfer(method, ...params);
778
779
  };
779
780
 
780
- const state$b = {
781
+ const state$a = {
781
782
  debugProviderMap: Object.create(null)
782
783
  };
783
784
  const getDebugProvider = id => {
784
- const provider = state$b.debugProviderMap[id];
785
+ const provider = state$a.debugProviderMap[id];
785
786
  if (!provider) {
786
787
  // @ts-ignore
787
788
  throw new VError(`no debug provider "${id}" found`);
@@ -792,7 +793,7 @@ const registerDebugProvider = debugProvider => {
792
793
  if (!debugProvider.id) {
793
794
  throw new Error('Failed to register debug system provider: missing id');
794
795
  }
795
- state$b.debugProviderMap[debugProvider.id] = debugProvider;
796
+ state$a.debugProviderMap[debugProvider.id] = debugProvider;
796
797
  };
797
798
  const start = async (protocol, path) => {
798
799
  try {
@@ -1646,7 +1647,7 @@ const set$7 = (id, fn) => {
1646
1647
  const get$8 = id => {
1647
1648
  return callbacks[id];
1648
1649
  };
1649
- const remove$2 = id => {
1650
+ const remove$3 = id => {
1650
1651
  delete callbacks[id];
1651
1652
  };
1652
1653
  let id$1 = 0;
@@ -1823,7 +1824,7 @@ const resolve = (id, response) => {
1823
1824
  return;
1824
1825
  }
1825
1826
  fn(response);
1826
- remove$2(id);
1827
+ remove$3(id);
1827
1828
  };
1828
1829
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
1829
1830
  const getErrorType = prettyError => {
@@ -2202,16 +2203,16 @@ const getWebSocketProtocol = () => {
2202
2203
  return location.protocol === 'https:' ? 'wss:' : 'ws:';
2203
2204
  };
2204
2205
 
2205
- const getWebSocketUrl = type => {
2206
+ const getWebSocketUrl = (type, host) => {
2206
2207
  const wsProtocol = getWebSocketProtocol();
2207
- return `${wsProtocol}//${location.host}/websocket/${type}`;
2208
+ return `${wsProtocol}//${host}/websocket/${type}`;
2208
2209
  };
2209
2210
 
2210
2211
  const create$4 = async ({
2211
2212
  type
2212
2213
  }) => {
2213
2214
  string(type);
2214
- const wsUrl = getWebSocketUrl(type);
2215
+ const wsUrl = getWebSocketUrl(type, location.host);
2215
2216
  const webSocket = new WebSocket(wsUrl);
2216
2217
  const rpc = await WebSocketRpcParent.create({
2217
2218
  webSocket,
@@ -2540,17 +2541,17 @@ const {
2540
2541
  }
2541
2542
  });
2542
2543
 
2543
- const state$a = {
2544
+ const state$9 = {
2544
2545
  providers: Object.create(null)
2545
2546
  };
2546
2547
  const registerSourceControlProvider = provider => {
2547
- state$a.providers[provider.id] = provider;
2548
+ state$9.providers[provider.id] = provider;
2548
2549
  };
2549
2550
  const getFilesFromProvider = provider => {
2550
2551
  return provider.getChangedFiles();
2551
2552
  };
2552
2553
  const getChangedFiles = async providerId => {
2553
- const provider = state$a.providers[providerId];
2554
+ const provider = state$9.providers[providerId];
2554
2555
  if (!provider) {
2555
2556
  throw new Error('no source control provider found');
2556
2557
  }
@@ -2561,7 +2562,7 @@ const getChangedFiles = async providerId => {
2561
2562
  const getFileBefore = async (providerId, uri) => {
2562
2563
  string(providerId);
2563
2564
  string(uri);
2564
- const provider = state$a.providers[providerId];
2565
+ const provider = state$9.providers[providerId];
2565
2566
  if (!provider) {
2566
2567
  throw new Error('no source control provider found');
2567
2568
  }
@@ -2583,7 +2584,7 @@ const getGroupsFromProvider = async (provider, cwd) => {
2583
2584
  throw new Error('source control provider is missing required function getGroups');
2584
2585
  };
2585
2586
  const getGroups = async (providerId, cwd) => {
2586
- const provider = state$a.providers[providerId];
2587
+ const provider = state$9.providers[providerId];
2587
2588
  if (!provider) {
2588
2589
  throw new Error('no source control provider found');
2589
2590
  }
@@ -2591,14 +2592,14 @@ const getGroups = async (providerId, cwd) => {
2591
2592
  return groups;
2592
2593
  };
2593
2594
  const acceptInput = async (providerId, value) => {
2594
- const provider = state$a.providers[providerId];
2595
+ const provider = state$9.providers[providerId];
2595
2596
  if (!provider) {
2596
2597
  throw new Error('no source control provider found');
2597
2598
  }
2598
2599
  await provider.acceptInput(value);
2599
2600
  };
2600
2601
  const add = async path => {
2601
- const provider = Object.values(state$a.providers)[0];
2602
+ const provider = Object.values(state$9.providers)[0];
2602
2603
  if (!provider) {
2603
2604
  return;
2604
2605
  }
@@ -2606,7 +2607,7 @@ const add = async path => {
2606
2607
  await provider.add(path);
2607
2608
  };
2608
2609
  const discard = async path => {
2609
- const provider = Object.values(state$a.providers)[0];
2610
+ const provider = Object.values(state$9.providers)[0];
2610
2611
  if (!provider) {
2611
2612
  return;
2612
2613
  }
@@ -2616,7 +2617,7 @@ const discard = async path => {
2616
2617
  const getEnabledProviderIds = async (scheme, root) => {
2617
2618
  string(scheme);
2618
2619
  string(root);
2619
- const providers = Object.values(state$a.providers);
2620
+ const providers = Object.values(state$9.providers);
2620
2621
  const enabledIds = [];
2621
2622
  for (const provider of providers) {
2622
2623
  // @ts-ignore
@@ -2643,7 +2644,7 @@ const {
2643
2644
  }
2644
2645
  });
2645
2646
 
2646
- const state$9 = {
2647
+ const state$8 = {
2647
2648
  textSearchProviders: Object.create(null)
2648
2649
  };
2649
2650
  const registerTextSearchProvider = textSearchProvider => {
@@ -2654,14 +2655,14 @@ const registerTextSearchProvider = textSearchProvider => {
2654
2655
  if (!textSearchProvider.scheme) {
2655
2656
  throw new Error('textSearchProvider is missing scheme');
2656
2657
  }
2657
- state$9.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
2658
+ state$8.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
2658
2659
  } catch (error) {
2659
2660
  throw new VError(error, 'Failed to register text search provider');
2660
2661
  }
2661
2662
  };
2662
2663
  const executeTextSearchProvider = async (scheme, query) => {
2663
2664
  try {
2664
- const textSearchProvider = state$9.textSearchProviders[scheme];
2665
+ const textSearchProvider = state$8.textSearchProviders[scheme];
2665
2666
  if (!textSearchProvider) {
2666
2667
  throw new Error(`No text search provider for ${scheme} found`);
2667
2668
  }
@@ -2861,14 +2862,14 @@ const createWorker = async ({
2861
2862
  return rpc;
2862
2863
  };
2863
2864
 
2864
- const state$8 = {
2865
+ const state$7 = {
2865
2866
  workspacePath: ''
2866
2867
  };
2867
2868
  const setWorkspacePath = path => {
2868
- state$8.workspacePath = path;
2869
+ state$7.workspacePath = path;
2869
2870
  };
2870
2871
  const getWorkspaceFolder = path => {
2871
- return state$8.workspacePath;
2872
+ return state$7.workspacePath;
2872
2873
  };
2873
2874
 
2874
2875
  class FormattingError extends Error {
@@ -3021,20 +3022,17 @@ const handleUnhandledRejection = event => {
3021
3022
  console.error(output);
3022
3023
  };
3023
3024
 
3024
- const state$7 = {
3025
- /**
3026
- * @type {any[]}
3027
- */
3025
+ const state$6 = {
3028
3026
  errors: []
3029
3027
  };
3030
3028
  const addError = error => {
3031
- // @ts-ignore
3032
- state$7.errors.push(error);
3029
+ state$6.errors = [...state$6.errors, error];
3033
3030
  };
3034
3031
  const hasRecentErrors = () => {
3035
- return state$7.errors.length > 0;
3032
+ return state$6.errors.length > 0;
3036
3033
  };
3037
3034
  const getRecentError = () => {
3035
+ state$6.errors.at(-1);
3038
3036
  };
3039
3037
 
3040
3038
  const handleContentSecurityPolicyViolation = event => {
@@ -3072,7 +3070,7 @@ const setup = ({
3072
3070
  global.vscode = api;
3073
3071
  };
3074
3072
 
3075
- const state$6 = {
3073
+ const state$5 = {
3076
3074
  webExtensions: []
3077
3075
  };
3078
3076
 
@@ -3134,7 +3132,7 @@ const addWebExtension = async path => {
3134
3132
  const manifestPath = getWebManifestPath(path);
3135
3133
  const manifest = await getWebExtensionManifest(path, manifestPath);
3136
3134
  // TODO avoid mutation if possible
3137
- state$6.webExtensions.push(manifest);
3135
+ state$5.webExtensions.push(manifest);
3138
3136
  clear();
3139
3137
  return manifest;
3140
3138
  };
@@ -3510,16 +3508,20 @@ replaceTraps(oldTraps => ({
3510
3508
  }
3511
3509
  }));
3512
3510
 
3511
+ const state$4 = {
3512
+ dbVersion: 1,
3513
+ /**
3514
+ * @type {any}
3515
+ */
3516
+ cachedDb: undefined
3517
+ };
3518
+
3513
3519
  const storeId = 'lvce-keyvalue';
3514
3520
 
3515
3521
  // TODO high memory usage in idb because of transactionDoneMap
3516
3522
 
3517
- const state$5 = {
3518
- dbVersion: 2,
3519
- cachedDb: undefined
3520
- };
3521
3523
  const getDb$1 = async () => {
3522
- const db = await openDB(storeId, state$5.dbVersion, {
3524
+ const db = await openDB(storeId, state$4.dbVersion, {
3523
3525
  async upgrade(db, oldVersion) {
3524
3526
  if (!db.objectStoreNames.contains(storeId)) {
3525
3527
  await db.createObjectStore(storeId, {
@@ -3530,9 +3532,15 @@ const getDb$1 = async () => {
3530
3532
  });
3531
3533
  return db;
3532
3534
  };
3535
+
3536
+ // TODO high memory usage in idb because of transactionDoneMap
3537
+
3538
+ const state$3 = {
3539
+ cachedDb: undefined
3540
+ };
3533
3541
  const getDbMemoized$1 = async () => {
3534
- state$5.cachedDb ||= await getDb$1();
3535
- return state$5.cachedDb;
3542
+ state$3.cachedDb ||= await getDb$1();
3543
+ return state$3.cachedDb;
3536
3544
  };
3537
3545
 
3538
3546
  // TODO high memory usage in idb because of transactionDoneMap
@@ -3698,7 +3706,7 @@ const getSharedProcessExtensions = () => {
3698
3706
  return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
3699
3707
  };
3700
3708
  const doGetExtensions = async () => {
3701
- const meta = state$6.webExtensions;
3709
+ const meta = state$5.webExtensions;
3702
3710
  if (platform === Web) {
3703
3711
  const webExtensions = await getWebExtensions();
3704
3712
  return [...webExtensions, ...meta];
@@ -3771,7 +3779,7 @@ const setThemeColor = async themeColor => {
3771
3779
  // TODO by default color theme should come from local storage, session storage, cache storage, indexeddb or blob url -> fast initial load
3772
3780
  // actual color theme can be computed after workbench has loaded (most times will be the same and doesn't need to be computed)
3773
3781
 
3774
- const state$4 = {
3782
+ const state$2 = {
3775
3783
  watchedTheme: ''
3776
3784
  };
3777
3785
  const FALLBACK_COLOR_THEME_ID = 'slime';
@@ -3782,7 +3790,7 @@ const FALLBACK_COLOR_THEME_ID = 'slime';
3782
3790
  const applyColorTheme = async colorThemeId => {
3783
3791
  try {
3784
3792
  string(colorThemeId);
3785
- state$4.colorTheme = colorThemeId;
3793
+ state$2.colorTheme = colorThemeId;
3786
3794
  const colorThemeCss = await getColorThemeCss(colorThemeId);
3787
3795
  await addCssStyleSheet('ContributedColorTheme', colorThemeCss);
3788
3796
  if (platform === Web) {
@@ -3797,10 +3805,10 @@ const applyColorTheme = async colorThemeId => {
3797
3805
  }
3798
3806
  };
3799
3807
  const watch = async id => {
3800
- if (state$4.watchedTheme === id) {
3808
+ if (state$2.watchedTheme === id) {
3801
3809
  return;
3802
3810
  }
3803
- state$4.watchedTheme = id;
3811
+ state$2.watchedTheme = id;
3804
3812
  await invoke$2('ExtensionHost.watchColorTheme', id);
3805
3813
  };
3806
3814
  const getPreferredColorTheme = () => {
@@ -3835,11 +3843,11 @@ const getConfiguredIframeWorkerUrl = async () => {
3835
3843
  return configuredWorkerUrl;
3836
3844
  };
3837
3845
 
3838
- const state$3 = {
3846
+ const state$1 = {
3839
3847
  id: 0
3840
3848
  };
3841
3849
  const create$1 = () => {
3842
- return ++state$3.id;
3850
+ return ++state$1.id;
3843
3851
  };
3844
3852
 
3845
3853
  const iframeWorkerCommandMap = {
@@ -4026,7 +4034,7 @@ const getUrlPrefix = (platform, extensionPath) => {
4026
4034
  return `/remote/${extensionPath}`;
4027
4035
  };
4028
4036
 
4029
- const handleRpcInfos = extension => {
4037
+ const handleRpcInfos = (extension, platform) => {
4030
4038
  try {
4031
4039
  if (!extension) {
4032
4040
  return;
@@ -4208,6 +4216,7 @@ const walk = (node, visitor) => {
4208
4216
  break;
4209
4217
  }
4210
4218
  };
4219
+
4211
4220
  const getBabelAstDependencies = (code, ast) => {
4212
4221
  const {
4213
4222
  program
@@ -4410,7 +4419,7 @@ const activate = async (extension, absolutePath) => {
4410
4419
  string(extension.browser);
4411
4420
  string(absolutePath);
4412
4421
  const module = await importScript(absolutePath);
4413
- handleRpcInfos(extension);
4422
+ handleRpcInfos(extension, platform);
4414
4423
  const token = create();
4415
4424
  try {
4416
4425
  await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
@@ -4484,7 +4493,7 @@ const mockRpc = () => {
4484
4493
  };
4485
4494
 
4486
4495
  const getStatusBarItems = async () => {
4487
- const providers = Object.values(state$a.providers);
4496
+ const providers = Object.values(state$9.providers);
4488
4497
  const statusBarItems = [];
4489
4498
  for (const provider of providers) {
4490
4499
  // @ts-ignore
@@ -4545,7 +4554,7 @@ const writeFile$1 = () => {
4545
4554
  const mkdir$1 = () => {
4546
4555
  throw new Error('not implemented');
4547
4556
  };
4548
- const remove$1 = () => {
4557
+ const remove$2 = () => {
4549
4558
  throw new Error('not implemented');
4550
4559
  };
4551
4560
  const readDirWithFileTypes$1 = async uri => {
@@ -4589,6 +4598,22 @@ class FileNotFoundError extends Error {
4589
4598
  }
4590
4599
  }
4591
4600
 
4601
+ // TODO move this to an extension?
4602
+
4603
+ const files = Object.create(null);
4604
+ const getDirent = uri => {
4605
+ return files[uri];
4606
+ };
4607
+ const setDirent = (uri, dirent) => {
4608
+ files[uri] = dirent;
4609
+ };
4610
+ const getAll = () => {
4611
+ return files;
4612
+ };
4613
+ const remove$1 = uri => {
4614
+ delete files[uri];
4615
+ };
4616
+
4592
4617
  const ApplicationJson = 'application/json';
4593
4618
  const AudioMpeg = 'audio/mpeg';
4594
4619
  const FontTtf = 'font/ttf';
@@ -4638,12 +4663,6 @@ const getContentType = uri => {
4638
4663
 
4639
4664
  // TODO move this to an extension?
4640
4665
 
4641
- const state$2 = {
4642
- files: Object.create(null)
4643
- };
4644
- const getDirent = uri => {
4645
- return state$2.files[uri];
4646
- };
4647
4666
  const readFile = uri => {
4648
4667
  const dirent = getDirent(uri);
4649
4668
  if (!dirent) {
@@ -4659,10 +4678,10 @@ const ensureParentDir = uri => {
4659
4678
  let endIndex = uri.indexOf(Slash);
4660
4679
  while (endIndex >= 0) {
4661
4680
  const part = uri.slice(startIndex, endIndex + 1);
4662
- state$2.files[part] = {
4681
+ setDirent(part, {
4663
4682
  type: Directory$1,
4664
4683
  content: ''
4665
- };
4684
+ });
4666
4685
  endIndex = uri.indexOf(Slash, endIndex + 1);
4667
4686
  }
4668
4687
  };
@@ -4674,10 +4693,10 @@ const writeFile = (uri, content) => {
4674
4693
  dirent.content = content;
4675
4694
  } else {
4676
4695
  ensureParentDir(uri);
4677
- state$2.files[uri] = {
4696
+ setDirent(uri, {
4678
4697
  type: File$1,
4679
4698
  content
4680
- };
4699
+ });
4681
4700
  }
4682
4701
  };
4683
4702
  const mkdir = uri => {
@@ -4685,20 +4704,20 @@ const mkdir = uri => {
4685
4704
  uri += Slash;
4686
4705
  }
4687
4706
  ensureParentDir(uri);
4688
- state$2.files[uri] = {
4707
+ setDirent(uri, {
4689
4708
  type: Directory$1,
4690
4709
  content: ''
4691
- };
4710
+ });
4692
4711
  };
4693
4712
  const remove = uri => {
4694
4713
  const toDelete = [];
4695
- for (const key of Object.keys(state$2.files)) {
4714
+ for (const key of Object.keys(getAll())) {
4696
4715
  if (key.startsWith(uri)) {
4697
4716
  toDelete.push(key);
4698
4717
  }
4699
4718
  }
4700
4719
  for (const key of toDelete) {
4701
- delete state$2.files[key];
4720
+ remove$1(key);
4702
4721
  }
4703
4722
  };
4704
4723
  const readDirWithFileTypes = uri => {
@@ -4706,7 +4725,7 @@ const readDirWithFileTypes = uri => {
4706
4725
  uri += Slash;
4707
4726
  }
4708
4727
  const dirents = [];
4709
- for (const [key, value] of Object.entries(state$2.files)) {
4728
+ for (const [key, value] of Object.entries(getAll())) {
4710
4729
  if (key.startsWith(uri)) {
4711
4730
  // @ts-ignore
4712
4731
  switch (value.type) {
@@ -4750,7 +4769,7 @@ const chmod = () => {
4750
4769
  throw new Error('[memfs] chmod not implemented');
4751
4770
  };
4752
4771
  const getFiles = () => {
4753
- return state$2.files;
4772
+ return getAll();
4754
4773
  };
4755
4774
 
4756
4775
  const getExtensionColorThemeNames = extension => {
@@ -4812,7 +4831,7 @@ const getIconThemeJson$1 = async iconThemeId => {
4812
4831
  extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
4813
4832
  };
4814
4833
  }
4815
- for (const webExtension of state$6.webExtensions) {
4834
+ for (const webExtension of state$5.webExtensions) {
4816
4835
  if (webExtension.iconThemes) {
4817
4836
  for (const iconTheme of webExtension.iconThemes) {
4818
4837
  // TODO handle error when icon theme path is not of type string
@@ -4908,7 +4927,7 @@ const handleIconThemeChange = async () => {
4908
4927
 
4909
4928
  const initialIconTheme = undefined;
4910
4929
 
4911
- const state$1 = {
4930
+ const state = {
4912
4931
  seenFiles: [],
4913
4932
  seenFolders: [],
4914
4933
  hasWarned: [],
@@ -4919,11 +4938,11 @@ const state$1 = {
4919
4938
  extensionPath: ''
4920
4939
  };
4921
4940
  const setTheme = iconTheme => {
4922
- state$1.iconTheme = iconTheme.json;
4923
- state$1.extensionPath = iconTheme.extensionPath;
4941
+ state.iconTheme = iconTheme.json;
4942
+ state.extensionPath = iconTheme.extensionPath;
4924
4943
  };
4925
4944
  const getState = () => {
4926
- return state$1;
4945
+ return state;
4927
4946
  };
4928
4947
 
4929
4948
  const setIconTheme = async iconThemeId => {
@@ -4943,23 +4962,38 @@ const hydrate = async () => {
4943
4962
  await setIconTheme(iconThemeId);
4944
4963
  };
4945
4964
 
4946
- const state = {
4947
- dbVersion: 1,
4948
- /**
4949
- * @type {any}
4950
- */
4951
- cachedDb: undefined
4952
- };
4953
-
4954
4965
  const isDataCloneError = error => {
4955
4966
  return error && error.name === 'DataCloneError';
4956
4967
  };
4957
4968
 
4958
4969
  // TODO high memory usage in idb because of transactionDoneMap
4959
4970
 
4971
+ const getHandleDb = async () => {
4972
+ const db = await openDB('handle', state$4.dbVersion, {
4973
+ async upgrade(db, oldVersion) {
4974
+ if (!db.objectStoreNames.contains('file-handles-store')) {
4975
+ // @ts-ignore
4976
+ await db.createObjectStore('file-handles-store', {});
4977
+ }
4978
+ }
4979
+ });
4980
+ return db;
4981
+ };
4982
+ const addHandle = async (uri, handle) => {
4983
+ const handleDb = await getHandleDb();
4984
+ await handleDb.put('file-handles-store', handle, uri);
4985
+ };
4986
+ const getHandle$1 = async uri => {
4987
+ const handleDb = await getHandleDb();
4988
+ const handle = await handleDb.get('file-handles-store', uri);
4989
+ return handle;
4990
+ };
4991
+
4992
+ // TODO high memory usage in idb because of transactionDoneMap
4993
+
4960
4994
  const getDb = async () => {
4961
4995
  // @ts-ignore
4962
- const db = await openDB('session', state.dbVersion, {
4996
+ const db = await openDB('session', state$4.dbVersion, {
4963
4997
  async upgrade(db, oldVersion) {
4964
4998
  if (!db.objectStoreNames.contains('session')) {
4965
4999
  const objectStore = await db.createObjectStore('session', {
@@ -4974,8 +5008,8 @@ const getDb = async () => {
4974
5008
  return db;
4975
5009
  };
4976
5010
  const getDbMemoized = async () => {
4977
- state.cachedDb ||= await getDb();
4978
- return state.cachedDb;
5011
+ state$4.cachedDb ||= await getDb();
5012
+ return state$4.cachedDb;
4979
5013
  };
4980
5014
  const saveValue = async (storeId, value) => {
4981
5015
  try {
@@ -5013,26 +5047,6 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
5013
5047
  }
5014
5048
  return objects;
5015
5049
  };
5016
- const getHandleDb = async () => {
5017
- const db = await openDB('handle', state.dbVersion, {
5018
- async upgrade(db, oldVersion) {
5019
- if (!db.objectStoreNames.contains('file-handles-store')) {
5020
- // @ts-ignore
5021
- await db.createObjectStore('file-handles-store', {});
5022
- }
5023
- }
5024
- });
5025
- return db;
5026
- };
5027
- const addHandle = async (uri, handle) => {
5028
- const handleDb = await getHandleDb();
5029
- await handleDb.put('file-handles-store', handle, uri);
5030
- };
5031
- const getHandle$1 = async uri => {
5032
- const handleDb = await getHandleDb();
5033
- const handle = await handleDb.get('file-handles-store', uri);
5034
- return handle;
5035
- };
5036
5050
 
5037
5051
  const getLanguagesFromExtension = extension => {
5038
5052
  // TODO what if extension is null? should not crash process, handle error gracefully
@@ -5141,7 +5155,7 @@ const removeLeadingSlash = path => {
5141
5155
  // TODO simplify code
5142
5156
  // 1. don't have playground prefix in fileMap json
5143
5157
  // 2. remove code here that removes the prefix
5144
- const searchFile$1 = async path => {
5158
+ const searchFile$2 = async path => {
5145
5159
  const fileList = await getJson(fileMapUrl);
5146
5160
  const result = fileList.map(removeLeadingSlash);
5147
5161
  const prefixLength = path.length - 'file:///'.length;
@@ -5152,6 +5166,29 @@ const searchFile$1 = async path => {
5152
5166
  return final;
5153
5167
  };
5154
5168
 
5169
+ const getHandle = async uri => {
5170
+ try {
5171
+ // TODO retrieve handle from state or from indexeddb
5172
+ // TODO if not found, throw error
5173
+ const handle = await getHandle$1(uri);
5174
+ return handle;
5175
+ } catch (error) {
5176
+ throw new VError(error, 'Failed to get handle');
5177
+ }
5178
+ };
5179
+
5180
+ const getDirectoryHandle = async uri => {
5181
+ const handle = await getHandle(uri);
5182
+ if (handle) {
5183
+ return handle;
5184
+ }
5185
+ const dirname$1 = dirname('/', uri);
5186
+ if (uri === dirname$1) {
5187
+ return undefined;
5188
+ }
5189
+ return getDirectoryHandle(dirname$1);
5190
+ };
5191
+
5155
5192
  const Directory = 'directory';
5156
5193
  const File = 'file';
5157
5194
 
@@ -5188,28 +5225,6 @@ const getChildHandles$1 = async handle => {
5188
5225
  return handles;
5189
5226
  };
5190
5227
 
5191
- const getHandle = async uri => {
5192
- try {
5193
- // TODO retrieve handle from state or from indexeddb
5194
- // TODO if not found, throw error
5195
- const handle = await getHandle$1(uri);
5196
- return handle;
5197
- } catch (error) {
5198
- throw new VError(error, 'Failed to get handle');
5199
- }
5200
- };
5201
-
5202
- const getDirectoryHandle$1 = async uri => {
5203
- const handle = await getHandle(uri);
5204
- if (handle) {
5205
- return handle;
5206
- }
5207
- const dirname$1 = dirname('/', uri);
5208
- if (uri === dirname$1) {
5209
- return undefined;
5210
- }
5211
- return getDirectoryHandle$1(dirname$1);
5212
- };
5213
5228
  const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
5214
5229
  const searchFilesRecursively = async (all, parent, handle) => {
5215
5230
  const childHandles = await getChildHandles$1(handle);
@@ -5230,9 +5245,10 @@ const searchFilesRecursively = async (all, parent, handle) => {
5230
5245
  }
5231
5246
  await Promise.all(promises);
5232
5247
  };
5233
- const searchFile = async uri => {
5248
+
5249
+ const searchFile$1 = async uri => {
5234
5250
  const path = uri.slice('html://'.length);
5235
- const handle = await getDirectoryHandle$1(path);
5251
+ const handle = await getDirectoryHandle(path);
5236
5252
  if (!handle) {
5237
5253
  // @ts-ignore
5238
5254
  throw new VError(`Folder not found ${uri}`);
@@ -5242,6 +5258,20 @@ const searchFile = async uri => {
5242
5258
  return all;
5243
5259
  };
5244
5260
 
5261
+ const searchFile = async (scheme, root, query, options, assetDir) => {
5262
+ string(scheme);
5263
+ string(root);
5264
+ string(query);
5265
+ const files = getFiles();
5266
+ const allResults = [];
5267
+ for (const [key, value] of Object.entries(files)) {
5268
+ if (value.type === File$1) {
5269
+ allResults.push(key);
5270
+ }
5271
+ }
5272
+ return allResults;
5273
+ };
5274
+
5245
5275
  const getTextSearchRegex = (query, matchCase) => {
5246
5276
  const flags = matchCase ? 'u' : 'iu';
5247
5277
  const regex = new RegExp(query, flags);
@@ -5344,18 +5374,6 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
5344
5374
  return allResults;
5345
5375
  };
5346
5376
 
5347
- const getDirectoryHandle = async uri => {
5348
- const handle = await getHandle(uri);
5349
- if (handle) {
5350
- return handle;
5351
- }
5352
- const dirname$1 = dirname('/', uri);
5353
- if (uri === dirname$1) {
5354
- return undefined;
5355
- }
5356
- return getDirectoryHandle(dirname$1);
5357
- };
5358
-
5359
5377
  const getChildHandles = async handle => {
5360
5378
  try {
5361
5379
  return await getChildHandles$1(handle);
@@ -5488,7 +5506,7 @@ const commandMap = {
5488
5506
  'FileSystemFetch.mkdir': mkdir$1,
5489
5507
  'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
5490
5508
  'FileSystemFetch.readFile': readFile$1,
5491
- 'FileSystemFetch.remove': remove$1,
5509
+ 'FileSystemFetch.remove': remove$2,
5492
5510
  'FileSystemFetch.writeFile': writeFile$1,
5493
5511
  'FileSystemMemory.chmod': chmod,
5494
5512
  'FileSystemMemory.getBlob': getBlob,
@@ -5514,8 +5532,9 @@ const commandMap = {
5514
5532
  'IndexedDb.set': set$3,
5515
5533
  'Languages.getLanguages': getLanguages,
5516
5534
  'SaveState.saveState': saveState,
5517
- 'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
5518
- 'SearchFileWithHtml.searchFileWithHtml': searchFile,
5535
+ 'SearchFileWithFetch.searchFileWithFetch': searchFile$2,
5536
+ 'SearchFileWithHtml.searchFileWithHtml': searchFile$1,
5537
+ 'SearchFileWithMemory.searchFileWithMemory': searchFile,
5519
5538
  'TextSearchFetch.textSearch': textSearch$2,
5520
5539
  'TextSearchHtml.textSearch': textSearch$1,
5521
5540
  'TextSearchMemory.textSearch': textSearch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"