@nyxwire/starlight 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -2
  3. package/dist/config.d.ts +9 -0
  4. package/dist/config.js +32 -0
  5. package/dist/docs/foundations/accessibility.md +71 -0
  6. package/dist/docs/foundations/color-roles.md +114 -0
  7. package/dist/docs/foundations/effects-motion.md +150 -0
  8. package/dist/docs/foundations/flavors.md +156 -0
  9. package/dist/docs/foundations/icons.md +45 -0
  10. package/dist/docs/foundations/palette.md +180 -0
  11. package/dist/docs/foundations/spacing-elevation.md +168 -0
  12. package/dist/docs/foundations/typography.md +80 -0
  13. package/dist/docs/index.md +51 -0
  14. package/dist/docs/kitchen-sink.md +283 -0
  15. package/dist/docs/manifest.json +61 -0
  16. package/dist/docs/setup.md +190 -0
  17. package/dist/ec-themes.d.ts +443 -0
  18. package/dist/ec-themes.js +217 -0
  19. package/dist/expressive-code.d.ts +75 -0
  20. package/dist/expressive-code.js +101 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.js +25 -0
  23. package/dist/options.d.ts +29 -0
  24. package/dist/options.js +56 -0
  25. package/dist/runtime.d.ts +16 -0
  26. package/dist/runtime.js +52 -0
  27. package/dist/theme-bridge.d.ts +27 -0
  28. package/dist/theme-bridge.js +73 -0
  29. package/package.json +67 -3
  30. package/src/chrome.css +191 -0
  31. package/src/components/ThemeProvider.astro +15 -0
  32. package/src/components/ThemeSelect.astro +51 -0
  33. package/src/components/env.d.ts +5 -0
  34. package/src/config.ts +53 -0
  35. package/src/content-components.css +154 -0
  36. package/src/ec-themes.ts +246 -0
  37. package/src/expressive-code.ts +115 -0
  38. package/src/index.ts +32 -0
  39. package/src/options.ts +80 -0
  40. package/src/prose.css +108 -0
  41. package/src/runtime.ts +67 -0
  42. package/src/theme-bridge.css +130 -0
  43. package/src/theme-bridge.ts +89 -0
  44. package/styles.css +299 -0
