fumadocs-mdx 13.0.5 → 13.0.7

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 (42) hide show
  1. package/dist/bin.cjs +162 -131
  2. package/dist/{build-mdx-BjXOmv0b.d.cts → build-mdx-BnJhW5O1.d.cts} +1 -1
  3. package/dist/{build-mdx-CY5UldCO.d.ts → build-mdx-DNzfRRlY.d.ts} +1 -1
  4. package/dist/bun/index.cjs +156 -132
  5. package/dist/bun/index.d.cts +7 -2
  6. package/dist/bun/index.d.ts +7 -2
  7. package/dist/bun/index.js +8 -11
  8. package/dist/{chunk-TZ5EQBFW.js → chunk-2AQRQXSO.js} +7 -1
  9. package/dist/chunk-2E2JCOSO.js +135 -0
  10. package/dist/chunk-4757L6ST.js +77 -0
  11. package/dist/{chunk-ZNVPB2IR.js → chunk-ETIN2W7C.js} +49 -41
  12. package/dist/config/index.d.cts +1 -1
  13. package/dist/config/index.d.ts +1 -1
  14. package/dist/{core-DB7TdlyC.d.cts → core-HkAVGq_a.d.cts} +1 -1
  15. package/dist/{core-DB7TdlyC.d.ts → core-HkAVGq_a.d.ts} +1 -1
  16. package/dist/index.d.cts +3 -3
  17. package/dist/index.d.ts +3 -3
  18. package/dist/next/index.js +2 -4
  19. package/dist/node/loader.cjs +146 -119
  20. package/dist/node/loader.js +6 -10
  21. package/dist/plugins/json-schema.d.cts +1 -1
  22. package/dist/plugins/json-schema.d.ts +1 -1
  23. package/dist/runtime/next/async.d.cts +3 -3
  24. package/dist/runtime/next/async.d.ts +3 -3
  25. package/dist/runtime/next/index.d.cts +4 -4
  26. package/dist/runtime/next/index.d.ts +4 -4
  27. package/dist/runtime/vite/browser.d.cts +2 -2
  28. package/dist/runtime/vite/browser.d.ts +2 -2
  29. package/dist/runtime/vite/server.d.cts +2 -2
  30. package/dist/runtime/vite/server.d.ts +2 -2
  31. package/dist/{types-Bnh9n7mj.d.cts → types-By6wKOnT.d.cts} +1 -1
  32. package/dist/{types-ey1AZqrg.d.ts → types-DgD5Omj2.d.ts} +1 -1
  33. package/dist/vite/index.cjs +166 -134
  34. package/dist/vite/index.js +8 -14
  35. package/dist/webpack/mdx.cjs +86 -75
  36. package/dist/webpack/mdx.js +3 -3
  37. package/dist/webpack/meta.cjs +64 -37
  38. package/dist/webpack/meta.js +3 -3
  39. package/package.json +7 -7
  40. package/dist/chunk-4JSFLXXT.js +0 -8
  41. package/dist/chunk-XYGORKQA.js +0 -130
  42. package/dist/chunk-YAIPHUCZ.js +0 -56
@@ -1,22 +1,23 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-TZ5EQBFW.js";
3
+ } from "./chunk-2AQRQXSO.js";
4
4
 
5
5
  // src/loaders/adapter.ts
6
6
  import { fileURLToPath } from "url";
7
7
  import fs from "fs/promises";
8
8
  import { parse } from "querystring";
9
9
  import path from "path";
