fumadocs-core 16.18.2 → 16.18.4

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 (84) hide show
  1. package/dist/{algolia-B36wJl6E.d.ts → algolia-DsNJZd4P.d.ts} +2 -2
  2. package/dist/{build-index-CqctTvug.js → build-index-8ryBfL45.js} +1 -1
  3. package/dist/{client-LE_6Q0xR.d.ts → client-Bv_2P4D3.d.ts} +3 -3
  4. package/dist/content/mdx/preset-bundler.d.ts +2 -2
  5. package/dist/content/mdx/preset-runtime.d.ts +2 -2
  6. package/dist/{dynamic-BKMu5hc8.js → dynamic-CENrXFis.js} +182 -23
  7. package/dist/dynamic-link.js +1 -1
  8. package/dist/framework/plugin.d.ts +2 -2
  9. package/dist/highlight/client.js +1 -1
  10. package/dist/highlight/index.js +1 -1
  11. package/dist/highlight/shiki/full.d.ts +1 -1
  12. package/dist/highlight/shiki/index.d.ts +1 -1
  13. package/dist/highlight/shiki/react.d.ts +2 -2
  14. package/dist/i18n/middleware.js +2088 -3439
  15. package/dist/{index-DWVer6sb.d.ts → index-BOhS1UKT.d.ts} +110 -13
  16. package/dist/{index-B0Bzrmfa.d.ts → index-e-8QoCiA.d.ts} +1 -1
  17. package/dist/mcp.d.ts +2 -2
  18. package/dist/mdx-plugins/index.d.ts +4 -4
  19. package/dist/mdx-plugins/index.js +6 -5
  20. package/dist/mdx-plugins/rehype-code.core.d.ts +1 -1
  21. package/dist/mdx-plugins/rehype-code.core.js +1 -1
  22. package/dist/mdx-plugins/rehype-code.d.ts +2 -2
  23. package/dist/mdx-plugins/rehype-code.js +1 -1
  24. package/dist/mdx-plugins/remark-code-tab.js +1 -1
  25. package/dist/mdx-plugins/remark-include.js +2 -2
  26. package/dist/mdx-plugins/remark-llms.js +1 -1
  27. package/dist/mdx-plugins/remark-npm.js +1 -1
  28. package/dist/mdx-plugins/remark-show.d.ts +2 -0
  29. package/dist/mdx-plugins/remark-show.js +162 -0
  30. package/dist/mdx-plugins/remark-steps.js +1 -1
  31. package/dist/mdx-plugins/remark-structure.js +1 -1
  32. package/dist/mdx-plugins/stringifier.js +6 -0
  33. package/dist/{meilisearch-CsyDr1xA.d.ts → meilisearch-DzjbVbAn.d.ts} +2 -2
  34. package/dist/{mixedbread-CyM4na_-.d.ts → mixedbread-CMi5F-zO.d.ts} +2 -2
  35. package/dist/negotiation/index.js +279 -290
  36. package/dist/{path-CH9Umap3.js → path-B8old5-F.js} +1 -1
  37. package/dist/{rehype-code-CPNaiqAY.d.ts → rehype-code-Czh_8L5z.d.ts} +1 -1
  38. package/dist/{rehype-code.core-D1aZ5yla.d.ts → rehype-code.core-BeCtKe7K.d.ts} +1 -1
  39. package/dist/{rehype-code.core-Dq2jmvan.js → rehype-code.core-Jt2VtK1A.js} +3 -3
  40. package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
  41. package/dist/search/algolia.d.ts +1 -1
  42. package/dist/search/algolia.js +1 -1
  43. package/dist/search/client/algolia.d.ts +1 -1
  44. package/dist/search/client/docs-search.d.ts +1 -1
  45. package/dist/search/client/fetch.d.ts +1 -1
  46. package/dist/search/client/fetch.js +1 -1
  47. package/dist/search/client/flexsearch-static.d.ts +1 -1
  48. package/dist/search/client/flexsearch-static.js +1 -1
  49. package/dist/search/client/meilisearch.d.ts +1 -1
  50. package/dist/search/client/mixedbread.d.ts +2 -2
  51. package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
  52. package/dist/search/client/orama-cloud-legacy.js +1 -1
  53. package/dist/search/client/orama-cloud.d.ts +1 -1
  54. package/dist/search/client/orama-cloud.js +1 -1
  55. package/dist/search/client/orama-static.d.ts +1 -1
  56. package/dist/search/client/orama-static.js +2 -2
  57. package/dist/search/client.d.ts +1 -1
  58. package/dist/search/flexsearch.d.ts +2 -2
  59. package/dist/search/flexsearch.js +1 -1
  60. package/dist/search/index.js +1 -1
  61. package/dist/search/meilisearch.d.ts +1 -1
  62. package/dist/search/meilisearch.js +1 -1
  63. package/dist/search/mixedbread.d.ts +2 -2
  64. package/dist/search/orama-cloud-legacy.d.ts +1 -1
  65. package/dist/search/orama-cloud.d.ts +2 -3
  66. package/dist/search/orama-cloud.js +1 -1
  67. package/dist/search/server.d.ts +1 -1
  68. package/dist/search/server.js +2 -2
  69. package/dist/{server-BUYLz3H4.d.ts → server-MsDv36PV.d.ts} +3 -3
  70. package/dist/source/dynamic.d.ts +1 -1
  71. package/dist/source/dynamic.js +1 -1
  72. package/dist/source/index.d.ts +2 -2
  73. package/dist/source/index.js +3 -3
  74. package/dist/source/llms.d.ts +1 -1
  75. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  76. package/dist/source/plugins/slugs.d.ts +1 -1
  77. package/dist/source/plugins/slugs.js +1 -1
  78. package/dist/source/plugins/status-badges.d.ts +1 -1
  79. package/dist/source/schema.d.ts +2 -0
  80. package/dist/source/schema.js +3 -0
  81. package/dist/utils/hast-to-jsx.js +22 -31
  82. package/package.json +21 -20
  83. package/dist/index-BFnMPJLk.d.ts +0 -17
  84. package/dist/rolldown-runtime-C-UrYobY.js +0 -13
