fumadocs-mdx 14.2.10 → 14.2.12
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/{adapter-nuKMfIZz.js → adapter-CzI6jiMm.js} +3 -3
- package/dist/adapter-CzI6jiMm.js.map +1 -0
- package/dist/build-mdx-CAXqH1_C.d.ts.map +1 -1
- package/dist/{build-mdx-C5FB6EIF.js → build-mdx-LmiB2qsc.js} +38 -12
- package/dist/build-mdx-LmiB2qsc.js.map +1 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +2 -5
- package/dist/bun/index.js.map +1 -1
- package/dist/codegen-Bd9bQlN7.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -2
- package/dist/config/index.js.map +1 -1
- package/dist/{core-BF3YhvIc.d.ts → core-C9TGjTWd.d.ts} +3 -2
- package/dist/core-C9TGjTWd.d.ts.map +1 -0
- package/dist/{index-file-B04Qazjk.js → index-file-4qOxhCQn.js} +8 -6
- package/dist/index-file-4qOxhCQn.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/{mdx-OAccQ48U.js → mdx-D95UF4l1.js} +2 -2
- package/dist/{mdx-OAccQ48U.js.map → mdx-D95UF4l1.js.map} +1 -1
- package/dist/next/index.cjs +7 -5
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +1 -5
- package/dist/next/index.js.map +1 -1
- package/dist/node/loader.js +2 -4
- package/dist/node/loader.js.map +1 -1
- package/dist/plugins/index-file.d.ts +1 -1
- package/dist/plugins/index-file.js +1 -3
- package/dist/plugins/json-schema.d.ts +2 -1
- package/dist/plugins/json-schema.d.ts.map +1 -1
- package/dist/plugins/json-schema.js +1 -1
- package/dist/plugins/json-schema.js.map +1 -1
- package/dist/plugins/last-modified.d.ts +2 -1
- package/dist/plugins/last-modified.d.ts.map +1 -1
- package/dist/{remark-include-C1PuNrmK.js → remark-include-CgjB4_2e.js} +2 -2
- package/dist/{remark-include-C1PuNrmK.js.map → remark-include-CgjB4_2e.js.map} +1 -1
- package/dist/runtime/browser.d.ts +2 -2
- package/dist/runtime/browser.js.map +1 -1
- package/dist/runtime/dynamic.d.ts +5 -5
- package/dist/runtime/dynamic.d.ts.map +1 -1
- package/dist/runtime/dynamic.js +2 -5
- package/dist/runtime/dynamic.js.map +1 -1
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/server.js +1 -1
- package/dist/runtime/server.js.map +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +3 -6
- package/dist/vite/index.js.map +1 -1
- package/dist/webpack/mdx.js +2 -5
- package/dist/webpack/mdx.js.map +1 -1
- package/dist/webpack/meta.js +1 -3
- package/dist/webpack/meta.js.map +1 -1
- package/package.json +17 -18
- package/dist/adapter-nuKMfIZz.js.map +0 -1
- package/dist/build-mdx-C5FB6EIF.js.map +0 -1
- package/dist/core-BF3YhvIc.d.ts.map +0 -1
- package/dist/index-file-B04Qazjk.js.map +0 -1
|
@@ -44,7 +44,7 @@ function toNode(loader) {
|
|
|
44
44
|
filePath,
|
|
45
45
|
query: Object.fromEntries(parsedUrl.searchParams.entries()),
|
|
46
46
|
async getSource() {
|
|
47
|
-
return
|
|
47
|
+
return await fs.readFile(filePath, "utf-8");
|
|
48
48
|
},
|
|
49
49
|
development: false,
|
|
50
50
|
compiler: { addDependency() {} }
|
|
@@ -130,7 +130,7 @@ function toBun(loader) {
|
|
|
130
130
|
development: false,
|
|
131
131
|
compiler: { addDependency() {} }
|
|
132
132
|
};
|
|
133
|
-
if (loader.bun?.load) return loader.bun.load(readFileSync(filePath)
|
|
133
|
+
if (loader.bun?.load) return loader.bun.load(readFileSync(filePath, "utf-8"), input);
|
|
134
134
|
const result = loader.load(input);
|
|
135
135
|
if (result instanceof Promise) return result.then(toResult);
|
|
136
136
|
return toResult(result);
|
|
@@ -140,4 +140,4 @@ function toBun(loader) {
|
|
|
140
140
|
//#endregion
|
|
141
141
|
export { createIntegratedConfigLoader as a, toWebpack as i, toNode as n, createStandaloneConfigLoader as o, toVite as r, toBun as t };
|
|
142
142
|
|
|
143
|
-
//# sourceMappingURL=adapter-
|
|
143
|
+
//# sourceMappingURL=adapter-CzI6jiMm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-CzI6jiMm.js","names":[],"sources":["../src/loaders/config.ts","../src/loaders/adapter.ts"],"sourcesContent":["import type { Core } from '@/core';\nimport fs from 'node:fs/promises';\n\nexport interface ConfigLoader {\n getCore(): Promise<Core>;\n}\n\nexport function createStandaloneConfigLoader({\n core,\n buildConfig,\n mode,\n}: {\n /**\n * core (not initialized)\n */\n core: Core;\n buildConfig: boolean;\n /**\n * In dev mode, the config file is dynamically re-loaded when it's updated.\n */\n mode: 'dev' | 'production';\n}): ConfigLoader {\n let prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined;\n\n async function getConfigHash(): Promise<string> {\n if (mode === 'production') return 'static';\n\n const stats = await fs.stat(core.getOptions().configPath).catch(() => {\n throw new Error('Cannot find config file');\n });\n\n return stats.mtime.getTime().toString();\n }\n\n return {\n async getCore() {\n const hash = await getConfigHash();\n if (!prev || hash !== prev.hash) {\n prev = {\n hash,\n init: (async () => {\n const { loadConfig } = await import('../config/load-from-file');\n\n await core.init({\n config: loadConfig(core, buildConfig),\n });\n })(),\n };\n }\n\n await prev.init;\n return core;\n },\n };\n}\n\n/**\n * create config loader from initialized core\n */\nexport function createIntegratedConfigLoader(core: Core): ConfigLoader {\n return {\n async getCore() {\n return core;\n },\n };\n}\n","import type { CompilerOptions } from '@/loaders/mdx/build-mdx';\nimport type { LoadFnOutput, LoadHook } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport fs from 'node:fs/promises';\nimport type { TransformPluginContext } from 'rolldown';\nimport type { Environment, TransformResult } from 'vite';\nimport { parse } from 'node:querystring';\nimport { ValidationError } from '@/utils/validation';\nimport type { LoaderContext } from 'webpack';\nimport { readFileSync } from 'node:fs';\n\nexport interface LoaderInput {\n development: boolean;\n compiler: CompilerOptions;\n\n filePath: string;\n query: Record<string, string | string[] | undefined>;\n getSource: () => string | Promise<string>;\n}\n\nexport interface LoaderOutput {\n code: string;\n map?: unknown;\n\n /**\n * Only supported in Vite 8.\n *\n * Explicitly define the transformed module type, for unsupported environments, you need to consider the differences between each bundler.\n */\n moduleType?: 'js' | 'json';\n}\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface Loader {\n /**\n * Filter file paths, the input can be either a file URL or file path.\n *\n * Must take resource query into consideration.\n */\n test?: RegExp;\n\n /**\n * Transform input into JavaScript.\n *\n * Returns:\n * - `LoaderOutput`: JavaScript code & source map.\n * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.\n */\n load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;\n\n bun?: {\n /**\n * 1. Bun doesn't allow `null` in loaders.\n * 2. Bun requires sync result to support dynamic require().\n */\n load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;\n };\n}\n\nexport function toNode(loader: Loader): LoadHook {\n return async (url, _context, nextLoad): Promise<LoadFnOutput> => {\n if (url.startsWith('file:///') && (!loader.test || loader.test.test(url))) {\n const parsedUrl = new URL(url);\n const filePath = fileURLToPath(parsedUrl);\n\n const result = await loader.load({\n filePath,\n query: Object.fromEntries(parsedUrl.searchParams.entries()),\n async getSource() {\n return await fs.readFile(filePath, 'utf-8');\n },\n development: false,\n compiler: {\n addDependency() {},\n },\n });\n\n if (result) {\n return {\n source: result.code,\n format: 'module',\n shortCircuit: true,\n };\n }\n }\n\n return nextLoad(url);\n };\n}\n\nexport interface ViteLoader {\n filter: (id: string) => boolean;\n\n transform: (\n this: TransformPluginContext & { environment: Environment },\n value: string,\n id: string,\n ) => Promise<TransformResult | null>;\n}\n\nexport function toVite(loader: Loader): ViteLoader {\n return {\n filter(id) {\n return !loader.test || loader.test.test(id);\n },\n async transform(value, id) {\n const environment = this.environment;\n const [file, query = ''] = id.split('?', 2);\n\n const result = await loader.load({\n filePath: file,\n query: parse(query),\n getSource() {\n return value;\n },\n development: environment.mode === 'dev',\n compiler: {\n addDependency: (file) => {\n this.addWatchFile(file);\n },\n },\n });\n\n if (result === null) return null;\n return {\n code: result.code,\n map: result.map as TransformResult['map'],\n moduleType: result.moduleType,\n };\n },\n };\n}\n\nexport type WebpackLoader = (\n this: LoaderContext<unknown>,\n source: string,\n callback: LoaderContext<unknown>['callback'],\n) => Promise<void>;\n\n/**\n * need to handle the `test` regex in Webpack config instead.\n */\nexport function toWebpack(loader: Loader): WebpackLoader {\n return async function (source, callback) {\n try {\n const result = await loader.load({\n filePath: this.resourcePath,\n query: parse(this.resourceQuery.slice(1)),\n getSource() {\n return source;\n },\n development: this.mode === 'development',\n compiler: this,\n });\n\n if (result === null) {\n callback(undefined, source);\n } else {\n callback(undefined, result.code, result.map as string);\n }\n } catch (error) {\n if (error instanceof ValidationError) {\n return callback(new Error(await error.toStringFormatted()));\n }\n\n if (!(error instanceof Error)) throw error;\n callback(error);\n }\n };\n}\n\nexport function toBun(loader: Loader) {\n function toResult(output: LoaderOutput | null): Bun.OnLoadResult {\n // it errors, treat this as an exception\n if (!output) return;\n\n return {\n contents: output.code,\n loader: output.moduleType ?? 'js',\n };\n }\n\n return (build: Bun.PluginBuilder) => {\n // avoid using async here, because it will cause dynamic require() to fail\n build.onLoad({ filter: loader.test ?? /.+/ }, (args) => {\n const [filePath, query = ''] = args.path.split('?', 2);\n const input: LoaderInput = {\n async getSource() {\n return Bun.file(filePath).text();\n },\n query: parse(query),\n filePath,\n development: false,\n compiler: {\n addDependency() {},\n },\n };\n\n if (loader.bun?.load) {\n return loader.bun.load(readFileSync(filePath, 'utf-8'), input);\n }\n\n const result = loader.load(input);\n if (result instanceof Promise) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"m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,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE;GACtD,MAAM,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,UAAU,QAAQ,EAAE,MAAM;GAGhE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,kBAAkB,QACpB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-mdx-CAXqH1_C.d.ts","names":[],"sources":["../src/loaders/mdx/build-mdx.ts"],"mappings":";;;;;;;;KAWK,SAAA,GAAY,UAAA,QAAkB,eAAA;AAAA,UAelB,eAAA;EACf,aAAA,GAAgB,IAAA;AAAA;AAAA,UAGD,qBAAA,eAAoC,MAAA;EACnD,WAAA,EAAa,WAAA;EACb,cAAA,EAAgB,cAAA;EAChB,GAAA,EAAK,WAAA;EACL,OAAA,EAAS,EAAA,CAAG,QAAA;EAAD;;;EAKX,SAAA;
|
|
1
|
+
{"version":3,"file":"build-mdx-CAXqH1_C.d.ts","names":[],"sources":["../src/loaders/mdx/build-mdx.ts"],"mappings":";;;;;;;;KAWK,SAAA,GAAY,UAAA,QAAkB,eAAA;AAAA,UAelB,eAAA;EACf,aAAA,GAAgB,IAAA;AAAA;AAAA,UAGD,qBAAA,eAAoC,MAAA;EACnD,WAAA,EAAa,WAAA;EACb,cAAA,EAAgB,cAAA;EAChB,GAAA,EAAK,WAAA;EACL,OAAA,EAAS,EAAA,CAAG,QAAA;EAAD;;;EAKX,SAAA;EARA;;;EAYA,MAAA;AAAA;AAAA,UAGe,eAAA;EAZf;;;EAgBA,WAAA,GAAc,MAAA;EAPd;;;EAYA,YAAA;IAAiB,IAAA;IAAc,KAAA;EAAA;EAKnB;;;EAAZ,SAAA,GAAY,eAAA;EAVZ;;;EAeA,aAAA,IAAiB,MAAA,mBAAyB,SAAA;AAAA;AAAA;EAAA,UAKhC,OAAA,SAAgB,eAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
-
import { n as flattenNode, t as remarkInclude } from "./remark-include-
|
|
2
|
+
import { n as flattenNode, t as remarkInclude } from "./remark-include-CgjB4_2e.js";
|
|
3
3
|
import { visit } from "unist-util-visit";
|
|
4
4
|
import { VFile } from "vfile";
|
|
5
5
|
import { createProcessor } from "@mdx-js/mdx";
|
|
@@ -7,7 +7,7 @@ import { valueToEstree } from "estree-util-value-to-estree";
|
|
|
7
7
|
import { removePosition } from "unist-util-remove-position";
|
|
8
8
|
import { mdxToMarkdown } from "mdast-util-mdx";
|
|
9
9
|
import { toMarkdown } from "mdast-util-to-markdown";
|
|
10
|
-
//#region ../core/dist/
|
|
10
|
+
//#region ../core/dist/utils-C73VXFR0.js
|
|
11
11
|
function toMdxExport(name, value) {
|
|
12
12
|
return toMdxExportRaw(name, valueToEstree(value));
|
|
13
13
|
}
|
|
@@ -54,12 +54,15 @@ function defaultStringifier(config = {}) {
|
|
|
54
54
|
return "children-only";
|
|
55
55
|
}
|
|
56
56
|
return true;
|
|
57
|
-
},
|
|
57
|
+
}, stringify, ...customExtension } = config;
|
|
58
58
|
function modHandler(handler, ctx) {
|
|
59
59
|
return function(node, parent, state, info) {
|
|
60
60
|
let visibility = filterElement(node);
|
|
61
61
|
if (visibility === false) return "";
|
|
62
|
-
if (
|
|
62
|
+
if (stringify) {
|
|
63
|
+
const v = stringify(node, parent, state, info, ctx);
|
|
64
|
+
if (v) return v;
|
|
65
|
+
}
|
|
63
66
|
const extraInfo = node.data?._stringify;
|
|
64
67
|
if (extraInfo) if (extraInfo === "children-only") visibility = "children-only";
|
|
65
68
|
else if ("text" in extraInfo) return extraInfo.text;
|
|
@@ -126,28 +129,52 @@ function defaultStringifier(config = {}) {
|
|
|
126
129
|
/**
|
|
127
130
|
* generate `llms.txt` for markdown.
|
|
128
131
|
*/
|
|
129
|
-
function remarkLLMs({ as = "_markdown", headingIds = true, ...
|
|
132
|
+
function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsPlaceholder, ...rest } = {}) {
|
|
130
133
|
const stringifier = defaultStringifier({
|
|
131
|
-
...
|
|
134
|
+
...rest,
|
|
132
135
|
filterElement(node) {
|
|
133
136
|
switch (node.type) {
|
|
134
137
|
case "mdxjsEsm": return false;
|
|
135
138
|
default: return true;
|
|
136
139
|
}
|
|
137
140
|
},
|
|
141
|
+
stringify(node, parent, state, info, ctx) {
|
|
142
|
+
if (mdxAsPlaceholder) switch (node.type) {
|
|
143
|
+
case "mdxJsxFlowElement":
|
|
144
|
+
case "mdxJsxTextElement": if (node.name && mdxAsPlaceholder.includes(node.name)) return placeholder(node, parent, state, info);
|
|
145
|
+
}
|
|
146
|
+
return rest.stringify?.(node, parent, state, info, ctx);
|
|
147
|
+
},
|
|
138
148
|
handlers: {
|
|
139
149
|
heading(node, _p, state, info) {
|
|
140
150
|
const id = node.data?.hProperties?.id;
|
|
141
151
|
const content = state.containerPhrasing(node, info);
|
|
142
152
|
return headingIds && id ? `${content} [#${id}]` : content;
|
|
143
153
|
},
|
|
144
|
-
...
|
|
154
|
+
...rest.handlers
|
|
145
155
|
}
|
|
146
156
|
});
|
|
147
|
-
return (node) => {
|
|
148
|
-
|
|
157
|
+
return (node, file) => {
|
|
158
|
+
const value = stringifier.call(this, node, void 0);
|
|
159
|
+
node.children.unshift(toMdxExport(as, value));
|
|
160
|
+
if (_data) file.data.markdown = value;
|
|
149
161
|
};
|
|
150
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Preserve AST data to render the MDX component at runtime, use `renderPlaceholder()` to render the placeholders.
|
|
165
|
+
*/
|
|
166
|
+
function placeholder(node, _parent, state, info) {
|
|
167
|
+
const attributes = {};
|
|
168
|
+
for (const attr of node.attributes) {
|
|
169
|
+
if (attr.type === "mdxJsxExpressionAttribute") continue;
|
|
170
|
+
attributes[attr.name] = attr.value;
|
|
171
|
+
}
|
|
172
|
+
return `\0${JSON.stringify({
|
|
173
|
+
name: node.name,
|
|
174
|
+
children: state.containerPhrasing(node, info),
|
|
175
|
+
attributes
|
|
176
|
+
})}\0`;
|
|
177
|
+
}
|
|
151
178
|
//#endregion
|
|
152
179
|
//#region src/loaders/mdx/remark-postprocess.ts
|
|
153
180
|
/**
|
|
@@ -181,8 +208,7 @@ function remarkPostprocess({ includeProcessedMarkdown = false, includeMDAST = fa
|
|
|
181
208
|
}
|
|
182
209
|
if (includeProcessedMarkdown) remarkLLMs.call(this, typeof includeProcessedMarkdown === "object" ? includeProcessedMarkdown : void 0)(tree, file, () => void 0);
|
|
183
210
|
if (includeMDAST) {
|
|
184
|
-
const
|
|
185
|
-
const mdast = JSON.stringify(options.removePosition ? removePosition(structuredClone(tree)) : tree);
|
|
211
|
+
const mdast = JSON.stringify((includeMDAST === true ? {} : includeMDAST).removePosition ? removePosition(structuredClone(tree)) : tree);
|
|
186
212
|
file.data["mdx-export"].push({
|
|
187
213
|
name: "_mdast",
|
|
188
214
|
value: mdast
|
|
@@ -278,4 +304,4 @@ async function buildMDX(core, collection, { filePath, frontmatter, source, _comp
|
|
|
278
304
|
//#endregion
|
|
279
305
|
export { build_mdx_exports as n, buildMDX as t };
|
|
280
306
|
|
|
281
|
-
//# sourceMappingURL=build-mdx-
|
|
307
|
+
//# sourceMappingURL=build-mdx-LmiB2qsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-mdx-LmiB2qsc.js","names":[],"sources":["../../core/dist/utils-C73VXFR0.js","../../core/dist/mdx-plugins/stringifier.js","../../core/dist/mdx-plugins/remark-llms.js","../src/loaders/mdx/remark-postprocess.ts","../src/loaders/mdx/build-mdx.ts"],"sourcesContent":["import { valueToEstree } from \"estree-util-value-to-estree\";\n//#region src/mdx-plugins/utils.ts\nfunction flattenNode(node) {\n\tif (\"children\" in node) return node.children.map((child) => flattenNode(child)).join(\"\");\n\tif (\"value\" in node && typeof node.value === \"string\") return node.value;\n\treturn \"\";\n}\nfunction toMdxExport(name, value) {\n\treturn toMdxExportRaw(name, valueToEstree(value));\n}\nfunction toMdxExportRaw(name, expression) {\n\treturn {\n\t\ttype: \"mdxjsEsm\",\n\t\tvalue: \"\",\n\t\tdata: { estree: {\n\t\t\ttype: \"Program\",\n\t\t\tsourceType: \"module\",\n\t\t\tbody: [{\n\t\t\t\ttype: \"ExportNamedDeclaration\",\n\t\t\t\tattributes: [],\n\t\t\t\tspecifiers: [],\n\t\t\t\tdeclaration: {\n\t\t\t\t\ttype: \"VariableDeclaration\",\n\t\t\t\t\tkind: \"let\",\n\t\t\t\t\tdeclarations: [{\n\t\t\t\t\t\ttype: \"VariableDeclarator\",\n\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\ttype: \"Identifier\",\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinit: expression\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t}]\n\t\t} }\n\t};\n}\nfunction handleTag(value, tag) {\n\tconst idx = value.indexOf(tag);\n\tif (idx !== -1) return value.slice(0, idx).trimEnd() + value.slice(idx + tag.length);\n\treturn false;\n}\n//#endregion\nexport { toMdxExportRaw as i, handleTag as n, toMdxExport as r, flattenNode as t };\n","import { mdxToMarkdown } from \"mdast-util-mdx\";\nimport { toMarkdown } from \"mdast-util-to-markdown\";\n//#region src/mdx-plugins/stringifier.ts\nfunction defaultStringifier(config = {}) {\n\tconst { filterMdxAttributes, filterElement = (node) => {\n\t\tswitch (node.type) {\n\t\t\tcase \"mdxJsxFlowElement\":\n\t\t\tcase \"mdxJsxTextElement\":\n\t\t\t\tswitch (node.name) {\n\t\t\t\t\tcase \"File\":\n\t\t\t\t\tcase \"TypeTable\":\n\t\t\t\t\tcase \"Callout\":\n\t\t\t\t\tcase \"Card\": return true;\n\t\t\t\t}\n\t\t\t\treturn \"children-only\";\n\t\t}\n\t\treturn true;\n\t}, stringify, ...customExtension } = config;\n\tfunction modHandler(handler, ctx) {\n\t\treturn function(node, parent, state, info) {\n\t\t\tlet visibility = filterElement(node);\n\t\t\tif (visibility === false) return \"\";\n\t\t\tif (stringify) {\n\t\t\t\tconst v = stringify(node, parent, state, info, ctx);\n\t\t\t\tif (v) return v;\n\t\t\t}\n\t\t\tconst extraInfo = node.data?._stringify;\n\t\t\tif (extraInfo) if (extraInfo === \"children-only\") visibility = \"children-only\";\n\t\t\telse if (\"text\" in extraInfo) return extraInfo.text;\n\t\t\telse node = extraInfo.node;\n\t\t\tif (visibility === \"children-only\") {\n\t\t\t\tif (!(\"children\" in node)) return \"\";\n\t\t\t\tswitch (node.type) {\n\t\t\t\t\tcase \"mdxJsxTextElement\":\n\t\t\t\t\tcase \"paragraph\": return state.containerPhrasing(node, info);\n\t\t\t\t\tcase \"mdxJsxFlowElement\": return state.containerFlow(node, info);\n\t\t\t\t\tdefault: return state.containerFlow({\n\t\t\t\t\t\ttype: \"root\",\n\t\t\t\t\t\tchildren: node.children\n\t\t\t\t\t}, info);\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (node.type) {\n\t\t\t\tcase \"mdxJsxFlowElement\":\n\t\t\t\tcase \"mdxJsxTextElement\": {\n\t\t\t\t\tconst stringifiedAttributes = [];\n\t\t\t\t\tfor (const attr of node.attributes) {\n\t\t\t\t\t\tif (attr.type === \"mdxJsxExpressionAttribute\") continue;\n\t\t\t\t\t\tif (filterMdxAttributes && !filterMdxAttributes(node, attr)) continue;\n\t\t\t\t\t\tconst str = typeof attr.value === \"string\" ? attr.value : attr.value?.value;\n\t\t\t\t\t\tif (!str) continue;\n\t\t\t\t\t\tstringifiedAttributes.push({\n\t\t\t\t\t\t\ttype: \"mdxJsxAttribute\",\n\t\t\t\t\t\t\tname: attr.name,\n\t\t\t\t\t\t\tvalue: str\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn handler({\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\tattributes: stringifiedAttributes\n\t\t\t\t\t}, parent, state, info);\n\t\t\t\t}\n\t\t\t\tdefault: return handler(node, parent, state, info);\n\t\t\t}\n\t\t};\n\t}\n\tconst customToMarkdown = { handlers: { _custom(node, _, state, info) {\n\t\tconst handlers = state.handlers;\n\t\tfor (const k in handlers) handlers[k] = modHandler(handlers[k], node.ctx);\n\t\treturn state.handle(node.root, void 0, state, info);\n\t} } };\n\treturn function(root, ctx) {\n\t\treturn toMarkdown({\n\t\t\ttype: \"_custom\",\n\t\t\troot,\n\t\t\tctx\n\t\t}, {\n\t\t\t...this?.data(\"settings\"),\n\t\t\textensions: [\n\t\t\t\tmdxToMarkdown(),\n\t\t\t\t...this?.data(\"toMarkdownExtensions\") ?? [],\n\t\t\t\tcustomToMarkdown,\n\t\t\t\tcustomExtension\n\t\t\t]\n\t\t});\n\t};\n}\n//#endregion\nexport { defaultStringifier };\n","import { r as toMdxExport } from \"../utils-C73VXFR0.js\";\nimport { defaultStringifier } from \"./stringifier.js\";\n//#region src/mdx-plugins/remark-llms.ts\n/**\n* generate `llms.txt` for markdown.\n*/\nfunction remarkLLMs({ as = \"_markdown\", headingIds = true, _data = false, mdxAsPlaceholder, ...rest } = {}) {\n\tconst stringifier = defaultStringifier({\n\t\t...rest,\n\t\tfilterElement(node) {\n\t\t\tswitch (node.type) {\n\t\t\t\tcase \"mdxjsEsm\": return false;\n\t\t\t\tdefault: return true;\n\t\t\t}\n\t\t},\n\t\tstringify(node, parent, state, info, ctx) {\n\t\t\tif (mdxAsPlaceholder) switch (node.type) {\n\t\t\t\tcase \"mdxJsxFlowElement\":\n\t\t\t\tcase \"mdxJsxTextElement\": if (node.name && mdxAsPlaceholder.includes(node.name)) return placeholder(node, parent, state, info);\n\t\t\t}\n\t\t\treturn rest.stringify?.(node, parent, state, info, ctx);\n\t\t},\n\t\thandlers: {\n\t\t\theading(node, _p, state, info) {\n\t\t\t\tconst id = node.data?.hProperties?.id;\n\t\t\t\tconst content = state.containerPhrasing(node, info);\n\t\t\t\treturn headingIds && id ? `${content} [#${id}]` : content;\n\t\t\t},\n\t\t\t...rest.handlers\n\t\t}\n\t});\n\treturn (node, file) => {\n\t\tconst value = stringifier.call(this, node, void 0);\n\t\tnode.children.unshift(toMdxExport(as, value));\n\t\tif (_data) file.data.markdown = value;\n\t};\n}\n/**\n* Preserve AST data to render the MDX component at runtime, use `renderPlaceholder()` to render the placeholders.\n*/\nfunction placeholder(node, _parent, state, info) {\n\tconst attributes = {};\n\tfor (const attr of node.attributes) {\n\t\tif (attr.type === \"mdxJsxExpressionAttribute\") continue;\n\t\tattributes[attr.name] = attr.value;\n\t}\n\treturn `\\0${JSON.stringify({\n\t\tname: node.name,\n\t\tchildren: state.containerPhrasing(node, info),\n\t\tattributes\n\t})}\\0`;\n}\n//#endregion\nexport { placeholder, remarkLLMs };\n","import type { Processor, Transformer } from 'unified';\nimport type { Root, RootContent } from 'mdast';\nimport { visit } from 'unist-util-visit';\nimport { valueToEstree } from 'estree-util-value-to-estree';\nimport { removePosition } from 'unist-util-remove-position';\nimport { flattenNode } from './mdast-utils';\nimport type { LLMsOptions } from 'fumadocs-core/mdx-plugins';\nimport { remarkLLMs } from 'fumadocs-core/mdx-plugins/remark-llms';\n\nexport interface ExtractedReference {\n href: string;\n}\n\nexport interface PostprocessOptions {\n _format: 'md' | 'mdx';\n\n /**\n * Properties to export from `vfile.data`\n */\n valueToExport?: string[];\n\n /**\n * stringify MDAST and export via `_markdown`.\n */\n includeProcessedMarkdown?: boolean | LLMsOptions;\n\n /**\n * extract link references, export via `extractedReferences`.\n */\n extractLinkReferences?: boolean;\n\n /**\n * store MDAST and export via `_mdast`.\n */\n includeMDAST?:\n | boolean\n | {\n removePosition?: boolean;\n };\n}\n\n/**\n * - collect references\n * - write frontmatter (auto-title & description)\n */\nexport function remarkPostprocess(\n this: Processor,\n {\n includeProcessedMarkdown = false,\n includeMDAST = false,\n extractLinkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\n return (tree, file) => {\n const frontmatter = (file.data.frontmatter ??= {});\n if (!frontmatter.title) {\n visit(tree, 'heading', (node) => {\n if (node.depth === 1) {\n frontmatter.title = flattenNode(node);\n return false;\n }\n });\n }\n\n file.data['mdx-export'] ??= [];\n file.data['mdx-export'].push({\n name: 'frontmatter',\n value: frontmatter,\n });\n\n if (extractLinkReferences) {\n const urls: ExtractedReference[] = [];\n\n visit(tree, 'link', (node) => {\n urls.push({\n href: node.url,\n });\n return 'skip';\n });\n\n file.data['mdx-export'].push({\n name: 'extractedReferences',\n value: urls,\n });\n }\n\n if (includeProcessedMarkdown) {\n const llms = remarkLLMs.call(\n this,\n typeof includeProcessedMarkdown === 'object' ? includeProcessedMarkdown : undefined,\n );\n llms(tree, file, () => undefined);\n }\n\n if (includeMDAST) {\n const options = includeMDAST === true ? {} : includeMDAST;\n const mdast = JSON.stringify(\n options.removePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data['mdx-export'].push({\n name: '_mdast',\n value: mdast,\n });\n }\n\n for (const { name, value } of file.data['mdx-export']) {\n tree.children.unshift(getMdastExport(name, value));\n }\n\n // reset the data to reduce memory usage\n file.data['mdx-export'] = [];\n\n for (const name of valueToExport) {\n if (!(name in file.data)) continue;\n\n tree.children.unshift(getMdastExport(name, file.data[name]));\n }\n };\n}\n\n/**\n * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins\n *\n * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node\n */\nfunction getMdastExport(name: string, value: unknown): RootContent {\n return {\n type: 'mdxjsEsm',\n value: '',\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: [\n {\n type: 'ExportNamedDeclaration',\n attributes: [],\n specifiers: [],\n source: null,\n declaration: {\n type: 'VariableDeclaration',\n kind: 'let',\n declarations: [\n {\n type: 'VariableDeclarator',\n id: {\n type: 'Identifier',\n name,\n },\n init: valueToEstree(value),\n },\n ],\n },\n },\n ],\n },\n },\n };\n}\n","import { createProcessor } from '@mdx-js/mdx';\nimport { VFile } from 'vfile';\nimport { remarkInclude } from '@/loaders/mdx/remark-include';\nimport type { StructuredData } from 'fumadocs-core/mdx-plugins';\nimport type { TOCItemType } from 'fumadocs-core/toc';\nimport type { FC } from 'react';\nimport type { MDXProps } from 'mdx/types';\nimport { type PostprocessOptions, remarkPostprocess } from '@/loaders/mdx/remark-postprocess';\nimport type { Core } from '@/core';\nimport type { DocCollectionItem } from '@/config/build';\n\ntype Processor = ReturnType<typeof createProcessor>;\n\ninterface BuildMDXOptions {\n /**\n * Specify a file path for source\n */\n filePath: string;\n source: string;\n frontmatter?: Record<string, unknown>;\n\n environment: 'bundler' | 'runtime';\n isDevelopment: boolean;\n _compiler?: CompilerOptions;\n}\n\nexport interface CompilerOptions {\n addDependency: (file: string) => void;\n}\n\nexport interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {\n frontmatter: Frontmatter;\n structuredData: StructuredData;\n toc: TOCItemType[];\n default: FC<MDXProps>;\n\n /**\n * Enable from `postprocess` option.\n */\n _markdown?: string;\n /**\n * Enable from `postprocess` option.\n */\n _mdast?: string;\n}\n\nexport interface FumadocsDataMap {\n /**\n * [Fumadocs MDX] raw frontmatter, you can modify it\n */\n frontmatter?: Record<string, unknown>;\n\n /**\n * [Fumadocs MDX] additional ESM exports to write\n */\n 'mdx-export'?: { name: string; value: unknown }[];\n\n /**\n * [Fumadocs MDX] The compiler object from loader\n */\n _compiler?: CompilerOptions;\n\n /**\n * [Fumadocs MDX] get internal processor, do not use this on user land.\n */\n _getProcessor?: (format: 'md' | 'mdx') => Processor;\n}\n\ndeclare module 'vfile' {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap extends FumadocsDataMap {}\n}\n\nexport async function buildMDX(\n core: Core,\n collection: DocCollectionItem | undefined,\n { filePath, frontmatter, source, _compiler, environment, isDevelopment }: BuildMDXOptions,\n): Promise<VFile> {\n const mdxOptions = await core.getConfig().getMDXOptions(collection, environment);\n\n function getProcessor(format: 'md' | 'mdx') {\n const cache = core.cache as Map<string, Processor>;\n const key = `build-mdx:${collection?.name ?? 'global'}:${format}`;\n let processor = cache.get(key);\n\n if (!processor) {\n const postprocessOptions: PostprocessOptions = {\n _format: format,\n ...collection?.postprocess,\n };\n\n processor = createProcessor({\n outputFormat: 'program',\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins: [\n remarkInclude,\n ...(mdxOptions.remarkPlugins ?? []),\n [remarkPostprocess, postprocessOptions],\n ],\n format,\n });\n\n cache.set(key, processor);\n }\n\n return processor;\n }\n\n let vfile = new VFile({\n value: source,\n path: filePath,\n cwd: collection?.cwd,\n data: { frontmatter, _compiler, _getProcessor: getProcessor },\n });\n\n if (collection) {\n vfile = await core.transformVFile({ collection, filePath, source }, vfile);\n }\n\n return getProcessor(filePath.endsWith('.mdx') ? 'mdx' : 'md').process(vfile);\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAS,YAAY,MAAM,OAAO;AACjC,QAAO,eAAe,MAAM,cAAc,MAAM,CAAC;;AAElD,SAAS,eAAe,MAAM,YAAY;AACzC,QAAO;EACN,MAAM;EACN,OAAO;EACP,MAAM,EAAE,QAAQ;GACf,MAAM;GACN,YAAY;GACZ,MAAM,CAAC;IACN,MAAM;IACN,YAAY,EAAE;IACd,YAAY,EAAE;IACd,aAAa;KACZ,MAAM;KACN,MAAM;KACN,cAAc,CAAC;MACd,MAAM;MACN,IAAI;OACH,MAAM;OACN;OACA;MACD,MAAM;MACN,CAAC;KACF;IACD,CAAC;GACF,EAAE;EACH;;;;AChCF,SAAS,mBAAmB,SAAS,EAAE,EAAE;CACxC,MAAM,EAAE,qBAAqB,iBAAiB,SAAS;AACtD,UAAQ,KAAK,MAAb;GACC,KAAK;GACL,KAAK;AACJ,YAAQ,KAAK,MAAb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SAAO;;CAGT,IAAI,QAAQ,IAAI,MAAM;EACpB,OAAO;EACP,MAAM;EACN,KAAK,YAAY;EACjB,MAAM;GAAE;GAAa;GAAW,eAAe;GAAc;EAC9D,CAAC;AAEF,KAAI,WACF,SAAQ,MAAM,KAAK,eAAe;EAAE;EAAY;EAAU;EAAQ,EAAE,MAAM;AAG5E,QAAO,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,CAAC,QAAQ,MAAM"}
|
package/dist/bun/index.d.ts
CHANGED
package/dist/bun/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bun/index.ts"],"mappings":";;;;UASiB,gBAAA,SAAyB,OAAA,CAAQ,WAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bun/index.ts"],"mappings":";;;;UASiB,gBAAA,SAAyB,OAAA,CAAQ,WAAA;;AAAlD;;EAIE,eAAA;AAAA;AAAA,iBAGc,eAAA,CAAgB,OAAA,GAAS,gBAAA,GAAwB,SAAA"}
|
package/dist/bun/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { t as createMdxLoader } from "../mdx-OAccQ48U.js";
|
|
3
|
-
import "../preset-BjHACE1Z.js";
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-D95UF4l1.js";
|
|
4
2
|
import { t as buildConfig } from "../build-DxkMdv29.js";
|
|
5
3
|
import { n as createCore, t as _Defaults } from "../core-BluWnx7f.js";
|
|
6
|
-
import "../
|
|
7
|
-
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-nuKMfIZz.js";
|
|
4
|
+
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-CzI6jiMm.js";
|
|
8
5
|
import { t as createMetaLoader } from "../meta-Di0sMUh5.js";
|
|
9
6
|
import { pathToFileURL } from "node:url";
|
|
10
7
|
//#region src/bun/index.ts
|
package/dist/bun/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/bun/index.ts"],"sourcesContent":["import type { BunPlugin } from 'bun';\nimport { createMdxLoader } from '@/loaders/mdx';\nimport { buildConfig } from '@/config/build';\nimport { pathToFileURL } from 'node:url';\nimport { _Defaults, type CoreOptions, createCore } from '@/core';\nimport { createIntegratedConfigLoader } from '@/loaders/config';\nimport { createMetaLoader } from '@/loaders/meta';\nimport { toBun } from '@/loaders/adapter';\n\nexport interface MdxPluginOptions extends Partial<CoreOptions> {\n /**\n * Skip meta file transformation step\n */\n disableMetaFile?: boolean;\n}\n\nexport function createMdxPlugin(options: MdxPluginOptions = {}): BunPlugin {\n const {\n environment = 'bun',\n outDir = _Defaults.outDir,\n configPath = _Defaults.configPath,\n disableMetaFile = false,\n } = options;\n\n return {\n name: 'bun-plugin-fumadocs-mdx',\n async setup(build) {\n const importPath = pathToFileURL(configPath).href;\n const core = createCore({\n environment,\n outDir,\n configPath,\n });\n\n await core.init({\n config: buildConfig(await import(importPath)),\n });\n\n const configLoader = createIntegratedConfigLoader(core);\n toBun(createMdxLoader(configLoader))(build);\n if (!disableMetaFile) toBun(createMetaLoader(configLoader))(build);\n },\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/bun/index.ts"],"sourcesContent":["import type { BunPlugin } from 'bun';\nimport { createMdxLoader } from '@/loaders/mdx';\nimport { buildConfig } from '@/config/build';\nimport { pathToFileURL } from 'node:url';\nimport { _Defaults, type CoreOptions, createCore } from '@/core';\nimport { createIntegratedConfigLoader } from '@/loaders/config';\nimport { createMetaLoader } from '@/loaders/meta';\nimport { toBun } from '@/loaders/adapter';\n\nexport interface MdxPluginOptions extends Partial<CoreOptions> {\n /**\n * Skip meta file transformation step\n */\n disableMetaFile?: boolean;\n}\n\nexport function createMdxPlugin(options: MdxPluginOptions = {}): BunPlugin {\n const {\n environment = 'bun',\n outDir = _Defaults.outDir,\n configPath = _Defaults.configPath,\n disableMetaFile = false,\n } = options;\n\n return {\n name: 'bun-plugin-fumadocs-mdx',\n async setup(build) {\n const importPath = pathToFileURL(configPath).href;\n const core = createCore({\n environment,\n outDir,\n configPath,\n });\n\n await core.init({\n config: buildConfig(await import(importPath)),\n });\n\n const configLoader = createIntegratedConfigLoader(core);\n toBun(createMdxLoader(configLoader))(build);\n if (!disableMetaFile) toBun(createMetaLoader(configLoader))(build);\n },\n };\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,gBAAgB,UAA4B,EAAE,EAAa;CACzE,MAAM,EACJ,cAAc,OACd,SAAS,UAAU,QACnB,aAAa,UAAU,YACvB,kBAAkB,UAChB;AAEJ,QAAO;EACL,MAAM;EACN,MAAM,MAAM,OAAO;GACjB,MAAM,aAAa,cAAc,WAAW,CAAC;GAC7C,MAAM,OAAO,WAAW;IACtB;IACA;IACA;IACD,CAAC;AAEF,SAAM,KAAK,KAAK,EACd,QAAQ,YAAY,MAAM,OAAO,YAAY,EAC9C,CAAC;GAEF,MAAM,eAAe,6BAA6B,KAAK;AACvD,SAAM,gBAAgB,aAAa,CAAC,CAAC,MAAM;AAC3C,OAAI,CAAC,gBAAiB,OAAM,iBAAiB,aAAa,CAAC,CAAC,MAAM;;EAErE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-Bd9bQlN7.js","names":[],"sources":["../src/utils/codegen.ts"],"sourcesContent":["import path from 'node:path';\nimport { glob } from 'tinyglobby';\n\nexport interface GlobImportOptions {\n base: string;\n query?: Record<string, string | undefined>;\n import?: string;\n eager?: boolean;\n}\n\nexport interface CodeGenOptions {\n target: 'default' | 'vite';\n outDir: string;\n /**\n * add .js
|
|
1
|
+
{"version":3,"file":"codegen-Bd9bQlN7.js","names":[],"sources":["../src/utils/codegen.ts"],"sourcesContent":["import path from 'node:path';\nimport { glob } from 'tinyglobby';\n\nexport interface GlobImportOptions {\n base: string;\n query?: Record<string, string | undefined>;\n import?: string;\n eager?: boolean;\n}\n\nexport interface CodeGenOptions {\n target: 'default' | 'vite';\n outDir: string;\n /**\n * add .js extension to imports\n */\n jsExtension: boolean;\n globCache: Map<string, Promise<string[]>>;\n}\n\nexport type CodeGen = ReturnType<typeof createCodegen>;\n\n/**\n * Code generator (one instance per file)\n */\nexport function createCodegen({\n target = 'default',\n outDir = '',\n jsExtension = false,\n globCache = new Map(),\n}: Partial<CodeGenOptions>) {\n let eagerImportId = 0;\n const banner: string[] = ['// @ts-nocheck'];\n\n if (target === 'vite') {\n banner.push('/// <reference types=\"vite/client\" />');\n }\n\n return {\n options: {\n target,\n outDir,\n } as CodeGenOptions,\n lines: [] as string[],\n addImport(statement: string) {\n this.lines.unshift(statement);\n },\n async pushAsync(insert: Promise<string | undefined>[]) {\n for (const line of await Promise.all(insert)) {\n if (line === undefined) continue;\n\n this.lines.push(line);\n }\n },\n\n async generateGlobImport(\n patterns: string | string[],\n options: GlobImportOptions,\n ): Promise<string> {\n if (target === 'vite') {\n return this.generateViteGlobImport(patterns, options);\n }\n\n return this.generateNodeGlobImport(patterns, options);\n },\n\n generateViteGlobImport(\n patterns: string | string[],\n { base, ...rest }: GlobImportOptions,\n ): string {\n patterns = (typeof patterns === 'string' ? [patterns] : patterns).map(normalizeViteGlobPath);\n\n return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(\n {\n base: normalizeViteGlobPath(path.relative(outDir, base)),\n ...rest,\n },\n null,\n 2,\n )})`;\n },\n async generateNodeGlobImport(\n patterns: string | string[],\n { base, eager = false, query = {}, import: importName }: GlobImportOptions,\n ): Promise<string> {\n const cacheKey = JSON.stringify({ patterns, base });\n let files = globCache.get(cacheKey);\n if (!files) {\n files = glob(patterns, {\n cwd: base,\n });\n globCache.set(cacheKey, files);\n }\n\n let code: string = '{';\n for (const item of await files) {\n const fullPath = path.join(base, item);\n const searchParams = new URLSearchParams();\n\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) searchParams.set(k, v);\n }\n\n const importPath = this.formatImportPath(fullPath) + '?' + searchParams.toString();\n if (eager) {\n const name = `__fd_glob_${eagerImportId++}`;\n this.lines.unshift(\n importName\n ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}`\n : `import * as ${name} from ${JSON.stringify(importPath)}`,\n );\n\n code += `${JSON.stringify(item)}: ${name}, `;\n } else {\n let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;\n if (importName) {\n line += `.then(mod => mod.${importName})`;\n }\n\n code += `${line}, `;\n }\n }\n\n code += '}';\n return code;\n },\n formatImportPath(file: string) {\n const ext = path.extname(file);\n let filename: string;\n\n if (ext === '.ts') {\n filename = file.substring(0, file.length - ext.length);\n if (jsExtension) filename += '.js';\n } else {\n filename = file;\n }\n\n const importPath = slash(path.relative(outDir, filename));\n return importPath.startsWith('.') ? importPath : `./${importPath}`;\n },\n toString() {\n return [...banner, ...this.lines].join('\\n');\n },\n };\n}\n\n/**\n * convert into POSIX & relative file paths, such that Vite can accept it.\n */\nfunction normalizeViteGlobPath(file: string) {\n file = slash(file);\n if (file.startsWith('./')) return file;\n if (file.startsWith('/')) return `.${file}`;\n\n return `./${file}`;\n}\n\nexport function slash(path: string): string {\n const isExtendedLengthPath = path.startsWith('\\\\\\\\?\\\\');\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll('\\\\', '/');\n}\n\nexport function ident(code: string, tab: number = 1) {\n return code\n .split('\\n')\n .map((v) => ' '.repeat(tab) + v)\n .join('\\n');\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,cAAc,EAC5B,SAAS,WACT,SAAS,IACT,cAAc,OACd,4BAAY,IAAI,KAAK,IACK;CAC1B,IAAI,gBAAgB;CACpB,MAAM,SAAmB,CAAC,iBAAiB;AAE3C,KAAI,WAAW,OACb,QAAO,KAAK,0CAAwC;AAGtD,QAAO;EACL,SAAS;GACP;GACA;GACD;EACD,OAAO,EAAE;EACT,UAAU,WAAmB;AAC3B,QAAK,MAAM,QAAQ,UAAU;;E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U,WAAW,KACtE,eAAe,KAAK,QAAQ,KAAK,UAAU,WAAW,GAC3D;AAED,aAAQ,GAAG,KAAK,UAAU,KAAK,CAAC,IAAI,KAAK;WACpC;KACL,IAAI,OAAO,GAAG,KAAK,UAAU,KAAK,CAAC,iBAAiB,KAAK,UAAU,WAAW,CAAC;AAC/E,SAAI,WACF,SAAQ,oBAAoB,WAAW;AAGzC,aAAQ,GAAG,KAAK;;;AAIpB,WAAQ;AACR,UAAO;;EAET,iBAAiB,MAAc;GAC7B,MAAM,MAAM,KAAK,QAAQ,KAAK;GAC9B,IAAI;AAEJ,OAAI,QAAQ,OAAO;AACjB,eAAW,KAAK,UAAU,GAAG,KAAK,SAAS,IAAI,OAAO;AACtD,QAAI,YAAa,aAAY;SAE7B,YAAW;GAGb,MAAM,aAAa,MAAM,KAAK,SAAS,QAAQ,SAAS,CAAC;AACzD,UAAO,WAAW,WAAW,IAAI,GAAG,aAAa,KAAK;;EAExD,WAAW;AACT,UAAO,CAAC,GAAG,QAAQ,GAAG,KAAK,MAAM,CAAC,KAAK,KAAK;;EAE/C;;;;;AAMH,SAAS,sBAAsB,MAAc;AAC3C,QAAO,MAAM,KAAK;AAClB,KAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAClC,KAAI,KAAK,WAAW,IAAI,CAAE,QAAO,IAAI;AAErC,QAAO,KAAK;;AAGd,SAAgB,MAAM,MAAsB;AAG1C,KAF6B,KAAK,WAAW,UAAU,CAGrD,QAAO;AAGT,QAAO,KAAK,WAAW,MAAM,IAAI;;AAGnC,SAAgB,MAAM,MAAc,MAAc,GAAG;AACnD,QAAO,KACJ,MAAM,KAAK,CACX,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG,EAAE,CAChC,KAAK,KAAK"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as GlobalConfig, B as MDXPresetOptions, D as CollectionSchema, E as BaseCollection, I as PostprocessOptions, L as metaSchema, M as defineCollections, N as defineConfig, O as DocCollection, P as defineDocs, R as pageSchema, T as AnyCollection, V as applyMdxPreset, j as MetaCollection, k as DocsCollection, w as remarkInclude, z as DefaultMDXOptions } from "../core-
|
|
1
|
+
import { A as GlobalConfig, B as MDXPresetOptions, D as CollectionSchema, E as BaseCollection, I as PostprocessOptions, L as metaSchema, M as defineCollections, N as defineConfig, O as DocCollection, P as defineDocs, R as pageSchema, T as AnyCollection, V as applyMdxPreset, j as MetaCollection, k as DocsCollection, w as remarkInclude, z as DefaultMDXOptions } from "../core-C9TGjTWd.js";
|
|
2
2
|
export { AnyCollection, BaseCollection, CollectionSchema, DefaultMDXOptions, DocCollection, DocsCollection, GlobalConfig, MDXPresetOptions, MetaCollection, PostprocessOptions, applyMdxPreset, defineCollections, defineConfig, defineDocs, pageSchema as frontmatterSchema, metaSchema, remarkInclude };
|
package/dist/config/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "../fuma-matter-Fge-qpw1.js";
|
|
2
1
|
import { t as applyMdxPreset } from "../preset-BjHACE1Z.js";
|
|
3
|
-
import { t as remarkInclude } from "../remark-include-
|
|
2
|
+
import { t as remarkInclude } from "../remark-include-CgjB4_2e.js";
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
//#region ../core/dist/source/schema.js
|
|
6
5
|
/**
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../core/dist/source/schema.js","../../src/config/define.ts"],"sourcesContent":["import { z } from \"zod\";\n//#region src/source/schema.ts\n/**\n* Zod 4 schema\n*/\nconst metaSchema = z.object({\n\ttitle: z.string().optional(),\n\tpages: z.array(z.string()).optional(),\n\tdescription: z.string().optional(),\n\troot: z.boolean().optional(),\n\tdefaultOpen: z.boolean().optional(),\n\tcollapsible: z.boolean().optional(),\n\ticon: z.string().optional()\n});\n/**\n* Zod 4 schema\n*/\nconst pageSchema = z.object({\n\ttitle: z.string(),\n\tdescription: z.string().optional(),\n\ticon: z.string().optional(),\n\tfull: z.boolean().optional(),\n\t_openapi: z.looseObject({}).optional()\n});\n//#endregion\nexport { metaSchema, pageSchema };\n","import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { MDXPresetOptions } from '@/config/preset';\nimport type { ProcessorOptions } from '@mdx-js/mdx';\nimport { metaSchema, pageSchema } from 'fumadocs-core/source/schema';\nimport type { PostprocessOptions } from '@/loaders/mdx/remark-postprocess';\nimport type { PluginOption } from '@/core';\nimport type { BuildEnvironment } from './build';\n\nexport type CollectionSchema<Schema extends StandardSchemaV1, Context> =\n | Schema\n | ((ctx: Context) => Schema);\n\nexport type AnyCollection = DocsCollection | DocCollection | MetaCollection;\n\nexport interface BaseCollection {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n}\n\nexport interface MetaCollection<\n Schema extends StandardSchemaV1 = StandardSchemaV1,\n> extends BaseCollection {\n type: 'meta';\n\n schema?: CollectionSchema<Schema, { path: string; source: string }>;\n}\n\nexport interface DocCollection<\n Schema extends StandardSchemaV1 = StandardSchemaV1,\n> extends BaseCollection {\n type: 'doc';\n\n postprocess?: Partial<PostprocessOptions>;\n mdxOptions?: ProcessorOptions | ((environment: BuildEnvironment) => Promise<ProcessorOptions>);\n\n /**\n * Load files with async\n */\n async?: boolean;\n\n /**\n * Compile files on-demand\n */\n dynamic?: boolean;\n\n schema?: CollectionSchema<Schema, { path: string; source: string }>;\n}\n\nexport interface DocsCollection<\n DocSchema extends StandardSchemaV1 = StandardSchemaV1,\n MetaSchema extends StandardSchemaV1 = StandardSchemaV1,\n> {\n type: 'docs';\n dir: string;\n\n docs: DocCollection<DocSchema>;\n meta: MetaCollection<MetaSchema>;\n}\n\nexport interface GlobalConfig {\n plugins?: PluginOption[];\n\n /**\n * Configure global MDX options\n */\n mdxOptions?: MDXPresetOptions | (() => Promise<MDXPresetOptions>);\n\n workspaces?: Record<\n string,\n {\n dir: string;\n config: Record<string, unknown>;\n }\n >;\n\n /**\n * specify a directory to access & store cache (disabled during development mode).\n *\n * The cache will never be updated, delete the cache folder to clean.\n */\n experimentalBuildCache?: string;\n}\n\nexport function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(\n options: DocCollection<Schema>,\n): DocCollection<Schema>;\nexport function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(\n options: MetaCollection<Schema>,\n): MetaCollection<Schema>;\n\nexport function defineCollections(\n options: DocCollection | MetaCollection,\n): DocCollection | MetaCollection {\n return options as any;\n}\n\nexport function defineDocs<\n DocSchema extends StandardSchemaV1 = typeof pageSchema,\n MetaSchema extends StandardSchemaV1 = typeof metaSchema,\n>(options: {\n /**\n * The content directory to scan files\n *\n * @defaultValue 'content/docs'\n */\n dir?: string;\n\n docs?: Omit<DocCollection<DocSchema>, 'dir' | 'type'>;\n meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;\n}): DocsCollection<DocSchema, MetaSchema> {\n const dir = options.dir ?? 'content/docs';\n\n return {\n type: 'docs',\n dir,\n docs: defineCollections({\n type: 'doc',\n dir,\n schema: pageSchema as any,\n ...options?.docs,\n }),\n meta: defineCollections({\n type: 'meta',\n dir,\n schema: metaSchema as any,\n ...options?.meta,\n }),\n };\n}\n\nexport function defineConfig(config: GlobalConfig = {}): GlobalConfig {\n return config;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../core/dist/source/schema.js","../../src/config/define.ts"],"sourcesContent":["import { z } from \"zod\";\n//#region src/source/schema.ts\n/**\n* Zod 4 schema\n*/\nconst metaSchema = z.object({\n\ttitle: z.string().optional(),\n\tpages: z.array(z.string()).optional(),\n\tdescription: z.string().optional(),\n\troot: z.boolean().optional(),\n\tdefaultOpen: z.boolean().optional(),\n\tcollapsible: z.boolean().optional(),\n\ticon: z.string().optional()\n});\n/**\n* Zod 4 schema\n*/\nconst pageSchema = z.object({\n\ttitle: z.string(),\n\tdescription: z.string().optional(),\n\ticon: z.string().optional(),\n\tfull: z.boolean().optional(),\n\t_openapi: z.looseObject({}).optional()\n});\n//#endregion\nexport { metaSchema, pageSchema };\n","import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { MDXPresetOptions } from '@/config/preset';\nimport type { ProcessorOptions } from '@mdx-js/mdx';\nimport { metaSchema, pageSchema } from 'fumadocs-core/source/schema';\nimport type { PostprocessOptions } from '@/loaders/mdx/remark-postprocess';\nimport type { PluginOption } from '@/core';\nimport type { BuildEnvironment } from './build';\n\nexport type CollectionSchema<Schema extends StandardSchemaV1, Context> =\n | Schema\n | ((ctx: Context) => Schema);\n\nexport type AnyCollection = DocsCollection | DocCollection | MetaCollection;\n\nexport interface BaseCollection {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n}\n\nexport interface MetaCollection<\n Schema extends StandardSchemaV1 = StandardSchemaV1,\n> extends BaseCollection {\n type: 'meta';\n\n schema?: CollectionSchema<Schema, { path: string; source: string }>;\n}\n\nexport interface DocCollection<\n Schema extends StandardSchemaV1 = StandardSchemaV1,\n> extends BaseCollection {\n type: 'doc';\n\n postprocess?: Partial<PostprocessOptions>;\n mdxOptions?: ProcessorOptions | ((environment: BuildEnvironment) => Promise<ProcessorOptions>);\n\n /**\n * Load files with async\n */\n async?: boolean;\n\n /**\n * Compile files on-demand\n */\n dynamic?: boolean;\n\n schema?: CollectionSchema<Schema, { path: string; source: string }>;\n}\n\nexport interface DocsCollection<\n DocSchema extends StandardSchemaV1 = StandardSchemaV1,\n MetaSchema extends StandardSchemaV1 = StandardSchemaV1,\n> {\n type: 'docs';\n dir: string;\n\n docs: DocCollection<DocSchema>;\n meta: MetaCollection<MetaSchema>;\n}\n\nexport interface GlobalConfig {\n plugins?: PluginOption[];\n\n /**\n * Configure global MDX options\n */\n mdxOptions?: MDXPresetOptions | (() => Promise<MDXPresetOptions>);\n\n workspaces?: Record<\n string,\n {\n dir: string;\n config: Record<string, unknown>;\n }\n >;\n\n /**\n * specify a directory to access & store cache (disabled during development mode).\n *\n * The cache will never be updated, delete the cache folder to clean.\n */\n experimentalBuildCache?: string;\n}\n\nexport function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(\n options: DocCollection<Schema>,\n): DocCollection<Schema>;\nexport function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(\n options: MetaCollection<Schema>,\n): MetaCollection<Schema>;\n\nexport function defineCollections(\n options: DocCollection | MetaCollection,\n): DocCollection | MetaCollection {\n return options as any;\n}\n\nexport function defineDocs<\n DocSchema extends StandardSchemaV1 = typeof pageSchema,\n MetaSchema extends StandardSchemaV1 = typeof metaSchema,\n>(options: {\n /**\n * The content directory to scan files\n *\n * @defaultValue 'content/docs'\n */\n dir?: string;\n\n docs?: Omit<DocCollection<DocSchema>, 'dir' | 'type'>;\n meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;\n}): DocsCollection<DocSchema, MetaSchema> {\n const dir = options.dir ?? 'content/docs';\n\n return {\n type: 'docs',\n dir,\n docs: defineCollections({\n type: 'doc',\n dir,\n schema: pageSchema as any,\n ...options?.docs,\n }),\n meta: defineCollections({\n type: 'meta',\n dir,\n schema: metaSchema as any,\n ...options?.meta,\n }),\n };\n}\n\nexport function defineConfig(config: GlobalConfig = {}): GlobalConfig {\n return config;\n}\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,EAAE,OAAO;CAC3B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CACrC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,MAAM,EAAE,SAAS,CAAC,UAAU;CAC5B,aAAa,EAAE,SAAS,CAAC,UAAU;CACnC,aAAa,EAAE,SAAS,CAAC,UAAU;CACnC,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,CAAC;;;;AAIF,MAAM,aAAa,EAAE,OAAO;CAC3B,OAAO,EAAE,QAAQ;CACjB,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,MAAM,EAAE,SAAS,CAAC,UAAU;CAC5B,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,UAAU;CACtC,CAAC;;;AC4EF,SAAgB,kBACd,SACgC;AAChC,QAAO;;AAGT,SAAgB,WAGd,SAUwC;CACxC,MAAM,MAAM,QAAQ,OAAO;AAE3B,QAAO;EACL,MAAM;EACN;EACA,MAAM,kBAAkB;GACtB,MAAM;GACN;GACA,QAAQ;GACR,GAAG,SAAS;GACb,CAAC;EACF,MAAM,kBAAkB;GACtB,MAAM;GACN;GACA,QAAQ;GACR,GAAG,SAAS;GACb,CAAC;EACH;;AAGH,SAAgB,aAAa,SAAuB,EAAE,EAAgB;AACpE,QAAO"}
|
|
@@ -2,11 +2,12 @@ import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, t as DocDat
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Pluggable, Processor, Transformer } from "unified";
|
|
4
4
|
import * as Plugins from "fumadocs-core/mdx-plugins";
|
|
5
|
+
import { LLMsOptions } from "fumadocs-core/mdx-plugins";
|
|
5
6
|
import { VFile } from "vfile";
|
|
6
7
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
7
|
-
import { FSWatcher } from "chokidar";
|
|
8
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
9
|
import { Root } from "mdast";
|
|
10
|
+
import { FSWatcher } from "chokidar";
|
|
10
11
|
import { MetaData, PageData, Source } from "fumadocs-core/source";
|
|
11
12
|
|
|
12
13
|
//#region src/config/preset.d.ts
|
|
@@ -381,4 +382,4 @@ declare function createCore(options: CoreOptions): {
|
|
|
381
382
|
type Core = ReturnType<typeof createCore>;
|
|
382
383
|
//#endregion
|
|
383
384
|
export { GlobalConfig as A, MDXPresetOptions as B, toFumadocsSource as C, CollectionSchema as D, BaseCollection as E, ExtractedReference as F, PostprocessOptions as I, metaSchema as L, defineCollections as M, defineConfig as N, DocCollection as O, defineDocs as P, pageSchema as R, server as S, AnyCollection as T, applyMdxPreset as V, DocCollectionEntry as _, EmitOptions as a, ServerCreate as b, PluginContext as c, TransformOptions as d, IndexFilePlugin as f, AsyncDocsCollectionEntry as g, AsyncDocCollectionEntry as h, EmitEntry as i, MetaCollection as j, DocsCollection as k, PluginOption as l, indexFile as m, Core as n, EmitOutput as o, IndexFilePluginOptions as p, CoreOptions as r, Plugin as s, CompilationContext as t, ServerContext as u, DocsCollectionEntry as v, remarkInclude as w, ServerOptions as x, MetaCollectionEntry as y, DefaultMDXOptions as z };
|
|
384
|
-
//# sourceMappingURL=core-
|
|
385
|
+
//# sourceMappingURL=core-C9TGjTWd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-C9TGjTWd.d.ts","names":[],"sources":["../src/config/preset.ts","../../core/dist/source/schema.js","../src/loaders/mdx/remark-postprocess.ts","../src/config/define.ts","../src/config/build.ts","../src/loaders/mdx/remark-include.ts","../src/runtime/server.ts","../src/plugins/index-file.ts","../src/core.ts"],"mappings":";;;;;;;;;;;;;KAKK,cAAA,GAAiB,SAAA,OAAgB,CAAA,EAAG,SAAA,OAAgB,SAAA;AAAA,KAE7C,iBAAA,GAAoB,IAAA,CAC9B,WAAA,CAAY,gBAAA;EAGZ,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,cAAA;;;;EAKhB,aAAA;EAEA,sBAAA,GAAyB,OAAA,CAAQ,gBAAA;EACjC,oBAAA,GAAuB,OAAA,CAAQ,oBAAA;EAC/B,kBAAA,GAAqB,OAAA,CAAQ,kBAAA;EAC7B,oBAAA,GAAuB,OAAA,CAAQ,oBAAA;EAC/B,gBAAA,GAAmB,OAAA,CAAQ,gBAAA;EAC3B,iBAAA,GAAoB,OAAA,CAAQ,iBAAA;AAAA;AAAA,KAgBlB,gBAAA;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;IACA,GAAA;EAAA;AAAA;AAAA,UAIa,WAAA;ERnEc;;;EQuE7B,YAAA,IAAgB,MAAA,EAAQ,MAAA;ERpEF;AAKxB;;EQoEE,eAAA,IAAmB,SAAA;ERnEV;;;EQwET,KAAA;AAAA;AAAA,UAGe,UAAA;EACf,OAAA,EAAS,SAAA;EACT,UAAA,EAAY,MAAA,SAAe,SAAA;AAAA;AAAA,iBAoBb,UAAA,CAAW,OAAA,EAAS,WAAA;;;;;;;;IA4BI,MAAA,EAAQ,SAAA,CAAU,YAAA;EAAA,IAAe,OAAA;;;eAoCxD,YAAA;;;;;;oBAYK,cAAA;+BAGW,cAAA;sBAGT,aAAA;qBAKK,aAAA,GAAgB,OAAA;qBASjB,WAAA,GAAmB,OAAA,CAAQ,UAAA;yBAiDxC,gBAAA,CAAiB,kBAAA,GAAmB,IAAA,YAE5C,OAAA;gCAcQ,gBAAA,CAAiB,iBAAA,GAAkB,IAAA,EACtC,MAAA,oBACL,OAAA,CAAQ,MAAA;0BAcA,gBAAA,CAAiB,iBAAA,GAAkB,IAAA,EACtC,KAAA,GACL,OAAA,CAAQ,KAAA;AAAA;AAAA,KAyDH,IAAA,GAAO,UAAA,QAAkB,UAAA"}
|
|
@@ -13,7 +13,7 @@ function createFSCache() {
|
|
|
13
13
|
const fullPath = toFullPath(file);
|
|
14
14
|
const cached = map.get(fullPath);
|
|
15
15
|
if (cached) return cached;
|
|
16
|
-
const read = fs.readFile(fullPath
|
|
16
|
+
const read = fs.readFile(fullPath, "utf-8");
|
|
17
17
|
map.set(fullPath, read);
|
|
18
18
|
return read;
|
|
19
19
|
},
|
|
@@ -153,7 +153,6 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
153
153
|
environment,
|
|
154
154
|
outDir
|
|
155
155
|
};
|
|
156
|
-
codegen.lines.push(`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`, `import * as Config from '${codegen.formatImportPath(configPath)}';`, "", `const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(partialOptions)}, ${JSON.stringify(serverOptions)});`);
|
|
157
156
|
async function generateCollectionObjectEntry(collection, absolutePath) {
|
|
158
157
|
const fullPath = path$1.relative(process.cwd(), absolutePath);
|
|
159
158
|
const content = await indexFileCache.read(fullPath).catch(() => "");
|
|
@@ -188,16 +187,19 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
188
187
|
switch (parent.type) {
|
|
189
188
|
case "docs": {
|
|
190
189
|
const metaGlob = await generateMetaCollectionGlob(ctx, parent.meta, true);
|
|
191
|
-
return `await create.docs("${parent.name}", "${getBase(parent)}", ${metaGlob}, ${entries.join(", ")})`;
|
|
190
|
+
return `await create.docs("${parent.name}", "${getBase(parent)}", ${metaGlob}, [${entries.join(", ")}])`;
|
|
192
191
|
}
|
|
193
|
-
case "doc": return `await create.doc("${collection.name}", "${getBase(collection)}", ${entries.join(", ")})`;
|
|
192
|
+
case "doc": return `await create.doc("${collection.name}", "${getBase(collection)}", [${entries.join(", ")}])`;
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
await
|
|
195
|
+
const objects = await Promise.all(core.getCollections().map(async (collection) => {
|
|
197
196
|
const obj = await generateCollectionObject(collection);
|
|
198
197
|
if (!obj) return;
|
|
199
198
|
return `\nexport const ${collection.name} = ${obj};`;
|
|
200
199
|
}));
|
|
200
|
+
const hasDynamicCollection = objects.some(Boolean);
|
|
201
|
+
codegen.lines.push(`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`, ...hasDynamicCollection ? [`import path from 'node:path';`] : [], `import * as Config from '${codegen.formatImportPath(configPath)}';`, "", `const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(partialOptions)}, ${JSON.stringify(serverOptions)});`);
|
|
202
|
+
codegen.lines.push(...objects.filter((obj) => obj !== void 0));
|
|
201
203
|
}
|
|
202
204
|
async function generateBrowserIndexFile(ctx) {
|
|
203
205
|
const { core, codegen, tc } = ctx;
|
|
@@ -259,4 +261,4 @@ function generateMetaCollectionGlob({ codegen, workspace }, collection, eager =
|
|
|
259
261
|
//#endregion
|
|
260
262
|
export { indexFile as t };
|
|
261
263
|
|
|
262
|
-
//# sourceMappingURL=index-file-
|
|
264
|
+
//# sourceMappingURL=index-file-4qOxhCQn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-file-4qOxhCQn.js","names":["path"],"sources":["../src/utils/fs-cache.ts","../src/plugins/index-file.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nconst map = new Map<string, Promise<string>>();\n\nexport function createFSCache() {\n return {\n read(file: string): Promise<string> {\n const fullPath = toFullPath(file);\n const cached = map.get(fullPath);\n if (cached) return cached;\n\n const read = fs.readFile(fullPath, 'utf-8');\n map.set(fullPath, read);\n return read;\n },\n\n delete(file: string) {\n map.delete(toFullPath(file));\n },\n };\n}\n\n/**\n * make file paths relative to cwd\n */\nfunction toFullPath(file: string) {\n if (path.isAbsolute(file)) {\n return path.relative(process.cwd(), file);\n }\n\n return file;\n}\n","import type { Core, CoreOptions, Plugin, PluginContext } from '@/core';\nimport type { CollectionItem, DocCollectionItem, MetaCollectionItem } from '@/config/build';\nimport path from 'path';\nimport { type CodeGen, createCodegen, ident, slash } from '@/utils/codegen';\nimport { glob } from 'tinyglobby';\nimport { createFSCache } from '@/utils/fs-cache';\nimport { createHash } from 'crypto';\nimport type { LazyEntry } from '@/runtime/dynamic';\nimport type { EmitEntry } from '@/core';\nimport { fumaMatter } from '@/utils/fuma-matter';\nimport type { ServerOptions } from '@/runtime/server';\n\nexport interface IndexFilePluginOptions {\n target?: 'default' | 'vite';\n\n /**\n * add `.js` extensions to imports, needed for ESM without bundler resolution\n */\n addJsExtension?: boolean;\n\n /**\n * Generate entry point for browser\n * @defaultValue true\n */\n browser?: boolean;\n\n /**\n * Generate entry point for dynamic compilation\n * @defaultValue true\n */\n dynamic?: boolean;\n}\n\nexport interface IndexFilePlugin {\n ['index-file']?: {\n generateTypeConfig?: (this: PluginContext) => string | void;\n serverOptions?: (this: PluginContext, options: ServerOptions) => void;\n };\n}\n\ninterface FileGenContext {\n core: Core;\n workspace?: string;\n codegen: CodeGen;\n serverOptions: ServerOptions;\n tc: string;\n}\n\nconst indexFileCache = createFSCache();\n\nexport default function indexFile(options: IndexFilePluginOptions = {}): Plugin {\n const { target = 'default', addJsExtension, browser = true, dynamic = true } = options;\n let dynamicCollections: CollectionItem[];\n\n function isDynamic(collection: CollectionItem) {\n return (\n (collection.type === 'docs' && collection.docs.dynamic) ||\n (collection.type === 'doc' && collection.dynamic)\n );\n }\n\n function generateConfigs(core: Core): {\n serverOptions: ServerOptions;\n tc: string;\n } {\n const serverOptions: ServerOptions = {};\n const typeConfigs: string[] = ['import(\"fumadocs-mdx/runtime/types\").InternalTypeConfig'];\n const ctx = core.getPluginContext();\n\n for (const plugin of core.getPlugins()) {\n const indexFilePlugin = plugin['index-file'];\n if (!indexFilePlugin) continue;\n\n indexFilePlugin.serverOptions?.call(ctx, serverOptions);\n const config = indexFilePlugin.generateTypeConfig?.call(ctx);\n if (config) typeConfigs.push(config);\n }\n\n return {\n serverOptions,\n tc: typeConfigs.join(' & '),\n };\n }\n\n return {\n name: 'index-file',\n config() {\n dynamicCollections = this.core.getCollections().filter(isDynamic);\n },\n configureServer(server) {\n if (!server.watcher) return;\n\n server.watcher.on('all', async (event, file) => {\n indexFileCache.delete(file);\n\n // dynamic collections always require re-generation on change\n if (dynamicCollections.length === 0) {\n // vite uses `import.meta.glob`, no need to re-generate\n if (target === 'vite') return;\n // only re-generate when adding/deleting entries\n if (target === 'default' && event === 'change') return;\n }\n\n const updatedCollection = this.core\n .getCollections()\n .find((collection) => collection.hasFile(file));\n\n if (!updatedCollection) return;\n if (!isDynamic(updatedCollection)) {\n if (target === 'vite') return;\n if (target === 'default' && event === 'change') return;\n }\n\n await this.core.emit({\n filterPlugin: (plugin) => plugin.name === 'index-file',\n filterWorkspace: () => false,\n write: true,\n });\n });\n },\n async emit() {\n const globCache = new Map<string, Promise<string[]>>();\n const { workspace, outDir } = this.core.getOptions();\n const { serverOptions, tc } = generateConfigs(this.core);\n const toEmitEntry = async (\n path: string,\n content: (ctx: FileGenContext) => Promise<void>,\n ): Promise<EmitEntry> => {\n const codegen = createCodegen({\n target,\n outDir: outDir,\n jsExtension: addJsExtension,\n globCache,\n });\n await content({\n core: this.core,\n codegen,\n serverOptions,\n tc,\n workspace: workspace?.name,\n });\n return {\n path,\n content: codegen.toString(),\n };\n };\n\n const out: Promise<EmitEntry>[] = [toEmitEntry('server.ts', generateServerIndexFile)];\n\n if (dynamic) out.push(toEmitEntry('dynamic.ts', generateDynamicIndexFile));\n\n if (browser) out.push(toEmitEntry('browser.ts', generateBrowserIndexFile));\n\n return await Promise.all(out);\n },\n };\n}\n\nasync function generateServerIndexFile(ctx: FileGenContext) {\n const { core, codegen, serverOptions, tc } = ctx;\n codegen.lines.push(\n `import { server } from 'fumadocs-mdx/runtime/server';`,\n `import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,\n '',\n `const create = server<typeof Config, ${tc}>(${JSON.stringify(serverOptions)});`,\n );\n\n async function generateCollectionObject(collection: CollectionItem): Promise<string | undefined> {\n const base = getBase(collection);\n\n switch (collection.type) {\n case 'docs': {\n if (collection.docs.dynamic) return;\n\n if (collection.docs.async) {\n const [metaGlob, headGlob, bodyGlob] = await Promise.all([\n generateMetaCollectionGlob(ctx, collection.meta, true),\n generateDocCollectionFrontmatterGlob(ctx, collection.docs, true),\n generateDocCollectionGlob(ctx, collection.docs),\n ]);\n\n return `await create.docsLazy(\"${collection.name}\", \"${base}\", ${metaGlob}, ${headGlob}, ${bodyGlob})`;\n }\n\n const [metaGlob, docGlob] = await Promise.all([\n generateMetaCollectionGlob(ctx, collection.meta, true),\n generateDocCollectionGlob(ctx, collection.docs, true),\n ]);\n\n return `await create.docs(\"${collection.name}\", \"${base}\", ${metaGlob}, ${docGlob})`;\n }\n case 'doc':\n if (collection.dynamic) return;\n\n if (collection.async) {\n const [headGlob, bodyGlob] = await Promise.all([\n generateDocCollectionFrontmatterGlob(ctx, collection, true),\n generateDocCollectionGlob(ctx, collection),\n ]);\n\n return `await create.docLazy(\"${collection.name}\", \"${base}\", ${headGlob}, ${bodyGlob})`;\n }\n\n return `await create.doc(\"${collection.name}\", \"${base}\", ${await generateDocCollectionGlob(\n ctx,\n collection,\n true,\n )})`;\n case 'meta':\n return `await create.meta(\"${collection.name}\", \"${base}\", ${await generateMetaCollectionGlob(\n ctx,\n collection,\n true,\n )})`;\n }\n }\n\n await codegen.pushAsync(\n core.getCollections().map(async (collection) => {\n const obj = await generateCollectionObject(collection);\n if (!obj) return;\n\n return `\\nexport const ${collection.name} = ${obj};`;\n }),\n );\n}\n\nasync function generateDynamicIndexFile(ctx: FileGenContext) {\n const { core, codegen, serverOptions, tc } = ctx;\n const { configPath, environment, outDir } = core.getOptions();\n // serializable config options\n const partialOptions: CoreOptions = {\n configPath,\n environment,\n outDir,\n };\n async function generateCollectionObjectEntry(\n collection: DocCollectionItem,\n absolutePath: string,\n ) {\n const fullPath = path.relative(process.cwd(), absolutePath);\n const content = await indexFileCache.read(fullPath).catch(() => '');\n const parsed = fumaMatter(content);\n const data = await core.transformFrontmatter(\n {\n collection,\n filePath: fullPath,\n source: content,\n },\n parsed.data as Record<string, unknown>,\n );\n\n const hash = createHash('md5').update(content).digest('hex');\n const infoStr: string[] = [\n // make sure it's included in vercel/nft\n `absolutePath: path.resolve(${JSON.stringify(fullPath)})`,\n ];\n for (const [k, v] of Object.entries({\n info: {\n fullPath,\n path: path.relative(collection.dir, absolutePath),\n },\n data,\n hash,\n } satisfies LazyEntry)) {\n infoStr.push(`${k}: ${JSON.stringify(v)}`);\n }\n\n return `{ ${infoStr.join(', ')} }`;\n }\n\n async function generateCollectionObject(parent: CollectionItem): Promise<string | undefined> {\n let collection: DocCollectionItem | undefined;\n if (parent.type === 'doc') collection = parent;\n else if (parent.type === 'docs') collection = parent.docs;\n\n if (!collection || !collection.dynamic) return;\n\n const files = await glob(collection.patterns, {\n cwd: collection.dir,\n absolute: true,\n });\n const entries = await Promise.all(\n files.map((file) => generateCollectionObjectEntry(collection, file)),\n );\n\n switch (parent.type) {\n case 'docs': {\n const metaGlob = await generateMetaCollectionGlob(ctx, parent.meta, true);\n\n return `await create.docs(\"${parent.name}\", \"${getBase(parent)}\", ${metaGlob}, [${entries.join(', ')}])`;\n }\n case 'doc':\n return `await create.doc(\"${collection.name}\", \"${getBase(collection)}\", [${entries.join(', ')}])`;\n }\n }\n\n const objects = await Promise.all(\n core.getCollections().map(async (collection) => {\n const obj = await generateCollectionObject(collection);\n if (!obj) return;\n\n return `\\nexport const ${collection.name} = ${obj};`;\n }),\n );\n const hasDynamicCollection = objects.some(Boolean);\n\n codegen.lines.push(\n `import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`,\n ...(hasDynamicCollection ? [`import path from 'node:path';`] : []),\n `import * as Config from '${codegen.formatImportPath(configPath)}';`,\n '',\n `const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(partialOptions)}, ${JSON.stringify(serverOptions)});`,\n );\n\n codegen.lines.push(...objects.filter((obj): obj is string => obj !== undefined));\n}\n\nasync function generateBrowserIndexFile(ctx: FileGenContext) {\n const { core, codegen, tc } = ctx;\n codegen.lines.push(\n `import { browser } from 'fumadocs-mdx/runtime/browser';`,\n `import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,\n '',\n `const create = browser<typeof Config, ${tc}>();`,\n );\n\n async function generateCollectionObject(collection: CollectionItem): Promise<string | undefined> {\n switch (collection.type) {\n case 'docs': {\n if (collection.docs.dynamic) return;\n\n return generateCollectionObject(collection.docs);\n }\n case 'doc':\n if (collection.dynamic) return;\n\n return `create.doc(\"${collection.name}\", ${await generateDocCollectionGlob(ctx, collection)})`;\n }\n }\n\n codegen.lines.push('const browserCollections = {');\n\n await codegen.pushAsync(\n core.getCollections().map(async (collection) => {\n const obj = await generateCollectionObject(collection);\n if (!obj) return;\n\n return ident(`${collection.name}: ${obj},`);\n }),\n );\n\n codegen.lines.push('};', 'export default browserCollections;');\n}\n\nfunction getBase(collection: CollectionItem) {\n return slash(path.relative(process.cwd(), collection.dir));\n}\n\nfunction generateDocCollectionFrontmatterGlob(\n { codegen, workspace }: FileGenContext,\n collection: DocCollectionItem,\n eager = false,\n) {\n return codegen.generateGlobImport(collection.patterns, {\n query: {\n collection: collection.name,\n only: 'frontmatter',\n workspace,\n },\n import: 'frontmatter',\n base: collection.dir,\n eager,\n });\n}\n\nfunction generateDocCollectionGlob(\n { codegen, workspace }: FileGenContext,\n collection: DocCollectionItem,\n eager = false,\n) {\n return codegen.generateGlobImport(collection.patterns, {\n query: {\n collection: collection.name,\n workspace,\n },\n base: collection.dir,\n eager,\n });\n}\n\nfunction generateMetaCollectionGlob(\n { codegen, workspace }: FileGenContext,\n collection: MetaCollectionItem,\n eager = false,\n) {\n return codegen.generateGlobImport(collection.patterns, {\n query: {\n collection: collection.name,\n workspace,\n },\n import: 'default',\n base: collection.dir,\n eager,\n });\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,sBAAM,IAAI,KAA8B;AAE9C,SAAgB,gBAAgB;AAC9B,QAAO;EACL,KAAK,MAA+B;GAClC,MAAM,WAAW,WAAW,KAAK;GACjC,MAAM,SAAS,IAAI,IAAI,SAAS;AAChC,OAAI,OAAQ,QAAO;GAEnB,MAAM,OAAO,GAAG,SAAS,UAAU,QAAQ;AAC3C,OAAI,IAAI,UAAU,KAAK;AACvB,UAAO;;EAGT,OAAO,MAAc;AACnB,OAAI,OAAO,WAAW,KAAK,CAAC;;EAE/B;;;;;AAMH,SAAS,WAAW,MAAc;AAChC,KAAI,KAAK,WAAW,KAAK,CACvB,QAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,KAAK;AAG3C,QAAO;;;;ACiBT,MAAM,iBAAiB,eAAe;AAEtC,SAAwB,UAAU,UAAkC,EAAE,EAAU;CAC9E,MAAM,EAAE,SAAS,WAAW,gBAAgB,UAAU,MAAM,UAA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AAS,0BACP,EAAE,SAAS,aACX,YACA,QAAQ,OACR;AACA,QAAO,QAAQ,mBAAmB,WAAW,UAAU;EACrD,OAAO;GACL,YAAY,WAAW;GACvB;GACD;EACD,MAAM,WAAW;EACjB;EACD,CAAC;;AAGJ,SAAS,2BACP,EAAE,SAAS,aACX,YACA,QAAQ,OACR;AACA,QAAO,QAAQ,mBAAmB,WAAW,UAAU;EACrD,OAAO;GACL,YAAY,WAAW;GACvB;GACD;EACD,QAAQ;EACR,MAAM,WAAW;EACjB;EACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { F as ExtractedReference, a as EmitOptions, c as PluginContext, d as TransformOptions, i as EmitEntry, l as PluginOption, n as Core, o as EmitOutput, r as CoreOptions, s as Plugin, t as CompilationContext, u as ServerContext } from "./core-
|
|
1
|
+
import { F as ExtractedReference, a as EmitOptions, c as PluginContext, d as TransformOptions, i as EmitEntry, l as PluginOption, n as Core, o as EmitOutput, r as CoreOptions, s as Plugin, t as CompilationContext, u as ServerContext } from "./core-C9TGjTWd.js";
|
|
2
2
|
import { t as CompiledMDXProperties } from "./build-mdx-CAXqH1_C.js";
|
|
3
3
|
export { type CompilationContext, type CompiledMDXProperties, type Core, type CoreOptions, type EmitEntry, type EmitOptions, type EmitOutput, type ExtractedReference, type Plugin, type PluginContext, type PluginOption, type ServerContext, type TransformOptions };
|
|
@@ -58,7 +58,7 @@ function createMdxLoader({ getCore }) {
|
|
|
58
58
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
59
59
|
map: null
|
|
60
60
|
};
|
|
61
|
-
const { buildMDX } = await import("./build-mdx-
|
|
61
|
+
const { buildMDX } = await import("./build-mdx-LmiB2qsc.js").then((n) => n.n);
|
|
62
62
|
const compiled = await buildMDX(core, docCollection, {
|
|
63
63
|
isDevelopment,
|
|
64
64
|
source: "\n".repeat(countLines(matter.matter)) + matter.content,
|
|
@@ -87,4 +87,4 @@ function countLines(s) {
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { createMdxLoader as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=mdx-
|
|
90
|
+
//# sourceMappingURL=mdx-D95UF4l1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx-
|
|
1
|
+
{"version":3,"file":"mdx-D95UF4l1.js","names":[],"sources":["../src/loaders/mdx/index.ts"],"sourcesContent":["import { fumaMatter } from '@/utils/fuma-matter';\nimport type { Loader } from '@/loaders/adapter';\nimport { z } from 'zod';\nimport type { DocCollectionItem } from '@/config/build';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { createHash } from 'node:crypto';\nimport type { ConfigLoader } from '@/loaders/config';\nimport { mdxLoaderGlob } from '..';\n\nconst querySchema = z.looseObject({\n only: z.literal(['frontmatter', 'all']).default('all'),\n collection: z.string().optional(),\n workspace: z.string().optional(),\n});\n\nconst cacheEntry = z.object({\n code: z.string(),\n map: z.any().optional(),\n hash: z.string().optional(),\n});\n\ntype CacheEntry = z.infer<typeof cacheEntry>;\n\nexport function createMdxLoader({ getCore }: ConfigLoader): Loader {\n return {\n test: mdxLoaderGlob,\n async load({ getSource, development: isDevelopment, query, compiler, filePath }) {\n let core = await getCore();\n const value = await getSource();\n const matter = fumaMatter(value);\n const { collection: collectionName, workspace, only } = querySchema.parse(query);\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let after: (() => Promise<void>) | undefined;\n\n const { experimentalBuildCache = false } = core.getConfig().global;\n if (!isDevelopment && experimentalBuildCache) {\n const cacheDir = experimentalBuildCache;\n const cacheKey = `${collectionName ?? 'global'}_${generateCacheHash(filePath)}`;\n\n const cached = await fs\n .readFile(path.join(cacheDir, cacheKey))\n .then((content) => cacheEntry.parse(JSON.parse(content.toString())))\n .catch(() => null);\n\n if (cached && cached.hash === generateCacheHash(value)) return cached;\n after = async () => {\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(\n path.join(cacheDir, cacheKey),\n JSON.stringify({\n ...out,\n hash: generateCacheHash(value),\n } satisfies CacheEntry),\n );\n };\n }\n\n const collection = collectionName ? core.getCollection(collectionName) : undefined;\n\n let docCollection: DocCollectionItem | undefined;\n switch (collection?.type) {\n case 'doc':\n docCollection = collection;\n break;\n case 'docs':\n docCollection = collection.docs;\n break;\n }\n\n if (docCollection) {\n matter.data = await core.transformFrontmatter(\n { collection: docCollection, filePath, source: value },\n matter.data as Record<string, unknown>,\n );\n }\n\n if (only === 'frontmatter') {\n return {\n code: `export const frontmatter = ${JSON.stringify(matter.data)}`,\n map: null,\n };\n }\n\n const { buildMDX } = await import('@/loaders/mdx/build-mdx');\n const compiled = await buildMDX(core, docCollection, {\n isDevelopment,\n // ensure the line number is correct in errors\n source: '\\n'.repeat(countLines(matter.matter)) + matter.content,\n filePath,\n frontmatter: matter.data as Record<string, unknown>,\n _compiler: compiler,\n environment: 'bundler',\n });\n\n const out = {\n code: String(compiled.value),\n map: compiled.map,\n };\n\n await after?.();\n return out;\n },\n };\n}\n\nfunction generateCacheHash(input: string): string {\n return createHash('md5').update(input).digest('hex');\n}\n\nfunction countLines(s: string) {\n let num = 0;\n\n for (const c of s) {\n if (c === '\\n') num++;\n }\n\n return num;\n}\n"],"mappings":";;;;;;;AAUA,MAAM,cAAc,EAAE,YAAY;CAChC,MAAM,EAAE,QAAQ,CAAC,eAAe,MAAM,CAAC,CAAC,QAAQ,MAAM;CACtD,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC;AAEF,MAAM,aAAa,EAAE,OAAO;CAC1B,MAAM,EAAE,QAAQ;CAChB,KAAK,EAAE,KAAK,CAAC,UAAU;CACvB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC5B,CAAC;AAIF,SAAgB,gBAAgB,EAAE,WAAiC;AACjE,QAAO;EACL,MAAM;EACN,MAAM,KAAK,EAAE,WAAW,aAAa,eAAe,OAAO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,MAAA,EAAA,EAAA;GAClC,MAAM,WAAW,MAAM,SAAS,MAAM,eAAe;IACnD;IAEA,QAAQ,KAAK,OAAO,WAAW,OAAO,OAAO,CAAC,GAAG,OAAO;IACxD;IACA,aAAa,OAAO;IACpB,WAAW;IACX,aAAa;IACd,CAAC;GAEF,MAAM,MAAM;IACV,MAAM,OAAO,SAAS,MAAM;IAC5B,KAAK,SAAS;IACf;AAED,SAAM,SAAS;AACf,UAAO;;EAEV;;AAGH,SAAS,kBAAkB,OAAuB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGtD,SAAS,WAAW,GAAW;CAC7B,IAAI,MAAM;AAEV,MAAK,MAAM,KAAK,EACd,KAAI,MAAM,KAAM;AAGlB,QAAO"}
|
package/dist/next/index.cjs
CHANGED
|
@@ -527,7 +527,7 @@ function createFSCache() {
|
|
|
527
527
|
const fullPath = toFullPath(file);
|
|
528
528
|
const cached = map.get(fullPath);
|
|
529
529
|
if (cached) return cached;
|
|
530
|
-
const read = node_fs_promises.default.readFile(fullPath
|
|
530
|
+
const read = node_fs_promises.default.readFile(fullPath, "utf-8");
|
|
531
531
|
map.set(fullPath, read);
|
|
532
532
|
return read;
|
|
533
533
|
},
|
|
@@ -689,7 +689,6 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
689
689
|
environment,
|
|
690
690
|
outDir
|
|
691
691
|
};
|
|
692
|
-
codegen.lines.push(`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`, `import * as Config from '${codegen.formatImportPath(configPath)}';`, "", `const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(partialOptions)}, ${JSON.stringify(serverOptions)});`);
|
|
693
692
|
async function generateCollectionObjectEntry(collection, absolutePath) {
|
|
694
693
|
const fullPath = path.default.relative(process.cwd(), absolutePath);
|
|
695
694
|
const content = await indexFileCache.read(fullPath).catch(() => "");
|
|
@@ -724,16 +723,19 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
724
723
|
switch (parent.type) {
|
|
725
724
|
case "docs": {
|
|
726
725
|
const metaGlob = await generateMetaCollectionGlob(ctx, parent.meta, true);
|
|
727
|
-
return `await create.docs("${parent.name}", "${getBase(parent)}", ${metaGlob}, ${entries.join(", ")})`;
|
|
726
|
+
return `await create.docs("${parent.name}", "${getBase(parent)}", ${metaGlob}, [${entries.join(", ")}])`;
|
|
728
727
|
}
|
|
729
|
-
case "doc": return `await create.doc("${collection.name}", "${getBase(collection)}", ${entries.join(", ")})`;
|
|
728
|
+
case "doc": return `await create.doc("${collection.name}", "${getBase(collection)}", [${entries.join(", ")}])`;
|
|
730
729
|
}
|
|
731
730
|
}
|
|
732
|
-
await
|
|
731
|
+
const objects = await Promise.all(core.getCollections().map(async (collection) => {
|
|
733
732
|
const obj = await generateCollectionObject(collection);
|
|
734
733
|
if (!obj) return;
|
|
735
734
|
return `\nexport const ${collection.name} = ${obj};`;
|
|
736
735
|
}));
|
|
736
|
+
const hasDynamicCollection = objects.some(Boolean);
|
|
737
|
+
codegen.lines.push(`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`, ...hasDynamicCollection ? [`import path from 'node:path';`] : [], `import * as Config from '${codegen.formatImportPath(configPath)}';`, "", `const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(partialOptions)}, ${JSON.stringify(serverOptions)});`);
|
|
738
|
+
codegen.lines.push(...objects.filter((obj) => obj !== void 0));
|
|
737
739
|
}
|
|
738
740
|
async function generateBrowserIndexFile(ctx) {
|
|
739
741
|
const { core, codegen, tc } = ctx;
|
package/dist/next/index.d.ts
CHANGED
package/dist/next/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/next/index.ts"],"mappings":";;;;UAWiB,gBAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/next/index.ts"],"mappings":";;;;UAWiB,gBAAA;;AAAjB;;EAIE,UAAA;EAS8B;;;;;EAF9B,MAAA;EAEA,KAAA,GAAQ,sBAAA;AAAA;AAAA,iBAKM,SAAA,CAAU,aAAA,GAAe,gBAAA,IAU/B,UAAA,GAAY,UAAA,KAAkB,UAAA;AAAA,iBAgJlB,WAAA,CAAY,OAAA,EAAS,gBAAA,GAAgB,OAAA"}
|
package/dist/next/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import "../fuma-matter-Fge-qpw1.js";
|
|
2
1
|
import { n as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-BauN_my2.js";
|
|
3
|
-
import "../preset-BjHACE1Z.js";
|
|
4
|
-
import "../build-DxkMdv29.js";
|
|
5
2
|
import { n as createCore, t as _Defaults } from "../core-BluWnx7f.js";
|
|
6
|
-
import "../codegen-Bd9bQlN7.js";
|
|
7
3
|
import { t as loadConfig } from "../load-from-file-vlVZ_DdD.js";
|
|
8
|
-
import { t as indexFile } from "../index-file-
|
|
4
|
+
import { t as indexFile } from "../index-file-4qOxhCQn.js";
|
|
9
5
|
import * as path$1 from "node:path";
|
|
10
6
|
//#region src/next/index.ts
|
|
11
7
|
const defaultPageExtensions = [
|