@lvce-editor/extension-host-worker 3.18.0 → 3.20.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.
@@ -2753,7 +2753,7 @@ const getWebView = id => {
2753
2753
  const setWebView = (id, webView) => {
2754
2754
  webViews[id] = webView;
2755
2755
  };
2756
- const getWebViews = () => {
2756
+ const getWebViews$1 = () => {
2757
2757
  return webViews;
2758
2758
  };
2759
2759
 
@@ -2775,7 +2775,7 @@ const getRemoteUrlForWebView = async (uri, options = {}) => {
2775
2775
  return objectUrl;
2776
2776
  };
2777
2777
 
2778
- const getRemoteUrl = async (uri, options = {}) => {
2778
+ const getRemoteUrl$1 = async (uri, options = {}) => {
2779
2779
  // TODO uri should always have protocol
2780
2780
  // then ask file system provider for remote url, for example disk file system provider or html file system provider
2781
2781
  const protocol = getProtocol(uri);
@@ -2978,7 +2978,7 @@ const api = {
2978
2978
  registerTypeDefinitionProvider: registerTypeDefinitionProvider,
2979
2979
  executeTypeDefinitionProvider: executeTypeDefinitionProvider,
2980
2980
  // Url
2981
- getRemoteUrl: getRemoteUrl,
2981
+ getRemoteUrl: getRemoteUrl$1,
2982
2982
  // Webview
2983
2983
  registerWebViewProvider: registerWebViewProvider,
2984
2984
  // Worker
@@ -3679,7 +3679,7 @@ const getWebExtensions = async () => {
3679
3679
  const getSharedProcessExtensions = () => {
3680
3680
  return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
3681
3681
  };
3682
- const getExtensions$1 = async () => {
3682
+ const doGetExtensions = async () => {
3683
3683
  if (platform === Web) {
3684
3684
  const webExtensions = await getWebExtensions();
3685
3685
  return webExtensions;
@@ -3693,6 +3693,10 @@ const getExtensions$1 = async () => {
3693
3693
  return extensions;
3694
3694
  };
3695
3695
 
3696
+ const getExtensions$1 = async () => {
3697
+ return doGetExtensions();
3698
+ };
3699
+
3696
3700
  const cache = Object.create(null);
3697
3701
  const id = 1;
3698
3702
  const get = () => {
@@ -4769,6 +4773,39 @@ const getRpcInfo = rpcId => {
4769
4773
  return info;
4770
4774
  };
4771
4775
 
4776
+ const getRemoteUrl = uri => {
4777
+ return `/remote/${uri}`;
4778
+ };
4779
+
4780
+ const getWebViewsFromExtensions = extensions => {
4781
+ const webViews = [];
4782
+ for (const extension of extensions) {
4783
+ if (extension && extension.webViews) {
4784
+ for (const webView of extension.webViews) {
4785
+ let path = extension.path;
4786
+ if (webView && webView.path) {
4787
+ path = `${extension.path}/${webView.path}`;
4788
+ }
4789
+ const uri = path;
4790
+ const remotePath = getRemoteUrl(uri);
4791
+ webViews.push({
4792
+ ...webView,
4793
+ path,
4794
+ uri,
4795
+ remotePath
4796
+ });
4797
+ }
4798
+ }
4799
+ }
4800
+ return webViews;
4801
+ };
4802
+
4803
+ const getWebViews = async () => {
4804
+ const extensions = await getExtensions();
4805
+ const webViews = getWebViewsFromExtensions(extensions);
4806
+ return webViews;
4807
+ };
4808
+
4772
4809
  const handleBeforeUnload = () => {
4773
4810
  // TODO save all webviews in localstorage
4774
4811
  // cannot use indexeddb during unload
@@ -4952,9 +4989,6 @@ const getLanguages = async () => {
4952
4989
  try {
4953
4990
  const extensions = await getExtensions();
4954
4991
  const languages = extensions.flatMap(getLanguagesFromExtension);
4955
- console.log({
4956
- languages
4957
- });
4958
4992
  return languages;
4959
4993
  } catch (error) {
4960
4994
  throw new VError(error, 'Failed to load languages');
@@ -5004,7 +5038,7 @@ const getAdditional = () => {
5004
5038
  }
5005
5039
  };
5006
5040
  const saveState = async () => {
5007
- const webViews = getWebViews();
5041
+ const webViews = getWebViews$1();
5008
5042
  const serialized = await serializeWebViews(webViews);
5009
5043
  const additional = await getAdditional();
5010
5044
  const all = [...serialized, ...additional];
@@ -5327,6 +5361,7 @@ const commandMap = {
5327
5361
  'ExtensionHost.launchIframeWorker': launchIframeWorker,
5328
5362
  'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
5329
5363
  'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
5364
+ 'Extensions.getExtensions': getExtensions,
5330
5365
  'FileSystemFetch.chmod': chmod$1,
5331
5366
  'FileSystemFetch.getBlob': getBlob$1,
5332
5367
  'FileSystemFetch.mkdir': mkdir$1,
@@ -5335,7 +5370,6 @@ const commandMap = {
5335
5370
  'FileSystemFetch.remove': remove$1,
5336
5371
  'FileSystemFetch.writeFile': writeFile$1,
5337
5372
  'FileSystemMemory.chmod': chmod,
5338
- 'Languages.getLanguages': getLanguages,
5339
5373
  'FileSystemMemory.getBlob': getBlob,
5340
5374
  'FileSystemMemory.getBlobUrl': getBlobUrl,
5341
5375
  'FileSystemMemory.getFiles': getFiles,
@@ -5355,6 +5389,7 @@ const commandMap = {
5355
5389
  'IndexedDb.getValuesByIndexName': getValuesByIndexName,
5356
5390
  'IndexedDb.saveValue': saveValue,
5357
5391
  'IndexedDb.set': set$4,
5392
+ 'Languages.getLanguages': getLanguages,
5358
5393
  'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
5359
5394
  'SearchFileWithHtml.searchFileWithHtml': searchFile,
5360
5395
  'TextSearchFetch.textSearch': textSearch$2,
@@ -5363,6 +5398,7 @@ const commandMap = {
5363
5398
  'WebView.create3': createWebView3,
5364
5399
  'WebView.createWebViewWorkerRpc': createWebViewWorkerRpc,
5365
5400
  'WebView.getRpcInfo': getRpcInfo,
5401
+ 'WebViews.getWebViews': getWebViews,
5366
5402
  ['ExtensionHostDebug.evaluate']: evaluate,
5367
5403
  ['ExtensionHostDebug.getProperties']: getProperties,
5368
5404
  ['ExtensionHostDebug.listProcesses']: listProcesses,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "3.18.0",
3
+ "version": "3.20.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "main": "dist/extensionHostWorkerMain.js",
6
6
  "type": "module",