xonecas.io
70160
Ce

cel-tui / commit 14ebf7c

fix(components): replace syntax highlighting shiki runtime with lowlight

xonecas2026-04-10 14ebf7c0e46f489f8c2536201b71bd94a37b4c0c parent 9dfeaba

7 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

bun.lock+8−91
@@ -21,8 +21,7 @@
2121 "dependencies": {
2222 "@cel-tui/core": "workspace:*",
2323 "@cel-tui/types": "workspace:*",
24- "shiki": "^4.0.2",
25- "shiki-stream": "^0.1.4",
24+ "lowlight": "^3.3.0",
2625 "yoctomarkdown": "^0.1.0",
2726 },
2827 "peerDependencies": {
@@ -75,19 +74,13 @@
7574
7675 "@gerrit0/mini-shiki": ["@gerrit0/mini-shiki@3.23.0", "", { "dependencies": { "@shikijs/engine-oniguruma": "^3.23.0", "@shikijs/langs": "^3.23.0", "@shikijs/themes": "^3.23.0", "@shikijs/types": "^3.23.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-bEMORlG0cqdjVyCEuU0cDQbORWX+kYCeo0kV1lbxF5bt4r7SID2l9bqsxJEM0zndaxpOUT7riCyIVEuqq/Ynxg=="],
7776
78- "@shikijs/core": ["@shikijs/core@4.0.2", "", { "dependencies": { "@shikijs/primitive": "4.0.2", "@shikijs/types": "4.0.2", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-hxT0YF4ExEqB8G/qFdtJvpmHXBYJ2lWW7qTHDarVkIudPFE6iCIrqdgWxGn5s+ppkGXI0aEGlibI0PAyzP3zlw=="],
77+ "@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-1nWINwKXxKKLqPibT5f4pAFLej9oZzQTsby8942OTlsJzOBZ0MWKiwzMsd+jhzu8YPCHAswGnnN1YtQfirL35g=="],
7978
80- "@shikijs/engine-javascript": ["@shikijs/engine-javascript@4.0.2", "", { "dependencies": { "@shikijs/types": "4.0.2", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^4.3.4" } }, "sha512-7PW0Nm49DcoUIQEXlJhNNBHyoGMjalRETTCcjMqEaMoJRLljy1Bi/EGV3/qLBgLKQejdspiiYuHGQW6dX94Nag=="],
79+ "@shikijs/langs": ["@shikijs/langs@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-2Ep4W3Re5aB1/62RSYQInK9mM3HsLeB91cHqznAJMuylqjzNVAVCMnNWRHFtcNHXsoNRayP9z1qj4Sq3nMqYXg=="],
8180
82- "@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@4.0.2", "", { "dependencies": { "@shikijs/types": "4.0.2", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-UpCB9Y2sUKlS9z8juFSKz7ZtysmeXCgnRF0dlhXBkmQnek7lAToPte8DkxmEYGNTMii72zU/lyXiCB6StuZeJg=="],
81+ "@shikijs/themes": ["@shikijs/themes@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-5qySYa1ZgAT18HR/ypENL9cUSGOeI2x+4IvYJu4JgVJdizn6kG4ia5Q1jDEOi7gTbN4RbuYtmHh0W3eccOrjMA=="],
8382
84- "@shikijs/langs": ["@shikijs/langs@4.0.2", "", { "dependencies": { "@shikijs/types": "4.0.2" } }, "sha512-KaXby5dvoeuZzN0rYQiPMjFoUrz4hgwIE+D6Du9owcHcl6/g16/yT5BQxSW5cGt2MZBz6Hl0YuRqf12omRfUUg=="],
85-
86- "@shikijs/primitive": ["@shikijs/primitive@4.0.2", "", { "dependencies": { "@shikijs/types": "4.0.2", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-M6UMPrSa3fN5ayeJwFVl9qWofl273wtK1VG8ySDZ1mQBfhCpdd8nEx7nPZ/tk7k+TYcpqBZzj/AnwxT9lO+HJw=="],
87-
88- "@shikijs/themes": ["@shikijs/themes@4.0.2", "", { "dependencies": { "@shikijs/types": "4.0.2" } }, "sha512-mjCafwt8lJJaVSsQvNVrJumbnnj1RI8jbUKrPKgE6E3OvQKxnuRoBaYC51H4IGHePsGN/QtALglWBU7DoKDFnA=="],
89-
90- "@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="],
83+ "@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
9184
9285 "@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.0.2", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="],
9386
@@ -95,14 +88,10 @@
9588
9689 "@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
9790
98- "@types/mdast": ["@types/mdast@4.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
99-
10091 "@types/node": ["@types/node@25.6.0", "", { "dependencies": { "undici-types": "~7.19.0" } }, "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ=="],
10192
10293 "@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
10394
104- "@ungap/structured-clone": ["@ungap/structured-clone@1.3.0", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
105-
10695 "ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
10796
10897 "argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
@@ -113,14 +102,6 @@
113102
114103 "bun-types": ["bun-types@1.3.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-1KGPpoxQWl9f6wcZh57LvrPIInQMn2TQ7jsgxqpRzg+l0QPOFvJVH7HmvHo/AiPgwXy+/Thf6Ov3EdVn1vOabg=="],
115104
116- "ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
117-
118- "character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
119-
120- "character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
121-
122- "comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
123-
124105 "dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
125106
126107 "devlop": ["devlop@1.1.0", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="],
@@ -129,11 +110,7 @@
129110
130111 "get-east-asian-width": ["get-east-asian-width@1.5.0", "", {}, "sha512-CQ+bEO+Tva/qlmw24dCejulK5pMzVnUOFOijVogd3KQs07HnRIgp8TGipvCCRT06xeYEbpbgwaCxglFyiuIcmA=="],
131112
132- "hast-util-to-html": ["hast-util-to-html@9.0.5", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iO …
133-
134- "hast-util-whitespace": ["hast-util-whitespace@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw=="],
135-
136- "html-void-elements": ["html-void-elements@3.0.0", "", {}, "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="],
113+ "highlight.js": ["highlight.js@11.11.1", "", {}, "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w=="],
137114
138115 "lefthook": ["lefthook@2.1.5", "", { "optionalDependencies": { "lefthook-darwin-arm64": "2.1.5", "lefthook-darwin-x64": "2.1.5", "lefthook-freebsd-arm64": "2.1.5", "lefthook-freebsd-x64": "2.1.5", "lefthook-linux-arm64": "2.1.5", "lefthook-linux-x64": "2.1.5", "lefthook-openbsd-arm64": "2.1.5", "lefthook-openbsd-x64": "2.1.5", "lefthook-windows-arm64": "2.1.5", "lefthook-windows-x64": "2.1.5" }, "bin": { "lefthook": "bin/index.js" } }, "sha512-yB9IFWurFllusbPZqvG0EavTmpNXPya2MuO7Li7YT78xAj3u …
139116
@@ -159,58 +136,26 @@
159136
160137 "linkify-it": ["linkify-it@5.0.0", "", { "dependencies": { "uc.micro": "^2.0.0" } }, "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ=="],
161138
139+ "lowlight": ["lowlight@3.3.0", "", { "dependencies": { "@types/hast": "^3.0.0", "devlop": "^1.0.0", "highlight.js": "~11.11.0" } }, "sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ=="],
140+
162141 "lunr": ["lunr@2.3.9", "", {}, "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow=="],
163142
164143 "markdown-it": ["markdown-it@14.1.1", "", { "dependencies": { "argparse": "^2.0.1", "entities": "^4.4.0", "linkify-it": "^5.0.0", "mdurl": "^2.0.0", "punycode.js": "^2.3.1", "uc.micro": "^2.1.0" }, "bin": { "markdown-it": "bin/markdown-it.mjs" } }, "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA=="],
165144
166- "mdast-util-to-hast": ["mdast-util-to-hast@13.2.1", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", "@ungap/structured-clone": "^1.0.0", "devlop": "^1.0.0", "micromark-util-sanitize-uri": "^2.0.0", "trim-lines": "^3.0.0", "unist-util-position": "^5.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.0" } }, "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA=="],
167-
168145 "mdurl": ["mdurl@2.0.0", "", {}, "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="],
169146
170- "micromark-util-character": ["micromark-util-character@2.1.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q=="],
171-
172- "micromark-util-encode": ["micromark-util-encode@2.0.1", "", {}, "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw=="],
173-
174- "micromark-util-sanitize-uri": ["micromark-util-sanitize-uri@2.0.1", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ=="],
175-
176- "micromark-util-symbol": ["micromark-util-symbol@2.0.1", "", {}, "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q=="],
177-
178- "micromark-util-types": ["micromark-util-types@2.0.2", "", {}, "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA=="],
179-
180147 "minimatch": ["minimatch@10.2.5", "", { "dependencies": { "brace-expansion": "^5.0.5" } }, "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg=="],
181148
182149 "mitata": ["mitata@1.0.34", "", {}, "sha512-Mc3zrtNBKIMeHSCQ0XqRLo1vbdIx1wvFV9c8NJAiyho6AjNfMY8bVhbS12bwciUdd1t4rj8099CH3N3NFahaUA=="],
183150
184- "oniguruma-parser": ["oniguruma-parser@0.12.1", "", {}, "sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w=="],
185-
186- "oniguruma-to-es": ["oniguruma-to-es@4.3.5", "", { "dependencies": { "oniguruma-parser": "^0.12.1", "regex": "^6.1.0", "regex-recursion": "^6.0.2" } }, "sha512-Zjygswjpsewa0NLTsiizVuMQZbp0MDyM6lIt66OxsF21npUDlzpHi1Mgb/qhQdkb+dWFTzJmFbEWdvZgRho8eQ=="],
187-
188151 "prettier": ["prettier@3.8.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-8c3mgTe0ASwWAJK+78dpviD+A8EqhndQPUBpNUIPt6+xWlIigCwfN01lWr9MAede4uqXGTEKeQWTvzb3vjia0Q=="],
189152
190- "property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
191-
192153 "punycode.js": ["punycode.js@2.3.1", "", {}, "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA=="],
193154
194- "regex": ["regex@6.1.0", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg=="],
195-
196- "regex-recursion": ["regex-recursion@6.0.2", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg=="],
197-
198- "regex-utilities": ["regex-utilities@2.3.0", "", {}, "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng=="],
199-
200- "shiki": ["shiki@4.0.2", "", { "dependencies": { "@shikijs/core": "4.0.2", "@shikijs/engine-javascript": "4.0.2", "@shikijs/engine-oniguruma": "4.0.2", "@shikijs/langs": "4.0.2", "@shikijs/themes": "4.0.2", "@shikijs/types": "4.0.2", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-eAVKTMedR5ckPo4xne/PjYQYrU3qx78gtJZ+sHlXEg5IHhhoQhMfZVzetTYuaJS0L2Ef3AcCRzCHV8T0WI6nIQ=="],
201-
202- "shiki-stream": ["shiki-stream@0.1.4", "", { "dependencies": { "@shikijs/core": "^3.0.0" }, "peerDependencies": { "react": "^19.0.0", "solid-js": "^1.9.0", "vue": "^3.2.0" }, "optionalPeers": ["react", "solid-js", "vue"] }, "sha512-4pz6JGSDmVTTkPJ/ueixHkFAXY4ySCc+unvCaDZV7hqq/sdJZirRxgIXSuNSKgiFlGTgRR97sdu2R8K55sPsrw=="],
203-
204- "space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="],
205-
206155 "string-width": ["string-width@8.2.0", "", { "dependencies": { "get-east-asian-width": "^1.5.0", "strip-ansi": "^7.1.2" } }, "sha512-6hJPQ8N0V0P3SNmP6h2J99RLuzrWz2gvT7VnK5tKvrNqJoyS9W4/Fb8mo31UiPvy00z7DQXkP2hnKBVav76thw=="],
207156
208- "stringify-entities": ["stringify-entities@4.0.4", "", { "dependencies": { "character-entities-html4": "^2.0.0", "character-entities-legacy": "^3.0.0" } }, "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg=="],
209-
210157 "strip-ansi": ["strip-ansi@7.2.0", "", { "dependencies": { "ansi-regex": "^6.2.2" } }, "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w=="],
211158
212- "trim-lines": ["trim-lines@3.0.1", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
213-
214159 "typedoc": ["typedoc@0.28.18", "", { "dependencies": { "@gerrit0/mini-shiki": "^3.23.0", "lunr": "^2.3.9", "markdown-it": "^14.1.1", "minimatch": "^10.2.4", "yaml": "^2.8.2" }, "peerDependencies": { "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x || 6.0.x" }, "bin": { "typedoc": "bin/typedoc" } }, "sha512-NTWTUOFRQ9+SGKKTuWKUioUkjxNwtS3JDRPVKZAXGHZy2wCA8bdv2iJiyeePn0xkmK+TCCqZFT0X7+2+FLjngA=="],
215160
216161 "typedoc-plugin-markdown": ["typedoc-plugin-markdown@4.11.0", "", { "peerDependencies": { "typedoc": "0.28.x" } }, "sha512-2iunh2ALyfyh204OF7h2u0kuQ84xB3jFZtFyUr01nThJkLvR8oGGSSDlyt2gyO4kXhvUxDcVbO0y43+qX+wFbw=="],
@@ -221,38 +166,10 @@
221166
222167 "undici-types": ["undici-types@7.19.2", "", {}, "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg=="],
223168
224- "unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="],
225-
226- "unist-util-position": ["unist-util-position@5.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA=="],
227-
228- "unist-util-stringify-position": ["unist-util-stringify-position@4.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ=="],
229-
230- "unist-util-visit": ["unist-util-visit@5.1.0", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.0.0" } }, "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg=="],
231-
232- "unist-util-visit-parents": ["unist-util-visit-parents@6.0.2", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ=="],
233-
234- "vfile": ["vfile@6.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "vfile-message": "^4.0.0" } }, "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q=="],
235-
236- "vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
237-
238169 "yaml": ["yaml@2.8.3", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg=="],
239170
240171 "yoctocolors": ["yoctocolors@2.1.2", "", {}, "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug=="],
241172
242173 "yoctomarkdown": ["yoctomarkdown@0.1.0", "", { "dependencies": { "string-width": "^8.2.0", "strip-ansi": "^7.2.0", "yoctocolors": "^2.1.2" }, "peerDependencies": { "typescript": "^5.9.3" }, "bin": { "yoctomarkdown": "src/cli.ts" } }, "sha512-N5ccZ2dQA3ZJSbImSeSxqfDHC/aBcyPWc5WI57corl4gB2Vsr4W11jswPhVNNI6R49ajFDNBNLLIqJTp5KtcQA=="],
243-
244- "zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
245-
246- "@gerrit0/mini-shiki/@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-1nWINwKXxKKLqPibT5f4pAFLej9oZzQTsby8942OTlsJzOBZ0MWKiwzMsd+jhzu8YPCHAswGnnN1YtQfirL35g=="],
247-
248- "@gerrit0/mini-shiki/@shikijs/langs": ["@shikijs/langs@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-2Ep4W3Re5aB1/62RSYQInK9mM3HsLeB91cHqznAJMuylqjzNVAVCMnNWRHFtcNHXsoNRayP9z1qj4Sq3nMqYXg=="],
249-
250- "@gerrit0/mini-shiki/@shikijs/themes": ["@shikijs/themes@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-5qySYa1ZgAT18HR/ypENL9cUSGOeI2x+4IvYJu4JgVJdizn6kG4ia5Q1jDEOi7gTbN4RbuYtmHh0W3eccOrjMA=="],
251-
252- "@gerrit0/mini-shiki/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
253-
254- "shiki-stream/@shikijs/core": ["@shikijs/core@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-NSWQz0riNb67xthdm5br6lAkvpDJRTgB36fxlo37ZzM2yq0PQFFzbd8psqC2XMPgCzo1fW6cVi18+ArJ44wqgA=="],
255-
256- "shiki-stream/@shikijs/core/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
257174 }
258175 }
docs/skill/cel-tui/SKILL.md+2−2
@@ -258,7 +258,7 @@ VStack({ flex: 1, overflow: "scroll", padding: { x: 1 } }, [
258258 SyntaxHighlight(source, "javascript", { theme: "dark-plus" });
259259 ```
260260
261-`SyntaxHighlight(content, language, props?)` renders bundled Shiki languages and aliases into cel-tui primitives. First render may show plain text while Shiki runtime, language, or theme loads; the component re-renders automatically once ready.
261+`SyntaxHighlight(content, language, props?)` renders registered lowlight/highlight.js languages and aliases into cel-tui primitives. Highlighting is synchronous. Unknown language ids render plain text. The optional `theme` accepts the small built-in presets (`"default"`, `"dark-plus"`) or a best-effort token-color registration object.
262262
263263 ## Gotchas
264264
@@ -278,7 +278,7 @@ SyntaxHighlight(source, "javascript", { theme: "dark-plus" });
278278 - **Kitty-first keyboard input** — the framework enables Kitty level 1 and gets full modifier fidelity when the host preserves it (`alt+x`, `ctrl+plus`, `shift+enter`, etc.). It also normalizes recoverable legacy encodings so common shortcuts keep working in tmux. For best results, use a Kitty-compatible terminal or `tmux` with `set -s extended-keys on`. On older legacy hosts, historically ambiguous collisions such as `ctrl+i` vs `tab` or `ctrl+m` vs `enter` cannot be recovered once the host c …
279279 - **tmux is good for keyboard-driven manual checks** — common `tmux send-keys` paths work for printable chars, `Tab`/`BTab`, `Enter`, `Escape`, arrows, and many `Ctrl+letter` shortcuts. Use exact raw-sequence injection only when you need to target a protocol-specific encoding. Mouse input remains unreliable in tmux and should be verified in a real terminal.
280280 - **Button limitations** — `Button` from `@cel-tui/components` does not forward container sizing props (`width`, `height`, `flex`, `minWidth`, etc.). It supports styling (`fgColor`, `bgColor`, `bold`, etc.), `focusStyle`, `focused`, `onFocus`, `onBlur`, `onKeyPress`, and `padding`. For full layout control, use `HStack` + `Text` directly.
281-- **SyntaxHighlight loads lazily** — first render may show plain text until the Shiki runtime, requested language, and requested theme finish loading. Unsupported language ids also render plain text.
281+- **SyntaxHighlight is append-optimized, not parser-state perfect** — append-only updates re-highlight a suffix window near the end instead of the whole block. Non-append edits still fall back to a full re-highlight. Unknown language ids render plain text.
282282
283283 ## Composing Components
284284
docs/skill/cel-tui/references/api.md+4−4
@@ -293,11 +293,11 @@ SyntaxHighlight(code, "javascript", { theme: "dark-plus" });
293293 ```
294294
295295 - Signature: `SyntaxHighlight(content, language, props?)`
296-- `language` accepts bundled Shiki language ids and aliases
297-- `props.theme` accepts a bundled Shiki theme name or a custom theme registration object
296+- `language` accepts registered lowlight/highlight.js language ids and aliases
297+- `props.theme` accepts the built-in presets (`"default"`, `"dark-plus"`) or a best-effort token theme registration object
298298 - Uses a terminal-friendly ANSI 16 fallback theme by default
299-- First render may show plain text while the Shiki runtime, language, or theme loads; unsupported languages also render plain text
300-- Append-only updates reuse a small per-language cache, so streaming code output works well
299+- Highlighting is synchronous; unsupported languages render plain text
300+- Append-only updates reuse a small per-language cache by re-highlighting only a suffix window near the end of the block
301301
302302 ## Theme
303303
examples/syntax-highlight.ts+2−2
@@ -2,7 +2,7 @@
22 * cel-tui: SyntaxHighlight demo
33 *
44 * Streams TypeScript code into the SyntaxHighlight component.
5- * Shows lazy Shiki loading plus append-only incremental highlighting.
5+ * Shows synchronous lowlight highlighting plus append-only incremental updates.
66 *
77 * Run: bun run examples/syntax-highlight.ts
88 */
@@ -79,7 +79,7 @@ const THEME_OPTIONS: ReadonlyArray<{
7979 },
8080 {
8181 label: "custom sunset",
82- help: "Custom Shiki theme remapped onto cel ANSI slots.",
82+ help: "Custom token theme remapped onto cel ANSI slots.",
8383 theme: CUSTOM_THEME,
8484 },
8585 ];
packages/components/package.json+1−2
@@ -34,8 +34,7 @@
3434 "dependencies": {
3535 "@cel-tui/types": "workspace:*",
3636 "@cel-tui/core": "workspace:*",
37- "shiki": "^4.0.2",
38- "shiki-stream": "^0.1.4",
37+ "lowlight": "^3.3.0",
3938 "yoctomarkdown": "^0.1.0"
4039 },
4140 "peerDependencies": {
packages/components/src/syntax-highlight.test.ts+49−61
@@ -65,30 +65,17 @@ function hasStyledText(node: ContainerNode): boolean {
6565 });
6666 }
6767
68-async function waitForHighlight(
68+function render(
6969 content: string,
7070 language: string,
7171 props?: SyntaxHighlightProps,
72-): Promise<ContainerNode> {
73- const deadline = Date.now() + 10_000;
74-
75- while (true) {
76- const node = SyntaxHighlight(content, language, props);
77- if (hasStyledText(node)) {
78- return node;
79- }
80-
81- if (Date.now() > deadline) {
82- throw new Error(`Timed out waiting for ${language} highlighter`);
83- }
84-
85- await new Promise((resolve) => setTimeout(resolve, 10));
86- }
72+): ContainerNode {
73+ return SyntaxHighlight(content, language, props);
8774 }
8875
8976 describe("SyntaxHighlight", () => {
9077 test("renders plain text for unknown languages", () => {
91- const node = SyntaxHighlight("plain text", "definitely-not-real");
78+ const node = render("plain text", "definitely-not-real");
9279
9380 expect(node.type).toBe("vstack");
9481 expect(node.children).toHaveLength(1);
@@ -96,8 +83,8 @@ describe("SyntaxHighlight", () => {
9683 expect(hasStyledText(node)).toBe(false);
9784 });
9885
99- test("eventually highlights javascript after lazy language load", async () => {
100- const node = await waitForHighlight("const value = 42", "javascript");
86+ test("highlights javascript synchronously", () => {
87+ const node = render("const value = 42", "javascript");
10188
10289 expect(node.type).toBe("vstack");
10390 expect(node.children).toHaveLength(1);
@@ -110,7 +97,7 @@ describe("SyntaxHighlight", () => {
11097 });
11198
11299 test("wraps plain fallback content by default", () => {
113- const node = SyntaxHighlight(
100+ const node = render(
114101 "alpha beta gamma delta epsilon",
115102 "definitely-not-real",
116103 );
@@ -118,8 +105,8 @@ describe("SyntaxHighlight", () => {
118105 expect(measureContentHeight(node, { width: 10 })).toBeGreaterThan(1);
119106 });
120107
121- test("wraps highlighted content by default", async () => {
122- const node = await waitForHighlight(
108+ test("wraps highlighted content by default", () => {
109+ const node = render(
123110 "const alpha beta gamma delta epsilon = 42",
124111 "javascript",
125112 );
@@ -127,71 +114,64 @@ describe("SyntaxHighlight", () => {
127114 expect(measureContentHeight(node, { width: 12 })).toBeGreaterThan(1);
128115 });
129116
130- test("default ansi16 theme uses terminal defaults for base text", async () => {
131- const node = await waitForHighlight("let value = 42", "javascript");
117+ test("default ansi16 theme uses terminal defaults for base text", () => {
118+ const node = render("let value = 42", "javascript");
132119
133120 expect(findText(node, "let").props.fgColor).toBe("color05");
134121 expect(findTextContaining(node, "value").props.fgColor).toBeUndefined();
135122 expect(findText(node, "42").props.fgColor).toBe("color03");
136123 });
137124
138- test("custom theme object overrides default colors", async () => {
139- const node = await waitForHighlight(
140- 'const message = "hello"',
141- "javascript",
142- {
143- theme: {
144- name: "syntax-highlight-test-theme",
145- type: "dark",
146- fg: "#e5e5e5",
147- bg: "#000000",
148- tokenColors: [
149- { settings: { foreground: "#e5e5e5" } },
150- {
151- scope: ["keyword", "storage"],
152- settings: { foreground: "#cd3131" },
153- },
154- { scope: "string", settings: { foreground: "#0dbc79" } },
155- ],
156- },
125+ test("custom theme object overrides default colors", () => {
126+ const node = render('const message = "hello"', "javascript", {
127+ theme: {
128+ name: "syntax-highlight-test-theme",
129+ type: "dark",
130+ fg: "#e5e5e5",
131+ bg: "#000000",
132+ tokenColors: [
133+ { settings: { foreground: "#e5e5e5" } },
134+ {
135+ scope: ["keyword", "storage"],
136+ settings: { foreground: "#cd3131" },
137+ },
138+ { scope: "string", settings: { foreground: "#0dbc79" } },
139+ ],
157140 },
158- );
141+ });
159142
160143 expect(findText(node, "const").props.fgColor).toBe("color01");
161144 expect(findTextContaining(node, "hello").props.fgColor).toBe("color02");
162145 });
163146
164- test("bundled shiki theme names load on demand", async () => {
165- const node = await waitForHighlight("const value = 42", "javascript", {
147+ test("named theme presets are accepted", () => {
148+ const node = render("const value = 42", "javascript", {
166149 theme: "dark-plus",
167150 });
168151
169152 expect(findText(node, "const").props.fgColor).toBeDefined();
170153 });
171154
172- test("keeps one rendered child per source line", async () => {
173- await waitForHighlight("const first = 1", "javascript");
174- const node = SyntaxHighlight(
175- "const first = 1\nconst second = 2",
176- "javascript",
177- );
155+ test("keeps one rendered child per source line", () => {
156+ render("const first = 1", "javascript");
157+ const node = render("const first = 1\nconst second = 2", "javascript");
178158
179159 expect(node.children).toHaveLength(2);
180160 expect(lineText(node.children[0]!)).toBe("const first = 1");
181161 expect(lineText(node.children[1]!)).toBe("const second = 2");
182162 });
183163
184- test("updates append-only content without duplicating previous text", async () => {
185- await waitForHighlight('const message = "hel', "javascript");
186- const node = SyntaxHighlight('const message = "hello"', "javascript");
164+ test("updates append-only content without duplicating previous text", () => {
165+ render('const message = "hel', "javascript");
166+ const node = render('const message = "hello"', "javascript");
187167
188168 expect(node.children).toHaveLength(1);
189169 expect(lineText(node.children[0]!)).toBe('const message = "hello"');
190170 });
191171
192- test("preserves grammar state across appended multiline comment", async () => {
193- await waitForHighlight("/* hello", "javascript");
194- const node = SyntaxHighlight("/* hello\nworld */", "javascript");
172+ test("preserves highlighting across appended multiline comment", () => {
173+ render("/* hello", "javascript");
174+ const node = render("/* hello\nworld */", "javascript");
195175
196176 expect(node.children).toHaveLength(2);
197177 expect(lineText(node.children[0]!)).toBe("/* hello");
@@ -203,9 +183,17 @@ describe("SyntaxHighlight", () => {
203183 expect(secondLine.props.fgColor).toBe(firstLine.props.fgColor);
204184 });
205185
206- test("falls back to full rehighlight on non-append edits", async () => {
207- await waitForHighlight("const value = 42", "javascript");
208- const node = SyntaxHighlight("function value() {}", "javascript");
186+ test("template substitutions reset back to base text style", () => {
187+ const node = render("`hi ${name}`", "javascript");
188+
189+ expect(findText(node, "`hi").props.fgColor).toBe("color02");
190+ expect(findText(node, " ").props.fgColor).toBe("color02");
191+ expect(findTextContaining(node, "${name}").props.fgColor).toBeUndefined();
192+ });
193+
194+ test("falls back to full rehighlight on non-append edits", () => {
195+ render("const value = 42", "javascript");
196+ const node = render("function value() {}", "javascript");
209197
210198 expect(node.children).toHaveLength(1);
211199 expect(lineText(node.children[0]!)).toBe("function value() {}");
packages/components/src/syntax-highlight.ts+504−523
@@ -1,24 +1,13 @@
11 import type { Color, ContainerNode, Node, StyleProps } from "@cel-tui/types";
2-import { cel, HStack, Text, VStack } from "@cel-tui/core";
3-import type {
4- BuiltinLanguage,
5- BuiltinTheme,
6- Highlighter,
7- ThemeRegistration,
8- ThemedToken,
9-} from "shiki";
10-import type {
11- ShikiStreamTokenizer,
12- ShikiStreamTokenizerEnqueueResult,
13-} from "shiki-stream";
2+import { HStack, Text, VStack } from "@cel-tui/core";
3+import { all, createLowlight } from "lowlight";
4+
5+const lowlight = createLowlight(all);
146
157 const DEFAULT_THEME_NAME = "cel-ansi16";
8+const APPEND_REHIGHLIGHT_WINDOW = 8_192;
169 const MAX_STATES_PER_KEY = 4;
1710
18-const FONT_STYLE_ITALIC = 1;
19-const FONT_STYLE_BOLD = 2;
20-const FONT_STYLE_UNDERLINE = 4;
21-
2211 const ANSI_SLOT_HEX: ReadonlyArray<readonly [Color, string]> = [
2312 ["color00", "#000000"],
2413 ["color01", "#cd3131"],
@@ -37,182 +26,234 @@ const ANSI_SLOT_HEX: ReadonlyArray<readonly [Color, string]> = [
3726 ["color14", "#29b8db"],
3827 ["color15", "#ffffff"],
3928 ];
40-const ANSI_SLOT_HEX_BY_COLOR = new Map<Color, string>(ANSI_SLOT_HEX);
4129
42-export type SyntaxHighlightTheme = BuiltinTheme | ThemeRegistration;
30+type TokenCategory =
31+ | "addition"
32+ | "comment"
33+ | "deletion"
34+ | "emphasis"
35+ | "function"
36+ | "keyword"
37+ | "link"
38+ | "literal"
39+ | "meta"
40+ | "number"
41+ | "parameter"
42+ | "property"
43+ | "regexp"
44+ | "string"
45+ | "strong"
46+ | "tag"
47+ | "type"
48+ | "variable";
49+
50+/** A best-effort token color override entry. */
51+export interface SyntaxHighlightThemeTokenColor {
52+ /** Target scopes or categories. */
53+ scope?: string | readonly string[];
54+ /** Style settings for the matched scopes. */
55+ settings: {
56+ foreground?: string;
57+ background?: string;
58+ fontStyle?: string;
59+ };
60+}
61+
62+/** Theme registration shape accepted by {@link SyntaxHighlight}. */
63+export interface SyntaxHighlightThemeRegistration {
64+ /** Optional theme name. */
65+ name?: string;
66+ /** Optional light/dark hint. */
67+ type?: "light" | "dark";
68+ /** Optional base foreground color. */
69+ fg?: string;
70+ /** Optional base background color. */
71+ bg?: string;
72+ /** Token color overrides. */
73+ tokenColors?: readonly SyntaxHighlightThemeTokenColor[];
74+}
75+
76+/**
77+ * SyntaxHighlight theme.
78+ *
79+ * String presets are intentionally small and stable. Unknown preset names fall
80+ * back to the default terminal-friendly theme.
81+ */
82+export type SyntaxHighlightTheme = string | SyntaxHighlightThemeRegistration;
4383
4484 /** Props for the {@link SyntaxHighlight} component. */
4585 export interface SyntaxHighlightProps {
4686 /**
47- * Optional Shiki theme override.
87+ * Optional theme override.
4888 *
49- * Pass either a bundled Shiki theme name (for example `"dark-plus"`)
50- * or a custom Shiki theme registration object.
89+ * Built-in presets currently include `"default"` and `"dark-plus"`.
90+ * Theme registration objects are applied as best-effort overrides onto the
91+ * lowlight/highlight.js token categories used by this component.
5192 */
5293 theme?: SyntaxHighlightTheme;
5394 }
5495
55-type SyntaxHighlightStatus = "ready" | "loading" | "error" | "unsupported";
96+interface HighlightRun {
97+ content: string;
98+ style: StyleProps;
99+}
56100
57-interface SyntaxHighlightRuntime {
58- bundledLanguages: Record<string, unknown>;
59- createHighlighter: (typeof import("shiki"))["createHighlighter"];
60- ShikiStreamTokenizer: (typeof import("shiki-stream"))["ShikiStreamTokenizer"];
101+interface ResolvedClassStyle {
102+ resetToBase?: boolean;
103+ style: StyleProps;
61104 }
62105
63106 interface ResolvedSyntaxHighlightTheme {
107+ baseStyle: StyleProps;
64108 cacheKey: string;
65- loadableTheme: SyntaxHighlightTheme;
66- themeName: string;
67- defaultFg?: string;
68- defaultBg?: string;
69- useTerminalDefaults: boolean;
70-}
71-
72-const DEFAULT_THEME: ThemeRegistration = {
73- name: DEFAULT_THEME_NAME,
74- displayName: "cel ANSI 16",
75- type: "dark",
76- fg: ansiHex("color07"),
77- bg: ansiHex("color00"),
78- colors: {
79- foreground: ansiHex("color07"),
80- "editor.foreground": ansiHex("color07"),
81- "editor.background": ansiHex("color00"),
82- "terminal.ansiBlack": ansiHex("color00"),
83- "terminal.ansiRed": ansiHex("color01"),
84- "terminal.ansiGreen": ansiHex("color02"),
85- "terminal.ansiYellow": ansiHex("color03"),
86- "terminal.ansiBlue": ansiHex("color04"),
87- "terminal.ansiMagenta": ansiHex("color05"),
88- "terminal.ansiCyan": ansiHex("color06"),
89- "terminal.ansiWhite": ansiHex("color07"),
90- "terminal.ansiBrightBlack": ansiHex("color08"),
91- "terminal.ansiBrightRed": ansiHex("color09"),
92- "terminal.ansiBrightGreen": ansiHex("color10"),
93- "terminal.ansiBrightYellow": ansiHex("color11"),
94- "terminal.ansiBrightBlue": ansiHex("color12"),
95- "terminal.ansiBrightMagenta": ansiHex("color13"),
96- "terminal.ansiBrightCyan": ansiHex("color14"),
97- "terminal.ansiBrightWhite": ansiHex("color15"),
98- },
99- tokenColors: [
100- { settings: { foreground: ansiHex("color07") } },
101- {
102- scope: ["comment", "string.quoted.docstring.multi"],
103- settings: { foreground: ansiHex("color08"), fontStyle: "italic" },
104- },
105- {
106- scope: ["string", "markup.inline"],
107- settings: { foreground: ansiHex("color02") },
108- },
109- {
110- scope: [
111- "constant.numeric",
112- "constant.language",
113- "constant.character",
114- "constant.other.placeholder",
115- ],
116- settings: { foreground: ansiHex("color03") },
117- },
118- {
119- scope: ["keyword", "storage", "entity.name.operator"],
120- settings: { foreground: ansiHex("color05") },
121- },
122- {
123- scope: ["entity.name.function", "support.function", "meta.function-call"],
124- settings: { foreground: ansiHex("color04") },
125- },
126- {
127- scope: [
128- "entity.name.type",
129- "support.type",
130- "support.class",
131- "entity.other.inherited-class",
132- ],
133- settings: { foreground: ansiHex("color06") },
134- },
135- {
136- scope: ["variable.parameter"],
137- settings: { foreground: ansiHex("color11") },
138- },
139- {
140- scope: [
141- "entity.other.attribute-name",
142- "meta.object-literal.key",
143- "meta.property-name",
144- "support.type.property-name",
145- ],
146- settings: { foreground: ansiHex("color06") },
147- },
148- {
149- scope: ["entity.name.tag", "string.regexp", "invalid"],
150- settings: { foreground: ansiHex("color01") },
151- },
152- {
153- scope: ["markup.bold", "strong", "markup.heading"],
154- settings: { fontStyle: "bold", foreground: ansiHex("color09") },
155- },
156- {
157- scope: ["markup.italic", "emphasis"],
158- settings: { fontStyle: "italic" },
159- },
160- {
161- scope: ["markup.underline", "meta.link.inline.markdown"],
162- settings: { foreground: ansiHex("color04"), fontStyle: "underline" },
163- },
164- ],
165-};
166-
167-const DEFAULT_RESOLVED_THEME: ResolvedSyntaxHighlightTheme = {
168- cacheKey: DEFAULT_THEME_NAME,
169- loadableTheme: DEFAULT_THEME,
170- themeName: DEFAULT_THEME_NAME,
171- defaultFg: normalizeHex(DEFAULT_THEME.fg ?? ansiHex("color07")),
172- defaultBg: normalizeHex(DEFAULT_THEME.bg ?? ansiHex("color00")),
173- useTerminalDefaults: true,
174-};
175-
176-const rgbCache = new Map<string, readonly [number, number, number]>();
177-const colorSlotCache = new Map<string, Color>();
178-const loadedLanguages = new Set<string>();
179-const loadingLanguages = new Map<string, Promise<void>>();
180-const languageErrors = new Map<string, Error>();
181-const loadedThemes = new Set<string>();
182-const loadingThemes = new Map<string, Promise<void>>();
183-const themeErrors = new Map<string, Error>();
184-const statesByKey = new Map<string, SyntaxHighlightState[]>();
185-
186-let runtimePromise: Promise<SyntaxHighlightRuntime> | null = null;
187-let runtimeInstance: SyntaxHighlightRuntime | null = null;
188-let runtimeError: Error | null = null;
189-let highlighterPromise: Promise<Highlighter> | null = null;
190-let highlighterInstance: Highlighter | null = null;
191-let highlighterError: Error | null = null;
109+ classStyles: ReadonlyMap<string, ResolvedClassStyle>;
110+}
192111
193112 interface SyntaxHighlightState {
194113 lastContent: string;
195- tokenizer: ShikiStreamTokenizer;
196114 lastNode: ContainerNode | null;
115+ lines: HighlightRun[][];
197116 theme: ResolvedSyntaxHighlightTheme;
198117 }
199118
200-interface HighlightRun {
201- content: string;
202- style: StyleProps;
119+interface HighlightTextNode {
120+ type: "text";
121+ value: string;
203122 }
204123
205-function ansiHex(color: Color): string {
206- const hex = ANSI_SLOT_HEX_BY_COLOR.get(color);
207- if (!hex) {
208- throw new Error(`Unknown ANSI slot: ${color}`);
209- }
210- return hex;
124+interface HighlightElementNode {
125+ type: "element";
126+ children: HighlightNode[];
127+ properties?: {
128+ className?: string | readonly string[];
129+ };
211130 }
212131
213-function normalizeError(error: unknown): Error {
214- return error instanceof Error ? error : new Error(String(error));
215-}
132+type HighlightNode = HighlightElementNode | HighlightTextNode;
133+
134+const rgbCache = new Map<string, readonly [number, number, number]>();
135+const colorSlotCache = new Map<string, Color>();
136+const statesByKey = new Map<string, SyntaxHighlightState[]>();
137+
138+const DEFAULT_CATEGORY_STYLES: Readonly<Record<TokenCategory, StyleProps>> = {
139+ addition: { fgColor: "color02" },
140+ comment: { fgColor: "color08", italic: true },
141+ deletion: { fgColor: "color01" },
142+ emphasis: { italic: true },
143+ function: { fgColor: "color04" },
144+ keyword: { fgColor: "color05" },
145+ link: { fgColor: "color04", underline: true },
146+ literal: { fgColor: "color03" },
147+ meta: { fgColor: "color09", bold: true },
148+ number: { fgColor: "color03" },
149+ parameter: { fgColor: "color11" },
150+ property: { fgColor: "color06" },
151+ regexp: { fgColor: "color01" },
152+ string: { fgColor: "color02" },
153+ strong: { bold: true },
154+ tag: { fgColor: "color01" },
155+ type: { fgColor: "color06" },
156+ variable: {},
157+};
158+
159+const DARK_PLUS_CATEGORY_STYLES: Readonly<
160+ Partial<Record<TokenCategory, StyleProps>>
161+> = {
162+ comment: { fgColor: "color08", italic: true },
163+ function: { fgColor: "color11" },
164+ keyword: { fgColor: "color12" },
165+ meta: { fgColor: "color08" },
166+ number: { fgColor: "color10" },
167+ property: { fgColor: "color07" },
168+ regexp: { fgColor: "color09" },
169+ string: { fgColor: "color09" },
170+ tag: { fgColor: "color09" },
171+ type: { fgColor: "color06" },
172+};
173+
174+const CATEGORY_CLASSES: Readonly<Record<TokenCategory, readonly string[]>> = {
175+ addition: ["addition"],
176+ comment: ["comment", "doctag", "quote"],
177+ deletion: ["deletion"],
178+ emphasis: ["emphasis"],
179+ function: ["function_", "title"],
180+ keyword: ["keyword", "operator", "selector-pseudo"],
181+ link: ["link"],
182+ literal: ["bullet", "literal", "symbol"],
183+ meta: ["meta", "section"],
184+ number: ["number"],
185+ parameter: ["params"],
186+ property: [
187+ "attr",
188+ "attribute",
189+ "property",
190+ "selector-attr",
191+ "selector-class",
192+ "selector-id",
193+ ],
194+ regexp: ["regexp"],
195+ string: ["string"],
196+ strong: ["strong"],
197+ tag: ["name", "selector-tag", "tag"],
198+ type: ["built_in", "class_", "type"],
199+ variable: ["variable"],
200+};
201+
202+const CATEGORY_SCOPE_HINTS: Readonly<Record<TokenCategory, readonly string[]>> =
203+ {
204+ addition: ["addition", "markup.inserted"],
205+ comment: ["comment", "quote"],
206+ deletion: ["deletion", "markup.deleted"],
207+ emphasis: ["emphasis", "markup.italic"],
208+ function: [
209+ "entity.name.function",
210+ "function",
211+ "meta.function-call",
212+ "support.function",
213+ "title",
214+ ],
215+ keyword: ["entity.name.operator", "keyword", "operator", "storage"],
216+ link: ["link", "meta.link"],
217+ literal: [
218+ "bullet",
219+ "constant.character",
220+ "constant.language",
221+ "literal",
222+ "symbol",
223+ ],
224+ meta: ["markup.heading", "meta", "section"],
225+ number: ["constant.numeric", "number"],
226+ parameter: ["params", "variable.parameter"],
227+ property: [
228+ "attr",
229+ "attribute",
230+ "entity.other.attribute-name",
231+ "meta.object-literal.key",
232+ "meta.property-name",
233+ "property",
234+ "support.type.property-name",
235+ ],
236+ regexp: ["regexp", "string.regexp"],
237+ string: ["markup.inline", "string"],
238+ strong: ["markup.bold", "markup.heading", "strong"],
239+ tag: ["entity.name.tag", "name", "selector-tag", "tag"],
240+ type: [
241+ "built_in",
242+ "class",
243+ "entity.name.type",
244+ "entity.other.inherited-class",
245+ "support.class",
246+ "support.type",
247+ "type",
248+ ],
249+ variable: ["variable"],
250+ };
251+
252+const DEFAULT_RESOLVED_THEME = buildResolvedTheme(
253+ DEFAULT_THEME_NAME,
254+ {},
255+ DEFAULT_CATEGORY_STYLES,
256+);
216257
217258 function hashString(input: string): string {
218259 let hash = 2166136261;
@@ -222,184 +263,207 @@ function hashString(input: string): string {
222263 return (hash >>> 0).toString(36);
223264 }
224265
225-function resolveTheme(
226- theme?: SyntaxHighlightTheme,
227-): ResolvedSyntaxHighlightTheme {
228- if (!theme) {
229- return DEFAULT_RESOLVED_THEME;
266+function normalizeHex(color: string): string {
267+ const lower = color.toLowerCase();
268+ if (lower.length === 4) {
269+ return `#${lower[1]}${lower[1]}${lower[2]}${lower[2]}${lower[3]}${lower[3]}`;
230270 }
231-
232- if (typeof theme === "string") {
233- return {
234- cacheKey: `builtin:${theme}`,
235- loadableTheme: theme,
236- themeName: theme,
237- useTerminalDefaults: false,
238- };
271+ if (lower.length === 9) {
272+ return lower.slice(0, 7);
239273 }
274+ return lower;
275+}
240276
241- const serialized = JSON.stringify(theme);
242- const cacheHash = hashString(serialized);
243- const themeName =
244- typeof theme.name === "string" && theme.name.length > 0
245- ? theme.name
246- : `cel-syntax-${cacheHash}`;
247- const loadableTheme =
248- themeName === theme.name ? theme : { ...theme, name: themeName };
277+function parseHex(color: string): readonly [number, number, number] {
278+ const cached = rgbCache.get(color);
279+ if (cached) {
280+ return cached;
281+ }
249282
250- return {
251- cacheKey: `custom:${cacheHash}`,
252- loadableTheme,
253- themeName,
254- useTerminalDefaults: false,
255- };
283+ const normalized = normalizeHex(color);
284+ const rgb: readonly [number, number, number] = [
285+ Number.parseInt(normalized.slice(1, 3), 16),
286+ Number.parseInt(normalized.slice(3, 5), 16),
287+ Number.parseInt(normalized.slice(5, 7), 16),
288+ ];
289+ rgbCache.set(color, rgb);
290+ return rgb;
256291 }
257292
258-function stateKey(
259- language: string,
260- theme: ResolvedSyntaxHighlightTheme,
261-): string {
262- return `${language}\u0000${theme.cacheKey}`;
293+function colorDistance(
294+ a: readonly [number, number, number],
295+ b: readonly [number, number, number],
296+): number {
297+ const dr = a[0] - b[0];
298+ const dg = a[1] - b[1];
299+ const db = a[2] - b[2];
300+ return dr * dr + dg * dg + db * db;
263301 }
264302
265-function getRuntimePromise(): Promise<SyntaxHighlightRuntime> {
266- if (runtimeError) {
267- return Promise.reject(runtimeError);
303+function colorToSlot(color: string | undefined): Color | undefined {
304+ if (!color) {
305+ return undefined;
268306 }
269307
270- if (!runtimePromise) {
271- runtimePromise = Promise.all([import("shiki"), import("shiki-stream")])
272- .then(([shiki, shikiStream]) => {
273- runtimeInstance = {
274- bundledLanguages: shiki.bundledLanguages as Record<string, unknown>,
275- createHighlighter: shiki.createHighlighter,
276- ShikiStreamTokenizer: shikiStream.ShikiStreamTokenizer,
277- };
278- return runtimeInstance;
279- })
280- .catch((error) => {
281- runtimeError = normalizeError(error);
282- throw runtimeError;
283- })
284- .finally(() => {
285- cel.render();
286- });
308+ const normalized = normalizeHex(color);
309+ const cached = colorSlotCache.get(normalized);
310+ if (cached) {
311+ return cached;
287312 }
288313
289- return runtimePromise;
290-}
314+ const rgb = parseHex(normalized);
315+ let best = ANSI_SLOT_HEX[0]![0];
316+ let bestDistance = Number.POSITIVE_INFINITY;
291317
292-function getHighlighterPromise(): Promise<Highlighter> {
293- if (highlighterError) {
294- return Promise.reject(highlighterError);
318+ for (const [slot, hex] of ANSI_SLOT_HEX) {
319+ const distance = colorDistance(rgb, parseHex(hex));
320+ if (distance < bestDistance) {
321+ best = slot;
322+ bestDistance = distance;
323+ }
295324 }
296325
297- if (!highlighterPromise) {
298- highlighterPromise = getRuntimePromise()
299- .then((runtime) =>
300- runtime.createHighlighter({
301- themes: [DEFAULT_THEME],
302- langs: [],
303- }),
304- )
305- .then((highlighter) => {
306- highlighterInstance = highlighter;
307- loadedThemes.add(DEFAULT_RESOLVED_THEME.cacheKey);
308- return highlighter;
309- })
310- .catch((error) => {
311- highlighterError = normalizeError(error);
312- throw highlighterError;
313- })
314- .finally(() => {
315- cel.render();
316- });
317- }
326+ colorSlotCache.set(normalized, best);
327+ return best;
328+}
318329
319- return highlighterPromise;
330+function mergeStyles(base: StyleProps, overrides: StyleProps): StyleProps {
331+ return {
332+ fgColor: overrides.fgColor ?? base.fgColor,
333+ bgColor: overrides.bgColor ?? base.bgColor,
334+ bold: overrides.bold ?? base.bold,
335+ italic: overrides.italic ?? base.italic,
336+ underline: overrides.underline ?? base.underline,
337+ };
320338 }
321339
322-function hasBundledLanguage(
Cut short: this commit's diff is over 1000 lines.