@lvce-editor/extension-detail-view 4.9.0 → 4.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.
|
@@ -319,7 +319,9 @@ const Dt = 67;
|
|
|
319
319
|
|
|
320
320
|
const ClientX = 'event.clientX';
|
|
321
321
|
const ClientY = 'event.clientY';
|
|
322
|
+
const TargetHref = 'event.target.href';
|
|
322
323
|
const TargetName = 'event.target.name';
|
|
324
|
+
const TargetSrc = 'event.target.src';
|
|
323
325
|
|
|
324
326
|
const DebugWorker = 55;
|
|
325
327
|
const ExtensionHostWorker = 44;
|
|
@@ -618,7 +620,7 @@ const getCommandsVirtualDom = state => {
|
|
|
618
620
|
return getFeatureCommandsVirtualDom(state.commands);
|
|
619
621
|
};
|
|
620
622
|
|
|
621
|
-
const isExternalLink = schema => {
|
|
623
|
+
const isExternalLink$1 = schema => {
|
|
622
624
|
return schema.startsWith('http://') || schema.startsWith('https://');
|
|
623
625
|
};
|
|
624
626
|
const hasWhitespace = value => {
|
|
@@ -665,7 +667,7 @@ const getSchemaLinkUrl = (schema, extensionUri) => {
|
|
|
665
667
|
if (trimmed !== schema) {
|
|
666
668
|
return '';
|
|
667
669
|
}
|
|
668
|
-
if (isExternalLink(schema)) {
|
|
670
|
+
if (isExternalLink$1(schema)) {
|
|
669
671
|
return isValidHttpUrl(schema) ? schema : '';
|
|
670
672
|
}
|
|
671
673
|
if (!isValidRelativePath(schema)) {
|
|
@@ -833,9 +835,17 @@ const getJsonValidationVirtualDom = state => {
|
|
|
833
835
|
return getFeatureJsonValidationVirtualDom(state.jsonValidation);
|
|
834
836
|
};
|
|
835
837
|
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
838
|
+
const getProgrammingLanguageTableEntry = programmingLanguage => {
|
|
839
|
+
return [];
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const getFeatureDetailsProgrammingLanguages = async extension => {
|
|
843
|
+
// TODO validate them also, to create better types
|
|
844
|
+
const programmingLanguages = extension.languages || [];
|
|
845
|
+
const rows = programmingLanguages.map(getProgrammingLanguageTableEntry);
|
|
846
|
+
return {
|
|
847
|
+
programmingLanguages: rows
|
|
848
|
+
};
|
|
839
849
|
};
|
|
840
850
|
|
|
841
851
|
const featureProgrammingLanguagesEnabled = extension => {
|
|
@@ -2684,6 +2694,7 @@ const HandleReadmeContextMenu = 12;
|
|
|
2684
2694
|
const HandleReadmeScroll = 13;
|
|
2685
2695
|
const HandleTabsClick = 14;
|
|
2686
2696
|
const HandleAdditionalDetailContextMenu = 15;
|
|
2697
|
+
const HandleReadmeClick = 16;
|
|
2687
2698
|
|
|
2688
2699
|
const ActivationEvents = 'ActivationEvents';
|
|
2689
2700
|
const Changelog = 'Changelog';
|
|
@@ -2733,7 +2744,8 @@ const getMarkdownVirtualDom = async (html, options) => {
|
|
|
2733
2744
|
return [{
|
|
2734
2745
|
...firstNode,
|
|
2735
2746
|
onScroll: HandleReadmeScroll,
|
|
2736
|
-
childCount: firstNode.childCount + 1
|
|
2747
|
+
childCount: firstNode.childCount + 1,
|
|
2748
|
+
onClick: HandleReadmeClick
|
|
2737
2749
|
}, ...extraDom, ...rest];
|
|
2738
2750
|
}
|
|
2739
2751
|
return dom;
|
|
@@ -2772,25 +2784,34 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
|
|
|
2772
2784
|
return markdown;
|
|
2773
2785
|
};
|
|
2774
2786
|
|
|
2787
|
+
const padBytes = bytes => {
|
|
2788
|
+
return bytes.toString(16).padStart(2, '0');
|
|
2789
|
+
};
|
|
2790
|
+
const hash = async content => {
|
|
2791
|
+
const sourceBytes = new TextEncoder().encode(content);
|
|
2792
|
+
const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
|
|
2793
|
+
const resultBytes = [...new Uint8Array(digest)];
|
|
2794
|
+
return resultBytes.map(padBytes).join('');
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2775
2797
|
const supportsNormalCacheKey = locationProtocol => {
|
|
2776
2798
|
return locationProtocol === 'http:' || locationProtocol === 'https:';
|
|
2777
2799
|
};
|
|
2778
2800
|
|
|
2779
|
-
const
|
|
2780
|
-
|
|
2801
|
+
const getMarkdownCacheHash = async (markdown, options) => {
|
|
2802
|
+
const stringifiedOptions = JSON.stringify(options);
|
|
2803
|
+
const contents = `${markdown}:${stringifiedOptions}`;
|
|
2804
|
+
return hash(contents);
|
|
2805
|
+
};
|
|
2806
|
+
const getMarkdownCacheKey = async (markdown, options) => {
|
|
2807
|
+
const hash = await getMarkdownCacheHash(markdown, options);
|
|
2808
|
+
if (supportsNormalCacheKey(options.locationProtocol)) {
|
|
2781
2809
|
return `/markdown/${hash}`;
|
|
2782
2810
|
}
|
|
2783
2811
|
// workaround for electron bug
|
|
2784
2812
|
return `https://-/markdown/${hash}`;
|
|
2785
2813
|
};
|
|
2786
2814
|
|
|
2787
|
-
const hash = async content => {
|
|
2788
|
-
const sourceBytes = new TextEncoder().encode(content);
|
|
2789
|
-
const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
|
|
2790
|
-
const resultBytes = [...new Uint8Array(digest)];
|
|
2791
|
-
return resultBytes.map(x => x.toString(16).padStart(2, '0')).join('');
|
|
2792
|
-
};
|
|
2793
|
-
|
|
2794
2815
|
// TODO pass application name from renderer worker to not hardcode it
|
|
2795
2816
|
const bucketName = 'markdown-cache';
|
|
2796
2817
|
const cachedCaches = Object.create(null);
|
|
@@ -2849,8 +2870,7 @@ const set$3 = async (key, value) => {
|
|
|
2849
2870
|
};
|
|
2850
2871
|
|
|
2851
2872
|
const renderMarkdownCached = async (markdown, options) => {
|
|
2852
|
-
const
|
|
2853
|
-
const cacheKey = getMarkdownCacheKey(markdownHash, options.locationProtocol);
|
|
2873
|
+
const cacheKey = await getMarkdownCacheKey(markdown, options);
|
|
2854
2874
|
const hasItem = await has(cacheKey);
|
|
2855
2875
|
if (hasItem) {
|
|
2856
2876
|
const value = await get$1(cacheKey);
|
|
@@ -3055,7 +3075,7 @@ const registerAllFeatures = () => {
|
|
|
3055
3075
|
id: ProgrammingLanguages,
|
|
3056
3076
|
getLabel: programmingLanguages,
|
|
3057
3077
|
isEnabled: featureProgrammingLanguagesEnabled,
|
|
3058
|
-
getDetails:
|
|
3078
|
+
getDetails: getFeatureDetailsProgrammingLanguages,
|
|
3059
3079
|
getVirtualDom: getProgrammingLanguagesVirtualDom
|
|
3060
3080
|
});
|
|
3061
3081
|
register$1({
|
|
@@ -3674,6 +3694,20 @@ const handleImageContextMenu = async (state, eventX, eventY) => {
|
|
|
3674
3694
|
return state;
|
|
3675
3695
|
};
|
|
3676
3696
|
|
|
3697
|
+
const isExternalLink = href => {
|
|
3698
|
+
return href.startsWith('http://') || href.startsWith('https://');
|
|
3699
|
+
};
|
|
3700
|
+
const handleReadmeClick = async (state, nodeName, href) => {
|
|
3701
|
+
if (!href || !isExternalLink(href)) {
|
|
3702
|
+
return state;
|
|
3703
|
+
}
|
|
3704
|
+
// TODO what to do about relative links? open them in editor?
|
|
3705
|
+
// TODO what to do about mail links?
|
|
3706
|
+
await openUrl$2(href);
|
|
3707
|
+
// TODO check node name and href
|
|
3708
|
+
return state;
|
|
3709
|
+
};
|
|
3710
|
+
|
|
3677
3711
|
const handleScroll = (state, scrollTop, scrollSource = Script) => {
|
|
3678
3712
|
const newScrollTop = Math.max(0, scrollTop);
|
|
3679
3713
|
return {
|
|
@@ -4711,6 +4745,14 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
|
|
|
4711
4745
|
}, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
|
|
4712
4746
|
};
|
|
4713
4747
|
|
|
4748
|
+
const getNoReadmeVirtualDom = () => {
|
|
4749
|
+
return [{
|
|
4750
|
+
type: Div,
|
|
4751
|
+
childCount: 1,
|
|
4752
|
+
className: Markdown
|
|
4753
|
+
}, text(noReadmeFound())];
|
|
4754
|
+
};
|
|
4755
|
+
|
|
4714
4756
|
const getChildCount = (additionalDetails, scrollToTopEnabled) => {
|
|
4715
4757
|
let count = 1;
|
|
4716
4758
|
if (additionalDetails) {
|
|
@@ -4725,11 +4767,7 @@ const getDetailsVirtualDom = (sanitizedReadmeHtml, width, scrollToTopButtonEnabl
|
|
|
4725
4767
|
const fourthHeading = resources();
|
|
4726
4768
|
const showAdditionalDetails = showSideBar;
|
|
4727
4769
|
const childCount = getChildCount(showAdditionalDetails);
|
|
4728
|
-
const contentDom = hasReadme ? sanitizedReadmeHtml :
|
|
4729
|
-
type: Div,
|
|
4730
|
-
childCount: 1,
|
|
4731
|
-
className: Markdown
|
|
4732
|
-
}, text(noReadmeFound())];
|
|
4770
|
+
const contentDom = hasReadme ? sanitizedReadmeHtml : getNoReadmeVirtualDom();
|
|
4733
4771
|
const dom = [{
|
|
4734
4772
|
type: Div,
|
|
4735
4773
|
className: ExtensionDetailPanel,
|
|
@@ -5064,7 +5102,7 @@ const renderEventListeners = () => {
|
|
|
5064
5102
|
params: ['handleIconError']
|
|
5065
5103
|
}, {
|
|
5066
5104
|
name: HandleReadmeContextMenu,
|
|
5067
|
-
params: ['handleReadmeContextMenu', ClientX, ClientY,
|
|
5105
|
+
params: ['handleReadmeContextMenu', ClientX, ClientY, TargetHref, TargetSrc]
|
|
5068
5106
|
}, {
|
|
5069
5107
|
name: HandleImageContextMenu,
|
|
5070
5108
|
params: ['handleImageContextMenu', ClientX, ClientY],
|
|
@@ -5092,6 +5130,10 @@ const renderEventListeners = () => {
|
|
|
5092
5130
|
}, {
|
|
5093
5131
|
name: HandleClickSettings,
|
|
5094
5132
|
params: ['handleClickSettings']
|
|
5133
|
+
}, {
|
|
5134
|
+
name: HandleReadmeClick,
|
|
5135
|
+
params: ['handleReadmeClick', 'event.target.nodeName', 'event.target.href'],
|
|
5136
|
+
preventDefault: true
|
|
5095
5137
|
}, {
|
|
5096
5138
|
name: HandleClickUninstall,
|
|
5097
5139
|
params: ['handleClickUninstall']
|
|
@@ -5154,6 +5196,7 @@ const commandMap = {
|
|
|
5154
5196
|
'ExtensionDetail.handleImageContextMenu': wrapCommand(handleImageContextMenu),
|
|
5155
5197
|
'ExtensionDetail.handleScroll': wrapCommand(handleScroll),
|
|
5156
5198
|
'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
|
|
5199
|
+
'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
|
|
5157
5200
|
'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
|
|
5158
5201
|
// deprecated
|
|
5159
5202
|
'ExtensionDetail.initialize': initialize,
|