zudoku 0.44.1 → 0.45.1

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 (576) hide show
  1. package/cli.js +8 -2
  2. package/dist/app/entry.client.js +34 -21
  3. package/dist/app/entry.client.js.map +1 -1
  4. package/dist/app/main.js +7 -0
  5. package/dist/app/main.js.map +1 -1
  6. package/dist/config/validators/common.d.ts +420 -288
  7. package/dist/config/validators/common.js +10 -0
  8. package/dist/config/validators/common.js.map +1 -1
  9. package/dist/config/validators/validate.d.ts +161 -108
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/components/Footer.js +2 -2
  14. package/dist/lib/components/Footer.js.map +1 -1
  15. package/dist/lib/components/Header.js +1 -1
  16. package/dist/lib/components/Header.js.map +1 -1
  17. package/dist/lib/components/Markdown.d.ts +3 -1
  18. package/dist/lib/components/Markdown.js +8 -14
  19. package/dist/lib/components/Markdown.js.map +1 -1
  20. package/dist/lib/components/context/ZudokuContext.d.ts +1 -1
  21. package/dist/lib/components/context/ZudokuContext.js +2 -3
  22. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  23. package/dist/lib/components/index.d.ts +2 -1
  24. package/dist/lib/core/ZudokuContext.d.ts +8 -0
  25. package/dist/lib/core/ZudokuContext.js.map +1 -1
  26. package/dist/lib/errors/ErrorAlert.js +1 -1
  27. package/dist/lib/errors/ErrorAlert.js.map +1 -1
  28. package/dist/lib/oas/graphql/circular.js +23 -18
  29. package/dist/lib/oas/graphql/circular.js.map +1 -1
  30. package/dist/lib/oas/parser/index.d.ts +3 -0
  31. package/dist/lib/oas/parser/index.js +6 -1
  32. package/dist/lib/oas/parser/index.js.map +1 -1
  33. package/dist/lib/plugins/openapi/CollapsibleCode.js +1 -1
  34. package/dist/lib/plugins/openapi/CollapsibleCode.js.map +1 -1
  35. package/dist/lib/plugins/openapi/ParamInfos.js +3 -1
  36. package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
  37. package/dist/lib/plugins/openapi/Sidecar.js +1 -1
  38. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  39. package/dist/lib/plugins/openapi/SidecarExamples.js +1 -1
  40. package/dist/lib/plugins/openapi/SidecarExamples.js.map +1 -1
  41. package/dist/lib/plugins/openapi/playground/IdentitySelector.js +1 -3
  42. package/dist/lib/plugins/openapi/playground/IdentitySelector.js.map +1 -1
  43. package/dist/lib/plugins/openapi/schema/SchemaExampleAndDefault.js +4 -1
  44. package/dist/lib/plugins/openapi/schema/SchemaExampleAndDefault.js.map +1 -1
  45. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +11 -12
  46. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
  47. package/dist/lib/plugins/openapi/schema/utils.d.ts +5 -1
  48. package/dist/lib/plugins/openapi/schema/utils.js +9 -5
  49. package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
  50. package/dist/lib/plugins/openapi/util/generateSchemaExample.d.ts +1 -1
  51. package/dist/lib/plugins/openapi/util/generateSchemaExample.js +4 -0
  52. package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  53. package/dist/lib/shiki.d.ts +35 -0
  54. package/dist/lib/shiki.js +103 -0
  55. package/dist/lib/shiki.js.map +1 -0
  56. package/dist/lib/ui/Callout.js +1 -1
  57. package/dist/lib/ui/Callout.js.map +1 -1
  58. package/dist/lib/ui/CodeBlock.d.ts +16 -0
  59. package/dist/lib/ui/CodeBlock.js +18 -0
  60. package/dist/lib/ui/CodeBlock.js.map +1 -0
  61. package/dist/lib/ui/SyntaxHighlight.d.ts +10 -15
  62. package/dist/lib/ui/SyntaxHighlight.js +12 -60
  63. package/dist/lib/ui/SyntaxHighlight.js.map +1 -1
  64. package/dist/lib/util/MdxComponents.d.ts +9 -3
  65. package/dist/lib/util/MdxComponents.js +9 -10
  66. package/dist/lib/util/MdxComponents.js.map +1 -1
  67. package/dist/vite/api/SchemaManager.js +2 -0
  68. package/dist/vite/api/SchemaManager.js.map +1 -1
  69. package/dist/vite/config.js +34 -0
  70. package/dist/vite/config.js.map +1 -1
  71. package/dist/vite/plugin-mdx.js +4 -11
  72. package/dist/vite/plugin-mdx.js.map +1 -1
  73. package/dist/vite/plugin-shiki-register.d.ts +3 -0
  74. package/dist/vite/plugin-shiki-register.js +38 -0
  75. package/dist/vite/plugin-shiki-register.js.map +1 -0
  76. package/dist/vite/plugin.js +2 -0
  77. package/dist/vite/plugin.js.map +1 -1
  78. package/lib/AuthenticationPlugin-BTJ37DKg.js +90 -0
  79. package/lib/{AuthenticationPlugin-BlJsiGuX.js.map → AuthenticationPlugin-BTJ37DKg.js.map} +1 -1
  80. package/lib/{Button-BBNrKpQd.js → Button-Bdk_Ij3U.js} +3 -3
  81. package/lib/{Button-BBNrKpQd.js.map → Button-Bdk_Ij3U.js.map} +1 -1
  82. package/lib/{Callout-D3Ja4OPX.js → Callout-XadUe37J.js} +12 -12
  83. package/lib/{Callout-D3Ja4OPX.js.map → Callout-XadUe37J.js.map} +1 -1
  84. package/lib/{Card-BtheiD7j.js → Card-BlCYNw5W.js} +2 -2
  85. package/lib/{Card-BtheiD7j.js.map → Card-BlCYNw5W.js.map} +1 -1
  86. package/lib/{CategoryHeading-D06WK_Wo.js → CategoryHeading-DZi-Szor.js} +2 -2
  87. package/lib/{CategoryHeading-D06WK_Wo.js.map → CategoryHeading-DZi-Szor.js.map} +1 -1
  88. package/lib/{Dialog-ByYz4ABw.js → Dialog-CNf2oWXG.js} +2 -2
  89. package/lib/{Dialog-ByYz4ABw.js.map → Dialog-CNf2oWXG.js.map} +1 -1
  90. package/lib/{Drawer-CEwbkLDb.js → Drawer-BPBxzel2.js} +25 -25
  91. package/lib/{Drawer-CEwbkLDb.js.map → Drawer-BPBxzel2.js.map} +1 -1
  92. package/lib/Markdown-D96AphCL.js +7691 -0
  93. package/lib/Markdown-D96AphCL.js.map +1 -0
  94. package/lib/MdxPage-tTTaDsLc.js +84 -0
  95. package/lib/{MdxPage-DlJaCSPf.js.map → MdxPage-tTTaDsLc.js.map} +1 -1
  96. package/lib/{OasProvider-CsUksaAo.js → OasProvider-DalHQixM.js} +4 -4
  97. package/lib/{OasProvider-CsUksaAo.js.map → OasProvider-DalHQixM.js.map} +1 -1
  98. package/lib/{OperationList-BlUBNsw2.js → OperationList-BB09ENaq.js} +1896 -1932
  99. package/lib/{OperationList-BlUBNsw2.js.map → OperationList-BB09ENaq.js.map} +1 -1
  100. package/lib/{Pagination-C5Fi7z_v.js → Pagination-CtmnJOJi.js} +4 -4
  101. package/lib/{Pagination-C5Fi7z_v.js.map → Pagination-CtmnJOJi.js.map} +1 -1
  102. package/lib/RouteGuard-lkdEJoDV.js +732 -0
  103. package/lib/{RouteGuard-D2gX29iI.js.map → RouteGuard-lkdEJoDV.js.map} +1 -1
  104. package/lib/{SchemaList-BQiBukIP.js → SchemaList-BH9bgMRw.js} +40 -41
  105. package/lib/{SchemaList-BQiBukIP.js.map → SchemaList-BH9bgMRw.js.map} +1 -1
  106. package/lib/{SchemaView-Bt95NiyQ.js → SchemaView-BsB7EFRl.js} +120 -115
  107. package/lib/SchemaView-BsB7EFRl.js.map +1 -0
  108. package/lib/Select-HTio1oSE.js +211 -0
  109. package/lib/{Select-CYaEBIYK.js.map → Select-HTio1oSE.js.map} +1 -1
  110. package/lib/SlotletProvider-CTgIBRWg.js +257 -0
  111. package/lib/SlotletProvider-CTgIBRWg.js.map +1 -0
  112. package/lib/SyntaxHighlight-UxOF1xNb.js +9107 -0
  113. package/lib/SyntaxHighlight-UxOF1xNb.js.map +1 -0
  114. package/lib/{Toc-BnN4zBb3.js → Toc-Ax54Pw8S.js} +3 -3
  115. package/lib/{Toc-BnN4zBb3.js.map → Toc-Ax54Pw8S.js.map} +1 -1
  116. package/lib/{chunk-BAXFHI7N-BLTsN6tl.js → chunk-BAXFHI7N-C9WnHsLV.js} +510 -517
  117. package/lib/{chunk-BAXFHI7N-BLTsN6tl.js.map → chunk-BAXFHI7N-C9WnHsLV.js.map} +1 -1
  118. package/lib/{circular-tOWjsgLZ.js → circular-CZaZtOBs.js} +1636 -1633
  119. package/lib/{circular-tOWjsgLZ.js.map → circular-CZaZtOBs.js.map} +1 -1
  120. package/lib/{cn-qaFjX9_3.js → cn-CwJPJKOE.js} +28 -29
  121. package/lib/{cn-qaFjX9_3.js.map → cn-CwJPJKOE.js.map} +1 -1
  122. package/lib/{createServer-XtO-PVox.js → createServer-DmqFeMgf.js} +3980 -3832
  123. package/lib/createServer-DmqFeMgf.js.map +1 -0
  124. package/lib/hook-BwOB_iZo.js +1442 -0
  125. package/lib/hook-BwOB_iZo.js.map +1 -0
  126. package/lib/{index-DwT-v3zK.js → index--oeBayMa.js} +2 -2
  127. package/lib/{index-DwT-v3zK.js.map → index--oeBayMa.js.map} +1 -1
  128. package/lib/index-BnT4-Efz.js +4975 -0
  129. package/lib/index-BnT4-Efz.js.map +1 -0
  130. package/lib/{index-LNp6rxyU.js → index-BvvmIczU.js} +2 -2
  131. package/lib/{index-LNp6rxyU.js.map → index-BvvmIczU.js.map} +1 -1
  132. package/lib/{index-CuBIgTKC.js → index-CrcNWbel.js} +9 -9
  133. package/lib/{index-CuBIgTKC.js.map → index-CrcNWbel.js.map} +1 -1
  134. package/lib/{index-CPNSgwSb.js → index-Z13x6tPX.js} +5 -5
  135. package/lib/{index-CPNSgwSb.js.map → index-Z13x6tPX.js.map} +1 -1
  136. package/lib/{index-CZnufgn5.js → index-sS7O9W-R.js} +899 -949
  137. package/lib/index-sS7O9W-R.js.map +1 -0
  138. package/lib/{index-DcHeSvkE.js → index-zddirpDj.js} +581 -609
  139. package/lib/{index-DcHeSvkE.js.map → index-zddirpDj.js.map} +1 -1
  140. package/lib/invariant-DAFpPywt.js +48 -0
  141. package/lib/{invariant-Caa8-XvF.js.map → invariant-DAFpPywt.js.map} +1 -1
  142. package/lib/mutation-CL2MCRQL.js +196 -0
  143. package/lib/{mutation-Bq5bn7Hf.js.map → mutation-CL2MCRQL.js.map} +1 -1
  144. package/lib/processors/removeParameters.js +27 -28
  145. package/lib/processors/removeParameters.js.map +1 -1
  146. package/lib/processors/removePaths.js +17 -17
  147. package/lib/processors/removePaths.js.map +1 -1
  148. package/lib/ui/Accordion.js +1 -1
  149. package/lib/ui/ActionButton.js +2 -2
  150. package/lib/ui/Alert.js +2 -2
  151. package/lib/ui/AlertDialog.js +1 -1
  152. package/lib/ui/Badge.js +2 -2
  153. package/lib/ui/Breadcrumb.js +1 -1
  154. package/lib/ui/Button.js +2 -2
  155. package/lib/ui/Callout.js +7 -7
  156. package/lib/ui/Callout.js.map +1 -1
  157. package/lib/ui/Card.js +1 -1
  158. package/lib/ui/Carousel.js +175 -175
  159. package/lib/ui/Carousel.js.map +1 -1
  160. package/lib/ui/Checkbox.js +1 -1
  161. package/lib/ui/CodeBlock.js +83 -0
  162. package/lib/ui/CodeBlock.js.map +1 -0
  163. package/lib/ui/Command.js +58 -58
  164. package/lib/ui/Command.js.map +1 -1
  165. package/lib/ui/Dialog.js +1 -1
  166. package/lib/ui/Drawer.js +2 -2
  167. package/lib/ui/DropdownMenu.js +1 -1
  168. package/lib/ui/Form.js +1 -1
  169. package/lib/ui/HoverCard.js +1 -1
  170. package/lib/ui/Input.js +1 -1
  171. package/lib/ui/Label.js +2 -2
  172. package/lib/ui/Pagination.js +1 -1
  173. package/lib/ui/Popover.js +1 -1
  174. package/lib/ui/Progress.js +1 -1
  175. package/lib/ui/RadioGroup.js +1 -1
  176. package/lib/ui/ScrollArea.js +1 -1
  177. package/lib/ui/Select.js +1 -1
  178. package/lib/ui/Skeleton.js +1 -1
  179. package/lib/ui/Slider.js +1 -1
  180. package/lib/ui/Switch.js +1 -1
  181. package/lib/ui/SyntaxHighlight.js +5 -6
  182. package/lib/ui/SyntaxHighlight.js.map +1 -1
  183. package/lib/ui/Tabs.js +1 -1
  184. package/lib/ui/Textarea.js +1 -1
  185. package/lib/ui/Toggle.js +2 -2
  186. package/lib/ui/ToggleGroup.js +1 -1
  187. package/lib/ui/Tooltip.js +1 -1
  188. package/lib/ui/util.js +1 -1
  189. package/lib/{useExposedProps-DmTJxEXG.js → useExposedProps-DG8J6ewJ.js} +2 -2
  190. package/lib/{useExposedProps-DmTJxEXG.js.map → useExposedProps-DG8J6ewJ.js.map} +1 -1
  191. package/lib/zudoku.auth-auth0.js +28 -31
  192. package/lib/zudoku.auth-auth0.js.map +1 -1
  193. package/lib/zudoku.auth-clerk.js +64 -70
  194. package/lib/zudoku.auth-clerk.js.map +1 -1
  195. package/lib/zudoku.auth-openid.js +373 -382
  196. package/lib/zudoku.auth-openid.js.map +1 -1
  197. package/lib/zudoku.components.js +7 -7
  198. package/lib/zudoku.hooks.js +2 -2
  199. package/lib/zudoku.plugin-api-catalog.js +45 -45
  200. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  201. package/lib/zudoku.plugin-api-keys.js +6 -6
  202. package/lib/zudoku.plugin-custom-pages.js +3 -3
  203. package/lib/zudoku.plugin-markdown.js +25 -28
  204. package/lib/zudoku.plugin-markdown.js.map +1 -1
  205. package/lib/zudoku.plugin-openapi.js +3 -3
  206. package/lib/zudoku.plugin-redirect.js +1 -1
  207. package/lib/zudoku.plugin-search-inkeep.js +26 -27
  208. package/lib/zudoku.plugin-search-inkeep.js.map +1 -1
  209. package/lib/zudoku.plugin-search-pagefind.js +107 -110
  210. package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
  211. package/package.json +39 -29
  212. package/src/app/entry.client.tsx +40 -25
  213. package/src/app/main.css +54 -3
  214. package/src/app/main.tsx +8 -0
  215. package/src/lib/components/Footer.tsx +3 -6
  216. package/src/lib/components/Header.tsx +1 -1
  217. package/src/lib/components/Markdown.tsx +29 -24
  218. package/src/lib/components/context/ZudokuContext.ts +2 -3
  219. package/src/lib/core/ZudokuContext.ts +5 -0
  220. package/src/lib/errors/ErrorAlert.tsx +1 -1
  221. package/src/lib/oas/graphql/circular.ts +27 -19
  222. package/src/lib/oas/parser/index.ts +6 -1
  223. package/src/lib/plugins/openapi/CollapsibleCode.tsx +5 -2
  224. package/src/lib/plugins/openapi/ParamInfos.tsx +3 -1
  225. package/src/lib/plugins/openapi/Sidecar.tsx +1 -1
  226. package/src/lib/plugins/openapi/SidecarExamples.tsx +2 -2
  227. package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +22 -35
  228. package/src/lib/plugins/openapi/schema/SchemaExampleAndDefault.tsx +5 -2
  229. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +23 -17
  230. package/src/lib/plugins/openapi/schema/utils.ts +18 -6
  231. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +6 -1
  232. package/src/lib/shiki.ts +133 -0
  233. package/src/lib/ui/Callout.tsx +1 -1
  234. package/src/lib/ui/CodeBlock.tsx +102 -0
  235. package/src/lib/ui/SyntaxHighlight.tsx +23 -182
  236. package/src/lib/util/MdxComponents.tsx +27 -14
  237. package/src/shiki/langs/abap.js +1 -0
  238. package/src/shiki/langs/actionscript-3.js +1 -0
  239. package/src/shiki/langs/ada.js +1 -0
  240. package/src/shiki/langs/angular-expression.js +1 -0
  241. package/src/shiki/langs/angular-html.js +1 -0
  242. package/src/shiki/langs/angular-inline-style.js +1 -0
  243. package/src/shiki/langs/angular-inline-template.js +1 -0
  244. package/src/shiki/langs/angular-let-declaration.js +1 -0
  245. package/src/shiki/langs/angular-template-blocks.js +1 -0
  246. package/src/shiki/langs/angular-template.js +1 -0
  247. package/src/shiki/langs/angular-ts.js +1 -0
  248. package/src/shiki/langs/apache.js +1 -0
  249. package/src/shiki/langs/apex.js +1 -0
  250. package/src/shiki/langs/apl.js +1 -0
  251. package/src/shiki/langs/applescript.js +1 -0
  252. package/src/shiki/langs/ara.js +1 -0
  253. package/src/shiki/langs/asciidoc.js +1 -0
  254. package/src/shiki/langs/asm.js +1 -0
  255. package/src/shiki/langs/astro.js +1 -0
  256. package/src/shiki/langs/awk.js +1 -0
  257. package/src/shiki/langs/ballerina.js +1 -0
  258. package/src/shiki/langs/bat.js +1 -0
  259. package/src/shiki/langs/beancount.js +1 -0
  260. package/src/shiki/langs/berry.js +1 -0
  261. package/src/shiki/langs/bibtex.js +1 -0
  262. package/src/shiki/langs/bicep.js +1 -0
  263. package/src/shiki/langs/blade.js +1 -0
  264. package/src/shiki/langs/bsl.js +1 -0
  265. package/src/shiki/langs/c.js +1 -0
  266. package/src/shiki/langs/cadence.js +1 -0
  267. package/src/shiki/langs/cairo.js +1 -0
  268. package/src/shiki/langs/clarity.js +1 -0
  269. package/src/shiki/langs/clojure.js +1 -0
  270. package/src/shiki/langs/cmake.js +1 -0
  271. package/src/shiki/langs/cobol.js +1 -0
  272. package/src/shiki/langs/codeowners.js +1 -0
  273. package/src/shiki/langs/codeql.js +1 -0
  274. package/src/shiki/langs/coffee.js +1 -0
  275. package/src/shiki/langs/common-lisp.js +1 -0
  276. package/src/shiki/langs/coq.js +1 -0
  277. package/src/shiki/langs/cpp-macro.js +1 -0
  278. package/src/shiki/langs/cpp.js +1 -0
  279. package/src/shiki/langs/crystal.js +1 -0
  280. package/src/shiki/langs/csharp.js +1 -0
  281. package/src/shiki/langs/css.js +1 -0
  282. package/src/shiki/langs/csv.js +1 -0
  283. package/src/shiki/langs/cue.js +1 -0
  284. package/src/shiki/langs/cypher.js +1 -0
  285. package/src/shiki/langs/d.js +1 -0
  286. package/src/shiki/langs/dart.js +1 -0
  287. package/src/shiki/langs/dax.js +1 -0
  288. package/src/shiki/langs/desktop.js +1 -0
  289. package/src/shiki/langs/diff.js +1 -0
  290. package/src/shiki/langs/docker.js +1 -0
  291. package/src/shiki/langs/dotenv.js +1 -0
  292. package/src/shiki/langs/dream-maker.js +1 -0
  293. package/src/shiki/langs/edge.js +1 -0
  294. package/src/shiki/langs/elixir.js +1 -0
  295. package/src/shiki/langs/elm.js +1 -0
  296. package/src/shiki/langs/emacs-lisp.js +1 -0
  297. package/src/shiki/langs/erb.js +1 -0
  298. package/src/shiki/langs/erlang.js +1 -0
  299. package/src/shiki/langs/es-tag-css.js +1 -0
  300. package/src/shiki/langs/es-tag-glsl.js +1 -0
  301. package/src/shiki/langs/es-tag-html.js +1 -0
  302. package/src/shiki/langs/es-tag-sql.js +1 -0
  303. package/src/shiki/langs/es-tag-xml.js +1 -0
  304. package/src/shiki/langs/fennel.js +1 -0
  305. package/src/shiki/langs/fish.js +1 -0
  306. package/src/shiki/langs/fluent.js +1 -0
  307. package/src/shiki/langs/fortran-fixed-form.js +1 -0
  308. package/src/shiki/langs/fortran-free-form.js +1 -0
  309. package/src/shiki/langs/fsharp.js +1 -0
  310. package/src/shiki/langs/gdresource.js +1 -0
  311. package/src/shiki/langs/gdscript.js +1 -0
  312. package/src/shiki/langs/gdshader.js +1 -0
  313. package/src/shiki/langs/genie.js +1 -0
  314. package/src/shiki/langs/gherkin.js +1 -0
  315. package/src/shiki/langs/git-commit.js +1 -0
  316. package/src/shiki/langs/git-rebase.js +1 -0
  317. package/src/shiki/langs/gleam.js +1 -0
  318. package/src/shiki/langs/glimmer-js.js +1 -0
  319. package/src/shiki/langs/glimmer-ts.js +1 -0
  320. package/src/shiki/langs/glsl.js +1 -0
  321. package/src/shiki/langs/gnuplot.js +1 -0
  322. package/src/shiki/langs/go.js +1 -0
  323. package/src/shiki/langs/graphql.js +1 -0
  324. package/src/shiki/langs/groovy.js +1 -0
  325. package/src/shiki/langs/hack.js +1 -0
  326. package/src/shiki/langs/haml.js +1 -0
  327. package/src/shiki/langs/handlebars.js +1 -0
  328. package/src/shiki/langs/haskell.js +1 -0
  329. package/src/shiki/langs/haxe.js +1 -0
  330. package/src/shiki/langs/hcl.js +1 -0
  331. package/src/shiki/langs/hjson.js +1 -0
  332. package/src/shiki/langs/hlsl.js +1 -0
  333. package/src/shiki/langs/html-derivative.js +1 -0
  334. package/src/shiki/langs/html.js +1 -0
  335. package/src/shiki/langs/http.js +1 -0
  336. package/src/shiki/langs/hxml.js +1 -0
  337. package/src/shiki/langs/hy.js +1 -0
  338. package/src/shiki/langs/imba.js +1 -0
  339. package/src/shiki/langs/ini.js +1 -0
  340. package/src/shiki/langs/java.js +1 -0
  341. package/src/shiki/langs/javascript.js +1 -0
  342. package/src/shiki/langs/jinja-html.js +1 -0
  343. package/src/shiki/langs/jinja.js +1 -0
  344. package/src/shiki/langs/jison.js +1 -0
  345. package/src/shiki/langs/json.js +1 -0
  346. package/src/shiki/langs/json5.js +1 -0
  347. package/src/shiki/langs/jsonc.js +1 -0
  348. package/src/shiki/langs/jsonl.js +1 -0
  349. package/src/shiki/langs/jsonnet.js +1 -0
  350. package/src/shiki/langs/jssm.js +1 -0
  351. package/src/shiki/langs/jsx.js +1 -0
  352. package/src/shiki/langs/julia.js +1 -0
  353. package/src/shiki/langs/kotlin.js +1 -0
  354. package/src/shiki/langs/kusto.js +1 -0
  355. package/src/shiki/langs/latex.js +1 -0
  356. package/src/shiki/langs/lean.js +1 -0
  357. package/src/shiki/langs/less.js +1 -0
  358. package/src/shiki/langs/liquid.js +1 -0
  359. package/src/shiki/langs/llvm.js +1 -0
  360. package/src/shiki/langs/log.js +1 -0
  361. package/src/shiki/langs/logo.js +1 -0
  362. package/src/shiki/langs/lua.js +1 -0
  363. package/src/shiki/langs/luau.js +1 -0
  364. package/src/shiki/langs/make.js +1 -0
  365. package/src/shiki/langs/markdown-vue.js +1 -0
  366. package/src/shiki/langs/markdown.js +1 -0
  367. package/src/shiki/langs/marko.js +1 -0
  368. package/src/shiki/langs/matlab.js +1 -0
  369. package/src/shiki/langs/mdc.js +1 -0
  370. package/src/shiki/langs/mdx.js +1 -0
  371. package/src/shiki/langs/mermaid.js +1 -0
  372. package/src/shiki/langs/mipsasm.js +1 -0
  373. package/src/shiki/langs/mojo.js +1 -0
  374. package/src/shiki/langs/move.js +1 -0
  375. package/src/shiki/langs/narrat.js +1 -0
  376. package/src/shiki/langs/nextflow.js +1 -0
  377. package/src/shiki/langs/nginx.js +1 -0
  378. package/src/shiki/langs/nim.js +1 -0
  379. package/src/shiki/langs/nix.js +1 -0
  380. package/src/shiki/langs/nushell.js +1 -0
  381. package/src/shiki/langs/objective-c.js +1 -0
  382. package/src/shiki/langs/objective-cpp.js +1 -0
  383. package/src/shiki/langs/ocaml.js +1 -0
  384. package/src/shiki/langs/pascal.js +1 -0
  385. package/src/shiki/langs/perl.js +1 -0
  386. package/src/shiki/langs/php.js +1 -0
  387. package/src/shiki/langs/plsql.js +1 -0
  388. package/src/shiki/langs/po.js +1 -0
  389. package/src/shiki/langs/polar.js +1 -0
  390. package/src/shiki/langs/postcss.js +1 -0
  391. package/src/shiki/langs/powerquery.js +1 -0
  392. package/src/shiki/langs/powershell.js +1 -0
  393. package/src/shiki/langs/prisma.js +1 -0
  394. package/src/shiki/langs/prolog.js +1 -0
  395. package/src/shiki/langs/proto.js +1 -0
  396. package/src/shiki/langs/pug.js +1 -0
  397. package/src/shiki/langs/puppet.js +1 -0
  398. package/src/shiki/langs/purescript.js +1 -0
  399. package/src/shiki/langs/python.js +1 -0
  400. package/src/shiki/langs/qml.js +1 -0
  401. package/src/shiki/langs/qmldir.js +1 -0
  402. package/src/shiki/langs/qss.js +1 -0
  403. package/src/shiki/langs/r.js +1 -0
  404. package/src/shiki/langs/racket.js +1 -0
  405. package/src/shiki/langs/raku.js +1 -0
  406. package/src/shiki/langs/razor.js +1 -0
  407. package/src/shiki/langs/reg.js +1 -0
  408. package/src/shiki/langs/regexp.js +1 -0
  409. package/src/shiki/langs/rel.js +1 -0
  410. package/src/shiki/langs/riscv.js +1 -0
  411. package/src/shiki/langs/rst.js +1 -0
  412. package/src/shiki/langs/ruby.js +1 -0
  413. package/src/shiki/langs/rust.js +1 -0
  414. package/src/shiki/langs/sas.js +1 -0
  415. package/src/shiki/langs/sass.js +1 -0
  416. package/src/shiki/langs/scala.js +1 -0
  417. package/src/shiki/langs/scheme.js +1 -0
  418. package/src/shiki/langs/scss.js +1 -0
  419. package/src/shiki/langs/sdbl.js +1 -0
  420. package/src/shiki/langs/shaderlab.js +1 -0
  421. package/src/shiki/langs/shellscript.js +1 -0
  422. package/src/shiki/langs/shellsession.js +1 -0
  423. package/src/shiki/langs/smalltalk.js +1 -0
  424. package/src/shiki/langs/solidity.js +1 -0
  425. package/src/shiki/langs/soy.js +1 -0
  426. package/src/shiki/langs/sparql.js +1 -0
  427. package/src/shiki/langs/splunk.js +1 -0
  428. package/src/shiki/langs/sql.js +1 -0
  429. package/src/shiki/langs/ssh-config.js +1 -0
  430. package/src/shiki/langs/stata.js +1 -0
  431. package/src/shiki/langs/stylus.js +1 -0
  432. package/src/shiki/langs/svelte.js +1 -0
  433. package/src/shiki/langs/swift.js +1 -0
  434. package/src/shiki/langs/system-verilog.js +1 -0
  435. package/src/shiki/langs/systemd.js +1 -0
  436. package/src/shiki/langs/talonscript.js +1 -0
  437. package/src/shiki/langs/tasl.js +1 -0
  438. package/src/shiki/langs/tcl.js +1 -0
  439. package/src/shiki/langs/templ.js +1 -0
  440. package/src/shiki/langs/terraform.js +1 -0
  441. package/src/shiki/langs/tex.js +1 -0
  442. package/src/shiki/langs/toml.js +1 -0
  443. package/src/shiki/langs/ts-tags.js +1 -0
  444. package/src/shiki/langs/tsv.js +1 -0
  445. package/src/shiki/langs/tsx.js +1 -0
  446. package/src/shiki/langs/turtle.js +1 -0
  447. package/src/shiki/langs/twig.js +1 -0
  448. package/src/shiki/langs/typescript.js +1 -0
  449. package/src/shiki/langs/typespec.js +1 -0
  450. package/src/shiki/langs/typst.js +1 -0
  451. package/src/shiki/langs/v.js +1 -0
  452. package/src/shiki/langs/vala.js +1 -0
  453. package/src/shiki/langs/vb.js +1 -0
  454. package/src/shiki/langs/verilog.js +1 -0
  455. package/src/shiki/langs/vhdl.js +1 -0
  456. package/src/shiki/langs/viml.js +1 -0
  457. package/src/shiki/langs/vue-directives.js +1 -0
  458. package/src/shiki/langs/vue-html.js +1 -0
  459. package/src/shiki/langs/vue-interpolations.js +1 -0
  460. package/src/shiki/langs/vue-sfc-style-variable-injection.js +1 -0
  461. package/src/shiki/langs/vue.js +1 -0
  462. package/src/shiki/langs/vyper.js +1 -0
  463. package/src/shiki/langs/wasm.js +1 -0
  464. package/src/shiki/langs/wenyan.js +1 -0
  465. package/src/shiki/langs/wgsl.js +1 -0
  466. package/src/shiki/langs/wikitext.js +1 -0
  467. package/src/shiki/langs/wit.js +1 -0
  468. package/src/shiki/langs/wolfram.js +1 -0
  469. package/src/shiki/langs/xml.js +1 -0
  470. package/src/shiki/langs/xsl.js +1 -0
  471. package/src/shiki/langs/yaml.js +1 -0
  472. package/src/shiki/langs/zenscript.js +1 -0
  473. package/src/shiki/langs/zig.js +1 -0
  474. package/src/shiki/themes/andromeeda.js +1 -0
  475. package/src/shiki/themes/aurora-x.js +1 -0
  476. package/src/shiki/themes/ayu-dark.js +1 -0
  477. package/src/shiki/themes/catppuccin-frappe.js +1 -0
  478. package/src/shiki/themes/catppuccin-latte.js +1 -0
  479. package/src/shiki/themes/catppuccin-macchiato.js +1 -0
  480. package/src/shiki/themes/catppuccin-mocha.js +1 -0
  481. package/src/shiki/themes/dark-plus.js +1 -0
  482. package/src/shiki/themes/dracula-soft.js +1 -0
  483. package/src/shiki/themes/dracula.js +1 -0
  484. package/src/shiki/themes/everforest-dark.js +1 -0
  485. package/src/shiki/themes/everforest-light.js +1 -0
  486. package/src/shiki/themes/github-dark-default.js +1 -0
  487. package/src/shiki/themes/github-dark-dimmed.js +1 -0
  488. package/src/shiki/themes/github-dark-high-contrast.js +1 -0
  489. package/src/shiki/themes/github-dark.js +1 -0
  490. package/src/shiki/themes/github-light-default.js +1 -0
  491. package/src/shiki/themes/github-light-high-contrast.js +1 -0
  492. package/src/shiki/themes/github-light.js +1 -0
  493. package/src/shiki/themes/gruvbox-dark-hard.js +1 -0
  494. package/src/shiki/themes/gruvbox-dark-medium.js +1 -0
  495. package/src/shiki/themes/gruvbox-dark-soft.js +1 -0
  496. package/src/shiki/themes/gruvbox-light-hard.js +1 -0
  497. package/src/shiki/themes/gruvbox-light-medium.js +1 -0
  498. package/src/shiki/themes/gruvbox-light-soft.js +1 -0
  499. package/src/shiki/themes/houston.js +1 -0
  500. package/src/shiki/themes/kanagawa-dragon.js +1 -0
  501. package/src/shiki/themes/kanagawa-lotus.js +1 -0
  502. package/src/shiki/themes/kanagawa-wave.js +1 -0
  503. package/src/shiki/themes/laserwave.js +1 -0
  504. package/src/shiki/themes/light-plus.js +1 -0
  505. package/src/shiki/themes/material-theme-darker.js +1 -0
  506. package/src/shiki/themes/material-theme-lighter.js +1 -0
  507. package/src/shiki/themes/material-theme-ocean.js +1 -0
  508. package/src/shiki/themes/material-theme-palenight.js +1 -0
  509. package/src/shiki/themes/material-theme.js +1 -0
  510. package/src/shiki/themes/min-dark.js +1 -0
  511. package/src/shiki/themes/min-light.js +1 -0
  512. package/src/shiki/themes/monokai.js +1 -0
  513. package/src/shiki/themes/night-owl.js +1 -0
  514. package/src/shiki/themes/nord.js +1 -0
  515. package/src/shiki/themes/one-dark-pro.js +1 -0
  516. package/src/shiki/themes/one-light.js +1 -0
  517. package/src/shiki/themes/plastic.js +1 -0
  518. package/src/shiki/themes/poimandres.js +1 -0
  519. package/src/shiki/themes/red.js +1 -0
  520. package/src/shiki/themes/rose-pine-dawn.js +1 -0
  521. package/src/shiki/themes/rose-pine-moon.js +1 -0
  522. package/src/shiki/themes/rose-pine.js +1 -0
  523. package/src/shiki/themes/slack-dark.js +1 -0
  524. package/src/shiki/themes/slack-ochin.js +1 -0
  525. package/src/shiki/themes/snazzy-light.js +1 -0
  526. package/src/shiki/themes/solarized-dark.js +1 -0
  527. package/src/shiki/themes/solarized-light.js +1 -0
  528. package/src/shiki/themes/synthwave-84.js +1 -0
  529. package/src/shiki/themes/tokyo-night.js +1 -0
  530. package/src/shiki/themes/vesper.js +1 -0
  531. package/src/shiki/themes/vitesse-black.js +1 -0
  532. package/src/shiki/themes/vitesse-dark.js +1 -0
  533. package/src/shiki/themes/vitesse-light.js +1 -0
  534. package/lib/AuthenticationPlugin-BlJsiGuX.js +0 -99
  535. package/lib/Markdown-DvdVn1O7.js +0 -17128
  536. package/lib/Markdown-DvdVn1O7.js.map +0 -1
  537. package/lib/MdxPage-DlJaCSPf.js +0 -85
  538. package/lib/RouteGuard-D2gX29iI.js +0 -744
  539. package/lib/SchemaView-Bt95NiyQ.js.map +0 -1
  540. package/lib/Select-CYaEBIYK.js +0 -223
  541. package/lib/SlotletProvider-wWbHYqWf.js +0 -340
  542. package/lib/SlotletProvider-wWbHYqWf.js.map +0 -1
  543. package/lib/SyntaxHighlight-o7q0acut.js +0 -2890
  544. package/lib/SyntaxHighlight-o7q0acut.js.map +0 -1
  545. package/lib/_commonjsHelpers-B4e78b8K.js +0 -29
  546. package/lib/_commonjsHelpers-B4e78b8K.js.map +0 -1
  547. package/lib/createServer-XtO-PVox.js.map +0 -1
  548. package/lib/hook-8GM2HXNM.js +0 -1478
  549. package/lib/hook-8GM2HXNM.js.map +0 -1
  550. package/lib/index-CZnufgn5.js.map +0 -1
  551. package/lib/index-CzUOM_vE.js +0 -5039
  552. package/lib/index-CzUOM_vE.js.map +0 -1
  553. package/lib/invariant-Caa8-XvF.js +0 -26
  554. package/lib/mutation-Bq5bn7Hf.js +0 -211
  555. package/lib/prism-bash.min-HHIMdNJ_.js +0 -7
  556. package/lib/prism-bash.min-HHIMdNJ_.js.map +0 -1
  557. package/lib/prism-csharp.min-C43x1RY2.js +0 -63
  558. package/lib/prism-csharp.min-C43x1RY2.js.map +0 -1
  559. package/lib/prism-java.min-CQzr40NQ.js +0 -35
  560. package/lib/prism-java.min-CQzr40NQ.js.map +0 -1
  561. package/lib/prism-javascript.min-CEqHqgbm.js +0 -9
  562. package/lib/prism-javascript.min-CEqHqgbm.js.map +0 -1
  563. package/lib/prism-json.min-B1GJqK1k.js +0 -2
  564. package/lib/prism-json.min-B1GJqK1k.js.map +0 -1
  565. package/lib/prism-jsstacktrace.min-BfobCF2F.js +0 -2
  566. package/lib/prism-jsstacktrace.min-BfobCF2F.js.map +0 -1
  567. package/lib/prism-markdown.min-C0Qn0m-5.js +0 -61
  568. package/lib/prism-markdown.min-C0Qn0m-5.js.map +0 -1
  569. package/lib/prism-markup-BNGj0Tvm.js +0 -174
  570. package/lib/prism-markup-BNGj0Tvm.js.map +0 -1
  571. package/lib/prism-objectivec.min-BXSWqpJJ.js +0 -2
  572. package/lib/prism-objectivec.min-BXSWqpJJ.js.map +0 -1
  573. package/lib/prism-ruby.min-L9OdQ6tU.js +0 -38
  574. package/lib/prism-ruby.min-L9OdQ6tU.js.map +0 -1
  575. package/lib/prism-typescript.min-qTySPvCh.js +0 -34
  576. package/lib/prism-typescript.min-qTySPvCh.js.map +0 -1
