fumadocs-core 15.7.8 → 15.7.10

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.
@@ -7,7 +7,7 @@ var defaultThemes = {
7
7
  dark: "github-dark"
8
8
  };
9
9
  var highlighters = /* @__PURE__ */ new Map();
10
- async function _highlight(code, options) {
10
+ async function highlightHast(code, options) {
11
11
  const {
12
12
  lang: initialLang,
13
13
  fallbackLanguage,
@@ -101,11 +101,12 @@ async function getHighlighter(engineType, options) {
101
101
  });
102
102
  }
103
103
  async function highlight(code, options) {
104
- return _renderHighlight(await _highlight(code, options), options);
104
+ return _renderHighlight(await highlightHast(code, options), options);
105
105
  }
106
106
 
107
107
  export {
108
108
  defaultThemes,
109
+ highlightHast,
109
110
  getHighlighter,
110
111
  highlight
111
112
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  removeUndefined
3
- } from "./chunk-KAOEMCTI.js";
3
+ } from "./chunk-ZMWYLUDP.js";
4
4
  import {
5
5
  createContentHighlighter
6
6
  } from "./chunk-CNWEGOUF.js";
@@ -0,0 +1,21 @@
1
+ // src/utils/remove-undefined.ts
2
+ function removeUndefined(value, deep = false) {
3
+ const obj = value;
4
+ for (const key in obj) {
5
+ if (obj[key] === void 0) delete obj[key];
6
+ if (!deep) continue;
7
+ const entry = obj[key];
8
+ if (typeof entry === "object" && entry !== null) {
9
+ removeUndefined(entry, deep);
10
+ continue;
11
+ }
12
+ if (Array.isArray(entry)) {
13
+ for (const item of entry) removeUndefined(item, deep);
14
+ }
15
+ }
16
+ return value;
17
+ }
18
+
19
+ export {
20
+ removeUndefined
21
+ };
@@ -3,6 +3,7 @@ import { HighlightOptions } from './index.js';
3
3
  import 'shiki';
4
4
  import 'shiki/themes';
5
5
  import 'hast-util-to-jsx-runtime';
6
+ import 'hast';
6
7
 
