@lvce-editor/extension-host-worker 4.10.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
  }
@@ -2787,6 +2788,10 @@ const getRemoteUrl$1 = async (uri, options = {}) => {
2787
2788
  };
2788
2789
 
2789
2790
  // TODO pass uuid to allow having multiple webviews open at the same time
2791
+
2792
+ /**
2793
+ * @deprecated use iframe worker instead of creating and querying webviews
2794
+ */
2790
2795
  const createWebView = async (providerId, port, uri, uid, origin, webView) => {
2791
2796
  const provider = getProvider(providerId);
2792
2797
  if (!provider) {
@@ -2818,9 +2823,17 @@ const disposeWebView = id => {
2818
2823
  // TODO race condition
2819
2824
  // const webView=webViews[id]
2820
2825
  };
2826
+
2827
+ /**
2828
+ * @deprecated use iframe worker instead of creating and querying webviews
2829
+ */
2821
2830
  const registerWebViewProvider = provider => {
2822
2831
  setProvider(provider.id, provider);
2823
2832
  };
2833
+
2834
+ /**
2835
+ * @deprecated use iframe worker instead of creating and querying webviews
2836
+ */
2824
2837
  const getWebViewInfo = providerId => {
2825
2838
  const webView = getWebView(providerId);
2826
2839
  if (!webView) {
@@ -2849,14 +2862,14 @@ const createWorker = async ({
2849
2862
  return rpc;
2850
2863
  };
2851
2864
 
2852
- const state$8 = {
2865
+ const state$7 = {
2853
2866
  workspacePath: ''
2854
2867
  };
2855
2868
  const setWorkspacePath = path => {
2856
- state$8.workspacePath = path;
2869
+ state$7.workspacePath = path;
2857
2870
  };
2858
2871
  const getWorkspaceFolder = path => {
2859
- return state$8.workspacePath;
2872
+ return state$7.workspacePath;
2860
2873
  };
2861
2874
 
2862
2875
  class FormattingError extends Error {
@@ -3009,20 +3022,17 @@ const handleUnhandledRejection = event => {
3009
3022
  console.error(output);
3010
3023
  };
3011
3024
 
3012
- const state$7 = {
3013
- /**
3014
- * @type {any[]}
3015
- */
3025
+ const state$6 = {
3016
3026
  errors: []
3017
3027
  };
3018
3028
  const addError = error => {
3019
- // @ts-ignore
3020
- state$7.errors.push(error);
3029
+ state$6.errors = [...state$6.errors, error];
3021
3030
  };
3022
3031
  const hasRecentErrors = () => {
3023
- return state$7.errors.length > 0;
3032
+ return state$6.errors.length > 0;
3024
3033
  };
3025
3034
  const getRecentError = () => {
3035
+ state$6.errors.at(-1);
3026
3036
  };
3027
3037
 
3028
3038
  const handleContentSecurityPolicyViolation = event => {
@@ -3060,7 +3070,7 @@ const setup = ({
3060
3070
  global.vscode = api;
3061
3071
  };
3062
3072
 
3063
- const state$6 = {
3073
+ const state$5 = {
3064
3074
  webExtensions: []
3065
3075
  };
3066
3076
 
@@ -3122,7 +3132,7 @@ const addWebExtension = async path => {
3122
3132
  const manifestPath = getWebManifestPath(path);
3123
3133
  const manifest = await getWebExtensionManifest(path, manifestPath);
3124
3134
  // TODO avoid mutation if possible
3125
- state$6.webExtensions.push(manifest);
3135
+ state$5.webExtensions.push(manifest);
3126
3136
  clear();
3127
3137
  return manifest;
3128
3138
  };
@@ -3498,16 +3508,20 @@ replaceTraps(oldTraps => ({
3498
3508
  }
3499
3509
  }));
3500
3510
 
3511
+ const state$4 = {
3512
+ dbVersion: 1,
3513
+ /**
3514
+ * @type {any}
3515
+ */
3516
+ cachedDb: undefined
3517
+ };
3518
+
3501
3519
  const storeId = 'lvce-keyvalue';
3502
3520
 
3503
3521
  // TODO high memory usage in idb because of transactionDoneMap
3504
3522
 
3505
- const state$5 = {
3506
- dbVersion: 2,
3507
- cachedDb: undefined
3508
- };
3509
3523
  const getDb$1 = async () => {
3510
- const db = await openDB(storeId, state$5.dbVersion, {
3524
+ const db = await openDB(storeId, state$4.dbVersion, {
3511
3525
  async upgrade(db, oldVersion) {
3512
3526
  if (!db.objectStoreNames.contains(storeId)) {
3513
3527
  await db.createObjectStore(storeId, {
@@ -3518,9 +3532,15 @@ const getDb$1 = async () => {
3518
3532
  });
3519
3533
  return db;
3520
3534
  };
3535
+
3536
+ // TODO high memory usage in idb because of transactionDoneMap
3537
+
3538
+ const state$3 = {
3539
+ cachedDb: undefined
3540
+ };
3521
3541
  const getDbMemoized$1 = async () => {
3522
- state$5.cachedDb ||= await getDb$1();
3523
- return state$5.cachedDb;
3542
+ state$3.cachedDb ||= await getDb$1();
3543
+ return state$3.cachedDb;
3524
3544
  };
3525
3545
 
3526
3546
  // TODO high memory usage in idb because of transactionDoneMap
@@ -3686,7 +3706,7 @@ const getSharedProcessExtensions = () => {
3686
3706
  return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
3687
3707
  };
3688
3708
  const doGetExtensions = async () => {
3689
- const meta = state$6.webExtensions;
3709
+ const meta = state$5.webExtensions;
3690
3710
  if (platform === Web) {
3691
3711
  const webExtensions = await getWebExtensions();
3692
3712
  return [...webExtensions, ...meta];
@@ -3759,7 +3779,7 @@ const setThemeColor = async themeColor => {
3759
3779
  // TODO by default color theme should come from local storage, session storage, cache storage, indexeddb or blob url -> fast initial load
3760
3780
  // actual color theme can be computed after workbench has loaded (most times will be the same and doesn't need to be computed)
3761
3781
 
3762
- const state$4 = {
3782
+ const state$2 = {
3763
3783
  watchedTheme: ''
3764
3784
  };
3765
3785
  const FALLBACK_COLOR_THEME_ID = 'slime';
@@ -3770,7 +3790,7 @@ const FALLBACK_COLOR_THEME_ID = 'slime';
3770
3790
  const applyColorTheme = async colorThemeId => {
3771
3791
  try {
3772
3792
  string(colorThemeId);
3773
- state$4.colorTheme = colorThemeId;
3793
+ state$2.colorTheme = colorThemeId;
3774
3794
  const colorThemeCss = await getColorThemeCss(colorThemeId);
3775
3795
  await addCssStyleSheet('ContributedColorTheme', colorThemeCss);
3776
3796
  if (platform === Web) {
@@ -3785,10 +3805,10 @@ const applyColorTheme = async colorThemeId => {
3785
3805
  }
3786
3806
  };
3787
3807
  const watch = async id => {
3788
- if (state$4.watchedTheme === id) {
3808
+ if (state$2.watchedTheme === id) {
3789
3809
  return;
3790
3810
  }
3791
- state$4.watchedTheme = id;
3811
+ state$2.watchedTheme = id;
3792
3812
  await invoke$2('ExtensionHost.watchColorTheme', id);
3793
3813
  };
3794
3814
  const getPreferredColorTheme = () => {
@@ -3823,11 +3843,11 @@ const getConfiguredIframeWorkerUrl = async () => {
3823
3843
  return configuredWorkerUrl;
3824
3844
  };
3825
3845
 
3826
- const state$3 = {
3846
+ const state$1 = {
3827
3847
  id: 0
3828
3848
  };
3829
3849
  const create$1 = () => {
3830
- return ++state$3.id;
3850
+ return ++state$1.id;
3831
3851
  };
3832
3852
 
3833
3853
  const iframeWorkerCommandMap = {
@@ -4014,7 +4034,7 @@ const getUrlPrefix = (platform, extensionPath) => {
4014
4034
  return `/remote/${extensionPath}`;
4015
4035
  };
4016
4036
 
4017
- const handleRpcInfos = extension => {
4037
+ const handleRpcInfos = (extension, platform) => {
4018
4038
  try {
4019
4039
  if (!extension) {
4020
4040
  return;
@@ -4196,6 +4216,7 @@ const walk = (node, visitor) => {
4196
4216
  break;
4197
4217
  }
4198
4218
  };
4219
+
4199
4220
  const getBabelAstDependencies = (code, ast) => {
4200
4221
  const {
4201
4222
  program
@@ -4398,7 +4419,7 @@ const activate = async (extension, absolutePath) => {
4398
4419
  string(extension.browser);
4399
4420
  string(absolutePath);
4400
4421
  const module = await importScript(absolutePath);
4401
- handleRpcInfos(extension);
4422
+ handleRpcInfos(extension, platform);
4402
4423
  const token = create();
4403
4424
  try {
4404
4425
  await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
@@ -4472,7 +4493,7 @@ const mockRpc = () => {
4472
4493
  };
4473
4494
 
4474
4495
  const getStatusBarItems = async () => {
4475
- const providers = Object.values(state$a.providers);
4496
+ const providers = Object.values(state$9.providers);
4476
4497
  const statusBarItems = [];
4477
4498
  for (const provider of providers) {
4478
4499
  // @ts-ignore
@@ -4533,7 +4554,7 @@ const writeFile$1 = () => {
4533
4554
  const mkdir$1 = () => {
4534
4555
  throw new Error('not implemented');
4535
4556
  };
4536
- const remove$1 = () => {
4557
+ const remove$2 = () => {
4537
4558
  throw new Error('not implemented');
4538
4559
  };
4539
4560
  const readDirWithFileTypes$1 = async uri => {
@@ -4577,6 +4598,22 @@ class FileNotFoundError extends Error {
4577
4598
  }
4578
4599
  }
4579
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
+
4580
4617
  const ApplicationJson = 'application/json';
4581
4618
  const AudioMpeg = 'audio/mpeg';
4582
4619
  const FontTtf = 'font/ttf';
@@ -4626,12 +4663,6 @@ const getContentType = uri => {
4626
4663
 
4627
4664
  // TODO move this to an extension?
4628
4665
 
4629
- const state$2 = {
4630
- files: Object.create(null)
4631
- };
4632
- const getDirent = uri => {
4633
- return state$2.files[uri];
4634
- };
4635
4666
  const readFile = uri => {
4636
4667
  const dirent = getDirent(uri);
4637
4668
  if (!dirent) {
@@ -4647,10 +4678,10 @@ const ensureParentDir = uri => {
4647
4678
  let endIndex = uri.indexOf(Slash);
4648
4679
  while (endIndex >= 0) {
4649
4680
  const part = uri.slice(startIndex, endIndex + 1);
4650
- state$2.files[part] = {
4681
+ setDirent(part, {
4651
4682
  type: Directory$1,
4652
4683
  content: ''
4653
- };
4684
+ });
4654
4685
  endIndex = uri.indexOf(Slash, endIndex + 1);
4655
4686
  }
4656
4687
  };
@@ -4662,10 +4693,10 @@ const writeFile = (uri, content) => {
4662
4693
  dirent.content = content;
4663
4694
  } else {
4664
4695
  ensureParentDir(uri);
4665
- state$2.files[uri] = {
4696
+ setDirent(uri, {
4666
4697
  type: File$1,
4667
4698
  content
4668
- };
4699
+ });
4669
4700
  }
4670
4701
  };
4671
4702
  const mkdir = uri => {
@@ -4673,20 +4704,20 @@ const mkdir = uri => {
4673
4704
  uri += Slash;
4674
4705
  }
4675
4706
  ensureParentDir(uri);
4676
- state$2.files[uri] = {
4707
+ setDirent(uri, {
4677
4708
  type: Directory$1,
4678
4709
  content: ''
4679
- };
4710
+ });
4680
4711
  };
4681
4712
  const remove = uri => {
4682
4713
  const toDelete = [];
4683
- for (const key of Object.keys(state$2.files)) {
4714
+ for (const key of Object.keys(getAll())) {
4684
4715
  if (key.startsWith(uri)) {
4685
4716
  toDelete.push(key);
4686
4717
  }
4687
4718
  }
4688
4719
  for (const key of toDelete) {
4689
- delete state$2.files[key];
4720
+ remove$1(key);
4690
4721
  }
4691
4722
  };
4692
4723
  const readDirWithFileTypes = uri => {
@@ -4694,7 +4725,7 @@ const readDirWithFileTypes = uri => {
4694
4725
  uri += Slash;
4695
4726
  }
4696
4727
  const dirents = [];
4697
- for (const [key, value] of Object.entries(state$2.files)) {
4728
+ for (const [key, value] of Object.entries(getAll())) {
4698
4729
  if (key.startsWith(uri)) {
4699
4730
  // @ts-ignore
4700
4731
  switch (value.type) {
@@ -4738,7 +4769,7 @@ const chmod = () => {
4738
4769
  throw new Error('[memfs] chmod not implemented');
4739
4770
  };
4740
4771
  const getFiles = () => {
4741
- return state$2.files;
4772
+ return getAll();
4742
4773
  };
4743
4774
 
4744
4775
  const getExtensionColorThemeNames = extension => {
@@ -4800,7 +4831,7 @@ const getIconThemeJson$1 = async iconThemeId => {
4800
4831
  extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
4801
4832
  };
4802
4833
  }
4803
- for (const webExtension of state$6.webExtensions) {
4834
+ for (const webExtension of state$5.webExtensions) {
4804
4835
  if (webExtension.iconThemes) {
4805
4836
  for (const iconTheme of webExtension.iconThemes) {
4806
4837
  // TODO handle error when icon theme path is not of type string
@@ -4838,6 +4869,10 @@ const getRpcInfo = rpcId => {
4838
4869
  return info;
4839
4870
  };
4840
4871
 
4872
+ const getWebViewInfo2 = providerId => {
4873
+ return invoke('WebView.getWebViewInfo', providerId);
4874
+ };
4875
+
4841
4876
  const getRemoteUrl = uri => {
4842
4877
  return `/remote/${uri}`;
4843
4878
  };
@@ -4892,7 +4927,7 @@ const handleIconThemeChange = async () => {
4892
4927
 
4893
4928
  const initialIconTheme = undefined;
4894
4929
 
4895
- const state$1 = {
4930
+ const state = {
4896
4931
  seenFiles: [],
4897
4932
  seenFolders: [],
4898
4933
  hasWarned: [],
@@ -4903,11 +4938,11 @@ const state$1 = {
4903
4938
  extensionPath: ''
4904
4939
  };
4905
4940
  const setTheme = iconTheme => {
4906
- state$1.iconTheme = iconTheme.json;
4907
- state$1.extensionPath = iconTheme.extensionPath;
4941
+ state.iconTheme = iconTheme.json;
4942
+ state.extensionPath = iconTheme.extensionPath;
4908
4943
  };
4909
4944
  const getState = () => {
4910
- return state$1;
4945
+ return state;
4911
4946
  };
4912
4947
 
4913
4948
  const setIconTheme = async iconThemeId => {
@@ -4927,23 +4962,38 @@ const hydrate = async () => {
4927
4962
  await setIconTheme(iconThemeId);
4928
4963
  };
4929
4964
 
4930
- const state = {
4931
- dbVersion: 1,
4932
- /**
4933
- * @type {any}
4934
- */
4935
- cachedDb: undefined
4936
- };
4937
-
4938
4965
  const isDataCloneError = error => {
4939
4966
  return error && error.name === 'DataCloneError';
4940
4967
  };
4941
4968
 
4942
4969
  // TODO high memory usage in idb because of transactionDoneMap
4943
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
+
4944
4994
  const getDb = async () => {
4945
4995
  // @ts-ignore
4946
- const db = await openDB('session', state.dbVersion, {
4996
+ const db = await openDB('session', state$4.dbVersion, {
4947
4997
  async upgrade(db, oldVersion) {
4948
4998
  if (!db.objectStoreNames.contains('session')) {
4949
4999
  const objectStore = await db.createObjectStore('session', {
@@ -4958,8 +5008,8 @@ const getDb = async () => {
4958
5008
  return db;
4959
5009
  };
4960
5010
  const getDbMemoized = async () => {
4961
- state.cachedDb ||= await getDb();
4962
- return state.cachedDb;
5011
+ state$4.cachedDb ||= await getDb();
5012
+ return state$4.cachedDb;
4963
5013
  };
4964
5014
  const saveValue = async (storeId, value) => {
4965
5015
  try {
@@ -4997,26 +5047,6 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
4997
5047
  }
4998
5048
  return objects;
4999
5049
  };
5000
- const getHandleDb = async () => {
5001
- const db = await openDB('handle', state.dbVersion, {
5002
- async upgrade(db, oldVersion) {
5003
- if (!db.objectStoreNames.contains('file-handles-store')) {
5004
- // @ts-ignore
5005
- await db.createObjectStore('file-handles-store', {});
5006
- }
5007
- }
5008
- });
5009
- return db;
5010
- };
5011
- const addHandle = async (uri, handle) => {
5012
- const handleDb = await getHandleDb();
5013
- await handleDb.put('file-handles-store', handle, uri);
5014
- };
5015
- const getHandle$1 = async uri => {
5016
- const handleDb = await getHandleDb();
5017
- const handle = await handleDb.get('file-handles-store', uri);
5018
- return handle;
5019
- };
5020
5050
 
5021
5051
  const getLanguagesFromExtension = extension => {
5022
5052
  // TODO what if extension is null? should not crash process, handle error gracefully
@@ -5125,7 +5155,7 @@ const removeLeadingSlash = path => {
5125
5155
  // TODO simplify code
5126
5156
  // 1. don't have playground prefix in fileMap json
5127
5157
  // 2. remove code here that removes the prefix
5128
- const searchFile$1 = async path => {
5158
+ const searchFile$2 = async path => {
5129
5159
  const fileList = await getJson(fileMapUrl);
5130
5160
  const result = fileList.map(removeLeadingSlash);
5131
5161
  const prefixLength = path.length - 'file:///'.length;
@@ -5136,6 +5166,29 @@ const searchFile$1 = async path => {
5136
5166
  return final;
5137
5167
  };
5138
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
+
5139
5192
  const Directory = 'directory';
5140
5193
  const File = 'file';
5141
5194
 
@@ -5172,28 +5225,6 @@ const getChildHandles$1 = async handle => {
5172
5225
  return handles;
5173
5226
  };
5174
5227
 
5175
- const getHandle = async uri => {
5176
- try {
5177
- // TODO retrieve handle from state or from indexeddb
5178
- // TODO if not found, throw error
5179
- const handle = await getHandle$1(uri);
5180
- return handle;
5181
- } catch (error) {
5182
- throw new VError(error, 'Failed to get handle');
5183
- }
5184
- };
5185
-
5186
- const getDirectoryHandle$1 = async uri => {
5187
- const handle = await getHandle(uri);
5188
- if (handle) {
5189
- return handle;
5190
- }
5191
- const dirname$1 = dirname('/', uri);
5192
- if (uri === dirname$1) {
5193
- return undefined;
5194
- }
5195
- return getDirectoryHandle$1(dirname$1);
5196
- };
5197
5228
  const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
5198
5229
  const searchFilesRecursively = async (all, parent, handle) => {
5199
5230
  const childHandles = await getChildHandles$1(handle);
@@ -5214,9 +5245,10 @@ const searchFilesRecursively = async (all, parent, handle) => {
5214
5245
  }
5215
5246
  await Promise.all(promises);
5216
5247
  };
5217
- const searchFile = async uri => {
5248
+
5249
+ const searchFile$1 = async uri => {
5218
5250
  const path = uri.slice('html://'.length);
5219
- const handle = await getDirectoryHandle$1(path);
5251
+ const handle = await getDirectoryHandle(path);
5220
5252
  if (!handle) {
5221
5253
  // @ts-ignore
5222
5254
  throw new VError(`Folder not found ${uri}`);
@@ -5226,6 +5258,20 @@ const searchFile = async uri => {
5226
5258
  return all;
5227
5259
  };
5228
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
+
5229
5275
  const getTextSearchRegex = (query, matchCase) => {
5230
5276
  const flags = matchCase ? 'u' : 'iu';
5231
5277
  const regex = new RegExp(query, flags);
@@ -5328,18 +5374,6 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
5328
5374
  return allResults;
5329
5375
  };
5330
5376
 
5331
- const getDirectoryHandle = async uri => {
5332
- const handle = await getHandle(uri);
5333
- if (handle) {
5334
- return handle;
5335
- }
5336
- const dirname$1 = dirname('/', uri);
5337
- if (uri === dirname$1) {
5338
- return undefined;
5339
- }
5340
- return getDirectoryHandle(dirname$1);
5341
- };
5342
-
5343
5377
  const getChildHandles = async handle => {
5344
5378
  try {
5345
5379
  return await getChildHandles$1(handle);
@@ -5446,17 +5480,33 @@ const commandMap = {
5446
5480
  'ColorTheme.getColorThemeNames': getColorThemeNames,
5447
5481
  'ColorTheme.hydrate': hydrate$1,
5448
5482
  'ExtensionHost.launchIframeWorker': launchIframeWorker,
5483
+ 'ExtensionHostDebug.evaluate': evaluate,
5484
+ 'ExtensionHostDebug.getProperties': getProperties,
5485
+ 'ExtensionHostDebug.listProcesses': listProcesses,
5486
+ 'ExtensionHostDebug.pause': pause,
5487
+ 'ExtensionHostDebug.resume': resume,
5488
+ 'ExtensionHostDebug.setPauseOnException': setPauseOnException,
5489
+ 'ExtensionHostDebug.setPauseOnExceptions': setPauseOnExceptions,
5490
+ 'ExtensionHostDebug.start': start,
5491
+ 'ExtensionHostDebug.stepInto': stepInto,
5492
+ 'ExtensionHostDebug.stepOut': stepOut,
5493
+ 'ExtensionHostDebug.stepOver': stepOver,
5449
5494
  'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
5450
5495
  'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
5451
- 'Extensions.getExtensions': getExtensions,
5452
- 'Extensions.getExtension': getExtension,
5496
+ 'ExtensionHostWebView.create': createWebView,
5497
+ 'ExtensionHostWebView.dispose': disposeWebView,
5498
+ 'ExtensionHostWebView.getWebViewInfo': getWebViewInfo,
5499
+ 'ExtensionHostWebView.getWebViewInfo2': getWebViewInfo2,
5500
+ 'ExtensionHostWebView.load': loadWebView,
5453
5501
  'Extensions.addWebExtension': addWebExtension,
5502
+ 'Extensions.getExtension': getExtension,
5503
+ 'Extensions.getExtensions': getExtensions,
5454
5504
  'FileSystemFetch.chmod': chmod$1,
5455
5505
  'FileSystemFetch.getBlob': getBlob$1,
5456
5506
  'FileSystemFetch.mkdir': mkdir$1,
5457
5507
  'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
5458
5508
  'FileSystemFetch.readFile': readFile$1,
5459
- 'FileSystemFetch.remove': remove$1,
5509
+ 'FileSystemFetch.remove': remove$2,
5460
5510
  'FileSystemFetch.writeFile': writeFile$1,
5461
5511
  'FileSystemMemory.chmod': chmod,
5462
5512
  'FileSystemMemory.getBlob': getBlob,
@@ -5467,6 +5517,8 @@ const commandMap = {
5467
5517
  'FileSystemMemory.readFile': readFile,
5468
5518
  'FileSystemMemory.remove': remove,
5469
5519
  'FileSystemMemory.writeFile': writeFile,
5520
+ 'HandleBeforeUnload.handleBeforeUnload': handleBeforeUnload,
5521
+ 'HandleMessagePort.handleMessagePort': handleMessagePort,
5470
5522
  'IconTheme.getJson': getIconThemeJson,
5471
5523
  'IconTheme.getState': getState,
5472
5524
  'IconTheme.hydrate': hydrate,
@@ -5479,8 +5531,10 @@ const commandMap = {
5479
5531
  'IndexedDb.saveValue': saveValue,
5480
5532
  'IndexedDb.set': set$3,
5481
5533
  'Languages.getLanguages': getLanguages,
5482
- 'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
5483
- 'SearchFileWithHtml.searchFileWithHtml': searchFile,
5534
+ 'SaveState.saveState': saveState,
5535
+ 'SearchFileWithFetch.searchFileWithFetch': searchFile$2,
5536
+ 'SearchFileWithHtml.searchFileWithHtml': searchFile$1,
5537
+ 'SearchFileWithMemory.searchFileWithMemory': searchFile,
5484
5538
  'TextSearchFetch.textSearch': textSearch$2,
5485
5539
  'TextSearchHtml.textSearch': textSearch$1,
5486
5540
  'TextSearchMemory.textSearch': textSearch,
@@ -5489,24 +5543,6 @@ const commandMap = {
5489
5543
  'WebView.createWebViewWorkerRpc2': createWebViewWorkerRpc2,
5490
5544
  'WebView.getRpcInfo': getRpcInfo,
5491
5545
  'WebViews.getWebViews': getWebViews,
5492
- ['ExtensionHostDebug.evaluate']: evaluate,
5493
- ['ExtensionHostDebug.getProperties']: getProperties,
5494
- ['ExtensionHostDebug.listProcesses']: listProcesses,
5495
- ['ExtensionHostDebug.pause']: pause,
5496
- ['ExtensionHostDebug.resume']: resume,
5497
- ['ExtensionHostDebug.setPauseOnException']: setPauseOnException,
5498
- ['ExtensionHostDebug.setPauseOnExceptions']: setPauseOnExceptions,
5499
- ['ExtensionHostDebug.start']: start,
5500
- ['ExtensionHostDebug.stepInto']: stepInto,
5501
- ['ExtensionHostDebug.stepOut']: stepOut,
5502
- ['ExtensionHostDebug.stepOver']: stepOver,
5503
- ['ExtensionHostWebView.create']: createWebView,
5504
- ['ExtensionHostWebView.dispose']: disposeWebView,
5505
- ['ExtensionHostWebView.getWebViewInfo']: getWebViewInfo,
5506
- ['ExtensionHostWebView.load']: loadWebView,
5507
- ['HandleBeforeUnload.handleBeforeUnload']: handleBeforeUnload,
5508
- ['HandleMessagePort.handleMessagePort']: handleMessagePort,
5509
- ['SaveState.saveState']: saveState,
5510
5546
  [BraceCompletionExecuteBraceCompletionProvider]: executeBraceCompletionProvider,
5511
5547
  [ClosingTagExecuteClosingTagProvider]: executeClosingTagProvider,
5512
5548
  [CommandExecute]: executeCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "4.10.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"