@lvce-editor/extension-host-worker 5.14.0 → 5.15.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.
@@ -324,7 +324,7 @@ const syncIncremental = (textDocumentId, changes) => {
324
324
  textDocument.text = before + syntheticChange.inserted + after;
325
325
  runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
326
326
  };
327
- const get$b = textDocumentId => {
327
+ const get$c = textDocumentId => {
328
328
  const textDocument = getDocument(textDocumentId);
329
329
  return textDocument;
330
330
  };
@@ -543,7 +543,7 @@ const registerMethod = ({
543
543
  }) => {
544
544
  context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
545
545
  try {
546
- const textDocument = get$b(textDocumentId);
546
+ const textDocument = get$c(textDocumentId);
547
547
  if (!textDocument) {
548
548
  throw new Error(`textDocument with id ${textDocumentId} not found`);
549
549
  }
@@ -676,7 +676,7 @@ const executeOrganizeImports = async uid => {
676
676
  if (!organizeImportsAction) {
677
677
  return [];
678
678
  }
679
- const textDocument = get$b(uid);
679
+ const textDocument = get$c(uid);
680
680
  const edits = await organizeImportsAction.execute(textDocument);
681
681
  return edits;
682
682
  };
@@ -768,7 +768,7 @@ const rpcs$2 = Object.create(null);
768
768
  const set$g = (id, rpc) => {
769
769
  rpcs$2[id] = rpc;
770
770
  };
771
- const get$a = id => {
771
+ const get$b = id => {
772
772
  return rpcs$2[id];
773
773
  };
774
774
 
@@ -778,13 +778,13 @@ const create$a = rpcId => {
778
778
  return {
779
779
  // @ts-ignore
780
780
  invoke(method, ...params) {
781
- const rpc = get$a(rpcId);
781
+ const rpc = get$b(rpcId);
782
782
  // @ts-ignore
783
783
  return rpc.invoke(method, ...params);
784
784
  },
785
785
  // @ts-ignore
786
786
  invokeAndTransfer(method, ...params) {
787
- const rpc = get$a(rpcId);
787
+ const rpc = get$b(rpcId);
788
788
  // @ts-ignore
789
789
  return rpc.invokeAndTransfer(method, ...params);
790
790
  },
@@ -792,7 +792,7 @@ const create$a = rpcId => {
792
792
  set$g(rpcId, rpc);
793
793
  },
794
794
  async dispose() {
795
- const rpc = get$a(rpcId);
795
+ const rpc = get$b(rpcId);
796
796
  await rpc.dispose();
797
797
  }
798
798
  };
@@ -1027,11 +1027,11 @@ const {
1027
1027
  const RendererWorker = 1;
1028
1028
 
1029
1029
  const invoke$2 = (method, ...params) => {
1030
- const rpc = get$a(RendererWorker);
1030
+ const rpc = get$b(RendererWorker);
1031
1031
  return rpc.invoke(method, ...params);
1032
1032
  };
1033
1033
  const invokeAndTransfer$2 = (method, ...params) => {
1034
- const rpc = get$a(RendererWorker);
1034
+ const rpc = get$b(RendererWorker);
1035
1035
  return rpc.invokeAndTransfer(method, ...params);
1036
1036
  };
1037
1037
 
@@ -1048,7 +1048,7 @@ const exec = async (command, args, options) => {
1048
1048
  };
1049
1049
 
1050
1050
  const fileSystemProviderMap = Object.create(null);
1051
- const get$9 = protocol => {
1051
+ const get$a = protocol => {
1052
1052
  const provider = fileSystemProviderMap[protocol];
1053
1053
  if (!provider) {
1054
1054
  // @ts-ignore
@@ -1056,7 +1056,7 @@ const get$9 = protocol => {
1056
1056
  }
1057
1057
  return provider;
1058
1058
  };
1059
- const set$8 = (id, provider) => {
1059
+ const set$9 = (id, provider) => {
1060
1060
  if (!id) {
1061
1061
  throw new Error('Failed to register file system provider: missing id');
1062
1062
  }
@@ -1067,11 +1067,11 @@ const registerFileSystemProvider = fileSystemProvider => {
1067
1067
  if (!fileSystemProvider.id) {
1068
1068
  throw new Error('Failed to register file system provider: missing id');
1069
1069
  }
1070
- set$8(fileSystemProvider.id, fileSystemProvider);
1070
+ set$9(fileSystemProvider.id, fileSystemProvider);
1071
1071
  };
1072
1072
  const readDirWithFileTypes$2 = async (protocol, path) => {
1073
1073
  try {
1074
- const provider = get$9(protocol);
1074
+ const provider = get$a(protocol);
1075
1075
  return await provider.readDirWithFileTypes(path);
1076
1076
  } catch (error) {
1077
1077
  throw new VError(error, 'Failed to execute file system provider');
@@ -1079,7 +1079,7 @@ const readDirWithFileTypes$2 = async (protocol, path) => {
1079
1079
  };
1080
1080
  const readFile$2 = async (protocol, path) => {
1081
1081
  try {
1082
- const provider = get$9(protocol);
1082
+ const provider = get$a(protocol);
1083
1083
  return await provider.readFile(path);
1084
1084
  } catch (error) {
1085
1085
  throw new VError(error, 'Failed to execute file system provider');
@@ -1107,7 +1107,7 @@ const readDirWithFileTypesExternal = async path => {
1107
1107
  };
1108
1108
  const rename$1 = async (protocol, oldUri, newUri) => {
1109
1109
  try {
1110
- const provider = get$9(protocol);
1110
+ const provider = get$a(protocol);
1111
1111
  return await provider.rename(oldUri, newUri);
1112
1112
  } catch (error) {
1113
1113
  throw new VError(error, 'Failed to execute file system provider');
@@ -1115,7 +1115,7 @@ const rename$1 = async (protocol, oldUri, newUri) => {
1115
1115
  };
1116
1116
  const writeFile$2 = async (protocol, uri, content) => {
1117
1117
  try {
1118
- const provider = get$9(protocol);
1118
+ const provider = get$a(protocol);
1119
1119
  return await provider.writeFile(uri, content);
1120
1120
  } catch (error) {
1121
1121
  throw new VError(error, 'Failed to execute file system provider');
@@ -1123,7 +1123,7 @@ const writeFile$2 = async (protocol, uri, content) => {
1123
1123
  };
1124
1124
  const getPathSeparator = protocol => {
1125
1125
  try {
1126
- const provider = get$9(protocol);
1126
+ const provider = get$a(protocol);
1127
1127
  return provider.pathSeparator;
1128
1128
  } catch (error) {
1129
1129
  throw new VError(error, 'Failed to execute file system provider');
@@ -1739,10 +1739,10 @@ const create$4$2 = (method, params) => {
1739
1739
  };
1740
1740
  };
1741
1741
  const callbacks = Object.create(null);
1742
- const set$7 = (id, fn) => {
1742
+ const set$8 = (id, fn) => {
1743
1743
  callbacks[id] = fn;
1744
1744
  };
1745
- const get$8 = id => {
1745
+ const get$9 = id => {
1746
1746
  return callbacks[id];
1747
1747
  };
1748
1748
  const remove$3 = id => {
@@ -1758,7 +1758,7 @@ const registerPromise = () => {
1758
1758
  resolve,
1759
1759
  promise
1760
1760
  } = Promise.withResolvers();
1761
- set$7(id, resolve);
1761
+ set$8(id, resolve);
1762
1762
  return {
1763
1763
  id,
1764
1764
  promise
@@ -1922,7 +1922,7 @@ const warn$1 = (...args) => {
1922
1922
  console.warn(...args);
1923
1923
  };
1924
1924
  const resolve = (id, response) => {
1925
- const fn = get$8(id);
1925
+ const fn = get$9(id);
1926
1926
  if (!fn) {
1927
1927
  console.log(response);
1928
1928
  warn$1(`callback ${id} may already be disposed`);
@@ -2570,7 +2570,7 @@ const getExtensionHostSubWorkerUrl = () => {
2570
2570
  };
2571
2571
  const extensionHostSubWorkerUrl = getExtensionHostSubWorkerUrl();
2572
2572
 
2573
- const set$6 = async (url, contentSecurityPolicy) => {
2573
+ const set$7 = async (url, contentSecurityPolicy) => {
2574
2574
  const pathName = new URL(url).pathname;
2575
2575
  await invoke$2('ExtensionHostWorkerContentSecurityPolicy.set', pathName, contentSecurityPolicy);
2576
2576
  };
@@ -2590,7 +2590,7 @@ const createLegacyRpc = async ({
2590
2590
  string(name);
2591
2591
  object(commandMap);
2592
2592
  if (contentSecurityPolicy) {
2593
- await set$6(url, contentSecurityPolicy);
2593
+ await set$7(url, contentSecurityPolicy);
2594
2594
  }
2595
2595
  const rpc = await create$2({
2596
2596
  method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
@@ -2611,7 +2611,7 @@ const rpcs$1 = Object.create(null);
2611
2611
  const add$1 = (id, rpc) => {
2612
2612
  rpcs$1[id] = rpc;
2613
2613
  };
2614
- const get$7 = id => {
2614
+ const get$8 = id => {
2615
2615
  return rpcs$1[id];
2616
2616
  };
2617
2617
 
@@ -2620,15 +2620,15 @@ const rpcs = Object.create(null);
2620
2620
  const register = (id, execute) => {
2621
2621
  registry[id] = execute;
2622
2622
  };
2623
- const get$6 = id => {
2623
+ const get$7 = id => {
2624
2624
  return rpcs[id];
2625
2625
  };
2626
- const set$5 = (id, rpc) => {
2626
+ const set$6 = (id, rpc) => {
2627
2627
  rpcs[id] = rpc;
2628
2628
  };
2629
2629
 
2630
2630
  const createRpcWithId$1 = async (id, commandMap, execute) => {
2631
- const info = get$7(id);
2631
+ const info = get$8(id);
2632
2632
  if (!info) {
2633
2633
  throw new Error(`rpc with id ${id} not found`);
2634
2634
  }
@@ -2644,16 +2644,16 @@ const createRpcWithId$1 = async (id, commandMap, execute) => {
2644
2644
  rpc.ipc.execute = execute;
2645
2645
  }
2646
2646
  await rpc.invoke('LoadFile.loadFile', info.url);
2647
- set$5(id, rpc);
2647
+ set$6(id, rpc);
2648
2648
  return rpc;
2649
2649
  };
2650
2650
 
2651
2651
  const getOrCreateRpc = async (id, commandMap, execute) => {
2652
- const rpc = get$6(id);
2652
+ const rpc = get$7(id);
2653
2653
  if (!rpc) {
2654
- set$5(id, createRpcWithId$1(id, commandMap, execute));
2654
+ set$6(id, createRpcWithId$1(id, commandMap, execute));
2655
2655
  }
2656
- return get$6(id);
2656
+ return get$7(id);
2657
2657
  };
2658
2658
  const createRpcWithId = ({
2659
2659
  id,
@@ -3253,13 +3253,13 @@ const state$5 = {
3253
3253
 
3254
3254
  const cache = Object.create(null);
3255
3255
  const id = 1;
3256
- const get$5 = () => {
3256
+ const get$6 = () => {
3257
3257
  return cache[id];
3258
3258
  };
3259
3259
  const has = () => {
3260
3260
  return id in cache;
3261
3261
  };
3262
- const set$4 = value => {
3262
+ const set$5 = value => {
3263
3263
  cache[id] = value;
3264
3264
  };
3265
3265
  const clear = () => {
@@ -3724,7 +3724,7 @@ const getDbMemoized$1 = async () => {
3724
3724
 
3725
3725
  // TODO high memory usage in idb because of transactionDoneMap
3726
3726
 
3727
- const set$3 = async (key, value) => {
3727
+ const set$4 = async (key, value) => {
3728
3728
  try {
3729
3729
  const db = await getDbMemoized$1();
3730
3730
  await db.put(storeId, value, key);
@@ -3732,7 +3732,7 @@ const set$3 = async (key, value) => {
3732
3732
  throw new VError(error, 'Failed to save value to indexed db');
3733
3733
  }
3734
3734
  };
3735
- const get$4 = async key => {
3735
+ const get$5 = async key => {
3736
3736
  try {
3737
3737
  const db = await getDbMemoized$1();
3738
3738
  const value = await db.get(storeId, key);
@@ -3745,19 +3745,19 @@ const get$4 = async key => {
3745
3745
  const getCacheKey$1 = colorThemeId => {
3746
3746
  return 'color-theme-' + colorThemeId;
3747
3747
  };
3748
- const get$3 = colorThemeId => {
3748
+ const get$4 = colorThemeId => {
3749
3749
  const cacheKey = getCacheKey$1(colorThemeId);
3750
- return get$4(cacheKey);
3750
+ return get$5(cacheKey);
3751
3751
  };
3752
- const set$2 = (colorThemeId, data) => {
3752
+ const set$3 = (colorThemeId, data) => {
3753
3753
  const cacheKey = getCacheKey$1(colorThemeId);
3754
- return set$3(cacheKey, data);
3754
+ return set$4(cacheKey, data);
3755
3755
  };
3756
3756
 
3757
3757
  const GetColorThemeCssCachedIndexedDb = {
3758
3758
  __proto__: null,
3759
- get: get$3,
3760
- set: set$2
3759
+ get: get$4,
3760
+ set: set$3
3761
3761
  };
3762
3762
 
3763
3763
  const getText$1 = key => {
@@ -3770,35 +3770,35 @@ const setText = (key, value) => {
3770
3770
  const getCacheKey = colorThemeId => {
3771
3771
  return 'lvce-color-theme-' + colorThemeId;
3772
3772
  };
3773
- const get$2 = colorThemeId => {
3773
+ const get$3 = colorThemeId => {
3774
3774
  const cacheKey = getCacheKey(colorThemeId);
3775
3775
  return getText$1(cacheKey);
3776
3776
  };
3777
- const set$1 = (colorThemeId, data) => {
3777
+ const set$2 = (colorThemeId, data) => {
3778
3778
  const cacheKey = getCacheKey(colorThemeId);
3779
3779
  return setText(cacheKey, data);
3780
3780
  };
3781
3781
 
3782
3782
  const GetColorThemeCssCachedLocalStorage = {
3783
3783
  __proto__: null,
3784
- get: get$2,
3785
- set: set$1
3784
+ get: get$3,
3785
+ set: set$2
3786
3786
  };
3787
3787
 
3788
- const get$1 = colorThemeId => {
3788
+ const get$2 = colorThemeId => {
3789
3789
  return '';
3790
3790
  };
3791
- const set = (colorThemeId, data) => {
3791
+ const set$1 = (colorThemeId, data) => {
3792
3792
  // noop
3793
3793
  };
3794
3794
 
3795
3795
  const GetColorThemeCssCachedNoop = {
3796
3796
  __proto__: null,
3797
- get: get$1,
3798
- set
3797
+ get: get$2,
3798
+ set: set$1
3799
3799
  };
3800
3800
 
3801
- const get = key => {
3801
+ const get$1 = key => {
3802
3802
  return invoke$2('Preferences.get', key);
3803
3803
  };
3804
3804
 
@@ -3813,7 +3813,7 @@ const getCacheFn = config => {
3813
3813
  }
3814
3814
  };
3815
3815
  const getColorThemeCssCached = async (colorThemeId, getData) => {
3816
- const config = await get('colorTheme.cache');
3816
+ const config = await get$1('colorTheme.cache');
3817
3817
  const module = await getCacheFn(config);
3818
3818
  const cachedData = await module.get(colorThemeId);
3819
3819
  if (cachedData) {
@@ -3905,9 +3905,9 @@ const getExtensions$1 = async () => {
3905
3905
  // TODO getExtensions is still called 6 times on startup instead of 1
3906
3906
  const getExtensions = () => {
3907
3907
  if (!has()) {
3908
- set$4(getExtensions$1());
3908
+ set$5(getExtensions$1());
3909
3909
  }
3910
- return get$5();
3910
+ return get$6();
3911
3911
  };
3912
3912
 
3913
3913
  const getColorThemeJson$2 = async colorThemeId => {
@@ -3976,7 +3976,7 @@ const applyColorTheme = async colorThemeId => {
3976
3976
  const themeColor = getMetaThemeColor(colorThemeId) || '';
3977
3977
  await setThemeColor(themeColor);
3978
3978
  }
3979
- if (platform !== Web && (await get('development.watchColorTheme'))) {
3979
+ if (platform !== Web && (await get$1('development.watchColorTheme'))) {
3980
3980
  watch(colorThemeId);
3981
3981
  }
3982
3982
  } catch (error) {
@@ -3991,7 +3991,7 @@ const watch = async id => {
3991
3991
  await invoke$2('ExtensionHost.watchColorTheme', id);
3992
3992
  };
3993
3993
  const getPreferredColorTheme = () => {
3994
- const preferredColorTheme = get('workbench.colorTheme');
3994
+ const preferredColorTheme = get$1('workbench.colorTheme');
3995
3995
  return preferredColorTheme;
3996
3996
  };
3997
3997
 
@@ -4014,7 +4014,7 @@ const hydrate$1 = async () => {
4014
4014
  const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
4015
4015
 
4016
4016
  const getConfiguredIframeWorkerUrl = async () => {
4017
- let configuredWorkerUrl = (await get('develop.iframeWorkerPath')) || '';
4017
+ let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
4018
4018
  if (configuredWorkerUrl) {
4019
4019
  configuredWorkerUrl = '/remote' + configuredWorkerUrl;
4020
4020
  }
@@ -4594,6 +4594,26 @@ const importScript = async url => {
4594
4594
  }
4595
4595
  };
4596
4596
 
4597
+ const states = Object.create(null);
4598
+ const set = status => {
4599
+ states[status.id] = status;
4600
+ };
4601
+ const get = extensionId => {
4602
+ return states[extensionId];
4603
+ };
4604
+ const update = (id, update) => {
4605
+ states[id] = {
4606
+ ...states[id],
4607
+ ...update
4608
+ };
4609
+ };
4610
+
4611
+ const None = 0;
4612
+ const Importing = 1;
4613
+ const Activating = 2;
4614
+ const Activated = 3;
4615
+ const Error$1 = 4;
4616
+
4597
4617
  const activationTimeout = 10_000;
4598
4618
  const rejectAfterTimeout = async (timeout, token) => {
4599
4619
  await sleep(timeout);
@@ -4602,16 +4622,36 @@ const rejectAfterTimeout = async (timeout, token) => {
4602
4622
  }
4603
4623
  throw new Error(`Activation timeout of ${timeout}ms exceeded`);
4604
4624
  };
4605
- const activate = async (extension, absolutePath) => {
4625
+
4626
+ // TODO separate importing extension and activating extension for smaller functions
4627
+ // and better error handling
4628
+ const activate = async (extension, absolutePath, activationEvent) => {
4629
+ const extensionId = extension.id;
4606
4630
  try {
4607
4631
  string(extension.path);
4608
4632
  string(extension.browser);
4609
4633
  string(absolutePath);
4634
+ set({
4635
+ activationEvent: activationEvent,
4636
+ id: extensionId,
4637
+ activationTime: 0,
4638
+ status: Importing
4639
+ });
4640
+ const startTime = performance.now();
4610
4641
  const module = await importScript(absolutePath);
4611
4642
  handleRpcInfos(extension, platform);
4643
+ update(extensionId, {
4644
+ status: Activating
4645
+ });
4612
4646
  const token = create();
4613
4647
  try {
4614
4648
  await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
4649
+ const endTime = performance.now();
4650
+ const time = endTime - startTime;
4651
+ update(extensionId, {
4652
+ status: Activated,
4653
+ activationTime: time
4654
+ });
4615
4655
  } catch (error) {
4616
4656
  if (isImportError(error)) {
4617
4657
  const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
@@ -4622,6 +4662,9 @@ const activate = async (extension, absolutePath) => {
4622
4662
  cancel(token);
4623
4663
  }
4624
4664
  } catch (error) {
4665
+ update(extensionId, {
4666
+ status: Error$1 // TODO maybe store error also in runtime status state
4667
+ });
4625
4668
  const id = getExtensionId(extension);
4626
4669
  throw new VError(error, `Failed to activate extension ${id}`);
4627
4670
  }
@@ -5092,20 +5135,21 @@ const getIconThemeJson = async iconThemeId => {
5092
5135
  };
5093
5136
 
5094
5137
  const getRpcInfo = rpcId => {
5095
- const info = get$7(rpcId);
5138
+ const info = get$8(rpcId);
5096
5139
  if (!info) {
5097
5140
  throw new Error(`Rpc not found ${rpcId}`);
5098
5141
  }
5099
5142
  return info;
5100
5143
  };
5101
5144
 
5145
+ const emptyStatus = {
5146
+ status: None,
5147
+ id: '',
5148
+ activationEvent: '',
5149
+ activationTime: 0
5150
+ };
5102
5151
  const getRuntimeStatus = extensionId => {
5103
- return {
5104
- status: 'not-running',
5105
- id: extensionId,
5106
- activationEvent: '',
5107
- activationTime: 0
5108
- };
5152
+ return get(extensionId) || emptyStatus;
5109
5153
  };
5110
5154
 
5111
5155
  const getWebViewInfo2 = providerId => {
@@ -5210,7 +5254,7 @@ const setIconTheme = async iconThemeId => {
5210
5254
  }
5211
5255
  };
5212
5256
  const hydrate = async () => {
5213
- const iconThemeId = (await get('icon-theme')) || 'vscode-icons';
5257
+ const iconThemeId = (await get$1('icon-theme')) || 'vscode-icons';
5214
5258
  await setIconTheme(iconThemeId);
5215
5259
  };
5216
5260
 
@@ -5787,12 +5831,12 @@ const commandMap = {
5787
5831
  'IconTheme.hydrate': hydrate,
5788
5832
  'IconTheme.setIconTheme': setIconTheme,
5789
5833
  'IndexedDb.addHandle': addHandle,
5790
- 'IndexedDb.get': get$4,
5834
+ 'IndexedDb.get': get$5,
5791
5835
  'IndexedDb.getHandle': getHandle$1,
5792
5836
  'IndexedDb.getValues': getValues,
5793
5837
  'IndexedDb.getValuesByIndexName': getValuesByIndexName,
5794
5838
  'IndexedDb.saveValue': saveValue,
5795
- 'IndexedDb.set': set$3,
5839
+ 'IndexedDb.set': set$4,
5796
5840
  'Languages.getLanguages': getLanguages,
5797
5841
  'SaveState.saveState': saveState,
5798
5842
  'SearchFileWithFetch.searchFileWithFetch': searchFile$2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "5.14.0",
3
+ "version": "5.15.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"