7
8
  declare function useShiki(code: string, options: HighlightOptions & {
8
9
  /**
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  highlight
4
- } from "../chunk-NJLFLPV4.js";
4
+ } from "../chunk-HN2NUUD2.js";
5
5
  import "../chunk-JSBRDJBE.js";
6
6
 
7
7
  // src/highlight/client.tsx
@@ -2,6 +2,7 @@ import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta, Awaitable, R
2
2
  import { BundledTheme } from 'shiki/themes';
3
3
  import { Components } from 'hast-util-to-jsx-runtime';
4
4
  import { ReactNode } from 'react';
5
+ import { Root } from 'hast';
5
6
 
6
7
  type HighlightOptionsCommon = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
7
8
  engine?: 'js' | 'oniguruma' | Awaitable<RegexEngine>;
@@ -10,6 +11,7 @@ type HighlightOptionsCommon = CodeToHastOptionsCommon<BundledLanguage> & CodeOpt
10
11
  };
11
12
  type HighlightOptionsThemes = CodeOptionsThemes<BundledTheme>;
12
13
  type HighlightOptions = HighlightOptionsCommon & (HighlightOptionsThemes | Record<never, never>);
14
+ declare function highlightHast(code: string, options: HighlightOptions): Promise<Root>;
13
15
  /**
14
16
  * Get Shiki highlighter instance of Fumadocs (mostly for internal use, don't recommend you to use it).
15
17
  *
@@ -19,4 +21,4 @@ type HighlightOptions = HighlightOptionsCommon & (HighlightOptionsThemes | Recor
19
21
  declare function getHighlighter(engineType: 'js' | 'oniguruma' | 'custom', options: BundledHighlighterOptions<BundledLanguage, BundledTheme>): Promise<Highlighter>;
20
22
  declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
21
23
 
22
- export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, highlight };
24
+ export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, highlight, highlightHast };
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  getHighlighter,
3
- highlight
4
- } from "../chunk-NJLFLPV4.js";
3
+ highlight,
4
+ highlightHast
5
+ } from "../chunk-HN2NUUD2.js";
5
6
  import "../chunk-JSBRDJBE.js";
6
7
  export {
7
8
  getHighlighter,
8
- highlight
9
+ highlight,
10
+ highlightHast
9
11
  };
@@ -0,0 +1,15 @@
1
+ import { createI18nMiddleware as createI18nMiddleware$1 } from './middleware.js';
2
+ export { I18nConfig, defineI18n } from './index.js';
3
+ import 'next/dist/server/web/types';
4
+
5
+ /**
6
+ * From what I observed, Next.js will somehow pick "browser" export instead of "import" in middleware.
7
+ * Hence, `createI18nMiddleware` is not available from `fumadocs-core/i18n`, even with compatibility layer.
8
+ *
9
+ * I hope Next.js will fix it in the future, before old projects bump deps and face errors.
10
+ *
11
+ * @deprecated Import from `fumadocs-core/i18n/middleware` instead
12
+ */
13
+ declare const createI18nMiddleware: typeof createI18nMiddleware$1;
14
+
15
+ export { createI18nMiddleware };
@@ -0,0 +1,19 @@
1
+ import {
2
+ defineI18n
3
+ } from "../chunk-HUTQC33E.js";
4
+ import "../chunk-JSBRDJBE.js";
5
+
6
+ // src/i18n/legacy.ts
7
+ var createI18nMiddleware = (...args) => {
8
+ console.warn(
9
+ "[Fumadocs Core] Please import i18n middleware from `fumadocs-core/i18n/middleware` instead, this export will soon be removed."
10
+ );
11
+ const middleware = import("./middleware.js").then(
12
+ (res) => res.createI18nMiddleware(...args)
13
+ );
14
+ return async (...args2) => (await middleware)(...args2);
15
+ };
16
+ export {
17
+ createI18nMiddleware,
18
+ defineI18n
19
+ };
@@ -1,5 +1,5 @@
1
- import { I18nConfig } from './index.js';
2
1
  import { NextMiddleware } from 'next/dist/server/web/types';
2
+ import { I18nConfig } from './index.js';
3
3
 
4
4
  interface MiddlewareOptions extends I18nConfig {
5
5
  /**
@@ -1,7 +1,73 @@
1
- import {
2
- createI18nMiddleware
3
- } from "../chunk-KLUGJRZC.js";
4
1
  import "../chunk-JSBRDJBE.js";
2
+
3
+ // src/i18n/middleware.ts
4
+ import { match as matchLocale } from "@formatjs/intl-localematcher";
5
+ import Negotiator from "negotiator";
6
+ import { NextResponse } from "next/server";
7
+ var COOKIE = "FD_LOCALE";
8
+ function getLocale(request, locales, defaultLanguage) {
9
+ const negotiatorHeaders = {};
10
+ request.headers.forEach((value, key) => {
11
+ negotiatorHeaders[key] = value;
12
+ });
13
+ const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
14
+ locales
15
+ );
16
+ return matchLocale(languages, locales, defaultLanguage);
17
+ }
18
+ var defaultFormat = (locale, path) => {
19
+ return `/${locale}/${path}`;
20
+ };
21
+ function createI18nMiddleware({
22
+ languages,
23
+ defaultLanguage,
24
+ format = defaultFormat,
25
+ hideLocale = "never"
26
+ }) {
27
+ function getUrl(request, pathname, locale) {
28
+ if (!locale) {
29
+ return new URL(
30
+ pathname.startsWith("/") ? pathname : `/${pathname}`,
31
+ request.url
32
+ );
33
+ }
34
+ return new URL(
35
+ format(locale, pathname.startsWith("/") ? pathname.slice(1) : pathname),
36
+ request.url
37
+ );
38
+ }
39
+ return (request) => {
40
+ const inputPath = `${request.nextUrl.pathname}${request.nextUrl.search}`;
41
+ const pathLocale = languages.find(
42
+ (locale) => inputPath.startsWith(`/${locale}/`) || inputPath === `/${locale}`
43
+ );
44
+ if (!pathLocale) {
45
+ if (hideLocale === "default-locale") {
46
+ return NextResponse.rewrite(
47
+ getUrl(request, inputPath, defaultLanguage)
48
+ );
49
+ }
50
+ const preferred = getLocale(request, languages, defaultLanguage);
51
+ if (hideLocale === "always") {
52
+ const locale = request.cookies.get(COOKIE)?.value ?? preferred;
53
+ return NextResponse.rewrite(getUrl(request, inputPath, locale));
54
+ }
55
+ return NextResponse.redirect(getUrl(request, inputPath, preferred));
56
+ }
57
+ if (hideLocale === "always") {
58
+ const path = inputPath.slice(`/${pathLocale}`.length);
59
+ const res = NextResponse.redirect(getUrl(request, path));
60
+ res.cookies.set(COOKIE, pathLocale);
61
+ return res;
62
+ }
63
+ if (hideLocale === "default-locale" && pathLocale === defaultLanguage) {
64
+ return NextResponse.redirect(
65
+ getUrl(request, inputPath.slice(`/${pathLocale}`.length))
66
+ );
67
+ }
68
+ return NextResponse.next();
69
+ };
70
+ }
5
71
  export {
6
72
  createI18nMiddleware
7
73
  };
@@ -8,11 +8,11 @@ export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as
8
8
  export { a as RemarkCodeTabOptions, R as RemarkHeadingOptions, b as remarkCodeTab, r as remarkHeading } from '../remark-code-tab-DmyIyi6m.js';
9
9
  import { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
10
10
 
11
- interface CodeBlockIcon {
11
+ type CodeBlockIcon = {
12
12
  viewBox: string;
13
13
  fill: string;
14
14
  d: string;
15
- }
15
+ } | string;
16
16
  interface IconOptions {
17
17
  shortcuts?: Record<string, string>;
18
18
  extend?: Record<string, CodeBlockIcon>;
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  defaultThemes,
7
7
  getHighlighter
8
- } from "../chunk-NJLFLPV4.js";
8
+ } from "../chunk-HN2NUUD2.js";
9
9
  import "../chunk-JSBRDJBE.js";
10
10
 
11
11
  // src/mdx-plugins/index.ts
@@ -161,7 +161,7 @@ function transformerIcon(options = {}) {
161
161
  const iconName = lang in shortcuts ? shortcuts[lang] : lang;
162
162
  const icon = iconName in icons ? icons[iconName] : defaultIcon;
163
163
  if (icon) {
164
- pre.properties.icon = `<svg viewBox="${icon.viewBox}"><path d="${icon.d}" fill="${icon.fill}" /></svg>`;
164
+ pre.properties.icon = typeof icon === "string" ? icon : `<svg viewBox="${icon.viewBox}"><path d="${icon.d}" fill="${icon.fill}" /></svg>`;
165
165
  }
166
166
  return pre;
167
167
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  removeUndefined
3
- } from "./chunk-KAOEMCTI.js";
3
+ } from "./chunk-ZMWYLUDP.js";
4
4
  import {
5
5
  createContentHighlighter
6
6
  } from "./chunk-CNWEGOUF.js";
@@ -73,11 +73,11 @@ function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty
73
73
  return searchDocs(debouncedValue, client);
74
74
  }
75
75
  if (client.type === "orama-cloud") {
76
- const { searchDocs } = await import("../orama-cloud-BYTAI6QU.js");
76
+ const { searchDocs } = await import("../orama-cloud-TXCWJTK3.js");
77
77
  return searchDocs(debouncedValue, client);
78
78
  }
79
79
  if (client.type === "static") {
80
- const { search: search2 } = await import("../static-IWYDJ3C5.js");
80
+ const { search: search2 } = await import("../static-K5IAOO6T.js");
81
81
  return search2(debouncedValue, client);
82
82
  }
83
83
  if (client.type === "mixedbread") {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  searchAdvanced,
3
3
  searchSimple
4
- } from "../chunk-KIJ7AMBP.js";
5
- import "../chunk-KAOEMCTI.js";
4
+ } from "../chunk-R7I54YHO.js";
5
+ import "../chunk-ZMWYLUDP.js";
6
6
  import {
7
7
  createContentHighlighter
8
8
  } from "../chunk-CNWEGOUF.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  searchAdvanced,
3
3
  searchSimple
4
- } from "./chunk-KIJ7AMBP.js";
5
- import "./chunk-KAOEMCTI.js";
4
+ } from "./chunk-R7I54YHO.js";
5
+ import "./chunk-ZMWYLUDP.js";
6
6
  import "./chunk-CNWEGOUF.js";
7
7
  import "./chunk-JSBRDJBE.js";
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.7.8",
3
+ "version": "15.7.10",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -62,8 +62,8 @@
62
62
  },
63
63
  "./i18n": {
64
64
  "browser": "./dist/i18n/index.js",
65
- "import": "./dist/i18n/index.server.js",
66
- "types": "./dist/i18n/index.server.d.ts"
65
+ "import": "./dist/i18n/legacy.js",
66
+ "types": "./dist/i18n/legacy.d.ts"
67
67
  },
68
68
  "./i18n/middleware": {
69
69
  "import": "./dist/i18n/middleware.js",
@@ -91,9 +91,9 @@
91
91
  ],
92
92
  "dependencies": {
93
93
  "@formatjs/intl-localematcher": "^0.6.1",
94
- "@orama/orama": "^3.1.12",
95
- "@shikijs/rehype": "^3.12.0",
96
- "@shikijs/transformers": "^3.12.0",
94
+ "@orama/orama": "^3.1.13",
95
+ "@shikijs/rehype": "^3.12.2",
96
+ "@shikijs/transformers": "^3.12.2",
97
97
  "github-slugger": "^2.0.0",
98
98
  "hast-util-to-estree": "^3.1.3",
99
99
  "hast-util-to-jsx-runtime": "^2.3.6",
@@ -105,22 +105,22 @@
105
105
  "remark-gfm": "^4.0.1",
106
106
  "remark-rehype": "^11.1.2",
107
107
  "scroll-into-view-if-needed": "^3.1.0",
108
- "shiki": "^3.12.0",
108
+ "shiki": "^3.12.2",
109
109
  "unist-util-visit": "^5.0.0"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@mdx-js/mdx": "^3.1.1",
113
- "@mixedbread/sdk": "^0.26.0",
113
+ "@mixedbread/sdk": "^0.27.0",
114
114
  "@oramacloud/client": "^2.1.4",
115
- "@tanstack/react-router": "^1.131.30",
115
+ "@tanstack/react-router": "^1.131.35",
116
116
  "@types/estree-jsx": "^1.0.5",
117
117
  "@types/hast": "^3.0.4",
118
118
  "@types/mdast": "^4.0.3",
119
119
  "@types/negotiator": "^0.6.4",
120
- "@types/node": "24.3.0",
120
+ "@types/node": "24.3.1",
121
121
  "@types/react": "^19.1.12",
122
122
  "@types/react-dom": "^19.1.9",
123
- "algoliasearch": "5.36.0",
123
+ "algoliasearch": "5.37.0",
124
124
  "mdast-util-mdx-jsx": "^3.2.0",
125
125
  "mdast-util-mdxjs-esm": "^2.0.1",
126
126
  "next": "^15.5.2",
@@ -131,20 +131,20 @@
131
131
  "unified": "^11.0.5",
132
132
  "vfile": "^6.0.3",
133
133
  "waku": "^0.26.0",
134
- "eslint-config-custom": "0.0.0",
135
- "tsconfig": "0.0.0"
134
+ "tsconfig": "0.0.0",
135
+ "eslint-config-custom": "0.0.0"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@mixedbread/sdk": "^0.19.0",
139
139
  "@oramacloud/client": "1.x.x || 2.x.x",
140
+ "@tanstack/react-router": "1.x.x",
140
141
  "@types/react": "*",
141
142
  "algoliasearch": "5.x.x",
142
143
  "next": "14.x.x || 15.x.x",
143
144
  "react": "18.x.x || 19.x.x",
144
145
  "react-dom": "18.x.x || 19.x.x",
145
- "waku": "^0.26.0",
146
- "@tanstack/react-router": "1.x.x",
147
- "react-router": "7.x.x"
146
+ "react-router": "7.x.x",
147
+ "waku": "^0.26.0"
148
148
  },
149
149
  "peerDependenciesMeta": {
150
150
  "@mixedbread/sdk": {
@@ -1,17 +0,0 @@
1
- // src/utils/remove-undefined.ts
2
- function removeUndefined(value, deep = false) {
3
- const obj = value;
4
- for (const key of Object.keys(obj)) {
5
- if (obj[key] === void 0) delete obj[key];
6
- if (deep && typeof obj[key] === "object" && obj[key] !== null) {
7
- removeUndefined(obj[key], deep);
8
- } else if (deep && Array.isArray(obj[key])) {
9
- obj[key].forEach((v) => removeUndefined(v, deep));
10
- }
11
- }
12
- return value;
13
- }
14
-
15
- export {
16
- removeUndefined
17
- };
@@ -1,72 +0,0 @@
1
- // src/i18n/middleware.ts
2
- import { match as matchLocale } from "@formatjs/intl-localematcher";
3
- import Negotiator from "negotiator";
4
- import { NextResponse } from "next/server";
5
- var COOKIE = "FD_LOCALE";
6
- function getLocale(request, locales, defaultLanguage) {
7
- const negotiatorHeaders = {};
8
- request.headers.forEach((value, key) => {
9
- negotiatorHeaders[key] = value;
10
- });
11
- const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
12
- locales
13
- );
14
- return matchLocale(languages, locales, defaultLanguage);
15
- }
16
- var defaultFormat = (locale, path) => {
17
- return `/${locale}/${path}`;
18
- };
19
- function createI18nMiddleware({
20
- languages,
21
- defaultLanguage,
22
- format = defaultFormat,
23
- hideLocale = "never"
24
- }) {
25
- function getUrl(request, pathname, locale) {
26
- if (!locale) {
27
- return new URL(
28
- pathname.startsWith("/") ? pathname : `/${pathname}`,
29
- request.url
30
- );
31
- }
32
- return new URL(
33
- format(locale, pathname.startsWith("/") ? pathname.slice(1) : pathname),
34
- request.url
35
- );
36
- }
37
- return (request) => {
38
- const inputPath = `${request.nextUrl.pathname}${request.nextUrl.search}`;
39
- const pathLocale = languages.find(
40
- (locale) => inputPath.startsWith(`/${locale}/`) || inputPath === `/${locale}`
41
- );
42
- if (!pathLocale) {
43
- if (hideLocale === "default-locale") {
44
- return NextResponse.rewrite(
45
- getUrl(request, inputPath, defaultLanguage)
46
- );
47
- }
48
- const preferred = getLocale(request, languages, defaultLanguage);
49
- if (hideLocale === "always") {
50
- const locale = request.cookies.get(COOKIE)?.value ?? preferred;
51
- return NextResponse.rewrite(getUrl(request, inputPath, locale));
52
- }
53
- return NextResponse.redirect(getUrl(request, inputPath, preferred));
54
- }
55
- if (hideLocale === "always") {
56
- const path = inputPath.slice(`/${pathLocale}`.length);
57
- const res = NextResponse.redirect(getUrl(request, path));
58
- res.cookies.set(COOKIE, pathLocale);
59
- return res;
60
- }
61
- if (hideLocale === "default-locale" && pathLocale === defaultLanguage) {
62
- return NextResponse.redirect(
63
- getUrl(request, inputPath.slice(`/${pathLocale}`.length))
64
- );
65
- }
66
- return NextResponse.next();
67
- };
68
- }
69
-
70
- export {
71
- createI18nMiddleware
72
- };
@@ -1,3 +0,0 @@
1
- export { I18nConfig, defineI18n } from './index.js';
2
- export { createI18nMiddleware } from './middleware.js';
3
- import 'next/dist/server/web/types';
@@ -1,11 +0,0 @@
1
- import {
2
- createI18nMiddleware
3
- } from "../chunk-KLUGJRZC.js";
4
- import {
5
- defineI18n
6
- } from "../chunk-HUTQC33E.js";
7
- import "../chunk-JSBRDJBE.js";
8
- export {
9
- createI18nMiddleware,
10
- defineI18n
11
- };