fumadocs-mdx 14.2.3 → 14.2.4

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.
Files changed (116) hide show
  1. package/dist/adapter-DG-viEbG.js +144 -0
  2. package/dist/adapter-DG-viEbG.js.map +1 -0
  3. package/dist/bin.d.ts +1 -1
  4. package/dist/bin.js +21 -12
  5. package/dist/bin.js.map +1 -0
  6. package/dist/build-BTTNEFmV.js +100 -0
  7. package/dist/build-BTTNEFmV.js.map +1 -0
  8. package/dist/build-mdx-10MrLupc.d.ts +53 -0
  9. package/dist/build-mdx-10MrLupc.d.ts.map +1 -0
  10. package/dist/build-mdx-BVeBo4jT.js +153 -0
  11. package/dist/build-mdx-BVeBo4jT.js.map +1 -0
  12. package/dist/build-mdx-ChjP7zAn.js +5 -0
  13. package/dist/bun/index.d.ts +10 -21
  14. package/dist/bun/index.d.ts.map +1 -0
  15. package/dist/bun/index.js +30 -49
  16. package/dist/bun/index.js.map +1 -0
  17. package/dist/codegen-DleOVLNr.js +101 -0
  18. package/dist/codegen-DleOVLNr.js.map +1 -0
  19. package/dist/config/index.d.ts +2 -18
  20. package/dist/config/index.js +50 -53
  21. package/dist/config/index.js.map +1 -0
  22. package/dist/core-DG43f_AU.d.ts +364 -0
  23. package/dist/core-DG43f_AU.d.ts.map +1 -0
  24. package/dist/core-DjldE3H9.js +212 -0
  25. package/dist/core-DjldE3H9.js.map +1 -0
  26. package/dist/fuma-matter-CHgJa_-B.js +27 -0
  27. package/dist/fuma-matter-CHgJa_-B.js.map +1 -0
  28. package/dist/index-Bc_4I1HE.d.ts +12 -0
  29. package/dist/index-Bc_4I1HE.d.ts.map +1 -0
  30. package/dist/index-file-D9HsrWU_.js +264 -0
  31. package/dist/index-file-D9HsrWU_.js.map +1 -0
  32. package/dist/index.d.ts +3 -61
  33. package/dist/index.js +1 -0
  34. package/dist/load-from-file-B7Rswy9i.js +5 -0
  35. package/dist/load-from-file-Doc98oEB.js +38 -0
  36. package/dist/load-from-file-Doc98oEB.js.map +1 -0
  37. package/dist/loaders-BVwYfelL.js +7 -0
  38. package/dist/loaders-BVwYfelL.js.map +1 -0
  39. package/dist/mdx-DMZ9tsAa.js +91 -0
  40. package/dist/mdx-DMZ9tsAa.js.map +1 -0
  41. package/dist/meta-DyieTM4Z.js +81 -0
  42. package/dist/meta-DyieTM4Z.js.map +1 -0
  43. package/dist/next/index.cjs +863 -1076
  44. package/dist/next/index.d.ts +17 -28
  45. package/dist/next/index.d.ts.map +1 -0
  46. package/dist/next/index.js +141 -170
  47. package/dist/next/index.js.map +1 -0
  48. package/dist/node/loader.d.ts +4 -2
  49. package/dist/node/loader.d.ts.map +1 -0
  50. package/dist/node/loader.js +26 -38
  51. package/dist/node/loader.js.map +1 -0
  52. package/dist/plugins/index-file.d.ts +2 -14
  53. package/dist/plugins/index-file.js +5 -8
  54. package/dist/plugins/json-schema.d.ts +14 -23
  55. package/dist/plugins/json-schema.d.ts.map +1 -0
  56. package/dist/plugins/json-schema.js +70 -78
  57. package/dist/plugins/json-schema.js.map +1 -0
  58. package/dist/plugins/last-modified.d.ts +21 -32
  59. package/dist/plugins/last-modified.d.ts.map +1 -0
  60. package/dist/plugins/last-modified.js +70 -78
  61. package/dist/plugins/last-modified.js.map +1 -0
  62. package/dist/preset-gmDZnBcg.js +61 -0
  63. package/dist/preset-gmDZnBcg.js.map +1 -0
  64. package/dist/remark-include-D3G3mAnv.js +247 -0
  65. package/dist/remark-include-D3G3mAnv.js.map +1 -0
  66. package/dist/runtime/browser.d.ts +32 -41
  67. package/dist/runtime/browser.d.ts.map +1 -0
  68. package/dist/runtime/browser.js +56 -63
  69. package/dist/runtime/browser.js.map +1 -0
  70. package/dist/runtime/dynamic.d.ts +13 -21
  71. package/dist/runtime/dynamic.d.ts.map +1 -0
  72. package/dist/runtime/dynamic.js +64 -76
  73. package/dist/runtime/dynamic.js.map +1 -0
  74. package/dist/runtime/server.d.ts +2 -14
  75. package/dist/runtime/server.js +111 -8
  76. package/dist/runtime/server.js.map +1 -0
  77. package/dist/runtime/types.d.ts +2 -61
  78. package/dist/runtime/types.js +1 -0
  79. package/dist/types-B6myALSk.d.ts +63 -0
  80. package/dist/types-B6myALSk.d.ts.map +1 -0
  81. package/dist/vite/index.d.ts +28 -39
  82. package/dist/vite/index.d.ts.map +1 -0
  83. package/dist/vite/index.js +79 -122
  84. package/dist/vite/index.js.map +1 -0
  85. package/dist/webpack/mdx.d.ts +6 -3
  86. package/dist/webpack/mdx.d.ts.map +1 -0
  87. package/dist/webpack/mdx.js +21 -34
  88. package/dist/webpack/mdx.js.map +1 -0
  89. package/dist/webpack/meta.d.ts +6 -3
  90. package/dist/webpack/meta.d.ts.map +1 -0
  91. package/dist/webpack/meta.js +23 -37
  92. package/dist/webpack/meta.js.map +1 -0
  93. package/dist/webpack--VSEE6Zp.js +15 -0
  94. package/dist/webpack--VSEE6Zp.js.map +1 -0
  95. package/loader-mdx.cjs +1 -3
  96. package/loader-meta.cjs +1 -3
  97. package/package.json +35 -35
  98. package/dist/build-mdx-5XLFMP5P.js +0 -8
  99. package/dist/chunk-257RZJEQ.js +0 -17
  100. package/dist/chunk-2PY3JUIC.js +0 -126
  101. package/dist/chunk-4EUH5CD2.js +0 -173
  102. package/dist/chunk-4JSFLXXT.js +0 -8
  103. package/dist/chunk-5OBUOALK.js +0 -141
  104. package/dist/chunk-DTFUANSF.js +0 -40
  105. package/dist/chunk-KWSETXYC.js +0 -274
  106. package/dist/chunk-OLD35ARB.js +0 -116
  107. package/dist/chunk-RSASAHLX.js +0 -91
  108. package/dist/chunk-S7KOJHHO.js +0 -89
  109. package/dist/chunk-STLEUNK7.js +0 -335
  110. package/dist/chunk-USQZ5OLE.js +0 -116
  111. package/dist/chunk-VWJKRQZR.js +0 -19
  112. package/dist/chunk-WFDF56IJ.js +0 -290
  113. package/dist/chunk-XYVVDDIF.js +0 -180
  114. package/dist/core-X5ggQtBM.d.ts +0 -350
  115. package/dist/index-BqkSNsGO.d.ts +0 -8
  116. package/dist/load-from-file-FHW724YY.js +0 -8
