fumadocs-mdx 14.0.1 → 14.0.3
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/{build-mdx-6UAK5FF5.js → build-mdx-W3233QBZ.js} +1 -1
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +8 -8
- package/dist/{chunk-ZY6UZ7NH.js → chunk-6RPNS75C.js} +1 -1
- package/dist/{chunk-7UKSZSPY.js → chunk-DKA3EWZH.js} +6 -7
- package/dist/{chunk-BEBCWQC7.js → chunk-GB4W3YCZ.js} +1 -1
- package/dist/{chunk-SLY7WXTX.js → chunk-KOPLIEVQ.js} +5 -6
- package/dist/{chunk-MTTISKQJ.js → chunk-LPX7ZO66.js} +1 -1
- package/dist/{chunk-K6HCOGOX.js → chunk-OLL7FM7W.js} +2 -2
- package/dist/{chunk-IQGEFL2B.js → chunk-Q5OSGLJL.js} +1 -1
- package/dist/{chunk-E5DJTSIM.js → chunk-S7KOJHHO.js} +4 -1
- package/dist/{chunk-6NISOLQ6.js → chunk-USWQVJWR.js} +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/{core-B9ZoS6sA.d.ts → core-C3QZSdEx.d.ts} +1 -1
- package/dist/{index-BD8Woo4m.d.cts → index-DG1I0CwF.d.ts} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/load-from-file-OZ5N7DXU.js +8 -0
- package/dist/next/index.cjs +10 -8
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +8 -8
- package/dist/node/loader.js +4 -4
- package/dist/plugins/index-file.d.ts +1 -1
- package/dist/plugins/index-file.js +2 -2
- package/dist/plugins/json-schema.d.ts +1 -1
- package/dist/plugins/last-modified.d.ts +5 -2
- package/dist/plugins/last-modified.js +10 -3
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/dynamic.d.ts +1 -1
- package/dist/runtime/dynamic.js +5 -5
- package/dist/runtime/server.d.ts +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +10 -10
- package/dist/webpack/mdx.d.ts +2 -2
- package/dist/webpack/mdx.js +6 -6
- package/dist/webpack/meta.d.ts +2 -2
- package/dist/webpack/meta.js +4 -4
- package/package.json +4 -6
- package/dist/bin.cjs +0 -1958
- package/dist/bin.d.cts +0 -1
- package/dist/bun/index.cjs +0 -1147
- package/dist/bun/index.d.cts +0 -25
- package/dist/config/index.cjs +0 -400
- package/dist/config/index.d.cts +0 -18
- package/dist/core-DTuP23zu.d.cts +0 -341
- package/dist/index-CNOvhtOn.d.ts +0 -8
- package/dist/index.cjs +0 -18
- package/dist/index.d.cts +0 -61
- package/dist/load-from-file-5HUQN36V.js +0 -8
- package/dist/next/index.d.cts +0 -33
- package/dist/node/loader.cjs +0 -1200
- package/dist/node/loader.d.cts +0 -5
- package/dist/plugins/index-file.cjs +0 -495
- package/dist/plugins/index-file.d.cts +0 -14
- package/dist/plugins/json-schema.cjs +0 -114
- package/dist/plugins/json-schema.d.cts +0 -31
- package/dist/plugins/last-modified.cjs +0 -110
- package/dist/plugins/last-modified.d.cts +0 -37
- package/dist/runtime/browser.cjs +0 -93
- package/dist/runtime/browser.d.cts +0 -53
- package/dist/runtime/dynamic.cjs +0 -1023
- package/dist/runtime/dynamic.d.cts +0 -27
- package/dist/runtime/server.cjs +0 -176
- package/dist/runtime/server.d.cts +0 -14
- package/dist/runtime/types.cjs +0 -18
- package/dist/runtime/types.d.cts +0 -61
- package/dist/vite/index.cjs +0 -1687
- package/dist/vite/index.d.cts +0 -44
- package/dist/webpack/mdx.cjs +0 -1124
- package/dist/webpack/mdx.d.cts +0 -20
- package/dist/webpack/meta.cjs +0 -684
- package/dist/webpack/meta.d.cts +0 -20
|
@@ -1,110 +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_path2 = __toESM(require("path"), 1);
|
|
37
|
-
var import_tinyexec = require("tinyexec");
|
|
38
|
-
|
|
39
|
-
// src/utils/codegen.ts
|
|
40
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
41
|
-
var import_tinyglobby = require("tinyglobby");
|
|
42
|
-
function ident(code, tab = 1) {
|
|
43
|
-
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/plugins/last-modified.ts
|
|
47
|
-
var cache = /* @__PURE__ */ new Map();
|
|
48
|
-
var ExtendTypes = `{
|
|
49
|
-
/**
|
|
50
|
-
* Last modified date of document file, obtained from version control.
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
lastModified?: Date;
|
|
54
|
-
}`;
|
|
55
|
-
function lastModified(options = {}) {
|
|
56
|
-
const { versionControl = "git", filter = () => true } = options;
|
|
57
|
-
return {
|
|
58
|
-
name: "last-modified",
|
|
59
|
-
"index-file": {
|
|
60
|
-
generateTypeConfig() {
|
|
61
|
-
const lines = [];
|
|
62
|
-
lines.push("{");
|
|
63
|
-
lines.push(" DocData: {");
|
|
64
|
-
for (const collection of this.core.getConfig().collectionList) {
|
|
65
|
-
if (filter(collection.name)) {
|
|
66
|
-
lines.push(ident(`${collection.name}: ${ExtendTypes},`, 2));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
lines.push(" }");
|
|
70
|
-
lines.push("}");
|
|
71
|
-
return lines.join("\n");
|
|
72
|
-
},
|
|
73
|
-
serverOptions(options2) {
|
|
74
|
-
options2.doc ??= {};
|
|
75
|
-
options2.doc.passthroughs ??= [];
|
|
76
|
-
options2.doc.passthroughs.push("lastModified");
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
doc: {
|
|
80
|
-
async vfile(file) {
|
|
81
|
-
if (!filter(this.collection.name)) return;
|
|
82
|
-
if (versionControl === "git") {
|
|
83
|
-
const timestamp = await getGitTimestamp(this.filePath);
|
|
84
|
-
if (timestamp === void 0) return;
|
|
85
|
-
file.data["mdx-export"] ??= [];
|
|
86
|
-
file.data["mdx-export"].push({
|
|
87
|
-
name: "lastModified",
|
|
88
|
-
value: timestamp
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
async function getGitTimestamp(file) {
|
|
96
|
-
const cached = cache.get(file);
|
|
97
|
-
if (cached) return cached;
|
|
98
|
-
const timePromise = (async () => {
|
|
99
|
-
const out = await (0, import_tinyexec.x)(
|
|
100
|
-
"git",
|
|
101
|
-
["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
|
|
102
|
-
{
|
|
103
|
-
throwOnError: true
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
return new Date(out.stdout);
|
|
107
|
-
})();
|
|
108
|
-
cache.set(file, timePromise);
|
|
109
|
-
return timePromise.catch(() => void 0);
|
|
110
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { j as Plugin } from '../core-DTuP23zu.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
|
-
import 'fumadocs-core/source';
|
|
10
|
-
import '../runtime/types.cjs';
|
|
11
|
-
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
-
import 'fumadocs-core/toc';
|
|
13
|
-
import 'mdast';
|
|
14
|
-
import 'mdx/types';
|
|
15
|
-
|
|
16
|
-
interface LastModifiedPluginOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Version control to obtain the last modified time.
|
|
19
|
-
*
|
|
20
|
-
* - `git`: Requires `git` to be installed.
|
|
21
|
-
*
|
|
22
|
-
* If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`.
|
|
23
|
-
*
|
|
24
|
-
* @defaultValue 'git'
|
|
25
|
-
*/
|
|
26
|
-
versionControl?: 'git';
|
|
27
|
-
/**
|
|
28
|
-
* Filter the collections to include by names
|
|
29
|
-
*/
|
|
30
|
-
filter?: (collection: string) => boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Injects `lastModified` property to page exports.
|
|
34
|
-
*/
|
|
35
|
-
declare function lastModified(options?: LastModifiedPluginOptions): Plugin;
|
|
36
|
-
|
|
37
|
-
export { type LastModifiedPluginOptions, lastModified as default };
|
package/dist/runtime/browser.cjs
DELETED
|
@@ -1,93 +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
|
-
browser: () => browser,
|
|
24
|
-
createClientLoader: () => createClientLoader
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(browser_exports);
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
function browser() {
|
|
29
|
-
return {
|
|
30
|
-
doc(_name, glob) {
|
|
31
|
-
const out = {
|
|
32
|
-
raw: glob,
|
|
33
|
-
createClientLoader({ id = _name, ...options }) {
|
|
34
|
-
return createClientLoader(this.raw, { id, ...options });
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
var loaderStore = /* @__PURE__ */ new Map();
|
|
42
|
-
function createClientLoader(globEntries, options) {
|
|
43
|
-
const { id = "", component } = options;
|
|
44
|
-
const renderers = {};
|
|
45
|
-
const loaders = /* @__PURE__ */ new Map();
|
|
46
|
-
const store = loaderStore.get(id) ?? {
|
|
47
|
-
preloaded: /* @__PURE__ */ new Map()
|
|
48
|
-
};
|
|
49
|
-
loaderStore.set(id, store);
|
|
50
|
-
for (const k in globEntries) {
|
|
51
|
-
loaders.set(k.startsWith("./") ? k.slice(2) : k, globEntries[k]);
|
|
52
|
-
}
|
|
53
|
-
function getLoader(path) {
|
|
54
|
-
const loader = loaders.get(path);
|
|
55
|
-
if (!loader)
|
|
56
|
-
throw new Error(
|
|
57
|
-
`[createClientLoader] ${path} does not exist in available entries`
|
|
58
|
-
);
|
|
59
|
-
return loader;
|
|
60
|
-
}
|
|
61
|
-
function getRenderer(path) {
|
|
62
|
-
if (path in renderers) return renderers[path];
|
|
63
|
-
const OnDemand = (0, import_react.lazy)(async () => {
|
|
64
|
-
const loaded = await getLoader(path)();
|
|
65
|
-
return { default: (props) => component(loaded, props) };
|
|
66
|
-
});
|
|
67
|
-
renderers[path] = (props) => {
|
|
68
|
-
const cached = store.preloaded.get(path);
|
|
69
|
-
if (!cached) return (0, import_react.createElement)(OnDemand, props);
|
|
70
|
-
return component(cached, props);
|
|
71
|
-
};
|
|
72
|
-
return renderers[path];
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
async preload(path) {
|
|
76
|
-
const loaded = await getLoader(path)();
|
|
77
|
-
store.preloaded.set(path, loaded);
|
|
78
|
-
return loaded;
|
|
79
|
-
},
|
|
80
|
-
getComponent(path) {
|
|
81
|
-
return getRenderer(path);
|
|
82
|
-
},
|
|
83
|
-
useContent(path, props) {
|
|
84
|
-
const Comp = this.getComponent(path);
|
|
85
|
-
return (0, import_react.createElement)(Comp, props);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
-
0 && (module.exports = {
|
|
91
|
-
browser,
|
|
92
|
-
createClientLoader
|
|
93
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ReactNode, FC } from 'react';
|
|
2
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { D as DocCollection, a as DocsCollection } from '../core-DTuP23zu.cjs';
|
|
4
|
-
import { CompiledMDXProperties } from '../index.cjs';
|
|
5
|
-
import { InternalTypeConfig } from './types.cjs';
|
|
6
|
-
import '@mdx-js/mdx';
|
|
7
|
-
import 'unified';
|
|
8
|
-
import 'fumadocs-core/mdx-plugins';
|
|
9
|
-
import 'zod';
|
|
10
|
-
import 'chokidar';
|
|
11
|
-
import 'vfile';
|
|
12
|
-
import 'fumadocs-core/source';
|
|
13
|
-
import 'fumadocs-core/toc';
|
|
14
|
-
import 'mdx/types';
|
|
15
|
-
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
16
|
-
import 'mdast';
|
|
17
|
-
|
|
18
|
-
type CompiledMDXFile<Name extends string, Frontmatter, TC extends InternalTypeConfig> = CompiledMDXProperties<Frontmatter> & TC['DocData'][Name] & Record<string, unknown>;
|
|
19
|
-
interface ClientLoaderOptions<Doc, Props> {
|
|
20
|
-
/**
|
|
21
|
-
* Loader ID (usually your collection name)
|
|
22
|
-
*
|
|
23
|
-
* The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
|
|
24
|
-
*
|
|
25
|
-
* We use loader ID to share cache between multiple instances of client loader.
|
|
26
|
-
*
|
|
27
|
-
* @defaultValue ''
|
|
28
|
-
*/
|
|
29
|
-
id?: string;
|
|
30
|
-
component: (loaded: Doc, props: Props) => ReactNode;
|
|
31
|
-
}
|
|
32
|
-
interface ClientLoader<Doc, Props> {
|
|
33
|
-
preload: (path: string) => Promise<Doc>;
|
|
34
|
-
/**
|
|
35
|
-
* Get a component that renders content with `React.lazy`.
|
|
36
|
-
*/
|
|
37
|
-
getComponent: (path: string) => FC<Props>;
|
|
38
|
-
/**
|
|
39
|
-
* Get react nodes that renders content with `React.lazy`.
|
|
40
|
-
*/
|
|
41
|
-
useContent: (path: string, props: Props) => ReactNode;
|
|
42
|
-
}
|
|
43
|
-
type BrowserCreate<Config, TC extends InternalTypeConfig> = ReturnType<typeof browser<Config, TC>>;
|
|
44
|
-
interface DocCollectionEntry<Name extends string = string, Frontmatter = unknown, TC extends InternalTypeConfig = InternalTypeConfig> {
|
|
45
|
-
raw: Record<string, () => Promise<CompiledMDXFile<Name, Frontmatter, TC>>>;
|
|
46
|
-
createClientLoader: <Props extends object>(options: ClientLoaderOptions<CompiledMDXFile<Name, Frontmatter, TC>, Props>) => ClientLoader<CompiledMDXFile<Name, Frontmatter, TC>, Props>;
|
|
47
|
-
}
|
|
48
|
-
declare function browser<Config, TC extends InternalTypeConfig>(): {
|
|
49
|
-
doc<Name extends keyof Config & string>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC> : never;
|
|
50
|
-
};
|
|
51
|
-
declare function createClientLoader<Doc = CompiledMDXProperties, Props extends object = object>(globEntries: Record<string, () => Promise<Doc>>, options: ClientLoaderOptions<Doc, Props>): ClientLoader<Doc, Props>;
|
|
52
|
-
|
|
53
|
-
export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry, browser, createClientLoader };
|