markstream-svelte 0.0.1-beta.1
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.
- package/README.md +77 -0
- package/dist/components/AdmonitionNode.svelte +8 -0
- package/dist/components/AdmonitionNode.svelte.d.ts +23 -0
- package/dist/components/AdmonitionNode.svelte.d.ts.map +1 -0
- package/dist/components/BlockquoteNode.svelte +10 -0
- package/dist/components/BlockquoteNode.svelte.d.ts +24 -0
- package/dist/components/BlockquoteNode.svelte.d.ts.map +1 -0
- package/dist/components/CheckboxNode.svelte +5 -0
- package/dist/components/CheckboxNode.svelte.d.ts +22 -0
- package/dist/components/CheckboxNode.svelte.d.ts.map +1 -0
- package/dist/components/CodeBlockNode.svelte +944 -0
- package/dist/components/CodeBlockNode.svelte.d.ts +43 -0
- package/dist/components/CodeBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/D2BlockNode.svelte +272 -0
- package/dist/components/D2BlockNode.svelte.d.ts +33 -0
- package/dist/components/D2BlockNode.svelte.d.ts.map +1 -0
- package/dist/components/DefinitionListNode.svelte +8 -0
- package/dist/components/DefinitionListNode.svelte.d.ts +23 -0
- package/dist/components/DefinitionListNode.svelte.d.ts.map +1 -0
- package/dist/components/EmojiNode.svelte +7 -0
- package/dist/components/EmojiNode.svelte.d.ts +22 -0
- package/dist/components/EmojiNode.svelte.d.ts.map +1 -0
- package/dist/components/EmphasisNode.svelte +8 -0
- package/dist/components/EmphasisNode.svelte.d.ts +24 -0
- package/dist/components/EmphasisNode.svelte.d.ts.map +1 -0
- package/dist/components/FallbackComponent.svelte +8 -0
- package/dist/components/FallbackComponent.svelte.d.ts +23 -0
- package/dist/components/FallbackComponent.svelte.d.ts.map +1 -0
- package/dist/components/FootnoteAnchorNode.svelte +21 -0
- package/dist/components/FootnoteAnchorNode.svelte.d.ts +22 -0
- package/dist/components/FootnoteAnchorNode.svelte.d.ts.map +1 -0
- package/dist/components/FootnoteNode.svelte +19 -0
- package/dist/components/FootnoteNode.svelte.d.ts +24 -0
- package/dist/components/FootnoteNode.svelte.d.ts.map +1 -0
- package/dist/components/FootnoteReferenceNode.svelte +26 -0
- package/dist/components/FootnoteReferenceNode.svelte.d.ts +22 -0
- package/dist/components/FootnoteReferenceNode.svelte.d.ts.map +1 -0
- package/dist/components/HardBreakNode.svelte +1 -0
- package/dist/components/HardBreakNode.svelte.d.ts +27 -0
- package/dist/components/HardBreakNode.svelte.d.ts.map +1 -0
- package/dist/components/HeadingNode.svelte +15 -0
- package/dist/components/HeadingNode.svelte.d.ts +24 -0
- package/dist/components/HeadingNode.svelte.d.ts.map +1 -0
- package/dist/components/HighlightNode.svelte +8 -0
- package/dist/components/HighlightNode.svelte.d.ts +24 -0
- package/dist/components/HighlightNode.svelte.d.ts.map +1 -0
- package/dist/components/HtmlBlockNode.svelte +8 -0
- package/dist/components/HtmlBlockNode.svelte.d.ts +23 -0
- package/dist/components/HtmlBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/HtmlInlineNode.svelte +8 -0
- package/dist/components/HtmlInlineNode.svelte.d.ts +23 -0
- package/dist/components/HtmlInlineNode.svelte.d.ts.map +1 -0
- package/dist/components/HtmlPreviewFrame.svelte +13 -0
- package/dist/components/HtmlPreviewFrame.svelte.d.ts +26 -0
- package/dist/components/HtmlPreviewFrame.svelte.d.ts.map +1 -0
- package/dist/components/ImageNode.svelte +86 -0
- package/dist/components/ImageNode.svelte.d.ts +25 -0
- package/dist/components/ImageNode.svelte.d.ts.map +1 -0
- package/dist/components/InfographicBlockNode.svelte +429 -0
- package/dist/components/InfographicBlockNode.svelte.d.ts +34 -0
- package/dist/components/InfographicBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/InlineCodeNode.svelte +7 -0
- package/dist/components/InlineCodeNode.svelte.d.ts +22 -0
- package/dist/components/InlineCodeNode.svelte.d.ts.map +1 -0
- package/dist/components/InlineWrapNode.svelte +10 -0
- package/dist/components/InlineWrapNode.svelte.d.ts +25 -0
- package/dist/components/InlineWrapNode.svelte.d.ts.map +1 -0
- package/dist/components/InsertNode.svelte +8 -0
- package/dist/components/InsertNode.svelte.d.ts +24 -0
- package/dist/components/InsertNode.svelte.d.ts.map +1 -0
- package/dist/components/LinkNode.svelte +41 -0
- package/dist/components/LinkNode.svelte.d.ts +25 -0
- package/dist/components/LinkNode.svelte.d.ts.map +1 -0
- package/dist/components/ListItemNode.svelte +9 -0
- package/dist/components/ListItemNode.svelte.d.ts +24 -0
- package/dist/components/ListItemNode.svelte.d.ts.map +1 -0
- package/dist/components/ListNode.svelte +16 -0
- package/dist/components/ListNode.svelte.d.ts +24 -0
- package/dist/components/ListNode.svelte.d.ts.map +1 -0
- package/dist/components/MarkdownCodeBlockNode.svelte +7 -0
- package/dist/components/MarkdownCodeBlockNode.svelte.d.ts +23 -0
- package/dist/components/MarkdownCodeBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/MathBlockNode.svelte +96 -0
- package/dist/components/MathBlockNode.svelte.d.ts +22 -0
- package/dist/components/MathBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/MathInlineNode.svelte +103 -0
- package/dist/components/MathInlineNode.svelte.d.ts +22 -0
- package/dist/components/MathInlineNode.svelte.d.ts.map +1 -0
- package/dist/components/MermaidBlockNode.svelte +557 -0
- package/dist/components/MermaidBlockNode.svelte.d.ts +40 -0
- package/dist/components/MermaidBlockNode.svelte.d.ts.map +1 -0
- package/dist/components/NodeOutlet.svelte +192 -0
- package/dist/components/NodeOutlet.svelte.d.ts +24 -0
- package/dist/components/NodeOutlet.svelte.d.ts.map +1 -0
- package/dist/components/NodeRenderer.svelte +349 -0
- package/dist/components/NodeRenderer.svelte.d.ts +64 -0
- package/dist/components/NodeRenderer.svelte.d.ts.map +1 -0
- package/dist/components/ParagraphNode.svelte +21 -0
- package/dist/components/ParagraphNode.svelte.d.ts +24 -0
- package/dist/components/ParagraphNode.svelte.d.ts.map +1 -0
- package/dist/components/PreCodeNode.svelte +13 -0
- package/dist/components/PreCodeNode.svelte.d.ts +22 -0
- package/dist/components/PreCodeNode.svelte.d.ts.map +1 -0
- package/dist/components/ReferenceNode.svelte +8 -0
- package/dist/components/ReferenceNode.svelte.d.ts +23 -0
- package/dist/components/ReferenceNode.svelte.d.ts.map +1 -0
- package/dist/components/RenderChildren.svelte +12 -0
- package/dist/components/RenderChildren.svelte.d.ts +24 -0
- package/dist/components/RenderChildren.svelte.d.ts.map +1 -0
- package/dist/components/StrikethroughNode.svelte +8 -0
- package/dist/components/StrikethroughNode.svelte.d.ts +24 -0
- package/dist/components/StrikethroughNode.svelte.d.ts.map +1 -0
- package/dist/components/StrongNode.svelte +8 -0
- package/dist/components/StrongNode.svelte.d.ts +24 -0
- package/dist/components/StrongNode.svelte.d.ts.map +1 -0
- package/dist/components/SubscriptNode.svelte +8 -0
- package/dist/components/SubscriptNode.svelte.d.ts +24 -0
- package/dist/components/SubscriptNode.svelte.d.ts.map +1 -0
- package/dist/components/SuperscriptNode.svelte +8 -0
- package/dist/components/SuperscriptNode.svelte.d.ts +24 -0
- package/dist/components/SuperscriptNode.svelte.d.ts.map +1 -0
- package/dist/components/TableNode.svelte +8 -0
- package/dist/components/TableNode.svelte.d.ts +23 -0
- package/dist/components/TableNode.svelte.d.ts.map +1 -0
- package/dist/components/TextNode.svelte +37 -0
- package/dist/components/TextNode.svelte.d.ts +25 -0
- package/dist/components/TextNode.svelte.d.ts.map +1 -0
- package/dist/components/ThematicBreakNode.svelte +1 -0
- package/dist/components/ThematicBreakNode.svelte.d.ts +27 -0
- package/dist/components/ThematicBreakNode.svelte.d.ts.map +1 -0
- package/dist/components/Tooltip.svelte +4 -0
- package/dist/components/Tooltip.svelte.d.ts +21 -0
- package/dist/components/Tooltip.svelte.d.ts.map +1 -0
- package/dist/components/VmrContainerNode.svelte +8 -0
- package/dist/components/VmrContainerNode.svelte.d.ts +23 -0
- package/dist/components/VmrContainerNode.svelte.d.ts.map +1 -0
- package/dist/components/shared/diagram-height.d.ts +10 -0
- package/dist/components/shared/diagram-height.d.ts.map +1 -0
- package/dist/components/shared/diagram-height.js +52 -0
- package/dist/components/shared/node-helpers.d.ts +108 -0
- package/dist/components/shared/node-helpers.d.ts.map +1 -0
- package/dist/components/shared/node-helpers.js +220 -0
- package/dist/components/shared/node-outlet-helpers.d.ts +9 -0
- package/dist/components/shared/node-outlet-helpers.d.ts.map +1 -0
- package/dist/components/shared/node-outlet-helpers.js +92 -0
- package/dist/components/shared/render-window.d.ts +19 -0
- package/dist/components/shared/render-window.d.ts.map +1 -0
- package/dist/components/shared/render-window.js +63 -0
- package/dist/components/shared/renderNodeHtml.d.ts +4 -0
- package/dist/components/shared/renderNodeHtml.d.ts.map +1 -0
- package/dist/components/shared/renderNodeHtml.js +19 -0
- package/dist/components/shared/rich-block-helpers.d.ts +7 -0
- package/dist/components/shared/rich-block-helpers.d.ts.map +1 -0
- package/dist/components/shared/rich-block-helpers.js +76 -0
- package/dist/customComponents.d.ts +10 -0
- package/dist/customComponents.d.ts.map +1 -0
- package/dist/customComponents.js +66 -0
- package/dist/enhanceRenderedHtml.d.ts +21 -0
- package/dist/enhanceRenderedHtml.d.ts.map +1 -0
- package/dist/enhanceRenderedHtml.js +768 -0
- package/dist/hydrateCustomTagContent.d.ts +3 -0
- package/dist/hydrateCustomTagContent.d.ts.map +1 -0
- package/dist/hydrateCustomTagContent.js +130 -0
- package/dist/i18n/useSafeI18n.d.ts +5 -0
- package/dist/i18n/useSafeI18n.d.ts.map +1 -0
- package/dist/i18n/useSafeI18n.js +42 -0
- package/dist/index.css +2009 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.px.css +2009 -0
- package/dist/index.tailwind.css +2009 -0
- package/dist/optional/d2.d.ts +7 -0
- package/dist/optional/d2.d.ts.map +1 -0
- package/dist/optional/d2.js +67 -0
- package/dist/optional/infographic.d.ts +2 -0
- package/dist/optional/infographic.d.ts.map +1 -0
- package/dist/optional/infographic.js +29 -0
- package/dist/optional/katex.d.ts +7 -0
- package/dist/optional/katex.d.ts.map +1 -0
- package/dist/optional/katex.js +93 -0
- package/dist/optional/mermaid.d.ts +7 -0
- package/dist/optional/mermaid.d.ts.map +1 -0
- package/dist/optional/mermaid.js +171 -0
- package/dist/optional/monaco.d.ts +5 -0
- package/dist/optional/monaco.d.ts.map +1 -0
- package/dist/optional/monaco.js +70 -0
- package/dist/parseNestedMarkdownToNodes.d.ts +15 -0
- package/dist/parseNestedMarkdownToNodes.d.ts.map +1 -0
- package/dist/parseNestedMarkdownToNodes.js +66 -0
- package/dist/renderMarkdownHtml.d.ts +31 -0
- package/dist/renderMarkdownHtml.d.ts.map +1 -0
- package/dist/renderMarkdownHtml.js +465 -0
- package/dist/sanitizeHtmlContent.d.ts +3 -0
- package/dist/sanitizeHtmlContent.d.ts.map +1 -0
- package/dist/sanitizeHtmlContent.js +175 -0
- package/dist/sanitizeSvg.d.ts +3 -0
- package/dist/sanitizeSvg.d.ts.map +1 -0
- package/dist/sanitizeSvg.js +76 -0
- package/dist/tailwind-entry.d.ts +2 -0
- package/dist/tailwind-entry.d.ts.map +1 -0
- package/dist/tailwind-entry.js +1 -0
- package/dist/tooltip/singletonTooltip.d.ts +8 -0
- package/dist/tooltip/singletonTooltip.d.ts.map +1 -0
- package/dist/tooltip/singletonTooltip.js +124 -0
- package/dist/types/monaco.d.ts +66 -0
- package/dist/types/monaco.d.ts.map +1 -0
- package/dist/types/monaco.js +1 -0
- package/dist/utils/languageIcon.d.ts +8 -0
- package/dist/utils/languageIcon.d.ts.map +1 -0
- package/dist/utils/languageIcon.js +182 -0
- package/dist/utils/normalizeKaTeXRenderInput.d.ts +2 -0
- package/dist/utils/normalizeKaTeXRenderInput.d.ts.map +1 -0
- package/dist/utils/normalizeKaTeXRenderInput.js +7 -0
- package/dist/workers/katexCdnWorker.d.ts +21 -0
- package/dist/workers/katexCdnWorker.d.ts.map +1 -0
- package/dist/workers/katexCdnWorker.js +193 -0
- package/dist/workers/katexRenderer.worker.d.ts +2 -0
- package/dist/workers/katexRenderer.worker.d.ts.map +1 -0
- package/dist/workers/katexRenderer.worker.js +55 -0
- package/dist/workers/katexWorkerClient.d.ts +36 -0
- package/dist/workers/katexWorkerClient.d.ts.map +1 -0
- package/dist/workers/katexWorkerClient.js +270 -0
- package/dist/workers/mermaidCdnWorker.d.ts +16 -0
- package/dist/workers/mermaidCdnWorker.d.ts.map +1 -0
- package/dist/workers/mermaidCdnWorker.js +235 -0
- package/dist/workers/mermaidParser.worker.d.ts +2 -0
- package/dist/workers/mermaidParser.worker.d.ts.map +1 -0
- package/dist/workers/mermaidParser.worker.js +85 -0
- package/dist/workers/mermaidWorkerClient.d.ts +16 -0
- package/dist/workers/mermaidWorkerClient.d.ts.map +1 -0
- package/dist/workers/mermaidWorkerClient.js +170 -0
- package/package.json +95 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type D2Loader = () => Promise<any> | any;
|
|
2
|
+
export declare function setD2Loader(loader: D2Loader | null): void;
|
|
3
|
+
export declare function enableD2(loader?: D2Loader): void;
|
|
4
|
+
export declare function disableD2(): void;
|
|
5
|
+
export declare function isD2Enabled(): boolean;
|
|
6
|
+
export declare function getD2(): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=d2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d2.d.ts","sourceRoot":"","sources":["../../src/optional/d2.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AA4B/C,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,QAGlD;AAED,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,QAEzC;AAED,wBAAgB,SAAS,SAExB;AAED,wBAAgB,WAAW,YAE1B;AAED,wBAAsB,KAAK,iBAmC1B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const defaultD2Loader = () => import('@terrastruct/d2');
|
|
2
|
+
let cachedD2 = null;
|
|
3
|
+
let d2Loader = defaultD2Loader;
|
|
4
|
+
let pendingImport = null;
|
|
5
|
+
function resetCachedD2() {
|
|
6
|
+
cachedD2 = null;
|
|
7
|
+
pendingImport = null;
|
|
8
|
+
}
|
|
9
|
+
function normalizeD2Module(mod) {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!mod)
|
|
12
|
+
return mod;
|
|
13
|
+
if (mod.D2 && typeof mod.D2 === 'function')
|
|
14
|
+
return mod.D2;
|
|
15
|
+
if (mod.default && mod.default.D2 && typeof mod.default.D2 === 'function')
|
|
16
|
+
return mod.default.D2;
|
|
17
|
+
const candidate = (_a = mod.default) !== null && _a !== void 0 ? _a : mod;
|
|
18
|
+
if (typeof candidate === 'function')
|
|
19
|
+
return candidate;
|
|
20
|
+
if ((candidate === null || candidate === void 0 ? void 0 : candidate.D2) && typeof candidate.D2 === 'function')
|
|
21
|
+
return candidate.D2;
|
|
22
|
+
return candidate;
|
|
23
|
+
}
|
|
24
|
+
export function setD2Loader(loader) {
|
|
25
|
+
d2Loader = loader;
|
|
26
|
+
resetCachedD2();
|
|
27
|
+
}
|
|
28
|
+
export function enableD2(loader) {
|
|
29
|
+
setD2Loader(loader !== null && loader !== void 0 ? loader : defaultD2Loader);
|
|
30
|
+
}
|
|
31
|
+
export function disableD2() {
|
|
32
|
+
setD2Loader(null);
|
|
33
|
+
}
|
|
34
|
+
export function isD2Enabled() {
|
|
35
|
+
return typeof d2Loader === 'function';
|
|
36
|
+
}
|
|
37
|
+
export async function getD2() {
|
|
38
|
+
if (cachedD2)
|
|
39
|
+
return cachedD2;
|
|
40
|
+
if (pendingImport)
|
|
41
|
+
return await pendingImport;
|
|
42
|
+
const loader = d2Loader;
|
|
43
|
+
if (!loader)
|
|
44
|
+
return null;
|
|
45
|
+
pendingImport = (async () => {
|
|
46
|
+
let mod;
|
|
47
|
+
try {
|
|
48
|
+
mod = await loader();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (loader === defaultD2Loader) {
|
|
52
|
+
throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
if (!mod)
|
|
57
|
+
return null;
|
|
58
|
+
cachedD2 = normalizeD2Module(mod);
|
|
59
|
+
return cachedD2;
|
|
60
|
+
})();
|
|
61
|
+
try {
|
|
62
|
+
return await pendingImport;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
pendingImport = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infographic.d.ts","sourceRoot":"","sources":["../../src/optional/infographic.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,iBA+BnC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
let infographicPromise = null;
|
|
2
|
+
let infographicInstance = null;
|
|
3
|
+
export async function getInfographic() {
|
|
4
|
+
if (infographicInstance)
|
|
5
|
+
return infographicInstance;
|
|
6
|
+
if (infographicPromise)
|
|
7
|
+
return await infographicPromise;
|
|
8
|
+
infographicPromise = import('@antv/infographic')
|
|
9
|
+
.then((mod) => {
|
|
10
|
+
const defaultExport = (mod && mod.default) ? mod.default : mod;
|
|
11
|
+
let resolved = defaultExport;
|
|
12
|
+
if (typeof defaultExport === 'function' && defaultExport.prototype && defaultExport.prototype.render) {
|
|
13
|
+
resolved = defaultExport;
|
|
14
|
+
}
|
|
15
|
+
else if (mod === null || mod === void 0 ? void 0 : mod.Infographic) {
|
|
16
|
+
resolved = mod.Infographic;
|
|
17
|
+
}
|
|
18
|
+
else if (defaultExport && defaultExport.Infographic) {
|
|
19
|
+
resolved = defaultExport.Infographic;
|
|
20
|
+
}
|
|
21
|
+
infographicInstance = resolved;
|
|
22
|
+
return resolved;
|
|
23
|
+
})
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
console.warn('[markstream-svelte] Failed to load @antv/infographic', error);
|
|
26
|
+
return null;
|
|
27
|
+
});
|
|
28
|
+
return await infographicPromise;
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type KatexLoader = () => Promise<any> | any;
|
|
2
|
+
export declare function setKatexLoader(loader: KatexLoader | null): void;
|
|
3
|
+
export declare function enableKatex(loader?: KatexLoader): void;
|
|
4
|
+
export declare function disableKatex(): void;
|
|
5
|
+
export declare function isKatexEnabled(): boolean;
|
|
6
|
+
export declare function getKatex(): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=katex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"katex.d.ts","sourceRoot":"","sources":["../../src/optional/katex.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AA+ClD,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,QAGxD;AAED,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,QAE/C;AAED,wBAAgB,YAAY,SAE3B;AAED,wBAAgB,cAAc,YAE7B;AAED,wBAAsB,QAAQ,iBA2C7B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
let katex = null;
|
|
2
|
+
let importAttempted = false;
|
|
3
|
+
let pendingImport = null;
|
|
4
|
+
let katexLoader = defaultKatexLoader;
|
|
5
|
+
function normalizeKatexModule(mod) {
|
|
6
|
+
var _a;
|
|
7
|
+
const resolved = (_a = mod === null || mod === void 0 ? void 0 : mod.default) !== null && _a !== void 0 ? _a : mod;
|
|
8
|
+
if (resolved && typeof resolved.renderToString === 'function')
|
|
9
|
+
return resolved;
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function getGlobalKatex() {
|
|
13
|
+
try {
|
|
14
|
+
const globalStore = globalThis;
|
|
15
|
+
return normalizeKatexModule(globalStore === null || globalStore === void 0 ? void 0 : globalStore.katex);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function defaultKatexLoader() {
|
|
22
|
+
return (async () => {
|
|
23
|
+
const globalKatex = getGlobalKatex();
|
|
24
|
+
if (globalKatex)
|
|
25
|
+
return globalKatex;
|
|
26
|
+
const mod = await import('katex');
|
|
27
|
+
try {
|
|
28
|
+
await import('katex/contrib/mhchem');
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Ignore optional mhchem support failures.
|
|
32
|
+
}
|
|
33
|
+
return normalizeKatexModule(mod);
|
|
34
|
+
})();
|
|
35
|
+
}
|
|
36
|
+
function resetCache() {
|
|
37
|
+
katex = null;
|
|
38
|
+
importAttempted = false;
|
|
39
|
+
pendingImport = null;
|
|
40
|
+
}
|
|
41
|
+
export function setKatexLoader(loader) {
|
|
42
|
+
katexLoader = loader;
|
|
43
|
+
resetCache();
|
|
44
|
+
}
|
|
45
|
+
export function enableKatex(loader) {
|
|
46
|
+
setKatexLoader(loader !== null && loader !== void 0 ? loader : defaultKatexLoader);
|
|
47
|
+
}
|
|
48
|
+
export function disableKatex() {
|
|
49
|
+
setKatexLoader(null);
|
|
50
|
+
}
|
|
51
|
+
export function isKatexEnabled() {
|
|
52
|
+
return typeof katexLoader === 'function';
|
|
53
|
+
}
|
|
54
|
+
export async function getKatex() {
|
|
55
|
+
const globalKatex = getGlobalKatex();
|
|
56
|
+
if (globalKatex) {
|
|
57
|
+
katex = globalKatex;
|
|
58
|
+
return katex;
|
|
59
|
+
}
|
|
60
|
+
if (katex)
|
|
61
|
+
return katex;
|
|
62
|
+
if (pendingImport)
|
|
63
|
+
return await pendingImport;
|
|
64
|
+
if (importAttempted)
|
|
65
|
+
return null;
|
|
66
|
+
const loader = katexLoader;
|
|
67
|
+
if (!loader) {
|
|
68
|
+
importAttempted = true;
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
pendingImport = (async () => {
|
|
72
|
+
var _a;
|
|
73
|
+
try {
|
|
74
|
+
const result = await loader();
|
|
75
|
+
const normalized = (_a = normalizeKatexModule(result)) !== null && _a !== void 0 ? _a : result;
|
|
76
|
+
if (normalized) {
|
|
77
|
+
katex = normalized;
|
|
78
|
+
return katex;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Swallow loader errors so callers can gracefully fall back.
|
|
83
|
+
}
|
|
84
|
+
importAttempted = true;
|
|
85
|
+
return null;
|
|
86
|
+
})();
|
|
87
|
+
try {
|
|
88
|
+
return await pendingImport;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
pendingImport = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type MermaidLoader = () => Promise<any> | any;
|
|
2
|
+
export declare function setMermaidLoader(loader: MermaidLoader | null): void;
|
|
3
|
+
export declare function enableMermaid(loader?: MermaidLoader): void;
|
|
4
|
+
export declare function disableMermaid(): void;
|
|
5
|
+
export declare function isMermaidEnabled(): boolean;
|
|
6
|
+
export declare function getMermaid(initConfig?: Record<string, any>): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../src/optional/mermaid.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AAqHpD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,QAG5D;AAED,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,QAEnD;AAED,wBAAgB,cAAc,SAE7B;AAED,wBAAgB,gBAAgB,YAE/B;AAED,wBAAsB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBA2DhE"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const defaultMermaidLoader = () => import('mermaid');
|
|
2
|
+
const GLOBAL_MERMAID_KEY = '__MARKSTREAM_ANGULAR_MERMAID__';
|
|
3
|
+
let cachedMermaid = null;
|
|
4
|
+
let importAttempted = false;
|
|
5
|
+
let lastInitKey = null;
|
|
6
|
+
let pendingImport = null;
|
|
7
|
+
let mermaidLoader = defaultMermaidLoader;
|
|
8
|
+
function computeInitKey(config) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const securityLevel = String((_a = config === null || config === void 0 ? void 0 : config.securityLevel) !== null && _a !== void 0 ? _a : 'strict');
|
|
11
|
+
const htmlLabels = (_b = config === null || config === void 0 ? void 0 : config.flowchart) === null || _b === void 0 ? void 0 : _b.htmlLabels;
|
|
12
|
+
return `${securityLevel}|htmlLabels:${htmlLabels === false ? '0' : '1'}`;
|
|
13
|
+
}
|
|
14
|
+
function normalizeMermaidModule(mod) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!mod)
|
|
17
|
+
return mod;
|
|
18
|
+
const candidate = (_a = mod === null || mod === void 0 ? void 0 : mod.default) !== null && _a !== void 0 ? _a : mod;
|
|
19
|
+
if (candidate && (typeof candidate.render === 'function' || typeof candidate.parse === 'function' || typeof candidate.initialize === 'function'))
|
|
20
|
+
return candidate;
|
|
21
|
+
if ((candidate === null || candidate === void 0 ? void 0 : candidate.mermaidAPI) && (typeof candidate.mermaidAPI.render === 'function' || typeof candidate.mermaidAPI.parse === 'function')) {
|
|
22
|
+
const api = candidate.mermaidAPI;
|
|
23
|
+
return {
|
|
24
|
+
...candidate,
|
|
25
|
+
render: api.render.bind(api),
|
|
26
|
+
parse: api.parse ? api.parse.bind(api) : undefined,
|
|
27
|
+
initialize: (opts) => {
|
|
28
|
+
if (typeof candidate.initialize === 'function')
|
|
29
|
+
return candidate.initialize(opts);
|
|
30
|
+
return api.initialize ? api.initialize(opts) : undefined;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if ((mod === null || mod === void 0 ? void 0 : mod.mermaid) && typeof mod.mermaid.render === 'function')
|
|
35
|
+
return mod.mermaid;
|
|
36
|
+
return candidate;
|
|
37
|
+
}
|
|
38
|
+
function patchInitialize(target) {
|
|
39
|
+
if (!target)
|
|
40
|
+
return;
|
|
41
|
+
try {
|
|
42
|
+
const originalInitialize = target === null || target === void 0 ? void 0 : target.initialize;
|
|
43
|
+
target.initialize = (opts) => {
|
|
44
|
+
const merged = { suppressErrorRendering: true, ...(opts || {}) };
|
|
45
|
+
if (typeof originalInitialize === 'function')
|
|
46
|
+
return originalInitialize.call(target, merged);
|
|
47
|
+
if ((target === null || target === void 0 ? void 0 : target.mermaidAPI) && typeof target.mermaidAPI.initialize === 'function')
|
|
48
|
+
return target.mermaidAPI.initialize(merged);
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Ignore patching failures and keep the original instance.
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function ensureInitialized(instance, config) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!instance || !config)
|
|
59
|
+
return;
|
|
60
|
+
const key = computeInitKey(config);
|
|
61
|
+
if (lastInitKey === key)
|
|
62
|
+
return;
|
|
63
|
+
try {
|
|
64
|
+
if (typeof instance.initialize === 'function')
|
|
65
|
+
instance.initialize(config);
|
|
66
|
+
else if ((_a = instance.mermaidAPI) === null || _a === void 0 ? void 0 : _a.initialize)
|
|
67
|
+
instance.mermaidAPI.initialize(config);
|
|
68
|
+
lastInitKey = key;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Mermaid may already be initialized; keep going.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function getGlobalMermaid() {
|
|
75
|
+
var _a;
|
|
76
|
+
try {
|
|
77
|
+
const globalStore = globalThis;
|
|
78
|
+
return normalizeMermaidModule((_a = globalStore === null || globalStore === void 0 ? void 0 : globalStore[GLOBAL_MERMAID_KEY]) !== null && _a !== void 0 ? _a : globalStore === null || globalStore === void 0 ? void 0 : globalStore.mermaid);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function setGlobalMermaid(instance) {
|
|
85
|
+
try {
|
|
86
|
+
;
|
|
87
|
+
globalThis[GLOBAL_MERMAID_KEY] = instance;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Ignore global cache writes when the host forbids mutation.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function resetCachedMermaid() {
|
|
94
|
+
cachedMermaid = null;
|
|
95
|
+
importAttempted = false;
|
|
96
|
+
lastInitKey = null;
|
|
97
|
+
pendingImport = null;
|
|
98
|
+
try {
|
|
99
|
+
delete globalThis[GLOBAL_MERMAID_KEY];
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Ignore failures when the global object is sealed.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function setMermaidLoader(loader) {
|
|
106
|
+
mermaidLoader = loader;
|
|
107
|
+
resetCachedMermaid();
|
|
108
|
+
}
|
|
109
|
+
export function enableMermaid(loader) {
|
|
110
|
+
setMermaidLoader(loader !== null && loader !== void 0 ? loader : defaultMermaidLoader);
|
|
111
|
+
}
|
|
112
|
+
export function disableMermaid() {
|
|
113
|
+
setMermaidLoader(null);
|
|
114
|
+
}
|
|
115
|
+
export function isMermaidEnabled() {
|
|
116
|
+
return typeof mermaidLoader === 'function';
|
|
117
|
+
}
|
|
118
|
+
export async function getMermaid(initConfig) {
|
|
119
|
+
if (cachedMermaid) {
|
|
120
|
+
ensureInitialized(cachedMermaid, initConfig);
|
|
121
|
+
return cachedMermaid;
|
|
122
|
+
}
|
|
123
|
+
const globalMermaid = getGlobalMermaid();
|
|
124
|
+
if (globalMermaid) {
|
|
125
|
+
patchInitialize(globalMermaid);
|
|
126
|
+
cachedMermaid = globalMermaid;
|
|
127
|
+
setGlobalMermaid(cachedMermaid);
|
|
128
|
+
ensureInitialized(cachedMermaid, initConfig);
|
|
129
|
+
return cachedMermaid;
|
|
130
|
+
}
|
|
131
|
+
if (pendingImport) {
|
|
132
|
+
const instance = await pendingImport;
|
|
133
|
+
if (instance)
|
|
134
|
+
ensureInitialized(instance, initConfig);
|
|
135
|
+
return instance;
|
|
136
|
+
}
|
|
137
|
+
if (importAttempted)
|
|
138
|
+
return null;
|
|
139
|
+
const loader = mermaidLoader;
|
|
140
|
+
if (!loader) {
|
|
141
|
+
importAttempted = true;
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
pendingImport = (async () => {
|
|
145
|
+
try {
|
|
146
|
+
const mod = await loader();
|
|
147
|
+
const instance = normalizeMermaidModule(mod);
|
|
148
|
+
if (!instance) {
|
|
149
|
+
importAttempted = true;
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
patchInitialize(instance);
|
|
153
|
+
cachedMermaid = instance;
|
|
154
|
+
setGlobalMermaid(cachedMermaid);
|
|
155
|
+
return cachedMermaid;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
importAttempted = true;
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
try {
|
|
163
|
+
const instance = await pendingImport;
|
|
164
|
+
if (instance)
|
|
165
|
+
ensureInitialized(instance, initConfig);
|
|
166
|
+
return instance;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
pendingImport = null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isCodeBlockRuntimeReady(): boolean;
|
|
2
|
+
export declare function resetCodeBlockRuntimeReadyForTest(): void;
|
|
3
|
+
export declare function preloadCodeBlockRuntime(): Promise<boolean>;
|
|
4
|
+
export declare function getUseMonaco(): Promise<any>;
|
|
5
|
+
//# sourceMappingURL=monaco.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco.d.ts","sourceRoot":"","sources":["../../src/optional/monaco.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,YAEtC;AAED,wBAAgB,iCAAiC,SAEhD;AAED,wBAAsB,uBAAuB,qBAG5C;AAoCD,wBAAsB,YAAY,iBA6BjC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
let monacoModule = null;
|
|
2
|
+
let importAttempted = false;
|
|
3
|
+
let pendingImport = null;
|
|
4
|
+
let workersPreloaded = false;
|
|
5
|
+
let codeBlockRuntimeReady = false;
|
|
6
|
+
export function isCodeBlockRuntimeReady() {
|
|
7
|
+
return codeBlockRuntimeReady;
|
|
8
|
+
}
|
|
9
|
+
export function resetCodeBlockRuntimeReadyForTest() {
|
|
10
|
+
codeBlockRuntimeReady = false;
|
|
11
|
+
}
|
|
12
|
+
export async function preloadCodeBlockRuntime() {
|
|
13
|
+
const runtime = await getUseMonaco();
|
|
14
|
+
return !!runtime;
|
|
15
|
+
}
|
|
16
|
+
async function preloadWorkers(mod) {
|
|
17
|
+
if (workersPreloaded)
|
|
18
|
+
return;
|
|
19
|
+
workersPreloaded = true;
|
|
20
|
+
const existingEnv = globalThis === null || globalThis === void 0 ? void 0 : globalThis.MonacoEnvironment;
|
|
21
|
+
if (existingEnv && (typeof existingEnv.getWorker === 'function' || typeof existingEnv.getWorkerUrl === 'function'))
|
|
22
|
+
return;
|
|
23
|
+
if (typeof (mod === null || mod === void 0 ? void 0 : mod.preloadMonacoWorkers) === 'function')
|
|
24
|
+
await mod.preloadMonacoWorkers();
|
|
25
|
+
}
|
|
26
|
+
async function warmupShikiTokenizer(mod) {
|
|
27
|
+
const getOrCreateHighlighter = mod === null || mod === void 0 ? void 0 : mod.getOrCreateHighlighter;
|
|
28
|
+
if (typeof getOrCreateHighlighter !== 'function')
|
|
29
|
+
return true;
|
|
30
|
+
try {
|
|
31
|
+
const highlighter = await getOrCreateHighlighter(['vitesse-dark', 'vitesse-light'], ['plaintext', 'text', 'javascript']);
|
|
32
|
+
if (highlighter && typeof highlighter.codeToTokens === 'function') {
|
|
33
|
+
highlighter.codeToTokens('const a = 1', { lang: 'javascript', theme: 'vitesse-dark' });
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.warn('[markstream-svelte] Failed to warm up stream-monaco tokenizer.', error);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function getUseMonaco() {
|
|
43
|
+
if (monacoModule)
|
|
44
|
+
return monacoModule;
|
|
45
|
+
if (pendingImport)
|
|
46
|
+
return await pendingImport;
|
|
47
|
+
if (importAttempted)
|
|
48
|
+
return null;
|
|
49
|
+
pendingImport = (async () => {
|
|
50
|
+
var _a;
|
|
51
|
+
try {
|
|
52
|
+
const imported = await import('stream-monaco');
|
|
53
|
+
monacoModule = (_a = imported === null || imported === void 0 ? void 0 : imported.default) !== null && _a !== void 0 ? _a : imported;
|
|
54
|
+
await preloadWorkers(monacoModule);
|
|
55
|
+
codeBlockRuntimeReady = true;
|
|
56
|
+
void warmupShikiTokenizer(monacoModule);
|
|
57
|
+
return monacoModule;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
importAttempted = true;
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
try {
|
|
65
|
+
return await pendingImport;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
pendingImport = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BaseNode, MarkdownIt, ParseOptions } from 'stream-markdown-parser';
|
|
2
|
+
export interface NestedMarkdownNodesInput {
|
|
3
|
+
node?: (BaseNode & Record<string, any>) | null;
|
|
4
|
+
nodes?: readonly BaseNode[] | null;
|
|
5
|
+
content?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface NestedMarkdownNodesOptions {
|
|
8
|
+
cacheKey?: string;
|
|
9
|
+
final?: boolean;
|
|
10
|
+
parseOptions?: ParseOptions;
|
|
11
|
+
customHtmlTags?: readonly string[];
|
|
12
|
+
customMarkdownIt?: (markdown: MarkdownIt) => MarkdownIt;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseNestedMarkdownToNodes(input: NestedMarkdownNodesInput, options?: NestedMarkdownNodesOptions): BaseNode[];
|
|
15
|
+
//# sourceMappingURL=parseNestedMarkdownToNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseNestedMarkdownToNodes.d.ts","sourceRoot":"","sources":["../src/parseNestedMarkdownToNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAIhF,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAA;IAC9C,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAA;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,KAAK,UAAU,CAAA;CACxD;AAKD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,wBAAwB,EAC/B,OAAO,GAAE,0BAA+B,GACvC,QAAQ,EAAE,CAsBZ"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getMarkdown, mergeCustomHtmlTags, parseMarkdownToStructure } from 'stream-markdown-parser';
|
|
2
|
+
import { hydrateCustomTagContent } from './hydrateCustomTagContent';
|
|
3
|
+
const DEFAULT_CACHE_KEY = 'markstream-svelte-nested-nodes';
|
|
4
|
+
const markdownCache = new Map();
|
|
5
|
+
export function parseNestedMarkdownToNodes(input, options = {}) {
|
|
6
|
+
if (Array.isArray(input.nodes))
|
|
7
|
+
return input.nodes.slice();
|
|
8
|
+
const nestedNode = input.node;
|
|
9
|
+
if (nestedNode) {
|
|
10
|
+
const children = getNodeList(nestedNode.children);
|
|
11
|
+
if (children.length > 0)
|
|
12
|
+
return children.slice();
|
|
13
|
+
}
|
|
14
|
+
const content = resolveContent(input);
|
|
15
|
+
if (!content)
|
|
16
|
+
return [];
|
|
17
|
+
const parseOptions = resolveParseOptions(input, options);
|
|
18
|
+
const markdown = resolveMarkdownInstance(options);
|
|
19
|
+
return hydrateCustomTagContent(parseMarkdownToStructure(content, markdown, parseOptions), content, mergeCustomHtmlTags(options.customHtmlTags, parseOptions === null || parseOptions === void 0 ? void 0 : parseOptions.customHtmlTags));
|
|
20
|
+
}
|
|
21
|
+
function resolveContent(input) {
|
|
22
|
+
var _a;
|
|
23
|
+
if (typeof input.content === 'string')
|
|
24
|
+
return input.content;
|
|
25
|
+
if (typeof ((_a = input.node) === null || _a === void 0 ? void 0 : _a.content) === 'string')
|
|
26
|
+
return input.node.content;
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
function resolveParseOptions(input, options) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const base = (_a = options.parseOptions) !== null && _a !== void 0 ? _a : {};
|
|
32
|
+
const resolvedFinal = (_b = options.final) !== null && _b !== void 0 ? _b : resolveFinalFromNode(input.node);
|
|
33
|
+
const customHtmlTags = mergeCustomHtmlTags(options.customHtmlTags, base.customHtmlTags);
|
|
34
|
+
if (resolvedFinal == null && customHtmlTags.length === 0)
|
|
35
|
+
return base;
|
|
36
|
+
return {
|
|
37
|
+
...base,
|
|
38
|
+
...(resolvedFinal == null ? {} : { final: resolvedFinal }),
|
|
39
|
+
...(customHtmlTags.length === 0 ? {} : { customHtmlTags }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function resolveFinalFromNode(node) {
|
|
43
|
+
if (!node || typeof node !== 'object')
|
|
44
|
+
return undefined;
|
|
45
|
+
if (typeof node.loading === 'boolean')
|
|
46
|
+
return !node.loading;
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
function resolveMarkdownInstance(options) {
|
|
50
|
+
var _a;
|
|
51
|
+
const normalizedTags = mergeCustomHtmlTags(options.customHtmlTags, (_a = options.parseOptions) === null || _a === void 0 ? void 0 : _a.customHtmlTags);
|
|
52
|
+
const cacheKey = `${options.cacheKey || DEFAULT_CACHE_KEY}::${normalizedTags.join(',')}`;
|
|
53
|
+
let markdown = markdownCache.get(cacheKey);
|
|
54
|
+
if (!markdown) {
|
|
55
|
+
markdown = getMarkdown(cacheKey, {
|
|
56
|
+
customHtmlTags: normalizedTags,
|
|
57
|
+
});
|
|
58
|
+
markdownCache.set(cacheKey, markdown);
|
|
59
|
+
}
|
|
60
|
+
return options.customMarkdownIt
|
|
61
|
+
? options.customMarkdownIt(markdown)
|
|
62
|
+
: markdown;
|
|
63
|
+
}
|
|
64
|
+
function getNodeList(value) {
|
|
65
|
+
return Array.isArray(value) ? value : [];
|
|
66
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BaseNode, HtmlPolicy, ParsedNode, ParseOptions } from 'stream-markdown-parser';
|
|
2
|
+
export type RenderableMarkdownNode = (ParsedNode | BaseNode) & Record<string, unknown>;
|
|
3
|
+
type NestedClassValue = string | readonly string[] | null | undefined;
|
|
4
|
+
export interface MarkstreamSvelteRenderOptions {
|
|
5
|
+
content?: string | null;
|
|
6
|
+
nodes?: readonly RenderableMarkdownNode[] | null;
|
|
7
|
+
final?: boolean;
|
|
8
|
+
parseOptions?: ParseOptions;
|
|
9
|
+
customHtmlTags?: readonly string[];
|
|
10
|
+
allowHtml?: boolean;
|
|
11
|
+
htmlPolicy?: HtmlPolicy;
|
|
12
|
+
}
|
|
13
|
+
export interface NestedMarkdownHtmlOptions {
|
|
14
|
+
cacheKey?: string;
|
|
15
|
+
customHtmlTags?: readonly string[];
|
|
16
|
+
allowHtml?: boolean;
|
|
17
|
+
htmlPolicy?: HtmlPolicy;
|
|
18
|
+
customNodeTag?: string;
|
|
19
|
+
customNodeClass?: NestedClassValue | ((node: RenderableMarkdownNode) => NestedClassValue);
|
|
20
|
+
}
|
|
21
|
+
export interface NestedMarkdownHtmlInput {
|
|
22
|
+
node?: RenderableMarkdownNode | null;
|
|
23
|
+
nodes?: readonly RenderableMarkdownNode[] | null;
|
|
24
|
+
content?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function renderMarkdownToHtml(input: MarkstreamSvelteRenderOptions): string;
|
|
27
|
+
export declare function renderNestedMarkdownToHtml(input: NestedMarkdownHtmlInput, options?: NestedMarkdownHtmlOptions): string;
|
|
28
|
+
export declare function renderMarkdownNodesToHtml(nodes: readonly RenderableMarkdownNode[] | null | undefined, options?: NestedMarkdownHtmlOptions): string;
|
|
29
|
+
export declare function renderMarkdownNodeToHtml(node: RenderableMarkdownNode | null | undefined, options?: NestedMarkdownHtmlOptions): string;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=renderMarkdownHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderMarkdownHtml.d.ts","sourceRoot":"","sources":["../src/renderMarkdownHtml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAwB,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAclH,MAAM,MAAM,sBAAsB,GAAG,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEtF,KAAK,gBAAgB,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;AAErE,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,CAAC,EAAE,SAAS,sBAAsB,EAAE,GAAG,IAAI,CAAA;IAChD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,IAAI,EAAE,sBAAsB,KAAK,gBAAgB,CAAC,CAAA;CAC1F;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,sBAAsB,EAAE,GAAG,IAAI,CAAA;IAChD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAiDD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,6BAA6B,GAAG,MAAM,CAYjF;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAGR;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,sBAAsB,EAAE,GAAG,IAAI,GAAG,SAAS,EAC3D,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAGR;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,sBAAsB,GAAG,IAAI,GAAG,SAAS,EAC/C,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAGR"}
|