@lvce-editor/extension-host-worker 4.11.0 → 4.13.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;
@@ -772,16 +773,16 @@ const send$1 = (method, ...params) => {
772
773
  const rpc = get$a(RendererWorker);
773
774
  return rpc.send(method, ...params);
774
775
  };
775
- const invokeAndTransfer$1 = (method, ...params) => {
776
+ const invokeAndTransfer$2 = (method, ...params) => {
776
777
  const rpc = get$a(RendererWorker);
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 => {
@@ -1973,7 +1974,7 @@ const send = (transport, method, ...params) => {
1973
1974
  const invoke$1 = (ipc, method, ...params) => {
1974
1975
  return invokeHelper(ipc, method, params, false);
1975
1976
  };
1976
- const invokeAndTransfer = (ipc, method, ...params) => {
1977
+ const invokeAndTransfer$1 = (ipc, method, ...params) => {
1977
1978
  return invokeHelper(ipc, method, params, true);
1978
1979
  };
1979
1980
 
@@ -2006,7 +2007,7 @@ const createRpc$1 = ipc => {
2006
2007
  return invoke$1(ipc, method, ...params);
2007
2008
  },
2008
2009
  invokeAndTransfer(method, ...params) {
2009
- return invokeAndTransfer(ipc, method, ...params);
2010
+ return invokeAndTransfer$1(ipc, method, ...params);
2010
2011
  }
2011
2012
  };
2012
2013
  return rpc;
@@ -2129,7 +2130,7 @@ const sendPort = async ({
2129
2130
  name,
2130
2131
  port
2131
2132
  }) => {
2132
- await invokeAndTransfer$1('IpcParent.create', {
2133
+ await invokeAndTransfer$2('IpcParent.create', {
2133
2134
  method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
2134
2135
  url,
2135
2136
  name,
@@ -2170,7 +2171,7 @@ const IpcParentWithModuleWorkerAndWorkaroundForChromeDevtoolsBug = {
2170
2171
  };
2171
2172
 
2172
2173
  const sendMessagePortToElectron = async (port, initialCommand) => {
2173
- await invokeAndTransfer$1('SendMessagePortToElectron.sendMessagePortToElectron', port, initialCommand);
2174
+ await invokeAndTransfer$2('SendMessagePortToElectron.sendMessagePortToElectron', port, initialCommand);
2174
2175
  };
2175
2176
 
2176
2177
  const getPort = async type => {
@@ -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
  }
@@ -2717,7 +2718,7 @@ const createWebViewIpc = async webView => {
2717
2718
  commandMap: {}
2718
2719
  });
2719
2720
  const portType = 'test';
2720
- await invokeAndTransfer$1('WebView.setPort', uid, port1, origin, portType);
2721
+ await invokeAndTransfer$2('WebView.setPort', uid, port1, origin, portType);
2721
2722
  // TODO maybe don't send a message port only to get object url?
2722
2723
  // TODO dispose rpc to avoid memory leak
2723
2724
  const rpc = await rpcPromise;
@@ -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,20 +3843,20 @@ 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 = {
3846
3854
  'WebView.compatExtensionHostWorkerInvoke': (...args) => invoke$2('WebView.compatExtensionHostWorkerInvoke', ...args),
3847
- 'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
3855
+ 'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$2('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
3848
3856
  'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
3849
- 'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatRendererProcessInvokeAndTransfer', ...args),
3857
+ 'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$2('WebView.compatRendererProcessInvokeAndTransfer', ...args),
3850
3858
  // @ts-ignore
3851
- 'WebView.compatRendererWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1(...args),
3859
+ 'WebView.compatRendererWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$2(...args),
3852
3860
  // @ts-ignore
3853
3861
  'WebView.compatRendererWorkerInvoke': (...args) => invoke$2(...args),
3854
3862
  'WebView.compatSharedProcessInvoke': (...args) => invoke$2('WebView.compatSharedProcessInvoke', ...args),
@@ -3888,6 +3896,10 @@ const invoke = async (method, ...params) => {
3888
3896
  const rpc = await ensureWorker();
3889
3897
  return rpc.invoke(method, ...params);
3890
3898
  };
3899
+ const invokeAndTransfer = async (method, ...params) => {
3900
+ const rpc = await ensureWorker();
3901
+ return rpc.invokeAndTransfer(method, ...params);
3902
+ };
3891
3903
 
3892
3904
  const createWebView3 = async ({
3893
3905
  id,
@@ -3918,7 +3930,7 @@ const createWebViewWorkerRpc2 = async (rpcInfo, port) => {
3918
3930
 
3919
3931
  // TODO have a way so that the worker already includes the webview api and the extension
3920
3932
  // host subworker doesn't need to import the other file
3921
- await invokeAndTransfer$1('IpcParent.create', {
3933
+ await invokeAndTransfer$2('IpcParent.create', {
3922
3934
  method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
3923
3935
  url: rpcInfo.url,
3924
3936
  name: rpcInfo.name,
@@ -3939,7 +3951,7 @@ const createWebViewWorkerRpc = async (rpcInfo, port) => {
3939
3951
 
3940
3952
  // TODO have a way so that the worker already includes the webview api and the extension
3941
3953
  // host subworker doesn't need to import the other file
3942
- await invokeAndTransfer$1('IpcParent.create', {
3954
+ await invokeAndTransfer$2('IpcParent.create', {
3943
3955
  method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
3944
3956
  url: extensionHostSubWorkerUrl,
3945
3957
  name: rpcInfo.name,
@@ -4026,7 +4038,7 @@ const getUrlPrefix = (platform, extensionPath) => {
4026
4038
  return `/remote/${extensionPath}`;
4027
4039
  };
4028
4040
 
4029
- const handleRpcInfos = extension => {
4041
+ const handleRpcInfos = (extension, platform) => {
4030
4042
  try {
4031
4043
  if (!extension) {
4032
4044
  return;
@@ -4208,6 +4220,7 @@ const walk = (node, visitor) => {
4208
4220
  break;
4209
4221
  }
4210
4222
  };
4223
+
4211
4224
  const getBabelAstDependencies = (code, ast) => {
4212
4225
  const {
4213
4226
  program
@@ -4410,7 +4423,7 @@ const activate = async (extension, absolutePath) => {
4410
4423
  string(extension.browser);
4411
4424
  string(absolutePath);
4412
4425
  const module = await importScript(absolutePath);
4413
- handleRpcInfos(extension);
4426
+ handleRpcInfos(extension, platform);
4414
4427
  const token = create();
4415
4428
  try {
4416
4429
  await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
@@ -4484,7 +4497,7 @@ const mockRpc = () => {
4484
4497
  };
4485
4498
 
4486
4499
  const getStatusBarItems = async () => {
4487
- const providers = Object.values(state$a.providers);
4500
+ const providers = Object.values(state$9.providers);
4488
4501
  const statusBarItems = [];
4489
4502
  for (const provider of providers) {
4490
4503
  // @ts-ignore
@@ -4545,7 +4558,7 @@ const writeFile$1 = () => {
4545
4558
  const mkdir$1 = () => {
4546
4559
  throw new Error('not implemented');
4547
4560
  };
4548
- const remove$1 = () => {
4561
+ const remove$2 = () => {
4549
4562
  throw new Error('not implemented');
4550
4563
  };
4551
4564
  const readDirWithFileTypes$1 = async uri => {
@@ -4589,6 +4602,22 @@ class FileNotFoundError extends Error {
4589
4602
  }
4590
4603
  }
4591
4604
 
4605
+ // TODO move this to an extension?
4606
+
4607
+ const files = Object.create(null);
4608
+ const getDirent = uri => {
4609
+ return files[uri];
4610
+ };
4611
+ const setDirent = (uri, dirent) => {
4612
+ files[uri] = dirent;
4613
+ };
4614
+ const getAll = () => {
4615
+ return files;
4616
+ };
4617
+ const remove$1 = uri => {
4618
+ delete files[uri];
4619
+ };
4620
+
4592
4621
  const ApplicationJson = 'application/json';
4593
4622
  const AudioMpeg = 'audio/mpeg';
4594
4623
  const FontTtf = 'font/ttf';
@@ -4638,12 +4667,6 @@ const getContentType = uri => {
4638
4667
 
4639
4668
  // TODO move this to an extension?
4640
4669
 
4641
- const state$2 = {
4642
- files: Object.create(null)
4643
- };
4644
- const getDirent = uri => {
4645
- return state$2.files[uri];
4646
- };
4647
4670
  const readFile = uri => {
4648
4671
  const dirent = getDirent(uri);
4649
4672
  if (!dirent) {
@@ -4659,10 +4682,10 @@ const ensureParentDir = uri => {
4659
4682
  let endIndex = uri.indexOf(Slash);
4660
4683
  while (endIndex >= 0) {
4661
4684
  const part = uri.slice(startIndex, endIndex + 1);
4662
- state$2.files[part] = {
4685
+ setDirent(part, {
4663
4686
  type: Directory$1,
4664
4687
  content: ''
4665
- };
4688
+ });
4666
4689
  endIndex = uri.indexOf(Slash, endIndex + 1);
4667
4690
  }
4668
4691
  };
@@ -4674,10 +4697,10 @@ const writeFile = (uri, content) => {
4674
4697
  dirent.content = content;
4675
4698
  } else {
4676
4699
  ensureParentDir(uri);
4677
- state$2.files[uri] = {
4700
+ setDirent(uri, {
4678
4701
  type: File$1,
4679
4702
  content
4680
- };
4703
+ });
4681
4704
  }
4682
4705
  };
4683
4706
  const mkdir = uri => {
@@ -4685,20 +4708,20 @@ const mkdir = uri => {
4685
4708
  uri += Slash;
4686
4709
  }
4687
4710
  ensureParentDir(uri);
4688
- state$2.files[uri] = {
4711
+ setDirent(uri, {
4689
4712
  type: Directory$1,
4690
4713
  content: ''
4691
- };
4714
+ });
4692
4715
  };
4693
4716
  const remove = uri => {
4694
4717
  const toDelete = [];
4695
- for (const key of Object.keys(state$2.files)) {
4718
+ for (const key of Object.keys(getAll())) {
4696
4719
  if (key.startsWith(uri)) {
4697
4720
  toDelete.push(key);
4698
4721
  }
4699
4722
  }
4700
4723
  for (const key of toDelete) {
4701
- delete state$2.files[key];
4724
+ remove$1(key);
4702
4725
  }
4703
4726
  };
4704
4727
  const readDirWithFileTypes = uri => {
@@ -4706,7 +4729,7 @@ const readDirWithFileTypes = uri => {
4706
4729
  uri += Slash;
4707
4730
  }
4708
4731
  const dirents = [];
4709
- for (const [key, value] of Object.entries(state$2.files)) {
4732
+ for (const [key, value] of Object.entries(getAll())) {
4710
4733
  if (key.startsWith(uri)) {
4711
4734
  // @ts-ignore
4712
4735
  switch (value.type) {
@@ -4750,7 +4773,7 @@ const chmod = () => {
4750
4773
  throw new Error('[memfs] chmod not implemented');
4751
4774
  };
4752
4775
  const getFiles = () => {
4753
- return state$2.files;
4776
+ return getAll();
4754
4777
  };
4755
4778
 
4756
4779
  const getExtensionColorThemeNames = extension => {
@@ -4812,7 +4835,7 @@ const getIconThemeJson$1 = async iconThemeId => {
4812
4835
  extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
4813
4836
  };
4814
4837
  }
4815
- for (const webExtension of state$6.webExtensions) {
4838
+ for (const webExtension of state$5.webExtensions) {
4816
4839
  if (webExtension.iconThemes) {
4817
4840
  for (const iconTheme of webExtension.iconThemes) {
4818
4841
  // TODO handle error when icon theme path is not of type string
@@ -4908,7 +4931,7 @@ const handleIconThemeChange = async () => {
4908
4931
 
4909
4932
  const initialIconTheme = undefined;
4910
4933
 
4911
- const state$1 = {
4934
+ const state = {
4912
4935
  seenFiles: [],
4913
4936
  seenFolders: [],
4914
4937
  hasWarned: [],
@@ -4919,11 +4942,11 @@ const state$1 = {
4919
4942
  extensionPath: ''
4920
4943
  };
4921
4944
  const setTheme = iconTheme => {
4922
- state$1.iconTheme = iconTheme.json;
4923
- state$1.extensionPath = iconTheme.extensionPath;
4945
+ state.iconTheme = iconTheme.json;
4946
+ state.extensionPath = iconTheme.extensionPath;
4924
4947
  };
4925
4948
  const getState = () => {
4926
- return state$1;
4949
+ return state;
4927
4950
  };
4928
4951
 
4929
4952
  const setIconTheme = async iconThemeId => {
@@ -4943,23 +4966,38 @@ const hydrate = async () => {
4943
4966
  await setIconTheme(iconThemeId);
4944
4967
  };
4945
4968
 
4946
- const state = {
4947
- dbVersion: 1,
4948
- /**
4949
- * @type {any}
4950
- */
4951
- cachedDb: undefined
4952
- };
4953
-
4954
4969
  const isDataCloneError = error => {
4955
4970
  return error && error.name === 'DataCloneError';
4956
4971
  };
4957
4972
 
4958
4973
  // TODO high memory usage in idb because of transactionDoneMap
4959
4974
 
4975
+ const getHandleDb = async () => {
4976
+ const db = await openDB('handle', state$4.dbVersion, {
4977
+ async upgrade(db, oldVersion) {
4978
+ if (!db.objectStoreNames.contains('file-handles-store')) {
4979
+ // @ts-ignore
4980
+ await db.createObjectStore('file-handles-store', {});
4981
+ }
4982
+ }
4983
+ });
4984
+ return db;
4985
+ };
4986
+ const addHandle = async (uri, handle) => {
4987
+ const handleDb = await getHandleDb();
4988
+ await handleDb.put('file-handles-store', handle, uri);
4989
+ };
4990
+ const getHandle$1 = async uri => {
4991
+ const handleDb = await getHandleDb();
4992
+ const handle = await handleDb.get('file-handles-store', uri);
4993
+ return handle;
4994
+ };
4995
+
4996
+ // TODO high memory usage in idb because of transactionDoneMap
4997
+
4960
4998
  const getDb = async () => {
4961
4999
  // @ts-ignore
4962
- const db = await openDB('session', state.dbVersion, {
5000
+ const db = await openDB('session', state$4.dbVersion, {
4963
5001
  async upgrade(db, oldVersion) {
4964
5002
  if (!db.objectStoreNames.contains('session')) {
4965
5003
  const objectStore = await db.createObjectStore('session', {
@@ -4974,8 +5012,8 @@ const getDb = async () => {
4974
5012
  return db;
4975
5013
  };
4976
5014
  const getDbMemoized = async () => {
4977
- state.cachedDb ||= await getDb();
4978
- return state.cachedDb;
5015
+ state$4.cachedDb ||= await getDb();
5016
+ return state$4.cachedDb;
4979
5017
  };
4980
5018
  const saveValue = async (storeId, value) => {
4981
5019
  try {
@@ -5013,26 +5051,6 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
5013
5051
  }
5014
5052
  return objects;
5015
5053
  };
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
5054
 
5037
5055
  const getLanguagesFromExtension = extension => {
5038
5056
  // TODO what if extension is null? should not crash process, handle error gracefully
@@ -5141,7 +5159,7 @@ const removeLeadingSlash = path => {
5141
5159
  // TODO simplify code
5142
5160
  // 1. don't have playground prefix in fileMap json
5143
5161
  // 2. remove code here that removes the prefix
5144
- const searchFile$1 = async path => {
5162
+ const searchFile$2 = async path => {
5145
5163
  const fileList = await getJson(fileMapUrl);
5146
5164
  const result = fileList.map(removeLeadingSlash);
5147
5165
  const prefixLength = path.length - 'file:///'.length;
@@ -5152,6 +5170,29 @@ const searchFile$1 = async path => {
5152
5170
  return final;
5153
5171
  };
5154
5172
 
5173
+ const getHandle = async uri => {
5174
+ try {
5175
+ // TODO retrieve handle from state or from indexeddb
5176
+ // TODO if not found, throw error
5177
+ const handle = await getHandle$1(uri);
5178
+ return handle;
5179
+ } catch (error) {
5180
+ throw new VError(error, 'Failed to get handle');
5181
+ }
5182
+ };
5183
+
5184
+ const getDirectoryHandle = async uri => {
5185
+ const handle = await getHandle(uri);
5186
+ if (handle) {
5187
+ return handle;
5188
+ }
5189
+ const dirname$1 = dirname('/', uri);
5190
+ if (uri === dirname$1) {
5191
+ return undefined;
5192
+ }
5193
+ return getDirectoryHandle(dirname$1);
5194
+ };
5195
+
5155
5196
  const Directory = 'directory';
5156
5197
  const File = 'file';
5157
5198
 
@@ -5188,28 +5229,6 @@ const getChildHandles$1 = async handle => {
5188
5229
  return handles;
5189
5230
  };
5190
5231
 
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
5232
  const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
5214
5233
  const searchFilesRecursively = async (all, parent, handle) => {
5215
5234
  const childHandles = await getChildHandles$1(handle);
@@ -5230,9 +5249,10 @@ const searchFilesRecursively = async (all, parent, handle) => {
5230
5249
  }
5231
5250
  await Promise.all(promises);
5232
5251
  };
5233
- const searchFile = async uri => {
5252
+
5253
+ const searchFile$1 = async uri => {
5234
5254
  const path = uri.slice('html://'.length);
5235
- const handle = await getDirectoryHandle$1(path);
5255
+ const handle = await getDirectoryHandle(path);
5236
5256
  if (!handle) {
5237
5257
  // @ts-ignore
5238
5258
  throw new VError(`Folder not found ${uri}`);
@@ -5242,6 +5262,20 @@ const searchFile = async uri => {
5242
5262
  return all;
5243
5263
  };
5244
5264
 
5265
+ const searchFile = async (scheme, root, query, options, assetDir) => {
5266
+ string(scheme);
5267
+ string(root);
5268
+ string(query);
5269
+ const files = getFiles();
5270
+ const allResults = [];
5271
+ for (const [key, value] of Object.entries(files)) {
5272
+ if (value.type === File$1) {
5273
+ allResults.push(key);
5274
+ }
5275
+ }
5276
+ return allResults;
5277
+ };
5278
+
5245
5279
  const getTextSearchRegex = (query, matchCase) => {
5246
5280
  const flags = matchCase ? 'u' : 'iu';
5247
5281
  const regex = new RegExp(query, flags);
@@ -5344,18 +5378,6 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
5344
5378
  return allResults;
5345
5379
  };
5346
5380
 
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
5381
  const getChildHandles = async handle => {
5360
5382
  try {
5361
5383
  return await getChildHandles$1(handle);
@@ -5455,6 +5477,13 @@ const textSearch = async (scheme, root, query, options, assetDir) => {
5455
5477
  return allResults;
5456
5478
  };
5457
5479
 
5480
+ const registerInterceptor = async (id, port) => {
5481
+ await invokeAndTransfer('WebView.registerInterceptor', id, port);
5482
+ };
5483
+ const unregisterInterceptor = async id => {
5484
+ await invoke('WebView.unregisterInterceptor', id);
5485
+ };
5486
+
5458
5487
  const commandMap = {
5459
5488
  'BulkReplacement.applyBulkReplacement': applyBulkReplacement,
5460
5489
  'ColorTheme.getColorThemeCssFromJson': getColorThemeCssFromJson,
@@ -5488,7 +5517,7 @@ const commandMap = {
5488
5517
  'FileSystemFetch.mkdir': mkdir$1,
5489
5518
  'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
5490
5519
  'FileSystemFetch.readFile': readFile$1,
5491
- 'FileSystemFetch.remove': remove$1,
5520
+ 'FileSystemFetch.remove': remove$2,
5492
5521
  'FileSystemFetch.writeFile': writeFile$1,
5493
5522
  'FileSystemMemory.chmod': chmod,
5494
5523
  'FileSystemMemory.getBlob': getBlob,
@@ -5514,13 +5543,16 @@ const commandMap = {
5514
5543
  'IndexedDb.set': set$3,
5515
5544
  'Languages.getLanguages': getLanguages,
5516
5545
  'SaveState.saveState': saveState,
5517
- 'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
5518
- 'SearchFileWithHtml.searchFileWithHtml': searchFile,
5546
+ 'SearchFileWithFetch.searchFileWithFetch': searchFile$2,
5547
+ 'SearchFileWithHtml.searchFileWithHtml': searchFile$1,
5548
+ 'SearchFileWithMemory.searchFileWithMemory': searchFile,
5519
5549
  'TextSearchFetch.textSearch': textSearch$2,
5520
5550
  'TextSearchHtml.textSearch': textSearch$1,
5521
5551
  'TextSearchMemory.textSearch': textSearch,
5522
5552
  'WebView.create3': createWebView3,
5523
5553
  'WebView.createWebViewWorkerRpc': createWebViewWorkerRpc,
5554
+ 'WebView.registerInterceptor': registerInterceptor,
5555
+ 'WebView.unregisterInterceptor': unregisterInterceptor,
5524
5556
  'WebView.createWebViewWorkerRpc2': createWebViewWorkerRpc2,
5525
5557
  'WebView.getRpcInfo': getRpcInfo,
5526
5558
  'WebViews.getWebViews': getWebViews,
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.13.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"