@xyd-js/components 0.1.0-build.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/.idea/git_toolbox_blame.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/.idea/xyd-components.iml +12 -0
  5. package/CHANGELOG.md +1369 -0
  6. package/LICENSE +21 -0
  7. package/README.md +3 -0
  8. package/TODO.md +1 -0
  9. package/coder.ts +1 -0
  10. package/content.ts +1 -0
  11. package/dist/Button-BLA2ghHZ.js +2 -0
  12. package/dist/Button-BLA2ghHZ.js.map +1 -0
  13. package/dist/Button-BTJ2hIal.js +2 -0
  14. package/dist/Button-BTJ2hIal.js.map +1 -0
  15. package/dist/Button-r4BCrEjy.js +2 -0
  16. package/dist/Button-r4BCrEjy.js.map +1 -0
  17. package/dist/CodeSample-BZ5tvyWY.js +2 -0
  18. package/dist/CodeSample-BZ5tvyWY.js.map +1 -0
  19. package/dist/CodeSample-BqXDbWdi.js +2 -0
  20. package/dist/CodeSample-BqXDbWdi.js.map +1 -0
  21. package/dist/CodeSample-Cqv86IdN.js +2 -0
  22. package/dist/CodeSample-Cqv86IdN.js.map +1 -0
  23. package/dist/Icon--77MqplU.js +2 -0
  24. package/dist/Icon--77MqplU.js.map +1 -0
  25. package/dist/Icon-DbNmvK_Q.js +2 -0
  26. package/dist/Icon-DbNmvK_Q.js.map +1 -0
  27. package/dist/Icon-uVIU1LW6.js +2 -0
  28. package/dist/Icon-uVIU1LW6.js.map +1 -0
  29. package/dist/PageFirstSlide-BDNmCTiJ.js +2 -0
  30. package/dist/PageFirstSlide-BDNmCTiJ.js.map +1 -0
  31. package/dist/PageFirstSlide-BpZ42bEU.js +2 -0
  32. package/dist/PageFirstSlide-BpZ42bEU.js.map +1 -0
  33. package/dist/PageFirstSlide-CqxiyK57.js +2 -0
  34. package/dist/PageFirstSlide-CqxiyK57.js.map +1 -0
  35. package/dist/TabsAnalytics-B_JYpawG.js +2 -0
  36. package/dist/TabsAnalytics-B_JYpawG.js.map +1 -0
  37. package/dist/TabsAnalytics-DAOfTZgv.js +2 -0
  38. package/dist/TabsAnalytics-DAOfTZgv.js.map +1 -0
  39. package/dist/TabsAnalytics-Dhyadlbu.js +2 -0
  40. package/dist/TabsAnalytics-Dhyadlbu.js.map +1 -0
  41. package/dist/Update-53fEhmjh.js +2 -0
  42. package/dist/Update-53fEhmjh.js.map +1 -0
  43. package/dist/Update-CFi6uapq.js +2 -0
  44. package/dist/Update-CFi6uapq.js.map +1 -0
  45. package/dist/Update-CiMIOgZi.js +2 -0
  46. package/dist/Update-CiMIOgZi.js.map +1 -0
  47. package/dist/VideoGuide-C0K9fFar.js +2 -0
  48. package/dist/VideoGuide-C0K9fFar.js.map +1 -0
  49. package/dist/VideoGuide-CJYkuLst.js +2 -0
  50. package/dist/VideoGuide-CJYkuLst.js.map +1 -0
  51. package/dist/VideoGuide-DBY-EyxG.js +2 -0
  52. package/dist/VideoGuide-DBY-EyxG.js.map +1 -0
  53. package/dist/_rollupPluginBabelHelpers-CvhQFv1t.js +4 -0
  54. package/dist/_rollupPluginBabelHelpers-CvhQFv1t.js.map +1 -0
  55. package/dist/_rollupPluginBabelHelpers-DSwDY1Dm.js +4 -0
  56. package/dist/_rollupPluginBabelHelpers-DSwDY1Dm.js.map +1 -0
  57. package/dist/_rollupPluginBabelHelpers-Dc-ocx4G.js +4 -0
  58. package/dist/_rollupPluginBabelHelpers-Dc-ocx4G.js.map +1 -0
  59. package/dist/coder/themes/classic.css +57 -0
  60. package/dist/coder/themes/classic.d.ts +96 -0
  61. package/dist/coder/themes/classic.js +2 -0
  62. package/dist/coder/themes/classic.js.map +1 -0
  63. package/dist/coder/themes/cosmo.css +64 -0
  64. package/dist/coder/themes/cosmo.d.ts +96 -0
  65. package/dist/coder/themes/cosmo.js +2 -0
  66. package/dist/coder/themes/cosmo.js.map +1 -0
  67. package/dist/coder.d.ts +94 -0
  68. package/dist/coder.js +2 -0
  69. package/dist/coder.js.map +1 -0
  70. package/dist/content.d.ts +411 -0
  71. package/dist/content.js +2 -0
  72. package/dist/content.js.map +1 -0
  73. package/dist/index.css +282 -0
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.js +2 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/layouts.d.ts +33 -0
  78. package/dist/layouts.js +2 -0
  79. package/dist/layouts.js.map +1 -0
  80. package/dist/pages.d.ts +176 -0
  81. package/dist/pages.js +2 -0
  82. package/dist/pages.js.map +1 -0
  83. package/dist/system.d.ts +45 -0
  84. package/dist/system.js +2 -0
  85. package/dist/system.js.map +1 -0
  86. package/dist/useUXClick-DK3cTAMR.js +2 -0
  87. package/dist/useUXClick-DK3cTAMR.js.map +1 -0
  88. package/dist/useUXClick-DO6qBcRy.js +2 -0
  89. package/dist/useUXClick-DO6qBcRy.js.map +1 -0
  90. package/dist/useUXClick-NwpsiuK9.js +2 -0
  91. package/dist/useUXClick-NwpsiuK9.js.map +1 -0
  92. package/dist/useUXEvents-CJtgGV4R.js +2 -0
  93. package/dist/useUXEvents-CJtgGV4R.js.map +1 -0
  94. package/dist/useUXEvents-Cxgl7xb-.js +2 -0
  95. package/dist/useUXEvents-Cxgl7xb-.js.map +1 -0
  96. package/dist/useUXEvents-XqAGxoEj.js +2 -0
  97. package/dist/useUXEvents-XqAGxoEj.js.map +1 -0
  98. package/dist/useUXScrollDepth-3rk3Z95r.js +2 -0
  99. package/dist/useUXScrollDepth-3rk3Z95r.js.map +1 -0
  100. package/dist/useUXScrollDepth-BwK-XOBg.js +2 -0
  101. package/dist/useUXScrollDepth-BwK-XOBg.js.map +1 -0
  102. package/dist/useUXScrollDepth-DKre7PBz.js +2 -0
  103. package/dist/useUXScrollDepth-DKre7PBz.js.map +1 -0
  104. package/dist/uxsdk.d.ts +53 -0
  105. package/dist/uxsdk.js +2 -0
  106. package/dist/uxsdk.js.map +1 -0
  107. package/dist/views.d.ts +18 -0
  108. package/dist/views.js +2 -0
  109. package/dist/views.js.map +1 -0
  110. package/dist/writer.d.ts +580 -0
  111. package/dist/writer.js +2 -0
  112. package/dist/writer.js.map +1 -0
  113. package/docs/.nojekyll +1 -0
  114. package/docs/assets/hierarchy.js +1 -0
  115. package/docs/assets/highlight.css +22 -0
  116. package/docs/assets/icons.js +18 -0
  117. package/docs/assets/icons.svg +1 -0
  118. package/docs/assets/main.js +60 -0
  119. package/docs/assets/navigation.js +1 -0
  120. package/docs/assets/search.js +1 -0
  121. package/docs/assets/style.css +1640 -0
  122. package/docs/functions/GuideCard.html +6 -0
  123. package/docs/hierarchy.html +1 -0
  124. package/docs/index.html +2 -0
  125. package/docs/interfaces/GuideCardProps.html +18 -0
  126. package/docs/modules.html +1 -0
  127. package/index.ts +0 -0
  128. package/layouts.ts +1 -0
  129. package/output.txt +13 -0
  130. package/package.json +81 -0
  131. package/pages.ts +1 -0
  132. package/postcss.config.cjs +5 -0
  133. package/rollup.config.js +195 -0
  134. package/src/coder/Code/Code.styles.tsx +151 -0
  135. package/src/coder/Code/Code.tsx +171 -0
  136. package/src/coder/Code/CodeLoader.tsx +10 -0
  137. package/src/coder/Code/annotations.tsx +51 -0
  138. package/src/coder/Code/highlight.ts +208 -0
  139. package/src/coder/Code/index.ts +16 -0
  140. package/src/coder/CodeCopy/CodeCopy.styles.tsx +21 -0
  141. package/src/coder/CodeCopy/CodeCopy.tsx +36 -0
  142. package/src/coder/CodeCopy/index.ts +7 -0
  143. package/src/coder/CodeSample/CodeSample.tsx +118 -0
  144. package/src/coder/CodeSample/CodeSampleAnalytics.tsx +112 -0
  145. package/src/coder/CodeSample/index.ts +11 -0
  146. package/src/coder/CodeSample/withLocalStored.tsx +50 -0
  147. package/src/coder/CodeTabs/CodeTabs.styles.tsx +126 -0
  148. package/src/coder/CodeTabs/CodeTabs.tsx +128 -0
  149. package/src/coder/CodeTabs/index.ts +6 -0
  150. package/src/coder/CodeTheme/CodeTheme.tsx +126 -0
  151. package/src/coder/CodeTheme/index.ts +7 -0
  152. package/src/coder/CoderProvider.tsx +26 -0
  153. package/src/coder/README.md +1 -0
  154. package/src/coder/hooks/highlight.ts +182 -0
  155. package/src/coder/index.ts +37 -0
  156. package/src/coder/themes/classic.css +57 -0
  157. package/src/coder/themes/classic.ts +270 -0
  158. package/src/coder/themes/cosmo.css +64 -0
  159. package/src/coder/themes/cosmo.ts +264 -0
  160. package/src/content/AppearanceDecorator.styles.tsx +11 -0
  161. package/src/content/ContentDecoator.styles.tsx +180 -0
  162. package/src/content/ContentDecorator.tsx +17 -0
  163. package/src/content/GridDecorator.styles.tsx +86 -0
  164. package/src/content/GridDecorator.tsx +23 -0
  165. package/src/content/ReactContent.tsx +671 -0
  166. package/src/content/TODO.md +1 -0
  167. package/src/content/index.ts +13 -0
  168. package/src/kit/Loader/Loader.styles.tsx +53 -0
  169. package/src/kit/Loader/Loader.tsx +22 -0
  170. package/src/kit/TODO.md +2 -0
  171. package/src/kit/index.ts +1 -0
  172. package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +325 -0
  173. package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +252 -0
  174. package/src/layouts/LayoutPrimary/index.ts +3 -0
  175. package/src/layouts/index.ts +6 -0
  176. package/src/pages/PageBlogHome/PageBlogHome.styles.tsx +67 -0
  177. package/src/pages/PageBlogHome/PageBlogHome.tsx +64 -0
  178. package/src/pages/PageBlogHome/index.ts +3 -0
  179. package/src/pages/PageBlogHome/types.ts +35 -0
  180. package/src/pages/PageBlogPost/PageBlogPost.styles.tsx +4 -0
  181. package/src/pages/PageBlogPost/PageBlogPost.tsx +9 -0
  182. package/src/pages/PageBlogPost/index.ts +3 -0
  183. package/src/pages/PageFirstSlide/PageFirstSlide.styles.tsx +134 -0
  184. package/src/pages/PageFirstSlide/PageFirstSlide.tsx +56 -0
  185. package/src/pages/PageFirstSlide/index.ts +1 -0
  186. package/src/pages/PageFirstSlide/types.ts +67 -0
  187. package/src/pages/PageHome/PageHome.styles.tsx +51 -0
  188. package/src/pages/PageHome/PageHome.tsx +62 -0
  189. package/src/pages/PageHome/index.ts +3 -0
  190. package/src/pages/PageHome/types.ts +79 -0
  191. package/src/pages/index.ts +7 -0
  192. package/src/system/Baseline/Baseline.styles.tsx +128 -0
  193. package/src/system/Baseline/Baseline.tsx +40 -0
  194. package/src/system/Baseline/bun.svg +1 -0
  195. package/src/system/Baseline/check.svg +1 -0
  196. package/src/system/Baseline/index.ts +1 -0
  197. package/src/system/Baseline/logo.svg +1 -0
  198. package/src/system/Baseline/node.svg +7 -0
  199. package/src/system/Baseline/npm.svg +5 -0
  200. package/src/system/Baseline/pnpm.svg +1 -0
  201. package/src/system/Footer/Footer.styles.tsx +213 -0
  202. package/src/system/Footer/Footer.tsx +105 -0
  203. package/src/system/Footer/index.ts +1 -0
  204. package/src/system/SearchButton/SearchButton.styles.tsx +89 -0
  205. package/src/system/SearchButton/SearchButton.tsx +118 -0
  206. package/src/system/SearchButton/index.ts +1 -0
  207. package/src/system/index.ts +3 -0
  208. package/src/utils/useStyle.ts +19 -0
  209. package/src/uxsdk/const.ts +1 -0
  210. package/src/uxsdk/index.ts +21 -0
  211. package/src/uxsdk/useUXClick.ts +21 -0
  212. package/src/uxsdk/useUXEvents.ts +105 -0
  213. package/src/uxsdk/useUXScrollDepth.ts +49 -0
  214. package/src/uxsdk/useUXUnreachableElementTracker.ts +100 -0
  215. package/src/views/HomeView/HomeView.styles.tsx +37 -0
  216. package/src/views/HomeView/HomeView.tsx +34 -0
  217. package/src/views/HomeView/index.ts +3 -0
  218. package/src/writer/Anchor/Anchor.styles.tsx +26 -0
  219. package/src/writer/Anchor/Anchor.tsx +51 -0
  220. package/src/writer/Anchor/index.tsx +1 -0
  221. package/src/writer/Badge/Badge.styles.tsx +44 -0
  222. package/src/writer/Badge/Badge.tsx +47 -0
  223. package/src/writer/Badge/index.ts +7 -0
  224. package/src/writer/Banner/Banner.styles.tsx +111 -0
  225. package/src/writer/Banner/Banner.tsx +151 -0
  226. package/src/writer/Banner/index.ts +1 -0
  227. package/src/writer/Blockquote/Blockquote.styles.tsx +20 -0
  228. package/src/writer/Blockquote/Blockquote.tsx +38 -0
  229. package/src/writer/Blockquote/index.ts +7 -0
  230. package/src/writer/BlogCard/BlogCard.styles.tsx +4 -0
  231. package/src/writer/BlogCard/BlogCard.tsx +9 -0
  232. package/src/writer/BlogCard/index.ts +3 -0
  233. package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +24 -0
  234. package/src/writer/Breadcrumbs/Breadcrumbs.tsx +57 -0
  235. package/src/writer/Breadcrumbs/index.ts +7 -0
  236. package/src/writer/Button/Button.styles.tsx +149 -0
  237. package/src/writer/Button/Button.tsx +82 -0
  238. package/src/writer/Button/index.ts +2 -0
  239. package/src/writer/Callout/Callout.styles.tsx +102 -0
  240. package/src/writer/Callout/Callout.tsx +166 -0
  241. package/src/writer/Callout/index.tsx +3 -0
  242. package/src/writer/Card/Card.styles.tsx +110 -0
  243. package/src/writer/Card/Card.tsx +94 -0
  244. package/src/writer/Card/index.ts +1 -0
  245. package/src/writer/Code/Code.styles.tsx +16 -0
  246. package/src/writer/Code/Code.tsx +16 -0
  247. package/src/writer/Code/index.ts +3 -0
  248. package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +191 -0
  249. package/src/writer/ColorSchemeButton/index.ts +1 -0
  250. package/src/writer/Details/Details.styles.tsx +101 -0
  251. package/src/writer/Details/Details.tsx +168 -0
  252. package/src/writer/Details/DetailsProps.tsx +34 -0
  253. package/src/writer/Details/index.ts +6 -0
  254. package/src/writer/GuideCard/GuideCard.styles.tsx +129 -0
  255. package/src/writer/GuideCard/GuideCard.tsx +123 -0
  256. package/src/writer/GuideCard/index.ts +1 -0
  257. package/src/writer/Heading/Heading.styles.tsx +93 -0
  258. package/src/writer/Heading/Heading.tsx +123 -0
  259. package/src/writer/Heading/index.ts +7 -0
  260. package/src/writer/Hr/Hr.styles.tsx +7 -0
  261. package/src/writer/Hr/Hr.tsx +10 -0
  262. package/src/writer/Hr/index.ts +3 -0
  263. package/src/writer/Icon/Icon.styles.tsx +15 -0
  264. package/src/writer/Icon/Icon.tsx +99 -0
  265. package/src/writer/Icon/index.ts +1 -0
  266. package/src/writer/IconSocial/IconSocial.tsx +107 -0
  267. package/src/writer/IconSocial/index.ts +1 -0
  268. package/src/writer/Image/Image.styles.tsx +9 -0
  269. package/src/writer/Image/Image.tsx +35 -0
  270. package/src/writer/Image/index.ts +1 -0
  271. package/src/writer/List/List.styles.tsx +47 -0
  272. package/src/writer/List/List.tsx +29 -0
  273. package/src/writer/List/index.ts +4 -0
  274. package/src/writer/NavLinks/NavLinks.styles.ts +32 -0
  275. package/src/writer/NavLinks/NavLinks.tsx +95 -0
  276. package/src/writer/NavLinks/index.ts +7 -0
  277. package/src/writer/Pre/Pre.styles.tsx +13 -0
  278. package/src/writer/Pre/Pre.tsx +14 -0
  279. package/src/writer/Pre/index.ts +3 -0
  280. package/src/writer/README.md +1 -0
  281. package/src/writer/Steps/Steps.styles.tsx +91 -0
  282. package/src/writer/Steps/Steps.tsx +75 -0
  283. package/src/writer/Steps/index.ts +5 -0
  284. package/src/writer/Table/Table.styles.tsx +100 -0
  285. package/src/writer/Table/Table.tsx +158 -0
  286. package/src/writer/Table/index.ts +3 -0
  287. package/src/writer/Tabs/Tabs.tsx +67 -0
  288. package/src/writer/Tabs/TabsAnalytics.tsx +25 -0
  289. package/src/writer/Tabs/TabsPrimary.styles.tsx +187 -0
  290. package/src/writer/Tabs/TabsPrimary.tsx +215 -0
  291. package/src/writer/Tabs/TabsProps.tsx +13 -0
  292. package/src/writer/Tabs/TabsSecondary.styles.tsx +78 -0
  293. package/src/writer/Tabs/TabsSecondary.tsx +176 -0
  294. package/src/writer/Tabs/index.ts +2 -0
  295. package/src/writer/Tabs/useValueChange.ts +84 -0
  296. package/src/writer/Text/Text.styles.tsx +66 -0
  297. package/src/writer/Text/Text.tsx +79 -0
  298. package/src/writer/Text/index.ts +3 -0
  299. package/src/writer/TocCard/TocCard.module.css +44 -0
  300. package/src/writer/TocCard/TocCard.tsx +42 -0
  301. package/src/writer/TocCard/index.ts +3 -0
  302. package/src/writer/Update/Update.styles.tsx +33 -0
  303. package/src/writer/Update/Update.tsx +37 -0
  304. package/src/writer/Update/index.ts +1 -0
  305. package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
  306. package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
  307. package/src/writer/VideoGuide/index.ts +1 -0
  308. package/src/writer/index.ts +53 -0
  309. package/system.ts +1 -0
  310. package/tsconfig.json +46 -0
  311. package/types.d.ts +52 -0
  312. package/uxsdk.ts +1 -0
  313. package/views.ts +2 -0
  314. package/writer.ts +1 -0