@@ -15,7 +15,9 @@ import { LogicalGroup } from "./LogicalGroup/LogicalGroup.js";
15
15
  import { SchemaExampleAndDefault } from "./SchemaExampleAndDefault.js";
16
16
  import { SchemaView } from "./SchemaView.js";
17
17
  import {
18
+ extractCircularRefInfo,
18
19
  hasLogicalGroupings,
20
+ isArrayCircularRef,
19
21
  isArrayType,
20
22
  isCircularRef,
21
23
  isComplexType,
@@ -40,13 +42,13 @@ export const SchemaLogicalGroup = ({ schema }: { schema: SchemaObject }) => {
40
42
  }
41
43
  };
42
44
 
43
- const RecursiveIndicator = () => (
45
+ const RecursiveIndicator = ({ circularProp }: { circularProp?: string }) => (
44
46
  <InlineCode
45
47
  className="inline-flex items-center gap-1.5 italic text-xs translate-y-0.5"
46
48
  selectOnClick={false}
47
49
  >
48
50
  <RefreshCcwDotIcon size={13} />
49
- <span>circular</span>
51
+ <span>{circularProp ? `${circularProp} (circular)` : "circular"}</span>
50
52
  </InlineCode>
51
53
  );
52
54
 
@@ -82,6 +84,16 @@ export const SchemaPropertyItem = ({
82
84
  );
83
85
  }
84
86
 
87
+ const isCollapsible = Boolean(
88
+ (hasLogicalGroupings(schema) ||
89
+ isComplexType(schema) ||
90
+ (isArrayType(schema) &&
91
+ "items" in schema &&
92
+ isComplexType(schema.items)) ||
93
+ schema.additionalProperties) &&
94
+ !isArrayCircularRef(schema),
95
+ );
96
+
85
97
  return (
86
98
  <li className="p-4 bg-border/20 hover:bg-border/30">
87
99
  <div className="flex flex-col gap-2.5 justify-between text-sm">
@@ -95,9 +107,11 @@ export const SchemaPropertyItem = ({
95
107
  group !== "optional" && (
96
108
  <span className="text-primary">required</span>
97
109
  ),
98
- isArrayType(schema) &&
99
- "items" in schema &&
100
- isCircularRef(schema.items) && <RecursiveIndicator />,
110
+ isArrayCircularRef(schema) && (
111
+ <RecursiveIndicator
112
+ circularProp={extractCircularRefInfo(schema.items)}
113
+ />
114
+ ),
101
115
  ]}
102
116
  />
103
117
  </div>
@@ -113,10 +127,7 @@ export const SchemaPropertyItem = ({
113
127
  {schema.const && <ConstValue schema={schema} hideDescription />}
114
128
  {schema.enum && <EnumValues values={schema.enum} />}
115
129
  <SchemaExampleAndDefault schema={schema} />
116
- {(hasLogicalGroupings(schema) ||
117
- isComplexType(schema) ||
118
- isArrayType(schema) ||
119
- schema.additionalProperties) && (
130
+ {isCollapsible && (
120
131
  <Collapsible.Root
121
132
  defaultOpen={defaultOpen}
122
133
  open={isOpen}
@@ -136,14 +147,9 @@ export const SchemaPropertyItem = ({
136
147
  <SchemaLogicalGroup schema={schema} />
137
148
  ) : schema.type === "object" ? (
138
149
  <SchemaView schema={schema} />
139
- ) : (
140
- isArrayType(schema) &&
141
- "items" in schema &&
142
- typeof schema.items === "object" &&
143
- !isCircularRef(schema.items) && (
144
- <SchemaView schema={schema.items} />
145
- )
146
- )}
150
+ ) : isArrayType(schema) && "items" in schema ? (
151
+ <SchemaView schema={schema.items} />
152
+ ) : null}
147
153
  </div>
148
154
  </Collapsible.Content>
149
155
  </Collapsible.Root>
@@ -12,11 +12,13 @@ export const isArrayType = (value: SchemaObject) =>
12
12
  // schema.type might be an array of types, so we need to check if "array" is one of them
13
13
  (Array.isArray(value.type) && value.type.includes("array"));
14
14
 
15
- export const isComplexType = (value: SchemaObject) =>
16
- (value.type === "object" && Object.keys(value.properties ?? {}).length > 0) ||
17
- (value.type === "array" &&
18
- typeof value.items === "object" &&
19
- (!value.items.type || value.items.type === "object"));
15
+ export const isComplexType = (value?: SchemaObject) =>
16
+ value &&
17
+ ((value.type === "object" &&
18
+ Object.keys(value.properties ?? {}).length > 0) ||
19
+ (value.type === "array" &&
20
+ typeof value.items === "object" &&
21
+ (!value.items.type || value.items.type === "object")));
20
22
 
21
23
  export const hasLogicalGroupings = (value: SchemaObject) =>
22
24
  Boolean(value.oneOf ?? value.allOf ?? value.anyOf);
@@ -30,4 +32,14 @@ export const LogicalSchemaTypeMap = {
30
32
  export type LogicalGroupType = "AND" | "OR" | "ONE";
31
33
 
32
34
  export const isCircularRef = (schema: unknown): schema is string =>
33
- schema === CIRCULAR_REF;
35
+ typeof schema === "string" && schema.startsWith(CIRCULAR_REF);
36
+
37
+ export const isArrayCircularRef = (
38
+ schema: SchemaObject,
39
+ ): schema is SchemaObject & { items: SchemaObject } =>
40
+ isArrayType(schema) && "items" in schema && isCircularRef(schema.items);
41
+
42
+ export const extractCircularRefInfo = (
43
+ ref?: string | SchemaObject,
44
+ ): string | undefined =>
45
+ typeof ref === "string" ? ref.split(":")[1] : undefined;
@@ -1,10 +1,15 @@
1
1
  import { type SchemaObject } from "../../../oas/graphql/index.js";
2
+ import { isCircularRef } from "../schema/utils.js";
2
3
 
3
4
  export const generateSchemaExample = (
4
- schema: SchemaObject,
5
+ schema?: SchemaObject,
5
6
  name?: string,
6
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
8
  ): any => {
9
+ if (!schema || isCircularRef(schema)) {
10
+ return null;
11
+ }
12
+
8
13
  // Check for schema-level example first
9
14
  if (schema.example !== undefined) {
10
15
  return schema.example;
@@ -0,0 +1,133 @@
1
+ import rehypeShikiFromHighlighter, {
2
+ type RehypeShikiCoreOptions,
3
+ } from "@shikijs/rehype/core";
4
+ import {
5
+ transformerMetaHighlight,
6
+ transformerMetaWordHighlight,
7
+ } from "@shikijs/transformers";
8
+ import type { Root } from "hast";
9
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
10
+ import { Fragment, type JSX } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import type { BundledLanguage, BundledTheme, HighlighterCore } from "shiki";
13
+ import { createHighlighterCore } from "shiki/core";
14
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
15
+ import type { Pluggable } from "unified";
16
+ import { visit } from "unist-util-visit";
17
+ import { cn } from "./util/cn.js";
18
+
19
+ const engine = createJavaScriptRegexEngine({ forgiving: true });
20
+ export const highlighter = await createHighlighterCore({
21
+ engine,
22
+ langAlias: {
23
+ markup: "html",
24
+ svg: "xml",
25
+ mathml: "xml",
26
+ atom: "xml",
27
+ ssml: "xml",
28
+ rss: "xml",
29
+ webmanifest: "json",
30
+ },
31
+ });
32
+
33
+ export const defaultHighlightOptions = {
34
+ themes: {
35
+ light: "github-light",
36
+ dark: "github-dark",
37
+ } satisfies { light: BundledTheme; dark: BundledTheme },
38
+ defaultColor: false,
39
+ inline: "tailing-curly-colon",
40
+ addLanguageClass: true,
41
+ transformers: [transformerMetaHighlight(), transformerMetaWordHighlight()],
42
+ parseMetaString: (str) => {
43
+ // Matches key="value", key=value, or key attributes
44
+ const matches = str.matchAll(
45
+ /([a-z0-9]+)(?:=(["'])(.*?)\2|=(.*?)(?:\s|$)|(?:\s|$))/gi,
46
+ );
47
+ return Object.fromEntries(
48
+ Array.from(matches).map((match) => {
49
+ const key = match[1];
50
+ const value = match[3] || match[4] || true;
51
+ return [key, value];
52
+ }),
53
+ );
54
+ },
55
+ } satisfies RehypeShikiCoreOptions;
56
+
57
+ export const defaultLanguages: BundledLanguage[] = [
58
+ "shellscript",
59
+ "javascript",
60
+ "jsx",
61
+ "typescript",
62
+ "tsx",
63
+ "json",
64
+ "python",
65
+ "java",
66
+ "go",
67
+ "csharp",
68
+ "kotlin",
69
+ "objective-c",
70
+ "php",
71
+ "ruby",
72
+ "swift",
73
+ "css",
74
+ "html",
75
+ "xml",
76
+ "yaml",
77
+ "markdown",
78
+ "mdx",
79
+ ];
80
+
81
+ const rehypeCodeBlockPlugin = () => (tree: Root) => {
82
+ visit(tree, "element", (node, _index, parent) => {
83
+ if (node.tagName !== "code") return;
84
+
85
+ const isCodeBlock = parent?.type === "element" && parent.tagName === "pre";
86
+ node.properties.inline = JSON.stringify(!isCodeBlock);
87
+
88
+ // Pass through properties from <pre> to <code> so we can handle it in `code` only
89
+ if (isCodeBlock) {
90
+ node.properties = {
91
+ ...node.properties,
92
+ ...structuredClone(parent.properties),
93
+ class: cn(node.properties.class, parent.properties.class),
94
+ };
95
+ parent.properties = {};
96
+ }
97
+ });
98
+ };
99
+
100
+ export const createConfiguredShikiRehypePlugins = (themes?: {
101
+ light: BundledTheme;
102
+ dark: BundledTheme;
103
+ }) => {
104
+ return [
105
+ [
106
+ rehypeShikiFromHighlighter,
107
+ highlighter,
108
+ {
109
+ ...defaultHighlightOptions,
110
+ themes: themes ?? defaultHighlightOptions.themes,
111
+ } satisfies RehypeShikiCoreOptions,
112
+ ] satisfies Pluggable,
113
+ rehypeCodeBlockPlugin,
114
+ ];
115
+ };
116
+
117
+ export const highlight = (
118
+ highlighter: HighlighterCore,
119
+ code: string,
120
+ lang = "text",
121
+ themes: {
122
+ light: BundledTheme;
123
+ dark: BundledTheme;
124
+ } = defaultHighlightOptions.themes,
125
+ ) => {
126
+ const value = highlighter.codeToHast(code, {
127
+ lang,
128
+ ...defaultHighlightOptions,
129
+ themes,
130
+ });
131
+
132
+ return toJsxRuntime(value, { Fragment, jsx, jsxs }) as JSX.Element;
133
+ };
@@ -77,7 +77,7 @@ export const Callout = ({
77
77
  "grid grid-cols-[min-content_1fr] items-baseline grid-rows-[fit-content_1fr] gap-x-4 gap-y-2",
78
78
  !icon && title && "flex flex-col gap-2",
79
79
  "[&_a]:underline [&_a]:decoration-current [&_a]:decoration-from-font [&_a]:underline-offset-4 hover:[&_a]:decoration-1",
80
- "[&_code]:!bg-gray-50 [&_code]:dark:!bg-gray-800 [&_code]:!border-none",
80
+ "[&_.code-block-wrapper]:border",
81
81
  "[&_ul]:list-disc [&_ol]:list-decimal [&_ul]:ps-4 [&_ul>li]:ps-1 [&_ul>li]:my-1",
82
82
  icon && title && "items-center",
83
83
  border,
@@ -0,0 +1,102 @@
1
+ import { CheckIcon, CopyIcon } from "lucide-react";
2
+ import type { ReactNode } from "react";
3
+ import { useRef, useState } from "react";
4
+ import { cn } from "../util/cn.js";
5
+
6
+ export type CodeBlockProps = {
7
+ className?: string;
8
+ noBackground?: boolean;
9
+ wrapLines?: boolean;
10
+ showLanguageIndicator?: boolean;
11
+ language?: string;
12
+ title?: string;
13
+ children?: ReactNode;
14
+ code?: ReactNode;
15
+ showCopy?: "hover" | "always" | "never";
16
+ showCopyText?: boolean;
17
+ disabled?: boolean;
18
+ showLineNumbers?: boolean;
19
+ };
20
+
21
+ export const CodeBlock = ({
22
+ children,
23
+ title,
24
+ language,
25
+ showCopy = "hover",
26
+ showCopyText,
27
+ showLanguageIndicator = true,
28
+ showLineNumbers,
29
+ ...props
30
+ }: CodeBlockProps) => {
31
+ const [isCopied, setIsCopied] = useState(false);
32
+ const ref = useRef<HTMLDivElement>(null);
33
+
34
+ if (!children) return null;
35
+
36
+ return (
37
+ <div
38
+ className={cn(
39
+ "code-block-wrapper relative group bg-muted/50 rounded-md",
40
+ showLineNumbers && "line-numbers",
41
+ )}
42
+ >
43
+ {title && (
44
+ <div className="text-xs text-muted-foreground top-2 font-mono border-b w-full py-2 px-4 ">
45
+ {title}
46
+ </div>
47
+ )}
48
+ <div
49
+ className={cn(
50
+ "code-block text-sm not-prose scrollbar overflow-x-auto scrollbar p-4",
51
+ props.className,
52
+ )}
53
+ ref={ref}
54
+ >
55
+ {children}
56
+ </div>
57
+ {showLanguageIndicator && (
58
+ <span
59
+ className={cn(
60
+ "absolute top-1.5 end-3 !text-[11px] font-mono text-muted-foreground transition group-hover:opacity-0",
61
+ title && "top-12",
62
+ )}
63
+ >
64
+ {language}
65
+ </span>
66
+ )}
67
+ {showCopy !== "never" && (
68
+ <button
69
+ type="button"
70
+ aria-label="Copy code"
71
+ title="Copy code"
72
+ className={cn(
73
+ "absolute top-2 end-2 p-2 hover:outline hover:outline-border/75 dark:hover:outline-border rounded-md text-sm text-muted-foreground transition",
74
+ title && "top-10",
75
+ showCopy === "hover" && "opacity-0 group-hover:opacity-100",
76
+ showCopyText && "flex gap-2 items-center font-medium",
77
+ )}
78
+ disabled={isCopied}
79
+ onClick={() => {
80
+ if (!ref.current?.textContent) return;
81
+
82
+ setIsCopied(true);
83
+ void navigator.clipboard.writeText(ref.current.textContent);
84
+ setTimeout(() => setIsCopied(false), 2000);
85
+ }}
86
+ >
87
+ {isCopied ? (
88
+ <CheckIcon
89
+ className="text-emerald-600"
90
+ size={16}
91
+ strokeWidth={2.5}
92
+ absoluteStrokeWidth
93
+ />
94
+ ) : (
95
+ <CopyIcon size={16} />
96
+ )}
97
+ {showCopyText && "Copy"}
98
+ </button>
99
+ )}
100
+ </div>
101
+ );
102
+ };
@@ -1,186 +1,27 @@
1
- import {
2
- Highlight,
3
- Prism,
4
- themes,
5
- type HighlightProps,
6
- } from "prism-react-renderer";
7
-
8
- import { CheckIcon, CopyIcon } from "lucide-react";
9
-
10
- globalThis.Prism = Prism;
11
- // @ts-expect-error This is untyped
12
- void import("prismjs/components/prism-bash.min.js");
13
- // @ts-expect-error This is untyped
14
- void import("prismjs/components/prism-ruby.min.js");
15
- // @ts-expect-error This is untyped
16
- void import("prismjs/components/prism-markup.js");
17
- // @ts-expect-error This is untyped
18
- void import("prismjs/components/prism-json.min.js");
19
- // @ts-expect-error This is untyped
20
- void import("prismjs/components/prism-java.min.js");
21
- // @ts-expect-error This is untyped
22
- void import("prismjs/components/prism-csharp.min.js");
23
- // @ts-expect-error This is untyped
24
- void import("prismjs/components/prism-objectivec.min.js");
25
- // @ts-expect-error This is untyped
26
- void import("prismjs/components/prism-markdown.min.js");
27
- // @ts-expect-error This is untyped
28
- void import("prismjs/components/prism-javascript.min.js");
29
- // @ts-expect-error This is untyped
30
- void import("prismjs/components/prism-typescript.min.js");
31
- // @ts-expect-error This is untyped
32
- void import("prismjs/components/prism-jsstacktrace.min.js");
33
-
34
- import { useTheme } from "next-themes";
35
- import { memo, useState } from "react";
36
- import { ClientOnly } from "../components/ClientOnly.js";
37
- import { cn } from "../util/cn.js";
38
-
39
- export type SyntaxHighlightProps = {
40
- className?: string;
41
- noBackground?: boolean;
42
- wrapLines?: boolean;
43
- showLanguageIndicator?: boolean;
44
- language?: string;
45
- title?: string;
46
- children?: string;
47
- code?: string;
48
- showCopy?: "hover" | "always" | "never";
49
- showCopyText?: boolean;
50
- disabled?: boolean;
51
- } & Omit<HighlightProps, "children" | "language">;
52
-
53
- const remapLang = {
54
- mdx: "md",
55
- } as Record<string, string>;
56
-
57
- const SyntaxHighlightInner = ({
58
- language = "plain",
59
- showCopy = "hover",
60
- showCopyText,
61
- title,
62
- children,
63
- disabled,
64
- ...props
65
- }: SyntaxHighlightProps) => {
66
- const { resolvedTheme } = useTheme();
67
- const [isCopied, setIsCopied] = useState(false);
68
-
69
- const code = children ?? props.code;
70
-
71
- if (!code) {
72
- return null;
73
- }
74
-
75
- const highlightTheme =
76
- resolvedTheme === "dark" ? themes.vsDark : themes.github;
77
-
78
- // hardcoded values from the themes to avoid color flash in SSR
79
- const themeColorClasses =
80
- "bg-[#f6f8fa] text-[#393a34] dark:bg-[#1e1e1e] dark:text-[#9cdcfe]";
81
-
82
- const Wrapper = ({
83
- children,
84
- className,
85
- style,
86
- }: {
87
- children: React.ReactNode;
88
- className?: string;
89
- style?: React.CSSProperties;
90
- }) => (
91
- <div className="relative group">
92
- {title && (
93
- <div className="text-xs text-muted-foreground absolute top-2 font-mono border-b w-full pb-2 px-4 ">
94
- {title}
95
- </div>
96
- )}
97
- <pre
98
- className={cn(
99
- "relative scrollbar overflow-x-auto",
100
- props.className,
101
- props.noBackground ? "!bg-transparent" : themeColorClasses,
102
- props.wrapLines && "whitespace-pre-wrap break-words",
103
- title && "pt-10",
104
- className,
105
- )}
106
- style={style}
107
- >
108
- {children}
109
- </pre>
110
- {props.showLanguageIndicator && (
111
- <span className="absolute top-1.5 end-3 text-[11px] font-mono text-muted-foreground transition group-hover:opacity-0">
112
- {language}
113
- </span>
114
- )}
115
- {showCopy !== "never" && (
116
- <button
117
- type="button"
118
- aria-label="Copy code"
119
- title="Copy code"
120
- className={cn(
121
- "absolute top-2 end-2 p-2 hover:outline hover:outline-border/75 dark:hover:outline-border rounded-md text-sm text-muted-foreground transition",
122
- showCopy === "hover"
123
- ? "opacity-0 group-hover:opacity-100 group-hover:bg-zinc-100 group-hover:dark:bg-zinc-700"
124
- : "bg-zinc-100 dark:bg-zinc-700",
125
- showCopyText && "flex gap-2 items-center font-medium",
126
- )}
127
- disabled={isCopied}
128
- onClick={() => {
129
- setIsCopied(true);
130
- void navigator.clipboard.writeText(code);
131
- setTimeout(() => setIsCopied(false), 2000);
132
- }}
133
- >
134
- {isCopied ? (
135
- <CheckIcon
136
- className="text-emerald-600"
137
- size={16}
138
- strokeWidth={2.5}
139
- absoluteStrokeWidth
140
- />
141
- ) : (
142
- <CopyIcon size={16} />
143
- )}
144
- {showCopyText && "Copy"}
145
- </button>
146
- )}
147
- </div>
148
- );
149
-
150
- if (disabled) {
151
- return (
152
- <ClientOnly fallback={<Wrapper>{code}</Wrapper>}>
153
- <Wrapper>{code}</Wrapper>
154
- </ClientOnly>
1
+ import { memo } from "react";
2
+ import { useZudoku } from "../components/context/ZudokuContext.js";
3
+ import { highlight } from "../shiki.js";
4
+ import invariant from "../util/invariant.js";
5
+ import { CodeBlock, type CodeBlockProps } from "./CodeBlock.js";
6
+
7
+ type SyntaxHighlightProps = CodeBlockProps &
8
+ ({ code: string; children?: never } | { code?: never; children: string });
9
+
10
+ export const SyntaxHighlight = memo(
11
+ ({ code, children, ...props }: SyntaxHighlightProps) => {
12
+ const { syntaxHighlighting } = useZudoku().options;
13
+
14
+ invariant(syntaxHighlighting?.highlighter, "Highlighter not found");
15
+
16
+ const highlightedCode = highlight(
17
+ syntaxHighlighting.highlighter,
18
+ code ?? children,
19
+ props.language,
20
+ syntaxHighlighting.themes,
155
21
  );
156
- }
157
-
158
- return (
159
- <ClientOnly fallback={<Wrapper>{code}</Wrapper>}>
160
- <Highlight
161
- theme={highlightTheme}
162
- language={remapLang[language] ?? language}
163
- {...props}
164
- code={code}
165
- >
166
- {({ className, style, tokens, getLineProps, getTokenProps }) => (
167
- <Wrapper className={className} style={style}>
168
- {tokens.map((line, i) => (
169
- // eslint-disable-next-line react/no-array-index-key
170
- <div key={i} {...getLineProps({ line })}>
171
- {line.map((token, key) => (
172
- // eslint-disable-next-line react/no-array-index-key
173
- <span key={key} {...getTokenProps({ token })} />
174
- ))}
175
- </div>
176
- ))}
177
- </Wrapper>
178
- )}
179
- </Highlight>
180
- </ClientOnly>
181
- );
182
- };
183
22
 
184
- export const SyntaxHighlight = memo(SyntaxHighlightInner);
23
+ return <CodeBlock {...props}>{highlightedCode}</CodeBlock>;
24
+ },
25
+ );
185
26
 
186
27
  SyntaxHighlight.displayName = "SyntaxHighlight";
@@ -1,4 +1,5 @@
1
1
  import { type MDXComponents } from "mdx/types.js";
2
+ import { CodeBlock } from "zudoku/ui/CodeBlock.js";
2
3
  import { AnchorLink } from "../components/AnchorLink.js";
3
4
  import { Heading } from "../components/Heading.js";
4
5
  import { InlineCode } from "../components/InlineCode.js";
@@ -6,6 +7,7 @@ import { Button } from "../ui/Button.js";
6
7
  import { Callout } from "../ui/Callout.js";
7
8
  import { Stepper } from "../ui/Stepper.js";
8
9
  import { SyntaxHighlight } from "../ui/SyntaxHighlight.js";
10
+ import { cn } from "./cn.js";
9
11
 
10
12
  export type MdxComponentsType = Readonly<MDXComponents> | null | undefined;
11
13
 
@@ -62,26 +64,37 @@ export const MdxComponents = {
62
64
  caution: (props) => <Callout type="caution" {...props} />,
63
65
  warning: (props) => <Callout type="caution" {...props} />,
64
66
  danger: (props) => <Callout type="danger" {...props} />,
65
- pre: ({ children }) => <>{children}</>,
66
- code: ({ className, children, ...props }) => {
67
- // `inline` provided by the rehype plugin, as react-markdown removed support for that
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- const { inline, title } = props as Record<string, unknown>;
67
+ pre: (props) => (
68
+ <pre className={cn("not-prose my-4", props.className)} {...props} />
69
+ ),
70
+ code: ({
71
+ className,
72
+ node: _node,
73
+ children,
74
+ title,
75
+ inline,
76
+ showLineNumbers,
77
+ ...props
78
+ }) => {
79
+ const match = className?.match(/language?-(\w+)/);
70
80
 
71
- if (inline === true || inline === "true") {
72
- return <InlineCode className={className}>{children}</InlineCode>;
81
+ if (inline === "true" || inline === true) {
82
+ return (
83
+ <InlineCode className={cn(className, "inline")}>{children}</InlineCode>
84
+ );
73
85
  }
74
86
 
75
- const match = className?.match(/language?-(\w+)/);
76
-
77
87
  return (
78
- <SyntaxHighlight
88
+ <CodeBlock
79
89
  language={match?.[1]}
80
- className="rounded-xl p-4 border dark:!bg-foreground/10 dark:border-transparent"
81
90
  showLanguageIndicator
82
- code={String(children).trim()}
83
- title={typeof title === "string" ? title : undefined}
84
- />
91
+ showLineNumbers={showLineNumbers}
92
+ title={title}
93
+ >
94
+ <code className={cn(className, "not-inline")} {...props}>
95
+ {children}
96
+ </code>
97
+ </CodeBlock>
85
98
  );
86
99
  },
87
100
  } satisfies MdxComponentsType;
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/abap";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/actionscript-3";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/ada";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/angular-expression";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/angular-html";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/angular-inline-style";
@@ -0,0 +1 @@
1
+ export { default } from "@shikijs/langs/angular-inline-template";