fumadocs-mdx 11.8.3 → 11.9.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.
Files changed (36) hide show
  1. package/dist/browser-CyU2Yl7A.d.cts +51 -0
  2. package/dist/browser-DEsQvNRx.d.ts +51 -0
  3. package/dist/chunk-46UPKP5R.js +77 -0
  4. package/dist/{chunk-BWRDVK5L.js → chunk-766EAFX6.js} +1 -1
  5. package/dist/chunk-COQ4VMK2.js +158 -0
  6. package/dist/config/index.d.cts +1 -1
  7. package/dist/config/index.d.ts +1 -1
  8. package/dist/config/zod-3.d.cts +1 -1
  9. package/dist/config/zod-3.d.ts +1 -1
  10. package/dist/{define-DAZmbu3U.d.cts → define-DnJzAZrj.d.cts} +1 -1
  11. package/dist/{define-DAZmbu3U.d.ts → define-DnJzAZrj.d.ts} +1 -1
  12. package/dist/index.d.cts +2 -2
  13. package/dist/index.d.ts +2 -2
  14. package/dist/loader-mdx.cjs +1 -1
  15. package/dist/loader-mdx.js +2 -2
  16. package/dist/next/index.cjs +126 -11
  17. package/dist/next/index.js +27 -9
  18. package/dist/runtime/async.d.cts +2 -2
  19. package/dist/runtime/async.d.ts +2 -2
  20. package/dist/runtime/async.js +1 -1
  21. package/dist/runtime/vite/browser.cjs +103 -0
  22. package/dist/runtime/vite/browser.d.cts +11 -0
  23. package/dist/runtime/vite/browser.d.ts +11 -0
  24. package/dist/runtime/vite/browser.js +10 -0
  25. package/dist/runtime/{vite.cjs → vite/server.cjs} +89 -61
  26. package/dist/runtime/vite/server.d.cts +41 -0
  27. package/dist/runtime/vite/server.d.ts +41 -0
  28. package/dist/runtime/{vite.js → vite/server.js} +14 -64
  29. package/dist/{types-B2kQsHs7.d.cts → types-BmVgoqsr.d.cts} +1 -1
  30. package/dist/{types-CkmezNbX.d.ts → types-WSHJKA8L.d.ts} +1 -1
  31. package/dist/vite/index.cjs +99 -84
  32. package/dist/vite/index.js +13 -93
  33. package/package.json +12 -11
  34. package/dist/chunk-6Y5JDZHD.js +0 -65
  35. package/dist/runtime/vite.d.cts +0 -72
  36. package/dist/runtime/vite.d.ts +0 -72
