fumadocs-core 16.2.4 → 16.2.5

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.
@@ -0,0 +1,12 @@
1
+ // src/content/mdx/util.ts
2
+ async function resolvePlugins(def, options = []) {
3
+ const list = (await Promise.all(def(Array.isArray(options) ? options : []))).filter((v) => v !== false);
4
+ if (typeof options === "function") {
5
+ return Promise.all(options(list));
6
+ }
7
+ return list;
8
+ }
9
+
10
+ export {
11
+ resolvePlugins
12
+ };
@@ -0,0 +1,31 @@
1
+ import { ProcessorOptions } from '@mdx-js/mdx';
2
+ import { RehypeCodeOptions } from '../../mdx-plugins/rehype-code.js';
3
+ import { RemarkImageOptions } from '../../mdx-plugins/remark-image.js';
4
+ import { StructureOptions } from '../../mdx-plugins/remark-structure.js';
5
+ import { RemarkHeadingOptions } from '../../mdx-plugins/remark-heading.js';
6
+ import { RemarkCodeTabOptions } from '../../mdx-plugins/remark-code-tab.js';
7
+ import { RemarkNpmOptions } from '../../mdx-plugins/remark-npm.js';
8
+ import { R as ResolvePlugins } from '../../util-bZU2QeJ2.js';
9
+ import 'hast';
10
+ import '@shikijs/rehype';
11
+ import 'unified';
12
+ import 'shiki';
13
+ import 'mdast';
14
+ import 'mdast-util-mdx-jsx';
15
+
16
+ type MDXBundlerPresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
17
+ rehypePlugins?: ResolvePlugins;
18
+ remarkPlugins?: ResolvePlugins;
19
+ remarkStructureOptions?: StructureOptions | false;
20
+ remarkHeadingOptions?: RemarkHeadingOptions;
21
+ remarkImageOptions?: RemarkImageOptions | false;
22
+ remarkCodeTabOptions?: RemarkCodeTabOptions | false;
23
+ remarkNpmOptions?: RemarkNpmOptions | false;
24
+ rehypeCodeOptions?: RehypeCodeOptions | false;
25
+ };
26
+ /**
27
+ * apply MDX processor presets
28
+ */
29
+ declare function mdxPreset(options?: MDXBundlerPresetOptions): Promise<ProcessorOptions>;
30
+
31
+ export { type MDXBundlerPresetOptions, mdxPreset };
@@ -0,0 +1,72 @@
1
+ import {
2
+ resolvePlugins
3
+ } from "../../chunk-GINBKBVQ.js";
4
+ import "../../chunk-U67V476Y.js";
5
+
6
+ // src/content/mdx/preset-bundler.ts
7
+ async function mdxPreset(options = {}) {
8
+ const {
9
+ rehypeCodeOptions,
10
+ remarkImageOptions,
11
+ remarkHeadingOptions,
12
+ remarkStructureOptions,
13
+ remarkCodeTabOptions,
14
+ remarkNpmOptions,
15
+ ...mdxOptions
16
+ } = options;
17
+ const remarkPlugins = await resolvePlugins(
18
+ (v) => [
19
+ import("remark-gfm").then((mod) => mod.default),
20
+ import("../../mdx-plugins/remark-heading.js").then((mod) => [
21
+ mod.remarkHeading,
22
+ {
23
+ generateToc: false,
24
+ ...remarkHeadingOptions
25
+ }
26
+ ]),
27
+ remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [
28
+ mod.remarkImage,
29
+ {
30
+ ...remarkImageOptions,
31
+ useImport: remarkImageOptions?.useImport ?? true
32
+ }
33
+ ]),
34
+ remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [
35
+ mod.remarkCodeTab,
36
+ remarkCodeTabOptions
37
+ ]),
38
+ remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
39
+ mod.remarkNpm,
40
+ remarkNpmOptions
41
+ ]),
42
+ ...v,
43
+ remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
44
+ mod.remarkStructure,
45
+ {
46
+ exportAs: "structuredData",
47
+ ...remarkStructureOptions
48
+ }
49
+ ])
50
+ ],
51
+ mdxOptions.remarkPlugins
52
+ );
53
+ const rehypePlugins = await resolvePlugins(
54
+ (v) => [
55
+ rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
56
+ mod.rehypeCode,
57
+ rehypeCodeOptions
58
+ ]),
59
+ ...v,
60
+ import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
61
+ ],
62
+ mdxOptions.rehypePlugins
63
+ );
64
+ return {
65
+ ...mdxOptions,
66
+ remarkPlugins,
67
+ rehypePlugins
68
+ };
69
+ }
70
+ export {
71
+ mdxPreset
72
+ };
@@ -0,0 +1,31 @@
1
+ import { ProcessorOptions } from '@mdx-js/mdx';
2
+ import { RehypeCodeOptions } from '../../mdx-plugins/rehype-code.js';
3
+ import { RemarkImageOptions } from '../../mdx-plugins/remark-image.js';
4
+ import { StructureOptions } from '../../mdx-plugins/remark-structure.js';
5
+ import { RemarkHeadingOptions } from '../../mdx-plugins/remark-heading.js';
6
+ import { RemarkCodeTabOptions } from '../../mdx-plugins/remark-code-tab.js';
7
+ import { RemarkNpmOptions } from '../../mdx-plugins/remark-npm.js';
8
+ import { R as ResolvePlugins } from '../../util-bZU2QeJ2.js';
9
+ import 'hast';
10
+ import '@shikijs/rehype';
11
+ import 'unified';
12
+ import 'shiki';
13
+ import 'mdast';
14
+ import 'mdast-util-mdx-jsx';
15
+
16
+ type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
17
+ rehypePlugins?: ResolvePlugins;
18
+ remarkPlugins?: ResolvePlugins;
19
+ remarkStructureOptions?: StructureOptions | false;
20
+ remarkHeadingOptions?: RemarkHeadingOptions;
21
+ remarkImageOptions?: RemarkImageOptions | false;
22
+ remarkCodeTabOptions?: RemarkCodeTabOptions | false;
23
+ remarkNpmOptions?: RemarkNpmOptions | false;
24
+ rehypeCodeOptions?: RehypeCodeOptions | false;
25
+ };
26
+ /**
27
+ * apply MDX processor presets
28
+ */
29
+ declare function mdxPreset(options?: MDXRuntimePresetOptions): Promise<ProcessorOptions>;
30
+
31
+ export { type MDXRuntimePresetOptions, mdxPreset };
@@ -0,0 +1,71 @@
1
+ import {
2
+ resolvePlugins
3
+ } from "../../chunk-GINBKBVQ.js";
4
+ import "../../chunk-U67V476Y.js";
5
+
6
+ // src/content/mdx/preset-runtime.ts
7
+ async function mdxPreset(options = {}) {
8
+ const {
9
+ rehypeCodeOptions,
10
+ remarkImageOptions,
11
+ remarkHeadingOptions,
12
+ remarkStructureOptions,
13
+ remarkCodeTabOptions,
14
+ remarkNpmOptions,
15
+ outputFormat = "function-body",
16
+ ...mdxOptions
17
+ } = options;
18
+ const remarkPlugins = await resolvePlugins(
19
+ (v) => [
20
+ import("remark-gfm").then((mod) => mod.default),
21
+ import("../../mdx-plugins/remark-heading.js").then((mod) => [
22
+ mod.remarkHeading,
23
+ {
24
+ generateToc: false,
25
+ ...remarkHeadingOptions
26
+ }
27
+ ]),
28
+ remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [
29
+ mod.remarkImage,
30
+ remarkImageOptions
31
+ ]),
32
+ remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [
33
+ mod.remarkCodeTab,
34
+ remarkCodeTabOptions
35
+ ]),
36
+ remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
37
+ mod.remarkNpm,
38
+ remarkNpmOptions
39
+ ]),
40
+ ...v,
41
+ remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
42
+ mod.remarkStructure,
43
+ {
44
+ exportAs: "structuredData",
45
+ ...remarkStructureOptions
46
+ }
47
+ ])
48
+ ],
49
+ mdxOptions.remarkPlugins
50
+ );
51
+ const rehypePlugins = await resolvePlugins(
52
+ (v) => [
53
+ rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
54
+ mod.rehypeCode,
55
+ rehypeCodeOptions
56
+ ]),
57
+ ...v,
58
+ import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
59
+ ],
60
+ mdxOptions.rehypePlugins
61
+ );
62
+ return {
63
+ ...mdxOptions,
64
+ outputFormat,
65
+ remarkPlugins,
66
+ rehypePlugins
67
+ };
68
+ }
69
+ export {
70
+ mdxPreset
71
+ };
@@ -59,18 +59,30 @@ type _ConfigUnion_<T extends Record<string, Source>> = {
59
59
  } : never;
