fumadocs-core 16.15.11 → 16.15.13

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.
@@ -1,5 +1,5 @@
1
1
  import { r as findPath } from "./utils-DEVq3cEC.js";
2
- import { r as extname, t as basename } from "./path-1H5VzYiT.js";
2
+ import { r as extname, t as basename } from "./path-m9Srg2Jq.js";
3
3
  //#region src/search/server/build-index.ts
4
4
  async function buildIndexDefault(page) {
5
5
  let structuredData;
@@ -1,7 +1,7 @@
1
1
  import { r as normalizeUrl } from "./url-BVHvi3_K.js";
2
2
  import { l as visit } from "./utils-DEVq3cEC.js";
3
3
  import { t as isEqualShallow } from "./is-equal-LdLqRs0o.js";
4
- import { a as normalize, i as joinPath, n as dirname, r as extname, t as basename } from "./path-1H5VzYiT.js";
4
+ import { a as normalize, i as joinPath, n as dirname, r as extname, t as basename } from "./path-m9Srg2Jq.js";
5
5
  import { slugsPlugin } from "./source/plugins/slugs.js";
6
6
  import { t as iconPlugin } from "./icon-BILaoXeg.js";
7
7
  import { cache } from "react";
@@ -55,7 +55,7 @@ const cacheDefault = { create: function create() {
55
55
  return new ObjectWithoutPrototypeCache();
56
56
  } };
57
57
  //#endregion
58
- //#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.13/node_modules/@formatjs/intl-localematcher/index.js
58
+ //#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.9.0/node_modules/@formatjs/intl-localematcher/index.js
59
59
  /**
60
60
  * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
61
61
  * @param locales
@@ -3242,7 +3242,20 @@ const regions = {
3242
3242
  "ZW"
3243
3243
  ]
3244
3244
  };
3245
- const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
3245
+ function splitUnicodeExtension(locale) {
3246
+ const subtags = locale.split("-");
3247
+ for (let i = 1; i < subtags.length; i++) {
3248
+ if (subtags[i] === "x") break;
3249
+ if (subtags[i] !== "u") continue;
3250
+ let end = i + 1;
3251
+ while (end < subtags.length && subtags[end].length > 1) end++;
3252
+ return {
3253
+ locale: [...subtags.slice(0, i), ...subtags.slice(end)].join("-"),
3254
+ extension: "-" + subtags.slice(i, end).join("-")
3255
+ };
3256
+ }
3257
+ return { locale };
3258
+ }
3246
3259
  /**
3247
3260
  * Asserts that a condition is true, throwing an error if it is not.
3248
3261
  * Used for runtime validation and type narrowing.
@@ -3542,7 +3555,7 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
3542
3555
  let extension;
3543
3556
  const noExtensionLocales = [];
3544
3557
  const noExtensionLocaleMap = requestedLocales.reduce((all, l) => {
3545
- const noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
3558
+ const { locale: noExtensionLocale } = splitUnicodeExtension(l);
3546
3559
  noExtensionLocales.push(noExtensionLocale);
3547
3560
  all[noExtensionLocale] = l;
3548
3561
  return all;
@@ -3550,7 +3563,7 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
3550
3563
  const result = findBestMatch(noExtensionLocales, availableLocales);
3551
3564
  if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
3552
3565
  foundLocale = result.matchedSupportedLocale;
3553
- extension = noExtensionLocaleMap[result.matchedDesiredLocale].slice(result.matchedDesiredLocale.length) || void 0;
3566
+ extension = splitUnicodeExtension(noExtensionLocaleMap[result.matchedDesiredLocale]).extension;
3554
3567
  }
3555
3568
  if (!foundLocale) return { locale: getDefaultLocale() };
3556
3569
  return {
@@ -3558,16 +3571,251 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
3558
3571
  extension
3559
3572
  };
3560
3573
  }
3574
+ const subdivisionAlias = {
3575
+ "cn11": "cnbj",
3576
+ "cn12": "cntj",
3577
+ "cn13": "cnhe",
3578
+ "cn14": "cnsx",
3579
+ "cn15": "cnmn",
3580
+ "cn21": "cnln",
3581
+ "cn22": "cnjl",
3582
+ "cn23": "cnhl",
3583
+ "cn31": "cnsh",
3584
+ "cn32": "cnjs",
3585
+ "cn33": "cnzj",
3586
+ "cn34": "cnah",
3587
+ "cn35": "cnfj",
3588
+ "cn36": "cnjx",
3589
+ "cn37": "cnsd",
3590
+ "cn41": "cnha",
3591
+ "cn42": "cnhb",
3592
+ "cn43": "cnhn",
3593
+ "cn44": "cngd",
3594
+ "cn45": "cngx",
3595
+ "cn46": "cnhi",
3596
+ "cn50": "cncq",
3597
+ "cn51": "cnsc",
3598
+ "cn52": "cngz",
3599
+ "cn53": "cnyn",
3600
+ "cn54": "cnxz",
3601
+ "cn61": "cnsn",
3602
+ "cn62": "cngs",
3603
+ "cn63": "cnqh",
3604
+ "cn64": "cnnx",
3605
+ "cn65": "cnxj",
3606
+ "cn71": "twzzzz",
3607
+ "cn91": "hkzzzz",
3608
+ "cn92": "mozzzz",
3609
+ "cz10a": "cz110",
3610
+ "cz10b": "cz111",
3611
+ "cz10c": "cz112",
3612
+ "cz10d": "cz113",
3613
+ "cz10e": "cz114",
3614
+ "cz10f": "cz115",
3615
+ "cz611": "cz663",
3616
+ "cz612": "cz632",
3617
+ "cz613": "cz633",
3618
+ "cz614": "cz634",
3619
+ "cz615": "cz635",
3620
+ "cz621": "cz641",
3621
+ "cz622": "cz642",
3622
+ "cz623": "cz643",
3623
+ "cz624": "cz644",
3624
+ "cz626": "cz646",
3625
+ "cz627": "cz647",
3626
+ "czjc": "cz31",
3627
+ "czjm": "cz64",
3628
+ "czka": "cz41",
3629
+ "czkr": "cz52",
3630
+ "czli": "cz51",
3631
+ "czmo": "cz80",
3632
+ "czol": "cz71",
3633
+ "czpa": "cz53",
3634
+ "czpl": "cz32",
3635
+ "czpr": "cz10",
3636
+ "czst": "cz20",
3637
+ "czus": "cz42",
3638
+ "czvy": "cz63",
3639
+ "czzl": "cz72",
3640
+ "fi01": "axzzzz",
3641
+ "fra": "frges",
3642
+ "frb": "frnaq",
3643
+ "frbl": "blzzzz",
3644
+ "frc": "frara",
3645
+ "frcp": "cpzzzz",
3646
+ "frd": "frbfc",
3647
+ "fre": "frbre",
3648
+ "frf": "frcvl",
3649
+ "frg": "frges",
3650
+ "frgf": "gfzzzz",
3651
+ "frgp": "gpzzzz",
3652
+ "frgua": "gpzzzz",
3653
+ "frh": "frcor",
3654
+ "fri": "frbfc",
3655
+ "frj": "fridf",
3656
+ "frk": "frocc",
3657
+ "frl": "frnaq",
3658
+ "frlre": "rezzzz",
3659
+ "frm": "frges",
3660
+ "frmay": "ytzzzz",
3661
+ "frmf": "mfzzzz",
3662
+ "frmq": "mqzzzz",
3663
+ "frn": "frocc",
3664
+ "frnc": "nczzzz",
3665
+ "fro": "frhdf",
3666
+ "frp": "frnor",
3667
+ "frpf": "pfzzzz",
3668
+ "frpm": "pmzzzz",
3669
+ "frq": "frnor",
3670
+ "frr": "frpdl",
3671
+ "frre": "rezzzz",
3672
+ "frs": "frhdf",
3673
+ "frt": "frnaq",
3674
+ "frtf": "tfzzzz",
3675
+ "fru": "frpac",
3676
+ "frv": "frara",
3677
+ "frwf": "wfzzzz",
3678
+ "fryt": "ytzzzz",
3679
+ "laxn": "laxs",
3680
+ "lud": "lucl",
3681
+ "lug": "luec",
3682
+ "lul": "luca",
3683
+ "mrnkc": "mr13",
3684
+ "nlaw": "awzzzz",
3685
+ "nlcw": "cwzzzz",
3686
+ "nlsx": "sxzzzz",
3687
+ "no23": "no50",
3688
+ "nzn": "nzauk",
3689
+ "nzs": "nzcan",
3690
+ "omba": "ombj",
3691
+ "omsh": "omsj",
3692
+ "plds": "pl02",
3693
+ "plkp": "pl04",
3694
+ "pllb": "pl08",
3695
+ "plld": "pl10",
3696
+ "pllu": "pl06",
3697
+ "plma": "pl12",
3698
+ "plmz": "pl14",
3699
+ "plop": "pl16",
3700
+ "plpd": "pl20",
3701
+ "plpk": "pl18",
3702
+ "plpm": "pl22",
3703
+ "plsk": "pl26",
3704
+ "plsl": "pl24",
3705
+ "plwn": "pl28",
3706
+ "plwp": "pl30",
3707
+ "plzp": "pl32",
3708
+ "shta": "tazzzz",
3709
+ "tteto": "tttob",
3710
+ "ttrcm": "ttmrc",
3711
+ "ttwto": "tttob",
3712
+ "twkhq": "twkhh",
3713
+ "twtnq": "twtnn",
3714
+ "twtpq": "twnwt",
3715
+ "twtxq": "twtxg",
3716
+ "usas": "aszzzz",
3717
+ "usgu": "guzzzz",
3718
+ "usmp": "mpzzzz",
3719
+ "uspr": "przzzz",
3720
+ "usum": "umzzzz",
3721
+ "usvi": "vizzzz"
3722
+ };
3723
+ const extensionAlias = {
3724
+ "t": {
3725
+ "d0": { "name": "charname" },
3726
+ "m0": {
3727
+ "beta-metsehaf": "betamets",
3728
+ "ies-jes": "iesjes",
3729
+ "names": "prprname",
3730
+ "tekie-alibekit": "tekieali"
3731
+ }
3732
+ },
3733
+ "u": {
3734
+ "ca": {
3735
+ "ethiopic-amete-alem": "ethioaa",
3736
+ "islamicc": "islamic-civil"
3737
+ },
3738
+ "kb": { "yes": "true" },
3739
+ "kc": { "yes": "true" },
3740
+ "kh": { "yes": "true" },
3741
+ "kk": { "yes": "true" },
3742
+ "kn": { "yes": "true" },
3743
+ "ks": {
3744
+ "primary": "level1",
3745
+ "tertiary": "level3"
3746
+ },
3747
+ "ms": { "imperial": "uksystem" },
3748
+ "tz": {
3749
+ "aqams": "aqmcm",
3750
+ "aukns": "auhba",
3751
+ "caffs": "cawnp",
3752
+ "camtr": "cator",
3753
+ "canpg": "cator",
3754
+ "capnt": "caiql",
3755
+ "cathu": "cator",
3756
+ "cayzf": "caedm",
3757
+ "cet": "bebru",
3758
+ "cnckg": "cnsha",
3759
+ "cnhrb": "cnsha",
3760
+ "cnkhg": "cnurc",
3761
+ "cst6cdt": "uschi",
3762
+ "cuba": "cuhav",
3763
+ "eet": "grath",
3764
+ "egypt": "egcai",
3765
+ "eire": "iedub",
3766
+ "est": "papty",
3767
+ "est5edt": "usnyc",
3768
+ "factory": "unk",
3769
+ "gaza": "gazastrp",
3770
+ "gmt0": "gmt",
3771
+ "hongkong": "hkhkg",
3772
+ "hst": "ushnl",
3773
+ "iceland": "isrey",
3774
+ "iran": "irthr",
3775
+ "israel": "jeruslm",
3776
+ "jamaica": "jmkin",
3777
+ "japan": "jptyo",
3778
+ "libya": "lytip",
3779
+ "met": "bebru",
3780
+ "mncoq": "mnuln",
3781
+ "mst": "usphx",
3782
+ "mst7mdt": "usden",
3783
+ "mxstis": "mxtij",
3784
+ "navajo": "usden",
3785
+ "poland": "plwaw",
3786
+ "portugal": "ptlis",
3787
+ "prc": "cnsha",
3788
+ "pst8pdt": "uslax",
3789
+ "roc": "twtpe",
3790
+ "rok": "krsel",
3791
+ "turkey": "trist",
3792
+ "uaozh": "uaiev",
3793
+ "uauzh": "uaiev",
3794
+ "uct": "utc",
3795
+ "umjon": "ushnl",
3796
+ "usnavajo": "usden",
3797
+ "wet": "ptlis",
3798
+ "zulu": "utc"
3799
+ }
3800
+ }
3801
+ };
3561
3802
  function CanonicalizeUValue(ukey, uvalue) {
3562
- let lowerValue = uvalue.toLowerCase();
3563
3803
  invariant(ukey !== void 0, `ukey must be defined`);
3564
- return lowerValue;
3804
+ let canonicalized = "";
3805
+ for (let i = 0; i < uvalue.length; i++) {
3806
+ const code = uvalue.charCodeAt(i);
3807
+ canonicalized += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : uvalue[i];
3808
+ }
3809
+ const aliases = Object.prototype.hasOwnProperty.call(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
3810
+ if (aliases && Object.prototype.hasOwnProperty.call(aliases, canonicalized)) canonicalized = aliases[canonicalized];
3811
+ if ((ukey === "rg" || ukey === "sd") && Object.prototype.hasOwnProperty.call(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
3812
+ return canonicalized === "true" ? "" : canonicalized;
3565
3813
  }
3566
3814
  function CanonicalizeUnicodeLocaleId(locale) {
3567
3815
  return Intl.getCanonicalLocales(locale)[0];
3568
3816
  }
3569
3817
  function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
3570
- invariant(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
3818
+ invariant(splitUnicodeExtension(locale).extension === void 0, "Expected locale to not have a Unicode locale extension");
3571
3819
  let extension = "-u";
3572
3820
  for (const attr of attributes) extension += `-${attr}`;
3573
3821
  for (const kw of keywords) {
@@ -3616,11 +3864,11 @@ function BestAvailableLocale(availableLocales, locale) {
3616
3864
  function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
3617
3865
  const result = { locale: "" };
3618
3866
  for (const locale of requestedLocales) {
3619
- const noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
3867
+ const { locale: noExtensionLocale, extension } = splitUnicodeExtension(locale);
3620
3868
  const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
3621
3869
  if (availableLocale) {
3622
3870
  result.locale = availableLocale;
3623
- if (locale !== noExtensionLocale) result.extension = locale.slice(noExtensionLocale.length, locale.length);
3871
+ if (extension) result.extension = extension;
3624
3872
  return result;
3625
3873
  }
3626
3874
  }
@@ -3676,10 +3924,9 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
3676
3924
  };
3677
3925
  let foundLocale = r.locale;
3678
3926
  let foundLocaleData = localeData[foundLocale];
3679
- const result = {
3680
- locale: "en",
3681
- dataLocale: foundLocale
3682
- };
3927
+ const result = Object.create(null);
3928
+ result.locale = "en";
3929
+ result.dataLocale = foundLocale;
3683
3930
  let components;
3684
3931
  let keywords;
3685
3932
  if (r.extension) {
@@ -3691,7 +3938,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
3691
3938
  let keyLocaleData = foundLocaleData?.[key] ?? [];
3692
3939
  invariant(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
3693
3940
  let value = keyLocaleData[0];
3694
- invariant(value === void 0 || typeof value === "string", `value must be a string or undefined`);
3941
+ invariant(value == null || typeof value === "string", `value must be a string, null, or undefined`);
3695
3942
  let supportedKeyword;
3696
3943
  let entry = keywords.find((k) => k.key === key);
3697
3944
  if (entry) {
@@ -3718,7 +3965,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
3718
3965
  optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
3719
3966
  if (optionsValue === "") optionsValue = "true";
3720
3967
  }
3721
- if (optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
3968
+ if (optionsValue !== void 0 && optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
3722
3969
  value = optionsValue;
3723
3970
  supportedKeyword = void 0;
3724
3971
  }
@@ -12,6 +12,17 @@ const HeadingTags = /* @__PURE__ */ new Set([
12
12
  "h5",
13
13
  "h6"
14
14
  ]);
15
+ /**
16
+ * Read the step number `remarkSteps` assigns to a heading.
17
+ */
18
+ function getStep(properties) {
19
+ const raw = properties["data-fd-step"] ?? properties.dataFdStep;
20
+ if (typeof raw === "number") return raw;
21
+ if (typeof raw === "string" && raw.trim() !== "") {
22
+ const step = Number(raw);
23
+ if (Number.isFinite(step)) return step;
24
+ }
25
+ }
15
26
  function rehypeToc({ exportToc = true } = {}) {
16
27
  if (exportToc === true) exportToc = {
17
28
  as: "esm",
@@ -42,7 +53,7 @@ function rehypeToc({ exportToc = true } = {}) {
42
53
  title: element,
43
54
  depth: Number(element.tagName[1]),
44
55
  url: `#${id}`,
45
- _step: typeof element.properties["data-fd-step"] === "number" ? element.properties["data-fd-step"] : void 0
56
+ _step: getStep(element.properties)
46
57
  });
47
58
  if (isTocOnly && parent && typeof idx === "number") parent.children.splice(idx, 1);
48
59
  return "skip";
@@ -12,7 +12,7 @@ function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsP
12
12
  filterElement(node) {
13
13
  switch (node.type) {
14
14
  case "mdxjsEsm": return false;
15
- default: return true;
15
+ default: return rest.filterElement?.(node) ?? true;
16
16
  }
17
17
  },
18
18
  stringify(node, parent, state, info, collect) {
@@ -1,4 +1,4 @@
1
- import { t as __commonJSMin } from "../rolldown-runtime-DC62tzP2.js";
1
+ import { t as __commonJSMin } from "../rolldown-runtime-EAsCxrDo.js";
2
2
  //#endregion
3
3
  //#region src/negotiation/index.ts
4
4
  var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "./rolldown-runtime-DC62tzP2.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-EAsCxrDo.js";
2
2
  //#region src/source/path.ts
3
3
  var path_exports = /* @__PURE__ */ __exportAll({
4
4
  basename: () => basename,
@@ -0,0 +1,14 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ //#endregion
14
+ export { __exportAll as n, __commonJSMin as t };
@@ -1,4 +1,4 @@
1
- import { n as buildDocuments } from "../build-index-COlcoMFJ.js";
1
+ import { n as buildDocuments } from "../build-index-BD-VRKOW.js";
2
2
  //#region src/search/algolia.ts
3
3
  /**
4
4
  * Build the search indexes of every page in a source.
@@ -1,13 +1,10 @@
1
- import { t as index_node_default } from "../../index.node-DkfYQyHM.js";
2
1
  import Slugger from "github-slugger";
3
2
  //#region src/search/client/mixedbread.ts
4
3
  const slugger = new Slugger();
5
4
  function extractHeadingTitle(text) {
6
5
  const trimmedText = text.trim();
7
6
  if (!trimmedText.startsWith("#")) return "";
8
- const firstLine = trimmedText.split("\n")[0]?.trim();
9
- if (firstLine) return index_node_default(firstLine, { useImgAltText: false });
10
- return "";
7
+ return trimmedText.split("\n")[0]?.trim() ?? "";
11
8
  }
12
9
  /**
13
10
  * @deprecated Use `createMixedbreadSearchAPI` from `fumadocs-core/search/mixedbread` instead.
@@ -1,4 +1,4 @@
1
- import { r as buildIndexDefault, t as buildBreadcrumbs } from "../build-index-COlcoMFJ.js";
1
+ import { r as buildIndexDefault, t as buildBreadcrumbs } from "../build-index-BD-VRKOW.js";
2
2
  import { t as createEndpoint } from "../endpoint-MyoBU5IC.js";
3
3
  import { t as buildDocuments } from "../build-doc-Cjg7QvFR.js";
4
4
  import { n as search, t as createDocument } from "../utils-Bvy3V-fv.js";
@@ -1,14 +1,11 @@
1
1
  import { t as createEndpoint } from "../endpoint-MyoBU5IC.js";
2
- import { t as index_node_default } from "../index.node-DkfYQyHM.js";
3
2
  import Slugger from "github-slugger";
4
3
  //#region src/search/mixedbread.ts
5
4
  const slugger = new Slugger();
6
5
  function extractHeadingTitle(text) {
7
6
  const trimmedText = text.trim();
8
7
  if (!trimmedText.startsWith("#")) return "";
9
- const firstLine = trimmedText.split("\n")[0]?.trim();
10
- if (firstLine) return index_node_default(firstLine, { useImgAltText: false });
11
- return "";
8
+ return trimmedText.split("\n")[0]?.trim() ?? "";
12
9
  }
13
10
  function defaultTransform(results) {
14
11
  return results.flatMap((item) => {
@@ -1,4 +1,4 @@
1
- import { n as buildDocuments } from "../build-index-COlcoMFJ.js";
1
+ import { n as buildDocuments } from "../build-index-BD-VRKOW.js";
2
2
  //#region src/search/orama-cloud.ts
3
3
  /**
4
4
  * Build the search indexes of every page in a source.
@@ -1,4 +1,4 @@
1
- import { r as buildIndexDefault, t as buildBreadcrumbs } from "../build-index-COlcoMFJ.js";
1
+ import { r as buildIndexDefault, t as buildBreadcrumbs } from "../build-index-BD-VRKOW.js";
2
2
  import { n as defaultReadOptions, t as createEndpoint } from "../endpoint-MyoBU5IC.js";
3
3
  import { t as buildDocuments } from "../build-doc-Cjg7QvFR.js";
4
4
  import { n as searchSimple, t as searchAdvanced } from "../advanced-Ct13khZr.js";
@@ -1,2 +1,2 @@
1
- import { t as dynamicLoader } from "../dynamic-lx_V4971.js";
1
+ import { t as dynamicLoader } from "../dynamic-CSrl9w26.js";
2
2
  export { dynamicLoader };
@@ -1,5 +1,5 @@
1
- import { o as path_exports } from "../path-1H5VzYiT.js";
2
- import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-lx_V4971.js";
1
+ import { o as path_exports } from "../path-m9Srg2Jq.js";
2
+ import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-CSrl9w26.js";
3
3
  import { getSlugs } from "./plugins/slugs.js";
4
4
  import { llms } from "./llms.js";
5
5
  export { FileSystem, path_exports as PathUtils, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
@@ -1,4 +1,4 @@
1
- import { n as dirname, r as extname, t as basename } from "../../path-1H5VzYiT.js";
1
+ import { n as dirname, r as extname, t as basename } from "../../path-m9Srg2Jq.js";
2
2
  //#region src/source/plugins/slugs.ts
3
3
  /**
4
4
  * Generate slugs for pages if missing.
package/dist/toc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { t as isEqualShallow } from "./is-equal-LdLqRs0o.js";
3
- import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
3
+ import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useSyncExternalStore } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import scrollIntoView from "scroll-into-view-if-needed";
6
6
  //#region src/utils/merge-refs.ts
@@ -24,11 +24,7 @@ function ScrollProvider({ containerRef, children }) {
24
24
  });
25
25
  }
26
26
  function AnchorProvider({ toc, single = false, children }) {
27
- const observer = useMemo(() => new Observer(), []);
28
- observer.single = single;
29
- useEffect(() => {
30
- observer.setItems(toc);
31
- }, [observer, toc]);
27
+ const observer = useMemo(() => new Observer(toc, single), [toc, single]);
32
28
  useEffect(() => {
33
29
  observer.watch({ threshold: .9 });
34
30
  return () => observer.unwatch();
@@ -38,45 +34,40 @@ function AnchorProvider({ toc, single = false, children }) {
38
34
  children
39
35
  });
40
36
  }
41
- function TOCItem({ ref, onActiveChange = () => null, autoScroll = true, ...props }) {
37
+ function TOCItem({ ref, onActiveChange, autoScroll = true, ...props }) {
42
38
  const id = props.href ? getItemId(props.href) : null;
43
39
  const containerRef = use(ScrollContext);
44
40
  const anchorRef = useRef(null);
45
- const isInitialRef = useRef(true);
41
+ const isMountedRef = useRef(false);
46
42
  const observer = useObserver();
47
- const [active, setActive] = useState(() => observer.items.some((item) => item.id === id && item.active));
48
- const onUpdate = useEffectEvent((items, initial) => {
49
- const itemData = id ? items.find((item) => item.id === id) : null;
50
- if (!itemData) return;
51
- if (itemData.active !== active) {
52
- setActive(itemData.active);
53
- onActiveChange(itemData.active);
54
- }
55
- const anchor = anchorRef.current;
56
- const container = containerRef?.current;
57
- if (!autoScroll || !anchor || !container) return;
58
- let lastActive;
59
- for (const item of items) {
60
- if (!item.active) continue;
61
- if (!lastActive || lastActive.t < item.t) lastActive = item;
62
- }
63
- if (lastActive?.id === id) scrollIntoView(anchor, {
64
- behavior: initial ? "instant" : "smooth",
65
- block: "center",
66
- inline: "center",
67
- scrollMode: "always",
68
- boundary: container
69
- });
70
- });
71
- useEffect(() => {
72
- if (autoScroll) onUpdate(observer.items, isInitialRef.current);
73
- isInitialRef.current = false;
74
- }, [observer, autoScroll]);
43
+ const active = useObserverValue((observer) => id !== null && observer.activeAnchors.includes(id));
44
+ const prevActiveRef = useRef(active);
45
+ if (prevActiveRef.current !== active) {
46
+ prevActiveRef.current = active;
47
+ onActiveChange?.(active);
48
+ }
75
49
  useEffect(() => {
76
- const listener = (items) => onUpdate(items, false);
77
- observer.listen(listener);
78
- return () => observer.unlisten(listener);
79
- }, [observer]);
50
+ if (id === null) return;
51
+ const callback = () => {
52
+ const anchor = anchorRef.current;
53
+ const container = containerRef?.current;
54
+ if (autoScroll && observer.activeAnchor === id && anchor && container) scrollIntoView(anchor, {
55
+ behavior: isMountedRef.current ? "smooth" : "instant",
56
+ block: "center",
57
+ inline: "center",
58
+ scrollMode: "always",
59
+ boundary: container
60
+ });
61
+ };
62
+ callback();
63
+ isMountedRef.current = true;
64
+ return observer.subscribe(callback);
65
+ }, [
66
+ autoScroll,
67
+ id,
68
+ observer,
69
+ containerRef
70
+ ]);
80
71
  return /* @__PURE__ */ jsx("a", {
81
72
  ref: mergeRefs(anchorRef, ref),
82
73
  "data-active": active,
@@ -88,6 +79,12 @@ function useObserver() {
88
79
  if (!observer) throw new Error(`Component must be used under the <AnchorProvider /> component.`);
89
80
  return observer;
90
81
  }
82
+ /** subscribe to a value of the observer, it must be stable between updates */
83
+ function useObserverValue(get) {
84
+ const observer = useObserver();
85
+ const getSnapshot = () => get(observer);
86
+ return useSyncExternalStore(observer.subscribe, getSnapshot, getSnapshot);
87
+ }
91
88
  /** @returns static info object, useful for custom rendering logic */
92
89
  function useTOC() {
93
90
  const observer = useObserver();
@@ -102,75 +99,58 @@ function useTOC() {
102
99
  function useTOCListener(listener) {
103
100
  const observer = useObserver();
104
101
  const callback = useEffectEvent(listener);
105
- useEffect(() => {
106
- observer.listen(callback);
107
- return () => observer.unlisten(callback);
108
- }, [observer]);
102
+ useEffect(() => observer.subscribe(callback), [observer]);
109
103
  }
110
104
  function useTOCSelector(select, isEqual = isEqualShallow) {
111
- const observer = useObserver();
112
- const [value, setValue] = useState(() => select(observer.items));
113
- useTOCListener((items) => {
105
+ const cache = useRef(null);
106
+ return useObserverValue(({ items }) => {
107
+ const prev = cache.current;
108
+ if (prev && prev.items === items && prev.select === select) return prev.value;
114
109
  const next = select(items);
115
- if (!isEqual(value, next)) setValue(next);
110
+ const value = prev && isEqual(prev.value, next) ? prev.value : next;
111
+ cache.current = {
112
+ items,
113
+ select,
114
+ value
115
+ };
116
+ return value;
116
117
  });
117
- return value;
118
118
  }
119
119
  /**
120
120
  * The estimated active heading ID
121
121
  */
122
122
  function useActiveAnchor() {
123
- return useTOCSelector((items) => {
124
- let out;
125
- for (const item of items) {
126
- if (!item.active) continue;
127
- if (!out || item.t > out.t) out = item;
128
- }
129
- return out?.id;
130
- });
123
+ return useObserverValue((observer) => observer.activeAnchor);
131
124
  }
132
125
  /**
133
126
  * The id of visible anchors
134
127
  */
135
128
  function useActiveAnchors() {
136
- return useTOCSelector((items) => {
137
- const out = [];
138
- for (const item of items) if (item.active) out.push(item.id);
139
- return out;
140
- });
129
+ return useObserverValue((observer) => observer.activeAnchors);
141
130
  }
142
131
  function useItems() {
143
- return useTOCSelector((items) => items);
132
+ return useObserverValue((observer) => observer.items);
144
133
  }
145
134
  function getItemId(url) {
146
135
  if (url.startsWith("#")) return url.slice(1);
147
136
  return null;
148
137
  }
149
138
  var Observer = class {
150
- constructor() {
151
- this.items = [];
152
- this.single = false;
139
+ constructor(toc, single) {
140
+ this.single = single;
141
+ this.activeAnchors = [];
153
142
  this.observer = null;
154
143
  this.listeners = /* @__PURE__ */ new Set();
155
- }
156
- listen(listener) {
157
- this.listeners.add(listener);
158
- }
159
- unlisten(listener) {
160
- this.listeners.delete(listener);
161
- }
162
- setItems(newItems) {
163
- const observer = this.observer;
164
- if (observer) for (const item of this.items) {
165
- const element = document.getElementById(item.id);
166
- if (!element) continue;
167
- observer.unobserve(element);
168
- }
169
- const next = [];
170
- for (const item of newItems) {
144
+ this.subscribe = (listener) => {
145
+ this.listeners.add(listener);
146
+ return () => {
147
+ this.listeners.delete(listener);
148
+ };
149
+ };
150
+ this.items = [];
151
+ for (const item of toc) {
171
152
  const id = getItemId(item.url);
172
- if (!id) continue;
173
- next.push({
153
+ if (id) this.items.push({
174
154
  id,
175
155
  active: false,
176
156
  fallback: false,
@@ -178,13 +158,21 @@ var Observer = class {
178
158
  original: item
179
159
  });
180
160
  }
181
- this.update(next);
182
- this.observeItems();
161
+ }
162
+ listen(listener) {
163
+ this.listeners.add(listener);
164
+ }
165
+ unlisten(listener) {
166
+ this.listeners.delete(listener);
183
167
  }
184
168
  watch(options) {
185
169
  if (this.observer) return;
186
170
  this.observer = new IntersectionObserver(this.callback.bind(this), options);
187
- this.observeItems();
171
+ for (const item of this.items) {
172
+ const element = document.getElementById(item.id);
173
+ if (!element) continue;
174
+ this.observer.observe(element);
175
+ }
188
176
  }
189
177
  unwatch() {
190
178
  this.observer?.disconnect();
@@ -228,16 +216,17 @@ var Observer = class {
228
216
  }
229
217
  this.update(updated);
230
218
  }
231
- observeItems() {
232
- if (!this.observer) return;
233
- for (const item of this.items) {
234
- const element = document.getElementById(item.id);
235
- if (!element) continue;
236
- this.observer.observe(element);
237
- }
238
- }
239
219
  update(next) {
220
+ let latest;
221
+ const activeAnchors = [];
222
+ for (const item of next) {
223
+ if (!item.active) continue;
224
+ activeAnchors.push(item.id);
225
+ if (!latest || item.t > latest.t) latest = item;
226
+ }
240
227
  this.items = next;
228
+ this.activeAnchors = activeAnchors;
229
+ this.activeAnchor = latest?.id;
241
230
  for (const listener of this.listeners) listener(next);
242
231
  }
243
232
  };
@@ -1,3 +1,6 @@
1
1
  //#region src/utils/use-media-query.d.ts
2
+ /**
3
+ * @returns `null` on the server, during hydration, or when disabled.
4
+ */
2
5
  export declare function useMediaQuery(query: string, disabled?: boolean): boolean | null;
3
6
  //#endregion
@@ -1,20 +1,17 @@
1
- import { useEffect, useState } from "react";
1
+ import { useCallback, useSyncExternalStore } from "react";
2
2
  //#region src/utils/use-media-query.ts
3
+ const getServerSnapshot = () => null;
4
+ /**
5
+ * @returns `null` on the server, during hydration, or when disabled.
6
+ */
3
7
  function useMediaQuery(query, disabled = false) {
4
- const [isMatch, setMatch] = useState(null);
5
- useEffect(() => {
6
- if (disabled) return;
7
- const mediaQueryList = window.matchMedia(query);
8
- const handleChange = () => {
9
- setMatch(mediaQueryList.matches);
10
- };
11
- handleChange();
12
- mediaQueryList.addEventListener("change", handleChange);
13
- return () => {
14
- mediaQueryList.removeEventListener("change", handleChange);
15
- };
16
- }, [disabled, query]);
17
- return isMatch;
8
+ const subscribe = useCallback((onChange) => {
9
+ if (disabled) return () => {};
10
+ const list = window.matchMedia(query);
11
+ list.addEventListener("change", onChange);
12
+ return () => list.removeEventListener("change", onChange);
13
+ }, [query, disabled]);
14
+ return useSyncExternalStore(subscribe, () => disabled ? null : window.matchMedia(query).matches, getServerSnapshot);
18
15
  }
19
16
  //#endregion
20
17
  export { useMediaQuery };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.15.11",
3
+ "version": "16.15.13",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -110,6 +110,7 @@
110
110
  "access": "public"
111
111
  },
112
112
  "dependencies": {
113
+ "@fumari/image-size": "^0.1.1",
113
114
  "estree-util-value-to-estree": "^3.5.0",
114
115
  "github-slugger": "^2.0.0",
115
116
  "hast-util-to-estree": "^3.1.3",
@@ -126,39 +127,38 @@
126
127
  "unified": "^11.0.5",
127
128
  "unist-util-visit": "^5.1.0",
128
129
  "vfile": "^6.0.3",
129
- "yaml": "^2.9.0",
130
- "zbsearch": "^4.0.0",
131
- "@fumari/image-size": "^0.1.1"
130
+ "yaml": "^2.9.1",
131
+ "zbsearch": "^4.0.0"
132
132
  },
133
133
  "devDependencies": {
134
- "@formatjs/intl-localematcher": "^0.8.13",
134
+ "@formatjs/intl-localematcher": "^0.9.0",
135
135
  "@mdx-js/mdx": "^3.1.1",
136
- "@mixedbread/sdk": "0.77.0",
136
+ "@mixedbread/sdk": "0.78.0",
137
137
  "@modelcontextprotocol/server": "2.0.0",
138
138
  "@orama/core": "^1.2.19",
139
139
  "@oramacloud/client": "^2.1.4",
140
140
  "@shikijs/transformers": "^4.4.3",
141
- "@tanstack/react-router": "1.170.33",
141
+ "@tanstack/react-router": "1.170.38",
142
142
  "@types/estree-jsx": "^1.0.5",
143
143
  "@types/hast": "^3.0.5",
144
144
  "@types/mdast": "^4.0.4",
145
- "@types/node": "26.5.0",
146
- "@types/react": "^19.2.18",
147
- "@types/react-dom": "^19.2.7",
148
- "algoliasearch": "5.57.0",
145
+ "@types/node": "26.6.1",
146
+ "@types/react": "^19.3.0",
147
+ "@types/react-dom": "^19.3.0",
148
+ "algoliasearch": "5.59.0",
149
149
  "flexsearch": "^0.8.212",
150
- "lucide-react": "^1.43.0",
151
- "next": "16.3.4",
150
+ "lucide-react": "^1.47.0",
151
+ "next": "16.3.5",
152
152
  "path-to-regexp": "^8.4.2",
153
- "react-router": "^8.3.1",
153
+ "react-router": "^8.4.0",
154
+ "rehype-raw": "^7.0.0",
154
155
  "remark-directive": "^4.0.0",
155
156
  "remark-mdx": "^3.1.1",
156
- "remove-markdown": "^0.7.0",
157
+ "tsconfig": "0.0.0",
157
158
  "tsdown": "0.23.0",
158
159
  "typescript": "^7.0.2",
159
- "waku": "1.0.0-rc.0",
160
- "zod": "4.5.4",
161
- "tsconfig": "0.0.0"
160
+ "waku": "1.0.0-rc.1",
161
+ "zod": "4.6.5"
162
162
  },
163
163
  "peerDependencies": {
164
164
  "@mdx-js/mdx": "*",
@@ -242,10 +242,9 @@
242
242
  },
243
243
  "inlinedDependencies": {
244
244
  "@formatjs/fast-memoize": "3.1.7",
245
- "@formatjs/intl-localematcher": "0.8.13",
245
+ "@formatjs/intl-localematcher": "0.9.0",
246
246
  "@shikijs/transformers": "4.4.3",
247
- "path-to-regexp": "8.4.2",
248
- "remove-markdown": "0.7.0"
247
+ "path-to-regexp": "8.4.2"
249
248
  },
250
249
  "scripts": {
251
250
  "build": "tsdown",
@@ -1,39 +0,0 @@
1
- import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DC62tzP2.js";
2
- var index_node_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
3
- module.exports = function(md, options) {
4
- options = options || {};
5
- options.listUnicodeChar = options.hasOwnProperty("listUnicodeChar") ? options.listUnicodeChar : false;
6
- options.stripListLeaders = options.hasOwnProperty("stripListLeaders") ? options.stripListLeaders : true;
7
- options.gfm = options.hasOwnProperty("gfm") ? options.gfm : true;
8
- options.useImgAltText = options.hasOwnProperty("useImgAltText") ? options.useImgAltText : true;
9
- options.abbr = options.hasOwnProperty("abbr") ? options.abbr : false;
10
- options.replaceLinksWithURL = options.hasOwnProperty("replaceLinksWithURL") ? options.replaceLinksWithURL : false;
11
- options.separateLinksAndTexts = options.hasOwnProperty("separateLinksAndTexts") ? options.separateLinksAndTexts : null;
12
- options.htmlTagsToSkip = options.hasOwnProperty("htmlTagsToSkip") ? options.htmlTagsToSkip : [];
13
- options.throwError = options.hasOwnProperty("throwError") ? options.throwError : false;
14
- var output = md || "";
15
- output = output.replace(/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/gm, "");
16
- try {
17
- if (options.stripListLeaders) {
18
- if (options.listUnicodeChar) output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, options.listUnicodeChar + " $1");
19
- else output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, "$1");
20
- }
21
- if (options.gfm) output = output.replace(/\n={2,}/g, "\n").replace(/~{3}.*\n/g, "").replace(/~~/g, "").replace(/```(?:.*)\n([\s\S]*?)```/g, (_, code) => code.trim());
22
- if (options.abbr) output = output.replace(/\*\[.*\]:.*\n/, "");
23
- let htmlReplaceRegex = /<[^>]*>/g;
24
- if (options.htmlTagsToSkip && options.htmlTagsToSkip.length > 0) {
25
- const joinedHtmlTagsToSkip = options.htmlTagsToSkip.join("|");
26
- htmlReplaceRegex = new RegExp(`<(?!\/?(${joinedHtmlTagsToSkip})(?=>|\s[^>]*>))[^>]*>`, "g");
27
- }
28
- if (options.separateLinksAndTexts) output = output.replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1" + options.separateLinksAndTexts + "$2");
29
- output = output.replace(htmlReplaceRegex, "").replace(/^[=\-]{2,}\s*$/g, "").replace(/\[\^.+?\](\: .*?$)?/g, "").replace(/\s{0,2}\[.*?\]: .*?$/g, "").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? "$1" : "").replace(/\[([\s\S]*?)\]\s*[\(\[](.*?)[\)\]]/g, options.replaceLinksWithURL ? "$2" : "$1").replace(/^(\n)?\s{0,3}>\s?/gm, "$1").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, "").replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm, "$1$3$4$6").replace(/([\*]+)(\S)(.*?\S)??\1/g, "$2$3").replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g, "$1$3$4$5").replace(/(`{3,})(.*?)\1/gm, "$2").replace(/`(.+?)`/g, "$1").replace(/~(.*?)~/g, "$1");
30
- } catch (e) {
31
- if (options.throwError) throw e;
32
- console.error("remove-markdown encountered error: %s", e);
33
- return md;
34
- }
35
- return output;
36
- };
37
- })))(), 1)).default;
38
- //#endregion
39
- export { index_node_default as t };
@@ -1,33 +0,0 @@
1
- //#region \0rolldown/runtime.js
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 __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
- var __exportAll = (all, no_symbols) => {
10
- let target = {};
11
- for (var name in all) __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
- return target;
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
- key = keys[i];
21
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
- get: ((k) => from[k]).bind(null, key),
23
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
- });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
29
- value: mod,
30
- enumerable: true
31
- }) : target, mod));
32
- //#endregion
33
- export { __exportAll as n, __toESM as r, __commonJSMin as t };