@hanzo/docs-core 16.5.0 → 16.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -3
  3. package/dist/{advanced-BRT5Ij43.js → advanced-BH0syJ-M.js} +3 -4
  4. package/dist/{algolia-CQPXCnjV.js → algolia-C7Crg8-5.js} +2 -3
  5. package/dist/breadcrumb.d.ts +2 -3
  6. package/dist/breadcrumb.js +3 -4
  7. package/dist/{chunk-B-ezknvj.js → chunk-CaR5F9JI.js} +3 -3
  8. package/dist/content/github.d.ts +1 -2
  9. package/dist/content/github.js +1 -2
  10. package/dist/content/index.d.ts +3 -4
  11. package/dist/content/index.js +1 -2
  12. package/dist/content/mdx/preset-bundler.d.ts +9 -10
  13. package/dist/content/mdx/preset-bundler.js +2 -3
  14. package/dist/content/mdx/preset-runtime.d.ts +9 -10
  15. package/dist/content/mdx/preset-runtime.js +2 -3
  16. package/dist/content/toc.d.ts +1 -3
  17. package/dist/content/toc.js +4 -5
  18. package/dist/create-i18n-Cv3Cocbs.d.ts +51 -0
  19. package/dist/{definitions-DuxDer_c.d.ts → definitions-DSNTbAwC.d.ts} +1 -2
  20. package/dist/dynamic-link.d.ts +3 -4
  21. package/dist/dynamic-link.js +1 -3
  22. package/dist/{fetch-B5e9CFfN.js → fetch-HotVeLLF.js} +1 -2
  23. package/dist/framework/index.d.ts +5 -6
  24. package/dist/framework/index.js +18 -19
  25. package/dist/framework/next.d.ts +3 -4
  26. package/dist/framework/next.js +1 -2
  27. package/dist/framework/react-router.d.ts +3 -4
  28. package/dist/framework/react-router.js +1 -2
  29. package/dist/framework/tanstack.d.ts +3 -4
  30. package/dist/framework/tanstack.js +1 -2
  31. package/dist/framework/waku.d.ts +3 -4
  32. package/dist/framework/waku.js +1 -2
  33. package/dist/hast-utils-BmGqqmvo.js +15 -0
  34. package/dist/highlight/client.d.ts +2 -4
  35. package/dist/highlight/client.js +7 -13
  36. package/dist/highlight/config.d.ts +15 -0
  37. package/dist/highlight/config.js +18 -0
  38. package/dist/highlight/core/client.d.ts +31 -0
  39. package/dist/highlight/core/client.js +68 -0
  40. package/dist/highlight/core/index.d.ts +27 -0
  41. package/dist/highlight/core/index.js +69 -0
  42. package/dist/highlight/index.d.ts +34 -2
  43. package/dist/highlight/index.js +57 -2
  44. package/dist/i18n/index.d.ts +39 -1
  45. package/dist/i18n/index.js +1 -2
  46. package/dist/i18n/middleware.d.ts +2 -3
  47. package/dist/i18n/middleware.js +1 -2
  48. package/dist/{icon-BWwSDabM.js → icon-OtPFhyk1.js} +1 -2
  49. package/dist/link.d.ts +3 -4
  50. package/dist/link.js +1 -2
  51. package/dist/{mdast-utils-mc9-X-PK.js → mdast-utils-gJMY143g.js} +1 -2
  52. package/dist/mdx-plugins/codeblock-utils.d.ts +35 -1
  53. package/dist/mdx-plugins/codeblock-utils.js +1 -2
  54. package/dist/mdx-plugins/index.d.ts +18 -15
  55. package/dist/mdx-plugins/index.js +7 -5
  56. package/dist/mdx-plugins/rehype-code.core.d.ts +38 -0
  57. package/dist/mdx-plugins/rehype-code.core.js +104 -0
  58. package/dist/mdx-plugins/rehype-code.d.ts +18 -2
  59. package/dist/mdx-plugins/rehype-code.js +24 -3
  60. package/dist/mdx-plugins/rehype-toc.d.ts +16 -1
  61. package/dist/mdx-plugins/rehype-toc.js +127 -1
  62. package/dist/mdx-plugins/remark-admonition.d.ts +20 -1
  63. package/dist/mdx-plugins/remark-admonition.js +2 -3
  64. package/dist/mdx-plugins/remark-code-tab.d.ts +30 -1
  65. package/dist/mdx-plugins/remark-code-tab.js +4 -5
  66. package/dist/mdx-plugins/remark-directive-admonition.d.ts +34 -1
  67. package/dist/mdx-plugins/remark-directive-admonition.js +1 -2
  68. package/dist/mdx-plugins/remark-feedback-block.d.ts +51 -0
  69. package/dist/mdx-plugins/remark-feedback-block.js +47 -0
  70. package/dist/mdx-plugins/remark-gfm.d.ts +2 -2
  71. package/dist/mdx-plugins/remark-heading.d.ts +35 -1
  72. package/dist/mdx-plugins/remark-heading.js +2 -3
  73. package/dist/mdx-plugins/remark-image.d.ts +63 -1
  74. package/dist/mdx-plugins/remark-image.js +1 -2
  75. package/dist/mdx-plugins/remark-mdx-files.d.ts +55 -2
  76. package/dist/mdx-plugins/remark-mdx-files.js +103 -13
  77. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +15 -1
  78. package/dist/mdx-plugins/remark-mdx-mermaid.js +1 -2
  79. package/dist/mdx-plugins/remark-npm.d.ts +34 -1
  80. package/dist/mdx-plugins/remark-npm.js +1 -2
  81. package/dist/mdx-plugins/remark-steps.d.ts +26 -1
  82. package/dist/mdx-plugins/remark-steps.js +1 -2
  83. package/dist/mdx-plugins/remark-structure.d.ts +75 -1
  84. package/dist/mdx-plugins/remark-structure.js +7 -8
  85. package/dist/{mixedbread-DlByNYSd.js → mixedbread-Bx9drx9S.js} +6 -5
  86. package/dist/negotiation/index.d.ts +1 -2
  87. package/dist/negotiation/index.js +1 -2
  88. package/dist/{normalize-url-ChLsV26G.js → normalize-url-DUHbcuVM.js} +1 -2
  89. package/dist/{orama-cloud-DH3g37zc.js → orama-cloud-ByznDyOk.js} +6 -7
  90. package/dist/orama-cloud-legacy-BbgJnf5f.js +81 -0
  91. package/dist/page-tree/index.d.ts +3 -45
  92. package/dist/page-tree/index.js +1 -1
  93. package/dist/{index-2U6Tl4--.d.ts → path-B77y3W0_.d.ts} +111 -98
  94. package/dist/{path-DHIjrDBP.js → path-D0Bwm6Fs.js} +2 -3
  95. package/dist/{remove-undefined-Cfs4o_mM.js → remove-undefined-CJm9cyrC.js} +1 -2
  96. package/dist/search/algolia.d.ts +66 -2
  97. package/dist/search/algolia.js +1 -2
  98. package/dist/search/client.d.ts +30 -7
  99. package/dist/search/client.js +27 -22
  100. package/dist/search/index.d.ts +1 -2
  101. package/dist/search/index.js +41 -1
  102. package/dist/search/orama-cloud-legacy.d.ts +77 -0
  103. package/dist/search/orama-cloud-legacy.js +49 -0
  104. package/dist/search/orama-cloud.d.ts +5 -9
  105. package/dist/search/orama-cloud.js +1 -2
  106. package/dist/search/server.d.ts +87 -4
  107. package/dist/search/server.js +7 -8
  108. package/dist/source/client/index.d.ts +13 -11
  109. package/dist/source/client/index.js +22 -13
  110. package/dist/source/index.d.ts +5 -3
  111. package/dist/source/index.js +428 -333
  112. package/dist/source/plugins/lucide-icons.d.ts +5 -4
  113. package/dist/source/plugins/lucide-icons.js +2 -3
  114. package/dist/source/plugins/slugs.d.ts +24 -2
  115. package/dist/source/plugins/slugs.js +2 -3
  116. package/dist/source/plugins/status-badges.d.ts +52 -0
  117. package/dist/source/plugins/status-badges.js +54 -0
  118. package/dist/source/schema.d.ts +1 -3
  119. package/dist/source/schema.js +1 -2
  120. package/dist/{static-Dq8pA8Ay.js → static-DTxK4eHk.js} +5 -6
  121. package/dist/toc.d.ts +1 -2
  122. package/dist/toc.js +1 -2
  123. package/dist/{rehype-code-sM9Tq-r7.js → transformer-icon-BYedaeE8.js} +1 -96
  124. package/dist/transformer-icon-D7-6aFzt.d.ts +18 -0
  125. package/dist/types-BSnJn7kF.d.ts +6 -0
  126. package/dist/{util-CK2ykiif.d.ts → util-C60LmklF.d.ts} +1 -2
  127. package/dist/{util-s9piKHsk.js → util-De0ALHOx.js} +1 -2
  128. package/dist/utils/use-media-query.d.ts +1 -2
  129. package/dist/utils/use-media-query.js +1 -2
  130. package/dist/utils/use-on-change.d.ts +1 -2
  131. package/dist/utils/use-on-change.js +1 -2
  132. package/dist/{utils-DUvi2WkD.js → utils-Bc53B3CJ.js} +8 -7
  133. package/dist/utils-IgHyYnrz.d.ts +45 -0
  134. package/package.json +68 -38
  135. package/dist/advanced-BRT5Ij43.js.map +0 -1
  136. package/dist/algolia-CQPXCnjV.js.map +0 -1
  137. package/dist/algolia-Cc1y6qWl.d.ts +0 -68
  138. package/dist/algolia-Cc1y6qWl.d.ts.map +0 -1
  139. package/dist/breadcrumb.d.ts.map +0 -1
  140. package/dist/breadcrumb.js.map +0 -1
  141. package/dist/codeblock-utils-DDnYb8gi.d.ts +0 -37
  142. package/dist/codeblock-utils-DDnYb8gi.d.ts.map +0 -1
  143. package/dist/content/github.d.ts.map +0 -1
  144. package/dist/content/github.js.map +0 -1
  145. package/dist/content/index.d.ts.map +0 -1
  146. package/dist/content/index.js.map +0 -1
  147. package/dist/content/mdx/preset-bundler.d.ts.map +0 -1
  148. package/dist/content/mdx/preset-bundler.js.map +0 -1
  149. package/dist/content/mdx/preset-runtime.d.ts.map +0 -1
  150. package/dist/content/mdx/preset-runtime.js.map +0 -1
  151. package/dist/content/toc.d.ts.map +0 -1
  152. package/dist/content/toc.js.map +0 -1
  153. package/dist/definitions-DuxDer_c.d.ts.map +0 -1
  154. package/dist/dynamic-link.d.ts.map +0 -1
  155. package/dist/dynamic-link.js.map +0 -1
  156. package/dist/fetch-B5e9CFfN.js.map +0 -1
  157. package/dist/framework/index.d.ts.map +0 -1
  158. package/dist/framework/index.js.map +0 -1
  159. package/dist/framework/next.d.ts.map +0 -1
  160. package/dist/framework/next.js.map +0 -1
  161. package/dist/framework/react-router.d.ts.map +0 -1
  162. package/dist/framework/react-router.js.map +0 -1
  163. package/dist/framework/tanstack.d.ts.map +0 -1
  164. package/dist/framework/tanstack.js.map +0 -1
  165. package/dist/framework/waku.d.ts.map +0 -1
  166. package/dist/framework/waku.js.map +0 -1
  167. package/dist/highlight/client.d.ts.map +0 -1
  168. package/dist/highlight/client.js.map +0 -1
  169. package/dist/i18n/index.js.map +0 -1
  170. package/dist/i18n/middleware.d.ts.map +0 -1
  171. package/dist/i18n/middleware.js.map +0 -1
  172. package/dist/icon-BWwSDabM.js.map +0 -1
  173. package/dist/index-2U6Tl4--.d.ts.map +0 -1
  174. package/dist/index-Bw-DCOra.d.ts +0 -41
  175. package/dist/index-Bw-DCOra.d.ts.map +0 -1
  176. package/dist/link.d.ts.map +0 -1
  177. package/dist/link.js.map +0 -1
  178. package/dist/mdast-utils-mc9-X-PK.js.map +0 -1
  179. package/dist/mdx-plugins/codeblock-utils.js.map +0 -1
  180. package/dist/mdx-plugins/remark-admonition.js.map +0 -1
  181. package/dist/mdx-plugins/remark-code-tab.js.map +0 -1
  182. package/dist/mdx-plugins/remark-directive-admonition.js.map +0 -1
  183. package/dist/mdx-plugins/remark-heading.js.map +0 -1
  184. package/dist/mdx-plugins/remark-image.js.map +0 -1
  185. package/dist/mdx-plugins/remark-mdx-files.js.map +0 -1
  186. package/dist/mdx-plugins/remark-mdx-mermaid.js.map +0 -1
  187. package/dist/mdx-plugins/remark-npm.js.map +0 -1
  188. package/dist/mdx-plugins/remark-steps.js.map +0 -1
  189. package/dist/mdx-plugins/remark-structure.js.map +0 -1
  190. package/dist/mixedbread-DlByNYSd.js.map +0 -1
  191. package/dist/negotiation/index.d.ts.map +0 -1
  192. package/dist/negotiation/index.js.map +0 -1
  193. package/dist/normalize-url-ChLsV26G.js.map +0 -1
  194. package/dist/orama-cloud-DH3g37zc.js.map +0 -1
  195. package/dist/page-tree/index.d.ts.map +0 -1
  196. package/dist/path-DHIjrDBP.js.map +0 -1
  197. package/dist/rehype-code-sM9Tq-r7.js.map +0 -1
  198. package/dist/rehype-code-vVWG4-ej.d.ts +0 -58
  199. package/dist/rehype-code-vVWG4-ej.d.ts.map +0 -1
  200. package/dist/rehype-toc-DJvSyE0o.d.ts +0 -18
  201. package/dist/rehype-toc-DJvSyE0o.d.ts.map +0 -1
  202. package/dist/rehype-toc-DVwJcwvA.js +0 -143
  203. package/dist/rehype-toc-DVwJcwvA.js.map +0 -1
  204. package/dist/remark-admonition-DOwBWzsH.d.ts +0 -22
  205. package/dist/remark-admonition-DOwBWzsH.d.ts.map +0 -1
  206. package/dist/remark-code-tab-CXsYlims.d.ts +0 -32
  207. package/dist/remark-code-tab-CXsYlims.d.ts.map +0 -1
  208. package/dist/remark-directive-admonition-BCm_yiU9.d.ts +0 -36
  209. package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +0 -1
  210. package/dist/remark-gfm-CeWpMwyk.d.ts +0 -2
  211. package/dist/remark-heading-CXvCY0go.d.ts +0 -37
  212. package/dist/remark-heading-CXvCY0go.d.ts.map +0 -1
  213. package/dist/remark-image-CvUis4R1.d.ts +0 -65
  214. package/dist/remark-image-CvUis4R1.d.ts.map +0 -1
  215. package/dist/remark-mdx-files-DOYafA4x.d.ts +0 -42
  216. package/dist/remark-mdx-files-DOYafA4x.d.ts.map +0 -1
  217. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +0 -17
  218. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +0 -1
  219. package/dist/remark-npm-Bo08HqcQ.d.ts +0 -36
  220. package/dist/remark-npm-Bo08HqcQ.d.ts.map +0 -1
  221. package/dist/remark-steps-CHJN-rtm.d.ts +0 -28
  222. package/dist/remark-steps-CHJN-rtm.d.ts.map +0 -1
  223. package/dist/remark-structure-DGuWR82i.d.ts +0 -77
  224. package/dist/remark-structure-DGuWR82i.d.ts.map +0 -1
  225. package/dist/remove-undefined-Cfs4o_mM.js.map +0 -1
  226. package/dist/search/algolia.js.map +0 -1
  227. package/dist/search/client.d.ts.map +0 -1
  228. package/dist/search/client.js.map +0 -1
  229. package/dist/search/index.d.ts.map +0 -1
  230. package/dist/search/orama-cloud.d.ts.map +0 -1
  231. package/dist/search/orama-cloud.js.map +0 -1
  232. package/dist/search/server.js.map +0 -1
  233. package/dist/search-D6ChCLhY.js +0 -44
  234. package/dist/search-D6ChCLhY.js.map +0 -1
  235. package/dist/server-DmY4lGBs.d.ts +0 -133
  236. package/dist/server-DmY4lGBs.d.ts.map +0 -1
  237. package/dist/shiki-B5wNmyIZ.js +0 -80
  238. package/dist/shiki-B5wNmyIZ.js.map +0 -1
  239. package/dist/shiki-Dq3XIYAT.d.ts +0 -33
  240. package/dist/shiki-Dq3XIYAT.d.ts.map +0 -1
  241. package/dist/source/client/index.d.ts.map +0 -1
  242. package/dist/source/client/index.js.map +0 -1
  243. package/dist/source/index.js.map +0 -1
  244. package/dist/source/plugins/lucide-icons.d.ts.map +0 -1
  245. package/dist/source/plugins/lucide-icons.js.map +0 -1
  246. package/dist/source/plugins/slugs.js.map +0 -1
  247. package/dist/source/schema.d.ts.map +0 -1
  248. package/dist/source/schema.js.map +0 -1
  249. package/dist/static-Dq8pA8Ay.js.map +0 -1
  250. package/dist/toc.d.ts.map +0 -1
  251. package/dist/toc.js.map +0 -1
  252. package/dist/util-CK2ykiif.d.ts.map +0 -1
  253. package/dist/util-s9piKHsk.js.map +0 -1
  254. package/dist/utils/use-effect-event.d.ts +0 -11
  255. package/dist/utils/use-effect-event.d.ts.map +0 -1
  256. package/dist/utils/use-effect-event.js +0 -19
  257. package/dist/utils/use-effect-event.js.map +0 -1
  258. package/dist/utils/use-media-query.d.ts.map +0 -1
  259. package/dist/utils/use-media-query.js.map +0 -1
  260. package/dist/utils/use-on-change.d.ts.map +0 -1
  261. package/dist/utils/use-on-change.js.map +0 -1
  262. package/dist/utils-DUvi2WkD.js.map +0 -1
