fumadocs-mdx 14.0.0 → 14.0.2

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 (77) hide show
  1. package/dist/{build-mdx-6UAK5FF5.js → build-mdx-W3233QBZ.js} +1 -1
  2. package/dist/bun/index.d.ts +7 -1
  3. package/dist/bun/index.js +9 -8
  4. package/dist/{chunk-5YXP7JLN.js → chunk-5OBUOALK.js} +8 -5
  5. package/dist/{chunk-ZY6UZ7NH.js → chunk-6RPNS75C.js} +1 -1
  6. package/dist/{chunk-XHJCLBZ4.js → chunk-ED3ON275.js} +86 -162
  7. package/dist/{chunk-7L2KNF6B.js → chunk-GB4W3YCZ.js} +51 -7
  8. package/dist/{chunk-SLY7WXTX.js → chunk-KOPLIEVQ.js} +5 -6
  9. package/dist/{chunk-OXSRIWQW.js → chunk-LPX7ZO66.js} +4 -3
  10. package/dist/{chunk-SRSRFOVI.js → chunk-OLL7FM7W.js} +3 -3
  11. package/dist/{chunk-5UMZCWKV.js → chunk-Q5OSGLJL.js} +1 -1
  12. package/dist/{chunk-E5DJTSIM.js → chunk-S7KOJHHO.js} +4 -1
  13. package/dist/{chunk-6NISOLQ6.js → chunk-USWQVJWR.js} +1 -1
  14. package/dist/chunk-WBIHDYMN.js +126 -0
  15. package/dist/config/index.d.ts +6 -1
  16. package/dist/config/index.js +1 -1
  17. package/dist/{index-D7JdSMpp.d.cts → core-C3QZSdEx.d.ts} +73 -4
  18. package/dist/{index-BlVBvy-z.d.ts → index-RVIZxMZG.d.ts} +1 -1
  19. package/dist/index.d.ts +56 -3
  20. package/dist/load-from-file-OZ5N7DXU.js +8 -0
  21. package/dist/next/index.cjs +263 -193
  22. package/dist/next/index.d.ts +7 -2
  23. package/dist/next/index.js +12 -10
  24. package/dist/node/loader.js +4 -4
  25. package/dist/plugins/index-file.d.ts +7 -22
  26. package/dist/plugins/index-file.js +2 -2
  27. package/dist/plugins/json-schema.d.ts +7 -1
  28. package/dist/plugins/last-modified.d.ts +15 -2
  29. package/dist/plugins/last-modified.js +43 -6
  30. package/dist/runtime/browser.d.ts +22 -19
  31. package/dist/runtime/browser.js +5 -6
  32. package/dist/runtime/dynamic.d.ts +12 -12
  33. package/dist/runtime/dynamic.js +12 -11
  34. package/dist/runtime/server.d.ts +10 -157
  35. package/dist/runtime/server.js +3 -3
  36. package/dist/runtime/types.d.ts +61 -0
  37. package/dist/runtime/types.js +0 -0
  38. package/dist/vite/index.d.ts +7 -2
  39. package/dist/vite/index.js +10 -9
  40. package/dist/webpack/mdx.d.ts +8 -2
  41. package/dist/webpack/mdx.js +5 -5
  42. package/dist/webpack/meta.d.ts +8 -2
  43. package/dist/webpack/meta.js +4 -4
  44. package/package.json +4 -6
  45. package/dist/bin.cjs +0 -1889
  46. package/dist/bin.d.cts +0 -1
  47. package/dist/bun/index.cjs +0 -1112
  48. package/dist/bun/index.d.cts +0 -19
  49. package/dist/chunk-PKI7ZDA5.js +0 -29
  50. package/dist/config/index.cjs +0 -400
  51. package/dist/config/index.d.cts +0 -13
  52. package/dist/index-D7JdSMpp.d.ts +0 -272
  53. package/dist/index-P2NNUkHn.d.cts +0 -8
  54. package/dist/index.cjs +0 -18
  55. package/dist/index.d.cts +0 -8
  56. package/dist/load-from-file-I3ALLIVB.js +0 -8
  57. package/dist/next/index.d.cts +0 -28
  58. package/dist/node/loader.cjs +0 -1165
  59. package/dist/node/loader.d.cts +0 -5
  60. package/dist/plugins/index-file.cjs +0 -471
  61. package/dist/plugins/index-file.d.cts +0 -29
  62. package/dist/plugins/json-schema.cjs +0 -114
  63. package/dist/plugins/json-schema.d.cts +0 -25
  64. package/dist/plugins/last-modified.cjs +0 -75
  65. package/dist/plugins/last-modified.d.cts +0 -27
  66. package/dist/runtime/browser.cjs +0 -94
  67. package/dist/runtime/browser.d.cts +0 -50
  68. package/dist/runtime/dynamic.cjs +0 -985
  69. package/dist/runtime/dynamic.d.cts +0 -27
  70. package/dist/runtime/server.cjs +0 -173
  71. package/dist/runtime/server.d.cts +0 -161
  72. package/dist/vite/index.cjs +0 -1620
  73. package/dist/vite/index.d.cts +0 -39
  74. package/dist/webpack/mdx.cjs +0 -1089
  75. package/dist/webpack/mdx.d.cts +0 -14
  76. package/dist/webpack/meta.cjs +0 -649
  77. package/dist/webpack/meta.d.cts +0 -14
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/plugins/last-modified.ts
31
- var last_modified_exports = {};
32
- __export(last_modified_exports, {
33
- default: () => lastModified
34
- });
35
- module.exports = __toCommonJS(last_modified_exports);
36
- var import_node_path = __toESM(require("path"), 1);
37
- var import_tinyexec = require("tinyexec");
38
- var cache = /* @__PURE__ */ new Map();
39
- function lastModified(options = {}) {
40
- const { versionControl = "git" } = options;
41
- return {
42
- name: "last-modified",
43
- doc: {
44
- async vfile(file) {
45
- if (versionControl === "git") {
46
- const timestamp = await getGitTimestamp(this.filePath).then(
47
- (v) => v?.getTime()
48
- );
49
- if (timestamp === void 0) return;
50
- file.data["mdx-export"] ??= [];
51
- file.data["mdx-export"].push({
52
- name: "lastModified",
53
- value: timestamp
54
- });
55
- }
56
- }
57
- }
58
- };
59
- }
60
- async function getGitTimestamp(file) {
61
- const cached = cache.get(file);
62
- if (cached) return cached;
63
- const timePromise = (async () => {
64
- const out = await (0, import_tinyexec.x)(
65
- "git",
66
- ["log", "-1", '--pretty="%ai"', import_node_path.default.relative(process.cwd(), file)],
67
- {
68
- throwOnError: true
69
- }
70
- );
71
- return new Date(out.stdout);
72
- })();
73
- cache.set(file, timePromise);
74
- return timePromise.catch(() => void 0);
75
- }
@@ -1,27 +0,0 @@
1
- import { j as Plugin } from '../index-D7JdSMpp.cjs';
2
- import '@mdx-js/mdx';
3
- import '@standard-schema/spec';
4
- import 'unified';
5
- import 'fumadocs-core/mdx-plugins';
6
- import 'zod';
7
- import 'chokidar';
8
- import 'vfile';
9
-
10
- interface LastModifiedPluginOptions {
11
- /**
12
- * Version control to obtain the last modified time.
13
- *
14
- * - `git`: Requires `git` to be installed.
15
- *
16
- * If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`.
17
- *
18
- * @defaultValue 'git'
19
- */
20
- versionControl?: 'git';
21
- }
22
- /**
23
- * Injects `lastModified` property to page exports.
24
- */
25
- declare function lastModified(options?: LastModifiedPluginOptions): Plugin;
26
-
27
- export { type LastModifiedPluginOptions, lastModified as default };
@@ -1,94 +0,0 @@
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/browser.ts
21
- var browser_exports = {};
22
- __export(browser_exports, {
23
- createClientLoader: () => createClientLoader,
24
- fromConfig: () => fromConfig
25
- });
26
- module.exports = __toCommonJS(browser_exports);
27
- var import_react = require("react");
28
- function fromConfig() {
29
- return {
30
- doc(_name, glob) {
31
- const raw = glob;
32
- const out = {
33
- raw,
34
- createClientLoader({ id = _name, ...options }) {
35
- return createClientLoader(raw, { id, ...options });
36
- }
37
- };
38
- return out;
39
- }
40
- };
41
- }
42
- var loaderStore = /* @__PURE__ */ new Map();
43
- function createClientLoader(globEntries, options) {
44
- const { id = "", component } = options;
45
- const renderers = {};
46
- const loaders = /* @__PURE__ */ new Map();
47
- const store = loaderStore.get(id) ?? {
48
- preloaded: /* @__PURE__ */ new Map()
49
- };
50
- loaderStore.set(id, store);
51
- for (const k in globEntries) {
52
- loaders.set(k.startsWith("./") ? k.slice(2) : k, globEntries[k]);
53
- }
54
- function getLoader(path) {
55
- const loader = loaders.get(path);
56
- if (!loader)
57
- throw new Error(
58
- `[createClientLoader] ${path} does not exist in available entries`
59
- );
60
- return loader;
61
- }
62
- function getRenderer(path) {
63
- if (path in renderers) return renderers[path];
64
- const OnDemand = (0, import_react.lazy)(async () => {
65
- const loaded = await getLoader(path)();
66
- return { default: (props) => component(loaded, props) };
67
- });
68
- renderers[path] = (props) => {
69
- const cached = store.preloaded.get(path);
70
- if (!cached) return (0, import_react.createElement)(OnDemand, props);
71
- return component(cached, props);
72
- };
73
- return renderers[path];
74
- }
75
- return {
76
- async preload(path) {
77
- const loaded = await getLoader(path)();
78
- store.preloaded.set(path, loaded);
79
- return loaded;
80
- },
81
- getComponent(path) {
82
- return getRenderer(path);
83
- },
84
- useContent(path, props) {
85
- const Comp = this.getComponent(path);
86
- return (0, import_react.createElement)(Comp, props);
87
- }
88
- };
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- createClientLoader,
93
- fromConfig
94
- });
@@ -1,50 +0,0 @@
1
- import { ReactNode, FC } from 'react';
2
- import { CompiledMDXFile } from './server.cjs';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
4
- import { D as DocCollection, b as DocsCollection } from '../index-D7JdSMpp.cjs';
5
- import 'fumadocs-core/source';
6
- import 'fumadocs-core/mdx-plugins';
7
- import 'fumadocs-core/toc';
8
- import 'mdx/types';
9
- import 'mdast';
10
- import '@mdx-js/mdx';
11
- import 'unified';
12
- import 'zod';
13
- import 'chokidar';
14
- import 'vfile';
15
-
16
- interface ClientLoaderOptions<Frontmatter, Props> {
17
- /**
18
- * Loader ID (usually your collection name)
19
- *
20
- * The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
21
- *
22
- * We use loader ID to share cache between multiple instances of client loader.
23
- *
24
- * @defaultValue ''
25
- */
26
- id?: string;
27
- component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
28
- }
29
- interface ClientLoader<Frontmatter, Props> {
30
- preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
31
- /**
32
- * Get a component that renders content with `React.lazy`.
33
- */
34
- getComponent: (path: string) => FC<Props>;
35
- /**
36
- * Get react nodes that renders content with `React.lazy`.
37
- */
38
- useContent: (path: string, props: Props) => ReactNode;
39
- }
40
- type BrowserCreate<Config> = ReturnType<typeof fromConfig<Config>>;
41
- interface DocCollectionEntry<Frontmatter> {
42
- raw: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
43
- createClientLoader: <Props extends object>(options: ClientLoaderOptions<Frontmatter, Props>) => ClientLoader<Frontmatter, Props>;
44
- }
45
- declare function fromConfig<Config>(): {
46
- doc<Name extends keyof Config>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<StandardSchemaV1.InferOutput<Schema>> : never;
47
- };
48
- declare function createClientLoader<Frontmatter, Props extends object = object>(globEntries: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
49
-
50
- export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry, createClientLoader, fromConfig };