@@ -1,126 +0,0 @@
1
- // src/utils/codegen.ts
2
- import path from "path";
3
- import { glob } from "tinyglobby";
4
- function createCodegen({
5
- target = "default",
6
- outDir = "",
7
- jsExtension = false,
8
- globCache = /* @__PURE__ */ new Map()
9
- }) {
10
- let eagerImportId = 0;
11
- const banner = ["// @ts-nocheck"];
12
- if (target === "vite") {
13
- banner.push('/// <reference types="vite/client" />');
14
- }
15
- return {
16
- options: {
17
- target,
18
- outDir
19
- },
20
- lines: [],
21
- addImport(statement) {
22
- this.lines.unshift(statement);
23
- },
24
- async pushAsync(insert) {
25
- for (const line of await Promise.all(insert)) {
26
- if (line === void 0) continue;
27
- this.lines.push(line);
28
- }
29
- },
30
- async generateGlobImport(patterns, options) {
31
- if (target === "vite") {
32
- return this.generateViteGlobImport(patterns, options);
33
- }
34
- return this.generateNodeGlobImport(patterns, options);
35
- },
36
- generateViteGlobImport(patterns, { base, ...rest }) {
37
- patterns = (typeof patterns === "string" ? [patterns] : patterns).map(
38
- normalizeViteGlobPath
39
- );
40
- return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
41
- {
42
- base: normalizeViteGlobPath(path.relative(outDir, base)),
43
- ...rest
44
- },
45
- null,
46
- 2
47
- )})`;
48
- },
49
- async generateNodeGlobImport(patterns, {
50
- base,
51
- eager = false,
52
- query = {},
53
- import: importName
54
- }) {
55
- const cacheKey = JSON.stringify({ patterns, base });
56
- let files = globCache.get(cacheKey);
57
- if (!files) {
58
- files = glob(patterns, {
59
- cwd: base
60
- });
61
- globCache.set(cacheKey, files);
62
- }
63
- let code = "{";
64
- for (const item of await files) {
65
- const fullPath = path.join(base, item);
66
- const searchParams = new URLSearchParams();
67
- for (const [k, v] of Object.entries(query)) {
68
- if (v !== void 0) searchParams.set(k, v);
69
- }
70
- const importPath = this.formatImportPath(fullPath) + "?" + searchParams.toString();
71
- if (eager) {
72
- const name = `__fd_glob_${eagerImportId++}`;
73
- this.lines.unshift(
74
- importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`
75
- );
76
- code += `${JSON.stringify(item)}: ${name}, `;
77
- } else {
78
- let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
79
- if (importName) {
80
- line += `.then(mod => mod.${importName})`;
81
- }
82
- code += `${line}, `;
83
- }
84
- }
85
- code += "}";
86
- return code;
87
- },
88
- formatImportPath(file) {
89
- const ext = path.extname(file);
90
- let filename;
91
- if (ext === ".ts") {
92
- filename = file.substring(0, file.length - ext.length);
93
- if (jsExtension) filename += ".js";
94
- } else {
95
- filename = file;
96
- }
97
- const importPath = slash(path.relative(outDir, filename));
98
- return importPath.startsWith(".") ? importPath : `./${importPath}`;
99
- },
100
- toString() {
101
- return [...banner, ...this.lines].join("\n");
102
- }
103
- };
104
- }
105
- function normalizeViteGlobPath(file) {
106
- file = slash(file);
107
- if (file.startsWith("./")) return file;
108
- if (file.startsWith("/")) return `.${file}`;
109
- return `./${file}`;
110
- }
111
- function slash(path2) {
112
- const isExtendedLengthPath = path2.startsWith("\\\\?\\");
113
- if (isExtendedLengthPath) {
114
- return path2;
115
- }
116
- return path2.replaceAll("\\", "/");
117
- }
118
- function ident(code, tab = 1) {
119
- return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
120
- }
121
-
122
- export {
123
- createCodegen,
124
- slash,
125
- ident
126
- };
@@ -1,173 +0,0 @@
1
- import {
2
- flattenNode,
3
- remarkInclude
4
- } from "./chunk-WFDF56IJ.js";
5
-
6
- // src/loaders/mdx/build-mdx.ts
7
- import { createProcessor } from "@mdx-js/mdx";
8
- import { VFile } from "vfile";
9
-
10
- // src/loaders/mdx/remark-postprocess.ts
11
- import { visit } from "unist-util-visit";
12
- import { toMarkdown } from "mdast-util-to-markdown";
13
- import { valueToEstree } from "estree-util-value-to-estree";
14
- import { removePosition } from "unist-util-remove-position";
15
- import remarkMdx from "remark-mdx";
16
- function remarkPostprocess({
17
- _format,
18
- includeProcessedMarkdown = false,
19
- includeMDAST = false,
20
- extractLinkReferences = false,
21
- valueToExport = []
22
- }) {
23
- let _stringifyProcessor;
24
- const getStringifyProcessor = () => {
25
- return _stringifyProcessor ??= _format === "mdx" ? this : (
26
- // force Markdown processor to stringify MDX nodes
27
- this().use(remarkMdx).freeze()
28
- );
29
- };
30
- return (tree, file) => {
31
- const frontmatter = file.data.frontmatter ??= {};
32
- if (!frontmatter.title) {
33
- visit(tree, "heading", (node) => {
34
- if (node.depth === 1) {
35
- frontmatter.title = flattenNode(node);
36
- return false;
37
- }
38
- });
39
- }
40
- file.data["mdx-export"] ??= [];
41
- file.data["mdx-export"].push({
42
- name: "frontmatter",
43
- value: frontmatter
44
- });
45
- if (extractLinkReferences) {
46
- const urls = [];
47
- visit(tree, "link", (node) => {
48
- urls.push({
49
- href: node.url
50
- });
51
- return "skip";
52
- });
53
- file.data["mdx-export"].push({
54
- name: "extractedReferences",
55
- value: urls
56
- });
57
- }
58
- if (includeProcessedMarkdown) {
59
- const processor = getStringifyProcessor();
60
- const markdown = toMarkdown(tree, {
61
- ...processor.data("settings"),
62
- // from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
63
- extensions: processor.data("toMarkdownExtensions") || []
64
- });
65
- file.data["mdx-export"].push({
66
- name: "_markdown",
67
- value: markdown
68
- });
69
- }
70
- if (includeMDAST) {
71
- const options = includeMDAST === true ? {} : includeMDAST;
72
- const mdast = JSON.stringify(
73
- options.removePosition ? removePosition(structuredClone(tree)) : tree
74
- );
75
- file.data["mdx-export"].push({
76
- name: "_mdast",
77
- value: mdast
78
- });
79
- }
80
- for (const { name, value } of file.data["mdx-export"]) {
81
- tree.children.unshift(getMdastExport(name, value));
82
- }
83
- file.data["mdx-export"] = [];
84
- for (const name of valueToExport) {
85
- if (!(name in file.data)) continue;
86
- tree.children.unshift(getMdastExport(name, file.data[name]));
87
- }
88
- };
89
- }
90
- function getMdastExport(name, value) {
91
- return {
92
- type: "mdxjsEsm",
93
- value: "",
94
- data: {
95
- estree: {
96
- type: "Program",
97
- sourceType: "module",
98
- body: [
99
- {
100
- type: "ExportNamedDeclaration",
101
- attributes: [],
102
- specifiers: [],
103
- source: null,
104
- declaration: {
105
- type: "VariableDeclaration",
106
- kind: "let",
107
- declarations: [
108
- {
109
- type: "VariableDeclarator",
110
- id: {
111
- type: "Identifier",
112
- name
113
- },
114
- init: valueToEstree(value)
115
- }
116
- ]
117
- }
118
- }
119
- ]
120
- }
121
- }
122
- };
123
- }
124
-
125
- // src/loaders/mdx/build-mdx.ts
126
- async function buildMDX(core, collection, {
127
- filePath,
128
- frontmatter,
129
- source,
130
- _compiler,
131
- environment,
132
- isDevelopment
133
- }) {
134
- const mdxOptions = await core.getConfig().getMDXOptions(collection, environment);
135
- function getProcessor(format) {
136
- const cache = core.cache;
137
- const key = `build-mdx:${collection?.name ?? "global"}:${format}`;
138
- let processor = cache.get(key);
139
- if (!processor) {
140
- const postprocessOptions = {
141
- _format: format,
142
- ...collection?.postprocess
143
- };
144
- processor = createProcessor({
145
- outputFormat: "program",
146
- development: isDevelopment,
147
- ...mdxOptions,
148
- remarkPlugins: [
149
- remarkInclude,
150
- ...mdxOptions.remarkPlugins ?? [],
151
- [remarkPostprocess, postprocessOptions]
152
- ],
153
- format
154
- });
155
- cache.set(key, processor);
156
- }
157
- return processor;
158
- }
159
- let vfile = new VFile({
160
- value: source,
161
- path: filePath,
162
- cwd: collection?.cwd,
163
- data: { frontmatter, _compiler, _getProcessor: getProcessor }
164
- });
165
- if (collection) {
166
- vfile = await core.transformVFile({ collection, filePath, source }, vfile);
167
- }
168
- return getProcessor(filePath.endsWith(".mdx") ? "mdx" : "md").process(vfile);
169
- }
170
-
171
- export {
172
- buildMDX
173
- };
@@ -1,8 +0,0 @@
1
- // src/loaders/index.ts
2
- var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
3
- var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
4
-
5
- export {
6
- metaLoaderGlob,
7
- mdxLoaderGlob
8
- };
@@ -1,141 +0,0 @@
1
- // src/runtime/server.ts
2
- import * as path from "path";
3
- function server(options = {}) {
4
- const { doc: { passthroughs: docPassthroughs = [] } = {} } = options;
5
- function fileInfo(file, base) {
6
- if (file.startsWith("./")) {
7
- file = file.slice(2);
8
- }
9
- return {
10
- path: file,
11
- fullPath: path.join(base, file)
12
- };
13
- }
14
- function mapDocData(entry) {
15
- const data = {
16
- body: entry.default,
17
- toc: entry.toc,
18
- structuredData: entry.structuredData,
19
- _exports: entry
20
- };
21
- for (const key of docPassthroughs) {
22
- data[key] = entry[key];
23
- }
24
- return data;
25
- }
26
- return {
27
- async doc(_name, base, glob) {
28
- const out = await Promise.all(
29
- Object.entries(glob).map(async ([k, v]) => {
30
- const data = typeof v === "function" ? await v() : v;
31
- return {
32
- ...mapDocData(data),
33
- ...data.frontmatter,
34
- ...createDocMethods(fileInfo(k, base), () => data)
35
- };
36
- })
37
- );
38
- return out;
39
- },
40
- async docLazy(_name, base, head, body) {
41
- const out = await Promise.all(
42
- Object.entries(head).map(async ([k, v]) => {
43
- const data = typeof v === "function" ? await v() : v;
44
- const content = body[k];
45
- return {
46
- ...data,
47
- ...createDocMethods(fileInfo(k, base), content),
48
- async load() {
49
- return mapDocData(await content());
50
- }
51
- };
52
- })
53
- );
54
- return out;
55
- },
56
- async meta(_name, base, glob) {
57
- const out = await Promise.all(
58
- Object.entries(glob).map(async ([k, v]) => {
59
- const data = typeof v === "function" ? await v() : v;
60
- return {
61
- info: fileInfo(k, base),
62
- ...data
63
- };
64
- })
65
- );
66
- return out;
67
- },
68
- async docs(name, base, metaGlob, docGlob) {
69
- const entry = {
70
- docs: await this.doc(name, base, docGlob),
71
- meta: await this.meta(name, base, metaGlob),
72
- toFumadocsSource() {
73
- return toFumadocsSource(this.docs, this.meta);
74
- }
75
- };
76
- return entry;
77
- },
78
- async docsLazy(name, base, metaGlob, docHeadGlob, docBodyGlob) {
79
- const entry = {
80
- docs: await this.docLazy(name, base, docHeadGlob, docBodyGlob),
81
- meta: await this.meta(name, base, metaGlob),
82
- toFumadocsSource() {
83
- return toFumadocsSource(this.docs, this.meta);
84
- }
85
- };
86
- return entry;
87
- }
88
- };
89
- }
90
- function toFumadocsSource(pages, metas) {
91
- const files = [];
92
- for (const entry of pages) {
93
- files.push({
94
- type: "page",
95
- path: entry.info.path,
96
- absolutePath: entry.info.fullPath,
97
- data: entry
98
- });
99
- }
100
- for (const entry of metas) {
101
- files.push({
102
- type: "meta",
103
- path: entry.info.path,
104
- absolutePath: entry.info.fullPath,
105
- data: entry
106
- });
107
- }
108
- return {
109
- files
110
- };
111
- }
112
- function createDocMethods(info, load) {
113
- return {
114
- info,
115
- async getText(type) {
116
- if (type === "raw") {
117
- const fs = await import("fs/promises");
118
- return (await fs.readFile(info.fullPath)).toString();
119
- }
120
- const data = await load();
121
- if (typeof data._markdown !== "string")
122
- throw new Error(
123
- "getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
124
- );
125
- return data._markdown;
126
- },
127
- async getMDAST() {
128
- const data = await load();
129
- if (!data._mdast)
130
- throw new Error(
131
- "getMDAST() requires `includeMDAST` to be enabled in your collection config."
132
- );
133
- return JSON.parse(data._mdast);
134
- }
135
- };
136
- }
137
-
138
- export {
139
- server,
140
- toFumadocsSource
141
- };
@@ -1,40 +0,0 @@
1
- import {
2
- buildConfig
3
- } from "./chunk-OLD35ARB.js";
4
-
5
- // src/config/load-from-file.ts
6
- import { pathToFileURL } from "url";
7
- async function compileConfig(core) {
8
- const { build } = await import("esbuild");
9
- const { configPath, outDir } = core.getOptions();
10
- const transformed = await build({
11
- entryPoints: [{ in: configPath, out: "source.config" }],
12
- bundle: true,
13
- outdir: outDir,
14
- target: "node20",
15
- write: true,
16
- platform: "node",
17
- format: "esm",
18
- packages: "external",
19
- outExtension: {
20
- ".js": ".mjs"
21
- },
22
- allowOverwrite: true
23
- });
24
- if (transformed.errors.length > 0) {
25
- throw new Error("failed to compile configuration file");
26
- }
27
- }
28
- async function loadConfig(core, build = false) {
29
- if (build) await compileConfig(core);
30
- const url = pathToFileURL(core.getCompiledConfigPath());
31
- url.searchParams.set("hash", Date.now().toString());
32
- const config = import(url.href).then(
33
- (loaded) => buildConfig(loaded)
34
- );
35
- return await config;
36
- }
37
-
38
- export {
39
- loadConfig
40
- };