fumadocs-mdx 14.2.8 → 14.2.10
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-XhFMy0vk.js → adapter-nuKMfIZz.js} +4 -6
- package/dist/adapter-nuKMfIZz.js.map +1 -0
- package/dist/bin.js +2 -3
- package/dist/bin.js.map +1 -1
- package/dist/{build-DXR8OpUp.js → build-DxkMdv29.js} +3 -4
- package/dist/{build-DXR8OpUp.js.map → build-DxkMdv29.js.map} +1 -1
- package/dist/build-mdx-C5FB6EIF.js +281 -0
- package/dist/build-mdx-C5FB6EIF.js.map +1 -0
- package/dist/{build-mdx-Cncu8QVO.d.ts → build-mdx-CAXqH1_C.d.ts} +1 -1
- package/dist/{build-mdx-Cncu8QVO.d.ts.map → build-mdx-CAXqH1_C.d.ts.map} +1 -1
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +9 -10
- package/dist/bun/index.js.map +1 -1
- package/dist/{codegen-DGkWwXbR.js → codegen-Bd9bQlN7.js} +2 -3
- package/dist/{codegen-DGkWwXbR.js.map → codegen-Bd9bQlN7.js.map} +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -6
- package/dist/config/index.js.map +1 -1
- package/dist/{core-CES68-08.d.ts → core-BF3YhvIc.d.ts} +72 -13
- package/dist/core-BF3YhvIc.d.ts.map +1 -0
- package/dist/{core-n8SqpyK5.js → core-BluWnx7f.js} +4 -6
- package/dist/{core-n8SqpyK5.js.map → core-BluWnx7f.js.map} +1 -1
- package/dist/{fuma-matter-BS5tWpr0.js → fuma-matter-Fge-qpw1.js} +2 -3
- package/dist/{fuma-matter-BS5tWpr0.js.map → fuma-matter-Fge-qpw1.js.map} +1 -1
- package/dist/{index-Jp-qanl0.d.ts → index-Cfo6kcGs.d.ts} +1 -3
- package/dist/index-Cfo6kcGs.d.ts.map +1 -0
- package/dist/index-file-B04Qazjk.js +262 -0
- package/dist/index-file-B04Qazjk.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{load-from-file-BNrV8Hf3.js → load-from-file-vlVZ_DdD.js} +4 -5
- package/dist/{load-from-file-BNrV8Hf3.js.map → load-from-file-vlVZ_DdD.js.map} +1 -1
- package/dist/{loaders-BPTAgJxN.js → loaders-BauN_my2.js} +2 -2
- package/dist/{loaders-BPTAgJxN.js.map → loaders-BauN_my2.js.map} +1 -1
- package/dist/{mdx-CdVuvckc.js → mdx-OAccQ48U.js} +6 -7
- package/dist/{mdx-CdVuvckc.js.map → mdx-OAccQ48U.js.map} +1 -1
- package/dist/{meta-VLRGCslG.js → meta-Di0sMUh5.js} +4 -5
- package/dist/{meta-VLRGCslG.js.map → meta-Di0sMUh5.js.map} +1 -1
- package/dist/next/index.cjs +8 -25
- package/dist/next/index.d.ts +1 -2
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +9 -10
- package/dist/next/index.js.map +1 -1
- package/dist/node/loader.js +7 -8
- package/dist/node/loader.js.map +1 -1
- package/dist/plugins/index-file.d.ts +2 -31
- package/dist/plugins/index-file.js +3 -236
- package/dist/plugins/json-schema.d.ts +1 -2
- package/dist/plugins/json-schema.d.ts.map +1 -1
- package/dist/plugins/json-schema.js +2 -3
- package/dist/plugins/json-schema.js.map +1 -1
- package/dist/plugins/last-modified.d.ts +1 -2
- package/dist/plugins/last-modified.d.ts.map +1 -1
- package/dist/plugins/last-modified.js +2 -3
- package/dist/plugins/last-modified.js.map +1 -1
- package/dist/{preset-CjHSfa0_.js → preset-BjHACE1Z.js} +2 -2
- package/dist/{preset-CjHSfa0_.js.map → preset-BjHACE1Z.js.map} +1 -1
- package/dist/{remark-include-CPvAzjw2.js → remark-include-C1PuNrmK.js} +5 -8
- package/dist/{remark-include-CPvAzjw2.js.map → remark-include-C1PuNrmK.js.map} +1 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
- package/dist/runtime/browser.d.ts +3 -3
- package/dist/runtime/browser.js +1 -2
- package/dist/runtime/browser.js.map +1 -1
- package/dist/runtime/dynamic.d.ts +2 -4
- package/dist/runtime/dynamic.d.ts.map +1 -1
- package/dist/runtime/dynamic.js +8 -9
- package/dist/runtime/dynamic.js.map +1 -1
- package/dist/runtime/server.d.ts +2 -49
- package/dist/runtime/server.js +1 -2
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/types.d.ts +2 -63
- package/dist/runtime/types.js +1 -1
- package/dist/types-DRpz2Vq2.d.ts +63 -0
- package/dist/types-DRpz2Vq2.d.ts.map +1 -0
- package/dist/vite/index.d.ts +1 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +11 -12
- package/dist/vite/index.js.map +1 -1
- package/dist/webpack/mdx.d.ts +1 -2
- package/dist/webpack/mdx.d.ts.map +1 -1
- package/dist/webpack/mdx.js +7 -8
- package/dist/webpack/mdx.js.map +1 -1
- package/dist/webpack/meta.d.ts +1 -2
- package/dist/webpack/meta.d.ts.map +1 -1
- package/dist/webpack/meta.js +6 -7
- package/dist/webpack/meta.js.map +1 -1
- package/dist/{webpack-CndmG3XE.js → webpack-sTIanFoi.js} +3 -4
- package/dist/{webpack-CndmG3XE.js.map → webpack-sTIanFoi.js.map} +1 -1
- package/package.json +10 -10
- package/dist/adapter-XhFMy0vk.js.map +0 -1
- package/dist/build-mdx-BlB14yk6.js +0 -159
- package/dist/build-mdx-BlB14yk6.js.map +0 -1
- package/dist/core-CES68-08.d.ts.map +0 -1
- package/dist/fs-cache-BhIxGK0G.js +0 -31
- package/dist/fs-cache-BhIxGK0G.js.map +0 -1
- package/dist/index-Jp-qanl0.d.ts.map +0 -1
- package/dist/plugins/index-file.d.ts.map +0 -1
- package/dist/plugins/index-file.js.map +0 -1
- package/dist/rolldown-runtime-CjeV3_4I.js +0 -18
- package/dist/runtime/server.d.ts.map +0 -1
- package/dist/runtime/types.d.ts.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { r as ValidationError } from "./core-
|
|
1
|
+
import { r as ValidationError } from "./core-BluWnx7f.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { parse } from "node:querystring";
|
|
6
|
-
|
|
7
6
|
//#region src/loaders/config.ts
|
|
8
7
|
function createStandaloneConfigLoader({ core, buildConfig, mode }) {
|
|
9
8
|
let prev;
|
|
@@ -18,7 +17,7 @@ function createStandaloneConfigLoader({ core, buildConfig, mode }) {
|
|
|
18
17
|
if (!prev || hash !== prev.hash) prev = {
|
|
19
18
|
hash,
|
|
20
19
|
init: (async () => {
|
|
21
|
-
const { loadConfig } = await import("./load-from-file-
|
|
20
|
+
const { loadConfig } = await import("./load-from-file-vlVZ_DdD.js").then((n) => n.n);
|
|
22
21
|
await core.init({ config: loadConfig(core, buildConfig) });
|
|
23
22
|
})()
|
|
24
23
|
};
|
|
@@ -34,7 +33,6 @@ function createIntegratedConfigLoader(core) {
|
|
|
34
33
|
return core;
|
|
35
34
|
} };
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
37
|
//#region src/loaders/adapter.ts
|
|
40
38
|
function toNode(loader) {
|
|
@@ -139,7 +137,7 @@ function toBun(loader) {
|
|
|
139
137
|
});
|
|
140
138
|
};
|
|
141
139
|
}
|
|
142
|
-
|
|
143
140
|
//#endregion
|
|
144
141
|
export { createIntegratedConfigLoader as a, toWebpack as i, toNode as n, createStandaloneConfigLoader as o, toVite as r, toBun as t };
|
|
145
|
-
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=adapter-nuKMfIZz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-nuKMfIZz.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 { 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)).toString();\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,\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 // Vite doesn't expose the real context types\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).toString(), 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"],"mappings":";;;;;;AAOA,SAAgB,6BAA6B,EAC3C,MACA,aACA,QAWe;CACf,IAAI;CAOJ,eAAe,gBAAiC;AAC9C,MAAI,SAAS,aAAc,QAAO;AAMlC,UAJc,MAAM,GAAG,KAAK,KAAK,YAAY,CAAC,WAAW,CAAC,YAAY;AACpE,SAAM,IAAI,MAAM,0BAA0B;IAC1C,EAEW,MAAM,SAAS,CAAC,UAAU;;AAGzC,QAAO,EACL,MAAM,UAAU;EACd,MAAM,OAAO,MAAM,eAAe;AAClC,MAAI,CAAC,QAAQ,SAAS,KAAK,KACzB,QAAO;GACL;GACA,OAAO,YAAY;IACjB,MAAM,EAAE,eAAe,MAA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/dist/bin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
|
|
4
3
|
//#region src/bin.ts
|
|
5
4
|
async function start() {
|
|
6
5
|
const [configPath, outDir] = process.argv.slice(2);
|
|
@@ -19,7 +18,7 @@ async function start() {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
start();
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
|
-
export {
|
|
22
|
+
export {};
|
|
23
|
+
|
|
25
24
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from 'node:fs';\n\nasync function start() {\n const [configPath, outDir] = process.argv.slice(2);\n const isNext =\n existsSync('next.config.js') ||\n existsSync('next.config.mjs') ||\n existsSync('next.config.mts') ||\n existsSync('next.config.ts');\n\n if (isNext) {\n const { postInstall } = await import('./next');\n await postInstall({ configPath, outDir });\n } else {\n const { postInstall } = await import('./vite');\n await postInstall({ configPath, outDir });\n }\n}\n\nvoid start();\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from 'node:fs';\n\nasync function start() {\n const [configPath, outDir] = process.argv.slice(2);\n const isNext =\n existsSync('next.config.js') ||\n existsSync('next.config.mjs') ||\n existsSync('next.config.mts') ||\n existsSync('next.config.ts');\n\n if (isNext) {\n const { postInstall } = await import('./next');\n await postInstall({ configPath, outDir });\n } else {\n const { postInstall } = await import('./vite');\n await postInstall({ configPath, outDir });\n }\n}\n\nvoid start();\n"],"mappings":";;;AAIA,eAAe,QAAQ;CACrB,MAAM,CAAC,YAAY,UAAU,QAAQ,KAAK,MAAM,EAAE;AAOlD,KALE,WAAW,iBAAiB,IAC5B,WAAW,kBAAkB,IAC7B,WAAW,kBAAkB,IAC7B,WAAW,iBAAiB,EAElB;EACV,MAAM,EAAE,gBAAgB,MAAM,OAAO;AACrC,QAAM,YAAY;GAAE;GAAY;GAAQ,CAAC;QACpC;EACL,MAAM,EAAE,gBAAgB,MAAM,OAAO;AACrC,QAAM,YAAY;GAAE;GAAY;GAAQ,CAAC;;;AAIxC,OAAO"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as applyMdxPreset } from "./preset-
|
|
1
|
+
import { t as applyMdxPreset } from "./preset-BjHACE1Z.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import picomatch from "picomatch";
|
|
4
|
-
|
|
5
4
|
//#region src/config/build.ts
|
|
6
5
|
const SupportedFormats = {
|
|
7
6
|
doc: ["mdx", "md"],
|
|
@@ -94,7 +93,7 @@ function buildConfig(config, cwd = process.cwd()) {
|
|
|
94
93
|
}
|
|
95
94
|
};
|
|
96
95
|
}
|
|
97
|
-
|
|
98
96
|
//#endregion
|
|
99
97
|
export { buildConfig as t };
|
|
100
|
-
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=build-DxkMdv29.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-
|
|
1
|
+
{"version":3,"file":"build-DxkMdv29.js","names":[],"sources":["../src/config/build.ts"],"sourcesContent":["import type { ProcessorOptions } from '@mdx-js/mdx';\nimport type {\n AnyCollection,\n DocCollection,\n DocsCollection,\n GlobalConfig,\n MetaCollection,\n} from '@/config/define';\nimport picomatch from 'picomatch';\nimport { applyMdxPreset } from '@/config/preset';\nimport path from 'node:path';\n\nexport type BuildEnvironment = 'bundler' | 'runtime';\n\nexport interface LoadedConfig {\n collections: Map<string, CollectionItem>;\n global: GlobalConfig;\n getMDXOptions(\n collection?: DocCollectionItem,\n environment?: BuildEnvironment,\n ): ProcessorOptions | Promise<ProcessorOptions>;\n workspaces: Record<\n string,\n {\n dir: string;\n config: LoadedConfig;\n }\n >;\n}\n\nexport type CollectionItem = MetaCollectionItem | DocCollectionItem | DocsCollectionItem;\n\ninterface PrimitiveCollectionItem {\n name: string;\n cwd: string;\n /**\n * content directory (absolute)\n */\n dir: string;\n hasFile: (filePath: string) => boolean;\n isFileSupported: (filePath: string) => boolean;\n patterns: string[];\n}\n\nexport type MetaCollectionItem = PrimitiveCollectionItem & Omit<MetaCollection, 'files' | 'dir'>;\nexport type DocCollectionItem = PrimitiveCollectionItem & Omit<DocCollection, 'files' | 'dir'>;\n\nexport interface DocsCollectionItem\n extends Omit<DocsCollection, 'dir' | 'meta' | 'docs'>, Omit<PrimitiveCollectionItem, 'patterns'> {\n meta: MetaCollectionItem;\n docs: DocCollectionItem;\n}\n\nconst SupportedFormats = {\n doc: ['mdx', 'md'],\n meta: ['json', 'yaml'],\n};\n\nexport function buildCollection(\n name: string,\n collection: AnyCollection,\n cwd: string,\n): CollectionItem {\n if (collection.type === 'docs') {\n return {\n ...collection,\n type: 'docs',\n get dir() {\n return this.docs.dir;\n },\n name,\n meta: buildCollection(name, collection.meta, cwd) as MetaCollectionItem,\n docs: buildCollection(name, collection.docs, cwd) as DocCollectionItem,\n hasFile(filePath) {\n return this.docs.hasFile(filePath) || this.meta.hasFile(filePath);\n },\n isFileSupported(filePath) {\n return this.docs.isFileSupported(filePath) || this.meta.isFileSupported(filePath);\n },\n cwd,\n };\n }\n\n return {\n ...collection,\n ...buildPrimitiveCollection(name, collection, cwd),\n };\n}\n\nfunction buildPrimitiveCollection(\n name: string,\n config: DocCollection | MetaCollection,\n cwd: string,\n): PrimitiveCollectionItem {\n const supportedFormats = SupportedFormats[config.type];\n const patterns = config.files ?? [`**/*.{${supportedFormats.join(',')}}`];\n let matcher: picomatch.Matcher;\n\n return {\n dir: path.resolve(cwd, config.dir),\n cwd,\n name,\n patterns,\n isFileSupported(filePath) {\n return supportedFormats.some((format) => filePath.endsWith(`.${format}`));\n },\n hasFile(filePath) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (matcher ??= picomatch(patterns))(relativePath);\n },\n };\n}\n\nexport function buildConfig(config: Record<string, unknown>, cwd = process.cwd()): LoadedConfig {\n const collections = new Map<string, CollectionItem>();\n const loaded: GlobalConfig = {};\n\n for (const [k, v] of Object.entries(config)) {\n if (!v) {\n continue;\n }\n\n if (typeof v === 'object' && 'type' in v) {\n if (v.type === 'docs' || v.type === 'doc' || v.type === 'meta') {\n collections.set(k, buildCollection(k, v as AnyCollection, cwd));\n continue;\n }\n }\n\n if (k === 'default' && v) {\n Object.assign(loaded, v);\n continue;\n }\n\n throw new Error(\n `Unknown export \"${k}\", you can only export collections from source configuration file.`,\n );\n }\n\n const mdxOptionsCache = new Map<string, ProcessorOptions | Promise<ProcessorOptions>>();\n return {\n global: loaded,\n collections,\n workspaces: Object.fromEntries(\n Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {\n return [\n key,\n {\n dir: value.dir,\n config: buildConfig(value.config, path.resolve(cwd, value.dir)),\n },\n ];\n }),\n ),\n getMDXOptions(collection, environment = 'bundler') {\n const key = collection ? `${environment}:${collection.name}` : environment;\n const cached = mdxOptionsCache.get(key);\n if (cached) return cached;\n let result: ProcessorOptions | Promise<ProcessorOptions>;\n\n if (collection?.mdxOptions) {\n const optionsFn = collection.mdxOptions;\n result = typeof optionsFn === 'function' ? optionsFn(environment) : optionsFn;\n } else {\n result = (async () => {\n const optionsFn = this.global.mdxOptions;\n const options = typeof optionsFn === 'function' ? await optionsFn() : optionsFn;\n\n return applyMdxPreset(options)(environment);\n })();\n }\n\n mdxOptionsCache.set(key, result);\n return result;\n },\n };\n}\n"],"mappings":";;;;AAqDA,MAAM,mBAAmB;CACvB,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,QAAQ,OAAO;CACvB;AAED,SAAgB,gBACd,MACA,YACA,KACgB;AAChB,KAAI,WAAW,SAAS,OACtB,QAAO;E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EAAE,SAAS,QAAQ;AAC9D,gBAAY,IAAI,GAAG,gBAAgB,GAAG,GAAoB,IAAI,CAAC;AAC/D;;;AAIJ,MAAI,MAAM,aAAa,GAAG;AACxB,UAAO,OAAO,QAAQ,EAAE;AACxB;;AAGF,QAAM,IAAI,MACR,mBAAmB,EAAE,oEACtB;;CAGH,MAAM,kCAAkB,IAAI,KAA2D;AACvF,QAAO;EACL,QAAQ;EACR;EACA,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW;AAC5D,UAAO,CACL,KACA;IACE,KAAK,MAAM;IACX,QAAQ,YAAY,MAAM,QAAQ,KAAK,QAAQ,KAAK,MAAM,IAAI,CAAC;IAChE,CACF;IACD,CACH;EACD,cAAc,YAAY,cAAc,WAAW;GACjD,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,WAAW,SAAS;GAC/D,MAAM,SAAS,gBAAgB,IAAI,IAAI;AACvC,OAAI,OAAQ,QAAO;GACnB,IAAI;AAEJ,OAAI,YAAY,YAAY;IAC1B,MAAM,YAAY,WAAW;AAC7B,aAAS,OAAO,cAAc,aAAa,UAAU,YAAY,GAAG;SAEpE,WAAU,YAAY;IACpB,MAAM,YAAY,KAAK,OAAO;AAG9B,WAAO,eAFS,OAAO,cAAc,aAAa,MAAM,WAAW,GAAG,UAExC,CAAC,YAAY;OACzC;AAGN,mBAAgB,IAAI,KAAK,OAAO;AAChC,UAAO;;EAEV"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
+
import { n as flattenNode, t as remarkInclude } from "./remark-include-C1PuNrmK.js";
|
|
3
|
+
import { visit } from "unist-util-visit";
|
|
4
|
+
import { VFile } from "vfile";
|
|
5
|
+
import { createProcessor } from "@mdx-js/mdx";
|
|
6
|
+
import { valueToEstree } from "estree-util-value-to-estree";
|
|
7
|
+
import { removePosition } from "unist-util-remove-position";
|
|
8
|
+
import { mdxToMarkdown } from "mdast-util-mdx";
|
|
9
|
+
import { toMarkdown } from "mdast-util-to-markdown";
|
|
10
|
+
//#region ../core/dist/mdast-utils-9tJwoVTq.js
|
|
11
|
+
function toMdxExport(name, value) {
|
|
12
|
+
return toMdxExportRaw(name, valueToEstree(value));
|
|
13
|
+
}
|
|
14
|
+
function toMdxExportRaw(name, expression) {
|
|
15
|
+
return {
|
|
16
|
+
type: "mdxjsEsm",
|
|
17
|
+
value: "",
|
|
18
|
+
data: { estree: {
|
|
19
|
+
type: "Program",
|
|
20
|
+
sourceType: "module",
|
|
21
|
+
body: [{
|
|
22
|
+
type: "ExportNamedDeclaration",
|
|
23
|
+
attributes: [],
|
|
24
|
+
specifiers: [],
|
|
25
|
+
declaration: {
|
|
26
|
+
type: "VariableDeclaration",
|
|
27
|
+
kind: "let",
|
|
28
|
+
declarations: [{
|
|
29
|
+
type: "VariableDeclarator",
|
|
30
|
+
id: {
|
|
31
|
+
type: "Identifier",
|
|
32
|
+
name
|
|
33
|
+
},
|
|
34
|
+
init: expression
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
}]
|
|
38
|
+
} }
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region ../core/dist/mdx-plugins/stringifier.js
|
|
43
|
+
function defaultStringifier(config = {}) {
|
|
44
|
+
const { filterMdxAttributes, filterElement = (node) => {
|
|
45
|
+
switch (node.type) {
|
|
46
|
+
case "mdxJsxFlowElement":
|
|
47
|
+
case "mdxJsxTextElement":
|
|
48
|
+
switch (node.name) {
|
|
49
|
+
case "File":
|
|
50
|
+
case "TypeTable":
|
|
51
|
+
case "Callout":
|
|
52
|
+
case "Card": return true;
|
|
53
|
+
}
|
|
54
|
+
return "children-only";
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}, onStringify, ...customExtension } = config;
|
|
58
|
+
function modHandler(handler, ctx) {
|
|
59
|
+
return function(node, parent, state, info) {
|
|
60
|
+
let visibility = filterElement(node);
|
|
61
|
+
if (visibility === false) return "";
|
|
62
|
+
if (onStringify) onStringify(node, ctx);
|
|
63
|
+
const extraInfo = node.data?._stringify;
|
|
64
|
+
if (extraInfo) if (extraInfo === "children-only") visibility = "children-only";
|
|
65
|
+
else if ("text" in extraInfo) return extraInfo.text;
|
|
66
|
+
else node = extraInfo.node;
|
|
67
|
+
if (visibility === "children-only") {
|
|
68
|
+
if (!("children" in node)) return "";
|
|
69
|
+
switch (node.type) {
|
|
70
|
+
case "mdxJsxTextElement":
|
|
71
|
+
case "paragraph": return state.containerPhrasing(node, info);
|
|
72
|
+
case "mdxJsxFlowElement": return state.containerFlow(node, info);
|
|
73
|
+
default: return state.containerFlow({
|
|
74
|
+
type: "root",
|
|
75
|
+
children: node.children
|
|
76
|
+
}, info);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
switch (node.type) {
|
|
80
|
+
case "mdxJsxFlowElement":
|
|
81
|
+
case "mdxJsxTextElement": {
|
|
82
|
+
const stringifiedAttributes = [];
|
|
83
|
+
for (const attr of node.attributes) {
|
|
84
|
+
if (attr.type === "mdxJsxExpressionAttribute") continue;
|
|
85
|
+
if (filterMdxAttributes && !filterMdxAttributes(node, attr)) continue;
|
|
86
|
+
const str = typeof attr.value === "string" ? attr.value : attr.value?.value;
|
|
87
|
+
if (!str) continue;
|
|
88
|
+
stringifiedAttributes.push({
|
|
89
|
+
type: "mdxJsxAttribute",
|
|
90
|
+
name: attr.name,
|
|
91
|
+
value: str
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return handler({
|
|
95
|
+
...node,
|
|
96
|
+
attributes: stringifiedAttributes
|
|
97
|
+
}, parent, state, info);
|
|
98
|
+
}
|
|
99
|
+
default: return handler(node, parent, state, info);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const customToMarkdown = { handlers: { _custom(node, _, state, info) {
|
|
104
|
+
const handlers = state.handlers;
|
|
105
|
+
for (const k in handlers) handlers[k] = modHandler(handlers[k], node.ctx);
|
|
106
|
+
return state.handle(node.root, void 0, state, info);
|
|
107
|
+
} } };
|
|
108
|
+
return function(root, ctx) {
|
|
109
|
+
return toMarkdown({
|
|
110
|
+
type: "_custom",
|
|
111
|
+
root,
|
|
112
|
+
ctx
|
|
113
|
+
}, {
|
|
114
|
+
...this?.data("settings"),
|
|
115
|
+
extensions: [
|
|
116
|
+
mdxToMarkdown(),
|
|
117
|
+
...this?.data("toMarkdownExtensions") ?? [],
|
|
118
|
+
customToMarkdown,
|
|
119
|
+
customExtension
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region ../core/dist/mdx-plugins/remark-llms.js
|
|
126
|
+
/**
|
|
127
|
+
* generate `llms.txt` for markdown.
|
|
128
|
+
*/
|
|
129
|
+
function remarkLLMs({ as = "_markdown", headingIds = true, ...stringify } = {}) {
|
|
130
|
+
const stringifier = defaultStringifier({
|
|
131
|
+
...stringify,
|
|
132
|
+
filterElement(node) {
|
|
133
|
+
switch (node.type) {
|
|
134
|
+
case "mdxjsEsm": return false;
|
|
135
|
+
default: return true;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
handlers: {
|
|
139
|
+
heading(node, _p, state, info) {
|
|
140
|
+
const id = node.data?.hProperties?.id;
|
|
141
|
+
const content = state.containerPhrasing(node, info);
|
|
142
|
+
return headingIds && id ? `${content} [#${id}]` : content;
|
|
143
|
+
},
|
|
144
|
+
...stringify.handlers
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return (node) => {
|
|
148
|
+
node.children.unshift(toMdxExport(as, stringifier.call(this, node, void 0)));
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/loaders/mdx/remark-postprocess.ts
|
|
153
|
+
/**
|
|
154
|
+
* - collect references
|
|
155
|
+
* - write frontmatter (auto-title & description)
|
|
156
|
+
*/
|
|
157
|
+
function remarkPostprocess({ includeProcessedMarkdown = false, includeMDAST = false, extractLinkReferences = false, valueToExport = [] }) {
|
|
158
|
+
return (tree, file) => {
|
|
159
|
+
const frontmatter = file.data.frontmatter ??= {};
|
|
160
|
+
if (!frontmatter.title) visit(tree, "heading", (node) => {
|
|
161
|
+
if (node.depth === 1) {
|
|
162
|
+
frontmatter.title = flattenNode(node);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
file.data["mdx-export"] ??= [];
|
|
167
|
+
file.data["mdx-export"].push({
|
|
168
|
+
name: "frontmatter",
|
|
169
|
+
value: frontmatter
|
|
170
|
+
});
|
|
171
|
+
if (extractLinkReferences) {
|
|
172
|
+
const urls = [];
|
|
173
|
+
visit(tree, "link", (node) => {
|
|
174
|
+
urls.push({ href: node.url });
|
|
175
|
+
return "skip";
|
|
176
|
+
});
|
|
177
|
+
file.data["mdx-export"].push({
|
|
178
|
+
name: "extractedReferences",
|
|
179
|
+
value: urls
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (includeProcessedMarkdown) remarkLLMs.call(this, typeof includeProcessedMarkdown === "object" ? includeProcessedMarkdown : void 0)(tree, file, () => void 0);
|
|
183
|
+
if (includeMDAST) {
|
|
184
|
+
const options = includeMDAST === true ? {} : includeMDAST;
|
|
185
|
+
const mdast = JSON.stringify(options.removePosition ? removePosition(structuredClone(tree)) : tree);
|
|
186
|
+
file.data["mdx-export"].push({
|
|
187
|
+
name: "_mdast",
|
|
188
|
+
value: mdast
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
for (const { name, value } of file.data["mdx-export"]) tree.children.unshift(getMdastExport(name, value));
|
|
192
|
+
file.data["mdx-export"] = [];
|
|
193
|
+
for (const name of valueToExport) {
|
|
194
|
+
if (!(name in file.data)) continue;
|
|
195
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins
|
|
201
|
+
*
|
|
202
|
+
* Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node
|
|
203
|
+
*/
|
|
204
|
+
function getMdastExport(name, value) {
|
|
205
|
+
return {
|
|
206
|
+
type: "mdxjsEsm",
|
|
207
|
+
value: "",
|
|
208
|
+
data: { estree: {
|
|
209
|
+
type: "Program",
|
|
210
|
+
sourceType: "module",
|
|
211
|
+
body: [{
|
|
212
|
+
type: "ExportNamedDeclaration",
|
|
213
|
+
attributes: [],
|
|
214
|
+
specifiers: [],
|
|
215
|
+
source: null,
|
|
216
|
+
declaration: {
|
|
217
|
+
type: "VariableDeclaration",
|
|
218
|
+
kind: "let",
|
|
219
|
+
declarations: [{
|
|
220
|
+
type: "VariableDeclarator",
|
|
221
|
+
id: {
|
|
222
|
+
type: "Identifier",
|
|
223
|
+
name
|
|
224
|
+
},
|
|
225
|
+
init: valueToEstree(value)
|
|
226
|
+
}]
|
|
227
|
+
}
|
|
228
|
+
}]
|
|
229
|
+
} }
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/loaders/mdx/build-mdx.ts
|
|
234
|
+
var build_mdx_exports = /* @__PURE__ */ __exportAll({ buildMDX: () => buildMDX });
|
|
235
|
+
async function buildMDX(core, collection, { filePath, frontmatter, source, _compiler, environment, isDevelopment }) {
|
|
236
|
+
const mdxOptions = await core.getConfig().getMDXOptions(collection, environment);
|
|
237
|
+
function getProcessor(format) {
|
|
238
|
+
const cache = core.cache;
|
|
239
|
+
const key = `build-mdx:${collection?.name ?? "global"}:${format}`;
|
|
240
|
+
let processor = cache.get(key);
|
|
241
|
+
if (!processor) {
|
|
242
|
+
const postprocessOptions = {
|
|
243
|
+
_format: format,
|
|
244
|
+
...collection?.postprocess
|
|
245
|
+
};
|
|
246
|
+
processor = createProcessor({
|
|
247
|
+
outputFormat: "program",
|
|
248
|
+
development: isDevelopment,
|
|
249
|
+
...mdxOptions,
|
|
250
|
+
remarkPlugins: [
|
|
251
|
+
remarkInclude,
|
|
252
|
+
...mdxOptions.remarkPlugins ?? [],
|
|
253
|
+
[remarkPostprocess, postprocessOptions]
|
|
254
|
+
],
|
|
255
|
+
format
|
|
256
|
+
});
|
|
257
|
+
cache.set(key, processor);
|
|
258
|
+
}
|
|
259
|
+
return processor;
|
|
260
|
+
}
|
|
261
|
+
let vfile = new VFile({
|
|
262
|
+
value: source,
|
|
263
|
+
path: filePath,
|
|
264
|
+
cwd: collection?.cwd,
|
|
265
|
+
data: {
|
|
266
|
+
frontmatter,
|
|
267
|
+
_compiler,
|
|
268
|
+
_getProcessor: getProcessor
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
if (collection) vfile = await core.transformVFile({
|
|
272
|
+
collection,
|
|
273
|
+
filePath,
|
|
274
|
+
source
|
|
275
|
+
}, vfile);
|
|
276
|
+
return getProcessor(filePath.endsWith(".mdx") ? "mdx" : "md").process(vfile);
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
export { build_mdx_exports as n, buildMDX as t };
|
|
280
|
+
|
|
281
|
+
//# sourceMappingURL=build-mdx-C5FB6EIF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-mdx-C5FB6EIF.js","names":[],"sources":["../../core/dist/mdast-utils-9tJwoVTq.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/mdast-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}\n//#endregion\nexport { toMdxExport as n, toMdxExportRaw 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}, onStringify, ...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 (onStringify) onStringify(node, ctx);\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 { n as toMdxExport } from \"../mdast-utils-9tJwoVTq.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, ...stringify } = {}) {\n\tconst stringifier = defaultStringifier({\n\t\t...stringify,\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\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...stringify.handlers\n\t\t}\n\t});\n\treturn (node) => {\n\t\tnode.children.unshift(toMdxExport(as, stringifier.call(this, node, void 0)));\n\t};\n}\n//#endregion\nexport { 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 { remarkLLMs, type LLMsOptions } 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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":["../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;;;EAYb,MAAA;AAAA;AAAA,UAGe,eAAA;EAZN;;;EAgBT,WAAA,GAAc,MAAA;EAPR;;AAGR;EASE,YAAA;IAAiB,IAAA;IAAc,KAAA;EAAA;EAUW;;;EAL1C,SAAA,GAAY,eAAA;EAVE;;;EAed,aAAA,IAAiB,MAAA,mBAAyB,SAAA;AAAA;AAAA;EAAA,UAKhC,OAAA,SAAgB,eAAA;AAAA"}
|
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,13 +1,12 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import
|
|
4
|
-
import { t as buildConfig } from "../build-
|
|
5
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
6
|
-
import "../codegen-
|
|
7
|
-
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-
|
|
8
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import "../fuma-matter-Fge-qpw1.js";
|
|
2
|
+
import { t as createMdxLoader } from "../mdx-OAccQ48U.js";
|
|
3
|
+
import "../preset-BjHACE1Z.js";
|
|
4
|
+
import { t as buildConfig } from "../build-DxkMdv29.js";
|
|
5
|
+
import { n as createCore, t as _Defaults } from "../core-BluWnx7f.js";
|
|
6
|
+
import "../codegen-Bd9bQlN7.js";
|
|
7
|
+
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-nuKMfIZz.js";
|
|
8
|
+
import { t as createMetaLoader } from "../meta-Di0sMUh5.js";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
|
-
|
|
11
10
|
//#region src/bun/index.ts
|
|
12
11
|
function createMdxPlugin(options = {}) {
|
|
13
12
|
const { environment = "bun", outDir = _Defaults.outDir, configPath = _Defaults.configPath, disableMetaFile = false } = options;
|
|
@@ -27,7 +26,7 @@ function createMdxPlugin(options = {}) {
|
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
30
|
export { createMdxPlugin };
|
|
31
|
+
|
|
33
32
|
//# sourceMappingURL=index.js.map
|
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,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { glob } from "tinyglobby";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/codegen.ts
|
|
5
4
|
/**
|
|
6
5
|
* Code generator (one instance per file)
|
|
@@ -95,7 +94,7 @@ function slash(path) {
|
|
|
95
94
|
function ident(code, tab = 1) {
|
|
96
95
|
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
97
96
|
}
|
|
98
|
-
|
|
99
97
|
//#endregion
|
|
100
98
|
export { ident as n, slash as r, createCodegen as t };
|
|
101
|
-
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=codegen-Bd9bQlN7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-
|
|
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 extenstion 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;;EAE/B,MAAM,UAAU,QAAuC;AACrD,QAAK,MAAM,QAAQ,MAAM,QAAQ,IAAI,OAAO,EAAE;AAC5C,QAAI,SAAS,KAAA,EAAW;AAExB,SAAK,MAAM,KAAK,KAAK;;;EAIzB,MAAM,mBACJ,UACA,SACiB;AACjB,OAAI,WAAW,OACb,QAAO,KAAK,uBAAuB,UAAU,QAAQ;AAGvD,UAAO,KAAK,uBAAuB,UAAU,QAAQ;;EAGv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;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
|
|
2
|
-
export { AnyCollection, BaseCollection, CollectionSchema, DefaultMDXOptions, DocCollection, DocsCollection, GlobalConfig, MDXPresetOptions, MetaCollection,
|
|
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-BF3YhvIc.js";
|
|
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,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
import { t as remarkInclude } from "../remark-include-
|
|
1
|
+
import "../fuma-matter-Fge-qpw1.js";
|
|
2
|
+
import { t as applyMdxPreset } from "../preset-BjHACE1Z.js";
|
|
3
|
+
import { t as remarkInclude } from "../remark-include-C1PuNrmK.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
5
|
//#region ../core/dist/source/schema.js
|
|
7
6
|
/**
|
|
8
7
|
* Zod 4 schema
|
|
@@ -26,7 +25,6 @@ const pageSchema = z.object({
|
|
|
26
25
|
full: z.boolean().optional(),
|
|
27
26
|
_openapi: z.looseObject({}).optional()
|
|
28
27
|
});
|
|
29
|
-
|
|
30
28
|
//#endregion
|
|
31
29
|
//#region src/config/define.ts
|
|
32
30
|
function defineCollections(options) {
|
|
@@ -54,7 +52,7 @@ function defineDocs(options) {
|
|
|
54
52
|
function defineConfig(config = {}) {
|
|
55
53
|
return config;
|
|
56
54
|
}
|
|
57
|
-
|
|
58
55
|
//#endregion
|
|
59
56
|
export { applyMdxPreset, defineCollections, defineConfig, defineDocs, pageSchema as frontmatterSchema, metaSchema, remarkInclude };
|
|
57
|
+
|
|
60
58
|
//# sourceMappingURL=index.js.map
|