@@ -2,13 +2,14 @@ import {
2
2
  findConfigFile,
3
3
  getConfigHash,
4
4
  loadConfig
5
- } from "../chunk-BWRDVK5L.js";
5
+ } from "../chunk-766EAFX6.js";
6
6
  import {
7
+ entry,
7
8
  getGlobPatterns,
8
9
  getImportCode,
9
10
  isFileSupported,
10
11
  toImportPath
11
- } from "../chunk-6Y5JDZHD.js";
12
+ } from "../chunk-COQ4VMK2.js";
12
13
  import {
13
14
  ValidationError,
14
15
  getGitTimestamp,
@@ -339,17 +340,34 @@ function createMDX({
339
340
  // src/postinstall.ts
340
341
  import * as path3 from "path";
341
342
  import * as fs3 from "fs/promises";
342
- async function postInstall(configPath = findConfigFile(), outDir = ".source") {
343
- const jsOut = path3.resolve(outDir, "index.ts");
343
+ import { existsSync } from "fs";
344
+ async function postInstall(configPath = findConfigFile(), outDir) {
345
+ const isNext = existsSync("next.config.js") || existsSync("next.config.mjs") || existsSync("next.config.ts");
346
+ if (isNext) {
347
+ await onNext(configPath, outDir ?? ".source");
348
+ } else {
349
+ await onVite(configPath, outDir ?? process.cwd());
350
+ }
351
+ console.log("[MDX] types generated");
352
+ }
353
+ async function onNext(configPath, outDir) {
354
+ const config = await loadConfig(configPath, outDir, void 0, true);
355
+ const outPath = path3.join(outDir, "index.ts");
356
+ await fs3.rm(outDir, { recursive: true });
357
+ await fs3.mkdir(outDir, { recursive: true });
344
358
  const hash = await getConfigHash(configPath);
345
- const config = await loadConfig(configPath, outDir, hash, true);
346
- await fs3.rm(path3.dirname(jsOut), { recursive: true });
347
- await fs3.mkdir(path3.dirname(jsOut), { recursive: true });
348
359
  await fs3.writeFile(
349
- jsOut,
360
+ outPath,
350
361
  await generateJS(configPath, config, { relativeTo: outDir }, hash)
351
362
  );
352
- console.log("[MDX] types generated");
363
+ }
364
+ async function onVite(configPath, outDir, addJsExtension) {
365
+ const config = await loadConfig(configPath, "node_modules", void 0, true);
366
+ const outFile = "source.generated.ts";
367
+ await fs3.writeFile(
368
+ path3.join(outDir, outFile),
369
+ entry(configPath, config, outDir, addJsExtension)
370
+ );
353
371
  }
354
372
  export {
355
373
  createMDX,
@@ -1,7 +1,7 @@
1
- import { L as LoadedConfig, a as RuntimeAsync } from '../types-B2kQsHs7.cjs';
1
+ import { L as LoadedConfig, a as RuntimeAsync } from '../types-BmVgoqsr.cjs';
2
2
  import '@standard-schema/spec';
3
3
  import 'fumadocs-core/source';
4
- import '../define-DAZmbu3U.cjs';
4
+ import '../define-DnJzAZrj.cjs';
5
5
  import 'fumadocs-core/mdx-plugins';
6
6
  import '@mdx-js/mdx';
7
7
  import 'unified';
@@ -1,7 +1,7 @@
1
- import { L as LoadedConfig, a as RuntimeAsync } from '../types-CkmezNbX.js';
1
+ import { L as LoadedConfig, a as RuntimeAsync } from '../types-WSHJKA8L.js';
2
2
  import '@standard-schema/spec';
3
3
  import 'fumadocs-core/source';
4
- import '../define-DAZmbu3U.js';
4
+ import '../define-DnJzAZrj.js';
5
5
  import 'fumadocs-core/mdx-plugins';
6
6
  import '@mdx-js/mdx';
7
7
  import 'unified';
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  buildMDX
7
7
  } from "../chunk-QQWCBFFE.js";
8
+ import "../chunk-SVTXMVLQ.js";
8
9
  import {
9
10
  buildConfig
10
11
  } from "../chunk-QVZ7JH4H.js";
11
- import "../chunk-SVTXMVLQ.js";
12
12
  import "../chunk-VWJKRQZR.js";
13
13
 
14
14
  // src/runtime/async.ts
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runtime/vite/browser.ts
21
+ var browser_exports = {};
22
+ __export(browser_exports, {
23
+ createClientLoader: () => createClientLoader,
24
+ fromConfig: () => fromConfigBase,
25
+ toClientRenderer: () => toClientRenderer
26
+ });
27
+ module.exports = __toCommonJS(browser_exports);
28
+ var import_react = require("react");
29
+
30
+ // src/runtime/vite/base.ts
31
+ function fromConfigBase() {
32
+ function normalize(entries, base) {
33
+ const out = {};
34
+ for (const k in entries) {
35
+ const mappedK = k.startsWith("./") ? k.slice(2) : k;
36
+ if (base) Object.assign(entries[k], { base });
37
+ out[mappedK] = entries[k];
38
+ }
39
+ return out;
40
+ }
41
+ return {
42
+ doc(_, base, glob) {
43
+ return normalize(glob, base);
44
+ },
45
+ meta(_, base, glob) {
46
+ return normalize(glob, base);
47
+ },
48
+ docLazy(_, base, head, body) {
49
+ return {
50
+ base,
51
+ head: normalize(head),
52
+ body: normalize(body)
53
+ };
54
+ }
55
+ };
56
+ }
57
+
58
+ // src/runtime/vite/browser.ts
59
+ var loaderStore = /* @__PURE__ */ new Map();
60
+ function createClientLoader(files, options) {
61
+ const { id = "", component } = options;
62
+ let renderer;
63
+ const store = loaderStore.get(id) ?? {
64
+ preloaded: /* @__PURE__ */ new Map()
65
+ };
66
+ loaderStore.set(id, store);
67
+ function getRenderer() {
68
+ if (renderer) return renderer;
69
+ renderer = {};
70
+ for (const k in files) {
71
+ const OnDemand = (0, import_react.lazy)(async () => {
72
+ const loaded = await files[k]();
73
+ return { default: (props) => component(loaded, props) };
74
+ });
75
+ renderer[k] = (props) => {
76
+ const cached = store.preloaded.get(k);
77
+ if (!cached) return (0, import_react.createElement)(OnDemand, props);
78
+ return component(cached, props);
79
+ };
80
+ }
81
+ return renderer;
82
+ }
83
+ return {
84
+ async preload(path) {
85
+ const loaded = await files[path]();
86
+ store.preloaded.set(path, loaded);
87
+ return loaded;
88
+ },
89
+ getRenderer,
90
+ getComponent(path) {
91
+ return getRenderer()[path];
92
+ }
93
+ };
94
+ }
95
+ function toClientRenderer(files, component) {
96
+ return createClientLoader(files, { component }).getRenderer();
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ createClientLoader,
101
+ fromConfig,
102
+ toClientRenderer
103
+ });
@@ -0,0 +1,11 @@
1
+ export { a as ClientLoader, b as ClientLoaderOptions, c as createClientLoader, f as fromConfig, t as toClientRenderer } from '../../browser-CyU2Yl7A.cjs';
2
+ import 'react';
3
+ import '../../build-mdx-DnC1jKvn.cjs';
4
+ import '@mdx-js/mdx';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'fumadocs-core/server';
7
+ import 'mdx/types';
8
+ import '../../define-DnJzAZrj.cjs';
9
+ import '@standard-schema/spec';
10
+ import 'unified';
11
+ import 'zod';
@@ -0,0 +1,11 @@
1
+ export { a as ClientLoader, b as ClientLoaderOptions, c as createClientLoader, f as fromConfig, t as toClientRenderer } from '../../browser-DEsQvNRx.js';
2
+ import 'react';
3
+ import '../../build-mdx-DnC1jKvn.js';
4
+ import '@mdx-js/mdx';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'fumadocs-core/server';
7
+ import 'mdx/types';
8
+ import '../../define-DnJzAZrj.js';
9
+ import '@standard-schema/spec';
10
+ import 'unified';
11
+ import 'zod';
@@ -0,0 +1,10 @@
1
+ import {
2
+ createClientLoader,
3
+ fromConfigBase,
4
+ toClientRenderer
5
+ } from "../../chunk-46UPKP5R.js";
6
+ export {
7
+ createClientLoader,
8
+ fromConfigBase as fromConfig,
9
+ toClientRenderer
10
+ };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,26 +17,101 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
- // src/runtime/vite.ts
21
- var vite_exports = {};
22
- __export(vite_exports, {
30
+ // src/runtime/vite/server.ts
31
+ var server_exports = {};
32
+ __export(server_exports, {
23
33
  createClientLoader: () => createClientLoader,
24
34
  fromConfig: () => fromConfig,
25
35
  toClientRenderer: () => toClientRenderer
26
36
  });
27
- module.exports = __toCommonJS(vite_exports);
28
- var import_react = require("react");
29
- function fromConfig() {
30
- function normalize(entries) {
37
+ module.exports = __toCommonJS(server_exports);
38
+
39
+ // src/runtime/vite/base.ts
40
+ function fromConfigBase() {
41
+ function normalize(entries, base) {
31
42
  const out = {};
32
43
  for (const k in entries) {
33
44
  const mappedK = k.startsWith("./") ? k.slice(2) : k;
45
+ if (base) Object.assign(entries[k], { base });
34
46
  out[mappedK] = entries[k];
35
47
  }
36
48
  return out;
37
49
  }
50
+ return {
51
+ doc(_, base, glob) {
52
+ return normalize(glob, base);
53
+ },
54
+ meta(_, base, glob) {
55
+ return normalize(glob, base);
56
+ },
57
+ docLazy(_, base, head, body) {
58
+ return {
59
+ base,
60
+ head: normalize(head),
61
+ body: normalize(body)
62
+ };
63
+ }
64
+ };
65
+ }
66
+
67
+ // src/runtime/vite/server.ts
68
+ var path = __toESM(require("path"), 1);
69
+
70
+ // src/runtime/vite/browser.ts
71
+ var import_react = require("react");
72
+ var loaderStore = /* @__PURE__ */ new Map();
73
+ function createClientLoader(files, options) {
74
+ const { id = "", component } = options;
75
+ let renderer;
76
+ const store = loaderStore.get(id) ?? {
77
+ preloaded: /* @__PURE__ */ new Map()
78
+ };
79
+ loaderStore.set(id, store);
80
+ function getRenderer() {
81
+ if (renderer) return renderer;
82
+ renderer = {};
83
+ for (const k in files) {
84
+ const OnDemand = (0, import_react.lazy)(async () => {
85
+ const loaded = await files[k]();
86
+ return { default: (props) => component(loaded, props) };
87
+ });
88
+ renderer[k] = (props) => {
89
+ const cached = store.preloaded.get(k);
90
+ if (!cached) return (0, import_react.createElement)(OnDemand, props);
91
+ return component(cached, props);
92
+ };
93
+ }
94
+ return renderer;
95
+ }
96
+ return {
97
+ async preload(path2) {
98
+ const loaded = await files[path2]();
99
+ store.preloaded.set(path2, loaded);
100
+ return loaded;
101
+ },
102
+ getRenderer,
103
+ getComponent(path2) {
104
+ return getRenderer()[path2];
105
+ }
106
+ };
107
+ }
108
+ function toClientRenderer(files, component) {
109
+ return createClientLoader(files, { component }).getRenderer();
110
+ }
111
+
112
+ // src/runtime/vite/server.ts
113
+ function fromConfig() {
114
+ const base = fromConfigBase();
38
115
  function mapPageData(entry) {
39
116
  const { toc, structuredData, lastModified, frontmatter } = entry;
40
117
  return {
@@ -57,24 +134,14 @@ function fromConfig() {
57
134
  };
58
135
  }
59
136
  return {
60
- doc(_, glob) {
61
- return normalize(glob);
62
- },
63
- meta(_, glob) {
64
- return normalize(glob);
65
- },
66
- docLazy(_, head, body) {
67
- return {
68
- head: normalize(head),
69
- body: normalize(body)
70
- };
71
- },
137
+ ...base,
72
138
  async sourceAsync(doc, meta) {
73
139
  const virtualFiles = [
74
140
  ...Object.entries(doc).map(async ([file, content]) => {
75
141
  return {
76
142
  type: "page",
77
143
  path: file,
144
+ absolutePath: path.join(content.base, file),
78
145
  data: mapPageData(await content())
79
146
  };
80
147
  }),
@@ -82,6 +149,7 @@ function fromConfig() {
82
149
  return {
83
150
  type: "meta",
84
151
  path: file,
152
+ absolutePath: path.join(content.base, file),
85
153
  data: await content()
86
154
  };
87
155
  })
@@ -94,6 +162,7 @@ function fromConfig() {
94
162
  return {
95
163
  type: "page",
96
164
  path: file,
165
+ absolutePath: path.join(doc.base, file),
97
166
  data: mapPageDataLazy(await frontmatter(), doc.body[file])
98
167
  };
99
168
  }),
@@ -101,6 +170,7 @@ function fromConfig() {
101
170
  return {
102
171
  type: "meta",
103
172
  path: file,
173
+ absolutePath: path.join(content.base, file),
104
174
  data: await content()
105
175
  };
106
176
  })
@@ -109,48 +179,6 @@ function fromConfig() {
109
179
  }
110
180
  };
111
181
  }
112
- var loaderStore = /* @__PURE__ */ new Map();
113
- function createClientLoader(files, options) {
114
- const { id = "", component } = options;
115
- const store = loaderStore.get(id) ?? {
116
- preloaded: /* @__PURE__ */ new Map()
117
- };
118
- loaderStore.set(id, store);
119
- let renderer;
120
- return {
121
- async preload(path) {
122
- const loaded = await files[path]();
123
- store.preloaded.set(path, loaded);
124
- return loaded;
125
- },
126
- getComponent(path) {
127
- renderer ??= toClientRenderer(files, component, {
128
- cache: store.preloaded
129
- });
130
- return renderer[path];
131
- }
132
- };
133
- }
134
- function toClientRenderer(files, component, options = {}) {
135
- const { cache } = options;
136
- const renderer = {};
137
- for (const k in files) {
138
- const OnDemand = (0, import_react.lazy)(async () => {
139
- const loaded = await files[k]();
140
- return { default: (props) => component(loaded, props) };
141
- });
142
- if (cache) {
143
- renderer[k] = (props) => {
144
- const cached = cache.get(k);
145
- if (!cached) return (0, import_react.createElement)(OnDemand, props);
146
- return component(cached, props);
147
- };
148
- } else {
149
- renderer[k] = OnDemand;
150
- }
151
- }
152
- return renderer;
153
- }
154
182
  // Annotate the CommonJS export names for ESM import in node:
155
183
  0 && (module.exports = {
156
184
  createClientLoader,
@@ -0,0 +1,41 @@
1
+ import { B as BaseCreate, D as DocMap, M as MetaMap, L as LazyDocMap, C as CompiledMDXFile } from '../../browser-CyU2Yl7A.cjs';
2
+ export { a as ClientLoader, b as ClientLoaderOptions, c as createClientLoader, t as toClientRenderer } from '../../browser-CyU2Yl7A.cjs';
3
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
4
+ import { C as CompiledMDXProperties } from '../../build-mdx-DnC1jKvn.cjs';
5
+ import { FC } from 'react';
6
+ import { MDXProps } from 'mdx/types';
7
+ import '../../define-DnJzAZrj.cjs';
8
+ import '@standard-schema/spec';
9
+ import 'fumadocs-core/mdx-plugins';
10
+ import '@mdx-js/mdx';
11
+ import 'unified';
12
+ import 'zod';
13
+ import 'fumadocs-core/server';
14
+
15
+ type Override<A, B> = Omit<A, keyof B> & B;
16
+ type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
17
+ /**
18
+ * @deprecated use `body` instead.
19
+ */
20
+ default: FC<MDXProps>;
21
+ _exports: Record<string, unknown>;
22
+ body: FC<MDXProps>;
23
+ }>;
24
+ type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
25
+ load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
26
+ body: FC<MDXProps>;
27
+ }>;
28
+ }>;
29
+ interface ServerCreate<Config> extends BaseCreate<Config> {
30
+ sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
31
+ pageData: MDXFileToPageData<DocOut>;
32
+ metaData: MetaOut;
33
+ }>>;
34
+ sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
35
+ pageData: MDXFileToPageDataLazy<DocOut>;
36
+ metaData: MetaOut;
37
+ }>>;
38
+ }
39
+ declare function fromConfig<Config>(): ServerCreate<Config>;
40
+
41
+ export { CompiledMDXFile, type ServerCreate, fromConfig };
@@ -0,0 +1,41 @@
1
+ import { B as BaseCreate, D as DocMap, M as MetaMap, L as LazyDocMap, C as CompiledMDXFile } from '../../browser-DEsQvNRx.js';
2
+ export { a as ClientLoader, b as ClientLoaderOptions, c as createClientLoader, t as toClientRenderer } from '../../browser-DEsQvNRx.js';
3
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
4
+ import { C as CompiledMDXProperties } from '../../build-mdx-DnC1jKvn.js';
5
+ import { FC } from 'react';
6
+ import { MDXProps } from 'mdx/types';
7
+ import '../../define-DnJzAZrj.js';
8
+ import '@standard-schema/spec';
9
+ import 'fumadocs-core/mdx-plugins';
10
+ import '@mdx-js/mdx';
11
+ import 'unified';
12
+ import 'zod';
13
+ import 'fumadocs-core/server';
14
+
15
+ type Override<A, B> = Omit<A, keyof B> & B;
16
+ type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
17
+ /**
18
+ * @deprecated use `body` instead.
19
+ */
20
+ default: FC<MDXProps>;
21
+ _exports: Record<string, unknown>;
22
+ body: FC<MDXProps>;
23
+ }>;
24
+ type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
25
+ load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
26
+ body: FC<MDXProps>;
27
+ }>;
28
+ }>;
29
+ interface ServerCreate<Config> extends BaseCreate<Config> {
30
+ sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
31
+ pageData: MDXFileToPageData<DocOut>;
32
+ metaData: MetaOut;
33
+ }>>;
34
+ sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
35
+ pageData: MDXFileToPageDataLazy<DocOut>;
36
+ metaData: MetaOut;
37
+ }>>;
38
+ }
39
+ declare function fromConfig<Config>(): ServerCreate<Config>;
40
+
41
+ export { CompiledMDXFile, type ServerCreate, fromConfig };
@@ -1,14 +1,13 @@
1
- // src/runtime/vite.ts
2
- import { createElement, lazy } from "react";
1
+ import {
2
+ createClientLoader,
3
+ fromConfigBase,
4
+ toClientRenderer
5
+ } from "../../chunk-46UPKP5R.js";
6
+
7
+ // src/runtime/vite/server.ts
8
+ import * as path from "path";
3
9
  function fromConfig() {
4
- function normalize(entries) {
5
- const out = {};
6
- for (const k in entries) {
7
- const mappedK = k.startsWith("./") ? k.slice(2) : k;
8
- out[mappedK] = entries[k];
9
- }
10
- return out;
11
- }
10
+ const base = fromConfigBase();
12
11
  function mapPageData(entry) {
13
12
  const { toc, structuredData, lastModified, frontmatter } = entry;
14
13
  return {
@@ -31,24 +30,14 @@ function fromConfig() {
31
30
  };
32
31
  }
33
32
  return {
34
- doc(_, glob) {
35
- return normalize(glob);
36
- },
37
- meta(_, glob) {
38
- return normalize(glob);
39
- },
40
- docLazy(_, head, body) {
41
- return {
42
- head: normalize(head),
43
- body: normalize(body)
44
- };
45
- },
33
+ ...base,
46
34
  async sourceAsync(doc, meta) {
47
35
  const virtualFiles = [
48
36
  ...Object.entries(doc).map(async ([file, content]) => {
49
37
  return {
50
38
  type: "page",
51
39
  path: file,
40
+ absolutePath: path.join(content.base, file),
52
41
  data: mapPageData(await content())
53
42
  };
54
43
  }),
@@ -56,6 +45,7 @@ function fromConfig() {
56
45
  return {
57
46
  type: "meta",
58
47
  path: file,
48
+ absolutePath: path.join(content.base, file),
59
49
  data: await content()
60
50
  };
61
51
  })
@@ -68,6 +58,7 @@ function fromConfig() {
68
58
  return {
69
59
  type: "page",
70
60
  path: file,
61
+ absolutePath: path.join(doc.base, file),
71
62
  data: mapPageDataLazy(await frontmatter(), doc.body[file])
72
63
  };
73
64
  }),
@@ -75,6 +66,7 @@ function fromConfig() {
75
66
  return {
76
67
  type: "meta",
77
68
  path: file,
69
+ absolutePath: path.join(content.base, file),
78
70
  data: await content()
79
71
  };
80
72
  })
@@ -83,48 +75,6 @@ function fromConfig() {
83
75
  }
84
76
  };
85
77
  }