@@ -0,0 +1,104 @@
1
+ import { parseCodeBlockAttributes } from "./codeblock-utils.js";
2
+ import { t as transformerIcon } from "../transformer-icon-BYedaeE8.js";
3
+ import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
4
+ import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight } from "@shikijs/transformers";
5
+
6
+ //#region src/mdx-plugins/rehype-code.core.ts
7
+ function rehypeCodeDefaultOptions(config) {
8
+ return {
9
+ lazy: true,
10
+ ...config.defaultThemes,
11
+ defaultColor: false,
12
+ defaultLanguage: "plaintext",
13
+ transformers: [
14
+ transformerNotationHighlight({ matchAlgorithm: "v3" }),
15
+ transformerNotationWordHighlight({ matchAlgorithm: "v3" }),
16
+ transformerNotationDiff({ matchAlgorithm: "v3" }),
17
+ transformerNotationFocus({ matchAlgorithm: "v3" })
18
+ ],
19
+ parseMetaString(meta) {
20
+ const parsed = parseCodeBlockAttributes(meta, ["title", "tab"]);
21
+ const data = parsed.attributes;
22
+ parsed.rest = parseLineNumber(parsed.rest, data);
23
+ data.__parsed_raw = parsed.rest;
24
+ return data;
25
+ }
26
+ };
27
+ }
28
+ function parseLineNumber(str, data) {
29
+ return str.replace(/lineNumbers=(\d+)|lineNumbers/, (_, ...args) => {
30
+ data["data-line-numbers"] = true;
31
+ if (args[0] !== void 0) data["data-line-numbers-start"] = Number(args[0]);
32
+ return "";
33
+ });
34
+ }
35
+ function createRehypeCode(configFactory) {
36
+ return function rehypeCode(_options) {
37
+ const { config, options } = typeof configFactory === "function" ? configFactory(_options) : {
38
+ config: configFactory,
39
+ options: {
40
+ ...rehypeCodeDefaultOptions(configFactory),
41
+ ..._options
42
+ }
43
+ };
44
+ const transformers = options.transformers ? [...options.transformers] : [];
45
+ transformers.unshift({
46
+ name: "rehype-code:pre-process",
47
+ preprocess(code, { meta }) {
48
+ if (meta && "__parsed_raw" in meta) {
49
+ meta.__raw = meta.__parsed_raw;
50
+ delete meta.__parsed_raw;
51
+ }
52
+ if (meta && options.filterMetaString) meta.__raw = options.filterMetaString(meta.__raw ?? "");
53
+ return code.replace(/\n$/, "");
54
+ }
55
+ });
56
+ if (options.icon !== false) transformers.push(transformerIcon(options.icon));
57
+ if (options.tab !== false) transformers.push(transformerTab());
58
+ const transformer = Promise.resolve(config.createHighlighter()).then(async (highlighter) => {
59
+ if ("themes" in options) await highlighter.loadTheme(...Object.values(options.themes).filter(Boolean));
60
+ else await highlighter.loadTheme(options.theme);
61
+ const langs = options.langs ?? (options.lazy ? [
62
+ "js",
63
+ "jsx",
64
+ "ts",
65
+ "tsx"
66
+ ] : Object.keys(highlighter.getBundledLanguages()));
67
+ await highlighter.loadLanguage(...langs);
68
+ return rehypeShikiFromHighlighter(highlighter, {
69
+ ...options,
70
+ transformers
71
+ });
72
+ });
73
+ return async (tree, file) => {
74
+ await (await transformer)(tree, file, () => {});
75
+ };
76
+ };
77
+ }
78
+ function transformerTab() {
79
+ return {
80
+ name: "rehype-code:tab",
81
+ root(root) {
82
+ const value = this.options.meta?.tab;
83
+ if (typeof value !== "string") return root;
84
+ console.warn("[Hanzo Docs] For `tab=\"value\" in codeblocks, please use `remarkCodeTab` plugin instead.");
85
+ return {
86
+ type: "root",
87
+ children: [{
88
+ type: "mdxJsxFlowElement",
89
+ name: "Tab",
90
+ data: { _codeblock: true },
91
+ attributes: [{
92
+ type: "mdxJsxAttribute",
93
+ name: "value",
94
+ value
95
+ }],
96
+ children: root.children
97
+ }]
98
+ };
99
+ }
100
+ };
101
+ }
102
+
103
+ //#endregion
104
+ export { createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,2 +1,18 @@
1
- import { a as CodeBlockIcon, i as transformerTab, n as rehypeCode, o as transformerIcon, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-vVWG4-ej.js";
2
- export { CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
1
+ import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-D7-6aFzt.js";
2
+ import { RehypeCodeOptionsCommon, transformerTab } from "./rehype-code.core.js";
3
+ import * as unified from "unified";
4
+ import * as hast from "hast";
5
+
6
+ //#region src/mdx-plugins/rehype-code.d.ts
7
+ type RehypeCodeOptions = RehypeCodeOptionsCommon & {
8
+ /**
9
+ * The regex engine to use.
10
+ *
11
+ * @defaultValue 'js'
12
+ */
13
+ engine?: 'js' | 'oniguruma';
14
+ };
15
+ declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
16
+ declare const rehypeCode: (this: unified.Processor, _options: Partial<RehypeCodeOptions> | undefined) => unified.Transformer<hast.Root, hast.Root>;
17
+ //#endregion
18
+ export { type CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,5 +1,26 @@
1
- import "../shiki-B5wNmyIZ.js";
2
- import "./codeblock-utils.js";
3
- import { i as transformerIcon, n as rehypeCodeDefaultOptions, r as transformerTab, t as rehypeCode } from "../rehype-code-sM9Tq-r7.js";
1
+ import { configDefault, configWASM } from "../highlight/index.js";
2
+ import { t as transformerIcon } from "../transformer-icon-BYedaeE8.js";
3
+ import { createRehypeCode, rehypeCodeDefaultOptions as rehypeCodeDefaultOptions$1, transformerTab } from "./rehype-code.core.js";
4
4
 
5
+ //#region src/mdx-plugins/rehype-code.ts
6
+ const rehypeCodeDefaultOptions = {
7
+ engine: "js",
8
+ ...rehypeCodeDefaultOptions$1(configDefault)
9
+ };
10
+ const rehypeCode = createRehypeCode((_options) => {
11
+ const options = {
12
+ ...rehypeCodeDefaultOptions,
13
+ ..._options
14
+ };
15
+ if (options.engine === "oniguruma") return {
16
+ config: configWASM,
17
+ options
18
+ };
19
+ return {
20
+ config: configDefault,
21
+ options
22
+ };
23
+ });
24
+
25
+ //#endregion
5
26
  export { rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,2 +1,17 @@
1
- import { n as rehypeToc, t as RehypeTocOptions } from "../rehype-toc-DJvSyE0o.js";
1
+ import { Processor, Transformer } from "unified";
2
+ import { Root } from "hast";
3
+
4
+ //#region src/mdx-plugins/rehype-toc.d.ts
5
+ interface RehypeTocOptions {
6
+ /**
7
+ * Export generated toc as a variable
8
+ *
9
+ * @defaultValue true
10
+ */
11
+ exportToc?: boolean;
12
+ }
13
+ declare function rehypeToc(this: Processor, {
14
+ exportToc
15
+ }?: RehypeTocOptions): Transformer<Root, Root>;
16
+ //#endregion
2
17
  export { RehypeTocOptions, rehypeToc };
@@ -1,3 +1,129 @@
1
- import { t as rehypeToc } from "../rehype-toc-DVwJcwvA.js";
1
+ import { t as visit } from "../hast-utils-BmGqqmvo.js";
2
+ import { toEstree } from "hast-util-to-estree";
2
3
 
4
+ //#region src/mdx-plugins/rehype-toc.ts
5
+ const TocOnlyTag = "[toc]";
6
+ const NoTocTag = "[!toc]";
7
+ function rehypeToc({ exportToc = true } = {}) {
8
+ return (tree) => {
9
+ const output = [];
10
+ visit(tree, [
11
+ "h1",
12
+ "h2",
13
+ "h3",
14
+ "h4",
15
+ "h5",
16
+ "h6"
17
+ ], (element) => {
18
+ const id = element.properties.id;
19
+ if (typeof id !== "string") return "skip";
20
+ let isTocOnly = false;
21
+ const last = element.children.at(-1);
22
+ if (last?.type === "text" && last.value.endsWith(TocOnlyTag)) {
23
+ isTocOnly = true;
24
+ last.value = last.value.substring(0, last.value.length - 5).trimEnd();
25
+ } else if (last?.type === "text" && last.value.endsWith(NoTocTag)) {
26
+ last.value = last.value.substring(0, last.value.length - 6).trimEnd();
27
+ return "skip";
28
+ }
29
+ const estree = toEstree(element, {
30
+ elementAttributeNameCase: "react",
31
+ stylePropertyNameCase: "dom"
32
+ });
33
+ if (estree.body[0].type === "ExpressionStatement") output.push({
34
+ title: estree.body[0].expression,
35
+ depth: Number(element.tagName.slice(1)),
36
+ url: `#${id}`
37
+ });
38
+ if (isTocOnly) Object.assign(element, {
39
+ type: "comment",
40
+ value: ""
41
+ });
42
+ return "skip";
43
+ });
44
+ const declaration = {
45
+ type: "VariableDeclaration",
46
+ kind: "const",
47
+ declarations: [{
48
+ type: "VariableDeclarator",
49
+ id: {
50
+ type: "Identifier",
51
+ name: "toc"
52
+ },
53
+ init: {
54
+ type: "ArrayExpression",
55
+ elements: output.map((item) => ({
56
+ type: "ObjectExpression",
57
+ properties: [
58
+ {
59
+ type: "Property",
60
+ method: false,
61
+ shorthand: false,
62
+ computed: false,
63
+ key: {
64
+ type: "Identifier",
65
+ name: "depth"
66
+ },
67
+ value: {
68
+ type: "Literal",
69
+ value: item.depth
70
+ },
71
+ kind: "init"
72
+ },
73
+ {
74
+ type: "Property",
75
+ method: false,
76
+ shorthand: false,
77
+ computed: false,
78
+ key: {
79
+ type: "Identifier",
80
+ name: "url"
81
+ },
82
+ value: {
83
+ type: "Literal",
84
+ value: item.url
85
+ },
86
+ kind: "init"
87
+ },
88
+ {
89
+ type: "Property",
90
+ method: false,
91
+ shorthand: false,
92
+ computed: false,
93
+ key: {
94
+ type: "Identifier",
95
+ name: "title"
96
+ },
97
+ value: {
98
+ type: "JSXFragment",
99
+ openingFragment: { type: "JSXOpeningFragment" },
100
+ closingFragment: { type: "JSXClosingFragment" },
101
+ children: item.title.children
102
+ },
103
+ kind: "init"
104
+ }
105
+ ]
106
+ }))
107
+ }
108
+ }]
109
+ };
110
+ tree.children.push({
111
+ type: "mdxjsEsm",
112
+ value: "",
113
+ data: { estree: {
114
+ type: "Program",
115
+ body: [exportToc ? {
116
+ type: "ExportNamedDeclaration",
117
+ declaration,
118
+ attributes: [],
119
+ specifiers: []
120
+ } : declaration],
121
+ sourceType: "module",
122
+ comments: []
123
+ } }
124
+ });
125
+ };
126
+ }
127
+
128
+ //#endregion
3
129
  export { rehypeToc };
@@ -1,2 +1,21 @@
1
- import { n as remarkAdmonition, t as RemarkAdmonitionOptions } from "../remark-admonition-DOwBWzsH.js";
1
+ import { Transformer } from "unified";
2
+ import { Root } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-admonition.d.ts
5
+ interface RemarkAdmonitionOptions {
6
+ tag?: string;
7
+ /**
8
+ * Map type to another type
9
+ */
10
+ typeMap?: Record<string, string>;
11
+ }
12
+ /**
13
+ * Remark Plugin to support Admonition syntax
14
+ *
15
+ * Useful when Migrating from Docusaurus
16
+ *
17
+ * @deprecated Use `remarkDirectiveAdmonition` with `remark-directive` configured instead.
18
+ */
19
+ declare function remarkAdmonition(options?: RemarkAdmonitionOptions): Transformer<Root, Root>;
20
+ //#endregion
2
21
  export { RemarkAdmonitionOptions, remarkAdmonition };
@@ -1,4 +1,4 @@
1
- import { t as flattenNode } from "../mdast-utils-mc9-X-PK.js";
1
+ import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
2
2
  import { visit } from "unist-util-visit";
3
3
 
4
4
  //#region src/mdx-plugins/remark-admonition.ts
@@ -70,5 +70,4 @@ function remarkAdmonition(options = {}) {
70
70
  }
71
71
 
72
72
  //#endregion
73
- export { remarkAdmonition };
74
- //# sourceMappingURL=remark-admonition.js.map
73
+ export { remarkAdmonition };
@@ -1,2 +1,31 @@
1
- import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "../remark-code-tab-CXsYlims.js";
1
+ import { Processor, Transformer } from "unified";
2
+ import { Code, Root } from "mdast";
3
+ import { MdxJsxFlowElement } from "mdast-util-mdx-jsx";
4
+
5
+ //#region src/mdx-plugins/remark-code-tab.d.ts
6
+ type TabType = keyof typeof Types;
7
+ interface RemarkCodeTabOptions {
8
+ Tabs?: TabType;
9
+ /**
10
+ * Parse MDX in tab values
11
+ *
12
+ * @defaultValue false
13
+ */
14
+ parseMdx?: boolean;
15
+ }
16
+ declare module 'mdast' {
17
+ interface CodeData {
18
+ tab?: string;
19
+ }
20
+ }
21
+ declare const Types: {
22
+ CodeBlockTabs: {
23
+ convert(processor: Processor, nodes: Code[], withMdx?: boolean, withParent?: boolean): MdxJsxFlowElement;
24
+ };
25
+ Tabs: {
26
+ convert(processor: Processor, nodes: Code[], withMdx?: boolean, withParent?: boolean): MdxJsxFlowElement;
27
+ };
28
+ };
29
+ declare function remarkCodeTab(this: Processor, options?: RemarkCodeTabOptions): Transformer<Root, Root>;
30
+ //#endregion
2
31
  export { RemarkCodeTabOptions, remarkCodeTab };
@@ -25,7 +25,7 @@ const Types = {
25
25
  Tabs: { convert(processor, nodes, withMdx = false, withParent = true) {
26
26
  const tabs = Array.from(processTabValue(nodes).entries());
27
27
  if (!withMdx) {
28
- const children$1 = tabs.map(([name, codes]) => {
28
+ const children = tabs.map(([name, codes]) => {
29
29
  return {
30
30
  type: "mdxJsxFlowElement",
31
31
  name: "Tab",
@@ -37,7 +37,7 @@ const Types = {
37
37
  children: codes
38
38
  };
39
39
  });
40
- if (!withParent) return createFragment(children$1);
40
+ if (!withParent) return createFragment(children);
41
41
  return {
42
42
  type: "mdxJsxFlowElement",
43
43
  name: "Tabs",
@@ -64,7 +64,7 @@ const Types = {
64
64
  } }
65
65
  }
66
66
  }],
67
- children: children$1
67
+ children
68
68
  };
69
69
  }
70
70
  const children = [{
@@ -180,5 +180,4 @@ function createFragment(children) {
180
180
  }
181
181
 
182
182
  //#endregion
183
- export { remarkCodeTab };
184
- //# sourceMappingURL=remark-code-tab.js.map
183
+ export { remarkCodeTab };
@@ -1,2 +1,35 @@
1
- import { n as remarkDirectiveAdmonition, t as RemarkDirectiveAdmonitionOptions } from "../remark-directive-admonition-BCm_yiU9.js";
1
+ import { Transformer } from "unified";
2
+ import { Root } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-directive-admonition.d.ts
5
+ interface RemarkDirectiveAdmonitionOptions {
6
+ /**
7
+ * the tag names of Callout component.
8
+ */
9
+ tags?: {
10
+ CalloutContainer?: string;
11
+ CalloutTitle?: string;
12
+ CalloutDescription?: string;
13
+ };
14
+ /**
15
+ * All supported admonition types and their linked Callout type.
16
+ *
17
+ * When specified, all defaults will be cleared.
18
+ */
19
+ types?: Record<string, string>;
20
+ }
21
+ /**
22
+ * Remark Plugin to support Admonition syntax in Docusaurus, useful for migrating from Docusaurus.
23
+ *
24
+ * Requires [`remark-directive`](https://github.com/remarkjs/remark-directive) to be configured.
25
+ */
26
+ declare function remarkDirectiveAdmonition({
27
+ tags: {
28
+ CalloutContainer,
29
+ CalloutTitle,
30
+ CalloutDescription
31
+ },
32
+ types
33
+ }?: RemarkDirectiveAdmonitionOptions): Transformer<Root, Root>;
34
+ //#endregion
2
35
  export { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition };
@@ -56,5 +56,4 @@ function remarkDirectiveAdmonition({ tags: { CalloutContainer = "CalloutContaine
56
56
  }
57
57
 
58
58
  //#endregion
59
- export { remarkDirectiveAdmonition };
60
- //# sourceMappingURL=remark-directive-admonition.js.map
59
+ export { remarkDirectiveAdmonition };
@@ -0,0 +1,51 @@
1
+ import { Transformer } from "unified";
2
+ import { Root, RootContent } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-feedback-block.d.ts
5
+ interface RemarkFeedbackBlockOptions {
6
+ /**
7
+ * generate block ID, default to using MD5.
8
+ */
9
+ generateHash?: (ctx: {
10
+ body: string;
11
+ }) => string;
12
+ /**
13
+ * @defaultValue FeedbackBlock
14
+ */
15
+ tagName?: string;
16
+ /**
17
+ * determine how the node should be resolved into a feedback block.
18
+ *
19
+ * scan paragraph, list, and image nodes by default.
20
+ *
21
+ * @returns
22
+ * - `true`: convert the node into a feedback block.
23
+ * - `false`: skip the current node and look into its children.
24
+ * - `skip`: skip the current node and its children.
25
+ */
26
+ resolve?: (node: RootContent) => boolean | 'skip';
27
+ /**
28
+ * generate & include the block body to `<FeedbackBlock body="..." />` as string
29
+ *
30
+ * @defaultValue true
31
+ */
32
+ generateBody?: boolean;
33
+ }
34
+ interface FeedbackBlockProps {
35
+ id: string;
36
+ /** the text body of block, only exists when `generateBody` is enabled. */
37
+ body?: string;
38
+ }
39
+ /**
40
+ * Generate MDX `<FeedbackBlock />` elements with an unique `id` for every block-like element.
41
+ *
42
+ * Note: the uniqueness is only guaranteed per MDX file/page.
43
+ */
44
+ declare function remarkFeedbackBlock({
45
+ generateHash,
46
+ tagName,
47
+ resolve,
48
+ generateBody
49
+ }?: RemarkFeedbackBlockOptions): Transformer<Root, Root>;
50
+ //#endregion
51
+ export { FeedbackBlockProps, RemarkFeedbackBlockOptions, remarkFeedbackBlock };
@@ -0,0 +1,47 @@
1
+ import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
2
+ import { visit } from "unist-util-visit";
3
+ import { createHash } from "node:crypto";
4
+
5
+ //#region src/mdx-plugins/remark-feedback-block.ts
6
+ /**
7
+ * Generate MDX `<FeedbackBlock />` elements with an unique `id` for every block-like element.
8
+ *
9
+ * Note: the uniqueness is only guaranteed per MDX file/page.
10
+ */
11
+ function remarkFeedbackBlock({ generateHash = ({ body }) => createHash("md5").update(body).digest("hex").substring(0, 16), tagName = "FeedbackBlock", resolve = (node) => node.type === "paragraph" || node.type === "image" || node.type === "list", generateBody = true } = {}) {
12
+ return (tree) => {
13
+ const counts = /* @__PURE__ */ new Map();
14
+ visit(tree, (node, index, parent) => {
15
+ if (node.type === "root") return;
16
+ const resolved = resolve(node);
17
+ if (resolved === false) return;
18
+ if (resolved === "skip") return "skip";
19
+ const text = flattenNode(node).trim();
20
+ if (text.length === 0 || !parent || typeof index !== "number") return;
21
+ let id = generateHash({ body: text });
22
+ const count = counts.get(id) ?? 0;
23
+ if (count > 0) id = `${id}-${count}`;
24
+ counts.set(id, count + 1);
25
+ const wrapper = {
26
+ type: "mdxJsxFlowElement",
27
+ name: tagName,
28
+ attributes: [{
29
+ type: "mdxJsxAttribute",
30
+ name: "id",
31
+ value: id
32
+ }],
33
+ children: [node]
34
+ };
35
+ if (generateBody) wrapper.attributes.push({
36
+ type: "mdxJsxAttribute",
37
+ name: "body",
38
+ value: text
39
+ });
40
+ parent.children[index] = wrapper;
41
+ return "skip";
42
+ });
43
+ };
44
+ }
45
+
46
+ //#endregion
47
+ export { remarkFeedbackBlock };
@@ -1,2 +1,2 @@
1
- import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-CeWpMwyk.js";
2
- export { RemarkGfmOptions, remarkGfm };
1
+ import remarkGfm, { Options as RemarkGfmOptions } from "remark-gfm";
2
+ export { type RemarkGfmOptions, remarkGfm };
@@ -1,2 +1,36 @@
1
- import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-CXvCY0go.js";
1
+ import { Transformer } from "unified";
2
+ import { Heading, Root } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-heading.d.ts
5
+ declare module 'mdast' {
6
+ interface HeadingData extends Data {
7
+ hProperties?: {
8
+ id?: string;
9
+ };
10
+ }
11
+ }
12
+ interface RemarkHeadingOptions {
13
+ slug?: (root: Root, heading: Heading, text: string) => string;
14
+ /**
15
+ * Allow custom headings ids
16
+ *
17
+ * @defaultValue true
18
+ */
19
+ customId?: boolean;
20
+ /**
21
+ * Attach an array of `TOCItemType` to `file.data.toc`
22
+ *
23
+ * @defaultValue true
24
+ */
25
+ generateToc?: boolean;
26
+ }
27
+ /**
28
+ * Add heading ids and extract TOC
29
+ */
30
+ declare function remarkHeading({
31
+ slug: defaultSlug,
32
+ customId,
33
+ generateToc
34
+ }?: RemarkHeadingOptions): Transformer<Root, Root>;
35
+ //#endregion
2
36
  export { RemarkHeadingOptions, remarkHeading };
@@ -1,4 +1,4 @@
1
- import { t as flattenNode } from "../mdast-utils-mc9-X-PK.js";
1
+ import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
2
2
  import Slugger from "github-slugger";
3
3
  import { visit } from "unist-util-visit";
4
4
 
@@ -41,5 +41,4 @@ function remarkHeading({ slug: defaultSlug, customId = true, generateToc = true
41
41
  }
42
42
 
43
43
  //#endregion
44
- export { remarkHeading };
45
- //# sourceMappingURL=remark-heading.js.map
44
+ export { remarkHeading };
@@ -1,2 +1,64 @@
1
- import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-CvUis4R1.js";
1
+ import { Transformer } from "unified";
2
+ import { Root } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-image.d.ts
5
+ type ExternalImageOptions = {
6
+ /**
7
+ * timeout for fetching remote images (in milliseconds)
8
+ */
9
+ timeout?: number;
10
+ } | boolean;
11
+ interface RemarkImageOptions {
12
+ /**
13
+ * Directory or base URL to resolve absolute image paths
14
+ */
15
+ publicDir?: string;
16
+ /**
17
+ * Preferred placeholder type, only available with `useImport` + local images.
18
+ *
19
+ * @defaultValue 'blur'
20
+ */
21
+ placeholder?: 'blur' | 'none';
22
+ /**
23
+ * Define how to handle errors when fetching image size.
24
+ *
25
+ * - `error` (default): throw an error.
26
+ * - `ignore`: do absolutely nothing (Next.js Image component may complain).
27
+ * - `hide`: remove that image element.
28
+ *
29
+ * @defaultValue 'error'
30
+ */
31
+ onError?: 'error' | 'hide' | 'ignore' | ((error: Error) => void);
32
+ /**
33
+ * Import images in the file, and let bundlers handle it.
34
+ *
35
+ * ```tsx
36
+ * import MyImage from "./public/img.png";
37
+ *
38
+ * <img src={MyImage} />
39
+ * ```
40
+ *
41
+ * When disabled, `placeholder` will be ignored.
42
+ *
43
+ * @defaultValue true
44
+ */
45
+ useImport?: boolean;
46
+ /**
47
+ * Fetch image size of external URLs
48
+ *
49
+ * @defaultValue true
50
+ */
51
+ external?: ExternalImageOptions;
52
+ }
53
+ /**
54
+ * Turn images into Next.js Image compatible usage.
55
+ */
56
+ declare function remarkImage({
57
+ placeholder,
58
+ external,
59
+ useImport,
60
+ onError,
61
+ publicDir
62
+ }?: RemarkImageOptions): Transformer<Root, Root>;
63
+ //#endregion
2
64
  export { RemarkImageOptions, remarkImage };
@@ -188,5 +188,4 @@ async function getImageSize(src, onExternal) {
188
188
  }
189
189
 
190
190
  //#endregion
191
- export { remarkImage };
192
- //# sourceMappingURL=remark-image.js.map
191
+ export { remarkImage };