@lvce-editor/extension-host-worker 3.16.0 → 3.17.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$f = {
93
93
  /** @type{any[]} */
94
94
  onDidOpenEditorListeners: [],
95
95
  /** @type{any[]} */
@@ -101,19 +101,19 @@ const state$e = {
101
101
  textDocuments: Object.create(null)
102
102
  };
103
103
  const setDocument = (textDocumentId, textDocument) => {
104
- state$e.textDocuments[textDocumentId] = textDocument;
104
+ state$f.textDocuments[textDocumentId] = textDocument;
105
105
  };
106
106
  const getDidOpenListeners = () => {
107
- return state$e.onDidSaveTextDocumentListeners;
107
+ return state$f.onDidSaveTextDocumentListeners;
108
108
  };
109
109
  const getWillChangeListeners = () => {
110
- return state$e.onWillChangeEditorListeners;
110
+ return state$f.onWillChangeEditorListeners;
111
111
  };
112
112
  const getDidChangeListeners = () => {
113
- return state$e.onDidChangeTextDocumentListeners;
113
+ return state$f.onDidChangeTextDocumentListeners;
114
114
  };
115
115
  const getDocument = textDocumentId => {
116
- return state$e.textDocuments[textDocumentId];
116
+ return state$f.textDocuments[textDocumentId];
117
117
  };
118
118
 
119
119
  const getOffset$1 = (textDocument, position) => {
@@ -675,7 +675,7 @@ const executeOrganizeImports = async uid => {
675
675
  return edits;
676
676
  };
677
677
 
678
- const state$d = {
678
+ const state$e = {
679
679
  commands: Object.create(null)
680
680
  };
681
681
  const getCommandDisplay = command => {
@@ -698,10 +698,10 @@ const registerCommand = command => {
698
698
  if (!command.execute) {
699
699
  throw new Error('command is missing execute function');
700
700
  }
701
- if (command.id in state$d.commands) {
701
+ if (command.id in state$e.commands) {
702
702
  throw new Error(`command cannot be registered multiple times`);
703
703
  }
704
- state$d.commands[command.id] = command;
704
+ state$e.commands[command.id] = command;
705
705
  } catch (error) {
706
706
  const commandDisplayId = getCommandDisplay(command);
707
707
  throw new VError(error, `Failed to register command${commandDisplayId}`);
@@ -709,7 +709,7 @@ const registerCommand = command => {
709
709
  };
710
710
  const executeCommand = async (id, ...args) => {
711
711
  try {
712
- const command = state$d.commands[id];
712
+ const command = state$e.commands[id];
713
713
  if (!command) {
714
714
  throw new Error(`command ${id} not found`);
715
715
  }
@@ -748,40 +748,40 @@ const {
748
748
  }]
749
749
  });
750
750
 
751
- const state$c = {
751
+ const state$d = {
752
752
  configuration: Object.create(null)
753
753
  };
754
754
  const getConfiguration = key => {
755
- return state$c.configuration[key] ?? '';
755
+ return state$d.configuration[key] ?? '';
756
756
  };
757
757
  const setConfigurations = preferences => {
758
- state$c.configuration = preferences;
758
+ state$d.configuration = preferences;
759
759
  };
760
760
 
761
- const state$b = {
761
+ const state$c = {
762
762
  rpc: undefined
763
763
  };
764
764
  const invoke$2 = (method, ...params) => {
765
- const rpc = state$b.rpc;
765
+ const rpc = state$c.rpc;
766
766
  return rpc.invoke(method, ...params);
767
767
  };
768
768
  const send$1 = (method, ...params) => {
769
- const rpc = state$b.rpc;
769
+ const rpc = state$c.rpc;
770
770
  return rpc.send(method, ...params);
771
771
  };
772
772
  const invokeAndTransfer$1 = (method, ...params) => {
773
- const rpc = state$b.rpc;
773
+ const rpc = state$c.rpc;
774
774
  return rpc.invokeAndTransfer(method, ...params);
775
775
  };
776
776
  const setRpc = rpc => {
777
- state$b.rpc = rpc;
777
+ state$c.rpc = rpc;
778
778
  };
779
779
 
780
- const state$a = {
780
+ const state$b = {
781
781
  debugProviderMap: Object.create(null)
782
782
  };
783
783
  const getDebugProvider = id => {
784
- const provider = state$a.debugProviderMap[id];
784
+ const provider = state$b.debugProviderMap[id];
785
785
  if (!provider) {
786
786
  // @ts-ignore
787
787
  throw new VError(`no debug provider "${id}" found`);
@@ -792,7 +792,7 @@ const registerDebugProvider = debugProvider => {
792
792
  if (!debugProvider.id) {
793
793
  throw new Error('Failed to register debug system provider: missing id');
794
794
  }
795
- state$a.debugProviderMap[debugProvider.id] = debugProvider;
795
+ state$b.debugProviderMap[debugProvider.id] = debugProvider;
796
796
  };
797
797
  const start = async (protocol, path) => {
798
798
  try {
@@ -2551,17 +2551,17 @@ const {
2551
2551
  }
2552
2552
  });
2553
2553
 
2554
- const state$9 = {
2554
+ const state$a = {
2555
2555
  providers: Object.create(null)
2556
2556
  };
2557
2557
  const registerSourceControlProvider = provider => {
2558
- state$9.providers[provider.id] = provider;
2558
+ state$a.providers[provider.id] = provider;
2559
2559
  };
2560
2560
  const getFilesFromProvider = provider => {
2561
2561
  return provider.getChangedFiles();
2562
2562
  };
2563
2563
  const getChangedFiles = async providerId => {
2564
- const provider = state$9.providers[providerId];
2564
+ const provider = state$a.providers[providerId];
2565
2565
  if (!provider) {
2566
2566
  throw new Error('no source control provider found');
2567
2567
  }
@@ -2572,7 +2572,7 @@ const getChangedFiles = async providerId => {
2572
2572
  const getFileBefore = async (providerId, uri) => {
2573
2573
  string(providerId);
2574
2574
  string(uri);
2575
- const provider = state$9.providers[providerId];
2575
+ const provider = state$a.providers[providerId];
2576
2576
  if (!provider) {
2577
2577
  throw new Error('no source control provider found');
2578
2578
  }
@@ -2594,7 +2594,7 @@ const getGroupsFromProvider = async (provider, cwd) => {
2594
2594
  throw new Error('source control provider is missing required function getGroups');
2595
2595
  };
2596
2596
  const getGroups = async (providerId, cwd) => {
2597
- const provider = state$9.providers[providerId];
2597
+ const provider = state$a.providers[providerId];
2598
2598
  if (!provider) {
2599
2599
  throw new Error('no source control provider found');
2600
2600
  }
@@ -2602,14 +2602,14 @@ const getGroups = async (providerId, cwd) => {
2602
2602
  return groups;
2603
2603
  };
2604
2604
  const acceptInput = async (providerId, value) => {
2605
- const provider = state$9.providers[providerId];
2605
+ const provider = state$a.providers[providerId];
2606
2606
  if (!provider) {
2607
2607
  throw new Error('no source control provider found');
2608
2608
  }
2609
2609
  await provider.acceptInput(value);
2610
2610
  };
2611
2611
  const add = async path => {
2612
- const provider = Object.values(state$9.providers)[0];
2612
+ const provider = Object.values(state$a.providers)[0];
2613
2613
  if (!provider) {
2614
2614
  return;
2615
2615
  }
@@ -2617,7 +2617,7 @@ const add = async path => {
2617
2617
  await provider.add(path);
2618
2618
  };
2619
2619
  const discard = async path => {
2620
- const provider = Object.values(state$9.providers)[0];
2620
+ const provider = Object.values(state$a.providers)[0];
2621
2621
  if (!provider) {
2622
2622
  return;
2623
2623
  }
@@ -2627,7 +2627,7 @@ const discard = async path => {
2627
2627
  const getEnabledProviderIds = async (scheme, root) => {
2628
2628
  string(scheme);
2629
2629
  string(root);
2630
- const providers = Object.values(state$9.providers);
2630
+ const providers = Object.values(state$a.providers);
2631
2631
  const enabledIds = [];
2632
2632
  for (const provider of providers) {
2633
2633
  // @ts-ignore
@@ -2656,7 +2656,7 @@ const {
2656
2656
  }
2657
2657
  });
2658
2658
 
2659
- const state$8 = {
2659
+ const state$9 = {
2660
2660
  textSearchProviders: Object.create(null)
2661
2661
  };
2662
2662
  const registerTextSearchProvider = textSearchProvider => {
@@ -2667,14 +2667,14 @@ const registerTextSearchProvider = textSearchProvider => {
2667
2667
  if (!textSearchProvider.scheme) {
2668
2668
  throw new Error('textSearchProvider is missing scheme');
2669
2669
  }
2670
- state$8.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
2670
+ state$9.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
2671
2671
  } catch (error) {
2672
2672
  throw new VError(error, 'Failed to register text search provider');
2673
2673
  }
2674
2674
  };
2675
2675
  const executeTextSearchProvider = async (scheme, query) => {
2676
2676
  try {
2677
- const textSearchProvider = state$8.textSearchProviders[scheme];
2677
+ const textSearchProvider = state$9.textSearchProviders[scheme];
2678
2678
  if (!textSearchProvider) {
2679
2679
  throw new Error(`No text search provider for ${scheme} found`);
2680
2680
  }
@@ -2864,14 +2864,14 @@ const createWorker = async ({
2864
2864
  return rpc;
2865
2865
  };
2866
2866
 
2867
- const state$7 = {
2867
+ const state$8 = {
2868
2868
  workspacePath: ''
2869
2869
  };
2870
2870
  const setWorkspacePath = path => {
2871
- state$7.workspacePath = path;
2871
+ state$8.workspacePath = path;
2872
2872
  };
2873
2873
  const getWorkspaceFolder = path => {
2874
- return state$7.workspacePath;
2874
+ return state$8.workspacePath;
2875
2875
  };
2876
2876
 
2877
2877
  class FormattingError extends Error {
@@ -3024,7 +3024,7 @@ const handleUnhandledRejection = event => {
3024
3024
  console.error(output);
3025
3025
  };
3026
3026
 
3027
- const state$6 = {
3027
+ const state$7 = {
3028
3028
  /**
3029
3029
  * @type {any[]}
3030
3030
  */
@@ -3032,10 +3032,10 @@ const state$6 = {
3032
3032
  };
3033
3033
  const addError = error => {
3034
3034
  // @ts-ignore
3035
- state$6.errors.push(error);
3035
+ state$7.errors.push(error);
3036
3036
  };
3037
3037
  const hasRecentErrors = () => {
3038
- return state$6.errors.length > 0;
3038
+ return state$7.errors.length > 0;
3039
3039
  };
3040
3040
  const getRecentError = () => {
3041
3041
  };
@@ -3450,13 +3450,13 @@ const storeId = 'lvce-keyvalue';
3450
3450
 
3451
3451
  // TODO high memory usage in idb because of transactionDoneMap
3452
3452
 
3453
- const state$5 = {
3453
+ const state$6 = {
3454
3454
  databases: Object.create(null),
3455
3455
  dbVersion: 2,
3456
3456
  cachedDb: undefined
3457
3457
  };
3458
3458
  const getDb$1 = async () => {
3459
- const db = await openDB(storeId, state$5.dbVersion, {
3459
+ const db = await openDB(storeId, state$6.dbVersion, {
3460
3460
  async upgrade(db, oldVersion) {
3461
3461
  if (!db.objectStoreNames.contains(storeId)) {
3462
3462
  await db.createObjectStore(storeId, {
@@ -3468,8 +3468,8 @@ const getDb$1 = async () => {
3468
3468
  return db;
3469
3469
  };
3470
3470
  const getDbMemoized$1 = async () => {
3471
- state$5.cachedDb ||= await getDb$1();
3472
- return state$5.cachedDb;
3471
+ state$6.cachedDb ||= await getDb$1();
3472
+ return state$6.cachedDb;
3473
3473
  };
3474
3474
 
3475
3475
  // TODO high memory usage in idb because of transactionDoneMap
@@ -3645,7 +3645,7 @@ const setThemeColor = async themeColor => {
3645
3645
  // TODO by default color theme should come from local storage, session storage, cache storage, indexeddb or blob url -> fast initial load
3646
3646
  // actual color theme can be computed after workbench has loaded (most times will be the same and doesn't need to be computed)
3647
3647
 
3648
- const state$4 = {
3648
+ const state$5 = {
3649
3649
  watchedTheme: ''
3650
3650
  };
3651
3651
  const FALLBACK_COLOR_THEME_ID = 'slime';
@@ -3656,7 +3656,7 @@ const FALLBACK_COLOR_THEME_ID = 'slime';
3656
3656
  const applyColorTheme = async colorThemeId => {
3657
3657
  try {
3658
3658
  string(colorThemeId);
3659
- state$4.colorTheme = colorThemeId;
3659
+ state$5.colorTheme = colorThemeId;
3660
3660
  const colorThemeCss = await getColorThemeCss(colorThemeId);
3661
3661
  await addCssStyleSheet('ContributedColorTheme', colorThemeCss);
3662
3662
  if (platform === Web) {
@@ -3671,10 +3671,10 @@ const applyColorTheme = async colorThemeId => {
3671
3671
  }
3672
3672
  };
3673
3673
  const watch = async id => {
3674
- if (state$4.watchedTheme === id) {
3674
+ if (state$5.watchedTheme === id) {
3675
3675
  return;
3676
3676
  }
3677
- state$4.watchedTheme = id;
3677
+ state$5.watchedTheme = id;
3678
3678
  await invoke$2('ExtensionHost.watchColorTheme', id);
3679
3679
  };
3680
3680
  const getPreferredColorTheme = () => {
@@ -3709,11 +3709,11 @@ const getConfiguredIframeWorkerUrl = async () => {
3709
3709
  return configuredWorkerUrl;
3710
3710
  };
3711
3711
 
3712
- const state$3 = {
3712
+ const state$4 = {
3713
3713
  id: 0
3714
3714
  };
3715
3715
  const create$1 = () => {
3716
- return ++state$3.id;
3716
+ return ++state$4.id;
3717
3717
  };
3718
3718
 
3719
3719
  const commandMap$1 = {
@@ -4321,7 +4321,7 @@ const mockRpc = () => {
4321
4321
  };
4322
4322
 
4323
4323
  const getStatusBarItems = async () => {
4324
- const providers = Object.values(state$9.providers);
4324
+ const providers = Object.values(state$a.providers);
4325
4325
  const statusBarItems = [];
4326
4326
  for (const provider of providers) {
4327
4327
  // @ts-ignore
@@ -4490,11 +4490,11 @@ const getContentType = uri => {
4490
4490
 
4491
4491
  // TODO move this to an extension?
4492
4492
 
4493
- const state$2 = {
4493
+ const state$3 = {
4494
4494
  files: Object.create(null)
4495
4495
  };
4496
4496
  const getDirent = uri => {
4497
- return state$2.files[uri];
4497
+ return state$3.files[uri];
4498
4498
  };
4499
4499
  const readFile = uri => {
4500
4500
  const dirent = getDirent(uri);
@@ -4511,7 +4511,7 @@ const ensureParentDir = uri => {
4511
4511
  let endIndex = uri.indexOf(Slash);
4512
4512
  while (endIndex >= 0) {
4513
4513
  const part = uri.slice(startIndex, endIndex + 1);
4514
- state$2.files[part] = {
4514
+ state$3.files[part] = {
4515
4515
  type: Directory$1,
4516
4516
  content: ''
4517
4517
  };
@@ -4526,7 +4526,7 @@ const writeFile = (uri, content) => {
4526
4526
  dirent.content = content;
4527
4527
  } else {
4528
4528
  ensureParentDir(uri);
4529
- state$2.files[uri] = {
4529
+ state$3.files[uri] = {
4530
4530
  type: File$1,
4531
4531
  content
4532
4532
  };
@@ -4537,20 +4537,20 @@ const mkdir = uri => {
4537
4537
  uri += Slash;
4538
4538
  }
4539
4539
  ensureParentDir(uri);
4540
- state$2.files[uri] = {
4540
+ state$3.files[uri] = {
4541
4541
  type: Directory$1,
4542
4542
  content: ''
4543
4543
  };
4544
4544
  };
4545
4545
  const remove = uri => {
4546
4546
  const toDelete = [];
4547
- for (const key of Object.keys(state$2.files)) {
4547
+ for (const key of Object.keys(state$3.files)) {
4548
4548
  if (key.startsWith(uri)) {
4549
4549
  toDelete.push(key);
4550
4550
  }
4551
4551
  }
4552
4552
  for (const key of toDelete) {
4553
- delete state$2.files[key];
4553
+ delete state$3.files[key];
4554
4554
  }
4555
4555
  };
4556
4556
  const readDirWithFileTypes = uri => {
@@ -4558,7 +4558,7 @@ const readDirWithFileTypes = uri => {
4558
4558
  uri += Slash;
4559
4559
  }
4560
4560
  const dirents = [];
4561
- for (const [key, value] of Object.entries(state$2.files)) {
4561
+ for (const [key, value] of Object.entries(state$3.files)) {
4562
4562
  if (key.startsWith(uri)) {
4563
4563
  // @ts-ignore
4564
4564
  switch (value.type) {
@@ -4602,31 +4602,10 @@ const chmod = () => {
4602
4602
  throw new Error('[memfs] chmod not implemented');
4603
4603
  };
4604
4604
  const getFiles = () => {
4605
- return state$2.files;
4605
+ return state$3.files;
4606
4606
  };
4607
4607
 
4608
- const getRpcInfo = rpcId => {
4609
- const info = get$7(rpcId);
4610
- if (!info) {
4611
- throw new Error(`Rpc not found ${rpcId}`);
4612
- }
4613
- return info;
4614
- };
4615
-
4616
- const handleBeforeUnload = () => {
4617
- // TODO save all webviews in localstorage
4618
- // cannot use indexeddb during unload
4619
- console.log('before unload');
4620
- };
4621
-
4622
- const handleMessagePort = async port => {
4623
- await MessagePortRpcClient.create({
4624
- messagePort: port,
4625
- commandMap: {}
4626
- });
4627
- };
4628
-
4629
- const state$1 = {
4608
+ const state$2 = {
4630
4609
  webExtensions: []
4631
4610
  };
4632
4611
 
@@ -4660,7 +4639,7 @@ const getStaticWebExtensions = () => {
4660
4639
  };
4661
4640
  const getWebExtensionsWeb = async () => {
4662
4641
  const staticWebExtensions = await getStaticWebExtensions();
4663
- return [...staticWebExtensions, ...state$1.webExtensions];
4642
+ return [...staticWebExtensions, ...state$2.webExtensions];
4664
4643
  };
4665
4644
  const isWebExtension = extension => {
4666
4645
  return extension && typeof extension.browser === 'string';
@@ -4669,7 +4648,7 @@ const getWebExtensionsDefault = async () => {
4669
4648
  const staticWebExtensions = await getStaticWebExtensions();
4670
4649
  const sharedProcessExtensions = await getSharedProcessExtensions$1();
4671
4650
  const sharedProcessWebExtensions = sharedProcessExtensions.filter(isWebExtension);
4672
- return [...staticWebExtensions, sharedProcessWebExtensions, ...state$1.webExtensions];
4651
+ return [...staticWebExtensions, sharedProcessWebExtensions, ...state$2.webExtensions];
4673
4652
  };
4674
4653
  const getWebExtensions = async () => {
4675
4654
  try {
@@ -4680,7 +4659,7 @@ const getWebExtensions = async () => {
4680
4659
  return await getWebExtensionsDefault();
4681
4660
  }
4682
4661
  } catch {
4683
- return state$1.webExtensions;
4662
+ return state$2.webExtensions;
4684
4663
  }
4685
4664
  };
4686
4665
 
@@ -4733,7 +4712,7 @@ const getIconThemeJson = async iconThemeId => {
4733
4712
  extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
4734
4713
  };
4735
4714
  }
4736
- for (const webExtension of state$1.webExtensions) {
4715
+ for (const webExtension of state$2.webExtensions) {
4737
4716
  if (webExtension.iconThemes) {
4738
4717
  for (const iconTheme of webExtension.iconThemes) {
4739
4718
  // TODO handle error when icon theme path is not of type string
@@ -4759,11 +4738,49 @@ const getIconThemeJson = async iconThemeId => {
4759
4738
  };
4760
4739
  };
4761
4740
 
4741
+ const getRpcInfo = rpcId => {
4742
+ const info = get$7(rpcId);
4743
+ if (!info) {
4744
+ throw new Error(`Rpc not found ${rpcId}`);
4745
+ }
4746
+ return info;
4747
+ };
4748
+
4749
+ const handleBeforeUnload = () => {
4750
+ // TODO save all webviews in localstorage
4751
+ // cannot use indexeddb during unload
4752
+ console.log('before unload');
4753
+ };
4754
+
4755
+ const handleMessagePort = async port => {
4756
+ await MessagePortRpcClient.create({
4757
+ messagePort: port,
4758
+ commandMap: {}
4759
+ });
4760
+ };
4761
+
4762
4762
  const handleIconThemeChange = async () => {
4763
4763
  await invoke$2('IconTheme.handleIconThemeChange');
4764
4764
  };
4765
4765
 
4766
+ const initialIconTheme = undefined;
4767
+
4768
+ const state$1 = {
4769
+ seenFiles: [],
4770
+ seenFolders: [],
4771
+ hasWarned: [],
4772
+ /**
4773
+ * @type{any}
4774
+ */
4775
+ iconTheme: initialIconTheme,
4776
+ extensionPath: ''
4777
+ };
4766
4778
  const setTheme = iconTheme => {
4779
+ state$1.iconTheme = iconTheme.json;
4780
+ state$1.extensionPath = iconTheme.extensionPath;
4781
+ };
4782
+ const getState = () => {
4783
+ return state$1;
4767
4784
  };
4768
4785
 
4769
4786
  const setIconTheme = async iconThemeId => {
@@ -5256,6 +5273,8 @@ const commandMap = {
5256
5273
  'FileSystemMemory.readFile': readFile,
5257
5274
  'FileSystemMemory.remove': remove,
5258
5275
  'FileSystemMemory.writeFile': writeFile,
5276
+ 'IconTheme.getState': getState,
5277
+ 'IconTheme.getJson': getIconThemeJson,
5259
5278
  'IconTheme.hydrate': hydrate,
5260
5279
  'IconTheme.setIconTheme': setIconTheme,
5261
5280
  'IndexedDb.addHandle': addHandle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "main": "dist/extensionHostWorkerMain.js",
6
6
  "type": "module",