@42-central/ui-react 0.23.0 → 0.25.0

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 (215) hide show
  1. package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
  2. package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
  3. package/dist/{chunk-OZMSXYBX.js → chunk-36NWC4GV.js} +3 -3
  4. package/dist/{chunk-OZMSXYBX.js.map → chunk-36NWC4GV.js.map} +1 -1
  5. package/dist/{chunk-4FEOMQYR.js → chunk-54W6VAI3.js} +5 -5
  6. package/dist/{chunk-4FEOMQYR.js.map → chunk-54W6VAI3.js.map} +1 -1
  7. package/dist/{chunk-SZEOTXRZ.js → chunk-6II2DVYR.js} +5 -5
  8. package/dist/{chunk-SZEOTXRZ.js.map → chunk-6II2DVYR.js.map} +1 -1
  9. package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
  10. package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
  11. package/dist/{chunk-YPFSRZ3T.js → chunk-6UIQJJNJ.js} +3 -3
  12. package/dist/{chunk-YPFSRZ3T.js.map → chunk-6UIQJJNJ.js.map} +1 -1
  13. package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
  14. package/dist/chunk-7247WBTV.js.map +1 -0
  15. package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
  16. package/dist/chunk-7E7JNWOC.js.map +1 -0
  17. package/dist/{chunk-C4NFRSOR.js → chunk-7HZBD4YZ.js} +4 -4
  18. package/dist/{chunk-C4NFRSOR.js.map → chunk-7HZBD4YZ.js.map} +1 -1
  19. package/dist/{chunk-JVG5ISPT.js → chunk-AHKMN3YQ.js} +3 -3
  20. package/dist/{chunk-JVG5ISPT.js.map → chunk-AHKMN3YQ.js.map} +1 -1
  21. package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
  22. package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
  23. package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
  24. package/dist/chunk-BMEJBY6H.js.map +1 -0
  25. package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
  26. package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
  27. package/dist/chunk-F374BNL4.js +129 -0
  28. package/dist/chunk-F374BNL4.js.map +1 -0
  29. package/dist/{chunk-MRAJ45IM.js → chunk-FZSLSUSX.js} +4 -4
  30. package/dist/{chunk-MRAJ45IM.js.map → chunk-FZSLSUSX.js.map} +1 -1
  31. package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
  32. package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
  33. package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
  34. package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
  35. package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
  36. package/dist/chunk-KKLCHLCZ.js.map +1 -0
  37. package/dist/{chunk-YWTOW7PZ.js → chunk-LHUWOA2U.js} +8 -8
  38. package/dist/{chunk-YWTOW7PZ.js.map → chunk-LHUWOA2U.js.map} +1 -1
  39. package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
  40. package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
  41. package/dist/{chunk-O7LS6OZR.js → chunk-LMCUGYHT.js} +3 -3
  42. package/dist/{chunk-O7LS6OZR.js.map → chunk-LMCUGYHT.js.map} +1 -1
  43. package/dist/{chunk-DHJB4UJD.js → chunk-N5M4PDBK.js} +4 -4
  44. package/dist/{chunk-DHJB4UJD.js.map → chunk-N5M4PDBK.js.map} +1 -1
  45. package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
  46. package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
  47. package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
  48. package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
  49. package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
  50. package/dist/chunk-PEHFWGTT.js.map +1 -0
  51. package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
  52. package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
  53. package/dist/{chunk-IRNF274I.js → chunk-PI7X5YFJ.js} +3 -3
  54. package/dist/{chunk-IRNF274I.js.map → chunk-PI7X5YFJ.js.map} +1 -1
  55. package/dist/{chunk-F2FSHVO5.js → chunk-QZ4N5LYG.js} +7 -7
  56. package/dist/{chunk-F2FSHVO5.js.map → chunk-QZ4N5LYG.js.map} +1 -1
  57. package/dist/{chunk-E5H3YWZV.js → chunk-SAXWCGWR.js} +3 -3
  58. package/dist/{chunk-E5H3YWZV.js.map → chunk-SAXWCGWR.js.map} +1 -1
  59. package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
  60. package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
  61. package/dist/{chunk-D3JYDAUZ.js → chunk-T44RW5DW.js} +4 -4
  62. package/dist/{chunk-D3JYDAUZ.js.map → chunk-T44RW5DW.js.map} +1 -1
  63. package/dist/{chunk-FB2G4LNH.js → chunk-UDCCOUWR.js} +5 -5
  64. package/dist/{chunk-FB2G4LNH.js.map → chunk-UDCCOUWR.js.map} +1 -1
  65. package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
  66. package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
  67. package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
  68. package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
  69. package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
  70. package/dist/chunk-X6DESK37.js.map +1 -0
  71. package/dist/{chunk-7AQ4MN4M.js → chunk-XUFCI262.js} +4 -4
  72. package/dist/{chunk-7AQ4MN4M.js.map → chunk-XUFCI262.js.map} +1 -1
  73. package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
  74. package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
  75. package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
  76. package/dist/chunk-ZVECQBGG.js.map +1 -0
  77. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  78. package/dist/components/action-icon/index.js +1 -1
  79. package/dist/components/alert/index.js +1 -1
  80. package/dist/components/ambient-background/ambient-background.d.ts +14 -3
  81. package/dist/components/ambient-background/ambient-background.d.ts.map +1 -1
  82. package/dist/components/ambient-background/index.js +225 -2
  83. package/dist/components/ambient-background/index.js.map +1 -1
  84. package/dist/components/ambient-background/starfield.d.ts +13 -0
  85. package/dist/components/ambient-background/starfield.d.ts.map +1 -0
  86. package/dist/components/app-shell/index.js +4 -4
  87. package/dist/components/autocomplete/index.js +3 -3
  88. package/dist/components/avatar/index.js +2 -2
  89. package/dist/components/badge/badge.d.ts.map +1 -1
  90. package/dist/components/badge/index.js +1 -1
  91. package/dist/components/button/index.js +1 -1
  92. package/dist/components/button-multi-select/index.js +3 -3
  93. package/dist/components/button-select/index.js +3 -3
  94. package/dist/components/calendar/index.js +4 -4
  95. package/dist/components/calendar-heatmap/index.js +2 -2
  96. package/dist/components/camera/index.js +10 -10
  97. package/dist/components/card/card.d.ts.map +1 -1
  98. package/dist/components/card/index.js +1 -1
  99. package/dist/components/carousel/index.js +2 -2
  100. package/dist/components/checkbox/checkbox.d.ts +3 -2
  101. package/dist/components/checkbox/checkbox.d.ts.map +1 -1
  102. package/dist/components/checkbox/index.js +2 -2
  103. package/dist/components/choice-card-group/index.js +2 -2
  104. package/dist/components/choice-card-group/index.js.map +1 -1
  105. package/dist/components/clipboard/index.js +3 -3
  106. package/dist/components/code-block/code-block.d.ts +6 -3
  107. package/dist/components/code-block/code-block.d.ts.map +1 -1
  108. package/dist/components/code-block/highlighter.d.ts +16 -15
  109. package/dist/components/code-block/highlighter.d.ts.map +1 -1
  110. package/dist/components/code-block/index.d.ts +2 -1
  111. package/dist/components/code-block/index.d.ts.map +1 -1
  112. package/dist/components/code-block/index.js +81 -10
  113. package/dist/components/code-block/index.js.map +1 -1
  114. package/dist/components/code-block/languages.d.ts +61 -0
  115. package/dist/components/code-block/languages.d.ts.map +1 -0
  116. package/dist/components/code-block/static.d.ts +2 -1
  117. package/dist/components/code-block/static.d.ts.map +1 -1
  118. package/dist/components/code-block/static.js +99 -10
  119. package/dist/components/code-block/static.js.map +1 -1
  120. package/dist/components/combobox/index.js +3 -3
  121. package/dist/components/combobox-list/index.js +5 -5
  122. package/dist/components/compare/index.js +2 -2
  123. package/dist/components/data-table/index.js +30 -30
  124. package/dist/components/data-table/index.js.map +1 -1
  125. package/dist/components/date-picker/index.js +12 -12
  126. package/dist/components/download-button/index.js +2 -2
  127. package/dist/components/drawer/index.js +4 -4
  128. package/dist/components/field/field.d.ts +3 -0
  129. package/dist/components/field/field.d.ts.map +1 -1
  130. package/dist/components/field/index.js +1 -1
  131. package/dist/components/file-item/index.js +5 -5
  132. package/dist/components/file-preview/index.js +5 -5
  133. package/dist/components/file-trigger/index.js +2 -2
  134. package/dist/components/file-upload/index.js +6 -6
  135. package/dist/components/gallery/index.js +2 -2
  136. package/dist/components/geodesic/a11y.d.ts +3 -3
  137. package/dist/components/geodesic/a11y.d.ts.map +1 -1
  138. package/dist/components/image-cropper/index.js +7 -7
  139. package/dist/components/indicator/index.js +1 -1
  140. package/dist/components/input/index.js +2 -2
  141. package/dist/components/kbd/index.js +3 -3
  142. package/dist/components/kbd/kbd.d.ts.map +1 -1
  143. package/dist/components/lightbox/index.js +7 -7
  144. package/dist/components/menu/index.js +2 -2
  145. package/dist/components/modal/index.js +4 -4
  146. package/dist/components/multi-combobox-list/index.js +5 -5
  147. package/dist/components/multi-select/index.js +6 -6
  148. package/dist/components/number-input/index.js +3 -3
  149. package/dist/components/overlays/index.js +6 -6
  150. package/dist/components/password-input/index.js +3 -3
  151. package/dist/components/photo-capture/index.js +14 -14
  152. package/dist/components/pills-input/index.js +5 -5
  153. package/dist/components/pin-input/index.js +2 -2
  154. package/dist/components/radio-group/index.js +1 -1
  155. package/dist/components/rating/index.js +1 -1
  156. package/dist/components/schedule/index.js +5 -5
  157. package/dist/components/segment-group/index.js +4 -4
  158. package/dist/components/select/index.js +4 -4
  159. package/dist/components/slider/index.js +2 -2
  160. package/dist/components/spotlight/index.js +9 -9
  161. package/dist/components/switch/index.js +14 -19
  162. package/dist/components/switch/index.js.map +1 -1
  163. package/dist/components/switch/switch.d.ts +1 -0
  164. package/dist/components/switch/switch.d.ts.map +1 -1
  165. package/dist/components/table/index.js +1 -1
  166. package/dist/components/table/table.d.ts.map +1 -1
  167. package/dist/components/tabs/index.js +3 -3
  168. package/dist/components/tags-input/index.js +5 -5
  169. package/dist/components/text-input/index.js +2 -2
  170. package/dist/components/textarea/index.js +2 -2
  171. package/dist/components/theme-icon/index.js +1 -1
  172. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  173. package/dist/components/time-input/index.js +7 -7
  174. package/dist/components/tree-multi-select/index.js +6 -6
  175. package/dist/components/tree-select/index.js +3 -3
  176. package/dist/index.js +4 -4
  177. package/dist/theme.css +103 -23
  178. package/package.json +1 -1
  179. package/src/components/action-icon/action-icon.tsx +3 -1
  180. package/src/components/ambient-background/ambient-background.test.tsx +59 -0
  181. package/src/components/ambient-background/ambient-background.tsx +15 -2
  182. package/src/components/ambient-background/starfield.tsx +333 -0
  183. package/src/components/badge/badge.tsx +11 -6
  184. package/src/components/button/button.tsx +1 -1
  185. package/src/components/card/card.tsx +10 -9
  186. package/src/components/checkbox/checkbox.test.tsx +17 -9
  187. package/src/components/checkbox/checkbox.tsx +26 -27
  188. package/src/components/choice-card-group/choice-card-group.tsx +3 -3
  189. package/src/components/code-block/code-block.tsx +7 -4
  190. package/src/components/code-block/highlighter.test.ts +79 -1
  191. package/src/components/code-block/highlighter.ts +76 -30
  192. package/src/components/code-block/index.ts +2 -0
  193. package/src/components/code-block/languages.ts +63 -0
  194. package/src/components/code-block/static.tsx +2 -1
  195. package/src/components/data-table/data-table-pagination.tsx +5 -5
  196. package/src/components/data-table/data-table-stack.tsx +2 -2
  197. package/src/components/field/field.tsx +14 -0
  198. package/src/components/kbd/kbd.tsx +2 -1
  199. package/src/components/switch/switch.test.tsx +15 -0
  200. package/src/components/switch/switch.tsx +27 -27
  201. package/src/components/table/table.test.tsx +1 -1
  202. package/src/components/table/table.tsx +14 -11
  203. package/src/components/theme-icon/theme-icon.tsx +46 -12
  204. package/src/icon-stroke.test.tsx +2 -0
  205. package/src/theme.css +103 -23
  206. package/src/theme.test.ts +10 -2
  207. package/dist/chunk-2MXWEIMD.js.map +0 -1
  208. package/dist/chunk-6VYGK3Q3.js.map +0 -1
  209. package/dist/chunk-7CNDZZZ6.js +0 -95
  210. package/dist/chunk-7CNDZZZ6.js.map +0 -1
  211. package/dist/chunk-BE2LWUHY.js.map +0 -1
  212. package/dist/chunk-DT6LKNZF.js.map +0 -1
  213. package/dist/chunk-F342ZT7O.js.map +0 -1
  214. package/dist/chunk-SVKN5ZHX.js.map +0 -1
  215. package/dist/chunk-VD6PB3VA.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/code-block/gutters.ts","../../../src/components/code-block/notation.ts","../../../src/components/code-block/highlighter.ts","../../../src/components/code-block/code-block.tsx","../../../src/components/code-block/presets.ts","../../../src/components/code-block/index.ts"],"names":["jsx","C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EAAM,SAAA,EAAW,OAAA,EAAS,SAAS,OAAA,EAAQ;AACtD;AASO,SAAS,UACd,OAAA,EACmC;AACnC,EAAA,MAAM,EAAE,GAAA,GAAM,WAAA,EAAa,GAAG,KAAA,EAAM,GAAI,WAAW,EAAC;AACpD,EAAA,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE,UAAA,EAAY,QAAA,EAAU,GAAG,KAAA,EAAM,EAAE;AACrD;ACUO,IAAMC,aAAY,MAAA,CAAO,MAAA,CAAO,WAAe,EAAE,MAAA,EAAQ,iBAAiB","file":"index.js","sourcesContent":["import type { Color } from \"../../lib/colors\"\nimport type { ParsedLine, ParsedNotation } from \"./notation\"\n\n/** A hast `<span>` node in the exact shape Shiki's own `line()` transformer\n * hook expects as a child — kept structurally minimal (not importing\n * `hast`'s own `Element` type) for the same reason `highlighter.ts`\n * derives `LineHast` via `Parameters<...>` rather than a direct import.\n * `children` allows a nested span (not just text) for the same reason\n * `applyStyle` (highlighter.ts) sometimes wraps a line's children in an\n * inner span — see `applyMarkerColor` below. */\nexport type GutterSpanHast = {\n type: \"element\"\n tagName: \"span\"\n properties: Record<string, string>\n children: Array<{ type: \"text\"; value: string } | GutterSpanHast>\n}\n\ntype CodeBlockGutterColumnBase = {\n /** CSS length reserved for this column, applied as `min-width` (not\n * `width`) — content can still grow past it rather than clipping.\n * @default for a counter column, sized to fit the largest number that\n * will actually appear anywhere in the document (e.g. 2.5ch once any\n * rendered value reaches 2 digits) — computed once, up front, and\n * applied uniformly to every line so a 1-digit line's number stays\n * right-aligned with a 2-digit one instead of shifting the code that\n * follows it. @default \"3ch\" for a content column. */\n width?: string\n /** @default \"right\" for a counter column, \"center\" for a content column */\n align?: \"left\" | \"center\" | \"right\"\n /** Escape hatch: extra class applied to every span this column renders. */\n className?: string\n /** Override the kind-based default (a counter is `aria-hidden` by\n * default — reading \"1, 2, 3...\" aloud per line is noise, redundant\n * with visual position; a content column is left in the accessible\n * tree by default, since its text is meaningful). */\n ariaHidden?: boolean\n}\n\nexport type CodeBlockCounterGutterColumn = CodeBlockGutterColumnBase & {\n kind: \"counter\"\n /** @default 1 */\n startAt?: number\n /** Tags that make this column skip (not advance, render blank) on that\n * line — this is the whole mechanism behind diverging diff old/new\n * numbering: an \"old\" column's `skip: [\"removed\"]` is wrong (it should\n * advance on removed/context, skip added) — see the worked diff example\n * in the docs. A line that's fully removed via notation (see\n * `ParsedLine.blank`) never advances any counter, since it never\n * renders at all. */\n skip?: string[]\n}\n\n/** A content column's per-tag mapping, in its full form — `color` tints the\n * marker's own TEXT, `background` its own fill, exactly the same split\n * every other styling surface in the kit uses (never conflated into one\n * \"colors\" concept). Independent of whatever color/background (if any)\n * the matched tag's own `tags` styling gives the *line* — a marker's\n * identity color (e.g. a diff's \"−\" always red, \"+\" always green) is a\n * different concern than the line's tint, and often wants to stay\n * legible even when the line itself only sets a translucent\n * `background`, no `color`. */\ntype CodeBlockGutterMarker = {\n /** `true` renders the notation marker's own payload verbatim (blame's\n * name, coverage's status, a tutorial-step number); a literal string\n * renders that fixed text regardless of payload (a diff's static\n * \"+\"/\"−\"). */\n text: string | true\n color?: Color\n background?: Color\n}\n\nexport type CodeBlockContentGutterColumn = CodeBlockGutterColumnBase & {\n kind: \"content\"\n /** Maps a notation tag to what this column renders when that tag matches\n * the line — either the shorthand (`true` for the payload verbatim, or a\n * literal string), or the full `{ text, color?, background? }` form when\n * the marker also needs its own color independent of the line's. The\n * first matching tag (in written order) wins. No match on a line → an\n * empty (but still width-reserving) cell. */\n tags: Record<string, string | true | CodeBlockGutterMarker>\n}\n\nexport type CodeBlockGutterColumn = CodeBlockCounterGutterColumn | CodeBlockContentGutterColumn\n\ntype CounterState = { value: number }\n\nfunction countNonSkipped(lines: ParsedLine[], skip: Set<string>): number {\n let n = 0\n for (const l of lines) {\n if (l.blank) continue\n if (!l.matches.some((m) => skip.has(m.tag))) n++\n }\n return n\n}\n\n/** The widest value a counter column will ever display, computed once from\n * the FULL document's notation (never just the local render window) —\n * this is what keeps the head and tail halves of a collapsed split\n * agreeing on the same gutter width too, with no extra plumbing, since\n * both already share this one `notation` (see `code-block.tsx`). Reserves\n * `<digit count> + 0.5`ch, floored at the pre-existing 1.5ch minimum, so a\n * single-digit-only document renders identically to before this fix. */\nfunction defaultCounterWidth(\n column: CodeBlockCounterGutterColumn,\n notation: ParsedNotation,\n): string {\n const startAt = column.startAt ?? 1\n const total = countNonSkipped(notation.perLine, new Set(column.skip ?? []))\n const maxValue = startAt + Math.max(total - 1, 0)\n const digits = String(maxValue).length\n return `${Math.max(digits + 0.5, 1.5)}ch`\n}\n\n/** Appends a class name via plain string concatenation — deliberately NOT\n * `cn()` (tailwind-merge): `decoration-bg`/`decoration-text` are our own\n * bespoke classes, but tailwind-merge pattern-matches the shared\n * `decoration-` prefix as Tailwind's real `text-decoration-color` utility\n * group and treats them as conflicting, silently dropping whichever was\n * added first (verified: `cn(\"decoration-bg\",\"decoration-text\")` →\n * `\"decoration-text\"` only). This is exactly why `applyStyle`\n * (highlighter.ts) uses Shiki's own dumb-append `addClassToHast` for the\n * same two classes instead of `cn()` — this mirrors that here, since a\n * freshly-built `GutterSpanHast` isn't yet part of a Shiki tree and has no\n * `addClassToHast` context available. */\nfunction appendClass(span: GutterSpanHast, extra: string): void {\n const existing = span.properties[\"class\"]\n span.properties[\"class\"] = existing ? `${existing} ${extra}` : extra\n}\n\n/**\n * Applies a marker's own `color`/`background` to its freshly-built span —\n * the exact same two-node `data-color` pattern `applyStyle` (highlighter.ts)\n * uses for a line, just constructing fresh nodes instead of mutating an\n * existing hast tree (so it can't share that function directly, and isn't\n * worth a shared abstraction for this little logic). `color` tints only the\n * marker's own text, `background` only its own fill — never conflated.\n */\nfunction applyMarkerColor(\n span: GutterSpanHast,\n color: Color | undefined,\n background: Color | undefined,\n): void {\n if (background !== undefined && color !== undefined && background !== color) {\n span.properties[\"data-color\"] = background\n appendClass(span, \"decoration-bg\")\n span.children = [\n {\n type: \"element\",\n tagName: \"span\",\n properties: { \"data-color\": color, class: \"decoration-text\" },\n children: span.children,\n },\n ]\n } else if (background !== undefined || color !== undefined) {\n const value = background ?? color\n if (value !== undefined) span.properties[\"data-color\"] = value\n if (background !== undefined) appendClass(span, \"decoration-bg\")\n if (color !== undefined) appendClass(span, \"decoration-text\")\n }\n}\n\nfunction renderColumn(\n column: CodeBlockGutterColumn,\n matches: NotationMatchLike[],\n counter: CounterState | undefined,\n defaultWidth: string,\n): GutterSpanHast {\n const isCounter = column.kind === \"counter\"\n const width = column.width ?? defaultWidth\n const align = column.align ?? (isCounter ? \"right\" : \"center\")\n const ariaHidden = column.ariaHidden ?? isCounter\n\n let text = \"\"\n let color: Color | undefined\n let background: Color | undefined\n if (isCounter && counter) {\n const skip = column.skip\n const skipped = skip != null && matches.some((m) => skip.includes(m.tag))\n if (!skipped) {\n text = String(counter.value)\n counter.value += 1\n }\n } else if (!isCounter) {\n const match = matches.find((m) => m.tag in column.tags)\n if (match) {\n const mapped = column.tags[match.tag]\n if (mapped !== null && typeof mapped === \"object\") {\n text = mapped.text === true ? (match.payload ?? \"\") : mapped.text\n color = mapped.color\n background = mapped.background\n } else {\n text = mapped === true ? (match.payload ?? \"\") : (mapped ?? \"\")\n }\n }\n }\n\n // Plain join, not `cn()` — same reasoning as `appendClass` above; none of\n // these are real Tailwind utilities that need conflict resolution, and\n // running them through tailwind-merge risks the same false-positive drop.\n const baseClasses = [\"gutter-column\", isCounter ? \"gutter-counter\" : \"gutter-content\"]\n if (column.className) baseClasses.push(column.className)\n\n const span: GutterSpanHast = {\n type: \"element\",\n tagName: \"span\",\n properties: {\n class: baseClasses.join(\" \"),\n style: `min-width:${width};text-align:${align}`,\n ...(ariaHidden ? { \"aria-hidden\": \"true\" } : {}),\n },\n children: text ? [{ type: \"text\", value: text }] : [],\n }\n if (text) applyMarkerColor(span, color, background)\n return span\n}\n\ntype NotationMatchLike = { tag: string; payload?: string }\n\n/** Resolves a `gutters` configuration against a full-source notation parse\n * into a stateful `render` closure — one call per rendered line, in\n * increasing line order, matching how Shiki's `line()` transformer hook\n * actually fires. Counter columns carry running state across those calls;\n * `headLineOffset` (the transformer's own `lineOffset`, 0 for the head\n * half of a collapsed split, `collapsedLines` for the tail half) seeds\n * each counter's starting value from how many non-skipped, non-blank\n * lines came before this rendering window in the FULL source — this is\n * what keeps a `skip`-aware counter's numbering continuous across that\n * split with no new architecture: both halves independently derive the\n * correct starting count from the same shared, already-parsed `notation`\n * (see `code-block.tsx`). */\nexport function resolveGutterColumns(\n gutters: CodeBlockGutterColumn[],\n notation: ParsedNotation,\n headLineOffset: number,\n) {\n const resolved = gutters.map((column) => {\n if (column.kind === \"counter\") {\n const seed =\n (column.startAt ?? 1) +\n countNonSkipped(notation.perLine.slice(0, headLineOffset), new Set(column.skip ?? []))\n return {\n column,\n counter: { value: seed } as CounterState | undefined,\n defaultWidth: defaultCounterWidth(column, notation),\n }\n }\n return { column, counter: undefined as CounterState | undefined, defaultWidth: \"3ch\" }\n })\n\n return {\n /** A blank (fully-removed) line never advances any counter, since it\n * never renders at all — callers should not invoke this for a line\n * whose `ParsedLine.blank` is true. */\n render(parsed: ParsedLine | undefined): GutterSpanHast[] {\n if (resolved.length === 0) return []\n const matches = parsed?.matches ?? []\n return resolved.map((r) => renderColumn(r.column, matches, r.counter, r.defaultWidth))\n },\n }\n}\n","/**\n * Comment-notation parser for `CodeBlock` — the ONLY per-line targeting\n * mechanism in the new design (replaces the old hand-counted `{ line }` /\n * { from, to }` index-based `decorations`). A line opts into styling/gutter\n * content by carrying a marker comment, e.g. `// [!code removed]` or\n * `// [!code blame:alice]`, anywhere a trailing comment is recognized —\n * modeled on Shiki's own `[!code xxx]` convention, but built from scratch\n * here rather than depending on `@shikijs/transformers`: its generic\n * `transformerNotationMap` only supports a fixed keyword enum (no arbitrary\n * `tag:payload` capture), and the lower-level engine that *would* support\n * that (`createCommentNotationTransformer`) is an internal, non-exported\n * module in that package — not something to depend on.\n *\n * Pure string → data. No Shiki/hast import at all, so it's callable once\n * per `CodeBlock` render (over the FULL, unsplit `code` prop) and shared\n * across both halves of the collapse/expand head-tail split — see\n * `code-block.tsx` and the `notation` option in `highlighter.ts`.\n *\n * ## Grammar\n *\n * `[!code <tag>]` or `[!code <tag>:<payload>]`. `<tag>` is any consumer-\n * defined identifier (`[A-Za-z][\\w-]*`) — CodeBlock itself has no built-in\n * vocabulary (\"diff\"/\"highlight\"/\"blame\" are just tag names someone chose).\n * `<payload>` is free-form text; `\\:` and `\\]` escape a literal colon or\n * bracket inside it. Multiple distinct markers may stack on one line\n * (`// [!code blame:alice] [!code coverage:miss]`) — a deliberate\n * generalization the fixed-enum Shiki transformers can't express, since\n * each of those is a single-keyword regex, not a general engine.\n *\n * There is deliberately NO range/count-suffix shorthand (Shiki's own\n * `[!code highlight:3]` \"applies to the next 3 lines\"). That shorthand\n * reintroduces exactly the counting problem this mechanism exists to\n * remove — you'd have to count how many lines a block spans to write `:5`.\n * Every marker applies only to the single line it's written on; a multi-\n * line diff removal is the same marker repeated on every affected line,\n * trivial when machine-generated (see `diff.ts`) and no worse by hand\n * either, since the marker sits right next to the line it describes.\n *\n * ## Comment styles recognized\n *\n * A marker is only honored inside a RECOGNIZED trailing comment, checked\n * per physical line (never across lines):\n * - `<!-- ... -->` and `/* ... *\\/` — block-style, single line only, and\n * ONLY as the comment's entire content (see \"Known limitation\" below).\n * - `{/* ... *\\/}` — a JSX/TSX expression-container comment, matched only\n * when it's the sole content of its own line (leading/trailing\n * whitespace aside).\n * - A line-style opener — `//`, `#`, `;`/`;;`, `%`/`%%`, or `--` — found\n * as the RIGHTMOST such token on the line (so `// TODO: fix // [!code\n * todo]` finds the second `//`, treating it as its own trailing\n * comment, leaving the first comment's prose untouched).\n * - A `*`-continuation line inside a `/** ... *\\/` block (a line that,\n * once left-trimmed, starts with `*` not immediately followed by `/`)\n * — so a marker on the 2nd+ line of a JSDoc-style comment is found too.\n *\n * Detection is purely textual against the raw source line, independent of\n * which language grammar Shiki tokenizes it with — this is what lets a\n * `//`-style marker (what `diff.ts` always emits) work correctly even for\n * a language whose grammar wouldn't itself treat `//` as a comment (e.g. a\n * diff of a CSS or Python sample): the *removal* (see `highlighter.ts`'s\n * `trimTrailingChars`) trims a character count off the end of the rendered\n * line, not a token, so it doesn't need the grammar's cooperation.\n *\n * ## What gets removed, and the \"trailing only\" constraint\n *\n * A marker is only recognized as notation if it — plus, for a line-style\n * opener, only whitespace, or for a block/JSX style, only whitespace and\n * the closing delimiter — runs to the true end of the line. This keeps\n * removal a clean SUFFIX trim (`stripCount` characters off the end of the\n * rendered line), which is what makes the hast-mutation side in\n * `highlighter.ts` a simple, robust operation instead of a fragile interior\n * edit. Two concrete behaviors this produces:\n * - `sum += x; // [!code highlight]` → not blank; only the marker (and\n * the now-empty `// `) is stripped, the code before it is untouched.\n * - `// [!code highlight]` alone on a line → the WHOLE line is blank and\n * is removed entirely (see `blank`), not left behind as an empty line.\n *\n * A marker with real prose BEFORE it in the same comment is supported for\n * line-style openers and the `*`-continuation form (`// keep this [!code\n * highlight]` → strips only the marker, keeping `// keep this`), since\n * those have no closing delimiter to preserve. Block/HTML/JSX comments do\n * NOT support this — the marker must be their entire content — because\n * removing an interior marker while preserving a `*\\/`/`-->`/`}` closer\n * isn't a suffix trim. A marker mixed with prose inside `/* *\\/`/`<!-- -->`/\n * `{/* *\\/}` is simply not recognized as notation and renders as literal\n * text; use a line-style trailing comment instead when prose needs to sit\n * alongside a marker.\n *\n * ## Known limitation\n *\n * The line-style opener scan picks the RIGHTMOST occurrence of `//`/`#`/\n * `;`/`;;`/`%`/`%%`/`--` that sits outside every marker's own matched span\n * (so a payload containing one of those substrings, e.g. `[!code\n * note:see--also]`, can't itself be mistaken for an opener) — but it does\n * not otherwise understand string literals or real comment grammar. A\n * comment-opener-like substring inside an unrelated string literal, at the\n * very end of a line with nothing after it, could in principle be\n * misdetected. This is a deliberate, documented tradeoff (a purely textual\n * heuristic, not a full per-language parser) rather than a bug to chase —\n * acceptable for hand-authored/machine-generated notation, which is what\n * this mechanism is for.\n */\n\nexport type NotationMatch = { tag: string; payload?: string }\n\nexport type ParsedLine = {\n /** Every marker matched on this line, in written order. */\n matches: NotationMatch[]\n /** Characters to trim off the END of this line's rendered text to\n * produce the marker-free version. 0 when the line has no marker, or\n * when `blank` is true (the whole line is removed instead). */\n stripCount: number\n /** True when the line becomes fully empty after removing its marker(s)\n * AND had at least one match — i.e. it should be spliced out of the\n * render entirely, not left behind as a blank line. A line that was\n * already blank in the source (no marker at all) is never flagged. */\n blank: boolean\n}\n\n/** Index 0 = source line 1. */\nexport type ParsedNotation = { perLine: ParsedLine[] }\n\nconst MARKER_SOURCE = String.raw`\\[!code\\s+([A-Za-z][\\w-]*)(?::((?:\\\\.|[^:\\]])*))?\\s*\\]`\nconst MARKER_RE = new RegExp(MARKER_SOURCE, \"g\")\nconst TRAILING_MARKERS_RE = new RegExp(`(?:${MARKER_SOURCE}\\\\s*)+$`)\nconst LINE_OPENER_RE = /\\/\\/|#|;{1,2}|%{1,2}|--/g\nconst UNESCAPE_RE = /\\\\(.)/g\n\nconst NO_MATCH: ParsedLine = { matches: [], stripCount: 0, blank: false }\n\nfunction unescapePayload(payload: string): string {\n return payload.replace(UNESCAPE_RE, \"$1\")\n}\n\nfunction collectMarkers(text: string): NotationMatch[] {\n return [...text.matchAll(MARKER_RE)].map((m) => ({\n tag: m[1] as string,\n payload: m[2] !== undefined ? unescapePayload(m[2]) : undefined,\n }))\n}\n\n/** Moves `index` left past any run of plain spaces/tabs immediately before\n * it, so a strip boundary doesn't leave a dangling trailing space. */\nfunction backOverWhitespace(line: string, index: number): number {\n let i = index\n while (i > 0 && (line[i - 1] === \" \" || line[i - 1] === \"\\t\")) i--\n return i\n}\n\nfunction toParsedLine(matches: NotationMatch[], line: string, removableFrom: number): ParsedLine {\n const start = backOverWhitespace(line, removableFrom)\n return { matches, stripCount: line.length - start, blank: line.slice(0, start).trim() === \"\" }\n}\n\n/** Block-style comment (`<!-- -->`, `/* *\\/`, or the JSX `{/* *\\/}` form) —\n * only matched when its entire content, once every marker is removed, is\n * blank (see the \"Known limitation\"/prose doc comment above the file). */\nfunction matchBlock(line: string, open: string, close: string): ParsedLine | null {\n const closeIdx = line.lastIndexOf(close)\n if (closeIdx === -1) return null\n if (line.slice(closeIdx + close.length).trim() !== \"\") return null\n const openIdx = line.lastIndexOf(open, closeIdx)\n if (openIdx === -1) return null\n const body = line.slice(openIdx + open.length, closeIdx)\n MARKER_RE.lastIndex = 0\n if (!MARKER_RE.test(body)) return null\n MARKER_RE.lastIndex = 0\n const remaining = body.replace(MARKER_RE, \"\").trim()\n if (remaining !== \"\") return null\n return toParsedLine(collectMarkers(body), line, openIdx)\n}\n\n/** A `//`/`#`/`;`/`;;`/`%`/`%%`/`--` trailing comment — the rightmost such\n * opener outside any marker's own span, so a marker's payload can safely\n * contain one of those substrings without being mistaken for an opener. */\nfunction matchLineStyle(line: string): ParsedLine | null {\n MARKER_RE.lastIndex = 0\n const markerSpans = [...line.matchAll(MARKER_RE)].map(\n (m) => [m.index, m.index + m[0].length] as const,\n )\n const insideAMarker = (i: number) => markerSpans.some(([s, e]) => i >= s && i < e)\n\n let openIdx = -1\n let openLen = 0\n for (const m of line.matchAll(LINE_OPENER_RE)) {\n if (insideAMarker(m.index)) continue\n openIdx = m.index\n openLen = m[0].length\n }\n if (openIdx === -1) return null\n\n const body = line.slice(openIdx + openLen)\n const trailing = body.match(TRAILING_MARKERS_RE)\n if (!trailing || trailing.index === undefined) return null\n\n const matches = collectMarkers(trailing[0])\n const prose = body.slice(0, trailing.index).trim()\n const removableFrom = prose === \"\" ? openIdx : openIdx + openLen + trailing.index\n return toParsedLine(matches, line, removableFrom)\n}\n\n/** The 2nd+ line of a `/** ... *\\/` block, e.g. ` * [!code highlight]`. */\nfunction matchContinuation(line: string): ParsedLine | null {\n const m = line.match(/^(\\s*)\\*(?!\\/)([\\s\\S]*)$/)\n if (!m) return null\n const [, indent, body] = m as [string, string, string]\n const trailing = body.match(TRAILING_MARKERS_RE)\n if (!trailing || trailing.index === undefined) return null\n\n const matches = collectMarkers(trailing[0])\n const prose = body.slice(0, trailing.index).trim()\n const removableFrom = prose === \"\" ? indent.length : indent.length + 1 + trailing.index\n return toParsedLine(matches, line, removableFrom)\n}\n\nfunction parseLine(line: string): ParsedLine {\n const jsx = matchBlock(line, \"{/*\", \"*/}\")\n if (jsx) return jsx\n const html = matchBlock(line, \"<!--\", \"-->\")\n if (html) return html\n const block = matchBlock(line, \"/*\", \"*/\")\n if (block) return block\n const lineStyle = matchLineStyle(line)\n if (lineStyle) return lineStyle\n const continuation = matchContinuation(line)\n if (continuation) return continuation\n return NO_MATCH\n}\n\n/** Parses every notation marker in `code`, once, line by line. With\n * `enabled: false` every line is a non-match — the markers stay in the\n * rendered source verbatim (a snippet that *documents* the notation), while\n * `perLine` keeps one entry per line so gutter counters still size right. */\nexport function parseNotation(code: string, enabled = true): ParsedNotation {\n return { perLine: code.split(\"\\n\").map((line) => (enabled ? parseLine(line) : NO_MATCH)) }\n}\n","import type {\n Highlighter,\n LanguageInput,\n ShikiTransformer,\n ShikiTransformerContext,\n ThemeInput,\n} from \"shiki\"\nimport type { Color } from \"../../lib/colors\"\nimport { type CodeBlockGutterColumn, resolveGutterColumns } from \"./gutters\"\nimport { type ParsedNotation, parseNotation } from \"./notation\"\n\n/** Structurally the same `Element` (hast) type `ShikiTransformer`'s own\n * `line`/`span` hooks receive — derived via `Parameters` rather than a\n * direct `import type { Element } from \"hast\"`, since `hast`'s types are\n * only reachable through `@shikijs/core`'s own dependency graph, not\n * necessarily resolvable as a bare specifier from this package. */\ntype LineHast = Parameters<NonNullable<ShikiTransformer[\"line\"]>>[0]\ntype HastNode = LineHast[\"children\"][number]\n\n/**\n * Module-level singleton — created lazily on first use, shared by every\n * `CodeBlock` on the page (a docs page can render dozens).\n */\nconst DEFAULT_THEMES = { light: \"github-light\", dark: \"github-dark-default\" } as const\n\nlet highlighterPromise: Promise<Highlighter> | null = null\n\nfunction getHighlighter(): Promise<Highlighter> {\n if (!highlighterPromise) {\n highlighterPromise = import(\"shiki\").then(({ createHighlighter }) =>\n createHighlighter({ themes: [DEFAULT_THEMES.light, DEFAULT_THEMES.dark], langs: [] }),\n )\n }\n return highlighterPromise\n}\n\n/**\n * Register a custom TextMate grammar so `<CodeBlock language=\"...\">` can\n * reference it by name, the same as a bundled language — Shiki's own\n * extension mechanism for a language it doesn't ship. Await this once\n * (e.g. at app startup) before rendering a `CodeBlock` that uses it.\n */\nexport async function registerLanguage(lang: LanguageInput): Promise<void> {\n const highlighter = await getHighlighter()\n await highlighter.loadLanguage(lang)\n}\n\n/** Register a custom VS Code-style theme, the same as a bundled theme —\n * Shiki's own extension mechanism for a theme it doesn't ship. */\nexport async function registerTheme(theme: ThemeInput): Promise<void> {\n const highlighter = await getHighlighter()\n await highlighter.loadTheme(theme)\n}\n\n/** Palette-driven styling — `background`/`color` tint via the kit's own\n * theme-aware `Color` tokens (the same `--c-soft`/`--c-text` mechanism\n * every colored component uses), independent of each other, the same\n * relationship `Mark`'s own `background`/`color` props have. `className`/\n * `style` stay as the escape hatch for anything the two color props don't\n * cover (layout, a specific shade, an arbitrary Tailwind utility) — prefer\n * `background`/`color` first; reach for `className`/`style` only for what\n * they can't express. */\ntype CodeBlockStyle = {\n /** Text color, via the same `Color` tokens as the rest of the kit. */\n color?: Color\n /** Background/highlight tint, via the same `Color` tokens as the rest of the kit. */\n background?: Color\n /** Escape hatch: an arbitrary class, for anything `color`/`background` don't cover. */\n className?: string\n /** Escape hatch: raw CSS text (e.g. `\"text-decoration: line-through\"`), not\n * a React `CSSProperties` object — styles are threaded through Shiki's\n * hast → HTML string pipeline, never React's own DOM `style` prop. */\n style?: string\n}\n\n/** Styling for a notation tag — a line carrying `// [!code removed]` looks\n * up `tags.removed`. `CodeBlock` has no built-in tag vocabulary of its\n * own: \"removed\", \"highlight\", \"blame\", etc. are just names a consumer\n * chose — see `notation.ts` for the full grammar. */\nexport type CodeBlockTagStyle = CodeBlockStyle\n\nexport type HighlightOptions = {\n lang?: string\n themes?: { light: string; dark: string }\n /** Notation-tag → styling lookup — see `CodeBlockTagStyle`. */\n tags?: Record<string, CodeBlockTagStyle>\n /** Stacked, ordered gutter columns rendered left of the code — see\n * `CodeBlockGutterColumn` (`gutters.ts`). */\n gutters?: CodeBlockGutterColumn[]\n /** Offset added to every rendered line number before matching notation/\n * seeding gutter counters — used by `CodeBlock`'s collapse split so a\n * highlighted \"tail\" half still reports its true position in the\n * original source. */\n lineOffset?: number\n /** A precomputed `parseNotation` of the FULL, un-split source. Passed by\n * `CodeBlock` so the collapsed head/tail split's two independent\n * `highlightCode` calls share one notation pass — this is what keeps a\n * `skip`-aware gutter counter's numbering continuous across that split.\n * Omitted (e.g. a consumer calling `highlightCode` directly) → computed\n * from this call's own `code`. */\n notation?: ParsedNotation\n /** Extra Shiki transformers (e.g. from the `@shikijs/transformers`\n * ecosystem, or your own), run after the internal notation transformer.\n * This is the escape hatch for extending Shiki's own capabilities —\n * anything a `ShikiTransformer` can do (custom notation, extra markup,\n * post-processing) works here without `CodeBlock` needing to know about\n * it. See also `registerLanguage`/`registerTheme` for extending the\n * language/theme side of the parser. */\n transformers?: ShikiTransformer[]\n}\n\nfunction appendStyle(hast: LineHast, style: string) {\n const existing = hast.properties[\"style\"]\n hast.properties[\"style\"] =\n typeof existing === \"string\" && existing.length > 0 ? `${existing};${style}` : style\n}\n\n/**\n * Applies one tag's styling to its matched line hast node. `className`/\n * `style` land directly on that node, verbatim — the escape hatch, no\n * interpretation. `background`/`color` route through the same `data-color`\n * + `--c-soft`/`--c-text` mechanism every colored component in the kit uses\n * (theme-aware, unlike a hardcoded shade) — `.shiki .decoration-bg`/\n * `.decoration-text` (styles.css) reference those vars at a specificity\n * that beats the ambient `.shiki span` token-color rule.\n *\n * `background`/`color` set to *different* colors need two independently-\n * scoped `data-color` attributes — the same constraint `Mark` has, for the\n * same reason (one attribute, one color's worth of both vars). Since the\n * target here is a hast node we already own (not JSX), the fix is the same\n * shape as `Mark`'s: wrap the existing children in an inner span that\n * scopes its own `data-color` for text, leaving the outer node's\n * `data-color` scoping the background. When they match (or only one is\n * given), a single `data-color` on the node itself is enough.\n */\nfunction applyStyle(\n hast: LineHast,\n s: CodeBlockStyle,\n addClassToHast: ShikiTransformerContext[\"addClassToHast\"],\n) {\n if (s.className) addClassToHast(hast, s.className)\n if (s.style) appendStyle(hast, s.style)\n\n const { background, color } = s\n if (background !== undefined && color !== undefined && background !== color) {\n hast.properties[\"data-color\"] = background\n addClassToHast(hast, \"decoration-bg\")\n hast.children = [\n {\n type: \"element\",\n tagName: \"span\",\n properties: { \"data-color\": color, class: \"decoration-text\" },\n children: hast.children,\n },\n ]\n } else if (background !== undefined || color !== undefined) {\n hast.properties[\"data-color\"] = background ?? color\n if (background !== undefined) addClassToHast(hast, \"decoration-bg\")\n if (color !== undefined) addClassToHast(hast, \"decoration-text\")\n }\n}\n\nfunction isEmptyNode(node: HastNode): boolean {\n if (node.type === \"text\") return node.value.length === 0\n if (node.type === \"element\") return node.children.length === 0\n return false\n}\n\nfunction trimNode(node: HastNode, remaining: number): number {\n if (node.type === \"text\") {\n const take = Math.min(remaining, node.value.length)\n node.value = node.value.slice(0, node.value.length - take)\n return remaining - take\n }\n if (node.type === \"element\") {\n let left = remaining\n while (left > 0 && node.children.length > 0) {\n const child = node.children[node.children.length - 1] as HastNode\n left = trimNode(child, left)\n if (isEmptyNode(child)) node.children.pop()\n else break\n }\n return left\n }\n return remaining\n}\n\n/** Trims `count` characters off the END of a line's rendered text, walking\n * its (possibly nested, per-token) hast children from the last one\n * backward — the mechanical half of notation removal; the regex work\n * already happened once in `notation.ts`, this just applies its\n * precomputed `stripCount` to the already-tokenized hast. */\nfunction trimTrailingChars(hast: LineHast, count: number) {\n let remaining = count\n while (remaining > 0 && hast.children.length > 0) {\n const last = hast.children[hast.children.length - 1] as HastNode\n remaining = trimNode(last, remaining)\n if (isEmptyNode(last)) hast.children.pop()\n else break\n }\n}\n\n/**\n * Builds the one internal Shiki transformer from a `HighlightOptions`\n * config. Deliberately generic: it has no notion of \"highlight\" or \"diff\"\n * — it only applies whatever `className`/`style`/`background`/`color` a\n * `tags` entry supplies, and whatever content a `gutters` column resolves\n * to, straight onto the matching line hast node(s), driven entirely by the\n * consumer-chosen notation tags found on each line. Built fresh per\n * `highlightCode` call (options differ per instance) — not part of the\n * shared singleton above.\n */\nfunction buildCodeBlockTransformer(\n opts: HighlightOptions,\n notation: ParsedNotation,\n): ShikiTransformer {\n const offset = opts.lineOffset ?? 0\n const gutters = resolveGutterColumns(opts.gutters ?? [], notation, offset)\n const toRemove = new Set<LineHast>()\n\n return {\n name: \"42-ui-code-block\",\n line(hast, renderedLine) {\n const line = renderedLine + offset\n const parsed = notation.perLine[line - 1]\n\n if (parsed?.blank) {\n toRemove.add(hast)\n return hast\n }\n\n if (parsed && parsed.stripCount > 0) trimTrailingChars(hast, parsed.stripCount)\n\n for (const m of parsed?.matches ?? []) {\n const style = opts.tags?.[m.tag]\n if (style) applyStyle(hast, style, this.addClassToHast)\n }\n\n const gutterSpans = gutters.render(parsed)\n if (gutterSpans.length > 0) hast.children.unshift(...gutterSpans)\n\n return hast\n },\n code(hast) {\n if (toRemove.size === 0) return hast\n hast.children = hast.children.filter((child, i, arr) => {\n if (child.type === \"element\" && toRemove.has(child as LineHast)) return false\n if (child.type === \"text\" && child.value === \"\\n\") {\n const neighbor = arr[i - 1] ?? arr[i + 1]\n if (neighbor?.type === \"element\" && toRemove.has(neighbor as LineHast)) return false\n }\n return true\n })\n return hast\n },\n }\n}\n\n/** Highlights `code` as HTML via the shared Shiki singleton. Loads the\n * requested language/themes on demand — via the highlighter's own\n * `getLoadedLanguages`/`getLoadedThemes` (authoritative, so a name\n * registered through `registerLanguage`/`registerTheme` is recognized as\n * already loaded and never re-fetched as if it were a bundled id). `lang`\n * defaults to `\"text\"` (Shiki's built-in plaintext grammar — no dynamic\n * import needed). Called with `defaultColor: false` so neither theme is\n * inlined as a plain `color`/`background-color` — both live only in the\n * `--shiki-light`/`--shiki-dark` custom properties consumed by\n * `styles.css`, so the dark-mode CSS rule there needs no `!important`. */\nexport async function highlightCode(code: string, opts: HighlightOptions = {}): Promise<string> {\n const lang = opts.lang ?? \"text\"\n const themes = opts.themes ?? DEFAULT_THEMES\n const highlighter = await getHighlighter()\n const notation = opts.notation ?? parseNotation(code)\n\n await Promise.all(\n [themes.light, themes.dark]\n .filter((t) => !highlighter.getLoadedThemes().includes(t))\n .map((t) => highlighter.loadTheme(t as never)),\n )\n if (!highlighter.getLoadedLanguages().includes(lang)) {\n await highlighter.loadLanguage(lang as never)\n }\n\n return highlighter.codeToHtml(code, {\n lang,\n themes,\n defaultColor: false,\n transformers: [buildCodeBlockTransformer(opts, notation), ...(opts.transformers ?? [])],\n })\n}\n","\"use client\"\n\nimport { type ReactNode, useEffect, useMemo, useState } from \"react\"\nimport type { ShikiTransformer } from \"shiki\"\nimport { cn } from \"../../lib/cn\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport {\n CodeBlockButton,\n CodeBlockChrome,\n type CodeBlockClassNames,\n type CodeBlockIcons,\n type CodeBlockTranslations,\n} from \"./chrome\"\nimport type { CodeBlockGutterColumn } from \"./gutters\"\nimport { type CodeBlockTagStyle, highlightCode } from \"./highlighter\"\nimport { type ParsedNotation, parseNotation } from \"./notation\"\n\nexport type {\n CodeBlockButtonProps,\n CodeBlockClassNames,\n CodeBlockIconSlot,\n CodeBlockIcons,\n CodeBlockTranslations,\n} from \"./chrome\"\nexport type {\n CodeBlockContentGutterColumn,\n CodeBlockCounterGutterColumn,\n CodeBlockGutterColumn,\n} from \"./gutters\"\nexport type { CodeBlockTagStyle } from \"./highlighter\"\n\n/**\n * CodeBlock — Shiki-powered syntax highlighting, spec'd off Mantine's\n * `CodeHighlight`: a copy button, collapse/expand for long snippets, and\n * replaceable toolbar icons (`icons`). `\"use client\"` — highlighting is inherently async\n * (Shiki's `codeToHtml`), so the component renders a plain, unhighlighted\n * `<pre><code>` fallback (same chrome, no layout shift) until it resolves.\n * Reactive to prop changes (re-highlights whenever `code`/`tags`/etc.\n * change) — use this for anything editable/dynamic (a live playground). For\n * static content known at render time (the common case — docs, MDX, a\n * fixed snippet), `CodeBlock.Static` is an async Server Component that\n * `await`s the same `highlightCode` during the server render instead,\n * shipping zero client JS for Shiki at all; the two share the exact same\n * `CodeBlockChrome` (chrome.tsx) for the toolbar/collapse UI.\n *\n * `tags`/`gutters` are a general notation-driven / gutter-column mechanism —\n * see `notation.ts` for the full `// [!code tag]` comment grammar and\n * `/docs/code-block` for worked examples. There's no baked-in \"highlight\"\n * or \"diff\" concept: a diff view, a spotlighted zone, blame, a redacted\n * token, etc. are all just tags/gutters the consumer authors themselves\n * (or generates — see `@42/ui-react/code-block/diff`). `lineNumbers()`/\n * `highlight()` (from `@42/ui-react/code-block`) are pre-built one-liner\n * arguments to `gutters`/`tags` for the two most common cases — not a\n * separate mechanism, and not a dedicated prop on `CodeBlock` itself.\n *\n * Ship `@42/ui-react/code-block/styles.css` alongside this component — it's\n * not part of the universal `colors.css`/`theme.css` chain, since only\n * consumers who render a `CodeBlock` need Shiki's token/gutter CSS.\n */\nexport type CodeBlockProps = WithTestId & {\n /** Source text to highlight. No `children` slot — content is Shiki-derived. */\n code: string\n /** Shiki-bundled language id (e.g. \"tsx\", \"bash\", \"json\"). Omit → plain \"text\" grammar, no async load. */\n language?: string\n /** Override the light/dark Shiki theme pair. @default { light: \"github-light\", dark: \"github-dark-default\" } */\n themes?: { light: string; dark: string }\n /** Notation-tag → styling lookup — a line carrying `// [!code removed]`\n * looks up `tags.removed`. See the component doc comment / `notation.ts`. */\n tags?: Record<string, CodeBlockTagStyle>\n /** Stacked, ordered gutter columns rendered left of the code — real DOM\n * nodes, never `::before` pseudo-elements. `lineNumbers()` (from\n * `@42/ui-react/code-block`) is the one-liner for a plain counter. */\n gutters?: CodeBlockGutterColumn[]\n /** Extra Shiki transformers (e.g. `@shikijs/transformers`, or your own),\n * run after the internal notation transformer — the escape hatch for\n * extending Shiki's own capabilities. See also `registerLanguage`/\n * `registerTheme` (exported from `@42/ui-react/code-block`) for\n * registering a custom language/theme the bundled set doesn't ship. */\n transformers?: ShikiTransformer[]\n /** Parse `// [!code tag]` markers. `false` renders them verbatim instead —\n * for a snippet that teaches the notation itself. @default true */\n notation?: boolean\n\n /** Header row above the code (e.g. a filename). When set, the toolbar\n * moves into the header instead of floating over the code. */\n title?: ReactNode\n\n /** @default true */\n withCopyButton?: boolean\n onCopy?: () => void\n\n /** Lines always visible before the fade + expand seam. Omit → never collapses. */\n collapsedLines?: number\n /** @default false */\n defaultExpanded?: boolean\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n\n /** Replaces the toolbar's icons: `copy`, `copied`, `expand`, `collapse`. A missing key keeps\n * its default; `null` leaves that button empty. */\n icons?: CodeBlockIcons\n\n /** Extra control(s) in the same floating controls row, rendered before the\n * expand/copy buttons. Purely additive — build them with `CodeBlock.Button`\n * for the exact same size/style as the built-in ones. */\n controls?: ReactNode\n\n /** Button/label copy, factored into one object — same convention as `Calendar`/`DatePicker`'s `translations` prop: a flat `Partial<CodeBlockTranslations>`, merged over English defaults, no context/bundled locale packs. */\n translations?: Partial<CodeBlockTranslations>\n\n className?: string\n classNames?: CodeBlockClassNames\n}\n\ntype HighlightedPreProps = {\n code: string\n lang?: string\n themes?: { light: string; dark: string }\n tags?: Record<string, CodeBlockTagStyle>\n gutters?: CodeBlockGutterColumn[]\n /** Shared across both the head and tail halves of the collapse split —\n * see `CodeBlockComponent` and `HighlightOptions.notation`. */\n notation: ParsedNotation\n lineOffset?: number\n transformers?: ShikiTransformer[]\n className?: string\n}\n\nfunction HighlightedPre({\n code,\n lang,\n themes,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n className,\n}: HighlightedPreProps) {\n const [html, setHtml] = useState<string | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setHtml(null)\n highlightCode(code, {\n lang,\n themes,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n }).then((h) => {\n if (!cancelled) setHtml(h)\n })\n return () => {\n cancelled = true\n }\n // biome-ignore lint/correctness/useExhaustiveDependencies: themes is tracked via its light/dark fields, not the (often inline, reference-unstable) object itself\n }, [\n code,\n lang,\n themes?.light,\n themes?.dark,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n themes,\n ])\n\n if (html) {\n // No horizontal padding here — `.shiki .line` (styles.css) carries its\n // own `padding-inline` instead, so a decorated line's background hugs\n // this container's edges rather than stopping short of it.\n // `dir=\"ltr\"`: source code reads left-to-right on an RTL page too — the\n // chrome (title, toolbar) still follows the page direction.\n // biome-ignore lint/security/noDangerouslySetInnerHtml: trusted, deterministic Shiki output, not user input\n return <div dir=\"ltr\" className={className} dangerouslySetInnerHTML={{ __html: html }} />\n }\n return (\n // The plain fallback has no `.line` spans of its own to carry padding,\n // so it keeps the horizontal inset directly.\n <pre dir=\"ltr\" className={cn(className, \"px-4\")}>\n <code>{code}</code>\n </pre>\n )\n}\n\nfunction CodeBlockComponent({\n code,\n language,\n themes,\n tags,\n gutters,\n transformers,\n notation: notationEnabled = true,\n collapsedLines,\n className,\n classNames,\n ...chromeProps\n}: CodeBlockProps) {\n const lines = code.split(\"\\n\")\n const isCollapsible = collapsedLines != null && lines.length > collapsedLines\n const headCode = isCollapsible ? lines.slice(0, collapsedLines).join(\"\\n\") : code\n const tailCode = isCollapsible ? lines.slice(collapsedLines).join(\"\\n\") : \"\"\n // Parsed once over the FULL, unsplit `code` — never `headCode`/`tailCode`\n // individually — and shared by both `HighlightedPre` calls below. This is\n // what keeps a `skip`-aware gutter counter's numbering continuous across\n // the collapse split: each half independently derives its own starting\n // count from this one shared parse (see `gutters.ts`'s `resolveGutterColumns`).\n const notation = useMemo(() => parseNotation(code, notationEnabled), [code, notationEnabled])\n\n const preClassName = cn(\"overflow-x-auto py-3 text-sm leading-relaxed font-mono\", classNames?.pre)\n\n return (\n <CodeBlockChrome\n code={code}\n isCollapsible={isCollapsible}\n className={className}\n classNames={classNames}\n headContent={\n <HighlightedPre\n code={headCode}\n lang={language}\n themes={themes}\n tags={tags}\n gutters={gutters}\n notation={notation}\n transformers={transformers}\n className={preClassName}\n />\n }\n tailContent={\n isCollapsible && (\n <HighlightedPre\n code={tailCode}\n lang={language}\n themes={themes}\n tags={tags}\n gutters={gutters}\n notation={notation}\n lineOffset={collapsedLines}\n transformers={transformers}\n className={preClassName}\n />\n )\n }\n {...chromeProps}\n />\n )\n}\n\n/** `CodeBlock.Button` is `CodeBlockButton` itself (chrome.tsx) — attached\n * for discoverable composition when building a custom `controls` button\n * (`<CodeBlock.Button>`), mirroring `Code.Mark`'s same \"attach, don't\n * reimplement\" pattern. Still independently exported at\n * `@42/ui-react/code-block` for a bare import. `CodeBlock.Static` is\n * attached separately, from `index.ts` — see its own doc comment for why\n * (it's an async Server Component; not safe to import into this\n * `\"use client\"` file). */\nexport const CodeBlock = Object.assign(CodeBlockComponent, { Button: CodeBlockButton })\n","import type { CodeBlockCounterGutterColumn } from \"./gutters\"\nimport type { CodeBlockTagStyle } from \"./highlighter\"\n\n/**\n * Trivial one-liners for the two most common `gutters`/`tags` configurations\n * — `CodeBlock` itself has no dedicated boolean prop for \"line numbers\" or\n * \"highlight a line\" (there's exactly one mechanism, `gutters`/`tags`); these\n * are just pre-built arguments to it, not special component behavior.\n */\n\n/** A plain sequential line-number column: `<CodeBlock gutters={[lineNumbers()]} />`. */\nexport function lineNumbers(options?: { startAt?: number }): CodeBlockCounterGutterColumn {\n return { kind: \"counter\", startAt: options?.startAt }\n}\n\n/**\n * A ready-made `tags` entry for `// [!code highlight]` (or a custom tag\n * name): `<CodeBlock tags={highlight()} />`. Defaults to the same\n * background `Mark` uses for its own unstyled highlight, for visual\n * consistency with the rest of the kit. Compose with a hand-written `tags`\n * object the same way as any other record: `tags={{ ...highlight(), removed: {...} }}`.\n */\nexport function highlight(\n options?: ({ tag?: string } & CodeBlockTagStyle) | undefined,\n): Record<string, CodeBlockTagStyle> {\n const { tag = \"highlight\", ...style } = options ?? {}\n return { [tag]: { background: \"yellow\", ...style } }\n}\n","import {\n CodeBlockButton,\n type CodeBlockButtonProps,\n type CodeBlockClassNames,\n type CodeBlockIconSlot,\n type CodeBlockIcons,\n type CodeBlockTranslations,\n} from \"./chrome\"\nimport { CodeBlock as CodeBlockBase, type CodeBlockProps } from \"./code-block\"\nimport type {\n CodeBlockContentGutterColumn,\n CodeBlockCounterGutterColumn,\n CodeBlockGutterColumn,\n} from \"./gutters\"\nimport { type CodeBlockTagStyle, registerLanguage, registerTheme } from \"./highlighter\"\nimport { highlight, lineNumbers } from \"./presets\"\n// Extensionless, matching every other relative import in this package — the\n// compiled output needs a `.js` suffix here (Node ESM, \"type\": \"module\", is\n// strict about it on a relative import that survives unbundled — see\n// tsup.config.ts's `external` note), but writing it here would break this\n// monorepo's OWN dev-mode source resolution instead (apps/docs's tsconfig\n// aliases `@42/ui-react/*` straight to this package's `src/`, and Turbopack\n// resolving raw source doesn't do the \"`.js` maps to `.tsx`\" mapping tsup/tsc\n// do). tsup.config.ts's onSuccess step rewrites this specific import to add\n// the extension in the COMPILED dist output only, after the fact.\nimport { CodeBlockStatic, type CodeBlockStaticProps } from \"./static\"\n\n/**\n * `CodeBlock.Static` is attached here, not inside `code-block.tsx` itself\n * — see `CodeBlockStatic`'s own doc comment (`static.tsx`) for why: it's an\n * async Server Component, and `code-block.tsx` is `\"use client\"`, which\n * can't import an async component without breaking the Client/Server\n * boundary (a Client Component's render can never `await`). This file\n * carries no directive of its own, so it can safely compose the\n * `\"use client\"` `CodeBlock` and the Server-Component-only\n * `CodeBlockStatic` under the one object consumers import.\n */\nexport const CodeBlock = Object.assign(CodeBlockBase, { Static: CodeBlockStatic })\n\nexport {\n CodeBlockButton,\n type CodeBlockButtonProps,\n type CodeBlockClassNames,\n type CodeBlockContentGutterColumn,\n type CodeBlockCounterGutterColumn,\n type CodeBlockGutterColumn,\n type CodeBlockIconSlot,\n type CodeBlockIcons,\n type CodeBlockProps,\n type CodeBlockStaticProps,\n type CodeBlockTagStyle,\n type CodeBlockTranslations,\n highlight,\n lineNumbers,\n registerLanguage,\n registerTheme,\n}\n"]}
