@vercel/geistdocs 2.15.3 → 2.15.4-canary.2a54b38
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/dist/cli/index.js +1 -1
- package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
- package/dist/internal/mdx-to-markdown.js +9 -0
- package/dist/internal/page-actions-client.js +1 -1
- package/dist/internal/page-actions.d.ts +4 -4
- package/dist/internal/page-actions.d.ts.map +1 -1
- package/dist/internal/page-actions.js +6 -1
- package/dist/internal/source-loader.d.ts +28 -0
- package/dist/internal/source-loader.d.ts.map +1 -0
- package/dist/internal/source-loader.js +77 -0
- package/dist/mdx-basic.d.ts +27 -0
- package/dist/mdx-basic.d.ts.map +1 -0
- package/dist/mdx-basic.js +61 -0
- package/dist/mdx.d.ts +3 -25
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +8 -61
- package/dist/mobile-docs-bar.js +1 -1
- package/dist/navigation.d.ts +11 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +8 -0
- package/dist/next.d.ts +11 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +82 -2
- package/dist/pages/docs-custom.d.ts +111 -0
- package/dist/pages/docs-custom.d.ts.map +1 -0
- package/dist/pages/docs-custom.js +250 -0
- package/dist/pages/docs.d.ts +5 -98
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +13 -250
- package/dist/source-config.d.ts +10 -1
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +21 -10
- package/dist/source.d.ts +6 -17
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +2 -75
- package/docs/agents.md +1 -1
- package/docs/llms.txt +27 -1
- package/docs/manifest.json +1 -1
- package/docs/pages/configuration.md +26 -0
- package/native-mdx/LICENSE-mdxjs-rs +22 -0
- package/native-mdx/UPSTREAM.md +16 -0
- package/native-mdx/binaries/darwin-arm64.node +0 -0
- package/native-mdx/binaries/linux-x64-gnu.node +0 -0
- package/native-mdx/data-entry.d.mts +15 -0
- package/native-mdx/data-entry.mjs +97 -0
- package/native-mdx/data-projection.mjs +205 -0
- package/native-mdx/fumadocs-adapter.mjs +36 -0
- package/native-mdx/index-emitter.mjs +34 -0
- package/native-mdx/loader-data.cjs +36 -0
- package/native-mdx/loader-mdx.cjs +9 -0
- package/native-mdx/loader-mdx.mjs +419 -0
- package/native-mdx/native-binding.cjs +27 -0
- package/native-mdx/navigation-entry.d.mts +11 -0
- package/native-mdx/navigation-entry.mjs +136 -0
- package/native-mdx/navigation-title.mjs +53 -0
- package/package.json +43 -15
- package/rehype-code-highlights.d.ts +13 -0
- package/rehype-code-highlights.js +230 -0
- package/shared-theme.css +7 -1
- package/source-config.js +27 -10
- package/template/content/docs/configuration.mdx +26 -0
- package/template/package.json +7 -4
- package/template/pnpm-workspace.yaml +3 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Vendored MDX compiler
|
|
2
|
+
|
|
3
|
+
Upstream: https://github.com/wooorm/mdxjs-rs
|
|
4
|
+
|
|
5
|
+
Source version: `mdxjs` 1.0.4 (MIT).
|
|
6
|
+
Published crate revision: `282729e6a0750c19dfd9217bc511971bf3295a29`, recorded in
|
|
7
|
+
that crate's `.cargo_vcs_info.json`.
|
|
8
|
+
|
|
9
|
+
This directory is an adapted subset, not an unmodified upstream checkout.
|
|
10
|
+
Geistdocs adds pipeline hooks and fixes JSX style attributes, URL encoding,
|
|
11
|
+
GFM nested links and component-only paragraph handling. Geistdocs-specific
|
|
12
|
+
transforms and highlighting live outside this directory.
|
|
13
|
+
|
|
14
|
+
Keep `LICENSE-mdxjs-rs` with these sources and with every distributed native
|
|
15
|
+
binary, including the private Geistdocs package. Review upstream changes and
|
|
16
|
+
rerun output parity tests before updating this fork.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin } from "fumadocs-mdx";
|
|
2
|
+
import type * as TypeScript from "typescript";
|
|
3
|
+
|
|
4
|
+
type Parser = typeof TypeScript;
|
|
5
|
+
|
|
6
|
+
/** Extend Fumadocs 14's existing emitter with an opt-in data.ts entry. */
|
|
7
|
+
export declare function dataEntryPlugin(
|
|
8
|
+
parser: Parser | (() => Parser | Promise<Parser>)
|
|
9
|
+
): Plugin;
|
|
10
|
+
|
|
11
|
+
/** Derive an entry in the same directory as the generated server.ts. */
|
|
12
|
+
export declare function createDataEntry(
|
|
13
|
+
serverCode: string,
|
|
14
|
+
parser: Parser
|
|
15
|
+
): { code: string; imports: number };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DATA_QUERY, withoutDataQuery } from "./data-projection.mjs";
|
|
2
|
+
import { extendIndexEmitter } from "./index-emitter.mjs";
|
|
3
|
+
|
|
4
|
+
const MDX_EXTENSION = /\.mdx?$/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Opt-in Fumadocs 14 plugin. Extend the existing index-file emitter in place:
|
|
8
|
+
* its own watcher calls core.emitAndWrite filtered to name === "index-file".
|
|
9
|
+
* Registering an independent emitter would miss those development updates.
|
|
10
|
+
*/
|
|
11
|
+
export function dataEntryPlugin(typeScriptOrLoader) {
|
|
12
|
+
let parserPromise;
|
|
13
|
+
const getParser = () =>
|
|
14
|
+
(parserPromise ??= Promise.resolve()
|
|
15
|
+
.then(() =>
|
|
16
|
+
typeof typeScriptOrLoader === "function"
|
|
17
|
+
? typeScriptOrLoader()
|
|
18
|
+
: typeScriptOrLoader
|
|
19
|
+
)
|
|
20
|
+
.then((module) => module.default ?? module));
|
|
21
|
+
return {
|
|
22
|
+
name: "geistdocs-data-entry",
|
|
23
|
+
config() {
|
|
24
|
+
extendIndexEmitter(this, "geistdocs-data-entry", async (entries) => {
|
|
25
|
+
const server = entries.find((entry) => entry.path === "server.ts");
|
|
26
|
+
if (!server || entries.some((entry) => entry.path === "data.ts")) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"Content entries require server.ts and an unused data.ts output"
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return [
|
|
32
|
+
...entries,
|
|
33
|
+
{
|
|
34
|
+
path: "data.ts",
|
|
35
|
+
content: createDataEntry(server.content, await getParser()).code,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Derive data.ts from Fumadocs' authoritative generated server.ts in the SAME
|
|
45
|
+
* directory. Call from the existing generation lifecycle after each emission.
|
|
46
|
+
* No globbing, watcher, filesystem writes or extra content registry is created.
|
|
47
|
+
* TypeScript is supplied by the build-time host, not a runtime dependency.
|
|
48
|
+
*/
|
|
49
|
+
export function createDataEntry(serverCode, ts) {
|
|
50
|
+
const file = ts.createSourceFile(
|
|
51
|
+
"server.ts",
|
|
52
|
+
serverCode,
|
|
53
|
+
ts.ScriptTarget.Latest,
|
|
54
|
+
true,
|
|
55
|
+
ts.ScriptKind.TS
|
|
56
|
+
);
|
|
57
|
+
if (file.parseDiagnostics.length) {
|
|
58
|
+
throw new Error("Cannot parse generated server entry");
|
|
59
|
+
}
|
|
60
|
+
const edits = [];
|
|
61
|
+
for (const statement of file.statements) {
|
|
62
|
+
if (
|
|
63
|
+
!(
|
|
64
|
+
ts.isImportDeclaration(statement) &&
|
|
65
|
+
ts.isStringLiteral(statement.moduleSpecifier)
|
|
66
|
+
)
|
|
67
|
+
) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const specifier = statement.moduleSpecifier;
|
|
71
|
+
const separator = specifier.text.indexOf("?");
|
|
72
|
+
const pathname =
|
|
73
|
+
separator < 0 ? specifier.text : specifier.text.slice(0, separator);
|
|
74
|
+
if (!MDX_EXTENSION.test(pathname)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const query = new URLSearchParams(
|
|
78
|
+
separator < 0 ? "" : specifier.text.slice(separator + 1)
|
|
79
|
+
);
|
|
80
|
+
// Only collection imports emitted by Fumadocs; preserve metadata JSON and
|
|
81
|
+
// unrelated modules, runtime options, passthroughs and collection order.
|
|
82
|
+
if (!query.has("collection") || query.has("only")) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const canonicalQuery = withoutDataQuery(specifier.text.slice(separator));
|
|
86
|
+
edits.push({
|
|
87
|
+
start: specifier.getStart(file),
|
|
88
|
+
end: specifier.end,
|
|
89
|
+
value: JSON.stringify(`${pathname}${canonicalQuery}&${DATA_QUERY}=1`),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
let code = serverCode;
|
|
93
|
+
for (const edit of edits.reverse()) {
|
|
94
|
+
code = code.slice(0, edit.start) + edit.value + code.slice(edit.end);
|
|
95
|
+
}
|
|
96
|
+
return { code, imports: edits.length };
|
|
97
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
|
|
3
|
+
// Deliberately conservative, opt-in projection of an already compiled module.
|
|
4
|
+
// Compilation, frontmatter validation and user plugins run before this helper.
|
|
5
|
+
export const DATA_QUERY = "geistdocs-data";
|
|
6
|
+
|
|
7
|
+
// Preserve spelling/order/encoding of every other parameter so forwarding
|
|
8
|
+
// resolves to the same module identity as the original rendering request.
|
|
9
|
+
export function withoutDataQuery(resourceQuery = "") {
|
|
10
|
+
const parts = (
|
|
11
|
+
resourceQuery.startsWith("?") ? resourceQuery.slice(1) : resourceQuery
|
|
12
|
+
).split("&");
|
|
13
|
+
const kept = parts.filter(
|
|
14
|
+
(part) => !new URLSearchParams(part).has(DATA_QUERY)
|
|
15
|
+
);
|
|
16
|
+
return kept.some(Boolean) ? `?${kept.join("&")}` : "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const JSX_RUNTIME = /^react\/jsx-(?:dev-)?runtime$/;
|
|
20
|
+
|
|
21
|
+
function createClosedValidator(ast) {
|
|
22
|
+
const runtimeCalls = new Set();
|
|
23
|
+
const runtimeValues = new Set();
|
|
24
|
+
const bindings = new Set();
|
|
25
|
+
for (const node of ast.body) {
|
|
26
|
+
if (node.id) {
|
|
27
|
+
bindings.add(node.id.name);
|
|
28
|
+
}
|
|
29
|
+
const declaration = node.declaration ?? node;
|
|
30
|
+
for (const item of declaration.declarations ?? []) {
|
|
31
|
+
bindings.add(item.id.name);
|
|
32
|
+
}
|
|
33
|
+
if (node.type !== "ImportDeclaration") {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
for (const item of node.specifiers) {
|
|
37
|
+
bindings.add(item.local.name);
|
|
38
|
+
if (!JSX_RUNTIME.test(node.source.value)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (["jsx", "jsxs", "jsxDEV"].includes(item.imported?.name)) {
|
|
42
|
+
runtimeCalls.add(item.local.name);
|
|
43
|
+
}
|
|
44
|
+
if (item.imported?.name === "Fragment") {
|
|
45
|
+
runtimeValues.add(item.local.name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const closed = (node) => {
|
|
50
|
+
if (!node) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
switch (node.type) {
|
|
54
|
+
case "Literal":
|
|
55
|
+
return !node.regex;
|
|
56
|
+
case "Identifier":
|
|
57
|
+
return (
|
|
58
|
+
runtimeValues.has(node.name) ||
|
|
59
|
+
(node.name === "undefined" && !bindings.has("undefined"))
|
|
60
|
+
);
|
|
61
|
+
case "ArrayExpression":
|
|
62
|
+
return node.elements.every((item) => item === null || closed(item));
|
|
63
|
+
case "ObjectExpression":
|
|
64
|
+
return node.properties.every(
|
|
65
|
+
(item) =>
|
|
66
|
+
item.type === "Property" &&
|
|
67
|
+
item.kind === "init" &&
|
|
68
|
+
!item.method &&
|
|
69
|
+
!item.computed &&
|
|
70
|
+
closed(item.value)
|
|
71
|
+
);
|
|
72
|
+
case "UnaryExpression":
|
|
73
|
+
return (
|
|
74
|
+
["-", "+", "!", "void"].includes(node.operator) &&
|
|
75
|
+
closed(node.argument)
|
|
76
|
+
);
|
|
77
|
+
case "CallExpression":
|
|
78
|
+
return (
|
|
79
|
+
node.callee.type === "Identifier" &&
|
|
80
|
+
runtimeCalls.has(node.callee.name) &&
|
|
81
|
+
node.arguments.every(closed)
|
|
82
|
+
);
|
|
83
|
+
case "NewExpression":
|
|
84
|
+
return (
|
|
85
|
+
node.callee.name === "Date" &&
|
|
86
|
+
!bindings.has("Date") &&
|
|
87
|
+
node.arguments.length === 1 &&
|
|
88
|
+
node.arguments[0].type === "Literal"
|
|
89
|
+
);
|
|
90
|
+
default:
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return closed;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function projectDataModule(code, parse) {
|
|
98
|
+
const fallback = (reason) => ({ code, projected: false, reason });
|
|
99
|
+
let ast;
|
|
100
|
+
try {
|
|
101
|
+
ast = parse(code, { ecmaVersion: "latest", sourceType: "module" });
|
|
102
|
+
} catch {
|
|
103
|
+
return fallback("unrecognized compiled syntax");
|
|
104
|
+
}
|
|
105
|
+
const closed = createClosedValidator(ast);
|
|
106
|
+
const kept = [];
|
|
107
|
+
let hasBody = false;
|
|
108
|
+
let hasFrontmatter = false;
|
|
109
|
+
for (const node of ast.body) {
|
|
110
|
+
switch (node.type) {
|
|
111
|
+
case "ImportDeclaration":
|
|
112
|
+
// Keep all imports, including component imports: their evaluation may
|
|
113
|
+
// have side effects. Let the bundler honor each package's sideEffects.
|
|
114
|
+
kept.push(code.slice(node.start, node.end));
|
|
115
|
+
break;
|
|
116
|
+
case "FunctionDeclaration":
|
|
117
|
+
case "EmptyStatement":
|
|
118
|
+
break;
|
|
119
|
+
case "ExportDefaultDeclaration":
|
|
120
|
+
if (
|
|
121
|
+
node.declaration.type !== "FunctionDeclaration" &&
|
|
122
|
+
!(
|
|
123
|
+
node.declaration.type === "Identifier" &&
|
|
124
|
+
ast.body.some(
|
|
125
|
+
(item) =>
|
|
126
|
+
item.type === "FunctionDeclaration" &&
|
|
127
|
+
item.id.name === node.declaration.name
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
return fallback("non-function default export");
|
|
132
|
+
}
|
|
133
|
+
hasBody = true;
|
|
134
|
+
break;
|
|
135
|
+
case "ExportNamedDeclaration": {
|
|
136
|
+
const declaration = node.declaration;
|
|
137
|
+
if (declaration?.type !== "VariableDeclaration") {
|
|
138
|
+
return fallback("executable or re-exported metadata");
|
|
139
|
+
}
|
|
140
|
+
if (
|
|
141
|
+
declaration.declarations.some(
|
|
142
|
+
(item) => item.id.type !== "Identifier" || !closed(item.init)
|
|
143
|
+
)
|
|
144
|
+
) {
|
|
145
|
+
return fallback("metadata depends on executable code");
|
|
146
|
+
}
|
|
147
|
+
hasFrontmatter ||= declaration.declarations.some(
|
|
148
|
+
(item) => item.id.name === "frontmatter"
|
|
149
|
+
);
|
|
150
|
+
kept.push(code.slice(node.start, node.end));
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
return fallback(`module evaluation requires ${node.type}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!(hasBody && hasFrontmatter)) {
|
|
158
|
+
return fallback("missing compiled MDX contract");
|
|
159
|
+
}
|
|
160
|
+
kept.push(
|
|
161
|
+
'export default function(){throw new Error("Data-only MDX cannot render a page; use the server entry.");}'
|
|
162
|
+
);
|
|
163
|
+
return { code: kept.join("\n"), projected: true, reason: null };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Compose with the existing loader rather than bypassing its compatibility gate.
|
|
167
|
+
// The delegate owns dependencies/config reloads and native-to-JS fallback.
|
|
168
|
+
export function createDataLoader(delegate, parse, onResult = () => undefined) {
|
|
169
|
+
return function dataLoader(source) {
|
|
170
|
+
const query = new URLSearchParams((this.resourceQuery ?? "").slice(1));
|
|
171
|
+
if (!query.has(DATA_QUERY)) {
|
|
172
|
+
return delegate.call(this, source);
|
|
173
|
+
}
|
|
174
|
+
const done = this.async();
|
|
175
|
+
const context = Object.create(this);
|
|
176
|
+
context.resourceQuery = withoutDataQuery(this.resourceQuery);
|
|
177
|
+
context.async = () => (error, code, _map, metadata) => {
|
|
178
|
+
if (error) {
|
|
179
|
+
return done(error);
|
|
180
|
+
}
|
|
181
|
+
let result;
|
|
182
|
+
try {
|
|
183
|
+
result = projectDataModule(code, parse);
|
|
184
|
+
if (!result.projected) {
|
|
185
|
+
// Reuse the canonical module instead of evaluating a second copy of
|
|
186
|
+
// authored MDX effects. This import still runs the full loader chain.
|
|
187
|
+
const request = JSON.stringify(
|
|
188
|
+
`./${basename(this.resourcePath)}${context.resourceQuery}${this.resourceFragment ?? ""}`
|
|
189
|
+
);
|
|
190
|
+
result = {
|
|
191
|
+
...result,
|
|
192
|
+
forwarded: true,
|
|
193
|
+
code: `export * from ${request};\nexport { default } from ${request};`,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
onResult({ filePath: this.resourcePath, ...result });
|
|
197
|
+
} catch (error) {
|
|
198
|
+
return done(error);
|
|
199
|
+
}
|
|
200
|
+
// Both projection and canonical forwarding invalidate the original map.
|
|
201
|
+
done(null, result.code, undefined, metadata);
|
|
202
|
+
};
|
|
203
|
+
return delegate.call(context, source);
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The version-specific Fumadocs boundary. Upgrades must update these imports
|
|
2
|
+
// together and pass native/JS parity plus configuration-reload tests.
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const dist = path.dirname(fileURLToPath(import.meta.resolve("fumadocs-mdx")));
|
|
9
|
+
const version = require(path.join(dist, "../package.json")).version;
|
|
10
|
+
if (version !== "14.0.4") {
|
|
11
|
+
throw new Error(
|
|
12
|
+
`Geistdocs MDX requires fumadocs-mdx 14.0.4; found ${version}`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export const internal = (chunk) =>
|
|
16
|
+
import(pathToFileURL(path.join(dist, chunk)).href);
|
|
17
|
+
export const { fumaMatter } = await internal("chunk-VWJKRQZR.js");
|
|
18
|
+
const { createCore } = await internal("chunk-K4KWUM3J.js");
|
|
19
|
+
const cores = new Map();
|
|
20
|
+
export function getCore(options) {
|
|
21
|
+
const key = JSON.stringify([options.configPath, options.outDir]);
|
|
22
|
+
if (!cores.has(key)) {
|
|
23
|
+
cores.set(
|
|
24
|
+
key,
|
|
25
|
+
createCore({
|
|
26
|
+
environment: "webpack",
|
|
27
|
+
configPath: options.configPath,
|
|
28
|
+
outDir: options.outDir,
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return cores.get(key);
|
|
33
|
+
}
|
|
34
|
+
export const { createStandaloneConfigLoader } =
|
|
35
|
+
await internal("chunk-NKIL543T.js");
|
|
36
|
+
export const { buildConfig } = await internal("chunk-6RPNS75C.js");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const EXTENSIONS = Symbol.for("geistdocs.index-emitter.extensions");
|
|
2
|
+
|
|
3
|
+
/** One wrapper for sibling entries; re-registering on config reload replaces
|
|
4
|
+
* each extension instead of recursively wrapping another plugin's emitter. */
|
|
5
|
+
export function extendIndexEmitter(context, name, extend) {
|
|
6
|
+
const plugins = context.core.getPlugins();
|
|
7
|
+
const indexes = plugins.filter((plugin) => plugin.name === "index-file");
|
|
8
|
+
if (indexes.length === 0 && context.environment === "webpack") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (indexes.length !== 1 || typeof indexes[0].emit !== "function") {
|
|
12
|
+
throw new Error("Content entries require one Fumadocs index-file emitter");
|
|
13
|
+
}
|
|
14
|
+
const index = indexes[0];
|
|
15
|
+
let state = index.emit[EXTENSIONS];
|
|
16
|
+
if (!state) {
|
|
17
|
+
state = { original: index.emit, extensions: new Map() };
|
|
18
|
+
const emit = async function () {
|
|
19
|
+
let entries = await state.original.call(this);
|
|
20
|
+
const active = new Set(
|
|
21
|
+
context.core.getPlugins().map((plugin) => plugin.name)
|
|
22
|
+
);
|
|
23
|
+
for (const [extensionName, extension] of state.extensions) {
|
|
24
|
+
if (active.has(extensionName)) {
|
|
25
|
+
entries = await extension(entries);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return entries;
|
|
29
|
+
};
|
|
30
|
+
emit[EXTENSIONS] = state;
|
|
31
|
+
index.emit = emit;
|
|
32
|
+
}
|
|
33
|
+
state.extensions.set(name, extend);
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Experimental wrapper: point experimentalMdxLoader at this file. Ordinary MDX
|
|
4
|
+
// stays unchanged; only generated data-entry imports carry geistdocs-data=1.
|
|
5
|
+
module.exports = function loader(source) {
|
|
6
|
+
if (
|
|
7
|
+
!new URLSearchParams((this.resourceQuery ?? "").slice(1)).has(
|
|
8
|
+
"geistdocs-data"
|
|
9
|
+
)
|
|
10
|
+
) {
|
|
11
|
+
// Rendering-only workers should not load the projection parser at all.
|
|
12
|
+
return require("./loader-mdx.cjs").call(this, source);
|
|
13
|
+
}
|
|
14
|
+
const done = this.async();
|
|
15
|
+
import("./data-projection.mjs")
|
|
16
|
+
.then(({ createDataLoader }) => {
|
|
17
|
+
const { parse } = require("next/dist/compiled/acorn");
|
|
18
|
+
const delegate = require("./loader-mdx.cjs");
|
|
19
|
+
const context = Object.create(this);
|
|
20
|
+
context.async = () => done;
|
|
21
|
+
return createDataLoader(
|
|
22
|
+
delegate,
|
|
23
|
+
parse,
|
|
24
|
+
({ filePath, projected, forwarded = false, reason, code }) => {
|
|
25
|
+
// Optional diagnostics for validation builds, never enable when timing.
|
|
26
|
+
if (process.env.GEISTDOCS_DATA_REPORT) {
|
|
27
|
+
require("node:fs").appendFileSync(
|
|
28
|
+
process.env.GEISTDOCS_DATA_REPORT,
|
|
29
|
+
`${JSON.stringify({ filePath, projected, forwarded, reason, outputBytes: Buffer.byteLength(code) })}\n`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
).call(context, source);
|
|
34
|
+
})
|
|
35
|
+
.catch(done);
|
|
36
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// CommonJS entry for Turbopack/webpack, like fumadocs-mdx's own shim.
|
|
3
|
+
module.exports = function loader(source) {
|
|
4
|
+
const callback = this.async();
|
|
5
|
+
import("./loader-mdx.mjs").then(
|
|
6
|
+
(mod) => mod.run.call(this, source, callback),
|
|
7
|
+
callback
|
|
8
|
+
);
|
|
9
|
+
};
|