@lvce-editor/extension-host-worker 4.1.0 → 4.2.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.
@@ -3076,6 +3076,67 @@ const setup = ({
3076
3076
  global.vscode = api;
3077
3077
  };
3078
3078
 
3079
+ const cache = Object.create(null);
3080
+ const id = 1;
3081
+ const get$5 = () => {
3082
+ return cache[id];
3083
+ };
3084
+ const has = () => {
3085
+ return id in cache;
3086
+ };
3087
+ const set$4 = value => {
3088
+ cache[id] = value;
3089
+ };
3090
+ const clear = () => {
3091
+ delete cache[id];
3092
+ };
3093
+
3094
+ const getJson = async url => {
3095
+ try {
3096
+ const response = await fetch(url);
3097
+ if (!response.ok) {
3098
+ throw new Error(response.statusText);
3099
+ }
3100
+ const json = await response.json();
3101
+ return json;
3102
+ } catch (error) {
3103
+ throw new VError(error, `Failed to get json`);
3104
+ }
3105
+ };
3106
+
3107
+ const NewLine = '\n';
3108
+ const Slash$1 = '/';
3109
+
3110
+ const interExtensionId = path => {
3111
+ const slashIndex = path.lastIndexOf(Slash$1);
3112
+ return path.slice(slashIndex + 1);
3113
+ };
3114
+
3115
+ const getWebExtensionManifest = async (path, manifestPath) => {
3116
+ try {
3117
+ const manifest = await getJson(manifestPath);
3118
+ return {
3119
+ ...manifest,
3120
+ path
3121
+ };
3122
+ } catch (error) {
3123
+ const id = interExtensionId(path);
3124
+ throw new VError(error, `Failed to load extension manifest for ${id}`);
3125
+ }
3126
+ };
3127
+
3128
+ const getWebManifestPath = path => {
3129
+ const manifestPath = `${path}/extension.json`;
3130
+ return manifestPath;
3131
+ };
3132
+
3133
+ const addWebExtension = async path => {
3134
+ const manifestPath = getWebManifestPath(path);
3135
+ const manifest = await getWebExtensionManifest(path, manifestPath);
3136
+ clear();
3137
+ return manifest;
3138
+ };
3139
+
3079
3140
  const applyBulkReplacement = async (files, ranges, replacement) => {
3080
3141
  console.log({
3081
3142
  files,
@@ -3089,8 +3150,6 @@ const addCssStyleSheet = (id, css) => {
3089
3150
  return invoke$2('Css.addCssStyleSheet', id, css);
3090
3151
  };
3091
3152
 
3092
- const NewLine = '\n';
3093
-
3094
3153
  const warn = (...args) => {
3095
3154
  console.warn(...args);
3096
3155
  };
@@ -3475,7 +3534,7 @@ const getDbMemoized$1 = async () => {
3475
3534
 
3476
3535
  // TODO high memory usage in idb because of transactionDoneMap
3477
3536
 
3478
- const set$4 = async (key, value) => {
3537
+ const set$3 = async (key, value) => {
3479
3538
  try {
3480
3539
  const db = await getDbMemoized$1();
3481
3540
  await db.put(storeId, value, key);
@@ -3483,7 +3542,7 @@ const set$4 = async (key, value) => {
3483
3542
  throw new VError(error, 'Failed to save value to indexed db');
3484
3543
  }
3485
3544
  };
3486
- const get$5 = async key => {
3545
+ const get$4 = async key => {
3487
3546
  try {
3488
3547
  const db = await getDbMemoized$1();
3489
3548
  const value = await db.get(storeId, key);
@@ -3496,19 +3555,19 @@ const get$5 = async key => {
3496
3555
  const getCacheKey$1 = colorThemeId => {
3497
3556
  return 'color-theme-' + colorThemeId;
3498
3557
  };
3499
- const get$4 = colorThemeId => {
3558
+ const get$3 = colorThemeId => {
3500
3559
  const cacheKey = getCacheKey$1(colorThemeId);
3501
- return get$5(cacheKey);
3560
+ return get$4(cacheKey);
3502
3561
  };
3503
- const set$3 = (colorThemeId, data) => {
3562
+ const set$2 = (colorThemeId, data) => {
3504
3563
  const cacheKey = getCacheKey$1(colorThemeId);
3505
- return set$4(cacheKey, data);
3564
+ return set$3(cacheKey, data);
3506
3565
  };
3507
3566
 
3508
3567
  const GetColorThemeCssCachedIndexedDb = {
3509
3568
  __proto__: null,
3510
- get: get$4,
3511
- set: set$3
3569
+ get: get$3,
3570
+ set: set$2
3512
3571
  };
3513
3572
 
3514
3573
  const getText$1 = key => {
@@ -3521,35 +3580,35 @@ const setText = (key, value) => {
3521
3580
  const getCacheKey = colorThemeId => {
3522
3581
  return 'lvce-color-theme-' + colorThemeId;
3523
3582
  };
3524
- const get$3 = colorThemeId => {
3583
+ const get$2 = colorThemeId => {
3525
3584
  const cacheKey = getCacheKey(colorThemeId);
3526
3585
  return getText$1(cacheKey);
3527
3586
  };
3528
- const set$2 = (colorThemeId, data) => {
3587
+ const set$1 = (colorThemeId, data) => {
3529
3588
  const cacheKey = getCacheKey(colorThemeId);
3530
3589
  return setText(cacheKey, data);
3531
3590
  };
3532
3591
 
3533
3592
  const GetColorThemeCssCachedLocalStorage = {
3534
3593
  __proto__: null,
3535
- get: get$3,
3536
- set: set$2
3594
+ get: get$2,
3595
+ set: set$1
3537
3596
  };
3538
3597
 
3539
- const get$2 = colorThemeId => {
3598
+ const get$1 = colorThemeId => {
3540
3599
  return '';
3541
3600
  };
3542
- const set$1 = (colorThemeId, data) => {
3601
+ const set = (colorThemeId, data) => {
3543
3602
  // noop
3544
3603
  };
3545
3604
 
3546
3605
  const GetColorThemeCssCachedNoop = {
3547
3606
  __proto__: null,
3548
- get: get$2,
3549
- set: set$1
3607
+ get: get$1,
3608
+ set
3550
3609
  };
3551
3610
 
3552
- const get$1 = key => {
3611
+ const get = key => {
3553
3612
  return invoke$2('Preferences.get', key);
3554
3613
  };
3555
3614
 
@@ -3564,7 +3623,7 @@ const getCacheFn = config => {
3564
3623
  }
3565
3624
  };
3566
3625
  const getColorThemeCssCached = async (colorThemeId, getData) => {
3567
- const config = await get$1('colorTheme.cache');
3626
+ const config = await get('colorTheme.cache');
3568
3627
  const module = await getCacheFn(config);
3569
3628
  const cachedData = await module.get(colorThemeId);
3570
3629
  if (cachedData) {
@@ -3617,19 +3676,6 @@ const state$5 = {
3617
3676
  webExtensions: []
3618
3677
  };
3619
3678
 
3620
- const getJson = async url => {
3621
- try {
3622
- const response = await fetch(url);
3623
- if (!response.ok) {
3624
- throw new Error(response.statusText);
3625
- }
3626
- const json = await response.json();
3627
- return json;
3628
- } catch (error) {
3629
- throw new VError(error, `Failed to get json`);
3630
- }
3631
- };
3632
-
3633
3679
  const getAssetDir = () => {
3634
3680
  // @ts-ignore
3635
3681
  if (typeof ASSET_DIR !== 'undefined') {
@@ -3670,24 +3716,12 @@ const getExtensions$1 = async () => {
3670
3716
  return doGetExtensions();
3671
3717
  };
3672
3718
 
3673
- const cache = Object.create(null);
3674
- const id = 1;
3675
- const get = () => {
3676
- return cache[id];
3677
- };
3678
- const has = () => {
3679
- return id in cache;
3680
- };
3681
- const set = value => {
3682
- cache[id] = value;
3683
- };
3684
-
3685
3719
  // TODO getExtensions is still called 6 times on startup instead of 1
3686
3720
  const getExtensions = () => {
3687
3721
  if (!has()) {
3688
- set(getExtensions$1());
3722
+ set$4(getExtensions$1());
3689
3723
  }
3690
- return get();
3724
+ return get$5();
3691
3725
  };
3692
3726
 
3693
3727
  const getColorThemeJson$2 = async colorThemeId => {
@@ -3756,7 +3790,7 @@ const applyColorTheme = async colorThemeId => {
3756
3790
  const themeColor = getMetaThemeColor(colorThemeId) || '';
3757
3791
  await setThemeColor(themeColor);
3758
3792
  }
3759
- if (platform !== Web && (await get$1('development.watchColorTheme'))) {
3793
+ if (platform !== Web && (await get('development.watchColorTheme'))) {
3760
3794
  watch(colorThemeId);
3761
3795
  }
3762
3796
  } catch (error) {
@@ -3771,7 +3805,7 @@ const watch = async id => {
3771
3805
  await invoke$2('ExtensionHost.watchColorTheme', id);
3772
3806
  };
3773
3807
  const getPreferredColorTheme = () => {
3774
- const preferredColorTheme = get$1('workbench.colorTheme');
3808
+ const preferredColorTheme = get('workbench.colorTheme');
3775
3809
  return preferredColorTheme;
3776
3810
  };
3777
3811
 
@@ -3794,7 +3828,7 @@ const hydrate$1 = async () => {
3794
3828
  const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
3795
3829
 
3796
3830
  const getConfiguredIframeWorkerUrl = async () => {
3797
- let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
3831
+ let configuredWorkerUrl = (await get('develop.iframeWorkerPath')) || '';
3798
3832
  if (configuredWorkerUrl) {
3799
3833
  configuredWorkerUrl = '/remote' + configuredWorkerUrl;
3800
3834
  }
@@ -4853,7 +4887,7 @@ const setIconTheme = async iconThemeId => {
4853
4887
  }
4854
4888
  };
4855
4889
  const hydrate = async () => {
4856
- const iconThemeId = (await get$1('icon-theme')) || 'vscode-icons';
4890
+ const iconThemeId = (await get('icon-theme')) || 'vscode-icons';
4857
4891
  await setIconTheme(iconThemeId);
4858
4892
  };
4859
4893
 
@@ -5360,6 +5394,7 @@ const commandMap = {
5360
5394
  'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
5361
5395
  'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
5362
5396
  'Extensions.getExtensions': getExtensions,
5397
+ 'Extensions.addWebExtension': addWebExtension,
5363
5398
  'FileSystemFetch.chmod': chmod$1,
5364
5399
  'FileSystemFetch.getBlob': getBlob$1,
5365
5400
  'FileSystemFetch.mkdir': mkdir$1,
@@ -5381,12 +5416,12 @@ const commandMap = {
5381
5416
  'IconTheme.hydrate': hydrate,
5382
5417
  'IconTheme.setIconTheme': setIconTheme,
5383
5418
  'IndexedDb.addHandle': addHandle,
5384
- 'IndexedDb.get': get$5,
5419
+ 'IndexedDb.get': get$4,
5385
5420
  'IndexedDb.getHandle': getHandle$1,
5386
5421
  'IndexedDb.getValues': getValues,
5387
5422
  'IndexedDb.getValuesByIndexName': getValuesByIndexName,
5388
5423
  'IndexedDb.saveValue': saveValue,
5389
- 'IndexedDb.set': set$4,
5424
+ 'IndexedDb.set': set$3,
5390
5425
  'Languages.getLanguages': getLanguages,
5391
5426
  'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
5392
5427
  'SearchFileWithHtml.searchFileWithHtml': searchFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "main": "dist/extensionHostWorkerMain.js",
6
6
  "type": "module",