mdx-forge 0.1.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/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/components/base/styles/callout.css +64 -0
- package/dist/components/base/styles/collapsible.css +96 -0
- package/dist/components/base/styles/index.css +7 -0
- package/dist/components/base/styles/tabs.css +97 -0
- package/dist/components/docusaurus/styles.css +291 -0
- package/dist/components/generic/styles.css +102 -0
- package/dist/components/nextra/styles.css +500 -0
- package/dist/components/shared/callout-variants.css +81 -0
- package/dist/components/shared/index.css +6 -0
- package/dist/components/shared/tokens.css +105 -0
- package/dist/components/starlight/styles.css +602 -0
- package/dist/components/styles/docusaurus.css +2 -0
- package/dist/components/styles/generic.css +2 -0
- package/dist/components/styles/nextjs.css +1 -0
- package/dist/components/styles/nextra.css +2 -0
- package/dist/components/styles/starlight.css +2 -0
- package/dist/components/styles/tokens.css +1 -0
- package/dist/esm/browser/errors.js +48 -0
- package/dist/esm/browser/eval/evaluateModule.js +49 -0
- package/dist/esm/browser/index.js +147 -0
- package/dist/esm/browser/internal/constants.js +4 -0
- package/dist/esm/browser/internal/logger.js +9 -0
- package/dist/esm/browser/internal/lru-cache.js +139 -0
- package/dist/esm/browser/internal/module-id.js +7 -0
- package/dist/esm/browser/internal/runtime-config.js +35 -0
- package/dist/esm/browser/internal/semaphore.js +23 -0
- package/dist/esm/browser/internal/style-injector.js +32 -0
- package/dist/esm/browser/loader/circular.js +15 -0
- package/dist/esm/browser/loader/loadModule.js +175 -0
- package/dist/esm/browser/preload/core.js +16 -0
- package/dist/esm/browser/preload/index.js +77 -0
- package/dist/esm/browser/preload/shimLoader.js +88 -0
- package/dist/esm/browser/registry/DependencyTracker.js +154 -0
- package/dist/esm/browser/registry/ModuleCache.js +168 -0
- package/dist/esm/browser/registry/ModuleRegistry.js +156 -0
- package/dist/esm/browser/registry/StyleCache.js +94 -0
- package/dist/esm/browser/registry/index.js +4 -0
- package/dist/esm/browser/runtime/require.js +40 -0
- package/dist/esm/browser/styles/injectStyles.js +42 -0
- package/dist/esm/browser/types.js +8 -0
- package/dist/esm/compiler/index.js +9 -0
- package/dist/esm/compiler/internal/components.js +28 -0
- package/dist/esm/compiler/internal/logging.js +10 -0
- package/dist/esm/compiler/internal/path.js +17 -0
- package/dist/esm/compiler/internal/plugin-loader.js +23 -0
- package/dist/esm/compiler/internal/trust.js +16 -0
- package/dist/esm/compiler/pipeline/common/icon-registry.js +1 -0
- package/dist/esm/compiler/pipeline/common/mdx-common.js +61 -0
- package/dist/esm/compiler/pipeline/common/pipeline-config.js +163 -0
- package/dist/esm/compiler/pipeline/common/pipeline-warnings.js +125 -0
- package/dist/esm/compiler/pipeline/rehype/create-diagram-placeholder.js +79 -0
- package/dist/esm/compiler/pipeline/rehype/graphviz-placeholder.js +15 -0
- package/dist/esm/compiler/pipeline/rehype/lazy-images.js +19 -0
- package/dist/esm/compiler/pipeline/rehype/mermaid-placeholder.js +11 -0
- package/dist/esm/compiler/pipeline/rehype/plantuml-placeholder.js +11 -0
- package/dist/esm/compiler/pipeline/rehype/rehype-raw.js +33 -0
- package/dist/esm/compiler/pipeline/rehype/shiki-helpers.js +9 -0
- package/dist/esm/compiler/pipeline/rehype/shiki.js +318 -0
- package/dist/esm/compiler/pipeline/remark/admonitions.js +168 -0
- package/dist/esm/compiler/pipeline/remark/generic-components.js +56 -0
- package/dist/esm/compiler/pipeline/remark/github-alerts.js +121 -0
- package/dist/esm/compiler/pipeline/transforms/callout.js +78 -0
- package/dist/esm/compiler/pipeline/transforms/code-group.js +23 -0
- package/dist/esm/compiler/pipeline/transforms/collapsible.js +30 -0
- package/dist/esm/compiler/pipeline/transforms/index.js +12 -0
- package/dist/esm/compiler/pipeline/transforms/tabs.js +48 -0
- package/dist/esm/compiler/pipeline/transforms/utils.js +69 -0
- package/dist/esm/compiler/plugins/builder.js +54 -0
- package/dist/esm/compiler/plugins/index.js +3 -0
- package/dist/esm/compiler/plugins/loader.js +120 -0
- package/dist/esm/compiler/plugins/shared-plugins.js +56 -0
- package/dist/esm/compiler/plugins/utils.js +13 -0
- package/dist/esm/compiler/safe/compile.js +228 -0
- package/dist/esm/compiler/transforms/index.js +1 -0
- package/dist/esm/compiler/trusted/compile.js +134 -0
- package/dist/esm/compiler/trusted/component-mapper.js +85 -0
- package/dist/esm/compiler/trusted/hasDefaultExport.js +15 -0
- package/dist/esm/compiler/types/compiler.js +1 -0
- package/dist/esm/compiler/types/index.js +3 -0
- package/dist/esm/compiler/types/mdx.js +3 -0
- package/dist/esm/compiler/types/pipeline.js +18 -0
- package/dist/esm/components/base/BaseCallout.js +50 -0
- package/dist/esm/components/base/BaseCard.js +11 -0
- package/dist/esm/components/base/BaseCodeBlock.js +42 -0
- package/dist/esm/components/base/BaseTabs.js +168 -0
- package/dist/esm/components/base/CopyButton.js +12 -0
- package/dist/esm/components/base/createCollapsible.js +63 -0
- package/dist/esm/components/base/createIconComponent.js +31 -0
- package/dist/esm/components/base/extractTextContent.js +19 -0
- package/dist/esm/components/base/icons.js +49 -0
- package/dist/esm/components/base/index.js +15 -0
- package/dist/esm/components/base/useCopyToClipboard.js +17 -0
- package/dist/esm/components/base/useTabState.js +113 -0
- package/dist/esm/components/docusaurus/CodeBlock.js +13 -0
- package/dist/esm/components/docusaurus/Details.js +18 -0
- package/dist/esm/components/docusaurus/Tabs.js +15 -0
- package/dist/esm/components/docusaurus/index.js +3 -0
- package/dist/esm/components/generic/Callout.js +28 -0
- package/dist/esm/components/generic/CodeGroup.js +52 -0
- package/dist/esm/components/generic/Collapsible.js +21 -0
- package/dist/esm/components/generic/TabItem.js +8 -0
- package/dist/esm/components/generic/Tabs.js +13 -0
- package/dist/esm/components/generic/index.js +6 -0
- package/dist/esm/components/generic/types.js +5 -0
- package/dist/esm/components/index.js +8 -0
- package/dist/esm/components/internal/clipboard.js +9 -0
- package/dist/esm/components/internal/cn.js +4 -0
- package/dist/esm/components/internal/constants.js +1 -0
- package/dist/esm/components/nextjs/Image.js +36 -0
- package/dist/esm/components/nextjs/Link.js +28 -0
- package/dist/esm/components/nextjs/index.js +2 -0
- package/dist/esm/components/nextra/Bleed.js +18 -0
- package/dist/esm/components/nextra/Callout.js +30 -0
- package/dist/esm/components/nextra/Cards.js +25 -0
- package/dist/esm/components/nextra/FileTree.js +11 -0
- package/dist/esm/components/nextra/Steps.js +11 -0
- package/dist/esm/components/nextra/Tabs.js +28 -0
- package/dist/esm/components/nextra/createNextraWrapper.js +12 -0
- package/dist/esm/components/nextra/index.js +6 -0
- package/dist/esm/components/registry/index.js +4 -0
- package/dist/esm/components/registry/queries.js +69 -0
- package/dist/esm/components/registry/registry-data.js +357 -0
- package/dist/esm/components/registry/shim-config.js +187 -0
- package/dist/esm/components/registry/types.js +3 -0
- package/dist/esm/components/starlight/Aside.js +24 -0
- package/dist/esm/components/starlight/Badge.js +6 -0
- package/dist/esm/components/starlight/Card.js +28 -0
- package/dist/esm/components/starlight/CardGrid.js +6 -0
- package/dist/esm/components/starlight/Code.js +25 -0
- package/dist/esm/components/starlight/FileTree.js +148 -0
- package/dist/esm/components/starlight/LinkCard.js +8 -0
- package/dist/esm/components/starlight/Steps.js +6 -0
- package/dist/esm/components/starlight/Tabs.js +6 -0
- package/dist/esm/components/starlight/index.js +9 -0
- package/dist/esm/internal/callout.js +43 -0
- package/dist/esm/internal/errors.js +27 -0
- package/dist/esm/internal/icons.js +41 -0
- package/dist/types/browser/errors.d.ts +18 -0
- package/dist/types/browser/eval/evaluateModule.d.ts +2 -0
- package/dist/types/browser/index.d.ts +20 -0
- package/dist/types/browser/internal/constants.d.ts +4 -0
- package/dist/types/browser/internal/logger.d.ts +9 -0
- package/dist/types/browser/internal/lru-cache.d.ts +33 -0
- package/dist/types/browser/internal/module-id.d.ts +1 -0
- package/dist/types/browser/internal/runtime-config.d.ts +10 -0
- package/dist/types/browser/internal/semaphore.d.ts +7 -0
- package/dist/types/browser/internal/style-injector.d.ts +3 -0
- package/dist/types/browser/loader/circular.d.ts +4 -0
- package/dist/types/browser/loader/loadModule.d.ts +2 -0
- package/dist/types/browser/preload/core.d.ts +11 -0
- package/dist/types/browser/preload/index.d.ts +21 -0
- package/dist/types/browser/preload/shimLoader.d.ts +20 -0
- package/dist/types/browser/registry/DependencyTracker.d.ts +23 -0
- package/dist/types/browser/registry/ModuleCache.d.ts +30 -0
- package/dist/types/browser/registry/ModuleRegistry.d.ts +44 -0
- package/dist/types/browser/registry/StyleCache.d.ts +17 -0
- package/dist/types/browser/registry/index.d.ts +4 -0
- package/dist/types/browser/runtime/require.d.ts +1 -0
- package/dist/types/browser/styles/injectStyles.d.ts +3 -0
- package/dist/types/browser/types.d.ts +50 -0
- package/dist/types/compiler/index.d.ts +6 -0
- package/dist/types/compiler/internal/components.d.ts +21 -0
- package/dist/types/compiler/internal/logging.d.ts +3 -0
- package/dist/types/compiler/internal/path.d.ts +2 -0
- package/dist/types/compiler/internal/plugin-loader.d.ts +2 -0
- package/dist/types/compiler/internal/trust.d.ts +2 -0
- package/dist/types/compiler/pipeline/common/icon-registry.d.ts +1 -0
- package/dist/types/compiler/pipeline/common/mdx-common.d.ts +8 -0
- package/dist/types/compiler/pipeline/common/pipeline-config.d.ts +39 -0
- package/dist/types/compiler/pipeline/common/pipeline-warnings.d.ts +21 -0
- package/dist/types/compiler/pipeline/rehype/create-diagram-placeholder.d.ts +15 -0
- package/dist/types/compiler/pipeline/rehype/graphviz-placeholder.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/lazy-images.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/mermaid-placeholder.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/plantuml-placeholder.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/rehype-raw.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/shiki-helpers.d.ts +2 -0
- package/dist/types/compiler/pipeline/rehype/shiki.d.ts +2 -0
- package/dist/types/compiler/pipeline/remark/admonitions.d.ts +2 -0
- package/dist/types/compiler/pipeline/remark/generic-components.d.ts +6 -0
- package/dist/types/compiler/pipeline/remark/github-alerts.d.ts +2 -0
- package/dist/types/compiler/pipeline/transforms/callout.d.ts +10 -0
- package/dist/types/compiler/pipeline/transforms/code-group.d.ts +3 -0
- package/dist/types/compiler/pipeline/transforms/collapsible.d.ts +3 -0
- package/dist/types/compiler/pipeline/transforms/index.d.ts +6 -0
- package/dist/types/compiler/pipeline/transforms/tabs.d.ts +4 -0
- package/dist/types/compiler/pipeline/transforms/utils.d.ts +6 -0
- package/dist/types/compiler/plugins/builder.d.ts +14 -0
- package/dist/types/compiler/plugins/index.d.ts +3 -0
- package/dist/types/compiler/plugins/loader.d.ts +4 -0
- package/dist/types/compiler/plugins/shared-plugins.d.ts +13 -0
- package/dist/types/compiler/plugins/utils.d.ts +4 -0
- package/dist/types/compiler/safe/compile.d.ts +2 -0
- package/dist/types/compiler/transforms/index.d.ts +1 -0
- package/dist/types/compiler/trusted/compile.d.ts +2 -0
- package/dist/types/compiler/trusted/component-mapper.d.ts +10 -0
- package/dist/types/compiler/trusted/hasDefaultExport.d.ts +2 -0
- package/dist/types/compiler/types/compiler.d.ts +83 -0
- package/dist/types/compiler/types/index.d.ts +3 -0
- package/dist/types/compiler/types/mdx.d.ts +36 -0
- package/dist/types/compiler/types/pipeline.d.ts +54 -0
- package/dist/types/components/base/BaseCallout.d.ts +26 -0
- package/dist/types/components/base/BaseCard.d.ts +11 -0
- package/dist/types/components/base/BaseCodeBlock.d.ts +23 -0
- package/dist/types/components/base/BaseTabs.d.ts +52 -0
- package/dist/types/components/base/CopyButton.d.ts +8 -0
- package/dist/types/components/base/createCollapsible.d.ts +27 -0
- package/dist/types/components/base/createIconComponent.d.ts +6 -0
- package/dist/types/components/base/extractTextContent.d.ts +2 -0
- package/dist/types/components/base/icons.d.ts +50 -0
- package/dist/types/components/base/index.d.ts +12 -0
- package/dist/types/components/base/useCopyToClipboard.d.ts +5 -0
- package/dist/types/components/base/useTabState.d.ts +43 -0
- package/dist/types/components/docusaurus/CodeBlock.d.ts +3 -0
- package/dist/types/components/docusaurus/Details.d.ts +4 -0
- package/dist/types/components/docusaurus/Tabs.d.ts +7 -0
- package/dist/types/components/docusaurus/index.d.ts +3 -0
- package/dist/types/components/generic/Callout.d.ts +8 -0
- package/dist/types/components/generic/CodeGroup.d.ts +4 -0
- package/dist/types/components/generic/Collapsible.d.ts +4 -0
- package/dist/types/components/generic/TabItem.d.ts +6 -0
- package/dist/types/components/generic/Tabs.d.ts +6 -0
- package/dist/types/components/generic/index.d.ts +6 -0
- package/dist/types/components/generic/types.d.ts +19 -0
- package/dist/types/components/index.d.ts +7 -0
- package/dist/types/components/internal/clipboard.d.ts +1 -0
- package/dist/types/components/internal/cn.d.ts +1 -0
- package/dist/types/components/internal/constants.d.ts +1 -0
- package/dist/types/components/nextjs/Image.d.ts +25 -0
- package/dist/types/components/nextjs/Link.d.ts +19 -0
- package/dist/types/components/nextjs/index.d.ts +2 -0
- package/dist/types/components/nextra/Bleed.d.ts +17 -0
- package/dist/types/components/nextra/Callout.d.ts +10 -0
- package/dist/types/components/nextra/Cards.d.ts +18 -0
- package/dist/types/components/nextra/FileTree.d.ts +4 -0
- package/dist/types/components/nextra/Steps.d.ts +4 -0
- package/dist/types/components/nextra/Tabs.d.ts +21 -0
- package/dist/types/components/nextra/createNextraWrapper.d.ts +14 -0
- package/dist/types/components/nextra/index.d.ts +6 -0
- package/dist/types/components/registry/index.d.ts +4 -0
- package/dist/types/components/registry/queries.d.ts +11 -0
- package/dist/types/components/registry/registry-data.d.ts +303 -0
- package/dist/types/components/registry/shim-config.d.ts +18 -0
- package/dist/types/components/registry/types.d.ts +25 -0
- package/dist/types/components/starlight/Aside.d.ts +6 -0
- package/dist/types/components/starlight/Badge.d.ts +9 -0
- package/dist/types/components/starlight/Card.d.ts +8 -0
- package/dist/types/components/starlight/CardGrid.d.ts +7 -0
- package/dist/types/components/starlight/Code.d.ts +11 -0
- package/dist/types/components/starlight/FileTree.d.ts +6 -0
- package/dist/types/components/starlight/LinkCard.d.ts +8 -0
- package/dist/types/components/starlight/Steps.d.ts +6 -0
- package/dist/types/components/starlight/Tabs.d.ts +2 -0
- package/dist/types/components/starlight/index.d.ts +9 -0
- package/dist/types/internal/callout.d.ts +7 -0
- package/dist/types/internal/errors.d.ts +3 -0
- package/dist/types/internal/icons.d.ts +50 -0
- package/package.json +150 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// packages/webview-app/src/components/shims/starlight/FileTree.tsx
|
|
3
|
+
// Starlight FileTree component shim for MDX Preview
|
|
4
|
+
// provide preview-compatible version of @astrojs/starlight/components FileTree
|
|
5
|
+
import { Children, isValidElement, } from 'react';
|
|
6
|
+
import { extractTextContent } from '../base/extractTextContent.js';
|
|
7
|
+
import { FILE_TREE_ICONS } from '../base/icons.js';
|
|
8
|
+
// check if a child is a bold element (strong)
|
|
9
|
+
function isBoldElement(node) {
|
|
10
|
+
if (!isValidElement(node)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return node.type === 'strong' || node.type === 'b';
|
|
14
|
+
}
|
|
15
|
+
// parse li element content to extract name, highlight status, & comment
|
|
16
|
+
function parseLiContent(children) {
|
|
17
|
+
const childArray = Children.toArray(children);
|
|
18
|
+
let name = '';
|
|
19
|
+
let isHighlighted = false;
|
|
20
|
+
let comment;
|
|
21
|
+
let nestedList;
|
|
22
|
+
for (const child of childArray) {
|
|
23
|
+
// check for nested ul (subdirectory)
|
|
24
|
+
if (isValidElement(child) && child.type === 'ul') {
|
|
25
|
+
nestedList = child;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// check for bold (highlighted)
|
|
29
|
+
if (isBoldElement(child)) {
|
|
30
|
+
isHighlighted = true;
|
|
31
|
+
const boldText = extractTextContent(child);
|
|
32
|
+
// bold text is the name, any text after is comment
|
|
33
|
+
const parts = boldText.split(/\s+/);
|
|
34
|
+
name = parts[0] || '';
|
|
35
|
+
if (parts.length > 1) {
|
|
36
|
+
comment = parts.slice(1).join(' ');
|
|
37
|
+
}
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// handle plain text
|
|
41
|
+
if (typeof child === 'string') {
|
|
42
|
+
const text = child.trim();
|
|
43
|
+
if (!text) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (!name) {
|
|
47
|
+
// first text segment is the name
|
|
48
|
+
const parts = text.split(/\s+/);
|
|
49
|
+
name = parts[0] || '';
|
|
50
|
+
if (parts.length > 1) {
|
|
51
|
+
const restText = parts.slice(1).join(' ');
|
|
52
|
+
comment = comment ? `${comment} ${restText}` : restText;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// additional text is comment
|
|
57
|
+
comment = comment ? `${comment} ${text}` : text;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { name, isHighlighted, comment, nestedList };
|
|
62
|
+
}
|
|
63
|
+
// parse a single <li> element into a FileTreeEntry
|
|
64
|
+
function parseLiElement(li) {
|
|
65
|
+
const { name, isHighlighted, comment, nestedList } = parseLiContent(li.props.children);
|
|
66
|
+
if (!name) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
// check for placeholder
|
|
70
|
+
if (name === '...' || name === '…') {
|
|
71
|
+
return {
|
|
72
|
+
name: '...',
|
|
73
|
+
isDirectory: false,
|
|
74
|
+
isHighlighted: false,
|
|
75
|
+
isPlaceholder: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// determine if directory (trailing / or has nested children)
|
|
79
|
+
const isDirectory = name.endsWith('/') || nestedList !== undefined;
|
|
80
|
+
const cleanName = name.endsWith('/') ? name.slice(0, -1) : name;
|
|
81
|
+
// parse nested children if present
|
|
82
|
+
let entryChildren;
|
|
83
|
+
if (nestedList && isValidElement(nestedList)) {
|
|
84
|
+
entryChildren = parseFileTreeChildren(nestedList.props.children);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
name: cleanName,
|
|
88
|
+
isDirectory,
|
|
89
|
+
isHighlighted,
|
|
90
|
+
comment: comment || undefined,
|
|
91
|
+
isPlaceholder: false,
|
|
92
|
+
children: entryChildren,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// parse children (unordered list) into structured entries
|
|
96
|
+
// handle both nested structure (<li>folder/<ul>...</ul></li>) &
|
|
97
|
+
// sibling structure (<li>folder/</li><ul>...</ul>)
|
|
98
|
+
function parseFileTreeChildren(children) {
|
|
99
|
+
const entries = [];
|
|
100
|
+
const childArray = Children.toArray(children);
|
|
101
|
+
for (let i = 0; i < childArray.length; i++) {
|
|
102
|
+
const child = childArray[i];
|
|
103
|
+
if (!isValidElement(child)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// handle <ul> wrapper - recursively process its children
|
|
107
|
+
if (child.type === 'ul') {
|
|
108
|
+
entries.push(...parseFileTreeChildren(child.props.children));
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
// handle <li> items
|
|
112
|
+
if (child.type === 'li') {
|
|
113
|
+
const entry = parseLiElement(child);
|
|
114
|
+
if (!entry) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
// check if next sibling is a <ul> that should be this directory's children
|
|
118
|
+
// handle the sibling pattern: <li>folder/</li><ul>...</ul>
|
|
119
|
+
const nextChild = childArray[i + 1];
|
|
120
|
+
if (entry.isDirectory &&
|
|
121
|
+
!entry.children?.length &&
|
|
122
|
+
isValidElement(nextChild) &&
|
|
123
|
+
nextChild.type === 'ul') {
|
|
124
|
+
entry.children = parseFileTreeChildren(nextChild.props.children);
|
|
125
|
+
// skip the <ul> since we've processed it as children
|
|
126
|
+
i++;
|
|
127
|
+
}
|
|
128
|
+
entries.push(entry);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return entries;
|
|
132
|
+
}
|
|
133
|
+
// render a single file tree entry
|
|
134
|
+
function FileTreeItem({ entry }) {
|
|
135
|
+
if (entry.isPlaceholder) {
|
|
136
|
+
return (_jsx("li", { className: "mdx-preview-starlight-file-tree-placeholder", children: _jsx("span", { className: "placeholder-dots", children: "..." }) }));
|
|
137
|
+
}
|
|
138
|
+
if (entry.isDirectory) {
|
|
139
|
+
return (_jsx("li", { className: "mdx-preview-starlight-file-tree-directory", children: _jsxs("details", { open: true, children: [_jsxs("summary", { className: entry.isHighlighted ? 'highlighted' : '', children: [_jsx("span", { className: "icon chevron", dangerouslySetInnerHTML: { __html: FILE_TREE_ICONS.chevron } }), _jsx("span", { className: "icon folder", dangerouslySetInnerHTML: { __html: FILE_TREE_ICONS.folder } }), _jsx("span", { className: "name", children: entry.name }), entry.comment && _jsx("span", { className: "comment", children: entry.comment })] }), entry.children && entry.children.length > 0 && (_jsx("ul", { children: entry.children.map((child, i) => (_jsx(FileTreeItem, { entry: child }, i))) }))] }) }));
|
|
140
|
+
}
|
|
141
|
+
return (_jsxs("li", { className: `mdx-preview-starlight-file-tree-file${entry.isHighlighted ? ' highlighted' : ''}`, children: [_jsx("span", { className: "icon file", dangerouslySetInnerHTML: { __html: FILE_TREE_ICONS.file } }), _jsx("span", { className: "name", children: entry.name }), entry.comment && _jsx("span", { className: "comment", children: entry.comment })] }));
|
|
142
|
+
}
|
|
143
|
+
// file tree component - render a file/folder tree structure
|
|
144
|
+
export function FileTree({ children }) {
|
|
145
|
+
const entries = parseFileTreeChildren(children);
|
|
146
|
+
return (_jsx("div", { className: "mdx-preview-starlight-file-tree", children: _jsx("ul", { children: entries.map((entry, i) => (_jsx(FileTreeItem, { entry: entry }, i))) }) }));
|
|
147
|
+
}
|
|
148
|
+
export default FileTree;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BaseCard } from '../base/index.js';
|
|
3
|
+
import { ArrowIcon } from '../base/icons.js';
|
|
4
|
+
// link card component
|
|
5
|
+
export function LinkCard({ title, description, href, }) {
|
|
6
|
+
return (_jsxs(BaseCard, { className: "mdx-preview-starlight-link-card", as: "a", href: href, openInNewTab: true, children: [_jsxs("div", { className: "mdx-preview-starlight-link-card-content", children: [_jsx("span", { className: "mdx-preview-starlight-link-card-title", children: title }), description && (_jsx("span", { className: "mdx-preview-starlight-link-card-description", children: description }))] }), _jsx("span", { className: "mdx-preview-starlight-link-card-arrow", children: _jsx(ArrowIcon, {}) })] }));
|
|
7
|
+
}
|
|
8
|
+
export default LinkCard;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// steps component - render numbered steps from ordered list children
|
|
3
|
+
export function Steps({ children }) {
|
|
4
|
+
return _jsx("div", { className: "mdx-preview-starlight-steps", children: children });
|
|
5
|
+
}
|
|
6
|
+
export default Steps;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// packages/webview-app/src/components/shims/starlight/Tabs.tsx
|
|
2
|
+
// Starlight Tabs/TabItem component shim for MDX Preview
|
|
3
|
+
// re-exports Docusaurus Tabs since they have compatible APIs
|
|
4
|
+
// Starlight & Docusaurus tabs have nearly identical APIs
|
|
5
|
+
// re-export the Docusaurus implementation for Starlight compatibility
|
|
6
|
+
export { Tabs, TabItem } from '../docusaurus/Tabs.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Card } from './Card.js';
|
|
2
|
+
export { CardGrid } from './CardGrid.js';
|
|
3
|
+
export { LinkCard } from './LinkCard.js';
|
|
4
|
+
export { Steps } from './Steps.js';
|
|
5
|
+
export { Badge } from './Badge.js';
|
|
6
|
+
export { Aside } from './Aside.js';
|
|
7
|
+
export { Tabs, TabItem } from './Tabs.js';
|
|
8
|
+
export { FileTree } from './FileTree.js';
|
|
9
|
+
export { Code } from './Code.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// shared callout type definitions & normalization
|
|
2
|
+
export const VALID_CALLOUT_TYPES = [
|
|
3
|
+
'note',
|
|
4
|
+
'tip',
|
|
5
|
+
'warning',
|
|
6
|
+
'danger',
|
|
7
|
+
'info',
|
|
8
|
+
'caution',
|
|
9
|
+
'important',
|
|
10
|
+
];
|
|
11
|
+
export const VALID_CALLOUT_TYPE_SET = new Set(VALID_CALLOUT_TYPES);
|
|
12
|
+
export const CALLOUT_TYPE_ALIASES = {
|
|
13
|
+
success: 'tip',
|
|
14
|
+
error: 'danger',
|
|
15
|
+
warn: 'warning',
|
|
16
|
+
hint: 'tip',
|
|
17
|
+
};
|
|
18
|
+
export const CALLOUT_TITLES = {
|
|
19
|
+
note: 'Note',
|
|
20
|
+
tip: 'Tip',
|
|
21
|
+
warning: 'Warning',
|
|
22
|
+
danger: 'Danger',
|
|
23
|
+
info: 'Info',
|
|
24
|
+
caution: 'Caution',
|
|
25
|
+
important: 'Important',
|
|
26
|
+
};
|
|
27
|
+
export function normalizeCalloutType(type) {
|
|
28
|
+
if (!type) {
|
|
29
|
+
return 'note';
|
|
30
|
+
}
|
|
31
|
+
const normalized = type.toLowerCase();
|
|
32
|
+
if (normalized in CALLOUT_TYPE_ALIASES) {
|
|
33
|
+
return CALLOUT_TYPE_ALIASES[normalized];
|
|
34
|
+
}
|
|
35
|
+
if (VALID_CALLOUT_TYPE_SET.has(normalized)) {
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
return 'note';
|
|
39
|
+
}
|
|
40
|
+
export function isValidCalloutType(type) {
|
|
41
|
+
const normalized = type.toLowerCase();
|
|
42
|
+
return (VALID_CALLOUT_TYPE_SET.has(normalized) || normalized in CALLOUT_TYPE_ALIASES);
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// shared error utilities
|
|
2
|
+
export function isError(value) {
|
|
3
|
+
return value instanceof Error;
|
|
4
|
+
}
|
|
5
|
+
// extract error message w/ robust object check
|
|
6
|
+
export function extractErrorMessage(error) {
|
|
7
|
+
if (error instanceof Error) {
|
|
8
|
+
return error.message;
|
|
9
|
+
}
|
|
10
|
+
if (typeof error === 'string') {
|
|
11
|
+
return error;
|
|
12
|
+
}
|
|
13
|
+
if (error && typeof error === 'object' && 'message' in error) {
|
|
14
|
+
const message = error.message;
|
|
15
|
+
if (typeof message === 'string') {
|
|
16
|
+
return message;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return 'Unknown error';
|
|
20
|
+
}
|
|
21
|
+
// convert any value to Error
|
|
22
|
+
export function normalizeError(error) {
|
|
23
|
+
if (isError(error)) {
|
|
24
|
+
return error;
|
|
25
|
+
}
|
|
26
|
+
return new Error(String(error));
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// centralized SVG icon definitions for callouts & shims
|
|
2
|
+
const INFO_ICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>';
|
|
3
|
+
const WARNING_ICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>';
|
|
4
|
+
export const CALLOUT_ICONS = {
|
|
5
|
+
note: INFO_ICON_SVG,
|
|
6
|
+
info: INFO_ICON_SVG,
|
|
7
|
+
tip: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18h6"></path><path d="M10 22h4"></path><path d="M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0 0 18 8 6 6 0 0 0 6 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 0 1 8.91 14"></path></svg>',
|
|
8
|
+
warning: WARNING_ICON_SVG,
|
|
9
|
+
caution: WARNING_ICON_SVG,
|
|
10
|
+
danger: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"></polygon><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>',
|
|
11
|
+
important: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>',
|
|
12
|
+
};
|
|
13
|
+
// backward-compatible alias for compiler consumers
|
|
14
|
+
export const ADMONITION_ICONS = CALLOUT_ICONS;
|
|
15
|
+
export const GITHUB_ICONS = {
|
|
16
|
+
lightbulb: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"></path></svg>',
|
|
17
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',
|
|
18
|
+
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',
|
|
19
|
+
error: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',
|
|
20
|
+
important: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',
|
|
21
|
+
arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M8.22 2.97a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06l2.97-2.97H3.75a.75.75 0 0 1 0-1.5h7.44L8.22 4.03a.75.75 0 0 1 0-1.06Z"></path></svg>',
|
|
22
|
+
copy: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg>',
|
|
23
|
+
check: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg>',
|
|
24
|
+
};
|
|
25
|
+
export const GITHUB_ALERT_ICONS = {
|
|
26
|
+
NOTE: GITHUB_ICONS.info,
|
|
27
|
+
TIP: GITHUB_ICONS.lightbulb,
|
|
28
|
+
IMPORTANT: GITHUB_ICONS.important,
|
|
29
|
+
WARNING: GITHUB_ICONS.warning,
|
|
30
|
+
CAUTION: GITHUB_ICONS.error,
|
|
31
|
+
};
|
|
32
|
+
export const FILE_TREE_ICONS = {
|
|
33
|
+
chevron: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>',
|
|
34
|
+
folder: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>',
|
|
35
|
+
file: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>',
|
|
36
|
+
};
|
|
37
|
+
export const LUCIDE_ICONS = {
|
|
38
|
+
arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>',
|
|
39
|
+
copy: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',
|
|
40
|
+
check: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',
|
|
41
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ModuleErrorCode = 'MODULE_NOT_FOUND' | 'CIRCULAR_DEPENDENCY' | 'FETCH_FAILED' | 'EVALUATION_FAILED' | 'MODULE_DEPTH_EXCEEDED';
|
|
2
|
+
export interface ModuleErrorData {
|
|
3
|
+
code: ModuleErrorCode;
|
|
4
|
+
moduleId?: string;
|
|
5
|
+
request?: string;
|
|
6
|
+
parentId?: string;
|
|
7
|
+
depth?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class ModuleError extends Error {
|
|
10
|
+
readonly data: ModuleErrorData;
|
|
11
|
+
constructor(message: string, data: ModuleErrorData, cause?: Error);
|
|
12
|
+
}
|
|
13
|
+
export declare function isModuleErrorData(value: unknown): value is ModuleErrorData;
|
|
14
|
+
export declare function createModuleNotFoundError(request: string, parentId: string): ModuleError;
|
|
15
|
+
export declare function createCircularDependencyError(moduleId: string, parentId?: string): ModuleError;
|
|
16
|
+
export declare function createFetchFailedError(request: string, parentId: string, cause?: Error): ModuleError;
|
|
17
|
+
export declare function createEvaluationFailedError(moduleId: string, cause?: Error): ModuleError;
|
|
18
|
+
export declare function createModuleDepthExceededError(moduleId: string, depth: number): ModuleError;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Framework, ModuleFetcher, ModuleLoaderConfig } from './types';
|
|
2
|
+
export { registry } from './registry/ModuleRegistry';
|
|
3
|
+
export { clearInjectedStyles } from './styles/injectStyles';
|
|
4
|
+
export { injectStyles } from './styles/injectStyles';
|
|
5
|
+
export { loadModule } from './loader/loadModule';
|
|
6
|
+
export { evaluateModule } from './eval/evaluateModule';
|
|
7
|
+
export { createSyncRequire } from './runtime/require';
|
|
8
|
+
export type { FetchResult, Module, ModuleRuntime, PreloadEntry } from './types';
|
|
9
|
+
export { setPreloadEntries, registerPreloadEntries } from './preload';
|
|
10
|
+
export declare function setVscodeMarkdownLayout(module: unknown): void;
|
|
11
|
+
export declare function configureRuntime(config: ModuleLoaderConfig): void;
|
|
12
|
+
export declare function setModuleFetcher(fetcher: ModuleFetcher): void;
|
|
13
|
+
export declare function resetModules(): void;
|
|
14
|
+
export declare function resetDependencies(): void;
|
|
15
|
+
export declare function invalidateModule(id: string): void;
|
|
16
|
+
export declare function invalidateModuleWithDependents(id: string): Set<string>;
|
|
17
|
+
export declare function clearAllCaches(): void;
|
|
18
|
+
export declare function ensureFrameworkShimsLoaded(framework: Framework): void;
|
|
19
|
+
export declare function ensureGenericShimsLoaded(components: string[]): void;
|
|
20
|
+
export declare function evaluateModuleToComponent(code: string, entryFilePath: string, dependencies: string[]): Promise<(...args: unknown[]) => unknown>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface LRUCacheOptions<K, V> {
|
|
2
|
+
maxEntries: number;
|
|
3
|
+
onEvict?: (key: K, value: V) => void;
|
|
4
|
+
estimateSize?: (value: V) => number;
|
|
5
|
+
maxMemoryBytes?: number;
|
|
6
|
+
isProtected?: (key: K, value: V) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class LRUCache<K, V> {
|
|
9
|
+
private cache;
|
|
10
|
+
private maxEntries;
|
|
11
|
+
private onEvict?;
|
|
12
|
+
private estimateSize?;
|
|
13
|
+
private maxMemoryBytes?;
|
|
14
|
+
private isProtected?;
|
|
15
|
+
private currentMemoryBytes;
|
|
16
|
+
constructor(options: LRUCacheOptions<K, V>);
|
|
17
|
+
get(key: K): V | null;
|
|
18
|
+
peek(key: K): V | undefined;
|
|
19
|
+
has(key: K): boolean;
|
|
20
|
+
set(key: K, value: V): void;
|
|
21
|
+
delete(key: K): boolean;
|
|
22
|
+
clear(): void;
|
|
23
|
+
keys(): IterableIterator<K>;
|
|
24
|
+
entries(): IterableIterator<[K, V]>;
|
|
25
|
+
updateSettings(options: Partial<LRUCacheOptions<K, V>>): void;
|
|
26
|
+
get size(): number;
|
|
27
|
+
get memoryBytes(): number;
|
|
28
|
+
private deleteEntry;
|
|
29
|
+
private evictOldestEvictable;
|
|
30
|
+
private countEvictable;
|
|
31
|
+
private getEvictableMemory;
|
|
32
|
+
private evictOverflow;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBareImport(specifier: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MDXRuntime, ModuleLoaderConfig } from '../types';
|
|
2
|
+
interface RuntimeState {
|
|
3
|
+
maxModuleLoadDepth: number;
|
|
4
|
+
maxConcurrentFetches: number;
|
|
5
|
+
preloadAliases: Record<string, string>;
|
|
6
|
+
runtime: MDXRuntime;
|
|
7
|
+
}
|
|
8
|
+
export declare function configureModuleLoader(config: ModuleLoaderConfig): void;
|
|
9
|
+
export declare function getModuleLoaderConfig(): RuntimeState;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Module } from '../types';
|
|
2
|
+
export declare function getPendingModule(id: string): Promise<Module> | undefined;
|
|
3
|
+
export declare function registerPendingModule(id: string, promise: Promise<Module>): void;
|
|
4
|
+
export declare function clearPendingModule(id: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModuleRegistry } from '../registry/ModuleRegistry';
|
|
2
|
+
import { type PreloadEntry } from '../types';
|
|
3
|
+
export interface LayoutOptions {
|
|
4
|
+
forceLightTheme?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const fallbackLayoutModule: {
|
|
7
|
+
createLayout: (_options?: LayoutOptions) => ({ children }: {
|
|
8
|
+
children?: unknown;
|
|
9
|
+
}) => {} | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function preloadCoreModules(registry: ModuleRegistry, vscodeMarkdownLayout: unknown, entries?: PreloadEntry[]): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ModuleRegistry } from '../registry/ModuleRegistry';
|
|
2
|
+
import type { Framework, FrameworkId, PreloadEntry } from '../types';
|
|
3
|
+
export { fallbackLayoutModule } from './core';
|
|
4
|
+
export declare function setPreloadEntries(entries: readonly PreloadEntry[]): void;
|
|
5
|
+
export declare function registerPreloadEntries(registry: ModuleRegistry, entries: readonly PreloadEntry[]): void;
|
|
6
|
+
export declare function initPreloadedModules(registry: ModuleRegistry, vscodeMarkdownLayout: unknown): void;
|
|
7
|
+
export declare function ensureFrameworkShims(_registry: ModuleRegistry, _framework: FrameworkId): Promise<void>;
|
|
8
|
+
export declare function ensureGenericShims(_registry: ModuleRegistry, _components: string[]): Promise<void>;
|
|
9
|
+
export declare function getPreservedIds(): string[];
|
|
10
|
+
export declare function resetFrameworkState(): void;
|
|
11
|
+
export declare function resetGenericShimsState(): void;
|
|
12
|
+
export declare function getLastShimLoadResult(): {
|
|
13
|
+
success: boolean;
|
|
14
|
+
framework: Framework;
|
|
15
|
+
failedShims: string[];
|
|
16
|
+
usedFallback: boolean;
|
|
17
|
+
} | null;
|
|
18
|
+
export declare function getLastGenericLoadResult(): {
|
|
19
|
+
loaded: string[];
|
|
20
|
+
failed: string[];
|
|
21
|
+
} | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModuleRegistry } from '../registry/ModuleRegistry';
|
|
2
|
+
import type { Framework } from '../types';
|
|
3
|
+
export interface ShimLoadResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
framework: Framework;
|
|
6
|
+
failedShims: string[];
|
|
7
|
+
usedFallback: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface RetryResult<T> {
|
|
10
|
+
result: T | null;
|
|
11
|
+
attempts: number;
|
|
12
|
+
lastError?: Error;
|
|
13
|
+
}
|
|
14
|
+
declare function retryLoad<T>(name: string, loader: () => Promise<T>, maxRetries?: number): Promise<RetryResult<T>>;
|
|
15
|
+
export declare function loadFrameworkShimsWithRetry(registry: ModuleRegistry, framework: Framework, frameworkLoader: (registry: ModuleRegistry) => Promise<void>, genericFallbackLoader: (registry: ModuleRegistry) => void): Promise<ShimLoadResult>;
|
|
16
|
+
export declare function loadGenericShimsWithRetry(registry: ModuleRegistry, componentNames: string[], shimLoaders: Record<string, (registry: ModuleRegistry) => Promise<void>>): Promise<{
|
|
17
|
+
loaded: string[];
|
|
18
|
+
failed: string[];
|
|
19
|
+
}>;
|
|
20
|
+
export { retryLoad as _retryLoadForTesting };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class DependencyTracker {
|
|
2
|
+
private resolutionMap;
|
|
3
|
+
private parentToResolutionKeys;
|
|
4
|
+
private targetToResolutionKeys;
|
|
5
|
+
private dependents;
|
|
6
|
+
private makeResolutionKey;
|
|
7
|
+
setResolution(parentId: string, request: string, fsPath: string): void;
|
|
8
|
+
getResolution(parentId: string, request: string): string | undefined;
|
|
9
|
+
addDependency(moduleId: string, dependsOnId: string): void;
|
|
10
|
+
getDependents(moduleId: string): Set<string> | undefined;
|
|
11
|
+
get dependentsCount(): number;
|
|
12
|
+
get resolutionsCount(): number;
|
|
13
|
+
cleanResolutionMapFor(moduleId: string): void;
|
|
14
|
+
cleanDependentsFor(moduleId: string): void;
|
|
15
|
+
invalidateWithDependents(moduleId: string): Set<string>;
|
|
16
|
+
clearDependencies(): void;
|
|
17
|
+
clearResolutions(): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
getStats(): {
|
|
20
|
+
resolutions: number;
|
|
21
|
+
dependents: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Module } from '../types';
|
|
2
|
+
export interface ModuleCacheConfig {
|
|
3
|
+
maxModules?: number;
|
|
4
|
+
maxMemoryBytes?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class ModuleCache {
|
|
7
|
+
private cache;
|
|
8
|
+
private pendingFetches;
|
|
9
|
+
private preloadedIds;
|
|
10
|
+
onEvict?: (id: string) => void;
|
|
11
|
+
constructor();
|
|
12
|
+
configure(options: ModuleCacheConfig): void;
|
|
13
|
+
get memoryBytes(): number;
|
|
14
|
+
get size(): number;
|
|
15
|
+
get preloadedCount(): number;
|
|
16
|
+
get pendingCount(): number;
|
|
17
|
+
preload(id: string, exports: unknown): void;
|
|
18
|
+
get(id: string): Module | undefined;
|
|
19
|
+
has(id: string): boolean;
|
|
20
|
+
isPreloaded(id: string): boolean;
|
|
21
|
+
set(id: string, module: Module): void;
|
|
22
|
+
delete(id: string): number;
|
|
23
|
+
private estimateExportsSize;
|
|
24
|
+
getPending(id: string): Promise<Module> | undefined;
|
|
25
|
+
setPending(id: string, promise: Promise<Module>): void;
|
|
26
|
+
clearPending(id: string): void;
|
|
27
|
+
clearAllPending(): void;
|
|
28
|
+
clearNonPreloaded(): void;
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Module } from '../types';
|
|
2
|
+
import { type ModuleCacheConfig } from './ModuleCache';
|
|
3
|
+
import { type StyleCacheConfig } from './StyleCache';
|
|
4
|
+
export interface LRUConfig extends ModuleCacheConfig, StyleCacheConfig {
|
|
5
|
+
}
|
|
6
|
+
export declare class ModuleRegistry {
|
|
7
|
+
private moduleCache;
|
|
8
|
+
private styleCache;
|
|
9
|
+
private dependencyTracker;
|
|
10
|
+
constructor();
|
|
11
|
+
configureLRU(options: LRUConfig): void;
|
|
12
|
+
preload(id: string, exports: unknown): void;
|
|
13
|
+
get(id: string): Module | undefined;
|
|
14
|
+
has(id: string): boolean;
|
|
15
|
+
isPreloaded(id: string): boolean;
|
|
16
|
+
set(id: string, module: Module): void;
|
|
17
|
+
getPending(id: string): Promise<Module> | undefined;
|
|
18
|
+
setPending(id: string, promise: Promise<Module>): void;
|
|
19
|
+
clearPending(id: string): void;
|
|
20
|
+
invalidate(id: string): void;
|
|
21
|
+
invalidateWithDependents(id: string): Set<string>;
|
|
22
|
+
addDependency(moduleId: string, dependsOnId: string): void;
|
|
23
|
+
clearDependencies(): void;
|
|
24
|
+
setResolution(parentId: string, request: string, fsPath: string): void;
|
|
25
|
+
getResolution(parentId: string, request: string): string | undefined;
|
|
26
|
+
clearResolutions(): void;
|
|
27
|
+
hasInjectedStyle(id: string): boolean;
|
|
28
|
+
markStyleInjected(id: string): void;
|
|
29
|
+
decrementStyleRef(id: string): void;
|
|
30
|
+
clearInjectedStyles(): void;
|
|
31
|
+
unmarkStyleInjected(id: string): void;
|
|
32
|
+
clearNonPreloaded(_preloadedIds?: string[]): void;
|
|
33
|
+
clear(): void;
|
|
34
|
+
getStats(): {
|
|
35
|
+
modules: number;
|
|
36
|
+
styles: number;
|
|
37
|
+
preloaded: number;
|
|
38
|
+
pending: number;
|
|
39
|
+
resolutions: number;
|
|
40
|
+
dependents: number;
|
|
41
|
+
memoryBytes: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare const registry: ModuleRegistry;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface StyleCacheConfig {
|
|
2
|
+
maxStyles?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare class StyleCache {
|
|
5
|
+
private cache;
|
|
6
|
+
private maxStyles;
|
|
7
|
+
constructor();
|
|
8
|
+
private createCache;
|
|
9
|
+
configure(options: StyleCacheConfig): void;
|
|
10
|
+
hasInjectedStyle(id: string): boolean;
|
|
11
|
+
get size(): number;
|
|
12
|
+
markStyleInjected(id: string): void;
|
|
13
|
+
private evictUnreferencedToCapacity;
|
|
14
|
+
decrementStyleRef(id: string): void;
|
|
15
|
+
unmarkStyleInjected(id: string): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createSyncRequire(parentId: string): (request: string) => unknown;
|