@42-central/ui-react 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-OZMSXYBX.js → chunk-36NWC4GV.js} +3 -3
- package/dist/{chunk-OZMSXYBX.js.map → chunk-36NWC4GV.js.map} +1 -1
- package/dist/{chunk-4FEOMQYR.js → chunk-54W6VAI3.js} +5 -5
- package/dist/{chunk-4FEOMQYR.js.map → chunk-54W6VAI3.js.map} +1 -1
- package/dist/{chunk-SZEOTXRZ.js → chunk-6II2DVYR.js} +5 -5
- package/dist/{chunk-SZEOTXRZ.js.map → chunk-6II2DVYR.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-YPFSRZ3T.js → chunk-6UIQJJNJ.js} +3 -3
- package/dist/{chunk-YPFSRZ3T.js.map → chunk-6UIQJJNJ.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-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
- package/dist/chunk-7E7JNWOC.js.map +1 -0
- package/dist/{chunk-C4NFRSOR.js → chunk-7HZBD4YZ.js} +4 -4
- package/dist/{chunk-C4NFRSOR.js.map → chunk-7HZBD4YZ.js.map} +1 -1
- package/dist/{chunk-JVG5ISPT.js → chunk-AHKMN3YQ.js} +3 -3
- package/dist/{chunk-JVG5ISPT.js.map → chunk-AHKMN3YQ.js.map} +1 -1
- 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-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-MRAJ45IM.js → chunk-FZSLSUSX.js} +4 -4
- package/dist/{chunk-MRAJ45IM.js.map → chunk-FZSLSUSX.js.map} +1 -1
- 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-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
- package/dist/chunk-KKLCHLCZ.js.map +1 -0
- package/dist/{chunk-YWTOW7PZ.js → chunk-LHUWOA2U.js} +8 -8
- package/dist/{chunk-YWTOW7PZ.js.map → chunk-LHUWOA2U.js.map} +1 -1
- 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-O7LS6OZR.js → chunk-LMCUGYHT.js} +3 -3
- package/dist/{chunk-O7LS6OZR.js.map → chunk-LMCUGYHT.js.map} +1 -1
- package/dist/{chunk-DHJB4UJD.js → chunk-N5M4PDBK.js} +4 -4
- package/dist/{chunk-DHJB4UJD.js.map → chunk-N5M4PDBK.js.map} +1 -1
- 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-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-PI7X5YFJ.js} +3 -3
- package/dist/{chunk-IRNF274I.js.map → chunk-PI7X5YFJ.js.map} +1 -1
- package/dist/{chunk-F2FSHVO5.js → chunk-QZ4N5LYG.js} +7 -7
- package/dist/{chunk-F2FSHVO5.js.map → chunk-QZ4N5LYG.js.map} +1 -1
- package/dist/{chunk-E5H3YWZV.js → chunk-SAXWCGWR.js} +3 -3
- package/dist/{chunk-E5H3YWZV.js.map → chunk-SAXWCGWR.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-D3JYDAUZ.js → chunk-T44RW5DW.js} +4 -4
- package/dist/{chunk-D3JYDAUZ.js.map → chunk-T44RW5DW.js.map} +1 -1
- package/dist/{chunk-FB2G4LNH.js → chunk-UDCCOUWR.js} +5 -5
- package/dist/{chunk-FB2G4LNH.js.map → chunk-UDCCOUWR.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-7AQ4MN4M.js → chunk-XUFCI262.js} +4 -4
- package/dist/{chunk-7AQ4MN4M.js.map → chunk-XUFCI262.js.map} +1 -1
- 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-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 +5 -3
- 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/index.js +4 -4
- package/dist/components/autocomplete/index.js +3 -3
- package/dist/components/avatar/index.js +2 -2
- 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-multi-select/index.js +3 -3
- package/dist/components/button-select/index.js +3 -3
- package/dist/components/calendar/index.js +4 -4
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +10 -10
- 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/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 +81 -10
- 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 +3 -3
- package/dist/components/combobox-list/index.js +5 -5
- package/dist/components/compare/index.js +2 -2
- package/dist/components/data-table/index.js +30 -30
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +12 -12
- package/dist/components/download-button/index.js +2 -2
- package/dist/components/drawer/index.js +4 -4
- 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/a11y.d.ts +3 -3
- package/dist/components/geodesic/a11y.d.ts.map +1 -1
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +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 +7 -7
- package/dist/components/menu/index.js +2 -2
- package/dist/components/modal/index.js +4 -4
- package/dist/components/multi-combobox-list/index.js +5 -5
- package/dist/components/multi-select/index.js +6 -6
- package/dist/components/number-input/index.js +3 -3
- package/dist/components/overlays/index.js +6 -6
- package/dist/components/password-input/index.js +3 -3
- package/dist/components/photo-capture/index.js +14 -14
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/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 +5 -5
- package/dist/components/segment-group/index.js +4 -4
- package/dist/components/select/index.js +4 -4
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spotlight/index.js +9 -9
- 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/tags-input/index.js +5 -5
- 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 +7 -7
- package/dist/components/tree-multi-select/index.js +6 -6
- package/dist/components/tree-select/index.js +3 -3
- package/dist/index.js +4 -4
- package/dist/theme.css +28 -23
- package/package.json +1 -1
- package/src/components/action-icon/action-icon.tsx +3 -1
- package/src/components/ambient-background/starfield.tsx +4 -2
- package/src/components/badge/badge.tsx +11 -6
- package/src/components/button/button.tsx +1 -1
- 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/kbd/kbd.tsx +2 -1
- 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/theme-icon/theme-icon.tsx +46 -12
- package/src/theme.css +28 -23
- package/dist/chunk-2MXWEIMD.js.map +0 -1
- package/dist/chunk-6VYGK3Q3.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-DT6LKNZF.js.map +0 -1
- package/dist/chunk-F342ZT7O.js.map +0 -1
- package/dist/chunk-SVKN5ZHX.js.map +0 -1
- package/dist/chunk-VD6PB3VA.js.map +0 -1
|
@@ -4,6 +4,7 @@ import type { WithTestId } from "../../lib/test-id";
|
|
|
4
4
|
import { CodeBlockButton, type CodeBlockClassNames, type CodeBlockIcons, type CodeBlockTranslations } from "./chrome";
|
|
5
5
|
import type { CodeBlockGutterColumn } from "./gutters";
|
|
6
6
|
import { type CodeBlockTagStyle } from "./highlighter";
|
|
7
|
+
import type { CodeBlockLanguage } from "./languages";
|
|
7
8
|
export type { CodeBlockButtonProps, CodeBlockClassNames, CodeBlockIconSlot, CodeBlockIcons, CodeBlockTranslations, } from "./chrome";
|
|
8
9
|
export type { CodeBlockContentGutterColumn, CodeBlockCounterGutterColumn, CodeBlockGutterColumn, } from "./gutters";
|
|
9
10
|
export type { CodeBlockTagStyle } from "./highlighter";
|
|
@@ -38,8 +39,10 @@ export type { CodeBlockTagStyle } from "./highlighter";
|
|
|
38
39
|
export type CodeBlockProps = WithTestId & {
|
|
39
40
|
/** Source text to highlight. No `children` slot — content is Shiki-derived. */
|
|
40
41
|
code: string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
42
|
+
/** A bundled language id or alias (e.g. "tsx", "bash", "json"), or a name
|
|
43
|
+
* registered through `registerLanguage`. An unknown name renders as plain
|
|
44
|
+
* text, with a dev-only warning. Omit → plain "text" grammar, no async load. */
|
|
45
|
+
language?: CodeBlockLanguage;
|
|
43
46
|
/** Override the light/dark Shiki theme pair. @default { light: "github-light", dark: "github-dark-default" } */
|
|
44
47
|
themes?: {
|
|
45
48
|
light: string;
|
|
@@ -56,7 +59,7 @@ export type CodeBlockProps = WithTestId & {
|
|
|
56
59
|
* run after the internal notation transformer — the escape hatch for
|
|
57
60
|
* extending Shiki's own capabilities. See also `registerLanguage`/
|
|
58
61
|
* `registerTheme` (exported from `@42/ui-react/code-block`) for
|
|
59
|
-
* registering a
|
|
62
|
+
* registering a language/theme the bundled set doesn't ship. */
|
|
60
63
|
transformers?: ShikiTransformer[];
|
|
61
64
|
/** Parse `// [!code tag]` markers. `false` renders them verbatim instead —
|
|
62
65
|
* for a snippet that teaches the notation itself. @default true */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/code-block.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,eAAe,EAEf,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/code-block.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,eAAe,EAEf,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,eAAe,CAAA;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IACxC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ;;qFAEiF;IACjF,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,gHAAgH;IAChH,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC;kFAC8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IACxC;;2EAEuE;IACvE,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACjC;;;;qEAIiE;IACjE,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACjC;wEACoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;mEAC+D;IAC/D,KAAK,CAAC,EAAE,SAAS,CAAA;IAEjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IAEnB,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qBAAqB;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IAE9C;wDACoD;IACpD,KAAK,CAAC,EAAE,cAAc,CAAA;IAEtB;;8DAE0D;IAC1D,QAAQ,CAAC,EAAE,SAAS,CAAA;IAEpB,8NAA8N;IAC9N,YAAY,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAE7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC,CAAA;AA8ED,iBAAS,kBAAkB,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,QAAQ,EAAE,eAAsB,EAChC,cAAc,EACd,SAAS,EACT,UAAU,EACV,GAAG,WAAW,EACf,EAAE,cAAc,+BAkDhB;AAED;;;;;;;4BAO4B;AAC5B,eAAO,MAAM,SAAS;;CAAiE,CAAA"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { LanguageInput, ShikiTransformer, ThemeInput } from "shiki";
|
|
2
2
|
import type { Color } from "../../lib/colors";
|
|
3
3
|
import { type CodeBlockGutterColumn } from "./gutters";
|
|
4
|
+
import { type CodeBlockLanguage } from "./languages";
|
|
4
5
|
import { type ParsedNotation } from "./notation";
|
|
5
6
|
/**
|
|
6
|
-
* Register a
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (e.g. at app startup) before rendering a `CodeBlock` that
|
|
7
|
+
* Register a TextMate grammar so `<CodeBlock language="...">` can reference
|
|
8
|
+
* it by name. Needed for any language outside the bundled `LANGUAGES` map,
|
|
9
|
+
* including Shiki's own: `registerLanguage((await import("shiki/langs/haskell.mjs")).default)`.
|
|
10
|
+
* Await this once (e.g. at app startup) before rendering a `CodeBlock` that
|
|
11
|
+
* uses it.
|
|
10
12
|
*/
|
|
11
13
|
export declare function registerLanguage(lang: LanguageInput): Promise<void>;
|
|
12
|
-
/** Register a
|
|
13
|
-
*
|
|
14
|
+
/** Register a VS Code-style theme so `themes` can reference it by name.
|
|
15
|
+
* Only `github-light` and `github-dark-default` load without it. */
|
|
14
16
|
export declare function registerTheme(theme: ThemeInput): Promise<void>;
|
|
15
17
|
/** Palette-driven styling — `background`/`color` tint via the kit's own
|
|
16
18
|
* theme-aware `Color` tokens (the same `--c-soft`/`--c-text` mechanism
|
|
@@ -38,7 +40,7 @@ type CodeBlockStyle = {
|
|
|
38
40
|
* chose — see `notation.ts` for the full grammar. */
|
|
39
41
|
export type CodeBlockTagStyle = CodeBlockStyle;
|
|
40
42
|
export type HighlightOptions = {
|
|
41
|
-
lang?:
|
|
43
|
+
lang?: CodeBlockLanguage;
|
|
42
44
|
themes?: {
|
|
43
45
|
light: string;
|
|
44
46
|
dark: string;
|
|
@@ -69,14 +71,13 @@ export type HighlightOptions = {
|
|
|
69
71
|
* language/theme side of the parser. */
|
|
70
72
|
transformers?: ShikiTransformer[];
|
|
71
73
|
};
|
|
72
|
-
/** Highlights `code` as HTML via the shared Shiki singleton.
|
|
73
|
-
*
|
|
74
|
-
* `
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* inlined as a plain `color`/`background-color` — both live only in the
|
|
74
|
+
/** Highlights `code` as HTML via the shared Shiki singleton. The language
|
|
75
|
+
* loads on demand from the `LANGUAGES` map; a name registered through
|
|
76
|
+
* `registerLanguage`/`registerTheme` is recognized as already loaded via the
|
|
77
|
+
* highlighter's own `getLoadedLanguages`/`getLoadedThemes`. `lang` defaults
|
|
78
|
+
* to `"text"` (Shiki's built-in plaintext grammar — no dynamic import
|
|
79
|
+
* needed). Called with `defaultColor: false` so neither theme is inlined as
|
|
80
|
+
* a plain `color`/`background-color` — both live only in the
|
|
80
81
|
* `--shiki-light`/`--shiki-dark` custom properties consumed by
|
|
81
82
|
* `styles.css`, so the dark-mode CSS rule there needs no `!important`. */
|
|
82
83
|
export declare function highlightCode(code: string, opts?: HighlightOptions): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlighter.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/highlighter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,gBAAgB,EAEhB,UAAU,EACX,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"highlighter.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/highlighter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,gBAAgB,EAEhB,UAAU,EACX,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,KAAK,qBAAqB,EAAwB,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAkB,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,YAAY,CAAA;AA0C/D;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE;AAED;qEACqE;AACrE,wBAAsB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE;AAED;;;;;;;0BAO0B;AAC1B,KAAK,cAAc,GAAG;IACpB,sEAAsE;IACtE,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,qFAAqF;IACrF,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;2EAEuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;sDAGsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAE9C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,iBAAiB,CAAA;IACxB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IACxC;kDAC8C;IAC9C,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACjC;;;2BAGuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;uCAKmC;IACnC,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB;;;;;;6CAMyC;IACzC,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAClC,CAAA;AAwLD;;;;;;;;2EAQ2E;AAC3E,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAe9F"}
|
|
@@ -2,6 +2,7 @@ import { CodeBlockButton, type CodeBlockButtonProps, type CodeBlockClassNames, t
|
|
|
2
2
|
import { type CodeBlockProps } from "./code-block";
|
|
3
3
|
import type { CodeBlockContentGutterColumn, CodeBlockCounterGutterColumn, CodeBlockGutterColumn } from "./gutters";
|
|
4
4
|
import { type CodeBlockTagStyle, registerLanguage, registerTheme } from "./highlighter";
|
|
5
|
+
import type { CodeBlockLanguage } from "./languages";
|
|
5
6
|
import { highlight, lineNumbers } from "./presets";
|
|
6
7
|
import { CodeBlockStatic, type CodeBlockStaticProps } from "./static";
|
|
7
8
|
/**
|
|
@@ -19,5 +20,5 @@ export declare const CodeBlock: (({ code, language, themes, tags, gutters, trans
|
|
|
19
20
|
} & {
|
|
20
21
|
Static: typeof CodeBlockStatic;
|
|
21
22
|
};
|
|
22
|
-
export { CodeBlockButton, type CodeBlockButtonProps, type CodeBlockClassNames, type CodeBlockContentGutterColumn, type CodeBlockCounterGutterColumn, type CodeBlockGutterColumn, type CodeBlockIconSlot, type CodeBlockIcons, type CodeBlockProps, type CodeBlockStaticProps, type CodeBlockTagStyle, type CodeBlockTranslations, highlight, lineNumbers, registerLanguage, registerTheme, };
|
|
23
|
+
export { CodeBlockButton, type CodeBlockButtonProps, type CodeBlockClassNames, type CodeBlockContentGutterColumn, type CodeBlockCounterGutterColumn, type CodeBlockGutterColumn, type CodeBlockIconSlot, type CodeBlockIcons, type CodeBlockLanguage, type CodeBlockProps, type CodeBlockStaticProps, type CodeBlockTagStyle, type CodeBlockTranslations, highlight, lineNumbers, registerLanguage, registerTheme, };
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,KAAK,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAUlD,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS;;;;CAA4D,CAAA;AAElF,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,KAAK,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAUlD,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS;;;;CAA4D,CAAA;AAElF,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,CAAA"}
|
|
@@ -5,6 +5,7 @@ import '../../chunk-N66NC6QK.js';
|
|
|
5
5
|
import '../../chunk-V6PY7C6S.js';
|
|
6
6
|
import '../../chunk-7P32XCEU.js';
|
|
7
7
|
import '../../chunk-H7WOMZXO.js';
|
|
8
|
+
import { devWarnOnce } from '../../chunk-LIZWCWED.js';
|
|
8
9
|
import '../../chunk-PMUCGFY5.js';
|
|
9
10
|
import '../../chunk-BUIHQJGE.js';
|
|
10
11
|
import '../../chunk-NKOTA5TM.js';
|
|
@@ -124,6 +125,50 @@ function resolveGutterColumns(gutters, notation, headLineOffset) {
|
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
// src/components/code-block/languages.ts
|
|
129
|
+
var LANGUAGES = {
|
|
130
|
+
c: () => import('shiki/langs/c.mjs'),
|
|
131
|
+
cpp: () => import('shiki/langs/cpp.mjs'),
|
|
132
|
+
"c++": () => import('shiki/langs/cpp.mjs'),
|
|
133
|
+
python: () => import('shiki/langs/python.mjs'),
|
|
134
|
+
py: () => import('shiki/langs/python.mjs'),
|
|
135
|
+
shellscript: () => import('shiki/langs/shellscript.mjs'),
|
|
136
|
+
bash: () => import('shiki/langs/shellscript.mjs'),
|
|
137
|
+
sh: () => import('shiki/langs/shellscript.mjs'),
|
|
138
|
+
shell: () => import('shiki/langs/shellscript.mjs'),
|
|
139
|
+
zsh: () => import('shiki/langs/shellscript.mjs'),
|
|
140
|
+
javascript: () => import('shiki/langs/javascript.mjs'),
|
|
141
|
+
js: () => import('shiki/langs/javascript.mjs'),
|
|
142
|
+
cjs: () => import('shiki/langs/javascript.mjs'),
|
|
143
|
+
mjs: () => import('shiki/langs/javascript.mjs'),
|
|
144
|
+
typescript: () => import('shiki/langs/typescript.mjs'),
|
|
145
|
+
ts: () => import('shiki/langs/typescript.mjs'),
|
|
146
|
+
cts: () => import('shiki/langs/typescript.mjs'),
|
|
147
|
+
mts: () => import('shiki/langs/typescript.mjs'),
|
|
148
|
+
jsx: () => import('shiki/langs/jsx.mjs'),
|
|
149
|
+
tsx: () => import('shiki/langs/tsx.mjs'),
|
|
150
|
+
json: () => import('shiki/langs/json.mjs'),
|
|
151
|
+
yaml: () => import('shiki/langs/yaml.mjs'),
|
|
152
|
+
yml: () => import('shiki/langs/yaml.mjs'),
|
|
153
|
+
markdown: () => import('shiki/langs/markdown.mjs'),
|
|
154
|
+
md: () => import('shiki/langs/markdown.mjs'),
|
|
155
|
+
html: () => import('shiki/langs/html.mjs'),
|
|
156
|
+
css: () => import('shiki/langs/css.mjs'),
|
|
157
|
+
sql: () => import('shiki/langs/sql.mjs'),
|
|
158
|
+
go: () => import('shiki/langs/go.mjs'),
|
|
159
|
+
rust: () => import('shiki/langs/rust.mjs'),
|
|
160
|
+
rs: () => import('shiki/langs/rust.mjs'),
|
|
161
|
+
java: () => import('shiki/langs/java.mjs'),
|
|
162
|
+
make: () => import('shiki/langs/make.mjs'),
|
|
163
|
+
makefile: () => import('shiki/langs/make.mjs'),
|
|
164
|
+
docker: () => import('shiki/langs/docker.mjs'),
|
|
165
|
+
dockerfile: () => import('shiki/langs/docker.mjs'),
|
|
166
|
+
diff: () => import('shiki/langs/diff.mjs')
|
|
167
|
+
};
|
|
168
|
+
function languageLoader(lang) {
|
|
169
|
+
return Object.hasOwn(LANGUAGES, lang) ? LANGUAGES[lang] : void 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
127
172
|
// src/components/code-block/notation.ts
|
|
128
173
|
var MARKER_SOURCE = String.raw`\[!code\s+([A-Za-z][\w-]*)(?::((?:\\.|[^:\]])*))?\s*\]`;
|
|
129
174
|
var MARKER_RE = new RegExp(MARKER_SOURCE, "g");
|
|
@@ -218,8 +263,17 @@ var DEFAULT_THEMES = { light: "github-light", dark: "github-dark-default" };
|
|
|
218
263
|
var highlighterPromise = null;
|
|
219
264
|
function getHighlighter() {
|
|
220
265
|
if (!highlighterPromise) {
|
|
221
|
-
highlighterPromise =
|
|
222
|
-
(
|
|
266
|
+
highlighterPromise = Promise.all([
|
|
267
|
+
import('shiki/core'),
|
|
268
|
+
import('shiki/engine/javascript'),
|
|
269
|
+
import('shiki/themes/github-light.mjs'),
|
|
270
|
+
import('shiki/themes/github-dark-default.mjs')
|
|
271
|
+
]).then(
|
|
272
|
+
([{ createHighlighterCore }, { createJavaScriptRegexEngine }, light, dark]) => createHighlighterCore({
|
|
273
|
+
themes: [light.default, dark.default],
|
|
274
|
+
langs: [],
|
|
275
|
+
engine: createJavaScriptRegexEngine()
|
|
276
|
+
})
|
|
223
277
|
);
|
|
224
278
|
}
|
|
225
279
|
return highlighterPromise;
|
|
@@ -325,17 +379,34 @@ function buildCodeBlockTransformer(opts, notation) {
|
|
|
325
379
|
}
|
|
326
380
|
};
|
|
327
381
|
}
|
|
382
|
+
var PLAIN_LANGUAGES = /* @__PURE__ */ new Set(["text", "txt", "plain", "plaintext"]);
|
|
383
|
+
async function resolveLanguage(highlighter, lang) {
|
|
384
|
+
if (PLAIN_LANGUAGES.has(lang) || highlighter.getLoadedLanguages().includes(lang)) return lang;
|
|
385
|
+
const loader = languageLoader(lang);
|
|
386
|
+
if (loader) {
|
|
387
|
+
await highlighter.loadLanguage((await loader()).default);
|
|
388
|
+
return lang;
|
|
389
|
+
}
|
|
390
|
+
devWarnOnce(
|
|
391
|
+
`CodeBlock: unknown language "${lang}", rendering as plain text. Register its grammar with registerLanguage() first.`
|
|
392
|
+
);
|
|
393
|
+
return "text";
|
|
394
|
+
}
|
|
395
|
+
function resolveTheme(highlighter, name, slot) {
|
|
396
|
+
if (highlighter.getLoadedThemes().includes(name)) return name;
|
|
397
|
+
devWarnOnce(
|
|
398
|
+
`CodeBlock: unknown theme "${name}", using "${DEFAULT_THEMES[slot]}" instead. Register it with registerTheme() first.`
|
|
399
|
+
);
|
|
400
|
+
return DEFAULT_THEMES[slot];
|
|
401
|
+
}
|
|
328
402
|
async function highlightCode(code, opts = {}) {
|
|
329
|
-
const lang = opts.lang ?? "text";
|
|
330
|
-
const themes = opts.themes ?? DEFAULT_THEMES;
|
|
331
403
|
const highlighter = await getHighlighter();
|
|
332
404
|
const notation = opts.notation ?? parseNotation(code);
|
|
333
|
-
await
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
405
|
+
const lang = await resolveLanguage(highlighter, opts.lang ?? "text");
|
|
406
|
+
const themes = {
|
|
407
|
+
light: resolveTheme(highlighter, opts.themes?.light ?? DEFAULT_THEMES.light, "light"),
|
|
408
|
+
dark: resolveTheme(highlighter, opts.themes?.dark ?? DEFAULT_THEMES.dark, "dark")
|
|
409
|
+
};
|
|
339
410
|
return highlighter.codeToHtml(code, {
|
|
340
411
|
lang,
|
|
341
412
|
themes,
|