@@ -1,11 +1,29 @@
1
- import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "./definitions-BQVehOBz.js";
2
- import { t as Awaitable } from "./types-Dvkw0Kd0.js";
1
+ import "./remark-gfm-DpVfAX1x.js";
2
+ import "./rehype-code-Czh_8L5z.js";
3
+ import "./remark-image-BwyGdFld.js";
4
+ import "./remark-include-D_FmDdtI.js";
3
5
  import { n as StructuredData } from "./remark-structure-50nmY6sX.js";
4
- import "./index-BFnMPJLk.js";
6
+ import "./remark-heading-Dhiig5Fv.js";
7
+ import "./remark-admonition-BxacgP6i.js";
8
+ import "./remark-directive-admonition-BT_PH6hL.js";
9
+ import "./rehype-toc-BBnmTg-x.js";
10
+ import "./remark-code-tab-Dj_--R3y.js";
11
+ import "./remark-steps-CKvq9VmR.js";
12
+ import "./remark-npm-IH35Vls_.js";
13
+ import "./codeblock-utils-D65x-Jra.js";
14
+ import "./remark-mdx-files-BJvKexDp.js";
15
+ import "./remark-mdx-mermaid-BrK4YVTJ.js";
16
+ import "./remark-feedback-block-2Ei4IDr4.js";
17
+ import { t as Awaitable } from "./types-Dvkw0Kd0.js";
5
18
  import { n as I18nConfig } from "./index-DFrWGSeW.js";
6
- import "./index-DMxrC6WS.js";
19
+ import { a as Separator, i as Root$1, n as Item, r as Node, t as Folder } from "./definitions-BQVehOBz.js";
7
20
  import { n as SerializedPageTree } from "./index-B2EN5xn0.js";
21
+ import "./index-DMxrC6WS.js";
22
+ import "./remark-llms-eA0WMw4X.js";
8
23
  import { ReactNode } from "react";
24
+ import { Expression } from "estree-jsx";
25
+ import { Processor, Transformer } from "unified";
26
+ import { Root } from "mdast";
9
27
  /**
10
28
  * In memory file system.
11
29
  */
@@ -51,6 +69,8 @@ interface ContentStoragePageFile<Type extends string | undefined = string | unde
51
69
  format: 'page';
52
70
  slugs: string[];
53
71
  data: Data;
72
+ /** for a page of a dynamic file, its params */
73
+ params?: Params;
54
74
  }