1
+ {"version":3,"sources":["../../../src/components/code-block/gutters.ts","../../../src/components/code-block/languages.ts","../../../src/components/code-block/notation.ts","../../../src/components/code-block/highlighter.ts","../../../src/components/code-block/code-block.tsx","../../../src/components/code-block/presets.ts","../../../src/components/code-block/index.ts"],"names":["jsx","CodeBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAS,eAAA,CAAgB,OAAqB,IAAA,EAA2B;AACvE,EAAA,IAAI,CAAA,GAAI,CAAA;AACR,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,IAAI,EAAE,KAAA,EAAO;AACb,IAAA,IAAI,CAAC,CAAA,CAAE,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,GAAG,CAAC,CAAA,EAAG,CAAA,EAAA;AAAA,EAC/C;AACA,EAAA,OAAO,CAAA;AACT;AASA,SAAS,mBAAA,CACP,QACA,QAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAU,OAAO,OAAA,IAAW,CAAA;AAClC,EAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,QAAA,CAAS,OAAA,EAAS,IAAI,IAAI,MAAA,CAAO,IAAA,IAAQ,EAAE,CAAC,CAAA;AAC1E,EAAA,MAAM,WAAW,OAAA,GAAU,IAAA,CAAK,GAAA,CAAI,KAAA,GAAQ,GAAG,CAAC,CAAA;AAChD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,QAAQ,CAAA,CAAE,MAAA;AAChC,EAAA,OAAO,GAAG,IAAA,CAAK,GAAA,CAAI,MAAA,GAAS,GAAA,EAAK,GAAG,CAAC,CAAA,EAAA,CAAA;AACvC;AAaA,SAAS,WAAA,CAAY,MAAsB,KAAA,EAAqB;AAC9D,EAAA,MAAM,QAAA,GAAW,IAAA,C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AAA;AAAA,MACA,aAAA;AAAA,MACA,SAAA;AAAA,MACA,UAAA;AAAA,MACA,WAAA,kBACE,GAAA;AAAA,QAAC,cAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAM,QAAA;AAAA,UACN,IAAA,EAAM,QAAA;AAAA,UACN,MAAA;AAAA,UACA,IAAA;AAAA,UACA,OAAA;AAAA,UACA,QAAA;AAAA,UACA,YAAA;AAAA,UACA,SAAA,EAAW;AAAA;AAAA,OACb;AAAA,MAEF,aACE,aAAA,oBACE,GAAA;AAAA,QAAC,cAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAM,QAAA;AAAA,UACN,IAAA,EAAM,QAAA;AAAA,UACN,MAAA;AAAA,UACA,IAAA;AAAA,UACA,OAAA;AAAA,UACA,QAAA;AAAA,UACA,UAAA,EAAY,cAAA;AAAA,UACZ,YAAA;AAAA,UACA,SAAA,EAAW;AAAA;AAAA,OACb;AAAA,MAGH,GAAG;AAAA;AAAA,GACN;AAEJ;AAUO,IAAM,YAAY,MAAA,CAAO,MAAA,CAAO,oBAAoB,EAAE,MAAA,EAAQ,iBAAiB,CAAA;;;AC9P/E,SAAS,YAAY,OAAA,EAA8D;AACxF,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAS,SAAS,OAAA,EAAQ;AACtD;AASO,SAAS,UACd,OAAA,EACmC;AACnC,EAAA,MAAM,EAAE,GAAA,GAAM,WAAA,EAAa,GAAG,KAAA,EAAM,GAAI,WAAW,EAAC;AACpD,EAAA,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE,UAAA,EAAY,QAAA,EAAU,GAAG,KAAA,EAAM,EAAE;AACrD;ACWO,IAAMC,aAAY,MAAA,CAAO,MAAA,CAAO,WAAe,EAAE,MAAA,EAAQ,iBAAiB","file":"index.js","sourcesContent":["import type { Color } from \"../../lib/colors\"\nimport type { ParsedLine, ParsedNotation } from \"./notation\"\n\n/** A hast `<span>` node in the exact shape Shiki's own `line()` transformer\n * hook expects as a child — kept structurally minimal (not importing\n * `hast`'s own `Element` type) for the same reason `highlighter.ts`\n * derives `LineHast` via `Parameters<...>` rather than a direct import.\n * `children` allows a nested span (not just text) for the same reason\n * `applyStyle` (highlighter.ts) sometimes wraps a line's children in an\n * inner span — see `applyMarkerColor` below. */\nexport type GutterSpanHast = {\n type: \"element\"\n tagName: \"span\"\n properties: Record<string, string>\n children: Array<{ type: \"text\"; value: string } | GutterSpanHast>\n}\n\ntype CodeBlockGutterColumnBase = {\n /** CSS length reserved for this column, applied as `min-width` (not\n * `width`) — content can still grow past it rather than clipping.\n * @default for a counter column, sized to fit the largest number that\n * will actually appear anywhere in the document (e.g. 2.5ch once any\n * rendered value reaches 2 digits) — computed once, up front, and\n * applied uniformly to every line so a 1-digit line's number stays\n * right-aligned with a 2-digit one instead of shifting the code that\n * follows it. @default \"3ch\" for a content column. */\n width?: string\n /** @default \"right\" for a counter column, \"center\" for a content column */\n align?: \"left\" | \"center\" | \"right\"\n /** Escape hatch: extra class applied to every span this column renders. */\n className?: string\n /** Override the kind-based default (a counter is `aria-hidden` by\n * default — reading \"1, 2, 3...\" aloud per line is noise, redundant\n * with visual position; a content column is left in the accessible\n * tree by default, since its text is meaningful). */\n ariaHidden?: boolean\n}\n\nexport type CodeBlockCounterGutterColumn = CodeBlockGutterColumnBase & {\n kind: \"counter\"\n /** @default 1 */\n startAt?: number\n /** Tags that make this column skip (not advance, render blank) on that\n * line — this is the whole mechanism behind diverging diff old/new\n * numbering: an \"old\" column's `skip: [\"removed\"]` is wrong (it should\n * advance on removed/context, skip added) — see the worked diff example\n * in the docs. A line that's fully removed via notation (see\n * `ParsedLine.blank`) never advances any counter, since it never\n * renders at all. */\n skip?: string[]\n}\n\n/** A content column's per-tag mapping, in its full form — `color` tints the\n * marker's own TEXT, `background` its own fill, exactly the same split\n * every other styling surface in the kit uses (never conflated into one\n * \"colors\" concept). Independent of whatever color/background (if any)\n * the matched tag's own `tags` styling gives the *line* — a marker's\n * identity color (e.g. a diff's \"−\" always red, \"+\" always green) is a\n * different concern than the line's tint, and often wants to stay\n * legible even when the line itself only sets a translucent\n * `background`, no `color`. */\ntype CodeBlockGutterMarker = {\n /** `true` renders the notation marker's own payload verbatim (blame's\n * name, coverage's status, a tutorial-step number); a literal string\n * renders that fixed text regardless of payload (a diff's static\n * \"+\"/\"−\"). */\n text: string | true\n color?: Color\n background?: Color\n}\n\nexport type CodeBlockContentGutterColumn = CodeBlockGutterColumnBase & {\n kind: \"content\"\n /** Maps a notation tag to what this column renders when that tag matches\n * the line — either the shorthand (`true` for the payload verbatim, or a\n * literal string), or the full `{ text, color?, background? }` form when\n * the marker also needs its own color independent of the line's. The\n * first matching tag (in written order) wins. No match on a line → an\n * empty (but still width-reserving) cell. */\n tags: Record<string, string | true | CodeBlockGutterMarker>\n}\n\nexport type CodeBlockGutterColumn = CodeBlockCounterGutterColumn | CodeBlockContentGutterColumn\n\ntype CounterState = { value: number }\n\nfunction countNonSkipped(lines: ParsedLine[], skip: Set<string>): number {\n let n = 0\n for (const l of lines) {\n if (l.blank) continue\n if (!l.matches.some((m) => skip.has(m.tag))) n++\n }\n return n\n}\n\n/** The widest value a counter column will ever display, computed once from\n * the FULL document's notation (never just the local render window) —\n * this is what keeps the head and tail halves of a collapsed split\n * agreeing on the same gutter width too, with no extra plumbing, since\n * both already share this one `notation` (see `code-block.tsx`). Reserves\n * `<digit count> + 0.5`ch, floored at the pre-existing 1.5ch minimum, so a\n * single-digit-only document renders identically to before this fix. */\nfunction defaultCounterWidth(\n column: CodeBlockCounterGutterColumn,\n notation: ParsedNotation,\n): string {\n const startAt = column.startAt ?? 1\n const total = countNonSkipped(notation.perLine, new Set(column.skip ?? []))\n const maxValue = startAt + Math.max(total - 1, 0)\n const digits = String(maxValue).length\n return `${Math.max(digits + 0.5, 1.5)}ch`\n}\n\n/** Appends a class name via plain string concatenation — deliberately NOT\n * `cn()` (tailwind-merge): `decoration-bg`/`decoration-text` are our own\n * bespoke classes, but tailwind-merge pattern-matches the shared\n * `decoration-` prefix as Tailwind's real `text-decoration-color` utility\n * group and treats them as conflicting, silently dropping whichever was\n * added first (verified: `cn(\"decoration-bg\",\"decoration-text\")` →\n * `\"decoration-text\"` only). This is exactly why `applyStyle`\n * (highlighter.ts) uses Shiki's own dumb-append `addClassToHast` for the\n * same two classes instead of `cn()` — this mirrors that here, since a\n * freshly-built `GutterSpanHast` isn't yet part of a Shiki tree and has no\n * `addClassToHast` context available. */\nfunction appendClass(span: GutterSpanHast, extra: string): void {\n const existing = span.properties[\"class\"]\n span.properties[\"class\"] = existing ? `${existing} ${extra}` : extra\n}\n\n/**\n * Applies a marker's own `color`/`background` to its freshly-built span —\n * the exact same two-node `data-color` pattern `applyStyle` (highlighter.ts)\n * uses for a line, just constructing fresh nodes instead of mutating an\n * existing hast tree (so it can't share that function directly, and isn't\n * worth a shared abstraction for this little logic). `color` tints only the\n * marker's own text, `background` only its own fill — never conflated.\n */\nfunction applyMarkerColor(\n span: GutterSpanHast,\n color: Color | undefined,\n background: Color | undefined,\n): void {\n if (background !== undefined && color !== undefined && background !== color) {\n span.properties[\"data-color\"] = background\n appendClass(span, \"decoration-bg\")\n span.children = [\n {\n type: \"element\",\n tagName: \"span\",\n properties: { \"data-color\": color, class: \"decoration-text\" },\n children: span.children,\n },\n ]\n } else if (background !== undefined || color !== undefined) {\n const value = background ?? color\n if (value !== undefined) span.properties[\"data-color\"] = value\n if (background !== undefined) appendClass(span, \"decoration-bg\")\n if (color !== undefined) appendClass(span, \"decoration-text\")\n }\n}\n\nfunction renderColumn(\n column: CodeBlockGutterColumn,\n matches: NotationMatchLike[],\n counter: CounterState | undefined,\n defaultWidth: string,\n): GutterSpanHast {\n const isCounter = column.kind === \"counter\"\n const width = column.width ?? defaultWidth\n const align = column.align ?? (isCounter ? \"right\" : \"center\")\n const ariaHidden = column.ariaHidden ?? isCounter\n\n let text = \"\"\n let color: Color | undefined\n let background: Color | undefined\n if (isCounter && counter) {\n const skip = column.skip\n const skipped = skip != null && matches.some((m) => skip.includes(m.tag))\n if (!skipped) {\n text = String(counter.value)\n counter.value += 1\n }\n } else if (!isCounter) {\n const match = matches.find((m) => m.tag in column.tags)\n if (match) {\n const mapped = column.tags[match.tag]\n if (mapped !== null && typeof mapped === \"object\") {\n text = mapped.text === true ? (match.payload ?? \"\") : mapped.text\n color = mapped.color\n background = mapped.background\n } else {\n text = mapped === true ? (match.payload ?? \"\") : (mapped ?? \"\")\n }\n }\n }\n\n // Plain join, not `cn()` — same reasoning as `appendClass` above; none of\n // these are real Tailwind utilities that need conflict resolution, and\n // running them through tailwind-merge risks the same false-positive drop.\n const baseClasses = [\"gutter-column\", isCounter ? \"gutter-counter\" : \"gutter-content\"]\n if (column.className) baseClasses.push(column.className)\n\n const span: GutterSpanHast = {\n type: \"element\",\n tagName: \"span\",\n properties: {\n class: baseClasses.join(\" \"),\n style: `min-width:${width};text-align:${align}`,\n ...(ariaHidden ? { \"aria-hidden\": \"true\" } : {}),\n },\n children: text ? [{ type: \"text\", value: text }] : [],\n }\n if (text) applyMarkerColor(span, color, background)\n return span\n}\n\ntype NotationMatchLike = { tag: string; payload?: string }\n\n/** Resolves a `gutters` configuration against a full-source notation parse\n * into a stateful `render` closure — one call per rendered line, in\n * increasing line order, matching how Shiki's `line()` transformer hook\n * actually fires. Counter columns carry running state across those calls;\n * `headLineOffset` (the transformer's own `lineOffset`, 0 for the head\n * half of a collapsed split, `collapsedLines` for the tail half) seeds\n * each counter's starting value from how many non-skipped, non-blank\n * lines came before this rendering window in the FULL source — this is\n * what keeps a `skip`-aware counter's numbering continuous across that\n * split with no new architecture: both halves independently derive the\n * correct starting count from the same shared, already-parsed `notation`\n * (see `code-block.tsx`). */\nexport function resolveGutterColumns(\n gutters: CodeBlockGutterColumn[],\n notation: ParsedNotation,\n headLineOffset: number,\n) {\n const resolved = gutters.map((column) => {\n if (column.kind === \"counter\") {\n const seed =\n (column.startAt ?? 1) +\n countNonSkipped(notation.perLine.slice(0, headLineOffset), new Set(column.skip ?? []))\n return {\n column,\n counter: { value: seed } as CounterState | undefined,\n defaultWidth: defaultCounterWidth(column, notation),\n }\n }\n return { column, counter: undefined as CounterState | undefined, defaultWidth: \"3ch\" }\n })\n\n return {\n /** A blank (fully-removed) line never advances any counter, since it\n * never renders at all — callers should not invoke this for a line\n * whose `ParsedLine.blank` is true. */\n render(parsed: ParsedLine | undefined): GutterSpanHast[] {\n if (resolved.length === 0) return []\n const matches = parsed?.matches ?? []\n return resolved.map((r) => renderColumn(r.column, matches, r.counter, r.defaultWidth))\n },\n }\n}\n","import type { LanguageRegistration } from \"shiki\"\n\ntype LanguageLoader = () => Promise<{ default: LanguageRegistration[] }>\n\n/**\n * The grammars `CodeBlock` can load by name — a deliberately finite map.\n *\n * Each entry is a separate dynamic import, so a consumer's bundler emits one\n * chunk per grammar here and nothing more. Shiki's full bundle registers\n * ~300 of them (plus the Oniguruma WASM), and every app depending on the kit\n * paid to emit and parse all of them even when it highlighted two languages.\n *\n * Aliases point to the same loader as their grammar: loading it registers\n * Shiki's own aliases too, so `ts` and `typescript` resolve to one grammar.\n * Anything not listed is added by the caller through `registerLanguage`.\n */\nexport const LANGUAGES = {\n c: () => import(\"shiki/langs/c.mjs\"),\n cpp: () => import(\"shiki/langs/cpp.mjs\"),\n \"c++\": () => import(\"shiki/langs/cpp.mjs\"),\n python: () => import(\"shiki/langs/python.mjs\"),\n py: () => import(\"shiki/langs/python.mjs\"),\n shellscript: () => import(\"shiki/langs/shellscript.mjs\"),\n bash: () => import(\"shiki/langs/shellscript.mjs\"),\n sh: () => import(\"shiki/langs/shellscript.mjs\"),\n shell: () => import(\"shiki/langs/shellscript.mjs\"),\n zsh: () => import(\"shiki/langs/shellscript.mjs\"),\n javascript: () => import(\"shiki/langs/javascript.mjs\"),\n js: () => import(\"shiki/langs/javascript.mjs\"),\n cjs: () => import(\"shiki/langs/javascript.mjs\"),\n mjs: () => import(\"shiki/langs/javascript.mjs\"),\n typescript: () => import(\"shiki/langs/typescript.mjs\"),\n ts: () => import(\"shiki/langs/typescript.mjs\"),\n cts: () => import(\"shiki/langs/typescript.mjs\"),\n mts: () => import(\"shiki/langs/typescript.mjs\"),\n jsx: () => import(\"shiki/langs/jsx.mjs\"),\n tsx: () => import(\"shiki/langs/tsx.mjs\"),\n json: () => import(\"shiki/langs/json.mjs\"),\n yaml: () => import(\"shiki/langs/yaml.mjs\"),\n yml: () => import(\"shiki/langs/yaml.mjs\"),\n markdown: () => import(\"shiki/langs/markdown.mjs\"),\n md: () => import(\"shiki/langs/markdown.mjs\"),\n html: () => import(\"shiki/langs/html.mjs\"),\n css: () => import(\"shiki/langs/css.mjs\"),\n sql: () => import(\"shiki/langs/sql.mjs\"),\n go: () => import(\"shiki/langs/go.mjs\"),\n rust: () => import(\"shiki/langs/rust.mjs\"),\n rs: () => import(\"shiki/langs/rust.mjs\"),\n java: () => import(\"shiki/langs/java.mjs\"),\n make: () => import(\"shiki/langs/make.mjs\"),\n makefile: () => import(\"shiki/langs/make.mjs\"),\n docker: () => import(\"shiki/langs/docker.mjs\"),\n dockerfile: () => import(\"shiki/langs/docker.mjs\"),\n diff: () => import(\"shiki/langs/diff.mjs\"),\n} satisfies Record<string, LanguageLoader>\n\n/** A language `CodeBlock` resolves by name: a bundled id or alias, `\"text\"`,\n * or any name registered through `registerLanguage`. */\nexport type CodeBlockLanguage = keyof typeof LANGUAGES | \"text\" | (string & {})\n\nexport function languageLoader(lang: string): LanguageLoader | undefined {\n return Object.hasOwn(LANGUAGES, lang) ? LANGUAGES[lang as keyof typeof LANGUAGES] : undefined\n}\n","/**\n * Comment-notation parser for `CodeBlock` — the ONLY per-line targeting\n * mechanism in the new design (replaces the old hand-counted `{ line }` /\n * { from, to }` index-based `decorations`). A line opts into styling/gutter\n * content by carrying a marker comment, e.g. `// [!code removed]` or\n * `// [!code blame:alice]`, anywhere a trailing comment is recognized —\n * modeled on Shiki's own `[!code xxx]` convention, but built from scratch\n * here rather than depending on `@shikijs/transformers`: its generic\n * `transformerNotationMap` only supports a fixed keyword enum (no arbitrary\n * `tag:payload` capture), and the lower-level engine that *would* support\n * that (`createCommentNotationTransformer`) is an internal, non-exported\n * module in that package — not something to depend on.\n *\n * Pure string → data. No Shiki/hast import at all, so it's callable once\n * per `CodeBlock` render (over the FULL, unsplit `code` prop) and shared\n * across both halves of the collapse/expand head-tail split — see\n * `code-block.tsx` and the `notation` option in `highlighter.ts`.\n *\n * ## Grammar\n *\n * `[!code <tag>]` or `[!code <tag>:<payload>]`. `<tag>` is any consumer-\n * defined identifier (`[A-Za-z][\\w-]*`) — CodeBlock itself has no built-in\n * vocabulary (\"diff\"/\"highlight\"/\"blame\" are just tag names someone chose).\n * `<payload>` is free-form text; `\\:` and `\\]` escape a literal colon or\n * bracket inside it. Multiple distinct markers may stack on one line\n * (`// [!code blame:alice] [!code coverage:miss]`) — a deliberate\n * generalization the fixed-enum Shiki transformers can't express, since\n * each of those is a single-keyword regex, not a general engine.\n *\n * There is deliberately NO range/count-suffix shorthand (Shiki's own\n * `[!code highlight:3]` \"applies to the next 3 lines\"). That shorthand\n * reintroduces exactly the counting problem this mechanism exists to\n * remove — you'd have to count how many lines a block spans to write `:5`.\n * Every marker applies only to the single line it's written on; a multi-\n * line diff removal is the same marker repeated on every affected line,\n * trivial when machine-generated (see `diff.ts`) and no worse by hand\n * either, since the marker sits right next to the line it describes.\n *\n * ## Comment styles recognized\n *\n * A marker is only honored inside a RECOGNIZED trailing comment, checked\n * per physical line (never across lines):\n * - `<!-- ... -->` and `/* ... *\\/` — block-style, single line only, and\n * ONLY as the comment's entire content (see \"Known limitation\" below).\n * - `{/* ... *\\/}` — a JSX/TSX expression-container comment, matched only\n * when it's the sole content of its own line (leading/trailing\n * whitespace aside).\n * - A line-style opener — `//`, `#`, `;`/`;;`, `%`/`%%`, or `--` — found\n * as the RIGHTMOST such token on the line (so `// TODO: fix // [!code\n * todo]` finds the second `//`, treating it as its own trailing\n * comment, leaving the first comment's prose untouched).\n * - A `*`-continuation line inside a `/** ... *\\/` block (a line that,\n * once left-trimmed, starts with `*` not immediately followed by `/`)\n * — so a marker on the 2nd+ line of a JSDoc-style comment is found too.\n *\n * Detection is purely textual against the raw source line, independent of\n * which language grammar Shiki tokenizes it with — this is what lets a\n * `//`-style marker (what `diff.ts` always emits) work correctly even for\n * a language whose grammar wouldn't itself treat `//` as a comment (e.g. a\n * diff of a CSS or Python sample): the *removal* (see `highlighter.ts`'s\n * `trimTrailingChars`) trims a character count off the end of the rendered\n * line, not a token, so it doesn't need the grammar's cooperation.\n *\n * ## What gets removed, and the \"trailing only\" constraint\n *\n * A marker is only recognized as notation if it — plus, for a line-style\n * opener, only whitespace, or for a block/JSX style, only whitespace and\n * the closing delimiter — runs to the true end of the line. This keeps\n * removal a clean SUFFIX trim (`stripCount` characters off the end of the\n * rendered line), which is what makes the hast-mutation side in\n * `highlighter.ts` a simple, robust operation instead of a fragile interior\n * edit. Two concrete behaviors this produces:\n * - `sum += x; // [!code highlight]` → not blank; only the marker (and\n * the now-empty `// `) is stripped, the code before it is untouched.\n * - `// [!code highlight]` alone on a line → the WHOLE line is blank and\n * is removed entirely (see `blank`), not left behind as an empty line.\n *\n * A marker with real prose BEFORE it in the same comment is supported for\n * line-style openers and the `*`-continuation form (`// keep this [!code\n * highlight]` → strips only the marker, keeping `// keep this`), since\n * those have no closing delimiter to preserve. Block/HTML/JSX comments do\n * NOT support this — the marker must be their entire content — because\n * removing an interior marker while preserving a `*\\/`/`-->`/`}` closer\n * isn't a suffix trim. A marker mixed with prose inside `/* *\\/`/`<!-- -->`/\n * `{/* *\\/}` is simply not recognized as notation and renders as literal\n * text; use a line-style trailing comment instead when prose needs to sit\n * alongside a marker.\n *\n * ## Known limitation\n *\n * The line-style opener scan picks the RIGHTMOST occurrence of `//`/`#`/\n * `;`/`;;`/`%`/`%%`/`--` that sits outside every marker's own matched span\n * (so a payload containing one of those substrings, e.g. `[!code\n * note:see--also]`, can't itself be mistaken for an opener) — but it does\n * not otherwise understand string literals or real comment grammar. A\n * comment-opener-like substring inside an unrelated string literal, at the\n * very end of a line with nothing after it, could in principle be\n * misdetected. This is a deliberate, documented tradeoff (a purely textual\n * heuristic, not a full per-language parser) rather than a bug to chase —\n * acceptable for hand-authored/machine-generated notation, which is what\n * this mechanism is for.\n */\n\nexport type NotationMatch = { tag: string; payload?: string }\n\nexport type ParsedLine = {\n /** Every marker matched on this line, in written order. */\n matches: NotationMatch[]\n /** Characters to trim off the END of this line's rendered text to\n * produce the marker-free version. 0 when the line has no marker, or\n * when `blank` is true (the whole line is removed instead). */\n stripCount: number\n /** True when the line becomes fully empty after removing its marker(s)\n * AND had at least one match — i.e. it should be spliced out of the\n * render entirely, not left behind as a blank line. A line that was\n * already blank in the source (no marker at all) is never flagged. */\n blank: boolean\n}\n\n/** Index 0 = source line 1. */\nexport type ParsedNotation = { perLine: ParsedLine[] }\n\nconst MARKER_SOURCE = String.raw`\\[!code\\s+([A-Za-z][\\w-]*)(?::((?:\\\\.|[^:\\]])*))?\\s*\\]`\nconst MARKER_RE = new RegExp(MARKER_SOURCE, \"g\")\nconst TRAILING_MARKERS_RE = new RegExp(`(?:${MARKER_SOURCE}\\\\s*)+$`)\nconst LINE_OPENER_RE = /\\/\\/|#|;{1,2}|%{1,2}|--/g\nconst UNESCAPE_RE = /\\\\(.)/g\n\nconst NO_MATCH: ParsedLine = { matches: [], stripCount: 0, blank: false }\n\nfunction unescapePayload(payload: string): string {\n return payload.replace(UNESCAPE_RE, \"$1\")\n}\n\nfunction collectMarkers(text: string): NotationMatch[] {\n return [...text.matchAll(MARKER_RE)].map((m) => ({\n tag: m[1] as string,\n payload: m[2] !== undefined ? unescapePayload(m[2]) : undefined,\n }))\n}\n\n/** Moves `index` left past any run of plain spaces/tabs immediately before\n * it, so a strip boundary doesn't leave a dangling trailing space. */\nfunction backOverWhitespace(line: string, index: number): number {\n let i = index\n while (i > 0 && (line[i - 1] === \" \" || line[i - 1] === \"\\t\")) i--\n return i\n}\n\nfunction toParsedLine(matches: NotationMatch[], line: string, removableFrom: number): ParsedLine {\n const start = backOverWhitespace(line, removableFrom)\n return { matches, stripCount: line.length - start, blank: line.slice(0, start).trim() === \"\" }\n}\n\n/** Block-style comment (`<!-- -->`, `/* *\\/`, or the JSX `{/* *\\/}` form) —\n * only matched when its entire content, once every marker is removed, is\n * blank (see the \"Known limitation\"/prose doc comment above the file). */\nfunction matchBlock(line: string, open: string, close: string): ParsedLine | null {\n const closeIdx = line.lastIndexOf(close)\n if (closeIdx === -1) return null\n if (line.slice(closeIdx + close.length).trim() !== \"\") return null\n const openIdx = line.lastIndexOf(open, closeIdx)\n if (openIdx === -1) return null\n const body = line.slice(openIdx + open.length, closeIdx)\n MARKER_RE.lastIndex = 0\n if (!MARKER_RE.test(body)) return null\n MARKER_RE.lastIndex = 0\n const remaining = body.replace(MARKER_RE, \"\").trim()\n if (remaining !== \"\") return null\n return toParsedLine(collectMarkers(body), line, openIdx)\n}\n\n/** A `//`/`#`/`;`/`;;`/`%`/`%%`/`--` trailing comment — the rightmost such\n * opener outside any marker's own span, so a marker's payload can safely\n * contain one of those substrings without being mistaken for an opener. */\nfunction matchLineStyle(line: string): ParsedLine | null {\n MARKER_RE.lastIndex = 0\n const markerSpans = [...line.matchAll(MARKER_RE)].map(\n (m) => [m.index, m.index + m[0].length] as const,\n )\n const insideAMarker = (i: number) => markerSpans.some(([s, e]) => i >= s && i < e)\n\n let openIdx = -1\n let openLen = 0\n for (const m of line.matchAll(LINE_OPENER_RE)) {\n if (insideAMarker(m.index)) continue\n openIdx = m.index\n openLen = m[0].length\n }\n if (openIdx === -1) return null\n\n const body = line.slice(openIdx + openLen)\n const trailing = body.match(TRAILING_MARKERS_RE)\n if (!trailing || trailing.index === undefined) return null\n\n const matches = collectMarkers(trailing[0])\n const prose = body.slice(0, trailing.index).trim()\n const removableFrom = prose === \"\" ? openIdx : openIdx + openLen + trailing.index\n return toParsedLine(matches, line, removableFrom)\n}\n\n/** The 2nd+ line of a `/** ... *\\/` block, e.g. ` * [!code highlight]`. */\nfunction matchContinuation(line: string): ParsedLine | null {\n const m = line.match(/^(\\s*)\\*(?!\\/)([\\s\\S]*)$/)\n if (!m) return null\n const [, indent, body] = m as [string, string, string]\n const trailing = body.match(TRAILING_MARKERS_RE)\n if (!trailing || trailing.index === undefined) return null\n\n const matches = collectMarkers(trailing[0])\n const prose = body.slice(0, trailing.index).trim()\n const removableFrom = prose === \"\" ? indent.length : indent.length + 1 + trailing.index\n return toParsedLine(matches, line, removableFrom)\n}\n\nfunction parseLine(line: string): ParsedLine {\n const jsx = matchBlock(line, \"{/*\", \"*/}\")\n if (jsx) return jsx\n const html = matchBlock(line, \"<!--\", \"-->\")\n if (html) return html\n const block = matchBlock(line, \"/*\", \"*/\")\n if (block) return block\n const lineStyle = matchLineStyle(line)\n if (lineStyle) return lineStyle\n const continuation = matchContinuation(line)\n if (continuation) return continuation\n return NO_MATCH\n}\n\n/** Parses every notation marker in `code`, once, line by line. With\n * `enabled: false` every line is a non-match — the markers stay in the\n * rendered source verbatim (a snippet that *documents* the notation), while\n * `perLine` keeps one entry per line so gutter counters still size right. */\nexport function parseNotation(code: string, enabled = true): ParsedNotation {\n return { perLine: code.split(\"\\n\").map((line) => (enabled ? parseLine(line) : NO_MATCH)) }\n}\n","import type {\n HighlighterCore,\n LanguageInput,\n ShikiTransformer,\n ShikiTransformerContext,\n ThemeInput,\n} from \"shiki\"\nimport type { Color } from \"../../lib/colors\"\nimport { devWarnOnce } from \"../../lib/dev-warn\"\nimport { type CodeBlockGutterColumn, resolveGutterColumns } from \"./gutters\"\nimport { type CodeBlockLanguage, languageLoader } from \"./languages\"\nimport { type ParsedNotation, parseNotation } from \"./notation\"\n\n/** Structurally the same `Element` (hast) type `ShikiTransformer`'s own\n * `line`/`span` hooks receive — derived via `Parameters` rather than a\n * direct `import type { Element } from \"hast\"`, since `hast`'s types are\n * only reachable through `@shikijs/core`'s own dependency graph, not\n * necessarily resolvable as a bare specifier from this package. */\ntype LineHast = Parameters<NonNullable<ShikiTransformer[\"line\"]>>[0]\ntype HastNode = LineHast[\"children\"][number]\n\n/**\n * Module-level singleton — created lazily on first use, shared by every\n * `CodeBlock` on the page (a docs page can render dozens).\n *\n * Built from Shiki's fine-grained core, never the bare `shiki` entry: that\n * one's registries carry ~300 grammar/theme imports and the Oniguruma WASM,\n * which every consumer's bundler would have to emit. The JavaScript regex\n * engine replaces the WASM, the two default themes are the only themes\n * loaded by name, and grammars come from the finite `LANGUAGES` map.\n */\nconst DEFAULT_THEMES = { light: \"github-light\", dark: \"github-dark-default\" } as const\n\nlet highlighterPromise: Promise<HighlighterCore> | null = null\n\nfunction getHighlighter(): Promise<HighlighterCore> {\n if (!highlighterPromise) {\n highlighterPromise = Promise.all([\n import(\"shiki/core\"),\n import(\"shiki/engine/javascript\"),\n import(\"shiki/themes/github-light.mjs\"),\n import(\"shiki/themes/github-dark-default.mjs\"),\n ]).then(([{ createHighlighterCore }, { createJavaScriptRegexEngine }, light, dark]) =>\n createHighlighterCore({\n themes: [light.default, dark.default],\n langs: [],\n engine: createJavaScriptRegexEngine(),\n }),\n )\n }\n return highlighterPromise\n}\n\n/**\n * Register a TextMate grammar so `<CodeBlock language=\"...\">` can reference\n * it by name. Needed for any language outside the bundled `LANGUAGES` map,\n * including Shiki's own: `registerLanguage((await import(\"shiki/langs/haskell.mjs\")).default)`.\n * Await this once (e.g. at app startup) before rendering a `CodeBlock` that\n * uses it.\n */\nexport async function registerLanguage(lang: LanguageInput): Promise<void> {\n const highlighter = await getHighlighter()\n await highlighter.loadLanguage(lang)\n}\n\n/** Register a VS Code-style theme so `themes` can reference it by name.\n * Only `github-light` and `github-dark-default` load without it. */\nexport async function registerTheme(theme: ThemeInput): Promise<void> {\n const highlighter = await getHighlighter()\n await highlighter.loadTheme(theme)\n}\n\n/** Palette-driven styling — `background`/`color` tint via the kit's own\n * theme-aware `Color` tokens (the same `--c-soft`/`--c-text` mechanism\n * every colored component uses), independent of each other, the same\n * relationship `Mark`'s own `background`/`color` props have. `className`/\n * `style` stay as the escape hatch for anything the two color props don't\n * cover (layout, a specific shade, an arbitrary Tailwind utility) — prefer\n * `background`/`color` first; reach for `className`/`style` only for what\n * they can't express. */\ntype CodeBlockStyle = {\n /** Text color, via the same `Color` tokens as the rest of the kit. */\n color?: Color\n /** Background/highlight tint, via the same `Color` tokens as the rest of the kit. */\n background?: Color\n /** Escape hatch: an arbitrary class, for anything `color`/`background` don't cover. */\n className?: string\n /** Escape hatch: raw CSS text (e.g. `\"text-decoration: line-through\"`), not\n * a React `CSSProperties` object — styles are threaded through Shiki's\n * hast → HTML string pipeline, never React's own DOM `style` prop. */\n style?: string\n}\n\n/** Styling for a notation tag — a line carrying `// [!code removed]` looks\n * up `tags.removed`. `CodeBlock` has no built-in tag vocabulary of its\n * own: \"removed\", \"highlight\", \"blame\", etc. are just names a consumer\n * chose — see `notation.ts` for the full grammar. */\nexport type CodeBlockTagStyle = CodeBlockStyle\n\nexport type HighlightOptions = {\n lang?: CodeBlockLanguage\n themes?: { light: string; dark: string }\n /** Notation-tag → styling lookup — see `CodeBlockTagStyle`. */\n tags?: Record<string, CodeBlockTagStyle>\n /** Stacked, ordered gutter columns rendered left of the code — see\n * `CodeBlockGutterColumn` (`gutters.ts`). */\n gutters?: CodeBlockGutterColumn[]\n /** Offset added to every rendered line number before matching notation/\n * seeding gutter counters — used by `CodeBlock`'s collapse split so a\n * highlighted \"tail\" half still reports its true position in the\n * original source. */\n lineOffset?: number\n /** A precomputed `parseNotation` of the FULL, un-split source. Passed by\n * `CodeBlock` so the collapsed head/tail split's two independent\n * `highlightCode` calls share one notation pass — this is what keeps a\n * `skip`-aware gutter counter's numbering continuous across that split.\n * Omitted (e.g. a consumer calling `highlightCode` directly) → computed\n * from this call's own `code`. */\n notation?: ParsedNotation\n /** Extra Shiki transformers (e.g. from the `@shikijs/transformers`\n * ecosystem, or your own), run after the internal notation transformer.\n * This is the escape hatch for extending Shiki's own capabilities —\n * anything a `ShikiTransformer` can do (custom notation, extra markup,\n * post-processing) works here without `CodeBlock` needing to know about\n * it. See also `registerLanguage`/`registerTheme` for extending the\n * language/theme side of the parser. */\n transformers?: ShikiTransformer[]\n}\n\nfunction appendStyle(hast: LineHast, style: string) {\n const existing = hast.properties[\"style\"]\n hast.properties[\"style\"] =\n typeof existing === \"string\" && existing.length > 0 ? `${existing};${style}` : style\n}\n\n/**\n * Applies one tag's styling to its matched line hast node. `className`/\n * `style` land directly on that node, verbatim — the escape hatch, no\n * interpretation. `background`/`color` route through the same `data-color`\n * + `--c-soft`/`--c-text` mechanism every colored component in the kit uses\n * (theme-aware, unlike a hardcoded shade) — `.shiki .decoration-bg`/\n * `.decoration-text` (styles.css) reference those vars at a specificity\n * that beats the ambient `.shiki span` token-color rule.\n *\n * `background`/`color` set to *different* colors need two independently-\n * scoped `data-color` attributes — the same constraint `Mark` has, for the\n * same reason (one attribute, one color's worth of both vars). Since the\n * target here is a hast node we already own (not JSX), the fix is the same\n * shape as `Mark`'s: wrap the existing children in an inner span that\n * scopes its own `data-color` for text, leaving the outer node's\n * `data-color` scoping the background. When they match (or only one is\n * given), a single `data-color` on the node itself is enough.\n */\nfunction applyStyle(\n hast: LineHast,\n s: CodeBlockStyle,\n addClassToHast: ShikiTransformerContext[\"addClassToHast\"],\n) {\n if (s.className) addClassToHast(hast, s.className)\n if (s.style) appendStyle(hast, s.style)\n\n const { background, color } = s\n if (background !== undefined && color !== undefined && background !== color) {\n hast.properties[\"data-color\"] = background\n addClassToHast(hast, \"decoration-bg\")\n hast.children = [\n {\n type: \"element\",\n tagName: \"span\",\n properties: { \"data-color\": color, class: \"decoration-text\" },\n children: hast.children,\n },\n ]\n } else if (background !== undefined || color !== undefined) {\n hast.properties[\"data-color\"] = background ?? color\n if (background !== undefined) addClassToHast(hast, \"decoration-bg\")\n if (color !== undefined) addClassToHast(hast, \"decoration-text\")\n }\n}\n\nfunction isEmptyNode(node: HastNode): boolean {\n if (node.type === \"text\") return node.value.length === 0\n if (node.type === \"element\") return node.children.length === 0\n return false\n}\n\nfunction trimNode(node: HastNode, remaining: number): number {\n if (node.type === \"text\") {\n const take = Math.min(remaining, node.value.length)\n node.value = node.value.slice(0, node.value.length - take)\n return remaining - take\n }\n if (node.type === \"element\") {\n let left = remaining\n while (left > 0 && node.children.length > 0) {\n const child = node.children[node.children.length - 1] as HastNode\n left = trimNode(child, left)\n if (isEmptyNode(child)) node.children.pop()\n else break\n }\n return left\n }\n return remaining\n}\n\n/** Trims `count` characters off the END of a line's rendered text, walking\n * its (possibly nested, per-token) hast children from the last one\n * backward — the mechanical half of notation removal; the regex work\n * already happened once in `notation.ts`, this just applies its\n * precomputed `stripCount` to the already-tokenized hast. */\nfunction trimTrailingChars(hast: LineHast, count: number) {\n let remaining = count\n while (remaining > 0 && hast.children.length > 0) {\n const last = hast.children[hast.children.length - 1] as HastNode\n remaining = trimNode(last, remaining)\n if (isEmptyNode(last)) hast.children.pop()\n else break\n }\n}\n\n/**\n * Builds the one internal Shiki transformer from a `HighlightOptions`\n * config. Deliberately generic: it has no notion of \"highlight\" or \"diff\"\n * — it only applies whatever `className`/`style`/`background`/`color` a\n * `tags` entry supplies, and whatever content a `gutters` column resolves\n * to, straight onto the matching line hast node(s), driven entirely by the\n * consumer-chosen notation tags found on each line. Built fresh per\n * `highlightCode` call (options differ per instance) — not part of the\n * shared singleton above.\n */\nfunction buildCodeBlockTransformer(\n opts: HighlightOptions,\n notation: ParsedNotation,\n): ShikiTransformer {\n const offset = opts.lineOffset ?? 0\n const gutters = resolveGutterColumns(opts.gutters ?? [], notation, offset)\n const toRemove = new Set<LineHast>()\n\n return {\n name: \"42-ui-code-block\",\n line(hast, renderedLine) {\n const line = renderedLine + offset\n const parsed = notation.perLine[line - 1]\n\n if (parsed?.blank) {\n toRemove.add(hast)\n return hast\n }\n\n if (parsed && parsed.stripCount > 0) trimTrailingChars(hast, parsed.stripCount)\n\n for (const m of parsed?.matches ?? []) {\n const style = opts.tags?.[m.tag]\n if (style) applyStyle(hast, style, this.addClassToHast)\n }\n\n const gutterSpans = gutters.render(parsed)\n if (gutterSpans.length > 0) hast.children.unshift(...gutterSpans)\n\n return hast\n },\n code(hast) {\n if (toRemove.size === 0) return hast\n hast.children = hast.children.filter((child, i, arr) => {\n if (child.type === \"element\" && toRemove.has(child as LineHast)) return false\n if (child.type === \"text\" && child.value === \"\\n\") {\n const neighbor = arr[i - 1] ?? arr[i + 1]\n if (neighbor?.type === \"element\" && toRemove.has(neighbor as LineHast)) return false\n }\n return true\n })\n return hast\n },\n }\n}\n\n/** Shiki's built-in plain-text names: rendered without any grammar. */\nconst PLAIN_LANGUAGES = new Set([\"text\", \"txt\", \"plain\", \"plaintext\"])\n\n/** Resolves `lang` to a name the highlighter can render: already loaded\n * (bundled earlier, or registered), loadable from the `LANGUAGES` map, or\n * else plain text, with a dev warning naming the fix. Unknown names used to\n * reject inside `loadLanguage`, leaving the block unhighlighted for good. */\nasync function resolveLanguage(highlighter: HighlighterCore, lang: string): Promise<string> {\n if (PLAIN_LANGUAGES.has(lang) || highlighter.getLoadedLanguages().includes(lang)) return lang\n const loader = languageLoader(lang)\n if (loader) {\n await highlighter.loadLanguage((await loader()).default)\n return lang\n }\n devWarnOnce(\n `CodeBlock: unknown language \"${lang}\", rendering as plain text. Register its grammar with registerLanguage() first.`,\n )\n return \"text\"\n}\n\n/** Resolves one theme slot to a loaded theme name. Only the two defaults are\n * loaded up front; any other name has to come through `registerTheme`, or\n * that slot falls back to its default, with a dev warning. */\nfunction resolveTheme(\n highlighter: HighlighterCore,\n name: string,\n slot: keyof typeof DEFAULT_THEMES,\n): string {\n if (highlighter.getLoadedThemes().includes(name)) return name\n devWarnOnce(\n `CodeBlock: unknown theme \"${name}\", using \"${DEFAULT_THEMES[slot]}\" instead. Register it with registerTheme() first.`,\n )\n return DEFAULT_THEMES[slot]\n}\n\n/** Highlights `code` as HTML via the shared Shiki singleton. The language\n * loads on demand from the `LANGUAGES` map; a name registered through\n * `registerLanguage`/`registerTheme` is recognized as already loaded via the\n * highlighter's own `getLoadedLanguages`/`getLoadedThemes`. `lang` defaults\n * to `\"text\"` (Shiki's built-in plaintext grammar — no dynamic import\n * needed). Called with `defaultColor: false` so neither theme is inlined as\n * a plain `color`/`background-color` — both live only in the\n * `--shiki-light`/`--shiki-dark` custom properties consumed by\n * `styles.css`, so the dark-mode CSS rule there needs no `!important`. */\nexport async function highlightCode(code: string, opts: HighlightOptions = {}): Promise<string> {\n const highlighter = await getHighlighter()\n const notation = opts.notation ?? parseNotation(code)\n const lang = await resolveLanguage(highlighter, opts.lang ?? \"text\")\n const themes = {\n light: resolveTheme(highlighter, opts.themes?.light ?? DEFAULT_THEMES.light, \"light\"),\n dark: resolveTheme(highlighter, opts.themes?.dark ?? DEFAULT_THEMES.dark, \"dark\"),\n }\n\n return highlighter.codeToHtml(code, {\n lang,\n themes,\n defaultColor: false,\n transformers: [buildCodeBlockTransformer(opts, notation), ...(opts.transformers ?? [])],\n })\n}\n","\"use client\"\n\nimport { type ReactNode, useEffect, useMemo, useState } from \"react\"\nimport type { ShikiTransformer } from \"shiki\"\nimport { cn } from \"../../lib/cn\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport {\n CodeBlockButton,\n CodeBlockChrome,\n type CodeBlockClassNames,\n type CodeBlockIcons,\n type CodeBlockTranslations,\n} from \"./chrome\"\nimport type { CodeBlockGutterColumn } from \"./gutters\"\nimport { type CodeBlockTagStyle, highlightCode } from \"./highlighter\"\nimport type { CodeBlockLanguage } from \"./languages\"\nimport { type ParsedNotation, parseNotation } from \"./notation\"\n\nexport type {\n CodeBlockButtonProps,\n CodeBlockClassNames,\n CodeBlockIconSlot,\n CodeBlockIcons,\n CodeBlockTranslations,\n} from \"./chrome\"\nexport type {\n CodeBlockContentGutterColumn,\n CodeBlockCounterGutterColumn,\n CodeBlockGutterColumn,\n} from \"./gutters\"\nexport type { CodeBlockTagStyle } from \"./highlighter\"\n\n/**\n * CodeBlock — Shiki-powered syntax highlighting, spec'd off Mantine's\n * `CodeHighlight`: a copy button, collapse/expand for long snippets, and\n * replaceable toolbar icons (`icons`). `\"use client\"` — highlighting is inherently async\n * (Shiki's `codeToHtml`), so the component renders a plain, unhighlighted\n * `<pre><code>` fallback (same chrome, no layout shift) until it resolves.\n * Reactive to prop changes (re-highlights whenever `code`/`tags`/etc.\n * change) — use this for anything editable/dynamic (a live playground). For\n * static content known at render time (the common case — docs, MDX, a\n * fixed snippet), `CodeBlock.Static` is an async Server Component that\n * `await`s the same `highlightCode` during the server render instead,\n * shipping zero client JS for Shiki at all; the two share the exact same\n * `CodeBlockChrome` (chrome.tsx) for the toolbar/collapse UI.\n *\n * `tags`/`gutters` are a general notation-driven / gutter-column mechanism —\n * see `notation.ts` for the full `// [!code tag]` comment grammar and\n * `/docs/code-block` for worked examples. There's no baked-in \"highlight\"\n * or \"diff\" concept: a diff view, a spotlighted zone, blame, a redacted\n * token, etc. are all just tags/gutters the consumer authors themselves\n * (or generates — see `@42/ui-react/code-block/diff`). `lineNumbers()`/\n * `highlight()` (from `@42/ui-react/code-block`) are pre-built one-liner\n * arguments to `gutters`/`tags` for the two most common cases — not a\n * separate mechanism, and not a dedicated prop on `CodeBlock` itself.\n *\n * Ship `@42/ui-react/code-block/styles.css` alongside this component — it's\n * not part of the universal `colors.css`/`theme.css` chain, since only\n * consumers who render a `CodeBlock` need Shiki's token/gutter CSS.\n */\nexport type CodeBlockProps = WithTestId & {\n /** Source text to highlight. No `children` slot — content is Shiki-derived. */\n code: string\n /** A bundled language id or alias (e.g. \"tsx\", \"bash\", \"json\"), or a name\n * registered through `registerLanguage`. An unknown name renders as plain\n * text, with a dev-only warning. Omit → plain \"text\" grammar, no async load. */\n language?: CodeBlockLanguage\n /** Override the light/dark Shiki theme pair. @default { light: \"github-light\", dark: \"github-dark-default\" } */\n themes?: { light: string; dark: string }\n /** Notation-tag → styling lookup — a line carrying `// [!code removed]`\n * looks up `tags.removed`. See the component doc comment / `notation.ts`. */\n tags?: Record<string, CodeBlockTagStyle>\n /** Stacked, ordered gutter columns rendered left of the code — real DOM\n * nodes, never `::before` pseudo-elements. `lineNumbers()` (from\n * `@42/ui-react/code-block`) is the one-liner for a plain counter. */\n gutters?: CodeBlockGutterColumn[]\n /** Extra Shiki transformers (e.g. `@shikijs/transformers`, or your own),\n * run after the internal notation transformer — the escape hatch for\n * extending Shiki's own capabilities. See also `registerLanguage`/\n * `registerTheme` (exported from `@42/ui-react/code-block`) for\n * registering a language/theme the bundled set doesn't ship. */\n transformers?: ShikiTransformer[]\n /** Parse `// [!code tag]` markers. `false` renders them verbatim instead —\n * for a snippet that teaches the notation itself. @default true */\n notation?: boolean\n\n /** Header row above the code (e.g. a filename). When set, the toolbar\n * moves into the header instead of floating over the code. */\n title?: ReactNode\n\n /** @default true */\n withCopyButton?: boolean\n onCopy?: () => void\n\n /** Lines always visible before the fade + expand seam. Omit → never collapses. */\n collapsedLines?: number\n /** @default false */\n defaultExpanded?: boolean\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n\n /** Replaces the toolbar's icons: `copy`, `copied`, `expand`, `collapse`. A missing key keeps\n * its default; `null` leaves that button empty. */\n icons?: CodeBlockIcons\n\n /** Extra control(s) in the same floating controls row, rendered before the\n * expand/copy buttons. Purely additive — build them with `CodeBlock.Button`\n * for the exact same size/style as the built-in ones. */\n controls?: ReactNode\n\n /** Button/label copy, factored into one object — same convention as `Calendar`/`DatePicker`'s `translations` prop: a flat `Partial<CodeBlockTranslations>`, merged over English defaults, no context/bundled locale packs. */\n translations?: Partial<CodeBlockTranslations>\n\n className?: string\n classNames?: CodeBlockClassNames\n}\n\ntype HighlightedPreProps = {\n code: string\n lang?: CodeBlockLanguage\n themes?: { light: string; dark: string }\n tags?: Record<string, CodeBlockTagStyle>\n gutters?: CodeBlockGutterColumn[]\n /** Shared across both the head and tail halves of the collapse split —\n * see `CodeBlockComponent` and `HighlightOptions.notation`. */\n notation: ParsedNotation\n lineOffset?: number\n transformers?: ShikiTransformer[]\n className?: string\n}\n\nfunction HighlightedPre({\n code,\n lang,\n themes,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n className,\n}: HighlightedPreProps) {\n const [html, setHtml] = useState<string | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setHtml(null)\n highlightCode(code, {\n lang,\n themes,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n }).then((h) => {\n if (!cancelled) setHtml(h)\n })\n return () => {\n cancelled = true\n }\n // biome-ignore lint/correctness/useExhaustiveDependencies: themes is tracked via its light/dark fields, not the (often inline, reference-unstable) object itself\n }, [\n code,\n lang,\n themes?.light,\n themes?.dark,\n tags,\n gutters,\n notation,\n lineOffset,\n transformers,\n themes,\n ])\n\n if (html) {\n // No horizontal padding here — `.shiki .line` (styles.css) carries its\n // own `padding-inline` instead, so a decorated line's background hugs\n // this container's edges rather than stopping short of it.\n // `dir=\"ltr\"`: source code reads left-to-right on an RTL page too — the\n // chrome (title, toolbar) still follows the page direction.\n // biome-ignore lint/security/noDangerouslySetInnerHtml: trusted, deterministic Shiki output, not user input\n return <div dir=\"ltr\" className={className} dangerouslySetInnerHTML={{ __html: html }} />\n }\n return (\n // The plain fallback has no `.line` spans of its own to carry padding,\n // so it keeps the horizontal inset directly.\n <pre dir=\"ltr\" className={cn(className, \"px-4\")}>\n <code>{code}</code>\n </pre>\n )\n}\n\nfunction CodeBlockComponent({\n code,\n language,\n themes,\n tags,\n gutters,\n transformers,\n notation: notationEnabled = true,\n collapsedLines,\n className,\n classNames,\n ...chromeProps\n}: CodeBlockProps) {\n const lines = code.split(\"\\n\")\n const isCollapsible = collapsedLines != null && lines.length > collapsedLines\n const headCode = isCollapsible ? lines.slice(0, collapsedLines).join(\"\\n\") : code\n const tailCode = isCollapsible ? lines.slice(collapsedLines).join(\"\\n\") : \"\"\n // Parsed once over the FULL, unsplit `code` — never `headCode`/`tailCode`\n // individually — and shared by both `HighlightedPre` calls below. This is\n // what keeps a `skip`-aware gutter counter's numbering continuous across\n // the collapse split: each half independently derives its own starting\n // count from this one shared parse (see `gutters.ts`'s `resolveGutterColumns`).\n const notation = useMemo(() => parseNotation(code, notationEnabled), [code, notationEnabled])\n\n const preClassName = cn(\"overflow-x-auto py-3 text-sm leading-relaxed font-mono\", classNames?.pre)\n\n return (\n <CodeBlockChrome\n code={code}\n isCollapsible={isCollapsible}\n className={className}\n classNames={classNames}\n headContent={\n <HighlightedPre\n code={headCode}\n lang={language}\n themes={themes}\n tags={tags}\n gutters={gutters}\n notation={notation}\n transformers={transformers}\n className={preClassName}\n />\n }\n tailContent={\n isCollapsible && (\n <HighlightedPre\n code={tailCode}\n lang={language}\n themes={themes}\n tags={tags}\n gutters={gutters}\n notation={notation}\n lineOffset={collapsedLines}\n transformers={transformers}\n className={preClassName}\n />\n )\n }\n {...chromeProps}\n />\n )\n}\n\n/** `CodeBlock.Button` is `CodeBlockButton` itself (chrome.tsx) — attached\n * for discoverable composition when building a custom `controls` button\n * (`<CodeBlock.Button>`), mirroring `Code.Mark`'s same \"attach, don't\n * reimplement\" pattern. Still independently exported at\n * `@42/ui-react/code-block` for a bare import. `CodeBlock.Static` is\n * attached separately, from `index.ts` — see its own doc comment for why\n * (it's an async Server Component; not safe to import into this\n * `\"use client\"` file). */\nexport const CodeBlock = Object.assign(CodeBlockComponent, { Button: CodeBlockButton })\n","import type { CodeBlockCounterGutterColumn } from \"./gutters\"\nimport type { CodeBlockTagStyle } from \"./highlighter\"\n\n/**\n * Trivial one-liners for the two most common `gutters`/`tags` configurations\n * — `CodeBlock` itself has no dedicated boolean prop for \"line numbers\" or\n * \"highlight a line\" (there's exactly one mechanism, `gutters`/`tags`); these\n * are just pre-built arguments to it, not special component behavior.\n */\n\n/** A plain sequential line-number column: `<CodeBlock gutters={[lineNumbers()]} />`. */\nexport function lineNumbers(options?: { startAt?: number }): CodeBlockCounterGutterColumn {\n return { kind: \"counter\", startAt: options?.startAt }\n}\n\n/**\n * A ready-made `tags` entry for `// [!code highlight]` (or a custom tag\n * name): `<CodeBlock tags={highlight()} />`. Defaults to the same\n * background `Mark` uses for its own unstyled highlight, for visual\n * consistency with the rest of the kit. Compose with a hand-written `tags`\n * object the same way as any other record: `tags={{ ...highlight(), removed: {...} }}`.\n */\nexport function highlight(\n options?: ({ tag?: string } & CodeBlockTagStyle) | undefined,\n): Record<string, CodeBlockTagStyle> {\n const { tag = \"highlight\", ...style } = options ?? {}\n return { [tag]: { background: \"yellow\", ...style } }\n}\n","import {\n CodeBlockButton,\n type CodeBlockButtonProps,\n type CodeBlockClassNames,\n type CodeBlockIconSlot,\n type CodeBlockIcons,\n type CodeBlockTranslations,\n} from \"./chrome\"\nimport { CodeBlock as CodeBlockBase, type CodeBlockProps } from \"./code-block\"\nimport type {\n CodeBlockContentGutterColumn,\n CodeBlockCounterGutterColumn,\n CodeBlockGutterColumn,\n} from \"./gutters\"\nimport { type CodeBlockTagStyle, registerLanguage, registerTheme } from \"./highlighter\"\nimport type { CodeBlockLanguage } from \"./languages\"\nimport { highlight, lineNumbers } from \"./presets\"\n// Extensionless, matching every other relative import in this package — the\n// compiled output needs a `.js` suffix here (Node ESM, \"type\": \"module\", is\n// strict about it on a relative import that survives unbundled — see\n// tsup.config.ts's `external` note), but writing it here would break this\n// monorepo's OWN dev-mode source resolution instead (apps/docs's tsconfig\n// aliases `@42/ui-react/*` straight to this package's `src/`, and Turbopack\n// resolving raw source doesn't do the \"`.js` maps to `.tsx`\" mapping tsup/tsc\n// do). tsup.config.ts's onSuccess step rewrites this specific import to add\n// the extension in the COMPILED dist output only, after the fact.\nimport { CodeBlockStatic, type CodeBlockStaticProps } from \"./static\"\n\n/**\n * `CodeBlock.Static` is attached here, not inside `code-block.tsx` itself\n * — see `CodeBlockStatic`'s own doc comment (`static.tsx`) for why: it's an\n * async Server Component, and `code-block.tsx` is `\"use client\"`, which\n * can't import an async component without breaking the Client/Server\n * boundary (a Client Component's render can never `await`). This file\n * carries no directive of its own, so it can safely compose the\n * `\"use client\"` `CodeBlock` and the Server-Component-only\n * `CodeBlockStatic` under the one object consumers import.\n */\nexport const CodeBlock = Object.assign(CodeBlockBase, { Static: CodeBlockStatic })\n\nexport {\n CodeBlockButton,\n type CodeBlockButtonProps,\n type CodeBlockClassNames,\n type CodeBlockContentGutterColumn,\n type CodeBlockCounterGutterColumn,\n type CodeBlockGutterColumn,\n type CodeBlockIconSlot,\n type CodeBlockIcons,\n type CodeBlockLanguage,\n type CodeBlockProps,\n type CodeBlockStaticProps,\n type CodeBlockTagStyle,\n type CodeBlockTranslations,\n highlight,\n lineNumbers,\n registerLanguage,\n registerTheme,\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import type { LanguageRegistration } from "shiki";
2
+ type LanguageLoader = () => Promise<{
3
+ default: LanguageRegistration[];
4
+ }>;
5
+ /**
6
+ * The grammars `CodeBlock` can load by name — a deliberately finite map.
7
+ *
8
+ * Each entry is a separate dynamic import, so a consumer's bundler emits one
9
+ * chunk per grammar here and nothing more. Shiki's full bundle registers
10
+ * ~300 of them (plus the Oniguruma WASM), and every app depending on the kit
11
+ * paid to emit and parse all of them even when it highlighted two languages.
12
+ *
13
+ * Aliases point to the same loader as their grammar: loading it registers
14
+ * Shiki's own aliases too, so `ts` and `typescript` resolve to one grammar.
15
+ * Anything not listed is added by the caller through `registerLanguage`.
16
+ */
17
+ export declare const LANGUAGES: {
18
+ c: () => Promise<typeof import("shiki/dist/langs/c.mjs")>;
19
+ cpp: () => Promise<typeof import("shiki/dist/langs/cpp.mjs")>;
20
+ "c++": () => Promise<typeof import("shiki/dist/langs/cpp.mjs")>;
21
+ python: () => Promise<typeof import("shiki/dist/langs/python.mjs")>;
22
+ py: () => Promise<typeof import("shiki/dist/langs/python.mjs")>;
23
+ shellscript: () => Promise<typeof import("shiki/dist/langs/shellscript.mjs")>;
24
+ bash: () => Promise<typeof import("shiki/dist/langs/shellscript.mjs")>;
25
+ sh: () => Promise<typeof import("shiki/dist/langs/shellscript.mjs")>;
26
+ shell: () => Promise<typeof import("shiki/dist/langs/shellscript.mjs")>;
27
+ zsh: () => Promise<typeof import("shiki/dist/langs/shellscript.mjs")>;
28
+ javascript: () => Promise<typeof import("shiki/dist/langs/javascript.mjs")>;
29
+ js: () => Promise<typeof import("shiki/dist/langs/javascript.mjs")>;
30
+ cjs: () => Promise<typeof import("shiki/dist/langs/javascript.mjs")>;
31
+ mjs: () => Promise<typeof import("shiki/dist/langs/javascript.mjs")>;
32
+ typescript: () => Promise<typeof import("shiki/dist/langs/typescript.mjs")>;
33
+ ts: () => Promise<typeof import("shiki/dist/langs/typescript.mjs")>;
34
+ cts: () => Promise<typeof import("shiki/dist/langs/typescript.mjs")>;
35
+ mts: () => Promise<typeof import("shiki/dist/langs/typescript.mjs")>;
36
+ jsx: () => Promise<typeof import("shiki/dist/langs/jsx.mjs")>;
37
+ tsx: () => Promise<typeof import("shiki/dist/langs/tsx.mjs")>;
38
+ json: () => Promise<typeof import("shiki/dist/langs/json.mjs")>;
39
+ yaml: () => Promise<typeof import("shiki/dist/langs/yaml.mjs")>;
40
+ yml: () => Promise<typeof import("shiki/dist/langs/yaml.mjs")>;
41
+ markdown: () => Promise<typeof import("shiki/dist/langs/markdown.mjs")>;
42
+ md: () => Promise<typeof import("shiki/dist/langs/markdown.mjs")>;
43
+ html: () => Promise<typeof import("shiki/dist/langs/html.mjs")>;
44
+ css: () => Promise<typeof import("shiki/dist/langs/css.mjs")>;
45
+ sql: () => Promise<typeof import("shiki/dist/langs/sql.mjs")>;
46
+ go: () => Promise<typeof import("shiki/dist/langs/go.mjs")>;
47
+ rust: () => Promise<typeof import("shiki/dist/langs/rust.mjs")>;
48
+ rs: () => Promise<typeof import("shiki/dist/langs/rust.mjs")>;
49
+ java: () => Promise<typeof import("shiki/dist/langs/java.mjs")>;
50
+ make: () => Promise<typeof import("shiki/dist/langs/make.mjs")>;
51
+ makefile: () => Promise<typeof import("shiki/dist/langs/make.mjs")>;
52
+ docker: () => Promise<typeof import("shiki/dist/langs/docker.mjs")>;
53
+ dockerfile: () => Promise<typeof import("shiki/dist/langs/docker.mjs")>;
54
+ diff: () => Promise<typeof import("shiki/dist/langs/diff.mjs")>;
55
+ };
56
+ /** A language `CodeBlock` resolves by name: a bundled id or alias, `"text"`,
57
+ * or any name registered through `registerLanguage`. */
58
+ export type CodeBlockLanguage = keyof typeof LANGUAGES | "text" | (string & {});
59
+ export declare function languageLoader(lang: string): LanguageLoader | undefined;
60
+ export {};
61
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAEjD,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,oBAAoB,EAAE,CAAA;CAAE,CAAC,CAAA;AAExE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCoB,CAAA;AAE1C;yDACyD;AACzD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAE/E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEvE"}
@@ -4,9 +4,10 @@ import type { WithTestId } from "../../lib/test-id";
4
4
  import { type CodeBlockClassNames, type CodeBlockIcons, type CodeBlockTranslations } from "./chrome";
5
5
  import type { CodeBlockGutterColumn } from "./gutters";
6
6
  import { type CodeBlockTagStyle } from "./highlighter";
7
+ import type { CodeBlockLanguage } from "./languages";
7
8
  export type CodeBlockStaticProps = WithTestId & {
8
9
  code: string;
9
- language?: string;
10
+ language?: CodeBlockLanguage;
10
11
  themes?: {
11
12
  light: string;
12
13
  dark: string;
@@ -1 +1 @@
1
- {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/static.tsx"],"names":[],"mappings":"AAAA,OAA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gBAAgB,EAAE,CAAA;IACjC,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,SAAS,CAAA;IAEjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IAEnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qBAAqB;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,iCAAiC;IACjC,KAAK,CAAC,EAAE,cAAc,CAAA;IAEtB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC,CAAA;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,QAAQ,EAAE,eAAsB,EAChC,cAAc,EACd,SAAS,EACT,UAAU,EACV,GAAG,WAAW,EACf,EAAE,oBAAoB,wCAqCtB"}
@@ -14,6 +14,25 @@ function cn(...inputs) {
14
14
  return twMerge(clsx(inputs));
15
15
  }
16
16
 
17
+ // src/lib/dev-warn.ts
18
+ function isProduction() {
19
+ try {
20
+ return process.env.NODE_ENV === "production";
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+ function devWarn(message) {
26
+ if (isProduction()) return;
27
+ console.warn(message);
28
+ }
29
+ var warned = /* @__PURE__ */ new Set();
30
+ function devWarnOnce(message) {
31
+ if (isProduction() || warned.has(message)) return;
32
+ warned.add(message);
33
+ devWarn(message);
34
+ }
35
+
17
36
  // src/components/code-block/gutters.ts
18
37
  function countNonSkipped(lines, skip) {
19
38
  let n = 0;
@@ -120,6 +139,50 @@ function resolveGutterColumns(gutters, notation, headLineOffset) {
120
139
  };
121
140
  }
122
141
 
142
+ // src/components/code-block/languages.ts
143
+ var LANGUAGES = {
144
+ c: () => import('shiki/langs/c.mjs'),
145
+ cpp: () => import('shiki/langs/cpp.mjs'),
146
+ "c++": () => import('shiki/langs/cpp.mjs'),
147
+ python: () => import('shiki/langs/python.mjs'),
148
+ py: () => import('shiki/langs/python.mjs'),
149
+ shellscript: () => import('shiki/langs/shellscript.mjs'),
150
+ bash: () => import('shiki/langs/shellscript.mjs'),
151
+ sh: () => import('shiki/langs/shellscript.mjs'),
152
+ shell: () => import('shiki/langs/shellscript.mjs'),
153
+ zsh: () => import('shiki/langs/shellscript.mjs'),
154
+ javascript: () => import('shiki/langs/javascript.mjs'),
155
+ js: () => import('shiki/langs/javascript.mjs'),
156
+ cjs: () => import('shiki/langs/javascript.mjs'),
157
+ mjs: () => import('shiki/langs/javascript.mjs'),
158
+ typescript: () => import('shiki/langs/typescript.mjs'),
159
+ ts: () => import('shiki/langs/typescript.mjs'),
160
+ cts: () => import('shiki/langs/typescript.mjs'),
161
+ mts: () => import('shiki/langs/typescript.mjs'),
162
+ jsx: () => import('shiki/langs/jsx.mjs'),
163
+ tsx: () => import('shiki/langs/tsx.mjs'),
164
+ json: () => import('shiki/langs/json.mjs'),
165
+ yaml: () => import('shiki/langs/yaml.mjs'),
166
+ yml: () => import('shiki/langs/yaml.mjs'),
167
+ markdown: () => import('shiki/langs/markdown.mjs'),
168
+ md: () => import('shiki/langs/markdown.mjs'),
169
+ html: () => import('shiki/langs/html.mjs'),
170
+ css: () => import('shiki/langs/css.mjs'),
171
+ sql: () => import('shiki/langs/sql.mjs'),
172
+ go: () => import('shiki/langs/go.mjs'),
173
+ rust: () => import('shiki/langs/rust.mjs'),
174
+ rs: () => import('shiki/langs/rust.mjs'),
175
+ java: () => import('shiki/langs/java.mjs'),
176
+ make: () => import('shiki/langs/make.mjs'),
177
+ makefile: () => import('shiki/langs/make.mjs'),
178
+ docker: () => import('shiki/langs/docker.mjs'),
179
+ dockerfile: () => import('shiki/langs/docker.mjs'),
180
+ diff: () => import('shiki/langs/diff.mjs')
181
+ };
182
+ function languageLoader(lang) {
183
+ return Object.hasOwn(LANGUAGES, lang) ? LANGUAGES[lang] : void 0;
184
+ }
185
+
123
186
  // src/components/code-block/notation.ts
124
187
  var MARKER_SOURCE = String.raw`\[!code\s+([A-Za-z][\w-]*)(?::((?:\\.|[^:\]])*))?\s*\]`;
125
188
  var MARKER_RE = new RegExp(MARKER_SOURCE, "g");
@@ -214,8 +277,17 @@ var DEFAULT_THEMES = { light: "github-light", dark: "github-dark-default" };
214
277
  var highlighterPromise = null;
215
278
  function getHighlighter() {
216
279
  if (!highlighterPromise) {
217
- highlighterPromise = import('shiki').then(
218
- ({ createHighlighter }) => createHighlighter({ themes: [DEFAULT_THEMES.light, DEFAULT_THEMES.dark], langs: [] })
280
+ highlighterPromise = Promise.all([
281
+ import('shiki/core'),
282
+ import('shiki/engine/javascript'),
283
+ import('shiki/themes/github-light.mjs'),
284
+ import('shiki/themes/github-dark-default.mjs')
285
+ ]).then(
286
+ ([{ createHighlighterCore }, { createJavaScriptRegexEngine }, light, dark]) => createHighlighterCore({
287
+ themes: [light.default, dark.default],
288
+ langs: [],
289
+ engine: createJavaScriptRegexEngine()
290
+ })
219
291
  );
220
292
  }
221
293
  return highlighterPromise;
@@ -313,17 +385,34 @@ function buildCodeBlockTransformer(opts, notation) {
313
385
  }
314
386
  };
315
387
  }
388
+ var PLAIN_LANGUAGES = /* @__PURE__ */ new Set(["text", "txt", "plain", "plaintext"]);
389
+ async function resolveLanguage(highlighter, lang) {
390
+ if (PLAIN_LANGUAGES.has(lang) || highlighter.getLoadedLanguages().includes(lang)) return lang;
391
+ const loader = languageLoader(lang);
392
+ if (loader) {
393
+ await highlighter.loadLanguage((await loader()).default);
394
+ return lang;
395
+ }
396
+ devWarnOnce(
397
+ `CodeBlock: unknown language "${lang}", rendering as plain text. Register its grammar with registerLanguage() first.`
398
+ );
399
+ return "text";
400
+ }
401
+ function resolveTheme(highlighter, name, slot) {
402
+ if (highlighter.getLoadedThemes().includes(name)) return name;
403
+ devWarnOnce(
404
+ `CodeBlock: unknown theme "${name}", using "${DEFAULT_THEMES[slot]}" instead. Register it with registerTheme() first.`
405
+ );
406
+ return DEFAULT_THEMES[slot];
407
+ }
316
408
  async function highlightCode(code, opts = {}) {
317
- const lang = opts.lang ?? "text";
318
- const themes = opts.themes ?? DEFAULT_THEMES;
319
409
  const highlighter = await getHighlighter();
320
410
  const notation = opts.notation ?? parseNotation(code);
321
- await Promise.all(
322
- [themes.light, themes.dark].filter((t) => !highlighter.getLoadedThemes().includes(t)).map((t) => highlighter.loadTheme(t))
323
- );
324
- if (!highlighter.getLoadedLanguages().includes(lang)) {
325
- await highlighter.loadLanguage(lang);
326
- }
411
+ const lang = await resolveLanguage(highlighter, opts.lang ?? "text");
412
+ const themes = {
413
+ light: resolveTheme(highlighter, opts.themes?.light ?? DEFAULT_THEMES.light, "light"),
414
+ dark: resolveTheme(highlighter, opts.themes?.dark ?? DEFAULT_THEMES.dark, "dark")
415
+ };
327
416
  return highlighter.codeToHtml(code, {
328
417
  lang,
329
418
  themes,