10
- function toNode(loader, test) {
10
+ function toNode(loader) {
11
11
  return async (url, _context, nextLoad) => {
12
- if (url.startsWith("file:///") && test.test(url)) {
12
+ if (url.startsWith("file:///") && (!loader.test || loader.test.test(url))) {
13
13
  const parsedUrl = new URL(url);
14
14
  const filePath = fileURLToPath(parsedUrl);
15
- const source = (await fs.readFile(filePath)).toString();
16
- const result = await loader({
15
+ const result = await loader.load({
17
16
  filePath,
18
17
  query: Object.fromEntries(parsedUrl.searchParams.entries()),
19
- source,
18
+ async getSource() {
19
+ return (await fs.readFile(filePath)).toString();
20
+ },
20
21
  development: false,
21
22
  compiler: {
22
23
  addDependency() {
@@ -35,32 +36,42 @@ function toNode(loader, test) {
35
36
  };
36
37
  }
37
38
  function toVite(loader) {
38
- return async function(file, query, value) {
39
- const result = await loader({
40
- filePath: file,
41
- query: parse(query),
42
- source: value,
43
- development: this.environment.mode === "dev",
44
- compiler: {
45
- addDependency: (file2) => {
46
- this.addWatchFile(file2);
39
+ return {
40
+ filter(id) {
41
+ return !loader.test || loader.test.test(id);
42
+ },
43
+ async transform(value, id) {
44
+ const [file, query = ""] = id.split("?", 2);
45
+ const result = await loader.load({
46
+ filePath: file,
47
+ query: parse(query),
48
+ getSource() {
49
+ return value;
50
+ },
51
+ development: this.environment.mode === "dev",
52
+ compiler: {
53
+ addDependency: (file2) => {
54
+ this.addWatchFile(file2);
55
+ }
47
56
  }
48
- }
49
- });
50
- if (result === null) return null;
51
- return {
52
- code: result.code,
53
- map: result.map
54
- };
57
+ });
58
+ if (result === null) return null;
59
+ return {
60
+ code: result.code,
61
+ map: result.map
62
+ };
63
+ }
55
64
  };
56
65
  }
57
66
  function toWebpack(loader) {
58
67
  return async function(source, callback) {
59
68
  try {
60
- const result = await loader({
69
+ const result = await loader.load({
61
70
  filePath: this.resourcePath,
62
71
  query: parse(this.resourceQuery.slice(1)),
63
- source,
72
+ getSource() {
73
+ return source;
74
+ },
64
75
  development: this.mode === "development",
65
76
  compiler: this
66
77
  });
@@ -80,31 +91,28 @@ function toWebpack(loader) {
80
91
  }
81
92
  };
82
93
  }
83
- function toBun(loader, test) {
94
+ function toBun(loader) {
84
95
  return (build) => {
85
- const queryData = /* @__PURE__ */ new Map();
86
- build.onResolve({ filter: test }, (args) => {
96
+ build.onLoad({ filter: loader.test ?? /.+/ }, async (args) => {
87
97
  const [filePath, query = ""] = args.path.split("?", 2);
88
- queryData.set(filePath, parse(query));
89
- return null;
90
- });
91
- build.onLoad({ filter: test }, async (args) => {
92
- const content = await Bun.file(args.path).text();
93
- const result = await loader({
94
- source: content,
95
- query: queryData.get(args.path) ?? {},
96
- filePath: args.path,
98
+ const input = {
99
+ async getSource() {
100
+ return Bun.file(filePath).text();
101
+ },
102
+ query: parse(query),
103
+ filePath,
97
104
  development: false,
98
105
  compiler: {
99
106
  addDependency() {
100
107
  }
101
108
  }
102
- });
109
+ };
110
+ const result = await loader.load(input);
103
111
  if (result === null) {
104
- return {
105
- contents: content,
106
- loader: args.loader
107
- };
112
+ if (!loader.bun?.fallback) {
113
+ return;
114
+ }
115
+ return loader.bun.fallback(input);
108
116
  }
109
117
  return {
110
118
  contents: result.code,
@@ -1,4 +1,4 @@
1
- export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-DB7TdlyC.cjs';
1
+ export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-HkAVGq_a.cjs';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -1,4 +1,4 @@
1
- export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-DB7TdlyC.js';
1
+ export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-HkAVGq_a.js';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -231,4 +231,4 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
231
231
  };
232
232
  type Core = ReturnType<typeof createCore>;
233
233
 
234
- export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type CollectionSchema as a, type DocCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, defineConfig as f, getDefaultMDXOptions as g, frontmatterSchema as h, type Plugin as i, buildConfig as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type PluginOption as n, type EmitOptions as o, findConfigFile as p, createCore as q, type Core as r };
234
+ export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, type CoreOptions as h, type Plugin as i, buildConfig as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type PluginOption as n, type EmitOptions as o, findConfigFile as p, createCore as q, type Core as r };
@@ -231,4 +231,4 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
231
231
  };
232
232
  type Core = ReturnType<typeof createCore>;
233
233
 
234
- export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type CollectionSchema as a, type DocCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, defineConfig as f, getDefaultMDXOptions as g, frontmatterSchema as h, type Plugin as i, buildConfig as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type PluginOption as n, type EmitOptions as o, findConfigFile as p, createCore as q, type Core as r };
234
+ export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, type CoreOptions as h, type Plugin as i, buildConfig as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type PluginOption as n, type EmitOptions as o, findConfigFile as p, createCore as q, type Core as r };
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
2
  import { TOCItemType } from 'fumadocs-core/toc';
3
3
  import { MDXContent } from 'mdx/types';
4
- import { E as ExtractedReference } from './core-DB7TdlyC.cjs';
5
- export { r as Core, C as CoreOptions, k as EmitEntry, o as EmitOptions, i as Plugin, l as PluginContext, n as PluginOption, S as ServerContext, q as createCore, p as findConfigFile } from './core-DB7TdlyC.cjs';
4
+ import { E as ExtractedReference } from './core-HkAVGq_a.cjs';
5
+ export { r as Core, h as CoreOptions, k as EmitEntry, o as EmitOptions, i as Plugin, l as PluginContext, n as PluginOption, S as ServerContext, q as createCore, p as findConfigFile } from './core-HkAVGq_a.cjs';
6
6
  import { Root } from 'mdast';
7
- import { C as CompiledMDXProperties } from './build-mdx-BjXOmv0b.cjs';
7
+ import { C as CompiledMDXProperties } from './build-mdx-BnJhW5O1.cjs';
8
8
  import '@mdx-js/mdx';
9
9
  import '@standard-schema/spec';
10
10
  import 'unified';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
2
  import { TOCItemType } from 'fumadocs-core/toc';
3
3
  import { MDXContent } from 'mdx/types';
4
- import { E as ExtractedReference } from './core-DB7TdlyC.js';
5
- export { r as Core, C as CoreOptions, k as EmitEntry, o as EmitOptions, i as Plugin, l as PluginContext, n as PluginOption, S as ServerContext, q as createCore, p as findConfigFile } from './core-DB7TdlyC.js';
4
+ import { E as ExtractedReference } from './core-HkAVGq_a.js';
5
+ export { r as Core, h as CoreOptions, k as EmitEntry, o as EmitOptions, i as Plugin, l as PluginContext, n as PluginOption, S as ServerContext, q as createCore, p as findConfigFile } from './core-HkAVGq_a.js';
6
6
  import { Root } from 'mdast';
7
- import { C as CompiledMDXProperties } from './build-mdx-CY5UldCO.js';
7
+ import { C as CompiledMDXProperties } from './build-mdx-DNzfRRlY.js';
8
8
  import '@mdx-js/mdx';
9
9
  import '@standard-schema/spec';
10
10
  import 'unified';
@@ -6,9 +6,6 @@ import {
6
6
  toImportPath
7
7
  } from "../chunk-CXA4JO4Z.js";
8
8
  import "../chunk-2HXTGJBI.js";
9
- import {
10
- mdxLoaderGlob
11
- } from "../chunk-4JSFLXXT.js";
12
9
  import {
13
10
  getGitTimestamp
14
11
  } from "../chunk-VUEZTR2H.js";
@@ -16,8 +13,9 @@ import {
16
13
  ValidationError,
17
14
  createCore,
18
15
  findConfigFile,
16
+ mdxLoaderGlob,
19
17
  validate
20
- } from "../chunk-TZ5EQBFW.js";
18
+ } from "../chunk-2AQRQXSO.js";
21
19
  import {
22
20
  fumaMatter
23
21
  } from "../chunk-VWJKRQZR.js";
@@ -776,6 +776,12 @@ var import_zod = require("zod");
776
776
  var import_promises2 = __toESM(require("fs/promises"), 1);
777
777
  var import_node_path3 = __toESM(require("path"), 1);
778
778
  var import_node_crypto = require("crypto");
779
+
780
+ // src/loaders/index.ts
781
+ var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
782
+ var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
783
+
784
+ // src/loaders/mdx/index.ts
779
785
  var querySchema = import_zod.z.object({
780
786
  only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
781
787
  collection: import_zod.z.string().optional()
@@ -786,84 +792,88 @@ var cacheEntry = import_zod.z.object({
786
792
  hash: import_zod.z.string().optional()
787
793
  });
788
794
  function createMdxLoader(configLoader2) {
789
- return async ({
790
- source: value,
791
- development: isDevelopment,
792
- query,
793
- compiler,
794
- filePath
795
- }) => {
796
- const matter = fumaMatter(value);
797
- const parsed = querySchema.parse(query);
798
- const config = await configLoader2.getConfig();
799
- let after;
800
- if (!isDevelopment && config.global.experimentalBuildCache) {
801
- const cacheDir = config.global.experimentalBuildCache;
802
- const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
803
- const cached = await import_promises2.default.readFile(import_node_path3.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
804
- if (cached && cached.hash === generateCacheHash(value)) return cached;
805
- after = async () => {
806
- await import_promises2.default.mkdir(cacheDir, { recursive: true });
807
- await import_promises2.default.writeFile(
808
- import_node_path3.default.join(cacheDir, cacheKey),
809
- JSON.stringify({
810
- ...out,
811
- hash: generateCacheHash(value)
812
- })
795
+ return {
796
+ test: mdxLoaderGlob,
797
+ async load({
798
+ getSource,
799
+ development: isDevelopment,
800
+ query,
801
+ compiler,
802
+ filePath
803
+ }) {
804
+ const value = await getSource();
805
+ const matter = fumaMatter(value);
806
+ const parsed = querySchema.parse(query);
807
+ const config = await configLoader2.getConfig();
808
+ let after;
809
+ if (!isDevelopment && config.global.experimentalBuildCache) {
810
+ const cacheDir = config.global.experimentalBuildCache;
811
+ const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
812
+ const cached = await import_promises2.default.readFile(import_node_path3.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
813
+ if (cached && cached.hash === generateCacheHash(value)) return cached;
814
+ after = async () => {
815
+ await import_promises2.default.mkdir(cacheDir, { recursive: true });
816
+ await import_promises2.default.writeFile(
817
+ import_node_path3.default.join(cacheDir, cacheKey),
818
+ JSON.stringify({
819
+ ...out,
820
+ hash: generateCacheHash(value)
821
+ })
822
+ );
823
+ };
824
+ }
825
+ const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
826
+ let docCollection;
827
+ switch (collection?.type) {
828
+ case "doc":
829
+ docCollection = collection;
830
+ break;
831
+ case "docs":
832
+ docCollection = collection.docs;
833
+ break;
834
+ }
835
+ if (docCollection?.schema) {
836
+ matter.data = await validate(
837
+ docCollection.schema,
838
+ matter.data,
839
+ {
840
+ source: value,
841
+ path: filePath
842
+ },
843
+ `invalid frontmatter in ${filePath}`
813
844
  );
814
- };
815
- }
816
- const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
817
- let docCollection;
818
- switch (collection?.type) {
819
- case "doc":
820
- docCollection = collection;
821
- break;
822
- case "docs":
823
- docCollection = collection.docs;
824
- break;
825
- }
826
- if (docCollection?.schema) {
827
- matter.data = await validate(
828
- docCollection.schema,
829
- matter.data,
845
+ }
846
+ if (parsed.only === "frontmatter") {
847
+ return {
848
+ code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
849
+ map: null
850
+ };
851
+ }
852
+ const data = {};
853
+ if (config.global.lastModifiedTime === "git") {
854
+ data.lastModified = (await getGitTimestamp(filePath))?.getTime();
855
+ }
856
+ const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
857
+ const compiled = await buildMDX(
858
+ `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
859
+ "\n".repeat(lineOffset) + matter.content,
830
860
  {
831
- source: value,
832
- path: filePath
833
- },
834
- `invalid frontmatter in ${filePath}`
861
+ development: isDevelopment,
862
+ ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
863
+ postprocess: docCollection?.postprocess,
864
+ data,
865
+ filePath,
866
+ frontmatter: matter.data,
867
+ _compiler: compiler
868
+ }
835
869
  );
836
- }
837
- if (parsed.only === "frontmatter") {
838
- return {
839
- code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
840
- map: null
870
+ const out = {
871
+ code: String(compiled.value),
872
+ map: compiled.map
841
873
  };
874
+ await after?.();
875
+ return out;
842
876
  }
843
- const data = {};
844
- if (config.global.lastModifiedTime === "git") {
845
- data.lastModified = (await getGitTimestamp(filePath))?.getTime();
846
- }
847
- const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
848
- const compiled = await buildMDX(
849
- `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
850
- "\n".repeat(lineOffset) + matter.content,
851
- {
852
- development: isDevelopment,
853
- ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
854
- postprocess: docCollection?.postprocess,
855
- data,
856
- filePath,
857
- frontmatter: matter.data,
858
- _compiler: compiler
859
- }
860
- );
861
- const out = {
862
- code: String(compiled.value),
863
- map: compiled.map
864
- };
865
- await after?.();
866
- return out;
867
877
  };
868
878
  }
869
879
  var hashes = /* @__PURE__ */ new WeakMap();
@@ -890,16 +900,17 @@ var import_node_url = require("url");
890
900
  var import_promises3 = __toESM(require("fs/promises"), 1);
891
901
  var import_node_querystring = require("querystring");
892
902
  var import_node_path4 = __toESM(require("path"), 1);
893
- function toNode(loader, test) {
903
+ function toNode(loader) {
894
904
  return async (url, _context, nextLoad) => {
895
- if (url.startsWith("file:///") && test.test(url)) {
905
+ if (url.startsWith("file:///") && (!loader.test || loader.test.test(url))) {
896
906
  const parsedUrl = new URL(url);
897
907
  const filePath = (0, import_node_url.fileURLToPath)(parsedUrl);
898
- const source = (await import_promises3.default.readFile(filePath)).toString();
899
- const result = await loader({
908
+ const result = await loader.load({
900
909
  filePath,
901
910
  query: Object.fromEntries(parsedUrl.searchParams.entries()),
902
- source,
911
+ async getSource() {
912
+ return (await import_promises3.default.readFile(filePath)).toString();
913
+ },
903
914
  development: false,
904
915
  compiler: {
905
916
  addDependency() {
@@ -965,51 +976,67 @@ var querySchema2 = import_zod2.z.object({
965
976
  }).loose();
966
977
  function createMetaLoader(configLoader2, resolve3 = {}) {
967
978
  const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve3;
968
- return async ({ filePath, query, source }) => {
969
- const isJson = filePath.endsWith(".json");
970
- const parsed = querySchema2.parse(query);
971
- const collection = parsed.collection ? (await configLoader2.getConfig()).getCollection(parsed.collection) : void 0;
972
- if (!collection) return null;
973
- let data;
974
- try {
975
- data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
976
- } catch (e) {
977
- throw new Error(`invalid data in ${filePath}`, { cause: e });
978
- }
979
- let schema;
980
- switch (collection?.type) {
981
- case "meta":
982
- schema = collection.schema;
983
- break;
984
- case "docs":
985
- schema = collection.meta.schema;
986
- break;
987
- }
988
- if (schema) {
989
- data = await validate(
990
- schema,
991
- data,
992
- { path: filePath, source },
993
- `invalid data in ${filePath}`
994
- );
995
- }
996
- let code;
979
+ function stringifyOutput(isJson, data) {
997
980
  if (isJson) {
998
- code = resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
981
+ return resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
999
982
  } else {
1000
- code = resolveYaml === "yaml" ? (0, import_js_yaml2.dump)(data) : `export default ${JSON.stringify(data)}`;
983
+ return resolveYaml === "yaml" ? (0, import_js_yaml2.dump)(data) : `export default ${JSON.stringify(data)}`;
984
+ }
985
+ }
986
+ return {
987
+ test: metaLoaderGlob,
988
+ async load({ filePath, query, getSource }) {
989
+ const parsed = querySchema2.parse(query);
990
+ const collection = parsed.collection ? (await configLoader2.getConfig()).getCollection(parsed.collection) : void 0;
991
+ if (!collection) return null;
992
+ const isJson = filePath.endsWith(".json");
993
+ const source = await getSource();
994
+ let data;
995
+ try {
996
+ data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
997
+ } catch (e) {
998
+ throw new Error(`invalid data in ${filePath}`, { cause: e });
999
+ }
1000
+ let schema;
1001
+ switch (collection?.type) {
1002
+ case "meta":
1003
+ schema = collection.schema;
1004
+ break;
1005
+ case "docs":
1006
+ schema = collection.meta.schema;
1007
+ break;
1008
+ }
1009
+ if (schema) {
1010
+ data = await validate(
1011
+ schema,
1012
+ data,
1013
+ { path: filePath, source },
1014
+ `invalid data in ${filePath}`
1015
+ );
1016
+ }
1017
+ return {
1018
+ code: stringifyOutput(isJson, data)
1019
+ };
1020
+ },
1021
+ bun: {
1022
+ async fallback({ getSource, filePath }) {
1023
+ const source = await getSource();
1024
+ const isJson = filePath.endsWith(".json");
1025
+ let data;
1026
+ try {
1027
+ data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
1028
+ } catch (e) {
1029
+ throw new Error(`invalid data in ${filePath}`, { cause: e });
1030
+ }
1031
+ return {
1032
+ loader: "object",
1033
+ exports: data
1034
+ };
1035
+ }
1001
1036
  }
1002
- return {
1003
- code,
1004
- map: null
1005
- };
1006
1037
  };
1007
1038
  }
1008
1039
 
1009
- // src/loaders/index.ts
1010
- var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
1011
- var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
1012
-
1013
1040
  // src/node/loader.ts
1014
1041
  var core = createCore({
1015
1042
  environment: "node",
@@ -1021,8 +1048,8 @@ var configLoader = createStandaloneConfigLoader({
1021
1048
  buildConfig: true,
1022
1049
  mode: "production"
1023
1050
  });
1024
- var mdxLoader = toNode(createMdxLoader(configLoader), mdxLoaderGlob);
1025
- var metaLoader = toNode(createMetaLoader(configLoader), metaLoaderGlob);
1051
+ var mdxLoader = toNode(createMdxLoader(configLoader));
1052
+ var metaLoader = toNode(createMetaLoader(configLoader));
1026
1053
  var load3 = (url, context, nextLoad) => {
1027
1054
  return mdxLoader(
1028
1055
  url,
@@ -1,24 +1,20 @@
1
1
  import {
2
2
  createMdxLoader
3
- } from "../chunk-XYGORKQA.js";
3
+ } from "../chunk-2E2JCOSO.js";
4
4
  import {
5
5
  createMetaLoader
6
- } from "../chunk-YAIPHUCZ.js";
6
+ } from "../chunk-4757L6ST.js";
7
7
  import {
8
8
  createStandaloneConfigLoader,
9
9
  toNode
10
- } from "../chunk-ZNVPB2IR.js";
10
+ } from "../chunk-ETIN2W7C.js";
11
11
  import "../chunk-3J3WL7WN.js";
12
12
  import "../chunk-K5ZLPEIQ.js";
13
- import {
14
- mdxLoaderGlob,
15
- metaLoaderGlob
16
- } from "../chunk-4JSFLXXT.js";
17
13
  import "../chunk-VUEZTR2H.js";
18
14
  import {
19
15
  createCore,
20
16
  findConfigFile
21
- } from "../chunk-TZ5EQBFW.js";
17
+ } from "../chunk-2AQRQXSO.js";
22
18
  import "../chunk-VWJKRQZR.js";
23
19
 
24
20
  // src/node/loader.ts
@@ -32,8 +28,8 @@ var configLoader = createStandaloneConfigLoader({
32
28
  buildConfig: true,
33
29
  mode: "production"
34
30
  });
35
- var mdxLoader = toNode(createMdxLoader(configLoader), mdxLoaderGlob);
36
- var metaLoader = toNode(createMetaLoader(configLoader), metaLoaderGlob);
31
+ var mdxLoader = toNode(createMdxLoader(configLoader));
32
+ var metaLoader = toNode(createMetaLoader(configLoader));
37
33
  var load = (url, context, nextLoad) => {
38
34
  return mdxLoader(
39
35
  url,
@@ -1,4 +1,4 @@
1
- import { i as Plugin } from '../core-DB7TdlyC.cjs';
1
+ import { i as Plugin } from '../core-HkAVGq_a.cjs';
2
2
  import '@mdx-js/mdx';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/mdx-plugins';
@@ -1,4 +1,4 @@
1
- import { i as Plugin } from '../core-DB7TdlyC.js';
1
+ import { i as Plugin } from '../core-HkAVGq_a.js';
2
2
  import '@mdx-js/mdx';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/mdx-plugins';
@@ -1,5 +1,5 @@
1
- import { R as RuntimeAsync } from '../../types-Bnh9n7mj.cjs';
2
- export { j as buildConfig } from '../../core-DB7TdlyC.cjs';
1
+ import { R as RuntimeAsync } from '../../types-By6wKOnT.cjs';
2
+ export { j as buildConfig } from '../../core-HkAVGq_a.cjs';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/source';
5
5
  import '../../index.cjs';
@@ -7,7 +7,7 @@ import 'fumadocs-core/mdx-plugins';
7
7
  import 'fumadocs-core/toc';
8
8
  import 'mdx/types';
9
9
  import 'mdast';
10
- import '../../build-mdx-BjXOmv0b.cjs';
10
+ import '../../build-mdx-BnJhW5O1.cjs';
11
11
  import '@mdx-js/mdx';
12
12
  import 'react';
13
13
  import 'unified';
@@ -1,5 +1,5 @@
1
- import { R as RuntimeAsync } from '../../types-ey1AZqrg.js';
2
- export { j as buildConfig } from '../../core-DB7TdlyC.js';
1
+ import { R as RuntimeAsync } from '../../types-DgD5Omj2.js';
2
+ export { j as buildConfig } from '../../core-HkAVGq_a.js';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/source';
5
5
  import '../../index.js';
@@ -7,7 +7,7 @@ import 'fumadocs-core/mdx-plugins';
7
7
  import 'fumadocs-core/toc';
8
8
  import 'mdx/types';
9
9
  import 'mdast';
10
- import '../../build-mdx-CY5UldCO.js';
10
+ import '../../build-mdx-DNzfRRlY.js';
11
11
  import '@mdx-js/mdx';
12
12
  import 'react';
13
13
  import 'unified';
@@ -1,9 +1,9 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { a as Runtime } from '../../types-Bnh9n7mj.cjs';
3
- export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, R as RuntimeAsync, b as RuntimeFile } from '../../types-Bnh9n7mj.cjs';
2
+ import { a as Runtime } from '../../types-By6wKOnT.cjs';
3
+ export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, R as RuntimeAsync, b as RuntimeFile } from '../../types-By6wKOnT.cjs';
4
4
  import { FileInfo } from '../../index.cjs';
5
5
  import '@standard-schema/spec';
6
- import '../../core-DB7TdlyC.cjs';
6
+ import '../../core-HkAVGq_a.cjs';
7
7
  import '@mdx-js/mdx';
8
8
  import 'fumadocs-core/mdx-plugins';
9
9
  import 'unified';
@@ -12,7 +12,7 @@ import 'chokidar';
12
12
  import 'fumadocs-core/toc';
13
13
  import 'mdx/types';
14
14
  import 'mdast';
15
- import '../../build-mdx-BjXOmv0b.cjs';
15
+ import '../../build-mdx-BnJhW5O1.cjs';
16
16
  import 'react';
17
17
 
18
18
  declare const _runtime: Runtime;