@42-central/ui-react 0.24.0 → 0.26.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.
- package/dist/{chunk-YWTOW7PZ.js → chunk-276RL7FX.js} +10 -10
- package/dist/{chunk-YWTOW7PZ.js.map → chunk-276RL7FX.js.map} +1 -1
- package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
- package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
- package/dist/{chunk-YPFSRZ3T.js → chunk-2NTCQIRP.js} +5 -5
- package/dist/{chunk-YPFSRZ3T.js.map → chunk-2NTCQIRP.js.map} +1 -1
- package/dist/{chunk-D3JYDAUZ.js → chunk-2TZU4LSX.js} +4 -4
- package/dist/{chunk-D3JYDAUZ.js.map → chunk-2TZU4LSX.js.map} +1 -1
- package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
- package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
- package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
- package/dist/chunk-7247WBTV.js.map +1 -0
- package/dist/{chunk-F2FSHVO5.js → chunk-7B44J3CF.js} +7 -7
- package/dist/{chunk-F2FSHVO5.js.map → chunk-7B44J3CF.js.map} +1 -1
- package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
- package/dist/chunk-7E7JNWOC.js.map +1 -0
- package/dist/{chunk-7AQ4MN4M.js → chunk-7OGZT7U2.js} +14 -6
- package/dist/chunk-7OGZT7U2.js.map +1 -0
- package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
- package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
- package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
- package/dist/chunk-BMEJBY6H.js.map +1 -0
- package/dist/{chunk-DHJB4UJD.js → chunk-DMI4KS32.js} +5 -5
- package/dist/{chunk-DHJB4UJD.js.map → chunk-DMI4KS32.js.map} +1 -1
- package/dist/{chunk-FB2G4LNH.js → chunk-DSZF2TW6.js} +7 -7
- package/dist/{chunk-FB2G4LNH.js.map → chunk-DSZF2TW6.js.map} +1 -1
- package/dist/{chunk-N66NC6QK.js → chunk-E3XLWMEB.js} +3 -3
- package/dist/{chunk-N66NC6QK.js.map → chunk-E3XLWMEB.js.map} +1 -1
- package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
- package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
- package/dist/chunk-F374BNL4.js +129 -0
- package/dist/chunk-F374BNL4.js.map +1 -0
- package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
- package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
- package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
- package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
- package/dist/{chunk-HRNWWL3Y.js → chunk-J2NW7JID.js} +61 -29
- package/dist/chunk-J2NW7JID.js.map +1 -0
- package/dist/{chunk-MRAJ45IM.js → chunk-JDPVD2YE.js} +5 -5
- package/dist/{chunk-MRAJ45IM.js.map → chunk-JDPVD2YE.js.map} +1 -1
- package/dist/{chunk-SZEOTXRZ.js → chunk-JFB6O7IY.js} +5 -5
- package/dist/{chunk-SZEOTXRZ.js.map → chunk-JFB6O7IY.js.map} +1 -1
- package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
- package/dist/chunk-KKLCHLCZ.js.map +1 -0
- package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
- package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
- package/dist/chunk-LJVIZNPE.js +9 -0
- package/dist/chunk-LJVIZNPE.js.map +1 -0
- package/dist/{chunk-HQPU73WV.js → chunk-LYGOFMXJ.js} +3 -3
- package/dist/{chunk-HQPU73WV.js.map → chunk-LYGOFMXJ.js.map} +1 -1
- package/dist/{chunk-JVG5ISPT.js → chunk-N42EFOML.js} +4 -4
- package/dist/{chunk-JVG5ISPT.js.map → chunk-N42EFOML.js.map} +1 -1
- package/dist/{chunk-C4NFRSOR.js → chunk-NF2PBGD3.js} +38 -25
- package/dist/chunk-NF2PBGD3.js.map +1 -0
- package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
- package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
- package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
- package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
- package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
- package/dist/chunk-PBSVX5DB.js.map +1 -0
- package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
- package/dist/chunk-PEHFWGTT.js.map +1 -0
- package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
- package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
- package/dist/{chunk-IRNF274I.js → chunk-PT22KEVD.js} +5 -5
- package/dist/{chunk-IRNF274I.js.map → chunk-PT22KEVD.js.map} +1 -1
- package/dist/{chunk-OZMSXYBX.js → chunk-QEAF57ZQ.js} +4 -4
- package/dist/{chunk-OZMSXYBX.js.map → chunk-QEAF57ZQ.js.map} +1 -1
- package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
- package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
- package/dist/{chunk-E5H3YWZV.js → chunk-SOUDKESO.js} +15 -8
- package/dist/chunk-SOUDKESO.js.map +1 -0
- package/dist/{chunk-4FEOMQYR.js → chunk-THGJLR5S.js} +6 -6
- package/dist/{chunk-4FEOMQYR.js.map → chunk-THGJLR5S.js.map} +1 -1
- package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
- package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
- package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
- package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
- package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
- package/dist/chunk-X6DESK37.js.map +1 -0
- package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
- package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
- package/dist/{chunk-O7LS6OZR.js → chunk-YMVUQ2L7.js} +4 -4
- package/dist/{chunk-O7LS6OZR.js.map → chunk-YMVUQ2L7.js.map} +1 -1
- package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
- package/dist/chunk-ZVECQBGG.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/ambient-background/index.js +14 -26
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/ambient-background/starfield.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +55 -10
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +300 -39
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +5 -5
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.js +12 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -2
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/button-multi-select/index.js +4 -4
- package/dist/components/button-select/button-select-control.d.ts +4 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +4 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +4 -4
- package/dist/components/calendar/index.js +4 -4
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +12 -12
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/checkbox/checkbox.d.ts +3 -2
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/clipboard/index.js +3 -3
- package/dist/components/code-block/chrome.js +3 -3
- package/dist/components/code-block/code-block.d.ts +6 -3
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/highlighter.d.ts +16 -15
- package/dist/components/code-block/highlighter.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.d.ts.map +1 -1
- package/dist/components/code-block/index.js +85 -14
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/languages.d.ts +61 -0
- package/dist/components/code-block/languages.d.ts.map +1 -0
- package/dist/components/code-block/static.d.ts +2 -1
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js +99 -10
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/combobox/index.js +5 -5
- package/dist/components/combobox-list/index.js +7 -7
- package/dist/components/compare/index.js +2 -2
- package/dist/components/data-table/index.js +32 -32
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +14 -14
- package/dist/components/download-button/index.js +2 -2
- package/dist/components/drawer/index.js +5 -5
- package/dist/components/field/field.d.ts +3 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-item/index.js +5 -5
- package/dist/components/file-preview/index.js +5 -5
- package/dist/components/file-trigger/index.js +2 -2
- package/dist/components/file-upload/index.js +6 -6
- package/dist/components/gallery/index.js +2 -2
- package/dist/components/geodesic/badge-frame.d.ts +13 -1
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
- package/dist/components/geodesic/exam-badge.d.ts +4 -1
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
- package/dist/components/geodesic/geometry.d.ts +14 -9
- package/dist/components/geodesic/geometry.d.ts.map +1 -1
- package/dist/components/geodesic/index.js +62 -23
- package/dist/components/geodesic/index.js.map +1 -1
- package/dist/components/geodesic/status.d.ts +8 -6
- package/dist/components/geodesic/status.d.ts.map +1 -1
- package/dist/components/geodesic/styles.css +15 -2
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +24 -9
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +15 -6
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +8 -8
- package/dist/components/menu/index.js +4 -4
- package/dist/components/modal/index.js +5 -5
- package/dist/components/multi-combobox-list/index.js +7 -7
- package/dist/components/multi-select/index.js +8 -8
- package/dist/components/nav-link/index.js +5 -1
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +5 -1
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/number-input/index.js +5 -5
- package/dist/components/overlays/index.js +7 -7
- package/dist/components/password-input/index.js +3 -3
- package/dist/components/photo-capture/index.js +16 -16
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/index.js +1 -1
- package/dist/components/schedule/index.js +7 -7
- package/dist/components/segment-group/index.js +4 -4
- package/dist/components/segment-group/segment-group.d.ts +6 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +6 -6
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spotlight/index.js +11 -11
- package/dist/components/switch/index.js +14 -19
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +1 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +3 -3
- package/dist/components/tabs/tabs-data.d.ts +4 -1
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +4 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +7 -7
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
- package/dist/components/time-input/index.js +9 -9
- package/dist/components/tree-multi-select/index.js +8 -8
- package/dist/components/tree-select/index.js +5 -5
- package/dist/index.js +4 -4
- package/dist/lib/sidebar-rail.d.ts +21 -0
- package/dist/lib/sidebar-rail.d.ts.map +1 -0
- package/dist/theme.css +35 -35
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/action-icon/action-icon.tsx +3 -1
- package/src/components/ambient-background/starfield.tsx +18 -43
- package/src/components/app-shell/app-shell.test.tsx +430 -5
- package/src/components/app-shell/app-shell.tsx +484 -24
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/avatar/avatar.test.tsx +12 -0
- package/src/components/avatar/avatar.tsx +9 -0
- package/src/components/badge/badge.tsx +11 -6
- package/src/components/button/button.tsx +1 -1
- package/src/components/button-group/button-group.test.tsx +24 -0
- package/src/components/button-group/button-group.tsx +21 -4
- package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
- package/src/components/button-select/button-select-control.tsx +5 -0
- package/src/components/button-select/button-select.test.tsx +25 -0
- package/src/components/button-select/button-select.tsx +13 -2
- package/src/components/card/card.tsx +10 -9
- package/src/components/checkbox/checkbox.test.tsx +17 -9
- package/src/components/checkbox/checkbox.tsx +26 -27
- package/src/components/choice-card-group/choice-card-group.tsx +3 -3
- package/src/components/code-block/code-block.tsx +7 -4
- package/src/components/code-block/highlighter.test.ts +79 -1
- package/src/components/code-block/highlighter.ts +76 -30
- package/src/components/code-block/index.ts +2 -0
- package/src/components/code-block/languages.ts +63 -0
- package/src/components/code-block/static.tsx +2 -1
- package/src/components/data-table/data-table-pagination.tsx +5 -5
- package/src/components/data-table/data-table-stack.tsx +2 -2
- package/src/components/field/field.tsx +14 -0
- package/src/components/geodesic/badge-frame.tsx +67 -13
- package/src/components/geodesic/exam-badge.tsx +8 -4
- package/src/components/geodesic/geometry.ts +8 -6
- package/src/components/geodesic/status.test.ts +11 -2
- package/src/components/geodesic/status.ts +11 -7
- package/src/components/geodesic/styles.css +15 -2
- package/src/components/indicator/indicator.test.tsx +45 -0
- package/src/components/indicator/indicator.tsx +40 -13
- package/src/components/kbd/kbd.tsx +2 -1
- package/src/components/nav-link/nav-link.test.tsx +121 -1
- package/src/components/nav-link/nav-link.tsx +78 -29
- package/src/components/segment-group/segment-group.test.tsx +22 -0
- package/src/components/segment-group/segment-group.tsx +35 -19
- package/src/components/switch/switch.test.tsx +15 -0
- package/src/components/switch/switch.tsx +27 -27
- package/src/components/table/table.test.tsx +1 -1
- package/src/components/table/table.tsx +14 -11
- package/src/components/tabs/tabs-data.tsx +5 -1
- package/src/components/tabs/tabs.test.tsx +28 -0
- package/src/components/tabs/tabs.tsx +14 -4
- package/src/components/theme-icon/theme-icon.tsx +46 -12
- package/src/lib/sidebar-rail.ts +24 -0
- package/src/theme.css +35 -35
- package/src/theme.test.ts +0 -1
- package/dist/chunk-2MXWEIMD.js.map +0 -1
- package/dist/chunk-6VYGK3Q3.js.map +0 -1
- package/dist/chunk-7AQ4MN4M.js.map +0 -1
- package/dist/chunk-7CNDZZZ6.js +0 -95
- package/dist/chunk-7CNDZZZ6.js.map +0 -1
- package/dist/chunk-BE2LWUHY.js.map +0 -1
- package/dist/chunk-C4NFRSOR.js.map +0 -1
- package/dist/chunk-DT6LKNZF.js.map +0 -1
- package/dist/chunk-E5H3YWZV.js.map +0 -1
- package/dist/chunk-F342ZT7O.js.map +0 -1
- package/dist/chunk-HRNWWL3Y.js.map +0 -1
- package/dist/chunk-MW42XVPD.js.map +0 -1
- package/dist/chunk-SVKN5ZHX.js.map +0 -1
- package/dist/chunk-VD6PB3VA.js.map +0 -1
|
@@ -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 =
|
|
218
|
-
(
|
|
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
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/cn.ts","../../../src/components/code-block/gutters.ts","../../../src/components/code-block/notation.ts","../../../src/components/code-block/highlighter.ts","../../../src/components/code-block/static.tsx"],"names":["jsx"],"mappings":";;;;;;AA0BA,IAAM,UAAU,mBAAA,CAAqC;AAAA,EACnD,MAAA,EAAQ;AAAA,IACN,WAAA,EAAa,EAAE,eAAA,EAAiB,CAAC,WAAW,CAAA,EAAE;AAAA,IAC9C,KAAA,EAAO,EAAE,MAAA,EAAQ,CAAC,KAAA,EAAO,QAAA,EAAU,aAAA,EAAe,OAAA,EAAS,MAAA,EAAQ,OAAA,EAAS,MAAM,CAAA;AAAE;AAExF,CAAC,CAAA;AAEM,SAAS,MAAM,MAAA,EAA8B;AAClD,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;;;ACmDA,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,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A;AAAA,MACA,aAAA;AAAA,MACA,SAAA;AAAA,MACA,UAAA;AAAA,MACA,6BAAa,GAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAM,QAAA,EAAU,WAAW,YAAA,EAAc,CAAA;AAAA,MACjE,WAAA,EAAa,YAAY,IAAA,oBAAQ,GAAA,CAAC,aAAU,IAAA,EAAM,QAAA,EAAU,WAAW,YAAA,EAAc,CAAA;AAAA,MACpF,GAAG;AAAA;AAAA,GACN;AAEJ","file":"static.js","sourcesContent":["/**\n * The single class-merging utility for the entire UI kit.\n *\n * Combines:\n * - clsx — conditional class composition (objects, arrays, falsy filtering)\n * - tailwind-merge — last-wins conflict resolution for Tailwind utility classes\n *\n * Consumers should never reach for raw template literals or hand-rolled\n * concatenation; route every dynamic class through `cn` for predictable\n * override behavior.\n */\n\nimport { type ClassValue, clsx } from \"clsx\"\nimport { extendTailwindMerge } from \"tailwind-merge\"\n\n/**\n * The kit's own `@utility` classes (theme.css) are unknown to tailwind-merge,\n * which guesses from the prefix: `text-trim` reads as a text *color*, so it\n * and a real color class silently knocked each other out. Registering it as\n * its own group makes it conflict only with itself.\n *\n * The kit's `--radius-*` tokens beyond the t-shirt scale are unknown too, so\n * a component default like `rounded-card` survived a consumer's `rounded-2xl`\n * and the stylesheet's order picked the winner. Listing them in the radius\n * scale makes the consumer's class replace the default.\n */\nconst twMerge = extendTailwindMerge<\"text-box-trim\">({\n extend: {\n classGroups: { \"text-box-trim\": [\"text-trim\"] },\n theme: { radius: [\"xxs\", \"button\", \"action-icon\", \"badge\", \"card\", \"input\", \"pill\"] },\n },\n})\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs))\n}\n","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","import type { ReactNode } from \"react\"\nimport type { ShikiTransformer } from \"shiki\"\nimport { cn } from \"../../lib/cn\"\nimport type { WithTestId } from \"../../lib/test-id\"\n// Extensionless — see the matching comment on code-block/index.ts's own\n// `from \"./static\"` for why (Node ESM needs `.js` in the compiled dist\n// output; this monorepo's own dev-mode source resolution needs it absent\n// here). tsup.config.ts's onSuccess step adds the extension post-build.\nimport {\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 { parseNotation } from \"./notation\"\n\nexport type CodeBlockStaticProps = WithTestId & {\n code: string\n language?: string\n themes?: { light: string; dark: string }\n tags?: Record<string, CodeBlockTagStyle>\n gutters?: CodeBlockGutterColumn[]\n transformers?: ShikiTransformer[]\n /** @default true */\n notation?: boolean\n title?: ReactNode\n\n /** @default true */\n withCopyButton?: boolean\n onCopy?: () => void\n\n collapsedLines?: number\n /** @default false */\n defaultExpanded?: boolean\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n /** See `CodeBlock`'s `icons`. */\n icons?: CodeBlockIcons\n\n controls?: ReactNode\n translations?: Partial<CodeBlockTranslations>\n className?: string\n classNames?: CodeBlockClassNames\n}\n\n/** Renders the already-highlighted HTML `highlightCode` produced — the\n * static counterpart of `code-block.tsx`'s `HighlightedPre`, minus the\n * loading-fallback branch: by the time this renders, the `await` in\n * `CodeBlockStatic` below has already resolved, so there's never a\n * not-yet-highlighted state to fall back to. */\n// `dir=\"ltr\"`: source code reads left-to-right on an RTL page too — the\n// chrome (title, toolbar) still follows the page direction.\nfunction StaticPre({ html, className }: { html: string; className?: string }) {\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\n/**\n * `CodeBlock.Static` — an async React Server Component that `await`s\n * `highlightCode` directly during the server render, instead of `CodeBlock`\n * (code-block.tsx)'s client-side effect. For a page that's statically\n * generated (as this kit's own docs pages are), that bakes the highlighted\n * markup into the build output: zero client JS spent on Shiki at all, no\n * loading flash, real SSR — not just streamed-in, actually static.\n *\n * The tradeoff this makes: no reactivity. `code`/`tags`/etc. are resolved\n * once, server-side, at render time — there's no client-side re-highlight\n * if they change later (they can't, from a Server Component's own\n * perspective; a `code` value from live client state needs `CodeBlock`\n * instead). Use this for anything with a fixed, known-at-render-time\n * `code` (docs, MDX, a blog post's snippets); reach for `CodeBlock` itself\n * for anything editable/dynamic (a live playground).\n *\n * Deliberately NOT attached onto `CodeBlockComponent` (`code-block.tsx`)\n * itself — that file is `\"use client\"`, and an async Server Component\n * being imported into a Client Component's own module is exactly the\n * shape React Server Components don't support (a Client Component's render\n * can't `await`, on the server or the client). `CodeBlock.Static` is\n * attached in `index.ts` instead, a plain barrel with no directive of its\n * own, which is the well-supported way to compose a `\"use client\"` export\n * and a Server-Component-only export under one object.\n *\n * Requires a React Server Components-capable framework (e.g. Next.js App\n * Router) to actually run as a Server Component — a plain client-rendered\n * React app (Vite, CRA, Next Pages Router) has no runtime that knows how to\n * execute an async function component at all.\n */\nexport async function CodeBlockStatic({\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}: CodeBlockStaticProps) {\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 // Same \"parse once over the full source, share across both halves\" reason\n // as CodeBlockComponent's own `notation` — see its comment.\n const notation = parseNotation(code, notationEnabled)\n\n const preClassName = cn(\"overflow-x-auto py-3 text-sm leading-relaxed font-mono\", classNames?.pre)\n\n const [headHtml, tailHtml] = await Promise.all([\n highlightCode(headCode, { lang: language, themes, tags, gutters, notation, transformers }),\n isCollapsible\n ? highlightCode(tailCode, {\n lang: language,\n themes,\n tags,\n gutters,\n notation,\n lineOffset: collapsedLines,\n transformers,\n })\n : null,\n ])\n\n return (\n <CodeBlockChrome\n code={code}\n isCollapsible={isCollapsible}\n className={className}\n classNames={classNames}\n headContent={<StaticPre html={headHtml} className={preClassName} />}\n tailContent={tailHtml != null && <StaticPre html={tailHtml} className={preClassName} />}\n {...chromeProps}\n />\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/cn.ts","../../../src/lib/dev-warn.ts","../../../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/static.tsx"],"names":["jsx"],"mappings":";;;;;;AA0BA,IAAM,UAAU,mBAAA,CAAqC;AAAA,EACnD,MAAA,EAAQ;AAAA,IACN,WAAA,EAAa,EAAE,eAAA,EAAiB,CAAC,WAAW,CAAA,EAAE;AAAA,IAC9C,KAAA,EAAO,EAAE,MAAA,EAAQ,CAAC,KAAA,EAAO,QAAA,EAAU,aAAA,EAAe,OAAA,EAAS,MAAA,EAAQ,OAAA,EAAS,MAAM,CAAA;AAAE;AAExF,CAAC,CAAA;AAEM,SAAS,MAAM,MAAA,EAA8B;AAClD,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;;;ACHA,SAAS,YAAA,GAAwB;AAC/B,EAAA,IAAI;AACF,IAAA,OAAO,OAAA,CAAA,GAAA,CAAA,QAAA,KAAyB,YAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEO,SAAS,QAAQ,OAAA,EAAuB;AAC7C,EAAA,IAAI,cAAa,EAAG;AACpB,EAAA,OAAA,CAAQ,KAAK,OAAO,CAAA;AACtB;AAEA,IAAM,MAAA,uBAAa,GAAA,EAAY;AAOxB,SAAS,YAAY,OAAA,EAAuB;AACjD,EAAA,IAAI,YAAA,EAAa,IAAK,MAAA,CAAO,GA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,SAAA;AAAA,MACA,UAAA;AAAA,MACA,6BAAa,GAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAM,QAAA,EAAU,WAAW,YAAA,EAAc,CAAA;AAAA,MACjE,WAAA,EAAa,YAAY,IAAA,oBAAQ,GAAA,CAAC,aAAU,IAAA,EAAM,QAAA,EAAU,WAAW,YAAA,EAAc,CAAA;AAAA,MACpF,GAAG;AAAA;AAAA,GACN;AAEJ","file":"static.js","sourcesContent":["/**\n * The single class-merging utility for the entire UI kit.\n *\n * Combines:\n * - clsx — conditional class composition (objects, arrays, falsy filtering)\n * - tailwind-merge — last-wins conflict resolution for Tailwind utility classes\n *\n * Consumers should never reach for raw template literals or hand-rolled\n * concatenation; route every dynamic class through `cn` for predictable\n * override behavior.\n */\n\nimport { type ClassValue, clsx } from \"clsx\"\nimport { extendTailwindMerge } from \"tailwind-merge\"\n\n/**\n * The kit's own `@utility` classes (theme.css) are unknown to tailwind-merge,\n * which guesses from the prefix: `text-trim` reads as a text *color*, so it\n * and a real color class silently knocked each other out. Registering it as\n * its own group makes it conflict only with itself.\n *\n * The kit's `--radius-*` tokens beyond the t-shirt scale are unknown too, so\n * a component default like `rounded-card` survived a consumer's `rounded-2xl`\n * and the stylesheet's order picked the winner. Listing them in the radius\n * scale makes the consumer's class replace the default.\n */\nconst twMerge = extendTailwindMerge<\"text-box-trim\">({\n extend: {\n classGroups: { \"text-box-trim\": [\"text-trim\"] },\n theme: { radius: [\"xxs\", \"button\", \"action-icon\", \"badge\", \"card\", \"input\", \"pill\"] },\n },\n})\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs))\n}\n","/**\n * Dev-mode-only warning helpers — the kit's pattern for runtime\n * misconfiguration checks (Schedule's `editable` prop was the first).\n *\n * The production gate lives in `isProduction()` and has three jobs:\n *\n * 1. Contain the LITERAL `process.env.NODE_ENV`. Bundlers (webpack/Next's\n * DefinePlugin, Vite, esbuild, Rollup's replace plugin) substitute only that\n * exact member expression. `process?.env?.NODE_ENV`, `globalThis.process`\n * or a destructured `env` are never replaced, so the warning would survive\n * into every consumer's production build — which is what the old gate did.\n * 2. Not throw without a bundler and without a `process` global (plain ESM in a\n * browser, Deno). Reading the literal inside `try` turns that\n * `ReferenceError` (or a `TypeError` for a `process` with no `env`) into\n * \"not production\", so the warning is logged, which is the right default\n * for code nobody built for production.\n * 3. Still warn in development and test.\n *\n * Why not `typeof process !== \"undefined\" && process.env.NODE_ENV === ...`:\n * the bundler replaces the second half with `\"production\"`, but on the client\n * there is still no `process` global, so the `typeof` half is false, the early\n * return never happens, and the warning logs in production anyway. Inside the\n * `try`, a production build reduces to `\"production\" === \"production\"`, and\n * the minifier drops the `console.warn` behind it.\n *\n * `process` is declared locally rather than pulling in `@types/node`, which\n * this otherwise browser-only package has no other reason to depend on. The\n * kit's own `dist` must keep the literal for consumers to replace; the shared\n * tsup factory (`@42/tsup-config`) defines it to itself for that reason.\n */\ndeclare const process: { env: { NODE_ENV?: string } }\n\nfunction isProduction(): boolean {\n try {\n return process.env.NODE_ENV === \"production\"\n } catch {\n return false\n }\n}\n\nexport function devWarn(message: string): void {\n if (isProduction()) return\n console.warn(message)\n}\n\nconst warned = new Set<string>()\n\n/**\n * `devWarn`, at most once per message for the page's lifetime. For a warning a\n * component would otherwise repeat on every render, such as a deprecated prop\n * that is still being passed.\n */\nexport function devWarnOnce(message: string): void {\n if (isProduction() || warned.has(message)) return\n warned.add(message)\n devWarn(message)\n}\n\n/**\n * Warns, once, that `component`'s `from` prop was renamed `to`. Call it where\n * the deprecated alias is read, guarded by the alias being set.\n */\nexport function warnRenamedProp(component: string, from: string, to: string): void {\n devWarnOnce(\n `${component}: \\`${from}\\` is deprecated, use \\`${to}\\`. It will be removed in the next minor.`,\n )\n}\n","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","import type { ReactNode } from \"react\"\nimport type { ShikiTransformer } from \"shiki\"\nimport { cn } from \"../../lib/cn\"\nimport type { WithTestId } from \"../../lib/test-id\"\n// Extensionless — see the matching comment on code-block/index.ts's own\n// `from \"./static\"` for why (Node ESM needs `.js` in the compiled dist\n// output; this monorepo's own dev-mode source resolution needs it absent\n// here). tsup.config.ts's onSuccess step adds the extension post-build.\nimport {\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 { parseNotation } from \"./notation\"\n\nexport type CodeBlockStaticProps = WithTestId & {\n code: string\n language?: CodeBlockLanguage\n themes?: { light: string; dark: string }\n tags?: Record<string, CodeBlockTagStyle>\n gutters?: CodeBlockGutterColumn[]\n transformers?: ShikiTransformer[]\n /** @default true */\n notation?: boolean\n title?: ReactNode\n\n /** @default true */\n withCopyButton?: boolean\n onCopy?: () => void\n\n collapsedLines?: number\n /** @default false */\n defaultExpanded?: boolean\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n /** See `CodeBlock`'s `icons`. */\n icons?: CodeBlockIcons\n\n controls?: ReactNode\n translations?: Partial<CodeBlockTranslations>\n className?: string\n classNames?: CodeBlockClassNames\n}\n\n/** Renders the already-highlighted HTML `highlightCode` produced — the\n * static counterpart of `code-block.tsx`'s `HighlightedPre`, minus the\n * loading-fallback branch: by the time this renders, the `await` in\n * `CodeBlockStatic` below has already resolved, so there's never a\n * not-yet-highlighted state to fall back to. */\n// `dir=\"ltr\"`: source code reads left-to-right on an RTL page too — the\n// chrome (title, toolbar) still follows the page direction.\nfunction StaticPre({ html, className }: { html: string; className?: string }) {\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\n/**\n * `CodeBlock.Static` — an async React Server Component that `await`s\n * `highlightCode` directly during the server render, instead of `CodeBlock`\n * (code-block.tsx)'s client-side effect. For a page that's statically\n * generated (as this kit's own docs pages are), that bakes the highlighted\n * markup into the build output: zero client JS spent on Shiki at all, no\n * loading flash, real SSR — not just streamed-in, actually static.\n *\n * The tradeoff this makes: no reactivity. `code`/`tags`/etc. are resolved\n * once, server-side, at render time — there's no client-side re-highlight\n * if they change later (they can't, from a Server Component's own\n * perspective; a `code` value from live client state needs `CodeBlock`\n * instead). Use this for anything with a fixed, known-at-render-time\n * `code` (docs, MDX, a blog post's snippets); reach for `CodeBlock` itself\n * for anything editable/dynamic (a live playground).\n *\n * Deliberately NOT attached onto `CodeBlockComponent` (`code-block.tsx`)\n * itself — that file is `\"use client\"`, and an async Server Component\n * being imported into a Client Component's own module is exactly the\n * shape React Server Components don't support (a Client Component's render\n * can't `await`, on the server or the client). `CodeBlock.Static` is\n * attached in `index.ts` instead, a plain barrel with no directive of its\n * own, which is the well-supported way to compose a `\"use client\"` export\n * and a Server-Component-only export under one object.\n *\n * Requires a React Server Components-capable framework (e.g. Next.js App\n * Router) to actually run as a Server Component — a plain client-rendered\n * React app (Vite, CRA, Next Pages Router) has no runtime that knows how to\n * execute an async function component at all.\n */\nexport async function CodeBlockStatic({\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}: CodeBlockStaticProps) {\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 // Same \"parse once over the full source, share across both halves\" reason\n // as CodeBlockComponent's own `notation` — see its comment.\n const notation = parseNotation(code, notationEnabled)\n\n const preClassName = cn(\"overflow-x-auto py-3 text-sm leading-relaxed font-mono\", classNames?.pre)\n\n const [headHtml, tailHtml] = await Promise.all([\n highlightCode(headCode, { lang: language, themes, tags, gutters, notation, transformers }),\n isCollapsible\n ? highlightCode(tailCode, {\n lang: language,\n themes,\n tags,\n gutters,\n notation,\n lineOffset: collapsedLines,\n transformers,\n })\n : null,\n ])\n\n return (\n <CodeBlockChrome\n code={code}\n isCollapsible={isCollapsible}\n className={className}\n classNames={classNames}\n headContent={<StaticPre html={headHtml} className={preClassName} />}\n tailContent={tailHtml != null && <StaticPre html={tailHtml} className={preClassName} />}\n {...chromeProps}\n />\n )\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { Combobox } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
2
|
+
export { Combobox } from '../../chunk-2NTCQIRP.js';
|
|
3
|
+
import '../../chunk-I4B3N3UX.js';
|
|
4
|
+
import '../../chunk-X6DESK37.js';
|
|
5
|
+
import '../../chunk-E3XLWMEB.js';
|
|
6
|
+
import '../../chunk-H7WOMZXO.js';
|
|
6
7
|
import '../../chunk-V6PY7C6S.js';
|
|
7
8
|
import '../../chunk-7P32XCEU.js';
|
|
8
|
-
import '../../chunk-H7WOMZXO.js';
|
|
9
9
|
import '../../chunk-PMUCGFY5.js';
|
|
10
10
|
import '../../chunk-BUIHQJGE.js';
|
|
11
11
|
import '../../chunk-6YNLRQ25.js';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { ComboboxList } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
2
|
+
export { ComboboxList } from '../../chunk-THGJLR5S.js';
|
|
3
|
+
import '../../chunk-QEAF57ZQ.js';
|
|
4
4
|
import '../../chunk-7TDHT3QD.js';
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
5
|
+
import '../../chunk-2NTCQIRP.js';
|
|
6
|
+
import '../../chunk-I4B3N3UX.js';
|
|
7
|
+
import '../../chunk-X6DESK37.js';
|
|
8
|
+
import '../../chunk-E3XLWMEB.js';
|
|
9
|
+
import '../../chunk-H7WOMZXO.js';
|
|
9
10
|
import '../../chunk-V6PY7C6S.js';
|
|
10
11
|
import '../../chunk-7P32XCEU.js';
|
|
11
|
-
import '../../chunk-H7WOMZXO.js';
|
|
12
12
|
import '../../chunk-PMUCGFY5.js';
|
|
13
13
|
import '../../chunk-BUIHQJGE.js';
|
|
14
14
|
import '../../chunk-6YNLRQ25.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { MEDIA_RADIUS } from '../../chunk-J43LSYQO.js';
|
|
3
3
|
import { ratioStyle } from '../../chunk-AHM6SGEU.js';
|
|
4
|
-
import { useLocale, useDirectionCheck } from '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
4
|
+
import { useLocale, useDirectionCheck } from '../../chunk-IUK7OJXZ.js';
|
|
5
|
+
import '../../chunk-LIZWCWED.js';
|
|
6
6
|
import { useUncontrolled } from '../../chunk-PMUCGFY5.js';
|
|
7
7
|
import '../../chunk-BUIHQJGE.js';
|
|
8
8
|
import { iconStroke } from '../../chunk-XXOR34T4.js';
|