55
75
  interface PageTreeBuilderContext<S extends ContentStorage = ContentStorage> {
56
76
  transformers: PageTreeTransformer<S>[];
@@ -65,7 +85,7 @@ interface PageTreeTransformer<S extends ContentStorage = ContentStorage> {
65
85
  file?: (this: PageTreeBuilderContext<S>, node: Item, filePath?: string) => Item;
66
86
  folder?: (this: PageTreeBuilderContext<S>, node: Folder, folderPath: string, metaPath?: string) => Folder;
67
87
  separator?: (this: PageTreeBuilderContext<S>, node: Separator) => Separator;
68
- root?: (this: PageTreeBuilderContext<S>, node: Root) => Root;
88
+ root?: (this: PageTreeBuilderContext<S>, node: Root$1) => Root$1;
69
89
  }
70
90
  interface PageTreeOptions<S extends ContentStorage = ContentStorage> {
71
91
  /** generate URL from page */
@@ -99,7 +119,7 @@ interface PageTreeOptions<S extends ContentStorage = ContentStorage> {
99
119
  }
100
120
  interface PageTreeBuilder {
101
121
  resolveFlattenPath(name: string, format: string): string;
102
- root(id?: string, path?: string): Root;
122
+ root(id?: string, path?: string): Root$1;
103
123
  }
104
124
  /**
105
125
  * a function to generate slugs, return `undefined` to generate default slugs.
@@ -182,6 +202,8 @@ interface Page<Type extends string | undefined = string | undefined, Data extend
182
202
  slugs: string[];
183
203
  url: string;
184
204
  data: Data;
205
+ /** for a page of a dynamic file, its params */
206
+ params?: Params;
185
207
  locale?: string | undefined;
186
208
  }
187
209
  interface Meta<Type extends string | undefined = string | undefined, Data extends MetaData = MetaData> extends SharedFileInfo {
@@ -192,8 +214,8 @@ interface LoaderOutput<Config extends LoaderConfig = LoaderConfig> {
192
214
  readonly $inferPage: Config['page'];
193
215
  readonly $inferMeta: Config['meta'];
194
216
  readonly $infer: Config;
195
- pageTree: Config['i18n'] extends I18nConfig ? Record<string, Root> : Root;
196
- getPageTree: (locale?: string) => Root;
217
+ pageTree: Config['i18n'] extends I18nConfig ? Record<string, Root$1> : Root$1;
218
+ getPageTree: (locale?: string) => Root$1;
197
219
  /**
198
220
  * get referenced page from href, supported:
199
221
  *
@@ -246,7 +268,7 @@ interface LoaderOutput<Config extends LoaderConfig = LoaderConfig> {
246
268
  */
247
269
  getPageByUrl: (url: string, language?: string) => Config['page'] | undefined;
248
270
  getNodePage: (node: Item, language?: string) => Config['page'] | undefined;
249
- getNodeMeta: (node: Folder | Root, language?: string) => Config['meta'] | undefined;
271
+ getNodeMeta: (node: Folder | Root$1, language?: string) => Config['meta'] | undefined;
250
272
  /**
251
273
  * generate static params for Next.js SSG
252
274
  *
@@ -257,7 +279,7 @@ interface LoaderOutput<Config extends LoaderConfig = LoaderConfig> {
257
279
  /**
258
280
  * serialize page tree for non-RSC environments
259
281
  */
260
- serializePageTree: (tree: Root) => Promise<SerializedPageTree>;
282
+ serializePageTree: (tree: Root$1) => Promise<SerializedPageTree>;
261
283
  }
262
284
  declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): ResolvedLoaderConfig['url'];
263
285
  /** content loader API for static content sources */
@@ -376,7 +398,11 @@ type SourceConfig = {
376
398
  pageData: PageData;
377
399
  metaData: MetaData;
378
400
  };
401
+ /** the values of dynamic segments, by their names */
402
+ type Params = Record<string, string>;
379
403
  interface MetaData {
404
+ /** the params of the pages in this folder, like Next.js `generateStaticParams()` */
405
+ staticParams?: Params[] | undefined;
380
406
  icon?: string | undefined;
381
407
  title?: string | undefined;
382
408
  root?: boolean | string | undefined;
@@ -387,6 +413,8 @@ interface MetaData {
387
413
  description?: string | undefined;
388
414
  }
389
415
  interface PageData {
416
+ /** the params of the pages this dynamic file makes, like Next.js `generateStaticParams()` */
417
+ staticParams?: Params[] | undefined;
390
418
  icon?: string | undefined;
391
419
  title?: string | undefined;
392
420
  description?: string | undefined;
@@ -418,10 +446,14 @@ interface VirtualPage<Data extends PageData> extends BaseVirtualFile {
418
446
  */
419
447
  slugs?: string[];
420
448
  data: Data;
449
+ /** for a file of a dynamic path, like `[framework]/deploy.mdx`, the data of its page at some params */
450
+ dataAt?: (params: Params) => Data;
421
451
  }
422
452
  interface VirtualMeta<Data extends MetaData> extends BaseVirtualFile {
423
453
  type: 'meta';
424
454
  data: Data;
455
+ /** for a meta file of a dynamic folder, like `[framework]/meta.ts`, its data in the folder filled with some params */
456
+ dataAt?: (params: Params) => Data;
425
457
  }
426
458
  /**
427
459
  * @deprecated you can directly pass a record of source objects to `loader()`.
@@ -484,13 +516,34 @@ declare function slash(path: string): string;
484
516
  * @throws Throws error if path starts with `./` or `../`
485
517
  */
486
518
  declare function normalize(path: string): string;
519
+ /** whether a path has dynamic segments, like `[framework]/deploy.mdx` */
520
+ declare function isDynamicPath(path: string): boolean;
521
+ interface StaticParamsOptions {
522
+ /** the `staticParams` of the file itself, like in its frontmatter */
523
+ staticParams?: Params[];
524
+ /**
525
+ * Read the `staticParams` of a meta file in the storage, by its path without the extension, like
526
+ * `[framework]/meta`. `undefined` when the file doesn't exist or lists none.
527
+ */
528
+ readStaticParams: (path: string) => Params[] | undefined;
529
+ }
530
+ /**
531
+ * The params of each page that a file of a dynamic path makes, like `[framework]/deploy.mdx`: its own
532
+ * `staticParams`, combined with those of the meta files in its folders by the names they share. `undefined` when the
533
+ * path isn't dynamic or nothing lists them, the file is then a page at its literal path.
534
+ *
535
+ * The meta files of a language come first, like `meta.cn.json` for `deploy.cn.mdx`.
536
+ *
537
+ * @param file - the path of the file, relative to the content directory
538
+ */
539
+ declare function getStaticParams(file: string, { staticParams, readStaticParams }: StaticParamsOptions): Params[] | undefined;
487
540
  interface Context {
488
541
  lang?: string;
489
542
  }
490
543
  interface LLMsConfig<Page = unknown> {
491
544
  TAB?: string;
492
- renderName?: (item: Node | Root, ctx: Context) => string;
493
- renderDescription?: (item: Root | Item | Folder, ctx: Context) => string;
545
+ renderName?: (item: Node | Root$1, ctx: Context) => string;
546
+ renderDescription?: (item: Root$1 | Item | Folder, ctx: Context) => string;
494
547
  renderUrl?: (item: Item, ctx: Context) => string;
495
548
  /**
496
549
  * Render a page as Markdown, required by `page()` and `full()`.
@@ -527,4 +580,48 @@ declare function llms<C extends LoaderConfig = LoaderConfig>(input: () => Awaita
527
580
  renderPage: (page: C['page']) => Awaitable<string>;
528
581
  }): LLMsWithPages<C['page'], Promise<string>>;
529
582
  declare function llms<C extends LoaderConfig = LoaderConfig>(input: () => Awaitable<LoaderOutput<C>>, config?: LLMsConfig<C['page']>): LLMs<Promise<string>>;
530
- export { types_d_exports as A, ContentStorage as B, LoaderPlugin as C, ResolvedLoaderConfig as D, Page as E, slugsPlugin as F, ContentStoragePageFile as H, PageTreeBuilder as I, PageTreeBuilderContext as L, SlugsPluginOptions as M, getSlugs as N, createGetUrl as O, slugsFromData as P, PageTreeOptions as R, LoaderOutput as S, Meta as T, FileSystem as U, ContentStorageMetaFile as V, dynamicLoader as _, path_d_exports as a, LoaderConfig as b, PageData as c, StaticSource as d, VirtualFile as f, DynamicLoaderConfig as g, DynamicLoader as h, llms as i, SlugFn as j, loader as k, Source as l, update as m, LLMsConfig as n, DynamicSource as o, multiple as p, LLMsWithPages as r, MetaData as s, LLMs as t, SourceUnion as u, InferMetaType as v, LoaderPluginOption as w, LoaderOptions as x, InferPageType as y, PageTreeTransformer as z };
583
+ declare module 'vfile' {
584
+ interface DataMap {
585
+ /** [Fumadocs: remark-show] for a page of a dynamic file, its params, read as `props` */
586
+ params?: Params;
587
+ }
588
+ }
589
+ interface RemarkShowOptions {
590
+ /**
591
+ * Values resolved at build time, by the names code reads them with, like the `define` option of Vite:
592
+ * `{ 'import.meta.env.EDITION': 'pro' }`. They are added to the defaults.
593
+ *
594
+ * A function decides them per page from its params, the defaults it doesn't return aren't resolved.
595
+ *
596
+ * @defaultValue the params of the page as `props`, and the env vars that bundlers inline into pages, with a
597
+ * `NEXT_PUBLIC_`, `VITE_` or `PUBLIC_` prefix, as `process.env` and `import.meta.env`
598
+ */
599
+ define?: Record<string, unknown> | ((page: {
600
+ params?: Params;
601
+ defaults: Record<string, unknown>;
602
+ }) => Record<string, unknown>);
603
+ }
604
+ /** the element of the branches checked when rendering, defined by the `declaration` of {@link ShowContext} */
605
+ declare const showElement = "_Show";
606
+ interface ShowContext {
607
+ /** the value of an expression, when the build-time values decide it */
608
+ evaluate: (expression: Expression) => {
609
+ value: unknown;
610
+ } | undefined;
611
+ /** whether code may read build-time values, to skip parsing the code that doesn't */
612
+ reads: (code: string) => boolean;
613
+ /** the ESM code that defines `showElement` */
614
+ declaration: string;
615
+ }
616
+ /**
617
+ * The build-time values of pages, for ports of `remarkShow()` to other compilers. Call it with the params of each
618
+ * page.
619
+ */
620
+ declare function createShowContext({ define }?: RemarkShowOptions): (params?: Params) => ShowContext;
621
+ /**
622
+ * Decide `<show when={...}>` branches before other plugins see the tree: a branch decided by `define` or the params of
623
+ * the page (`file.data.params`, as `props`) is removed or unwrapped, the others are checked when rendering. Text
624
+ * interpolations they decide, like `{props.framework}`, become text. Other expressions read `props` when rendering.
625
+ */
626
+ declare function remarkShow(this: Processor, options?: RemarkShowOptions): Transformer<Root, Root>;
627
+ export { LoaderOptions as A, SlugFn as B, update as C, InferMetaType as D, dynamicLoader as E, Page as F, PageTreeBuilder as G, getSlugs as H, ResolvedLoaderConfig as I, PageTreeTransformer as J, PageTreeBuilderContext as K, createGetUrl as L, LoaderPlugin as M, LoaderPluginOption as N, InferPageType as O, Meta as P, FileSystem as Q, loader as R, multiple as S, DynamicLoaderConfig as T, slugsFromData as U, SlugsPluginOptions as V, slugsPlugin as W, ContentStorageMetaFile as X, ContentStorage as Y, ContentStoragePageFile as Z, Params as _, showElement as a, StaticSource as b, LLMsWithPages as c, getStaticParams as d, isDynamicPath as f, PageData as g, MetaData as h, remarkShow as i, LoaderOutput as j, LoaderConfig as k, llms as l, DynamicSource as m, ShowContext as n, LLMs as o, path_d_exports as p, PageTreeOptions as q, createShowContext as r, LLMsConfig as s, RemarkShowOptions as t, StaticParamsOptions as u, Source as v, DynamicLoader as w, VirtualFile as x, SourceUnion as y, types_d_exports as z };
@@ -1,5 +1,5 @@
1
- import { n as DistributiveOmit, t as Awaitable } from "./types-Dvkw0Kd0.js";
2
1
  import { i as Highlighter } from "./index-BhAz6nyI.js";
2
+ import { n as DistributiveOmit, t as Awaitable } from "./types-Dvkw0Kd0.js";
3
3
  import { Root } from "hast";
4
4
  import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, HighlighterCore } from "shiki";
5
5
  interface InitOptions {
package/dist/mcp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { r as SearchServer } from "./server-MsDv36PV.js";
2
+ import { c as LLMsWithPages, j as LoaderOutput, k as LoaderConfig } from "./index-BOhS1UKT.js";
1
3
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
2
- import { S as LoaderOutput, b as LoaderConfig, r as LLMsWithPages } from "./index-DWVer6sb.js";
3
- import { r as SearchServer } from "./server-BUYLz3H4.js";
4
4
  import { McpServer } from "@modelcontextprotocol/server";
5
5
  /**
6
6
  * Register a `search` tool, backed by a search server from `fumadocs-core/search/server`.
@@ -1,7 +1,7 @@
1
1
  import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-DpVfAX1x.js";
2
- import { o as transformerTab } from "../rehype-code.core-D1aZ5yla.js";
2
+ import { o as transformerTab } from "../rehype-code.core-BeCtKe7K.js";
3
3
  import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-Bi4LROAz.js";
4
- import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-CPNaiqAY.js";
4
+ import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-Czh_8L5z.js";
5
5
  import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-BwyGdFld.js";
6
6
  import { n as extractCodeRegion, r as remarkInclude, t as RemarkIncludeOptions } from "../remark-include-D_FmDdtI.js";
7
7
  import { a as remarkStructureDefaultOptions, i as remarkStructure, n as StructuredData, o as structure, r as StructuredDataContent, t as StructureOptions } from "../remark-structure-50nmY6sX.js";
@@ -16,6 +16,6 @@ import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generate
16
16
  import { a as remarkMdxFiles, r as RemarkMdxFilesOptions } from "../remark-mdx-files-BJvKexDp.js";
17
17
  import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-BrK4YVTJ.js";
18
18
  import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-2Ei4IDr4.js";
19
+ import { i as remarkShow, t as RemarkShowOptions } from "../index-BOhS1UKT.js";
19
20
  import { t as LLMsOptions } from "../remark-llms-eA0WMw4X.js";
20
- import "../index-BFnMPJLk.js";
21
- export { CodeBlockAttributes, type CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, type LLMsOptions, RehypeCodeOptions, RehypeTOCItemType, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, type RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, RemarkIncludeOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, RemarkStepsOptions, StructureOptions, StructuredData, StructuredDataContent, extractCodeRegion, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkInclude, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
21
+ export { CodeBlockAttributes, type CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, type LLMsOptions, RehypeCodeOptions, RehypeTOCItemType, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, type RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, RemarkIncludeOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, type RemarkShowOptions, RemarkStepsOptions, StructureOptions, StructuredData, StructuredDataContent, extractCodeRegion, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkInclude, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkShow, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
@@ -1,19 +1,20 @@
1
- import { remarkHeading } from "./remark-heading.js";
2
- import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
3
1
  import { remarkGfm } from "./remark-gfm.js";
4
- import { i as transformerTab } from "../rehype-code.core-Dq2jmvan.js";
5
- import { transformerIcon } from "./transformer-icon.js";
6
2
  import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
7
3
  import { remarkImage } from "./remark-image.js";
4
+ import { i as transformerTab } from "../rehype-code.core-Jt2VtK1A.js";
5
+ import { transformerIcon } from "./transformer-icon.js";
8
6
  import { extractCodeRegion, remarkInclude } from "./remark-include.js";
9
7
  import { remarkStructure, remarkStructureDefaultOptions, structure } from "./remark-structure.js";
8
+ import { remarkHeading } from "./remark-heading.js";
10
9
  import { remarkAdmonition } from "./remark-admonition.js";
11
10
  import { remarkDirectiveAdmonition } from "./remark-directive-admonition.js";
12
11
  import { rehypeToc } from "./rehype-toc.js";
13
12
  import { remarkCodeTab } from "./remark-code-tab.js";
14
13
  import { remarkSteps } from "./remark-steps.js";
15
14
  import { remarkNpm } from "./remark-npm.js";
15
+ import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
16
16
  import { remarkMdxFiles } from "./remark-mdx-files.js";
17
17
  import { remarkMdxMermaid } from "./remark-mdx-mermaid.js";
18
18
  import { remarkFeedbackBlock } from "./remark-feedback-block.js";
19
- export { extractCodeRegion, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkInclude, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
19
+ import { remarkShow } from "./remark-show.js";
20
+ export { extractCodeRegion, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkInclude, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkShow, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
@@ -1,3 +1,3 @@
1
- import { a as rehypeCodeFromHighlighter, i as rehypeCodeDefaultOptions, n as RehypeCodeOptionsCommon, o as transformerTab, r as createRehypeCode, t as RehypeCodeFromHighlighterOptions } from "../rehype-code.core-D1aZ5yla.js";
1
+ import { a as rehypeCodeFromHighlighter, i as rehypeCodeDefaultOptions, n as RehypeCodeOptionsCommon, o as transformerTab, r as createRehypeCode, t as RehypeCodeFromHighlighterOptions } from "../rehype-code.core-BeCtKe7K.js";
2
2
  import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-Bi4LROAz.js";
3
3
  export { type CodeBlockIcon, RehypeCodeFromHighlighterOptions, RehypeCodeOptionsCommon, createRehypeCode, rehypeCodeDefaultOptions, rehypeCodeFromHighlighter, transformerIcon, transformerTab };
@@ -1,3 +1,3 @@
1
- import { i as transformerTab, n as rehypeCodeDefaultOptions, r as rehypeCodeFromHighlighter, t as createRehypeCode } from "../rehype-code.core-Dq2jmvan.js";
1
+ import { i as transformerTab, n as rehypeCodeDefaultOptions, r as rehypeCodeFromHighlighter, t as createRehypeCode } from "../rehype-code.core-Jt2VtK1A.js";
2
2
  import { transformerIcon } from "./transformer-icon.js";
3
3
  export { createRehypeCode, rehypeCodeDefaultOptions, rehypeCodeFromHighlighter, transformerIcon, transformerTab };
@@ -1,4 +1,4 @@
1
- import { o as transformerTab } from "../rehype-code.core-D1aZ5yla.js";
1
+ import { o as transformerTab } from "../rehype-code.core-BeCtKe7K.js";
2
2
  import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-Bi4LROAz.js";
3
- import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-CPNaiqAY.js";
3
+ import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-Czh_8L5z.js";
4
4
  export { type CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,5 +1,5 @@
1
1
  import { defaultShikiFactory, wasmShikiFactory } from "../highlight/shiki/full.js";
2
- import { i as transformerTab, n as rehypeCodeDefaultOptions$1, t as createRehypeCode } from "../rehype-code.core-Dq2jmvan.js";
2
+ import { i as transformerTab, n as rehypeCodeDefaultOptions$1, t as createRehypeCode } from "../rehype-code.core-Jt2VtK1A.js";
3
3
  import { transformerIcon } from "./transformer-icon.js";
4
4
  // src/mdx-plugins/rehype-code.ts
5
5
  const rehypeCodeDefaultOptions = {
@@ -1,5 +1,5 @@
1
- import { s as walk } from "../utils-DV8PBZiI.js";
2
1
  import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
2
+ import { s as walk } from "../utils-DV8PBZiI.js";
3
3
  // src/mdx-plugins/remark-code-tab.ts
4
4
  const Types = {
5
5
  CodeBlockTabs(processor, nodes, withMdx, withParent) {
@@ -1,7 +1,7 @@
1
+ import { frontmatter } from "../content/md/frontmatter.js";
2
+ import { t as headingIdRegex } from "../heading-id-BXARvmRb.js";
1
3
  import { embedSource, replaceSource } from "./stringifier.js";
2
4
  import { s as walk, t as flattenNode } from "../utils-DV8PBZiI.js";
3
- import { t as headingIdRegex } from "../heading-id-BXARvmRb.js";
4
- import { frontmatter } from "../content/md/frontmatter.js";
5
5
  import Slugger from "github-slugger";
6
6
  import * as path$1 from "node:path";
7
7
  import * as fs from "node:fs/promises";
@@ -1,5 +1,5 @@
1
- import { createStringifier } from "./stringifier.js";
2
1
  import { i as isJsxElement, o as toMdxExportRaw } from "../utils-DV8PBZiI.js";
2
+ import { createStringifier } from "./stringifier.js";
3
3
  import { n as stringifyHeadingId } from "../heading-id-BXARvmRb.js";
4
4
  // src/mdx-plugins/remark-llms.ts
5
5
  const componentNameRegex = /^[A-Z][\w$]*$/;
@@ -1,6 +1,6 @@
1
+ import { generateCodeBlockTabs } from "./codeblock-utils.js";
1
2
  import { replaceSource } from "./stringifier.js";
2
3
  import { s as walk } from "../utils-DV8PBZiI.js";
3
- import { generateCodeBlockTabs } from "./codeblock-utils.js";
4
4
  import convert from "npm-to-yarn";
5
5
  // src/mdx-plugins/remark-npm.ts
6
6
  function convertLines(cmd, to) {
@@ -0,0 +1,2 @@
1
+ import { a as showElement, i as remarkShow, n as ShowContext, r as createShowContext, t as RemarkShowOptions } from "../index-BOhS1UKT.js";
2
+ export { RemarkShowOptions, ShowContext, createShowContext, remarkShow, showElement };
@@ -0,0 +1,162 @@
1
+ import { replaceSource } from "./stringifier.js";
2
+ // src/mdx-plugins/remark-show.ts
3
+ /** the element of the branches checked when rendering, defined by the `declaration` of {@link ShowContext} */
4
+ const showElement = "_Show";
5
+ /**
6
+ * The build-time values of pages, for ports of `remarkShow()` to other compilers. Call it with the params of each
7
+ * page.
8
+ */
9
+ function createShowContext({ define = {} } = {}) {
10
+ const env = {};
11
+ for (const [k, v] of Object.entries(process.env)) if (v !== void 0 && /^(NEXT_PUBLIC|VITE|PUBLIC)_/.test(k)) env[k] = v;
12
+ return (params) => {
13
+ const defaults = {
14
+ "process.env": env,
15
+ "import.meta.env": env
16
+ };
17
+ if (params) defaults.props = params;
18
+ const values = typeof define === "function" ? define({
19
+ params,
20
+ defaults
21
+ }) : {
22
+ ...defaults,
23
+ ...define
24
+ };
25
+ const names = Object.keys(values);
26
+ return {
27
+ reads: (code) => names.some((name) => code.includes(name)),
28
+ evaluate(expression) {
29
+ const value = evaluate(expression, values);
30
+ if (value !== unknown) return { value };
31
+ },
32
+ declaration: `export function ${showElement}(props) { return props.when ? props.children : null }`
33
+ };
34
+ };
35
+ }
36
+ /**
37
+ * Decide `<show when={...}>` branches before other plugins see the tree: a branch decided by `define` or the params of
38
+ * the page (`file.data.params`, as `props`) is removed or unwrapped, the others are checked when rendering. Text
39
+ * interpolations they decide, like `{props.framework}`, become text. Other expressions read `props` when rendering.
40
+ */
41
+ function remarkShow(options) {
42
+ const createContext = createShowContext(options);
43
+ return (tree, file) => {
44
+ const context = createContext(file.data.params);
45
+ let used = false;
46
+ /** the nodes with their branches decided, in one pass so a parent with many branches stays linear */
47
+ const visitAll = (nodes, out) => {
48
+ for (const node of nodes) {
49
+ if (node.type === "mdxTextExpression") {
50
+ const statement = node.data?.estree?.body[0];
51
+ const result = statement?.type === "ExpressionStatement" ? context.evaluate(statement.expression) : void 0;
52
+ const value = result?.value;
53
+ if (typeof value === "string" || typeof value === "number") {
54
+ replaceSource(file, node, String(value));
55
+ out.push({
56
+ type: "text",
57
+ value: String(value)
58
+ });
59
+ } else if (result && (value === null || typeof value !== "object")) replaceSource(file, node, "");
60
+ else out.push(node);
61
+ continue;
62
+ }
63
+ if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === "show") {
64
+ const condition = getCondition(node) ?? file.fail("`<show>` needs a `when` expression, like `when={x === \"y\"}`", node);
65
+ const result = context.evaluate(condition);
66
+ if (result) {
67
+ replaceSource(file, node, result.value ? (s) => s.inner(node) : "");
68
+ if (!result.value) continue;
69
+ if (node.type === "mdxJsxTextElement" || node.children[0]?.position?.start.line !== node.position?.start.line) {
70
+ visitAll(node.children, out);
71
+ continue;
72
+ }
73
+ node.name = null;
74
+ node.attributes = [];
75
+ } else {
76
+ used = true;
77
+ node.name = showElement;
78
+ }
79
+ }
80
+ if ("children" in node) visit(node);
81
+ out.push(node);
82
+ }
83
+ };
84
+ const visit = (parent) => {
85
+ const children = [];
86
+ visitAll(parent.children, children);
87
+ parent.children = children;
88
+ };
89
+ visit(tree);
90
+ if (!used) return;
91
+ const [declaration] = this.parse(context.declaration).children;
92
+ delete declaration.position;
93
+ tree.children.unshift(declaration);
94
+ };
95
+ }
96
+ function getCondition(node) {
97
+ for (const attr of node.attributes) {
98
+ if (attr.type !== "mdxJsxAttribute" || attr.name !== "when") continue;
99
+ if (typeof attr.value !== "object" || !attr.value) return;
100
+ const statement = attr.value.data?.estree?.body[0];
101
+ if (statement?.type === "ExpressionStatement") return statement.expression;
102
+ }
103
+ }
104
+ const unknown = Symbol();
105
+ function evaluate(node, define) {
106
+ switch (node.type) {
107
+ case "Literal": return node.value;
108
+ case "Identifier":
109
+ case "MetaProperty":
110
+ case "MemberExpression": return resolve(node, define);
111
+ case "UnaryExpression": {
112
+ const value = node.operator === "!" ? evaluate(node.argument, define) : unknown;
113
+ return value === unknown ? unknown : !value;
114
+ }
115
+ case "BinaryExpression": {
116
+ if (node.left.type === "PrivateIdentifier") return unknown;
117
+ const a = evaluate(node.left, define);
118
+ const b = evaluate(node.right, define);
119
+ if (a === unknown || b === unknown) return unknown;
120
+ switch (node.operator) {
121
+ case "===": return a === b;
122
+ case "!==": return a !== b;
123
+ }
124
+ return unknown;
125
+ }
126
+ case "LogicalExpression": {
127
+ const left = evaluate(node.left, define);
128
+ if (left === unknown) return unknown;
129
+ return (node.operator === "&&" ? !left : node.operator === "||" ? !!left : left != null) ? left : evaluate(node.right, define);
130
+ }
131
+ case "ConditionalExpression": {
132
+ const test = evaluate(node.test, define);
133
+ if (test === unknown) return unknown;
134
+ return evaluate(test ? node.consequent : node.alternate, define);
135
+ }
136
+ default: return unknown;
137
+ }
138
+ }
139
+ /** the value of a reference by its name in `define`, like `import.meta.env.EDITION`, or a member of one */
140
+ function resolve(node, define) {
141
+ if (node.type === "Identifier" && node.name === "undefined") return void 0;
142
+ const name = nameOf(node);
143
+ if (name !== void 0 && Object.hasOwn(define, name)) return define[name];
144
+ if (node.type !== "MemberExpression" || node.object.type === "Super") return unknown;
145
+ const object = resolve(node.object, define);
146
+ const key = keyOf(node);
147
+ if (typeof object !== "object" || object === null || key === void 0 || !Object.hasOwn(object, key)) return unknown;
148
+ return object[key];
149
+ }
150
+ function nameOf(node) {
151
+ if (node.type === "Identifier") return node.name;
152
+ if (node.type === "MetaProperty") return `${node.meta.name}.${node.property.name}`;
153
+ if (node.type !== "MemberExpression" || node.object.type === "Super") return;
154
+ const object = nameOf(node.object);
155
+ const key = keyOf(node);
156
+ if (object !== void 0 && typeof key === "string") return `${object}.${key}`;
157
+ }
158
+ function keyOf(node) {
159
+ if (!node.computed && node.property.type === "Identifier") return node.property.name;
160
+ if (node.property.type === "Literal" && typeof node.property.value !== "object") return node.property.value;
161
+ }
162
+ export { createShowContext, remarkShow, showElement };
@@ -1,5 +1,5 @@
1
- import { replaceSource } from "./stringifier.js";
2
1
  import { r as handleTag, s as walk } from "../utils-DV8PBZiI.js";
2
+ import { replaceSource } from "./stringifier.js";
3
3
  // src/mdx-plugins/remark-steps.ts
4
4
  const StepRegex = /^(\d+)\.\s(.+)$/;
5
5
  const StepTag = "[step]";
@@ -1,5 +1,5 @@
1
- import { createStringifier } from "./stringifier.js";
2
1
  import { a as toMdxExport, i as isJsxElement, s as walk } from "../utils-DV8PBZiI.js";
2
+ import { createStringifier } from "./stringifier.js";
3
3
  import { t as headingIdRegex } from "../heading-id-BXARvmRb.js";
4
4
  import { remarkHeading } from "./remark-heading.js";
5
5
  import { tableRowToStructuredData } from "../search/index.js";
@@ -129,6 +129,11 @@ function createStringifier(file, namespace, expression = (_, fallback) => fallba
129
129
  appliedEnd = edit.end;
130
130
  }
131
131
  cursor = edit.end;
132
+ if (text === "" && /^[ \t]*$/.test(source.slice(source.lastIndexOf("\n", edit.start - 1) + 1, edit.start))) {
133
+ blankLines.lastIndex = cursor;
134
+ if (blankLines.test(source)) cursor = Math.min(blankLines.lastIndex, end);
135
+ if (cursor === end) out = out.trimEnd();
136
+ }
132
137
  }
