@lvce-editor/extension-detail-view 5.9.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) => {
@@ -3927,6 +3929,15 @@ const getBaseUrl = (extensionPath, platform) => {
3927
3929
  }
3928
3930
  };
3929
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
+
3930
3941
  const getExtensionIdFromUri = uri => {
3931
3942
  const id = uri.slice('extension-detail://'.length);
3932
3943
  return id;
@@ -4423,6 +4434,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4423
4434
  if (!extension) {
4424
4435
  throw new ExtensionNotFoundError(id);
4425
4436
  }
4437
+ const commit = await getCommit();
4426
4438
  const headerData = loadHeaderContent(state, platform, extension);
4427
4439
  const {
4428
4440
  badge,
@@ -4444,6 +4456,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4444
4456
  const locationProtocol = location.protocol;
4445
4457
  const readmeHtml = await renderMarkdown(readmeContent, {
4446
4458
  baseUrl,
4459
+ commit,
4447
4460
  linksExternal: true,
4448
4461
  locationProtocol
4449
4462
  });
@@ -4484,6 +4497,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4484
4497
  buttons,
4485
4498
  categories,
4486
4499
  changelogScrollTop,
4500
+ commit,
4487
4501
  description,
4488
4502
  detailsVirtualDom,
4489
4503
  disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "5.9.0",
3
+ "version": "5.10.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",