60
60
  }[keyof T];
61
61
  declare function multiple<T extends Record<string, Source>>(sources: T): Source<_ConfigUnion_<T>>;
62
+ declare function source<Page extends PageData, Meta extends MetaData>(config: {
63
+ pages: VirtualPage<Page>[];
64
+ metas: VirtualMeta<Meta>[];
65
+ }): Source<{
66
+ pageData: Page;
67
+ metaData: Meta;
68
+ }>;
62
69
  /**
63
- * map virtual files in source
70
+ * update a source object in-place.
64
71
  */
65
- declare function map<Config extends SourceConfig>(source: Source<Config>): {
66
- page<$Page extends PageData>(fn: (entry: VirtualPage<Config["pageData"]>) => VirtualPage<$Page>): Source<{
67
- pageData: $Page;
72
+ declare function update<Config extends SourceConfig>(source: Source<Config>): {
73
+ files<Page extends PageData, Meta extends MetaData>(fn: (files: VirtualFile<Config>[]) => (VirtualPage<Page> | VirtualMeta<Meta>)[]): typeof update<{
74
+ pageData: Page;
75
+ metaData: Meta;
76
+ }>;
77
+ page<V extends PageData>(fn: (page: VirtualPage<Config["pageData"]>) => VirtualPage<V>): typeof update<{
78
+ pageData: V;
68
79
  metaData: Config["metaData"];
69
80
  }>;
70
- meta<$Meta extends MetaData>(fn: (entry: VirtualMeta<Config["metaData"]>) => VirtualMeta<$Meta>): Source<{
81
+ meta<V extends MetaData>(fn: (meta: VirtualMeta<Config["metaData"]>) => VirtualMeta<V>): typeof update<{
71
82
  pageData: Config["pageData"];
72
- metaData: $Meta;
83
+ metaData: V;
73
84
  }>;
85
+ build(): Source<Config>;
74
86
  };
75
87
 
76
88
  /**
@@ -306,4 +318,4 @@ declare function loader<Config extends SourceConfig, I18n extends I18nConfig | u
306
318
  type InferPageType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Page<Config['source']['pageData']> : never;
307
319
  type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Meta<Config['source']['metaData']> : never;
308
320
 
309
- export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaData as M, type PageData as P, type ResolvedLoaderConfig as R, type Source as S, type VirtualFile as V, type _ConfigUnion_ as _, type SourceConfig as a, map as b, type LoaderConfig as c, type LoaderOptions as d, type Page as e, type Meta as f, type LoaderOutput as g, createGetUrl as h, type InferMetaType as i, type PageTreeBuilderContext as j, type PageTreeTransformer as k, loader as l, multiple as m, type PageTreeOptions as n, type PageTreeBuilder as o, createPageTreeBuilder as p, type ContentStorageFile as q, buildContentStorage as r, type LoaderPluginOption as s, buildPlugins as t };
321
+ export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaData as M, type PageData as P, type ResolvedLoaderConfig as R, type Source as S, type VirtualFile as V, type _ConfigUnion_ as _, type SourceConfig as a, type LoaderConfig as b, type LoaderOptions as c, type Page as d, type Meta as e, type LoaderOutput as f, createGetUrl as g, type InferMetaType as h, type PageTreeBuilderContext as i, type PageTreeTransformer as j, type PageTreeOptions as k, loader as l, multiple as m, type PageTreeBuilder as n, createPageTreeBuilder as o, type ContentStorageFile as p, buildContentStorage as q, type LoaderPluginOption as r, source as s, buildPlugins as t, update as u };
@@ -3,7 +3,7 @@ import { StructuredData } from '../mdx-plugins/remark-structure.js';
3
3
  import { SortedResult } from './index.js';
4
4
  export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
5
5
  import { I18nConfig } from '../i18n/index.js';
6
- import { g as LoaderOutput, c as LoaderConfig, I as InferPageType } from '../loader-qkSHi822.js';
6
+ import { f as LoaderOutput, b as LoaderConfig, I as InferPageType } from '../loader-BvlPPJX0.js';
7
7
  import 'mdast';
8
8
  import 'unified';
9
9
  import 'mdast-util-mdx-jsx';
@@ -1,4 +1,4 @@
1
- export { C as ContentStorage, q as ContentStorageFile, F as FileSystem, i as InferMetaType, I as InferPageType, c as LoaderConfig, d as LoaderOptions, g as LoaderOutput, L as LoaderPlugin, s as LoaderPluginOption, f as Meta, M as MetaData, e as Page, P as PageData, o as PageTreeBuilder, j as PageTreeBuilderContext, n as PageTreeOptions, k as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, r as buildContentStorage, t as buildPlugins, h as createGetUrl, p as createPageTreeBuilder, l as loader, b as map, m as multiple } from '../loader-qkSHi822.js';
1
+ export { C as ContentStorage, p as ContentStorageFile, F as FileSystem, h as InferMetaType, I as InferPageType, b as LoaderConfig, c as LoaderOptions, f as LoaderOutput, L as LoaderPlugin, r as LoaderPluginOption, e as Meta, M as MetaData, d as Page, P as PageData, n as PageTreeBuilder, i as PageTreeBuilderContext, k as PageTreeOptions, j as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, q as buildContentStorage, t as buildPlugins, g as createGetUrl, o as createPageTreeBuilder, l as loader, m as multiple, s as source, u as update } from '../loader-BvlPPJX0.js';
2
2
  import '../definitions-pJ7PybYY.js';
3
3
  import 'react';
4
4
  import '../i18n/index.js';
@@ -21,8 +21,8 @@ import "../chunk-U67V476Y.js";
21
21
  // src/source/source.ts
22
22
  function multiple(sources) {
23
23
  const out = { files: [] };
24
- for (const [type, source] of Object.entries(sources)) {
25
- for (const file of source.files) {
24
+ for (const [type, source2] of Object.entries(sources)) {
25
+ for (const file of source2.files) {
26
26
  out.files.push({
27
27
  ...file,
28
28
  data: {
@@ -34,21 +34,33 @@ function multiple(sources) {
34
34
  }
35
35
  return out;
36
36
  }
37
- function map(source) {
37
+ function source(config) {
38
38
  return {
39
+ files: [...config.pages, ...config.metas]
40
+ };
41
+ }
42
+ function update(source2) {
43
+ return {
44
+ files(fn) {
45
+ source2.files = fn(source2.files);
46
+ return this;
47
+ },
39
48
  page(fn) {
40
- return {
41
- files: source.files.map(
42
- (file) => file.type === "page" ? fn(file) : file
43
- )
44
- };
49
+ for (let i = 0; i < source2.files.length; i++) {
50
+ const file = source2.files[i];
51
+ if (file.type === "page") source2.files[i] = fn(file);
52
+ }
53
+ return this;
45
54
  },
46
55
  meta(fn) {
47
- return {
48
- files: source.files.map(
49
- (file) => file.type === "meta" ? fn(file) : file
50
- )
51
- };
56
+ for (let i = 0; i < source2.files.length; i++) {
57
+ const file = source2.files[i];
58
+ if (file.type === "meta") source2.files[i] = fn(file);
59
+ }
60
+ return this;
61
+ },
62
+ build() {
63
+ return source2;
52
64
  }
53
65
  };
54
66
  }
@@ -145,7 +157,7 @@ var parsers = {
145
157
  };
146
158
  function buildContentStorage(loaderConfig, defaultLanguage) {
147
159
  const {
148
- source,
160
+ source: source2,
149
161
  plugins = [],
150
162
  i18n = {
151
163
  defaultLanguage,
@@ -156,7 +168,7 @@ function buildContentStorage(loaderConfig, defaultLanguage) {
156
168
  const parser = parsers[i18n.parser ?? "dot"];
157
169
  const storages = {};
158
170
  const normalized = /* @__PURE__ */ new Map();
159
- for (const inputFile of source.files) {
171
+ for (const inputFile of source2.files) {
160
172
  let file;
161
173
  if (inputFile.type === "page") {
162
174
  file = {
@@ -298,15 +310,15 @@ function createPageTreeBuilder(loaderConfig) {
298
310
  };
299
311
  }
300
312
  function createFlattenPathResolver(storage) {
301
- const map2 = /* @__PURE__ */ new Map();
313
+ const map = /* @__PURE__ */ new Map();
302
314
  const files = storage.getFiles();
303
315
  for (const file of files) {
304
316
  const content = storage.read(file);
305
317
  const flattenPath = file.substring(0, file.length - extname(file).length);
306
- map2.set(flattenPath + "." + content.format, file);
318
+ map.set(flattenPath + "." + content.format, file);
307
319
  }
308
320
  return (name, format) => {
309
- return map2.get(name + "." + format) ?? name;
321
+ return map.get(name + "." + format) ?? name;
310
322
  };
311
323
  }
312
324
  function createPageTreeBuilderUtils(ctx) {
@@ -733,11 +745,11 @@ function loader(...args) {
733
745
  }
734
746
  };
735
747
  }
736
- function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
748
+ function resolveConfig(source2, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
737
749
  let config = {
738
750
  ...base,
739
751
  url: url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n),
740
- source,
752
+ source: source2,
741
753
  plugins: buildPlugins([
742
754
  slugsPlugin(slugs),
743
755
  icon && iconPlugin(icon),
@@ -758,6 +770,7 @@ export {
758
770
  createGetUrl,
759
771
  getSlugs,
760
772
  loader,
761
- map,
762
- multiple
773
+ multiple,
774
+ source,
775
+ update
763
776
  };
@@ -1,4 +1,4 @@
1
- import { L as LoaderPlugin } from '../../loader-qkSHi822.js';
1
+ import { L as LoaderPlugin } from '../../loader-BvlPPJX0.js';
2
2
  import { icons } from 'lucide-react';
3
3
  import '../../definitions-pJ7PybYY.js';
4
4
  import 'react';
@@ -0,0 +1,6 @@
1
+ import { Pluggable } from 'unified';
2
+
3
+ type Thenable<T> = T | PromiseLike<T>;
4
+ type ResolvePlugins = Thenable<Pluggable>[] | ((v: Pluggable[]) => Thenable<Pluggable>[]);
5
+
6
+ export type { ResolvePlugins as R };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.2.4",
3
+ "version": "16.2.5",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Fumadocs",
@@ -111,8 +111,8 @@
111
111
  "dependencies": {
112
112
  "@formatjs/intl-localematcher": "^0.6.2",
113
113
  "@orama/orama": "^3.1.16",
114
- "@shikijs/rehype": "^3.19.0",
115
- "@shikijs/transformers": "^3.19.0",
114
+ "@shikijs/rehype": "^3.20.0",
115
+ "@shikijs/transformers": "^3.20.0",
116
116
  "estree-util-value-to-estree": "^3.5.0",
117
117
  "github-slugger": "^2.0.0",
118
118
  "hast-util-to-estree": "^3.1.3",
@@ -125,14 +125,14 @@
125
125
  "remark-gfm": "^4.0.1",
126
126
  "remark-rehype": "^11.1.2",
127
127
  "scroll-into-view-if-needed": "^3.1.0",
128
- "shiki": "^3.19.0",
128
+ "shiki": "^3.20.0",
129
129
  "unist-util-visit": "^5.0.0"
130
130
  },
131
131
  "devDependencies": {
132
132
  "@mdx-js/mdx": "^3.1.1",
133
133
  "@mixedbread/sdk": "^0.46.0",
134
- "@orama/core": "^1.2.13",
135
- "@tanstack/react-router": "1.140.0",
134
+ "@orama/core": "^1.2.14",
135
+ "@tanstack/react-router": "1.136.18",
136
136
  "@types/estree-jsx": "^1.0.5",
137
137
  "@types/hast": "^3.0.4",
138
138
  "@types/mdast": "^4.0.4",
@@ -141,10 +141,10 @@
141
141
  "@types/react": "^19.2.7",
142
142
  "@types/react-dom": "^19.2.3",
143
143
  "algoliasearch": "5.46.0",
144
- "lucide-react": "^0.556.0",
144
+ "lucide-react": "^0.561.0",
145
145
  "mdast-util-mdx-jsx": "^3.2.0",
146
146
  "mdast-util-mdxjs-esm": "^2.0.1",
147
- "next": "16.0.8",
147
+ "next": "16.0.10",
148
148
  "react-router": "^7.10.1",
149
149
  "remark-directive": "^4.0.0",
150
150
  "remark-mdx": "^3.1.1",
@@ -152,7 +152,7 @@
152
152
  "typescript": "^5.9.3",
153
153
  "unified": "^11.0.5",
154
154
  "vfile": "^6.0.3",
155
- "waku": "^0.27.3",
155
+ "waku": "^0.27.4",
156
156
  "zod": "^4.1.13",
157
157
  "eslint-config-custom": "0.0.0",
158
158
  "tsconfig": "0.0.0"