@lvce-editor/extension-detail-view 5.9.0 → 5.11.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
|
-
|
|
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
|
}
|
|
@@ -2656,33 +2656,33 @@ const getCacheInternal = async cacheName => {
|
|
|
2656
2656
|
// @ts-ignore
|
|
2657
2657
|
const bucket = await navigator.storageBuckets.open(bucketName, {
|
|
2658
2658
|
expires: Date.now() + twoWeeks,
|
|
2659
|
-
quota:
|
|
2659
|
+
quota: 100 * 1024 * 1024 // 100MB
|
|
2660
2660
|
});
|
|
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
|
|
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(
|
|
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;
|
|
@@ -4325,12 +4336,23 @@ const getRepositoryLink = extension => {
|
|
|
4325
4336
|
const validLink = ensureValidLink(raw);
|
|
4326
4337
|
return validLink;
|
|
4327
4338
|
};
|
|
4339
|
+
const getIssuesLink = extension => {
|
|
4340
|
+
const repositoryLink = getRepositoryLink(extension);
|
|
4341
|
+
if (!repositoryLink) {
|
|
4342
|
+
return '';
|
|
4343
|
+
}
|
|
4344
|
+
if (repositoryLink && repositoryLink.startsWith('https://github.com')) {
|
|
4345
|
+
return `${repositoryLink}/issues`;
|
|
4346
|
+
}
|
|
4347
|
+
return '';
|
|
4348
|
+
};
|
|
4328
4349
|
|
|
4329
4350
|
const getResources = (isBuiltin, extension) => {
|
|
4330
4351
|
if (isBuiltin) {
|
|
4331
4352
|
return [];
|
|
4332
4353
|
}
|
|
4333
4354
|
const repositoryLink = getRepositoryLink(extension);
|
|
4355
|
+
const issueLink = getIssuesLink(extension);
|
|
4334
4356
|
const licenseLink = getLicenseLink();
|
|
4335
4357
|
// TODO
|
|
4336
4358
|
return [{
|
|
@@ -4340,7 +4362,7 @@ const getResources = (isBuiltin, extension) => {
|
|
|
4340
4362
|
}, {
|
|
4341
4363
|
icon: 'LinkExternal',
|
|
4342
4364
|
label: issues(),
|
|
4343
|
-
url:
|
|
4365
|
+
url: issueLink
|
|
4344
4366
|
}, {
|
|
4345
4367
|
icon: 'Repo',
|
|
4346
4368
|
label: repository(),
|
|
@@ -4423,6 +4445,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
|
|
|
4423
4445
|
if (!extension) {
|
|
4424
4446
|
throw new ExtensionNotFoundError(id);
|
|
4425
4447
|
}
|
|
4448
|
+
const commit = await getCommit();
|
|
4426
4449
|
const headerData = loadHeaderContent(state, platform, extension);
|
|
4427
4450
|
const {
|
|
4428
4451
|
badge,
|
|
@@ -4444,6 +4467,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
|
|
|
4444
4467
|
const locationProtocol = location.protocol;
|
|
4445
4468
|
const readmeHtml = await renderMarkdown(readmeContent, {
|
|
4446
4469
|
baseUrl,
|
|
4470
|
+
commit,
|
|
4447
4471
|
linksExternal: true,
|
|
4448
4472
|
locationProtocol
|
|
4449
4473
|
});
|
|
@@ -4484,6 +4508,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
|
|
|
4484
4508
|
buttons,
|
|
4485
4509
|
categories,
|
|
4486
4510
|
changelogScrollTop,
|
|
4511
|
+
commit,
|
|
4487
4512
|
description,
|
|
4488
4513
|
detailsVirtualDom,
|
|
4489
4514
|
disabled,
|
|
@@ -4760,7 +4785,7 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
|
|
|
4760
4785
|
}, {
|
|
4761
4786
|
childCount: 4,
|
|
4762
4787
|
className: AdditionalDetails,
|
|
4763
|
-
|
|
4788
|
+
onContextMenu: HandleAdditionalDetailContextMenu,
|
|
4764
4789
|
tabIndex: 0,
|
|
4765
4790
|
type: Div
|
|
4766
4791
|
}, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/extension-detail-view",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Extension Detail View Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/extensionDetailViewWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/constants": "^1.
|
|
14
|
+
"@lvce-editor/constants": "^1.41.0"
|
|
15
15
|
}
|
|
16
16
|
}
|