86
- var loaderStore = /* @__PURE__ */ new Map();
87
- function createClientLoader(files, options) {
88
- const { id = "", component } = options;
89
- const store = loaderStore.get(id) ?? {
90
- preloaded: /* @__PURE__ */ new Map()
91
- };
92
- loaderStore.set(id, store);
93
- let renderer;
94
- return {
95
- async preload(path) {
96
- const loaded = await files[path]();
97
- store.preloaded.set(path, loaded);
98
- return loaded;
99
- },
100
- getComponent(path) {
101
- renderer ??= toClientRenderer(files, component, {
102
- cache: store.preloaded
103
- });
104
- return renderer[path];
105
- }
106
- };
107
- }
108
- function toClientRenderer(files, component, options = {}) {
109
- const { cache } = options;
110
- const renderer = {};
111
- for (const k in files) {
112
- const OnDemand = lazy(async () => {
113
- const loaded = await files[k]();
114
- return { default: (props) => component(loaded, props) };
115
- });
116
- if (cache) {
117
- renderer[k] = (props) => {
118
- const cached = cache.get(k);
119
- if (!cached) return createElement(OnDemand, props);
120
- return component(cached, props);
121
- };
122
- } else {
123
- renderer[k] = OnDemand;
124
- }
125
- }
126
- return renderer;
127
- }
128
78
  export {
129
79
  createClientLoader,
130
80
  fromConfig,
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig } from './define-DAZmbu3U.cjs';
3
+ import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-DnJzAZrj.cjs';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { C as CompiledMDXProperties } from './build-mdx-DnC1jKvn.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig } from './define-DAZmbu3U.js';
3
+ import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-DnJzAZrj.js';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { C as CompiledMDXProperties } from './build-mdx-DnC1jKvn.js';
6
6