fumadocs-mdx 14.3.0 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-CrnPUO1X.js → adapter-DB1MHK9h.js} +3 -3
- package/dist/{adapter-CrnPUO1X.js.map → adapter-DB1MHK9h.js.map} +1 -1
- package/dist/{build-DxkMdv29.js → build-DPafU2lu.js} +2 -2
- package/dist/{build-DxkMdv29.js.map → build-DPafU2lu.js.map} +1 -1
- package/dist/{build-mdx-iu_4pINO.js → build-mdx-82nyqL4J.js} +2 -2
- package/dist/{build-mdx-iu_4pINO.js.map → build-mdx-82nyqL4J.js.map} +1 -1
- package/dist/{build-mdx-CAXqH1_C.d.ts → build-mdx-YyRh-ZGV.d.ts} +1 -1
- package/dist/{build-mdx-CAXqH1_C.d.ts.map → build-mdx-YyRh-ZGV.d.ts.map} +1 -1
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +5 -5
- package/dist/{codegen-Bd9bQlN7.js → codegen-B8EhLmbU.js} +1 -1
- package/dist/{codegen-Bd9bQlN7.js.map → codegen-B8EhLmbU.js.map} +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +2 -2
- package/dist/{core-BluWnx7f.js → core-B0lF760L.js} +2 -2
- package/dist/{core-BluWnx7f.js.map → core-B0lF760L.js.map} +1 -1
- package/dist/{core-C9TGjTWd.d.ts → core-DzcubDJt.d.ts} +2 -2
- package/dist/{core-C9TGjTWd.d.ts.map → core-DzcubDJt.d.ts.map} +1 -1
- package/dist/{index-Cfo6kcGs.d.ts → index-BIbaPT3v.d.ts} +1 -1
- package/dist/index-BIbaPT3v.d.ts.map +1 -0
- package/dist/{index-file-4qOxhCQn.js → index-file-eVlUbKSO.js} +4 -4
- package/dist/index-file-eVlUbKSO.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/{load-from-file-CEpo5Sqi.js → load-from-file-C1DDNVwF.js} +2 -2
- package/dist/{load-from-file-CEpo5Sqi.js.map → load-from-file-C1DDNVwF.js.map} +1 -1
- package/dist/{loaders-BauN_my2.js → loaders-ezSYYkT7.js} +1 -1
- package/dist/{loaders-BauN_my2.js.map → loaders-ezSYYkT7.js.map} +1 -1
- package/dist/{mdx-Cd17PhOW.js → mdx-D2vcWdqv.js} +5 -5
- package/dist/mdx-D2vcWdqv.js.map +1 -0
- package/dist/{meta-DV1ZTafU.js → meta-B6guI74I.js} +3 -3
- package/dist/{meta-DV1ZTafU.js.map → meta-B6guI74I.js.map} +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +4 -4
- package/dist/node/loader.js +4 -4
- package/dist/plugins/index-file.d.ts +1 -1
- package/dist/plugins/index-file.js +1 -1
- package/dist/plugins/json-schema.d.ts +1 -1
- package/dist/plugins/last-modified.d.ts +1 -1
- package/dist/plugins/last-modified.js +1 -1
- package/dist/{preset-BjHACE1Z.js → preset-B0H8HalE.js} +1 -1
- package/dist/{preset-BjHACE1Z.js.map → preset-B0H8HalE.js.map} +1 -1
- package/dist/{remark-include-naMKDvrK.js → remark-include-VDoXZSBN.js} +3 -3
- package/dist/remark-include-VDoXZSBN.js.map +1 -0
- package/dist/runtime/browser.d.ts +3 -3
- package/dist/runtime/dynamic.d.ts +2 -2
- package/dist/runtime/dynamic.js +5 -5
- package/dist/runtime/dynamic.js.map +1 -1
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/types.d.ts +1 -1
- package/dist/{types-DRpz2Vq2.d.ts → types-hAduruLB.d.ts} +1 -1
- package/dist/{types-DRpz2Vq2.d.ts.map → types-hAduruLB.d.ts.map} +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +7 -7
- package/dist/webpack/mdx.d.ts +1 -1
- package/dist/webpack/mdx.js +3 -3
- package/dist/webpack/meta.d.ts +1 -1
- package/dist/webpack/meta.js +3 -3
- package/dist/{webpack-sTIanFoi.js → webpack-DmRbt96H.js} +2 -2
- package/dist/{webpack-sTIanFoi.js.map → webpack-DmRbt96H.js.map} +1 -1
- package/package.json +2 -2
- package/dist/fuma-matter-Fge-qpw1.js +0 -26
- package/dist/fuma-matter-Fge-qpw1.js.map +0 -1
- package/dist/index-Cfo6kcGs.d.ts.map +0 -1
- package/dist/index-file-4qOxhCQn.js.map +0 -1
- package/dist/mdx-Cd17PhOW.js.map +0 -1
- package/dist/remark-include-naMKDvrK.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as ValidationError } from "./core-
|
|
2
|
-
import { t as loadConfig } from "./load-from-file-
|
|
1
|
+
import { r as ValidationError } from "./core-B0lF760L.js";
|
|
2
|
+
import { t as loadConfig } from "./load-from-file-C1DDNVwF.js";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -138,4 +138,4 @@ function toBun(loader) {
|
|
|
138
138
|
//#endregion
|
|
139
139
|
export { createIntegratedConfigLoader as a, toWebpack as i, toNode as n, createStandaloneConfigLoader as o, toVite as r, toBun as t };
|
|
140
140
|
|
|
141
|
-
//# sourceMappingURL=adapter-
|
|
141
|
+
//# sourceMappingURL=adapter-DB1MHK9h.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-
|
|
1
|
+
{"version":3,"file":"adapter-DB1MHK9h.js","names":[],"sources":["../src/loaders/config.ts","../src/loaders/adapter.ts"],"sourcesContent":["import { loadConfig } from '@/config/load-from-file';\nimport 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: core.init({\n config: loadConfig(core, buildConfig),\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"],"mappings":";;;;;;;AAQA,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,MAAM,KAAK,KAAK,EACd,QAAQ,WAAW,MAAM,YAAY,EACtC,CAAC;GACH;AAGH,QAAM,KAAK;AACX,SAAO;IAEV;;;;;AAMH,SAAgB,6BAA6B,MAA0B;AACrE,QAAO,EACL,MAAM,UAAU;AACd,SAAO;IAEV;;;;ACNH,SAAgB,OAAO,QAA0B;AAC/C,QAAO,OAAO,KAAK,UAAU,aAAoC;AAC/D,MAAI,IAAI,WAAW,WAAW,KAAK,CAAC,OAAO,QAAQ,OAAO,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AAS,KAAA,GAAW,OAAO,MAAM,OAAO,IAAc;WAEjD,OAAO;AACd,OAAI,iBAAiB,gBACnB,QAAO,SAAS,IAAI,MAAM,MAAM,MAAM,mBAAmB,CAAC,CAAC;AAG7D,OAAI,EAAE,iBAAiB,OAAQ,OAAM;AACrC,YAAS,MAAM;;;;AAKrB,SAAgB,MAAM,QAAgB;CACpC,SAAS,SAAS,QAA+C;AAE/D,MAAI,CAAC,OAAQ;AAEb,SAAO;GACL,UAAU,OAAO;GACjB,QAAQ,OAAO,cAAc;GAC9B;;AAGH,SAAQ,UAA6B;AAEnC,QAAM,OAAO,EAAE,QAAQ,OAAO,QAAQ,MAAM,GAAG,SAAS;GACtD,MAAM,CAAC,UAAU,QAAQ,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,4 +1,4 @@
|
|
|
1
|
-
import { t as applyMdxPreset } from "./preset-
|
|
1
|
+
import { t as applyMdxPreset } from "./preset-B0H8HalE.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import picomatch from "picomatch";
|
|
4
4
|
//#region src/config/build.ts
|
|
@@ -96,4 +96,4 @@ function buildConfig(config, cwd = process.cwd()) {
|
|
|
96
96
|
//#endregion
|
|
97
97
|
export { buildConfig as t };
|
|
98
98
|
|
|
99
|
-
//# sourceMappingURL=build-
|
|
99
|
+
//# sourceMappingURL=build-DPafU2lu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-
|
|
1
|
+
{"version":3,"file":"build-DPafU2lu.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;EACL,GAAG;EACH,MAAM;EACN,IAAI,MAAM;AACR,UAAO,KAAK,KAAK;;EAEnB;EACA,MAAM,gBAAgB,MAAM,WAAW,MAAM,IAAI;EACjD,MAAM,gBAAgB,MAAM,WAAW,MAAM,IAAI;EACjD,QAAQ,UAAU;AAChB,UAAO,KAAK,KAAK,QAAQ,SAAS,IAAI,KAAK,KAAK,QAAQ,SAAS;;EAEnE,gBAAgB,UAAU;AACxB,UAAO,KAAK,KAAK,gBAAgB,SAAS,IAAI,KAAK,KAAK,gBAAgB,SAAS;;EAEnF;EACD;AAGH,QAAO;EACL,GAAG;EACH,GAAG,yBAAyB,MAAM,YAAY,IAAI;EACnD;;AAGH,SAAS,yBACP,MACA,QACA,KACyB;CACzB,MAAM,mBAAmB,iBAAiB,OAAO;CACjD,MAAM,WAAW,OAAO,SAAS,CAAC,SAAS,iBAAiB,KAAK,IAAI,CAAC,GAAG;CACzE,IAAI;AAEJ,QAAO;EACL,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI;EAClC;EACA;EACA;EACA,gBAAgB,UAAU;AACxB,UAAO,iBAAiB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;EAE3E,QAAQ,UA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;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"}
|
|
@@ -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-VDoXZSBN.js";
|
|
3
3
|
import { visit } from "unist-util-visit";
|
|
4
4
|
import { VFile } from "vfile";
|
|
5
5
|
import { createProcessor } from "@mdx-js/mdx";
|
|
@@ -304,4 +304,4 @@ async function buildMDX(core, collection, { filePath, frontmatter, source, _comp
|
|
|
304
304
|
//#endregion
|
|
305
305
|
export { build_mdx_exports as n, buildMDX as t };
|
|
306
306
|
|
|
307
|
-
//# sourceMappingURL=build-mdx-
|
|
307
|
+
//# sourceMappingURL=build-mdx-82nyqL4J.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-mdx-iu_4pINO.js","names":[],"sources":["../../core/dist/utils-pSG8hSr9.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(flattenNode).join(\"\");\n\tif (\"value\" in node && typeof node.value === \"string\") return node.value;\n\treturn \"\";\n}\nfunction flattenNodeHast(node) {\n\tif (\"children\" in node) return node.children.map(flattenNodeHast).join(\"\");\n\treturn \"value\" in node && typeof node.value === \"string\" ? node.value : \"\";\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 a, toMdxExport as i, flattenNodeHast as n, handleTag 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 { i as toMdxExport } from \"../utils-pSG8hSr9.js\";\nimport { defaultStringifier } from \"./stringifier.js\";\nimport { defaultHandlers } from \"mdast-util-to-markdown\";\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 defaultValue = defaultHandlers.heading(node, _p, state, info);\n\t\t\t\treturn headingIds && id ? `${defaultValue} [#${id}]` : defaultValue;\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":";;;;;;;;;;AAWA,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;;;;ACpCF,SAAS,mBAAmB,SAAS,EAAE,EAAE;CACxC,MAAM,EAAE,qBAAqB,iBAAiB,SAAS;AACtD,UAAQ,KAAK,MAAb;GACC,KAAK;GACL,KAAK;AACJ,YAAQ,KAAK,MAAb;KACC,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK,OAAQ,QAAO;;AAErB,WAAO;;AAET,SAAO;IACL,WAAW,GAAG,oBAAoB;CACrC,SAAS,WAAW,SAAS,KAAK;AACjC,S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AEF,KAAI,WACF,SAAQ,MAAM,KAAK,eAAe;EAAE;EAAY;EAAU;EAAQ,EAAE,MAAM;AAG5E,QAAO,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,CAAC,QAAQ,MAAM"}
|
|
1
|
+
{"version":3,"file":"build-mdx-82nyqL4J.js","names":[],"sources":["../../core/dist/utils-pSG8hSr9.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(flattenNode).join(\"\");\n\tif (\"value\" in node && typeof node.value === \"string\") return node.value;\n\treturn \"\";\n}\nfunction flattenNodeHast(node) {\n\tif (\"children\" in node) return node.children.map(flattenNodeHast).join(\"\");\n\treturn \"value\" in node && typeof node.value === \"string\" ? node.value : \"\";\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 a, toMdxExport as i, flattenNodeHast as n, handleTag 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 { i as toMdxExport } from \"../utils-pSG8hSr9.js\";\nimport { defaultStringifier } from \"./stringifier.js\";\nimport { defaultHandlers } from \"mdast-util-to-markdown\";\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 defaultValue = defaultHandlers.heading(node, _p, state, info);\n\t\t\t\treturn headingIds && id ? `${defaultValue} [#${id}]` : defaultValue;\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":";;;;;;;;;;AAW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;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"}
|
package/dist/bun/index.d.ts
CHANGED
package/dist/bun/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-
|
|
2
|
-
import { t as buildConfig } from "../build-
|
|
3
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
4
|
-
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-
|
|
5
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-D2vcWdqv.js";
|
|
2
|
+
import { t as buildConfig } from "../build-DPafU2lu.js";
|
|
3
|
+
import { n as createCore, t as _Defaults } from "../core-B0lF760L.js";
|
|
4
|
+
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-DB1MHK9h.js";
|
|
5
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
//#region src/bun/index.ts
|
|
8
8
|
function createMdxPlugin(options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-
|
|
1
|
+
{"version":3,"file":"codegen-B8EhLmbU.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;;EAE/B,MAAM,UAAU,QAAuC;AACrD,QAAK,MAAM,QAAQ,MAAM,QAAQ,IAAI,OAAO,EAAE;AAC5C,QAAI,SAAS,KAAA,EAAW;AAExB,SA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L,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-DzcubDJt.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,5 +1,5 @@
|
|
|
1
|
-
import { t as applyMdxPreset } from "../preset-
|
|
2
|
-
import { t as remarkInclude } from "../remark-include-
|
|
1
|
+
import { t as applyMdxPreset } from "../preset-B0H8HalE.js";
|
|
2
|
+
import { t as remarkInclude } from "../remark-include-VDoXZSBN.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../core/dist/source/schema.js
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ident } from "./codegen-
|
|
1
|
+
import { n as ident } from "./codegen-B8EhLmbU.js";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
//#region src/utils/validation.ts
|
|
@@ -207,4 +207,4 @@ function postprocessPlugin() {
|
|
|
207
207
|
//#endregion
|
|
208
208
|
export { createCore as n, ValidationError as r, _Defaults as t };
|
|
209
209
|
|
|
210
|
-
//# sourceMappingURL=core-
|
|
210
|
+
//# sourceMappingURL=core-B0lF760L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-BluWnx7f.js","names":[],"sources":["../src/utils/validation.ts","../src/core.ts"],"sourcesContent":["import type { CollectionSchema } from '@/config';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nexport class ValidationError extends Error {\n title: string;\n issues: readonly StandardSchemaV1.Issue[];\n\n constructor(message: string, issues: readonly StandardSchemaV1.Issue[]) {\n super(`${message}:\\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join('\\n')}`);\n\n this.title = message;\n this.issues = issues;\n }\n\n async toStringFormatted() {\n // Handle ESM/CJS interop: picocolors is a CJS module that exports via\n // module.exports = createColors(). When dynamically imported in ESM context\n // (e.g., Next.js 16 Turbopack), the exports are wrapped under .default\n const picocolorsModule = await import('picocolors');\n const picocolors = picocolorsModule.default ?? picocolorsModule;\n\n return [\n picocolors.bold(`[MDX] ${this.title}:`),\n ...this.issues.map((issue) =>\n picocolors.redBright(\n `- ${picocolors.bold(issue.path?.join('.') ?? '*')}: ${issue.message}`,\n ),\n ),\n ].join('\\n');\n }\n}\n\nexport async function validate<Schema extends StandardSchemaV1, Context>(\n schema: CollectionSchema<Schema, Context>,\n data: unknown,\n context: Context,\n errorMessage: string,\n): Promise<StandardSchemaV1.InferOutput<Schema>> {\n if (typeof schema === 'function' && !('~standard' in schema)) {\n schema = schema(context);\n }\n\n if ('~standard' in schema) {\n const result = await (schema as StandardSchemaV1)['~standard'].validate(data);\n\n if (result.issues) {\n throw new ValidationError(errorMessage, result.issues);\n }\n\n return result.value;\n }\n\n return data;\n}\n","import type {\n CollectionItem,\n DocCollectionItem,\n LoadedConfig,\n MetaCollectionItem,\n} from '@/config/build';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport type { FSWatcher } from 'chokidar';\nimport { validate } from './utils/validation';\nimport type { VFile } from 'vfile';\nimport type { IndexFilePlugin } from './plugins/index-file';\nimport type { PostprocessOptions } from './config';\nimport { ident } from './utils/codegen';\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface EmitEntry {\n /**\n * path relative to output directory\n */\n path: string;\n content: string;\n}\n\nexport interface PluginContext {\n core: Core;\n}\n\nexport type CompilationContext<Collection> = PluginContext & TransformOptions<Collection>;\n\nexport interface TransformOptions<Collection> {\n collection: Collection;\n filePath: string;\n source: string;\n}\n\nexport interface Plugin extends IndexFilePlugin {\n name?: string;\n\n /**\n * on config loaded/updated\n */\n config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;\n\n /**\n * Generate files (e.g. types, index file, or JSON schemas)\n */\n emit?: (this: PluginContext) => Awaitable<EmitEntry[]>;\n\n /**\n * Configure Fumadocs dev server\n */\n configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;\n\n meta?: {\n /**\n * Transform metadata\n */\n transform?: (\n this: CompilationContext<MetaCollectionItem>,\n data: unknown,\n ) => Awaitable<unknown | void>;\n };\n\n doc?: {\n /**\n * Transform frontmatter\n */\n frontmatter?: (\n this: CompilationContext<DocCollectionItem>,\n data: Record<string, unknown>,\n ) => Awaitable<Record<string, unknown> | void>;\n\n /**\n * Transform `vfile` on compilation stage\n */\n vfile?: (this: CompilationContext<DocCollectionItem>, file: VFile) => Awaitable<VFile | void>;\n };\n}\n\nexport type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;\n\nexport interface ServerContext {\n /**\n * the file watcher, by default all content files are watched, along with other files.\n *\n * make sure to filter when listening to events\n */\n watcher?: FSWatcher;\n}\n\nexport interface CoreOptions {\n environment: string;\n configPath: string;\n outDir: string;\n plugins?: PluginOption[];\n\n /**\n * the workspace info if this instance is created as a workspace\n */\n workspace?: {\n parent: Core;\n name: string;\n dir: string;\n };\n}\n\nexport interface EmitOptions {\n /**\n * filter the plugins to run emit\n */\n filterPlugin?: (plugin: Plugin) => boolean;\n\n /**\n * filter the workspaces to run emit\n */\n filterWorkspace?: (workspace: string) => boolean;\n\n /**\n * write files\n */\n write?: boolean;\n}\n\nexport interface EmitOutput {\n entries: EmitEntry[];\n workspaces: Record<string, EmitEntry[]>;\n}\n\nexport const _Defaults = {\n configPath: 'source.config.ts',\n outDir: '.source',\n};\n\nasync function getPlugins(pluginOptions: PluginOption[]): Promise<Plugin[]> {\n const plugins: Plugin[] = [];\n\n for await (const option of pluginOptions) {\n if (!option) continue;\n if (Array.isArray(option)) plugins.push(...(await getPlugins(option)));\n else plugins.push(option);\n }\n\n return plugins;\n}\n\nexport function createCore(options: CoreOptions) {\n let config: LoadedConfig;\n let plugins: Plugin[];\n const workspaces = new Map<string, Core>();\n\n async function transformMetadata<T>(\n { collection, filePath, source }: TransformOptions<DocCollectionItem | MetaCollectionItem>,\n data: unknown,\n ): Promise<T> {\n if (collection.schema) {\n data = await validate(\n collection.schema,\n data,\n { path: filePath, source },\n collection.type === 'doc'\n ? `invalid frontmatter in ${filePath}`\n : `invalid data in ${filePath}`,\n );\n }\n\n return data as T;\n }\n\n return {\n /**\n * Convenient cache store, reset when config changes\n */\n cache: new Map<string, unknown>(),\n async init({ config: newConfig }: { config: Awaitable<LoadedConfig> }) {\n config = await newConfig;\n this.cache.clear();\n workspaces.clear();\n plugins = await getPlugins([postprocessPlugin(), options.plugins, config.global.plugins]);\n\n for (const plugin of plugins) {\n const out = await plugin.config?.call(this.getPluginContext(), config);\n if (out) config = out;\n }\n\n // only support workspaces with max depth 1\n if (!options.workspace) {\n await Promise.all(\n Object.entries(config.workspaces).map(async ([name, workspace]) => {\n const core = createCore({\n ...options,\n outDir: path.join(options.outDir, name),\n workspace: {\n name,\n parent: this,\n dir: workspace.dir,\n },\n });\n await core.init({ config: workspace.config });\n workspaces.set(name, core);\n }),\n );\n }\n },\n getWorkspaces() {\n return workspaces;\n },\n getOptions() {\n return options;\n },\n getConfig(): LoadedConfig {\n return config;\n },\n /**\n * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)\n */\n getCompiledConfigPath(): string {\n return path.join(options.outDir, 'source.config.mjs');\n },\n getPlugins() {\n return plugins;\n },\n getCollections(): CollectionItem[] {\n return Array.from(config.collections.values());\n },\n getCollection(name: string): CollectionItem | undefined {\n return config.collections.get(name);\n },\n getPluginContext(): PluginContext {\n return {\n core: this,\n };\n },\n async initServer(server: ServerContext): Promise<void> {\n const ctx = this.getPluginContext();\n for (const plugin of plugins) {\n await plugin.configureServer?.call(ctx, server);\n }\n for (const workspace of workspaces.values()) {\n await workspace.initServer(server);\n }\n },\n async emit(emitOptions: EmitOptions = {}): Promise<EmitOutput> {\n const { filterPlugin, filterWorkspace, write = false } = emitOptions;\n const start = performance.now();\n const ctx = this.getPluginContext();\n const added = new Set<string>();\n const out: EmitOutput = {\n entries: [],\n workspaces: {},\n };\n\n for (const li of await Promise.all(\n plugins.map((plugin) => {\n if ((filterPlugin && !filterPlugin(plugin)) || !plugin.emit) return;\n return plugin.emit.call(ctx);\n }),\n )) {\n if (!li) continue;\n for (const item of li) {\n if (added.has(item.path)) continue;\n out.entries.push(item);\n added.add(item.path);\n }\n }\n\n if (write) {\n await Promise.all(\n out.entries.map(async (entry) => {\n const file = path.join(options.outDir, entry.path);\n\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, entry.content);\n }),\n );\n\n console.log(\n options.workspace\n ? `[MDX: ${options.workspace.name}] generated files in ${performance.now() - start}ms`\n : `[MDX] generated files in ${performance.now() - start}ms`,\n );\n }\n\n for (const [name, workspace] of workspaces) {\n if (filterWorkspace && !filterWorkspace(name)) continue;\n out.workspaces[name] = (await workspace.emit(emitOptions)).entries;\n }\n\n return out;\n },\n async transformMeta(\n options: TransformOptions<MetaCollectionItem>,\n data: unknown,\n ): Promise<unknown> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n data = await transformMetadata(options, data);\n for (const plugin of plugins) {\n if (plugin.meta?.transform) data = (await plugin.meta.transform.call(ctx, data)) ?? data;\n }\n\n return data;\n },\n async transformFrontmatter(\n options: TransformOptions<DocCollectionItem>,\n data: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n data = await transformMetadata(options, data);\n for (const plugin of plugins) {\n if (plugin.doc?.frontmatter) data = (await plugin.doc.frontmatter.call(ctx, data)) ?? data;\n }\n\n return data;\n },\n async transformVFile(\n options: TransformOptions<DocCollectionItem>,\n file: VFile,\n ): Promise<VFile> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n for (const plugin of plugins) {\n if (plugin.doc?.vfile) file = (await plugin.doc.vfile.call(ctx, file)) ?? file;\n }\n\n return file;\n },\n };\n}\n\nfunction postprocessPlugin(): Plugin {\n const LinkReferenceTypes = `{\n /**\n * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.\n */\n extractedReferences: import(\"fumadocs-mdx\").ExtractedReference[];\n}`;\n\n return {\n 'index-file': {\n generateTypeConfig() {\n const lines: string[] = [];\n lines.push('{');\n lines.push(' DocData: {');\n for (const collection of this.core.getCollections()) {\n let postprocessOptions: Partial<PostprocessOptions> | undefined;\n switch (collection.type) {\n case 'doc':\n postprocessOptions = collection.postprocess;\n break;\n case 'docs':\n postprocessOptions = collection.docs.postprocess;\n break;\n }\n\n if (postprocessOptions?.extractLinkReferences) {\n lines.push(ident(`${collection.name}: ${LinkReferenceTypes},`, 2));\n }\n }\n lines.push(' }');\n lines.push('}');\n return lines.join('\\n');\n },\n serverOptions(options) {\n options.doc ??= {};\n options.doc.passthroughs ??= [];\n options.doc.passthroughs.push('extractedReferences');\n },\n },\n };\n}\n\nexport type Core = ReturnType<typeof createCore>;\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAIzC,YAAY,SAAiB,QAA2C;AACtE,QAAM,GAAG,QAAQ,KAAK,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,GAAG;AAE9F,OAAK,QAAQ;AACb,OAAK,SAAS;;CAGhB,MAAM,oBAAoB;EAIxB,MAAM,mBAAmB,MAAM,OAAO;EACtC,MAAM,aAAa,iBAAiB,WAAW;AAE/C,SAAO,CACL,WAAW,KAAK,SAAS,KAAK,MAAM,GAAG,EACvC,GAAG,KAAK,OAAO,KAAK,UAClB,WAAW,UACT,KAAK,WAAW,KAAK,MAAM,MAAM,KAAK,IAAI,IAAI,I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KAAK,YAAa,QAAQ,MAAM,OAAO,IAAI,YAAY,KAAK,KAAK,KAAK,IAAK;AAGxF,UAAO;;EAET,MAAM,eACJ,SACA,MACgB;GAChB,MAAM,MAAM;IACV,GAAG,KAAK,kBAAkB;IAC1B,GAAG;IACJ;AAED,QAAK,MAAM,UAAU,QACnB,KAAI,OAAO,KAAK,MAAO,QAAQ,MAAM,OAAO,IAAI,MAAM,KAAK,KAAK,KAAK,IAAK;AAG5E,UAAO;;EAEV;;AAGH,SAAS,oBAA4B;CACnC,MAAM,qBAAqB;;;;;;AAO3B,QAAO,EACL,cAAc;EACZ,qBAAqB;GACnB,MAAM,QAAkB,EAAE;AAC1B,SAAM,KAAK,IAAI;AACf,SAAM,KAAK,eAAe;AAC1B,QAAK,MAAM,cAAc,KAAK,KAAK,gBAAgB,EAAE;IACnD,IAAI;AACJ,YAAQ,WAAW,MAAnB;KACE,KAAK;AACH,2BAAqB,WAAW;AAChC;KACF,KAAK;AACH,2BAAqB,WAAW,KAAK;AACrC;;AAGJ,QAAI,oBAAoB,sBACtB,OAAM,KAAK,MAAM,GAAG,WAAW,KAAK,IAAI,mBAAmB,IAAI,EAAE,CAAC;;AAGtE,SAAM,KAAK,MAAM;AACjB,SAAM,KAAK,IAAI;AACf,UAAO,MAAM,KAAK,KAAK;;EAEzB,cAAc,SAAS;AACrB,WAAQ,QAAQ,EAAE;AAClB,WAAQ,IAAI,iBAAiB,EAAE;AAC/B,WAAQ,IAAI,aAAa,KAAK,sBAAsB;;EAEvD,EACF"}
|
|
1
|
+
{"version":3,"file":"core-B0lF760L.js","names":[],"sources":["../src/utils/validation.ts","../src/core.ts"],"sourcesContent":["import type { CollectionSchema } from '@/config';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nexport class ValidationError extends Error {\n title: string;\n issues: readonly StandardSchemaV1.Issue[];\n\n constructor(message: string, issues: readonly StandardSchemaV1.Issue[]) {\n super(`${message}:\\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join('\\n')}`);\n\n this.title = message;\n this.issues = issues;\n }\n\n async toStringFormatted() {\n // Handle ESM/CJS interop: picocolors is a CJS module that exports via\n // module.exports = createColors(). When dynamically imported in ESM context\n // (e.g., Next.js 16 Turbopack), the exports are wrapped under .default\n const picocolorsModule = await import('picocolors');\n const picocolors = picocolorsModule.default ?? picocolorsModule;\n\n return [\n picocolors.bold(`[MDX] ${this.title}:`),\n ...this.issues.map((issue) =>\n picocolors.redBright(\n `- ${picocolors.bold(issue.path?.join('.') ?? '*')}: ${issue.message}`,\n ),\n ),\n ].join('\\n');\n }\n}\n\nexport async function validate<Schema extends StandardSchemaV1, Context>(\n schema: CollectionSchema<Schema, Context>,\n data: unknown,\n context: Context,\n errorMessage: string,\n): Promise<StandardSchemaV1.InferOutput<Schema>> {\n if (typeof schema === 'function' && !('~standard' in schema)) {\n schema = schema(context);\n }\n\n if ('~standard' in schema) {\n const result = await (schema as StandardSchemaV1)['~standard'].validate(data);\n\n if (result.issues) {\n throw new ValidationError(errorMessage, result.issues);\n }\n\n return result.value;\n }\n\n return data;\n}\n","import type {\n CollectionItem,\n DocCollectionItem,\n LoadedConfig,\n MetaCollectionItem,\n} from '@/config/build';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport type { FSWatcher } from 'chokidar';\nimport { validate } from './utils/validation';\nimport type { VFile } from 'vfile';\nimport type { IndexFilePlugin } from './plugins/index-file';\nimport type { PostprocessOptions } from './config';\nimport { ident } from './utils/codegen';\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface EmitEntry {\n /**\n * path relative to output directory\n */\n path: string;\n content: string;\n}\n\nexport interface PluginContext {\n core: Core;\n}\n\nexport type CompilationContext<Collection> = PluginContext & TransformOptions<Collection>;\n\nexport interface TransformOptions<Collection> {\n collection: Collection;\n filePath: string;\n source: string;\n}\n\nexport interface Plugin extends IndexFilePlugin {\n name?: string;\n\n /**\n * on config loaded/updated\n */\n config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;\n\n /**\n * Generate files (e.g. types, index file, or JSON schemas)\n */\n emit?: (this: PluginContext) => Awaitable<EmitEntry[]>;\n\n /**\n * Configure Fumadocs dev server\n */\n configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;\n\n meta?: {\n /**\n * Transform metadata\n */\n transform?: (\n this: CompilationContext<MetaCollectionItem>,\n data: unknown,\n ) => Awaitable<unknown | void>;\n };\n\n doc?: {\n /**\n * Transform frontmatter\n */\n frontmatter?: (\n this: CompilationContext<DocCollectionItem>,\n data: Record<string, unknown>,\n ) => Awaitable<Record<string, unknown> | void>;\n\n /**\n * Transform `vfile` on compilation stage\n */\n vfile?: (this: CompilationContext<DocCollectionItem>, file: VFile) => Awaitable<VFile | void>;\n };\n}\n\nexport type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;\n\nexport interface ServerContext {\n /**\n * the file watcher, by default all content files are watched, along with other files.\n *\n * make sure to filter when listening to events\n */\n watcher?: FSWatcher;\n}\n\nexport interface CoreOptions {\n environment: string;\n configPath: string;\n outDir: string;\n plugins?: PluginOption[];\n\n /**\n * the workspace info if this instance is created as a workspace\n */\n workspace?: {\n parent: Core;\n name: string;\n dir: string;\n };\n}\n\nexport interface EmitOptions {\n /**\n * filter the plugins to run emit\n */\n filterPlugin?: (plugin: Plugin) => boolean;\n\n /**\n * filter the workspaces to run emit\n */\n filterWorkspace?: (workspace: string) => boolean;\n\n /**\n * write files\n */\n write?: boolean;\n}\n\nexport interface EmitOutput {\n entries: EmitEntry[];\n workspaces: Record<string, EmitEntry[]>;\n}\n\nexport const _Defaults = {\n configPath: 'source.config.ts',\n outDir: '.source',\n};\n\nasync function getPlugins(pluginOptions: PluginOption[]): Promise<Plugin[]> {\n const plugins: Plugin[] = [];\n\n for await (const option of pluginOptions) {\n if (!option) continue;\n if (Array.isArray(option)) plugins.push(...(await getPlugins(option)));\n else plugins.push(option);\n }\n\n return plugins;\n}\n\nexport function createCore(options: CoreOptions) {\n let config: LoadedConfig;\n let plugins: Plugin[];\n const workspaces = new Map<string, Core>();\n\n async function transformMetadata<T>(\n { collection, filePath, source }: TransformOptions<DocCollectionItem | MetaCollectionItem>,\n data: unknown,\n ): Promise<T> {\n if (collection.schema) {\n data = await validate(\n collection.schema,\n data,\n { path: filePath, source },\n collection.type === 'doc'\n ? `invalid frontmatter in ${filePath}`\n : `invalid data in ${filePath}`,\n );\n }\n\n return data as T;\n }\n\n return {\n /**\n * Convenient cache store, reset when config changes\n */\n cache: new Map<string, unknown>(),\n async init({ config: newConfig }: { config: Awaitable<LoadedConfig> }) {\n config = await newConfig;\n this.cache.clear();\n workspaces.clear();\n plugins = await getPlugins([postprocessPlugin(), options.plugins, config.global.plugins]);\n\n for (const plugin of plugins) {\n const out = await plugin.config?.call(this.getPluginContext(), config);\n if (out) config = out;\n }\n\n // only support workspaces with max depth 1\n if (!options.workspace) {\n await Promise.all(\n Object.entries(config.workspaces).map(async ([name, workspace]) => {\n const core = createCore({\n ...options,\n outDir: path.join(options.outDir, name),\n workspace: {\n name,\n parent: this,\n dir: workspace.dir,\n },\n });\n await core.init({ config: workspace.config });\n workspaces.set(name, core);\n }),\n );\n }\n },\n getWorkspaces() {\n return workspaces;\n },\n getOptions() {\n return options;\n },\n getConfig(): LoadedConfig {\n return config;\n },\n /**\n * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)\n */\n getCompiledConfigPath(): string {\n return path.join(options.outDir, 'source.config.mjs');\n },\n getPlugins() {\n return plugins;\n },\n getCollections(): CollectionItem[] {\n return Array.from(config.collections.values());\n },\n getCollection(name: string): CollectionItem | undefined {\n return config.collections.get(name);\n },\n getPluginContext(): PluginContext {\n return {\n core: this,\n };\n },\n async initServer(server: ServerContext): Promise<void> {\n const ctx = this.getPluginContext();\n for (const plugin of plugins) {\n await plugin.configureServer?.call(ctx, server);\n }\n for (const workspace of workspaces.values()) {\n await workspace.initServer(server);\n }\n },\n async emit(emitOptions: EmitOptions = {}): Promise<EmitOutput> {\n const { filterPlugin, filterWorkspace, write = false } = emitOptions;\n const start = performance.now();\n const ctx = this.getPluginContext();\n const added = new Set<string>();\n const out: EmitOutput = {\n entries: [],\n workspaces: {},\n };\n\n for (const li of await Promise.all(\n plugins.map((plugin) => {\n if ((filterPlugin && !filterPlugin(plugin)) || !plugin.emit) return;\n return plugin.emit.call(ctx);\n }),\n )) {\n if (!li) continue;\n for (const item of li) {\n if (added.has(item.path)) continue;\n out.entries.push(item);\n added.add(item.path);\n }\n }\n\n if (write) {\n await Promise.all(\n out.entries.map(async (entry) => {\n const file = path.join(options.outDir, entry.path);\n\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, entry.content);\n }),\n );\n\n console.log(\n options.workspace\n ? `[MDX: ${options.workspace.name}] generated files in ${performance.now() - start}ms`\n : `[MDX] generated files in ${performance.now() - start}ms`,\n );\n }\n\n for (const [name, workspace] of workspaces) {\n if (filterWorkspace && !filterWorkspace(name)) continue;\n out.workspaces[name] = (await workspace.emit(emitOptions)).entries;\n }\n\n return out;\n },\n async transformMeta(\n options: TransformOptions<MetaCollectionItem>,\n data: unknown,\n ): Promise<unknown> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n data = await transformMetadata(options, data);\n for (const plugin of plugins) {\n if (plugin.meta?.transform) data = (await plugin.meta.transform.call(ctx, data)) ?? data;\n }\n\n return data;\n },\n async transformFrontmatter(\n options: TransformOptions<DocCollectionItem>,\n data: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n data = await transformMetadata(options, data);\n for (const plugin of plugins) {\n if (plugin.doc?.frontmatter) data = (await plugin.doc.frontmatter.call(ctx, data)) ?? data;\n }\n\n return data;\n },\n async transformVFile(\n options: TransformOptions<DocCollectionItem>,\n file: VFile,\n ): Promise<VFile> {\n const ctx = {\n ...this.getPluginContext(),\n ...options,\n };\n\n for (const plugin of plugins) {\n if (plugin.doc?.vfile) file = (await plugin.doc.vfile.call(ctx, file)) ?? file;\n }\n\n return file;\n },\n };\n}\n\nfunction postprocessPlugin(): Plugin {\n const LinkReferenceTypes = `{\n /**\n * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.\n */\n extractedReferences: import(\"fumadocs-mdx\").ExtractedReference[];\n}`;\n\n return {\n 'index-file': {\n generateTypeConfig() {\n const lines: string[] = [];\n lines.push('{');\n lines.push(' DocData: {');\n for (const collection of this.core.getCollections()) {\n let postprocessOptions: Partial<PostprocessOptions> | undefined;\n switch (collection.type) {\n case 'doc':\n postprocessOptions = collection.postprocess;\n break;\n case 'docs':\n postprocessOptions = collection.docs.postprocess;\n break;\n }\n\n if (postprocessOptions?.extractLinkReferences) {\n lines.push(ident(`${collection.name}: ${LinkReferenceTypes},`, 2));\n }\n }\n lines.push(' }');\n lines.push('}');\n return lines.join('\\n');\n },\n serverOptions(options) {\n options.doc ??= {};\n options.doc.passthroughs ??= [];\n options.doc.passthroughs.push('extractedReferences');\n },\n },\n };\n}\n\nexport type Core = ReturnType<typeof createCore>;\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAIzC,YAAY,SAAiB,QAA2C;AACtE,QAAM,GAAG,QAAQ,KAAK,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,GAAG;AAE9F,OAAK,QAAQ;AACb,OAAK,SAAS;;CAGhB,MAAM,oBAAoB;EAIxB,MAAM,mBAAmB,MAAM,OAAO;EACtC,MAAM,aAAa,iBAAiB,WAAW;AAE/C,SAAO,CACL,WAAW,KAAK,SAAS,KAAK,MAAM,GAAG,EACvC,GAAG,KAAK,OAAO,KAAK,UAClB,WAAW,UACT,KAAK,WAAW,KAAK,MAAM,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM,UAC9D,CACF,CACF,CAAC,KAAK,KAAK;;;AAIhB,eAAsB,SACpB,QACA,MACA,SACA,cAC+C;AAC/C,KAAI,OAAO,WAAW,cAAc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GAAG,KAAK,kBAAkB;IAC1B,GAAG;IACJ;AAED,QAAK,MAAM,UAAU,QACnB,KAAI,OAAO,KAAK,MAAO,QAAQ,MAAM,OAAO,IAAI,MAAM,KAAK,KAAK,KAAK,IAAK;AAG5E,UAAO;;EAEV;;AAGH,SAAS,oBAA4B;CACnC,MAAM,qBAAqB;;;;;;AAO3B,QAAO,EACL,cAAc;EACZ,qBAAqB;GACnB,MAAM,QAAkB,EAAE;AAC1B,SAAM,KAAK,IAAI;AACf,SAAM,KAAK,eAAe;AAC1B,QAAK,MAAM,cAAc,KAAK,KAAK,gBAAgB,EAAE;IACnD,IAAI;AACJ,YAAQ,WAAW,MAAnB;KACE,KAAK;AACH,2BAAqB,WAAW;AAChC;KACF,KAAK;AACH,2BAAqB,WAAW,KAAK;AACrC;;AAGJ,QAAI,oBAAoB,sBACtB,OAAM,KAAK,MAAM,GAAG,WAAW,KAAK,IAAI,mBAAmB,IAAI,EAAE,CAAC;;AAGtE,SAAM,KAAK,MAAM;AACjB,SAAM,KAAK,IAAI;AACf,UAAO,MAAM,KAAK,KAAK;;EAEzB,cAAc,SAAS;AACrB,WAAQ,QAAQ,EAAE;AAClB,WAAQ,IAAI,iBAAiB,EAAE;AAC/B,WAAQ,IAAI,aAAa,KAAK,sBAAsB;;EAEvD,EACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, t as DocData } from "./types-
|
|
1
|
+
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, t as DocData } from "./types-hAduruLB.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Pluggable, Processor, Transformer } from "unified";
|
|
4
4
|
import * as Plugins from "fumadocs-core/mdx-plugins";
|
|
@@ -382,4 +382,4 @@ declare function createCore(options: CoreOptions): {
|
|
|
382
382
|
type Core = ReturnType<typeof createCore>;
|
|
383
383
|
//#endregion
|
|
384
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 };
|
|
385
|
-
//# sourceMappingURL=core-
|
|
385
|
+
//# sourceMappingURL=core-DzcubDJt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-
|
|
1
|
+
{"version":3,"file":"core-DzcubDJt.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,iBAA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,MAAA,EAAQ,IAAA;IACR,IAAA;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BIbaPT3v.d.ts","names":[],"sources":["../src/webpack/index.ts"],"mappings":";UAEiB,oBAAA;EACf,0BAAA;EACA,UAAA;EACA,MAAA;EACA,KAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { n as ident, r as slash, t as createCodegen } from "./codegen-B8EhLmbU.js";
|
|
2
|
+
import { frontmatter } from "fumadocs-core/content/md/frontmatter";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { glob } from "tinyglobby";
|
|
@@ -156,7 +156,7 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
156
156
|
async function generateCollectionObjectEntry(collection, absolutePath) {
|
|
157
157
|
const fullPath = path$1.relative(process.cwd(), absolutePath);
|
|
158
158
|
const content = await indexFileCache.read(fullPath).catch(() => "");
|
|
159
|
-
const parsed =
|
|
159
|
+
const parsed = frontmatter(content);
|
|
160
160
|
const data = await core.transformFrontmatter({
|
|
161
161
|
collection,
|
|
162
162
|
filePath: fullPath,
|
|
@@ -261,4 +261,4 @@ function generateMetaCollectionGlob({ codegen, workspace }, collection, eager =
|
|
|
261
261
|
//#endregion
|
|
262
262
|
export { indexFile as t };
|
|
263
263
|
|
|
264
|
-
//# sourceMappingURL=index-file-
|
|
264
|
+
//# sourceMappingURL=index-file-eVlUbKSO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-file-eVlUbKSO.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 { frontmatter } from 'fumadocs-core/content/md/frontmatter';\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 = frontmatter(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,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KAAK,MAAM,qCAAqC;;AAGhE,SAAS,QAAQ,YAA4B;AAC3C,QAAO,MAAMA,OAAK,SAAS,QAAQ,KAAK,EAAE,WAAW,IAAI,CAAC;;AAG5D,SAAS,qCACP,EAAE,SAAS,aACX,YACA,QAAQ,OACR;AACA,QAAO,QAAQ,mBAAmB,WAAW,UAAU;EACrD,OAAO;GACL,YAAY,WAAW;GACvB,MAAM;GACN;GACD;EACD,QAAQ;EACR,MAAM,WAAW;EACjB;EACD,CAAC;;AAGJ,SAAS,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-
|
|
2
|
-
import { t as CompiledMDXProperties } from "./build-mdx-
|
|
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-DzcubDJt.js";
|
|
2
|
+
import { t as CompiledMDXProperties } from "./build-mdx-YyRh-ZGV.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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
-
import { t as buildConfig } from "./build-
|
|
2
|
+
import { t as buildConfig } from "./build-DPafU2lu.js";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
//#region src/config/load-from-file.ts
|
|
5
5
|
var load_from_file_exports = /* @__PURE__ */ __exportAll({ loadConfig: () => loadConfig });
|
|
@@ -36,4 +36,4 @@ async function loadConfig(core, build = false) {
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { load_from_file_exports as n, loadConfig as t };
|
|
38
38
|
|
|
39
|
-
//# sourceMappingURL=load-from-file-
|
|
39
|
+
//# sourceMappingURL=load-from-file-C1DDNVwF.js.map
|