@@ -0,0 +1,443 @@
1
+ import { syntaxRoles } from '@nyxwire/palette';
2
+ import type { DarkFlavorName, FlavorName } from '@nyxwire/palette';
3
+ type SyntaxRoleName = keyof typeof syntaxRoles;
4
+ export type TokenRoleName = Exclude<SyntaxRoleName, 'editor-bg' | 'selection' | 'line-highlight'>;
5
+ export type ExpressiveCodeTokenColor = {
6
+ readonly name: string;
7
+ readonly scope: readonly string[];
8
+ readonly settings: {
9
+ readonly foreground?: string;
10
+ readonly fontStyle?: string;
11
+ };
12
+ };
13
+ /** A VS Code / TextMate theme object: plain JSON, accepted by Expressive Code and Shiki. */
14
+ export type NyxwireExpressiveCodeTheme = {
15
+ readonly name: string;
16
+ readonly type: 'dark' | 'light';
17
+ readonly colors: Readonly<Record<string, string>>;
18
+ readonly tokenColors: readonly ExpressiveCodeTokenColor[];
19
+ };
20
+ /** TextMate scopes per palette syntax role (contract §6.4). More specific scopes win in Shiki. */
21
+ export declare const TOKEN_SCOPES: {
22
+ readonly keyword: readonly ["keyword", "keyword.control", "keyword.other", "keyword.operator.new", "keyword.operator.expression", "keyword.operator.wordlike", "keyword.operator.logical.python", "variable.language"];
23
+ readonly storage: readonly ["storage", "storage.type"];
24
+ readonly modifier: readonly ["storage.modifier", "keyword.other.modifier"];
25
+ readonly string: readonly ["string", "string.quoted", "string.template", "punctuation.definition.string"];
26
+ readonly number: readonly ["constant.numeric", "keyword.other.unit"];
27
+ readonly constant: readonly ["constant", "constant.other", "constant.character", "variable.other.constant", "variable.other.enummember", "support.constant"];
28
+ readonly boolean: readonly ["constant.language", "constant.language.boolean"];
29
+ readonly null: readonly ["constant.language.null", "constant.language.undefined", "constant.language.nil", "constant.language.none"];
30
+ readonly function: readonly ["entity.name.function", "support.function", "variable.function"];
31
+ readonly method: readonly ["entity.name.function.member", "meta.method-call entity.name.function"];
32
+ readonly type: readonly ["entity.name.type", "support.type", "support.type.primitive", "entity.name.type.parameter"];
33
+ readonly class: readonly ["entity.name.class", "support.class", "entity.other.inherited-class"];
34
+ readonly interface: readonly ["entity.name.type.interface"];
35
+ readonly enum: readonly ["entity.name.type.enum"];
36
+ readonly namespace: readonly ["entity.name.namespace", "entity.name.type.module", "entity.name.scope-resolution"];
37
+ readonly variable: readonly ["variable", "variable.other", "variable.other.readwrite", "meta.definition.variable"];
38
+ readonly parameter: readonly ["variable.parameter", "meta.parameter"];
39
+ readonly property: readonly ["variable.other.property", "variable.other.object.property", "support.variable.property", "meta.object-literal.key", "support.type.property-name", "entity.name.tag.yaml"];
40
+ readonly tag: readonly ["entity.name.tag"];
41
+ readonly attribute: readonly ["entity.other.attribute-name"];
42
+ readonly operator: readonly ["keyword.operator", "punctuation.separator.key-value"];
43
+ readonly punctuation: readonly ["punctuation", "punctuation.separator", "punctuation.terminator", "punctuation.accessor", "punctuation.definition.tag", "meta.brace"];
44
+ readonly comment: readonly ["comment", "punctuation.definition.comment", "string.comment"];
45
+ readonly regex: readonly ["string.regexp"];
46
+ readonly escape: readonly ["constant.character.escape", "punctuation.definition.template-expression", "punctuation.section.embedded"];
47
+ readonly decorator: readonly ["meta.decorator", "entity.name.function.decorator", "punctuation.decorator", "storage.type.annotation"];
48
+ readonly 'markup-heading': readonly ["markup.heading", "entity.name.section.markdown"];
49
+ readonly 'markup-link': readonly ["markup.underline.link", "string.other.link", "markup.link"];
50
+ readonly inserted: readonly ["markup.inserted", "meta.diff.header.to-file", "punctuation.definition.inserted"];
51
+ readonly deleted: readonly ["markup.deleted", "meta.diff.header.from-file", "punctuation.definition.deleted", "invalid", "invalid.illegal"];
52
+ readonly changed: readonly ["markup.changed", "meta.diff.range", "punctuation.definition.changed"];
53
+ };
54
+ /**
55
+ * Builds a VS Code theme from one flavor. Dark flavors share their accents, so a dark theme only
56
+ * differs in its neutral editor colors; code-block surfaces are re-pointed to CSS variables by
57
+ * `expressiveCodeStyleOverrides`, which keeps them in sync with the active flavor at runtime.
58
+ */
59
+ export declare function createExpressiveCodeTheme(flavorName: FlavorName): NyxwireExpressiveCodeTheme;
60
+ /** Raw dark theme built from Nocturne neutrals and the accents shared by every dark flavor. */
61
+ export declare const nyxwireDark: NyxwireExpressiveCodeTheme;
62
+ /** Raw light theme built from Lumen. */
63
+ export declare const nyxwireLight: NyxwireExpressiveCodeTheme;
64
+ /**
65
+ * Rendered theme for one flavor: syntax ink is lifted to 5.5:1 on the dimmer of the two code
66
+ * surfaces (line highlight in dark flavors, editor background in Lumen). Raw themes stay untouched.
67
+ */
68
+ export declare function createCodeTheme(flavor: FlavorName): {
69
+ name: string;
70
+ type: "dark" | "light";
71
+ colors: {
72
+ "editor.background": string;
73
+ "editor.foreground": string;
74
+ "editor.selectionBackground": string;
75
+ "editorLineNumber.foreground": string;
76
+ "editorLineNumber.activeForeground": string;
77
+ "editorGroupHeader.tabsBackground": string;
78
+ "editorGroupHeader.tabsBorder": string;
79
+ "tab.activeBackground": string;
80
+ "tab.activeForeground": string;
81
+ "tab.activeBorder": string;
82
+ "tab.activeBorderTop": string;
83
+ "tab.inactiveBackground": string;
84
+ "tab.inactiveForeground": string;
85
+ "titleBar.activeBackground": string;
86
+ "titleBar.activeForeground": string;
87
+ "titleBar.border": string;
88
+ "terminal.background": string;
89
+ "terminal.ansiBlack": string;
90
+ "terminal.ansiRed": string;
91
+ "terminal.ansiGreen": string;
92
+ "terminal.ansiYellow": string;
93
+ "terminal.ansiBlue": string;
94
+ "terminal.ansiMagenta": string;
95
+ "terminal.ansiCyan": string;
96
+ "terminal.ansiWhite": string;
97
+ "terminal.ansiBrightBlack": string;
98
+ "terminal.ansiBrightRed": string;
99
+ "terminal.ansiBrightGreen": string;
100
+ "terminal.ansiBrightYellow": string;
101
+ "terminal.ansiBrightBlue": string;
102
+ "terminal.ansiBrightMagenta": string;
103
+ "terminal.ansiBrightCyan": string;
104
+ "terminal.ansiBrightWhite": string;
105
+ focusBorder: string;
106
+ "scrollbarSlider.background": string;
107
+ "scrollbarSlider.hoverBackground": string;
108
+ "menu.selectionBackground": string;
109
+ "menu.selectionForeground": string;
110
+ "textLink.foreground": string;
111
+ "widget.shadow": string;
112
+ foreground: string;
113
+ disabledForeground: string;
114
+ descriptionForeground: string;
115
+ errorForeground: string;
116
+ "icon.foreground": string;
117
+ contrastActiveBorder: string;
118
+ contrastBorder: string;
119
+ "textBlockQuote.background": string;
120
+ "textBlockQuote.border": string;
121
+ "textCodeBlock.background": string;
122
+ "textLink.activeForeground": string;
123
+ "textPreformat.foreground": string;
124
+ "textSeparator.foreground": string;
125
+ "editorActiveLineNumber.foreground": string;
126
+ "editor.inactiveSelectionBackground": string;
127
+ "editor.selectionHighlightBackground": string;
128
+ "editorError.foreground": string;
129
+ "editorWarning.foreground": string;
130
+ "editorInfo.foreground": string;
131
+ "editorHint.foreground": string;
132
+ "problemsErrorIcon.foreground": string;
133
+ "problemsWarningIcon.foreground": string;
134
+ "problemsInfoIcon.foreground": string;
135
+ "editor.findMatchBackground": string;
136
+ "editor.findMatchHighlightBackground": string;
137
+ "editor.findRangeHighlightBackground": string;
138
+ "editorLink.activeForeground": string;
139
+ "editorLightBulb.foreground": string;
140
+ "editorLightBulbAutoFix.foreground": string;
141
+ "diffEditor.insertedTextBackground": string;
142
+ "diffEditor.insertedTextBorder": string;
143
+ "diffEditor.removedTextBackground": string;
144
+ "diffEditor.removedTextBorder": string;
145
+ "diffEditor.insertedLineBackground": string;
146
+ "diffEditor.removedLineBackground": string;
147
+ "editorStickyScroll.background": string;
148
+ "editorStickyScrollHover.background": string;
149
+ "editorInlayHint.background": string;
150
+ "editorInlayHint.foreground": string;
151
+ "editorInlayHint.typeForeground": string;
152
+ "editorInlayHint.typeBackground": string;
153
+ "editorInlayHint.parameterForeground": string;
154
+ "editorInlayHint.parameterBackground": string;
155
+ "editorPane.background": string;
156
+ "editorGroup.emptyBackground": string;
157
+ "editorGroup.focusedEmptyBorder": string;
158
+ "editorGroupHeader.noTabsBackground": string;
159
+ "editorGroupHeader.border": string;
160
+ "editorGroup.border": string;
161
+ "editorGroup.dropBackground": string;
162
+ "editorGroup.dropIntoPromptForeground": string;
163
+ "editorGroup.dropIntoPromptBackground": string;
164
+ "editorGroup.dropIntoPromptBorder": string;
165
+ "sideBySideEditor.horizontalBorder": string;
166
+ "sideBySideEditor.verticalBorder": string;
167
+ "scrollbar.shadow": string;
168
+ "scrollbarSlider.activeBackground": string;
169
+ "panel.background": string;
170
+ "panel.border": string;
171
+ "panelTitle.activeBorder": string;
172
+ "panelTitle.activeForeground": string;
173
+ "panelTitle.inactiveForeground": string;
174
+ "panelSectionHeader.background": string;
175
+ "editorWidget.background": string;
176
+ "editorWidget.foreground": string;
177
+ "editorWidget.border": string;
178
+ "quickInput.background": string;
179
+ "quickInput.foreground": string;
180
+ "quickInputTitle.background": string;
181
+ "pickerGroup.foreground": string;
182
+ "pickerGroup.border": string;
183
+ "editor.hoverHighlightBackground": string;
184
+ "editorHoverWidget.background": string;
185
+ "editorHoverWidget.foreground": string;
186
+ "editorHoverWidget.border": string;
187
+ "editorHoverWidget.statusBarBackground": string;
188
+ "titleBar.inactiveBackground": string;
189
+ "titleBar.inactiveForeground": string;
190
+ "toolbar.hoverBackground": string;
191
+ "toolbar.activeBackground": string;
192
+ "tab.unfocusedActiveBackground": string;
193
+ "tab.unfocusedInactiveBackground": string;
194
+ "tab.unfocusedActiveForeground": string;
195
+ "tab.unfocusedInactiveForeground": string;
196
+ "tab.hoverBackground": string;
197
+ "tab.unfocusedHoverBackground": string;
198
+ "tab.hoverForeground": string;
199
+ "tab.unfocusedHoverForeground": string;
200
+ "tab.border": string;
201
+ "tab.lastPinnedBorder": string;
202
+ "tab.unfocusedActiveBorder": string;
203
+ "tab.unfocusedActiveBorderTop": string;
204
+ "tab.hoverBorder": string;
205
+ "tab.unfocusedHoverBorder": string;
206
+ "tab.activeModifiedBorder": string;
207
+ "tab.inactiveModifiedBorder": string;
208
+ "tab.unfocusedActiveModifiedBorder": string;
209
+ "tab.unfocusedInactiveModifiedBorder": string;
210
+ "badge.background": string;
211
+ "badge.foreground": string;
212
+ "button.background": string;
213
+ "button.foreground": string;
214
+ "button.border": string;
215
+ "button.separator": string;
216
+ "button.hoverBackground": string;
217
+ "button.secondaryBackground": string;
218
+ "button.secondaryForeground": string;
219
+ "button.secondaryHoverBackground": string;
220
+ "dropdown.background": string;
221
+ "dropdown.foreground": string;
222
+ "dropdown.border": string;
223
+ "list.activeSelectionBackground": string;
224
+ "list.activeSelectionForeground": string;
225
+ "tree.indentGuidesStroke": string;
226
+ "input.background": string;
227
+ "input.foreground": string;
228
+ "input.placeholderForeground": string;
229
+ "inputOption.activeBorder": string;
230
+ "inputOption.hoverBackground": string;
231
+ "inputOption.activeBackground": string;
232
+ "inputOption.activeForeground": string;
233
+ "inputValidation.infoBackground": string;
234
+ "inputValidation.infoBorder": string;
235
+ "inputValidation.warningBackground": string;
236
+ "inputValidation.warningBorder": string;
237
+ "inputValidation.errorBackground": string;
238
+ "inputValidation.errorBorder": string;
239
+ "keybindingLabel.background": string;
240
+ "keybindingLabel.foreground": string;
241
+ "keybindingLabel.border": string;
242
+ "keybindingLabel.bottomBorder": string;
243
+ "menu.foreground": string;
244
+ "menu.background": string;
245
+ "menu.separatorBackground": string;
246
+ "editor.snippetTabstopHighlightBackground": string;
247
+ "editor.snippetFinalTabstopHighlightBorder": string;
248
+ } & {
249
+ [key: string]: string;
250
+ };
251
+ settings: import("@expressive-code/core").ThemeSetting[];
252
+ };
253
+ /** One rendered theme per flavor, the configured dark flavor first (Expressive Code's base theme). */
254
+ export declare function createCodeThemes(dark?: DarkFlavorName): {
255
+ name: string;
256
+ type: "dark" | "light";
257
+ colors: {
258
+ "editor.background": string;
259
+ "editor.foreground": string;
260
+ "editor.selectionBackground": string;
261
+ "editorLineNumber.foreground": string;
262
+ "editorLineNumber.activeForeground": string;
263
+ "editorGroupHeader.tabsBackground": string;
264
+ "editorGroupHeader.tabsBorder": string;
265
+ "tab.activeBackground": string;
266
+ "tab.activeForeground": string;
267
+ "tab.activeBorder": string;
268
+ "tab.activeBorderTop": string;
269
+ "tab.inactiveBackground": string;
270
+ "tab.inactiveForeground": string;
271
+ "titleBar.activeBackground": string;
272
+ "titleBar.activeForeground": string;
273
+ "titleBar.border": string;
274
+ "terminal.background": string;
275
+ "terminal.ansiBlack": string;
276
+ "terminal.ansiRed": string;
277
+ "terminal.ansiGreen": string;
278
+ "terminal.ansiYellow": string;
279
+ "terminal.ansiBlue": string;
280
+ "terminal.ansiMagenta": string;
281
+ "terminal.ansiCyan": string;
282
+ "terminal.ansiWhite": string;
283
+ "terminal.ansiBrightBlack": string;
284
+ "terminal.ansiBrightRed": string;
285
+ "terminal.ansiBrightGreen": string;
286
+ "terminal.ansiBrightYellow": string;
287
+ "terminal.ansiBrightBlue": string;
288
+ "terminal.ansiBrightMagenta": string;
289
+ "terminal.ansiBrightCyan": string;
290
+ "terminal.ansiBrightWhite": string;
291
+ focusBorder: string;
292
+ "scrollbarSlider.background": string;
293
+ "scrollbarSlider.hoverBackground": string;
294
+ "menu.selectionBackground": string;
295
+ "menu.selectionForeground": string;
296
+ "textLink.foreground": string;
297
+ "widget.shadow": string;
298
+ foreground: string;
299
+ disabledForeground: string;
300
+ descriptionForeground: string;
301
+ errorForeground: string;
302
+ "icon.foreground": string;
303
+ contrastActiveBorder: string;
304
+ contrastBorder: string;
305
+ "textBlockQuote.background": string;
306
+ "textBlockQuote.border": string;
307
+ "textCodeBlock.background": string;
308
+ "textLink.activeForeground": string;
309
+ "textPreformat.foreground": string;
310
+ "textSeparator.foreground": string;
311
+ "editorActiveLineNumber.foreground": string;
312
+ "editor.inactiveSelectionBackground": string;
313
+ "editor.selectionHighlightBackground": string;
314
+ "editorError.foreground": string;
315
+ "editorWarning.foreground": string;
316
+ "editorInfo.foreground": string;
317
+ "editorHint.foreground": string;
318
+ "problemsErrorIcon.foreground": string;
319
+ "problemsWarningIcon.foreground": string;
320
+ "problemsInfoIcon.foreground": string;
321
+ "editor.findMatchBackground": string;
322
+ "editor.findMatchHighlightBackground": string;
323
+ "editor.findRangeHighlightBackground": string;
324
+ "editorLink.activeForeground": string;
325
+ "editorLightBulb.foreground": string;
326
+ "editorLightBulbAutoFix.foreground": string;
327
+ "diffEditor.insertedTextBackground": string;
328
+ "diffEditor.insertedTextBorder": string;
329
+ "diffEditor.removedTextBackground": string;
330
+ "diffEditor.removedTextBorder": string;
331
+ "diffEditor.insertedLineBackground": string;
332
+ "diffEditor.removedLineBackground": string;
333
+ "editorStickyScroll.background": string;
334
+ "editorStickyScrollHover.background": string;
335
+ "editorInlayHint.background": string;
336
+ "editorInlayHint.foreground": string;
337
+ "editorInlayHint.typeForeground": string;
338
+ "editorInlayHint.typeBackground": string;
339
+ "editorInlayHint.parameterForeground": string;
340
+ "editorInlayHint.parameterBackground": string;
341
+ "editorPane.background": string;
342
+ "editorGroup.emptyBackground": string;
343
+ "editorGroup.focusedEmptyBorder": string;
344
+ "editorGroupHeader.noTabsBackground": string;
345
+ "editorGroupHeader.border": string;
346
+ "editorGroup.border": string;
347
+ "editorGroup.dropBackground": string;
348
+ "editorGroup.dropIntoPromptForeground": string;
349
+ "editorGroup.dropIntoPromptBackground": string;
350
+ "editorGroup.dropIntoPromptBorder": string;
351
+ "sideBySideEditor.horizontalBorder": string;
352
+ "sideBySideEditor.verticalBorder": string;
353
+ "scrollbar.shadow": string;
354
+ "scrollbarSlider.activeBackground": string;
355
+ "panel.background": string;
356
+ "panel.border": string;
357
+ "panelTitle.activeBorder": string;
358
+ "panelTitle.activeForeground": string;
359
+ "panelTitle.inactiveForeground": string;
360
+ "panelSectionHeader.background": string;
361
+ "editorWidget.background": string;
362
+ "editorWidget.foreground": string;
363
+ "editorWidget.border": string;
364
+ "quickInput.background": string;
365
+ "quickInput.foreground": string;
366
+ "quickInputTitle.background": string;
367
+ "pickerGroup.foreground": string;
368
+ "pickerGroup.border": string;
369
+ "editor.hoverHighlightBackground": string;
370
+ "editorHoverWidget.background": string;
371
+ "editorHoverWidget.foreground": string;
372
+ "editorHoverWidget.border": string;
373
+ "editorHoverWidget.statusBarBackground": string;
374
+ "titleBar.inactiveBackground": string;
375
+ "titleBar.inactiveForeground": string;
376
+ "toolbar.hoverBackground": string;
377
+ "toolbar.activeBackground": string;
378
+ "tab.unfocusedActiveBackground": string;
379
+ "tab.unfocusedInactiveBackground": string;
380
+ "tab.unfocusedActiveForeground": string;
381
+ "tab.unfocusedInactiveForeground": string;
382
+ "tab.hoverBackground": string;
383
+ "tab.unfocusedHoverBackground": string;
384
+ "tab.hoverForeground": string;
385
+ "tab.unfocusedHoverForeground": string;
386
+ "tab.border": string;
387
+ "tab.lastPinnedBorder": string;
388
+ "tab.unfocusedActiveBorder": string;
389
+ "tab.unfocusedActiveBorderTop": string;
390
+ "tab.hoverBorder": string;
391
+ "tab.unfocusedHoverBorder": string;
392
+ "tab.activeModifiedBorder": string;
393
+ "tab.inactiveModifiedBorder": string;
394
+ "tab.unfocusedActiveModifiedBorder": string;
395
+ "tab.unfocusedInactiveModifiedBorder": string;
396
+ "badge.background": string;
397
+ "badge.foreground": string;
398
+ "button.background": string;
399
+ "button.foreground": string;
400
+ "button.border": string;
401
+ "button.separator": string;
402
+ "button.hoverBackground": string;
403
+ "button.secondaryBackground": string;
404
+ "button.secondaryForeground": string;
405
+ "button.secondaryHoverBackground": string;
406
+ "dropdown.background": string;
407
+ "dropdown.foreground": string;
408
+ "dropdown.border": string;
409
+ "list.activeSelectionBackground": string;
410
+ "list.activeSelectionForeground": string;
411
+ "tree.indentGuidesStroke": string;
412
+ "input.background": string;
413
+ "input.foreground": string;
414
+ "input.placeholderForeground": string;
415
+ "inputOption.activeBorder": string;
416
+ "inputOption.hoverBackground": string;
417
+ "inputOption.activeBackground": string;
418
+ "inputOption.activeForeground": string;
419
+ "inputValidation.infoBackground": string;
420
+ "inputValidation.infoBorder": string;
421
+ "inputValidation.warningBackground": string;
422
+ "inputValidation.warningBorder": string;
423
+ "inputValidation.errorBackground": string;
424
+ "inputValidation.errorBorder": string;
425
+ "keybindingLabel.background": string;
426
+ "keybindingLabel.foreground": string;
427
+ "keybindingLabel.border": string;
428
+ "keybindingLabel.bottomBorder": string;
429
+ "menu.foreground": string;
430
+ "menu.background": string;
431
+ "menu.separatorBackground": string;
432
+ "editor.snippetTabstopHighlightBackground": string;
433
+ "editor.snippetFinalTabstopHighlightBorder": string;
434
+ } & {
435
+ [key: string]: string;
436
+ };
437
+ settings: import("@expressive-code/core").ThemeSetting[];
438
+ }[];
439
+ /** Scopes each generated theme to `[data-flavor]`; any other theme gets no selector. */
440
+ export declare function flavorThemeSelector(theme: {
441
+ readonly name: string;
442
+ }): string | false;
443
+ export {};
@@ -0,0 +1,217 @@
1
+ import { ExpressiveCodeTheme } from '@expressive-code/core';
2
+ import { defaultFlavor, flavorMeta, flavorNames, palette, syntaxRoles } from '@nyxwire/palette';
3
+ /** TextMate scopes per palette syntax role (contract §6.4). More specific scopes win in Shiki. */
4
+ export const TOKEN_SCOPES = {
5
+ keyword: [
6
+ 'keyword',
7
+ 'keyword.control',
8
+ 'keyword.other',
9
+ 'keyword.operator.new',
10
+ 'keyword.operator.expression',
11
+ 'keyword.operator.wordlike',
12
+ 'keyword.operator.logical.python',
13
+ 'variable.language',
14
+ ],
15
+ storage: ['storage', 'storage.type'],
16
+ modifier: ['storage.modifier', 'keyword.other.modifier'],
17
+ string: ['string', 'string.quoted', 'string.template', 'punctuation.definition.string'],
18
+ number: ['constant.numeric', 'keyword.other.unit'],
19
+ constant: [
20
+ 'constant',
21
+ 'constant.other',
22
+ 'constant.character',
23
+ 'variable.other.constant',
24
+ 'variable.other.enummember',
25
+ 'support.constant',
26
+ ],
27
+ boolean: ['constant.language', 'constant.language.boolean'],
28
+ null: [
29
+ 'constant.language.null',
30
+ 'constant.language.undefined',
31
+ 'constant.language.nil',
32
+ 'constant.language.none',
33
+ ],
34
+ function: ['entity.name.function', 'support.function', 'variable.function'],
35
+ method: ['entity.name.function.member', 'meta.method-call entity.name.function'],
36
+ type: [
37
+ 'entity.name.type',
38
+ 'support.type',
39
+ 'support.type.primitive',
40
+ 'entity.name.type.parameter',
41
+ ],
42
+ class: ['entity.name.class', 'support.class', 'entity.other.inherited-class'],
43
+ interface: ['entity.name.type.interface'],
44
+ enum: ['entity.name.type.enum'],
45
+ namespace: ['entity.name.namespace', 'entity.name.type.module', 'entity.name.scope-resolution'],
46
+ variable: ['variable', 'variable.other', 'variable.other.readwrite', 'meta.definition.variable'],
47
+ parameter: ['variable.parameter', 'meta.parameter'],
48
+ property: [
49
+ 'variable.other.property',
50
+ 'variable.other.object.property',
51
+ 'support.variable.property',
52
+ 'meta.object-literal.key',
53
+ 'support.type.property-name',
54
+ 'entity.name.tag.yaml',
55
+ ],
56
+ tag: ['entity.name.tag'],
57
+ attribute: ['entity.other.attribute-name'],
58
+ operator: ['keyword.operator', 'punctuation.separator.key-value'],
59
+ punctuation: [
60
+ 'punctuation',
61
+ 'punctuation.separator',
62
+ 'punctuation.terminator',
63
+ 'punctuation.accessor',
64
+ 'punctuation.definition.tag',
65
+ 'meta.brace',
66
+ ],
67
+ comment: ['comment', 'punctuation.definition.comment', 'string.comment'],
68
+ regex: ['string.regexp'],
69
+ escape: [
70
+ 'constant.character.escape',
71
+ 'punctuation.definition.template-expression',
72
+ 'punctuation.section.embedded',
73
+ ],
74
+ decorator: [
75
+ 'meta.decorator',
76
+ 'entity.name.function.decorator',
77
+ 'punctuation.decorator',
78
+ 'storage.type.annotation',
79
+ ],
80
+ 'markup-heading': ['markup.heading', 'entity.name.section.markdown'],
81
+ 'markup-link': ['markup.underline.link', 'string.other.link', 'markup.link'],
82
+ inserted: ['markup.inserted', 'meta.diff.header.to-file', 'punctuation.definition.inserted'],
83
+ deleted: [
84
+ 'markup.deleted',
85
+ 'meta.diff.header.from-file',
86
+ 'punctuation.definition.deleted',
87
+ 'invalid',
88
+ 'invalid.illegal',
89
+ ],
90
+ changed: ['markup.changed', 'meta.diff.range', 'punctuation.definition.changed'],
91
+ };
92
+ const FONT_STYLE_RULES = [
93
+ { name: 'markup-bold', scope: ['markup.bold'], settings: { fontStyle: 'bold' } },
94
+ { name: 'markup-italic', scope: ['markup.italic'], settings: { fontStyle: 'italic' } },
95
+ {
96
+ name: 'markup-strikethrough',
97
+ scope: ['markup.strikethrough'],
98
+ settings: { fontStyle: 'strikethrough' },
99
+ },
100
+ ];
101
+ function isTokenRole(role) {
102
+ return Object.hasOwn(TOKEN_SCOPES, role);
103
+ }
104
+ function withAlpha(hex, opacity) {
105
+ return `${hex}${Math.round(opacity * 255)
106
+ .toString(16)
107
+ .padStart(2, '0')}`;
108
+ }
109
+ /**
110
+ * Builds a VS Code theme from one flavor. Dark flavors share their accents, so a dark theme only
111
+ * differs in its neutral editor colors; code-block surfaces are re-pointed to CSS variables by
112
+ * `expressiveCodeStyleOverrides`, which keeps them in sync with the active flavor at runtime.
113
+ */
114
+ export function createExpressiveCodeTheme(flavorName) {
115
+ const colors = palette[flavorName];
116
+ const { dark } = flavorMeta[flavorName];
117
+ const color = (name) => colors[name];
118
+ const role = (name) => color(syntaxRoles[name].color);
119
+ const selection = withAlpha(role('selection'), syntaxRoles.selection.opacity);
120
+ const ansiBlack = dark ? color('surface1') : color('subtext1');
121
+ const ansiWhite = dark ? color('subtext1') : color('surface2');
122
+ const tokenColors = Object.keys(syntaxRoles)
123
+ .filter(isTokenRole)
124
+ .map((name) => {
125
+ const spec = syntaxRoles[name];
126
+ return {
127
+ name,
128
+ scope: TOKEN_SCOPES[name],
129
+ settings: {
130
+ foreground: color(spec.color),
131
+ ...('fontStyle' in spec ? { fontStyle: spec.fontStyle } : {}),
132
+ },
133
+ };
134
+ });
135
+ return {
136
+ name: `nyxwire-${flavorName}`,
137
+ type: dark ? 'dark' : 'light',
138
+ colors: {
139
+ 'editor.background': role('editor-bg'),
140
+ 'editor.foreground': color('text'),
141
+ 'editor.selectionBackground': selection,
142
+ 'editor.lineHighlightBackground': role('line-highlight'),
143
+ 'editorCursor.foreground': color('indigo'),
144
+ 'editorLineNumber.foreground': color('subtext0'),
145
+ 'editorLineNumber.activeForeground': color('subtext0'),
146
+ 'editorIndentGuide.background1': color('surface1'),
147
+ 'editorGroupHeader.tabsBackground': color('mantle'),
148
+ 'editorGroupHeader.tabsBorder': color('overlay0'),
149
+ 'tab.activeBackground': role('editor-bg'),
150
+ 'tab.activeForeground': color('text'),
151
+ 'tab.activeBorder': role('editor-bg'),
152
+ 'tab.activeBorderTop': color('indigo'),
153
+ 'tab.inactiveBackground': color('mantle'),
154
+ 'tab.inactiveForeground': color('subtext0'),
155
+ 'titleBar.activeBackground': color('mantle'),
156
+ 'titleBar.activeForeground': color('subtext1'),
157
+ 'titleBar.border': color('overlay0'),
158
+ 'terminal.background': role('editor-bg'),
159
+ 'terminal.foreground': color('text'),
160
+ 'terminal.ansiBlack': ansiBlack,
161
+ 'terminal.ansiRed': color('alarm'),
162
+ 'terminal.ansiGreen': color('matrix'),
163
+ 'terminal.ansiYellow': color('volt'),
164
+ 'terminal.ansiBlue': color('arc'),
165
+ 'terminal.ansiMagenta': color('indigo'),
166
+ 'terminal.ansiCyan': color('ice'),
167
+ 'terminal.ansiWhite': ansiWhite,
168
+ 'terminal.ansiBrightBlack': dark ? color('overlay1') : color('overlay2'),
169
+ 'terminal.ansiBrightRed': color('flare'),
170
+ 'terminal.ansiBrightGreen': color('matrix'),
171
+ 'terminal.ansiBrightYellow': color('circuit'),
172
+ 'terminal.ansiBrightBlue': color('steel'),
173
+ 'terminal.ansiBrightMagenta': color('synth'),
174
+ 'terminal.ansiBrightCyan': color('ice'),
175
+ 'terminal.ansiBrightWhite': dark ? color('text') : color('overlay0'),
176
+ focusBorder: color('indigo'),
177
+ 'scrollbarSlider.background': withAlpha(color('overlay1'), 0.4),
178
+ 'scrollbarSlider.hoverBackground': withAlpha(color('overlay2'), 0.6),
179
+ 'menu.selectionBackground': selection,
180
+ 'menu.selectionForeground': color('text'),
181
+ 'textLink.foreground': color('arc'),
182
+ 'widget.shadow': withAlpha(color('crust'), 0.6),
183
+ },
184
+ tokenColors: [...tokenColors, ...FONT_STYLE_RULES],
185
+ };
186
+ }
187
+ /** Raw dark theme built from Nocturne neutrals and the accents shared by every dark flavor. */
188
+ export const nyxwireDark = createExpressiveCodeTheme('nocturne');
189
+ /** Raw light theme built from Lumen. */
190
+ export const nyxwireLight = createExpressiveCodeTheme('lumen');
191
+ /**
192
+ * Rendered theme for one flavor: syntax ink is lifted to 5.5:1 on the dimmer of the two code
193
+ * surfaces (line highlight in dark flavors, editor background in Lumen). Raw themes stay untouched.
194
+ */
195
+ export function createCodeTheme(flavor) {
196
+ const { tokenColors, ...raw } = createExpressiveCodeTheme(flavor);
197
+ const theme = new ExpressiveCodeTheme({
198
+ ...raw,
199
+ tokenColors: tokenColors.map(({ scope, ...rule }) => ({ ...rule, scope: [...scope] })),
200
+ });
201
+ const colors = palette[flavor];
202
+ const weakestBackground = flavorMeta[flavor].dark
203
+ ? colors[syntaxRoles['line-highlight'].color]
204
+ : colors[syntaxRoles['editor-bg'].color];
205
+ theme.ensureMinSyntaxHighlightingColorContrast(5.5, weakestBackground);
206
+ // Starlight may load a different copy of Expressive Code, so hand it plain data.
207
+ return { name: theme.name, type: theme.type, colors: theme.colors, settings: theme.settings };
208
+ }
209
+ /** One rendered theme per flavor, the configured dark flavor first (Expressive Code's base theme). */
210
+ export function createCodeThemes(dark = defaultFlavor === 'lumen' ? 'nocturne' : defaultFlavor) {
211
+ return [dark, ...flavorNames.filter((flavor) => flavor !== dark)].map(createCodeTheme);
212
+ }
213
+ /** Scopes each generated theme to `[data-flavor]`; any other theme gets no selector. */
214
+ export function flavorThemeSelector(theme) {
215
+ const flavor = flavorNames.find((id) => theme.name === `nyxwire-${id}`);
216
+ return flavor ? `[data-flavor='${flavor}']` : false;
217
+ }