133
138
  return out + source.slice(cursor, end);
134
139
  }
@@ -215,6 +220,7 @@ function markdownTable(rows) {
215
220
  ...table.slice(1)
216
221
  ].map(line).join("\n");
217
222
  }
223
+ const blankLines = /(?:[ \t\r]*\n)+/y;
218
224
  const containerPrefixRegex = /^(?:[ \t]*(?:>|[-*+](?=[ \t])|\d{1,9}[.)](?=[ \t])))*[ \t]*/;
219
225
  /** the prefix of the containers (e.g. lists & blockquotes) at `start`, on the lines after the first */
220
226
  function containerPrefix(source, start) {
@@ -1,6 +1,6 @@
1
- import { t as Awaitable } from "./types-Dvkw0Kd0.js";
2
1
  import { n as StructuredData } from "./remark-structure-50nmY6sX.js";
3
- import { S as LoaderOutput, b as LoaderConfig } from "./index-DWVer6sb.js";
2
+ import { j as LoaderOutput, k as LoaderConfig } from "./index-BOhS1UKT.js";
3
+ import { t as Awaitable } from "./types-Dvkw0Kd0.js";
4
4
  import { Meilisearch } from "meilisearch";
5
5
  interface DocumentRecord {
6
6
  title: string;
@@ -1,6 +1,6 @@
1
- import { n as SearchAPI } from "./server-BUYLz3H4.js";
2
1
  import { r as SortedResult } from "./index-CE1OSGGq.js";
3
- import { t as DocumentRecord } from "./meilisearch-CsyDr1xA.js";
2
+ import { n as SearchAPI } from "./server-MsDv36PV.js";
3
+ import { t as DocumentRecord } from "./meilisearch-DzjbVbAn.js";
4
4
  import Mixedbread from "@mixedbread/sdk";
5
5
  import { ScoredTextInputChunk } from "@mixedbread/sdk/resources/stores";
6
6
  /**