@lvce-editor/extension-detail-view 5.8.0 → 5.10.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.
@@ -2623,7 +2623,7 @@ const supportsNormalCacheKey = locationProtocol => {
2623
2623
 
2624
2624
  const getMarkdownCacheHash = async (markdown, options) => {
2625
2625
  const stringifiedOptions = JSON.stringify(options);
2626
- const contents = `${markdown}:${stringifiedOptions}`;
2626
+ const contents = `${markdown}:${stringifiedOptions}:${options.commit}`;
2627
2627
  return hash(contents);
2628
2628
  };
2629
2629
  const getMarkdownCacheKey = async (markdown, options) => {
@@ -2636,7 +2636,7 @@ const getMarkdownCacheKey = async (markdown, options) => {
2636
2636
  };
2637
2637
 
2638
2638
  // TODO pass application name from renderer worker to not hardcode it
2639
- const bucketName = 'markdown-cache';
2639
+
2640
2640
  const cachedCaches = Object.create(null);
2641
2641
  const noopCache = {
2642
2642
  async match() {
@@ -2648,7 +2648,7 @@ const supportsStorageBuckets = () => {
2648
2648
  // @ts-ignore
2649
2649
  return Boolean(navigator.storageBuckets);
2650
2650
  };
2651
- const getCacheInternal = async cacheName => {
2651
+ const getCacheInternal = async (cacheName, bucketName) => {
2652
2652
  if (!supportsStorageBuckets()) {
2653
2653
  return noopCache;
2654
2654
  }
@@ -2661,28 +2661,28 @@ const getCacheInternal = async cacheName => {
2661
2661
  const cache = await bucket.caches.open(cacheName);
2662
2662
  return cache;
2663
2663
  };
2664
- const getCache = cacheName => {
2664
+ const getCache = (cacheName, bucketName) => {
2665
2665
  if (!(cacheName in cachedCaches)) {
2666
- cachedCaches[cacheName] = getCacheInternal(cacheName);
2666
+ cachedCaches[cacheName] = getCacheInternal(cacheName, bucketName);
2667
2667
  }
2668
2668
  return cachedCaches[cacheName];
2669
2669
  };
2670
2670
 
2671
2671
  // TODO pass application name from renderer worker to not hardcode it
2672
2672
  const cacheName = 'lvce-editor/markdown-cache';
2673
- const has = async key => {
2674
- const cache = await getCache(cacheName);
2673
+ const has = async (key, bucketName) => {
2674
+ const cache = await getCache(cacheName, bucketName);
2675
2675
  const response = await cache.match(key);
2676
2676
  return Boolean(response);
2677
2677
  };
2678
- const get$1 = async key => {
2679
- const cache = await getCache(cacheName);
2678
+ const get$1 = async (key, bucketName) => {
2679
+ const cache = await getCache(cacheName, bucketName);
2680
2680
  const response = await cache.match(key);
2681
2681
  const text = await response?.text();
2682
2682
  return text || '';
2683
2683
  };
2684
- const set$2 = async (key, value) => {
2685
- const cache = await getCache(cacheName);
2684
+ const set$2 = async (key, bucketName, value) => {
2685
+ const cache = await getCache(cacheName, bucketName);
2686
2686
  await cache.put(key, new Response(value, {
2687
2687
  headers: {
2688
2688
  'Content-Length': `${value.length}`,
@@ -2693,13 +2693,14 @@ const set$2 = async (key, value) => {
2693
2693
 
2694
2694
  const renderMarkdownCached = async (markdown, options) => {
2695
2695
  const cacheKey = await getMarkdownCacheKey(markdown, options);
2696
- const hasItem = await has(cacheKey);
2696
+ const bucketName = `markdown-cache`;
2697
+ const hasItem = await has(cacheKey, bucketName);
2697
2698
  if (hasItem) {
2698
- const value = await get$1(cacheKey);
2699
+ const value = await get$1(cacheKey, bucketName);
2699
2700
  return value; // TODO validate if it's valid
2700
2701
  }
2701
2702
  const html = await render(markdown, options);
2702
- await set$2(cacheKey, html);
2703
+ await set$2(cacheKey, bucketName, html);
2703
2704
  return html;
2704
2705
  };
2705
2706
 
@@ -3085,6 +3086,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3085
3086
  changelogScrollTop: 0,
3086
3087
  changelogVirtualDom: [],
3087
3088
  commands: [],
3089
+ commit: '',
3088
3090
  description: '',
3089
3091
  detailsVirtualDom: [],
3090
3092
  disabled: false,
@@ -3623,7 +3625,7 @@ const isEnoentError = error => {
3623
3625
  const error = async error => {
3624
3626
  // TODO send message to error worker or log worker
3625
3627
  // @ts-ignore
3626
- console.error(message);
3628
+ console.error(error);
3627
3629
  };
3628
3630
 
3629
3631
  const join = (...parts) => {
@@ -3739,12 +3741,25 @@ const selectTabFeatures = async state => {
3739
3741
  selected: tab.name === Features
3740
3742
  };
3741
3743
  });
3744
+ const newFeatures = features.map(feature => {
3745
+ if (feature.id === actualSelectedFeature) {
3746
+ return {
3747
+ ...feature,
3748
+ selected: true
3749
+ };
3750
+ }
3751
+ return {
3752
+ ...feature,
3753
+ selected: false
3754
+ };
3755
+ });
3742
3756
  return {
3743
3757
  ...state,
3758
+ ...partialNewState,
3759
+ features: newFeatures,
3744
3760
  selectedFeature: features[0].id || '',
3745
3761
  selectedTab: Features,
3746
- tabs: newTabs,
3747
- ...partialNewState
3762
+ tabs: newTabs
3748
3763
  };
3749
3764
  };
3750
3765
 
@@ -3914,6 +3929,15 @@ const getBaseUrl = (extensionPath, platform) => {
3914
3929
  }
3915
3930
  };
3916
3931
 
3932
+ const getCommit = async () => {
3933
+ try {
3934
+ const commit = await invoke$1('Layout.getCommit');
3935
+ return commit;
3936
+ } catch {
3937
+ return '';
3938
+ }
3939
+ };
3940
+
3917
3941
  const getExtensionIdFromUri = uri => {
3918
3942
  const id = uri.slice('extension-detail://'.length);
3919
3943
  return id;
@@ -4286,21 +4310,26 @@ const getLicenseLink = extension => {
4286
4310
  return '#';
4287
4311
  };
4288
4312
 
4289
- const getRepositoryLinkRaw = extension => {
4290
- if (extension && hasProperty(extension, 'repository') && typeof extension.repository === 'string') {
4291
- return extension.repository; // TODO watch out for javascript: or other invalid links or path traversal
4292
- }
4293
- return '';
4294
- };
4295
4313
  const ensureValidLink = link => {
4296
4314
  if (!link) {
4297
4315
  return '';
4298
4316
  }
4299
- const parsed = new URL(link);
4300
- if (parsed.protocol !== 'https:') {
4317
+ try {
4318
+ const parsed = new URL(link);
4319
+ if (parsed.protocol !== 'https:') {
4320
+ return '';
4321
+ }
4322
+ return link;
4323
+ } catch {
4301
4324
  return '';
4302
4325
  }
4303
- return link;
4326
+ };
4327
+
4328
+ const getRepositoryLinkRaw = extension => {
4329
+ if (extension && hasProperty(extension, 'repository') && typeof extension.repository === 'string') {
4330
+ return extension.repository; // TODO watch out for javascript: or other invalid links or path traversal
4331
+ }
4332
+ return '';
4304
4333
  };
4305
4334
  const getRepositoryLink = extension => {
4306
4335
  const raw = getRepositoryLinkRaw(extension);
@@ -4405,6 +4434,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4405
4434
  if (!extension) {
4406
4435
  throw new ExtensionNotFoundError(id);
4407
4436
  }
4437
+ const commit = await getCommit();
4408
4438
  const headerData = loadHeaderContent(state, platform, extension);
4409
4439
  const {
4410
4440
  badge,
@@ -4426,6 +4456,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4426
4456
  const locationProtocol = location.protocol;
4427
4457
  const readmeHtml = await renderMarkdown(readmeContent, {
4428
4458
  baseUrl,
4459
+ commit,
4429
4460
  linksExternal: true,
4430
4461
  locationProtocol
4431
4462
  });
@@ -4466,6 +4497,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4466
4497
  buttons,
4467
4498
  categories,
4468
4499
  changelogScrollTop,
4500
+ commit,
4469
4501
  description,
4470
4502
  detailsVirtualDom,
4471
4503
  disabled,
@@ -5091,7 +5123,6 @@ const render2 = (uid, diffResult) => {
5091
5123
  return commands;
5092
5124
  };
5093
5125
 
5094
- // @ts-nocheck
5095
5126
  const renderEventListeners = () => {
5096
5127
  return [{
5097
5128
  name: HandleAdditionalDetailContextMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "5.8.0",
3
+ "version": "5.10.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",