@@ -0,0 +1,182 @@
1
+ // import { splitAnnotationsAndCode } from './extract-annotations.js';
2
+ import {
3
+ type CodeAnnotation,
4
+ type RawCode,
5
+ type HighlightedCode,
6
+ type Token
7
+ // Whitespace,
8
+ // isWhitespace,
9
+ } from 'codehike/code';
10
+ import {
11
+ type Lines,
12
+ type Tokens,
13
+ highlightSync as lighter,
14
+ LANG_NAMES,
15
+ type Theme
16
+ } from '@code-hike/lighter';
17
+
18
+ type Whitespace = string
19
+
20
+ type AnyToken = Token | Whitespace
21
+
22
+ function isWhitespace(token: Token | Whitespace): token is Whitespace {
23
+ return typeof token === 'string';
24
+ }
25
+
26
+ export function highlight(
27
+ data: RawCode,
28
+ theme: Theme,
29
+ lang: string
30
+ ): HighlightedCode {
31
+ // let { value, lang = 'txt' } = data;
32
+
33
+ if (!LANG_NAMES.includes(lang)) {
34
+ console.warn(`Unknown language "${lang}"`);
35
+ lang = 'txt';
36
+ }
37
+
38
+ // const { code, annotations } = await splitAnnotationsAndCode(
39
+ // value,
40
+ // lang,
41
+ // config.annotationPrefix || '!'
42
+ // );
43
+ //
44
+
45
+ const {
46
+ lines,
47
+ lang: lighterLang,
48
+ style
49
+ } = lighter(data.value, lang, theme as any, {
50
+ annotations: [],
51
+ scopes: false // true for better token transitions, but breaks css themes
52
+ });
53
+
54
+ const tokens = joinLines(lines);
55
+ // split surrounding whitespace for each token
56
+ const splitTokens = splitWhitespace(tokens);
57
+ // join consecutive whitespace tokens
58
+ const joinedTokens = joinWhitespace(splitTokens);
59
+
60
+ return {
61
+ ...data,
62
+ code: data.value,
63
+ tokens: joinedTokens,
64
+ lang: lighterLang,
65
+ annotations: [], // TODO: in the future
66
+ // annotations: compatAnnotations(annotations),
67
+ themeName: typeof theme === 'string' ? theme : theme?.name || 'unknown',
68
+ style
69
+ };
70
+ }
71
+
72
+ function compatAnnotations(annotations: any[]): CodeAnnotation[] {
73
+ const newAnnotations: CodeAnnotation[] = [];
74
+ for (const a of annotations) {
75
+ const { name, query, ranges } = a;
76
+ for (const r of ranges) {
77
+ if (r.lineNumber) {
78
+ const { lineNumber, fromColumn, toColumn } = r;
79
+ newAnnotations.push({
80
+ name,
81
+ query,
82
+ lineNumber,
83
+ fromColumn,
84
+ toColumn
85
+ });
86
+ } else {
87
+ const { fromLineNumber, toLineNumber } = r;
88
+ newAnnotations.push({
89
+ name,
90
+ query,
91
+ fromLineNumber,
92
+ toLineNumber
93
+ });
94
+ }
95
+ }
96
+ }
97
+ return newAnnotations;
98
+ }
99
+
100
+ // group the Lines into one array
101
+ function joinLines(lines: Lines): AnyToken[] {
102
+ const joinedTokens: AnyToken[] = [];
103
+ lines.forEach((lineOrGroup, i) => {
104
+ if ('lines' in lineOrGroup) {
105
+ throw new Error('Shouldnt be groups');
106
+ } else {
107
+ const tokens = joinTokens(lineOrGroup.tokens);
108
+ joinedTokens.push(...tokens);
109
+ if (i < lines.length - 1) {
110
+ joinedTokens.push('\n');
111
+ }
112
+ }
113
+ });
114
+ return joinedTokens;
115
+ }
116
+
117
+ function joinTokens(tokens: Tokens): AnyToken[] {
118
+ return tokens.map((tokenOrGroup) => {
119
+ if ('tokens' in tokenOrGroup) {
120
+ throw new Error('Shouldnt be groups');
121
+ } else {
122
+ const t = [tokenOrGroup.content] as Token;
123
+ const { color, ...rest } = tokenOrGroup.style || {};
124
+ t.push(color);
125
+ if (Object.keys(rest).length) {
126
+ t.push(rest);
127
+ }
128
+ return t;
129
+ }
130
+ });
131
+ }
132
+
133
+ function splitWhitespace(tokens: AnyToken[]) {
134
+ const ejected: AnyToken[] = [];
135
+ tokens.forEach((tokenOrGroup) => {
136
+ if (isWhitespace(tokenOrGroup)) {
137
+ ejected.push(tokenOrGroup);
138
+ } else {
139
+ const [before, content, after] = splitSurroundingWhitespace(
140
+ tokenOrGroup[0]
141
+ );
142
+ if (before?.length) {
143
+ ejected.push(before);
144
+ }
145
+ if (content.length) {
146
+ const copy = [...tokenOrGroup] as Token;
147
+ copy[0] = content;
148
+ ejected.push(copy);
149
+ }
150
+ if (after?.length) {
151
+ ejected.push(after);
152
+ }
153
+ }
154
+ });
155
+ return ejected;
156
+ }
157
+
158
+ function joinWhitespace(tokens: AnyToken[]) {
159
+ const joinedTokens: AnyToken[] = [];
160
+ tokens.forEach((tokenOrGroup) => {
161
+ if (isWhitespace(tokenOrGroup)) {
162
+ let last = joinedTokens[joinedTokens.length - 1];
163
+ if (last && isWhitespace(last)) {
164
+ joinedTokens[joinedTokens.length - 1] += tokenOrGroup;
165
+ } else if (tokenOrGroup !== '') {
166
+ joinedTokens.push(tokenOrGroup);
167
+ }
168
+ } else if (tokenOrGroup[0].length > 0) {
169
+ joinedTokens.push(tokenOrGroup);
170
+ }
171
+ });
172
+ return joinedTokens;
173
+ }
174
+
175
+ // splits " \t foo bar \n" into [" \t ","foo bar"," \n"]
176
+ // "foo bar" -> ["","foo bar",""]
177
+ function splitSurroundingWhitespace(content: string) {
178
+ const trimmed = content.trim();
179
+ const before = content.slice(0, content.indexOf(trimmed));
180
+ const after = content.slice(content.indexOf(trimmed) + trimmed.length);
181
+ return [before, trimmed, after];
182
+ }
@@ -0,0 +1,37 @@
1
+ export {
2
+ annotations
3
+ } from "./Code"
4
+ export type {
5
+ CodeProps
6
+ } from "./Code"
7
+ export {
8
+ Code,
9
+ CodeLoader,
10
+
11
+ highlightAsync,
12
+ highlight
13
+ } from "./Code"
14
+ //
15
+
16
+ export type { CodeSampleProps } from "./CodeSample";
17
+ export { CodeSample } from "./CodeSample";
18
+ //
19
+
20
+ export type {
21
+ CodeTabsProps
22
+ } from "./CodeTabs";
23
+ export {
24
+ withCodeTabs
25
+ } from "./CodeTabs";
26
+ //
27
+
28
+ export type { CodeThemeProps, CodeThemeBlockProps } from "./CodeTheme";
29
+ export {
30
+ CodeTheme,
31
+
32
+ useCodeTheme
33
+ } from "./CodeTheme";
34
+
35
+ export {
36
+ CoderProvider
37
+ } from "./CoderProvider";
@@ -0,0 +1,57 @@
1
+ :root {
2
+ --syntax-primary: #1971a8;
3
+ --syntax-secondary: #008c6a;
4
+
5
+ --syntax1: #FFFFFF;
6
+ --syntax2: #ffffff00;
7
+ --syntax3: #D9D7D5;
8
+ --syntax4: #ECECEC;
9
+ --syntax5: #F5F5F5;
10
+ --syntax6: #282828;
11
+ --syntax7: #565456;
12
+ --syntax8: #C7C6C5;
13
+ --syntax9: #A6A6A6;
14
+ --syntax10: #242424;
15
+ --syntax11: #EEF5FE;
16
+ --syntax12: #82ADF3;
17
+ --syntax13: #3C93FD;
18
+ --syntax14: #CECECE;
19
+ --syntax15: #353740;
20
+ --syntax16: #e62c7a;
21
+ --syntax17: #007400;
22
+ --syntax18: #643820;
23
+ --syntax19: #272AD8;
24
+ --syntax20: #AA0D91;
25
+ --syntax21: #3F6E74;
26
+ --syntax23: #536579;
27
+ --syntax24: var(--syntax-primary);
28
+ --syntax26: #816927;
29
+ --syntax27: var(--syntax-secondary);
30
+ }
31
+
32
+ [data-color-scheme="dark"] {
33
+ }
34
+ @media (prefers-color-scheme: dark) {
35
+ :root:not([data-color-scheme="light"]):not([data-color-scheme="dark"]) {
36
+ }
37
+ }
38
+
39
+ [data-color-scheme="dark"] {
40
+ --syntax1: #353740;
41
+ --syntax2: #353740;
42
+ --syntax15: #fff;
43
+ --syntax19: var(--syntax-primary);
44
+ --syntax27: var(--syntax-secondary);
45
+ }
46
+
47
+ /* System Dark Mode Support */
48
+ @media (prefers-color-scheme: dark) {
49
+ :root:not([data-color-scheme="light"]):not([data-color-scheme="dark"]) {
50
+ --syntax1: #353740;
51
+ --syntax2: #353740;
52
+ --syntax15: #fff;
53
+ --syntax19: var(--syntax-primary);
54
+ --syntax27: var(--syntax-secondary);
55
+ }
56
+ }
57
+
@@ -0,0 +1,270 @@
1
+ export default {
2
+ name: "classic",
3
+ "type": "from-css",
4
+ colors: {
5
+ "list.focusForeground": "var(--syntax1)",
6
+ "scrollbar.shadow": "var(--syntax2)",
7
+ "tab.activeBorder": "var(--syntax1)",
8
+ "widget.shadow": "var(--syntax2)",
9
+ "activityBar.border": "var(--syntax3)",
10
+ "editorGroup.border": "var(--syntax3)",
11
+ "editorGroupHeader.tabsBorder": "var(--syntax3)",
12
+ "editorWidget.border": "var(--syntax3)",
13
+ "editorWidget.resizeBorder": "var(--syntax3)",
14
+ "input.border": "var(--syntax3)",
15
+ "notificationCenter.border": "var(--syntax3)",
16
+ "notifications.border": "var(--syntax3)",
17
+ "panel.border": "var(--syntax3)",
18
+ "sideBar.border": "var(--syntax3)",
19
+ "statusBar.border": "var(--syntax3)",
20
+ "tab.border": "var(--syntax3)",
21
+ "activityBar.background": "var(--syntax4)",
22
+ "statusBar.background": "var(--syntax4)",
23
+ "statusBar.noFolderBackground": "var(--syntax4)",
24
+ "statusBar.debuggingBackground": "var(--syntax4)",
25
+ "editorGroupHeader.tabsBackground": "var(--syntax5)",
26
+ "editorWidget.background": "var(--syntax5)",
27
+ "sideBar.background": "var(--syntax5)",
28
+ "sideBarSectionHeader.background": "var(--syntax5)",
29
+ "tab.inactiveBackground": "var(--syntax5)",
30
+ "activityBarBadge.background": "var(--syntax6)",
31
+ "activityBar.foreground": "var(--syntax6)",
32
+ "statusBar.foreground": "var(--syntax7)",
33
+ "input.placeholderForeground": "var(--syntax8)",
34
+ "editorLineNumber.foreground": "var(--syntax9)",
35
+ "editorLineNumber.activeForeground": "var(--syntax6)",
36
+ foreground: "var(--syntax6)",
37
+ "panelTitle.activeForeground": "var(--syntax6)",
38
+ "sideBarTitle.foreground": "var(--syntax6)",
39
+ "sideBarSectionHeader.foreground": "var(--syntax6)",
40
+ "panelTitle.inactiveForeground": "var(--syntax10)",
41
+ "tab.inactiveForeground": "var(--syntax10)",
42
+ "list.highlightForeground": "var(--syntax10)",
43
+ "editor.lineHighlightBackground": "var(--syntax11)",
44
+ focusBorder: "var(--syntax12)",
45
+ "button.background": "var(--syntax13)",
46
+ "list.activeSelectionBackground": "var(--syntax13)",
47
+ "list.focusBackground": "var(--syntax13)",
48
+ "selection.background": "#B3D7FF",
49
+ "list.inactiveSelectionBackground": "var(--syntax14)",
50
+ "terminal.ansiBlack": "var(--syntax15)",
51
+ "terminal.ansiBrightBlack": "var(--syntax15)",
52
+ "terminal.ansiRed": "var(--syntax16)",
53
+ "terminal.ansiBrightRed": "var(--syntax16)",
54
+ "terminal.ansiGreen": "var(--syntax17)",
55
+ "terminal.ansiBrightGreen": "var(--syntax17)",
56
+ "terminal.ansiYellow": "var(--syntax18)",
57
+ "terminal.ansiBrightYellow": "var(--syntax18)",
58
+ "terminal.ansiBlue": "var(--syntax19)",
59
+ "terminal.ansiBrightBlue": "var(--syntax19)",
60
+ "terminal.ansiMagenta": "var(--syntax20)",
61
+ "terminal.ansiBrightMagenta": "var(--syntax20)",
62
+ "terminal.ansiCyan": "var(--syntax21)",
63
+ "terminal.ansiBrightCyan": "var(--syntax21)",
64
+ },
65
+ tokenColors: [
66
+ {
67
+ scope: "new.expr entity.name",
68
+ settings: {
69
+ foreground: "var(--syntax15)",
70
+ },
71
+ },
72
+ {
73
+ name: "Comments",
74
+ scope: ["comment", "comment storage.type"],
75
+ settings: {
76
+ foreground: "var(--syntax23)",
77
+ fontStyle: "italic",
78
+ },
79
+ },
80
+ {
81
+ name: "CSS",
82
+ scope: [
83
+ "entity.other.attribute-name.pseudo-class.css",
84
+ "entity.other.attribute-name.pseudo-class.scss",
85
+ "entity.other.attribute-name.pseudo-element.css",
86
+ "entity.other.attribute-name.pseudo-element.scss",
87
+ "support.function.calc.css",
88
+ "support.function.calc.scss",
89
+ "support.type.property-name.css",
90
+ "support.type.property-name.scss",
91
+ "support.type.vendored.property-name.css",
92
+ "support.type.vendored.property-name.scss",
93
+ "meta.property-value.css support.constant",
94
+ "meta.property-value.scss support.constant",
95
+ "meta.property-value.css support.constant.property-value",
96
+ "meta.property-value.scss support.constant.property-value",
97
+ "support.function.transform.css",
98
+ "support.function.transform.scss",
99
+ ],
100
+ settings: {
101
+ foreground: "var(--syntax20)",
102
+ },
103
+ },
104
+ {
105
+ name: "Decorator",
106
+ scope: [
107
+ "meta.decorator",
108
+ "meta.decorator punctuation.decorator",
109
+ "meta.decorator variable.other.readwrite",
110
+ "meta.decorator meta.function-call entity.name.function",
111
+ ],
112
+ settings: {
113
+ foreground: "var(--syntax18)",
114
+ },
115
+ },
116
+ {
117
+ name: "Doctype",
118
+ scope: ["meta.tag.sgml.html"],
119
+ settings: {
120
+ foreground: "var(--syntax9)",
121
+ },
122
+ },
123
+ {
124
+ name: "Functions",
125
+ scope: ["entity.name.function", "support.function"],
126
+ settings: {
127
+ foreground: "var(--syntax15)",
128
+ },
129
+ },
130
+ {
131
+ name: "Keys (general)",
132
+ scope: [
133
+ "meta.property-list meta.property-name",
134
+ "support.type.property-name",
135
+ "support.type.map.key",
136
+ "entity.name.tag.yaml",
137
+ ],
138
+ settings: {
139
+ foreground: "var(--syntax15)",
140
+ },
141
+ },
142
+ // NEW: Explicit rule for object literal & JSON keys – will render red (syntax16)
143
+ {
144
+ name: "Object Keys",
145
+ scope: [
146
+ "meta.object-literal.key",
147
+ "meta.object-literal.key string.quoted.double",
148
+ "meta.object-literal.key string.quoted.single",
149
+ "meta.object-literal.key punctuation.definition.string.begin",
150
+ "meta.object-literal.key punctuation.definition.string.end",
151
+ "support.type.property-name.json",
152
+ ],
153
+ settings: {
154
+ foreground: "var(--syntax16)",
155
+ },
156
+ },
157
+ {
158
+ name: "Keywords",
159
+ scope: [
160
+ "keyword.control",
161
+ "keyword.declaration",
162
+ "keyword.expressions-and-types",
163
+ "keyword.operator.new",
164
+ "keyword.reserved",
165
+ "keyword.statement",
166
+ "storage.type",
167
+ "storage.modifier",
168
+ "constant.language",
169
+ "variable.language.super",
170
+ "variable.language.this",
171
+ "text.html entity.name.tag",
172
+ "meta.tag entity.name.tag",
173
+ "meta.tag support.class",
174
+ "string.regexp keyword.other",
175
+ ],
176
+ settings: {
177
+ foreground: "var(--syntax24)",
178
+ fontStyle: "bold",
179
+ },
180
+ },
181
+ {
182
+ name: "Operators",
183
+ scope: [
184
+ "storage.type.function.arrow",
185
+ "meta.template.expression punctuation",
186
+ "punctuation.separator.key-value",
187
+ "meta.object-literal.key meta.brace.square",
188
+ "meta.template.expression keyword.operator",
189
+ "keyword.operator.or.regexp",
190
+ "keyword.operator.quantifier",
191
+ "punctuation.definition.group.regexp",
192
+ "punctuation.definition.character-class",
193
+ ],
194
+ settings: {
195
+ foreground: "var(--syntax15)",
196
+ },
197
+ },
198
+ {
199
+ scope: [
200
+ "meta.tag entity.other.attribute-name",
201
+ "constant.character.escape.backslash",
202
+ ],
203
+ settings: {
204
+ foreground: "var(--syntax26)",
205
+ },
206
+ },
207
+ {
208
+ name: "Numbers",
209
+ scope: ["constant.numeric", "keyword.other.unit", "constant.other.color"],
210
+ settings: {
211
+ foreground: "var(--syntax19)",
212
+ },
213
+ },
214
+ {
215
+ name: "Strings",
216
+ scope: [
217
+ "string",
218
+ "variable.parameter.url.scss",
219
+ "markup.heading.markdown",
220
+ "beginning.punctuation.definition.list.markdown",
221
+ "meta.template.expression meta.embedded punctuation.definition.string.begin",
222
+ "meta.template.expression meta.embedded punctuation.definition.string.end",
223
+ ],
224
+ settings: {
225
+ foreground: "var(--syntax27)",
226
+ },
227
+ },
228
+ {
229
+ name: "Types",
230
+ scope: [
231
+ "meta.type",
232
+ "meta.return.type",
233
+ "entity.name.type",
234
+ "support.type.primitive",
235
+ ],
236
+ settings: {
237
+ foreground: "var(--syntax15)",
238
+ },
239
+ },
240
+ {
241
+ name: "Variables",
242
+ scope: [
243
+ "meta.objectliteral variable.other.object",
244
+ "entity.name.type.module",
245
+ "entity.other.inherited-class",
246
+ "variable.scss",
247
+ "variable.other.bracket.shell",
248
+ "entity.name.function.scss",
249
+ ],
250
+ settings: {
251
+ foreground: "var(--syntax21)",
252
+ },
253
+ },
254
+ {
255
+ name: "Keywords",
256
+ scope: [
257
+ "keyword.control.at-rule",
258
+ "meta.import variable.other.readwrite",
259
+ "meta.definition.variable variable.other.readwrite",
260
+ "meta.definition.variable variable.other.constant",
261
+ "meta.template.expression variable.other.readwrite",
262
+ "meta.template.expression variable.other.constant",
263
+ "support.constant.property-value",
264
+ ],
265
+ settings: {
266
+ foreground: "var(--syntax15)",
267
+ },
268
+ }
269
+ ],
270
+ };
@@ -0,0 +1,64 @@
1
+ :root {
2
+ --syntax-primary: #7051d4;
3
+ --syntax-secondary: #D12F1B;
4
+ --syntax-tertiary: #713DA9;
5
+
6
+ --syntax1: #FFFFFF;
7
+ --syntax2: #ffffff00;
8
+ --syntax3: #D9D7D5;
9
+ --syntax4: #ECECEC;
10
+ --syntax5: #F5F5F5;
11
+ --syntax6: #282828;
12
+ --syntax7: #565456;
13
+ --syntax8: #C7C6C5;
14
+ --syntax9: #A6A6A6;
15
+ --syntax10: #242424;
16
+ --syntax11: #EEF5FE;
17
+ --syntax12: #82ADF3;
18
+ --syntax13: #3C93FD;
19
+ --syntax14: #CECECE;
20
+ --syntax15: #000000;
21
+ --syntax16: #C41A16;
22
+ --syntax17: #007400;
23
+ --syntax18: #643820;
24
+ --syntax19: #272AD8;
25
+ --syntax20: #AA0D91;
26
+ --syntax21: #3F6E74;
27
+ --syntax22: var(--syntax-tertiary);
28
+ --syntax23: #536579;
29
+ --syntax24: var(--syntax-primary);
30
+ --syntax25: #AD3DA4;
31
+ --syntax26: #816927;
32
+ --syntax27: var(--syntax-secondary);
33
+ }
34
+
35
+ [data-color-scheme="dark"] {
36
+ --syntax-secondary: #df3079;
37
+ }
38
+ @media (prefers-color-scheme: dark) {
39
+ :root:not([data-color-scheme="light"]):not([data-color-scheme="dark"]) {
40
+ --syntax-secondary: #df3079;
41
+ }
42
+ }
43
+
44
+ [data-color-scheme="dark"] {
45
+ --syntax1: #000;
46
+ --syntax2: #000;
47
+ --syntax15: #fff;
48
+ --syntax16: #0e0e10;
49
+ --syntax19: #2e95d3;
50
+ --syntax27: var(--syntax-secondary);
51
+ }
52
+
53
+ /* System Dark Mode Support */
54
+ @media (prefers-color-scheme: dark) {
55
+ :root:not([data-color-scheme="light"]):not([data-color-scheme="dark"]) {
56
+ --syntax1: #000;
57
+ --syntax2: #000;
58
+ --syntax15: #fff;
59
+ --syntax16: #0e0e10;
60
+ --syntax19: #2e95d3;
61
+ --syntax27: var(--syntax-secondary);
62
+ }
63
+ }
64
+