@tooee/themes 0.1.9 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ThemePicker.d.ts.map +1 -1
- package/dist/ThemePicker.js +2 -21
- package/dist/ThemePicker.js.map +1 -1
- package/dist/context.d.ts +38 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +70 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +15 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +136 -0
- package/dist/loader.js.map +1 -0
- package/dist/syntax-rules.d.ts +4 -0
- package/dist/syntax-rules.d.ts.map +1 -0
- package/dist/syntax-rules.js +207 -0
- package/dist/syntax-rules.js.map +1 -0
- package/dist/{theme.d.ts → types.d.ts} +3 -43
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +145 -0
- package/dist/types.js.map +1 -0
- package/package.json +17 -16
- package/src/ThemePicker.tsx +2 -23
- package/src/context.tsx +142 -0
- package/src/index.ts +10 -18
- package/src/loader.ts +155 -0
- package/src/syntax-rules.ts +210 -0
- package/src/types.ts +219 -0
- package/dist/theme.d.ts.map +0 -1
- package/dist/theme.js +0 -560
- package/dist/theme.js.map +0 -1
- package/src/theme.tsx +0 -727
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { RGBA, SyntaxStyle } from "@opentui/core"
|
|
2
|
+
import type { ResolvedTheme } from "./types.js"
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// SyntaxStyle builder
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
function getSyntaxRules(resolved: ResolvedTheme) {
|
|
9
|
+
return [
|
|
10
|
+
{ scope: ["default"], style: { foreground: RGBA.fromHex(resolved.text) } },
|
|
11
|
+
{ scope: ["prompt"], style: { foreground: RGBA.fromHex(resolved.accent) } },
|
|
12
|
+
{
|
|
13
|
+
scope: ["comment", "comment.documentation"],
|
|
14
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxComment), italic: true },
|
|
15
|
+
},
|
|
16
|
+
{ scope: ["string", "symbol"], style: { foreground: RGBA.fromHex(resolved.syntaxString) } },
|
|
17
|
+
{ scope: ["number", "boolean"], style: { foreground: RGBA.fromHex(resolved.syntaxNumber) } },
|
|
18
|
+
{ scope: ["character.special"], style: { foreground: RGBA.fromHex(resolved.syntaxString) } },
|
|
19
|
+
{
|
|
20
|
+
scope: ["keyword.return", "keyword.conditional", "keyword.repeat", "keyword.coroutine"],
|
|
21
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword), italic: true },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
scope: ["keyword.type"],
|
|
25
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxType), bold: true, italic: true },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
scope: ["keyword.function", "function.method"],
|
|
29
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxFunction) },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
scope: ["keyword"],
|
|
33
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword), italic: true },
|
|
34
|
+
},
|
|
35
|
+
{ scope: ["keyword.import"], style: { foreground: RGBA.fromHex(resolved.syntaxKeyword) } },
|
|
36
|
+
{
|
|
37
|
+
scope: ["operator", "keyword.operator", "punctuation.delimiter"],
|
|
38
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxOperator) },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
scope: ["keyword.conditional.ternary"],
|
|
42
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxOperator) },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
scope: ["variable", "variable.parameter", "function.method.call", "function.call"],
|
|
46
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxVariable) },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
scope: ["variable.member", "function", "constructor"],
|
|
50
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxFunction) },
|
|
51
|
+
},
|
|
52
|
+
{ scope: ["type", "module"], style: { foreground: RGBA.fromHex(resolved.syntaxType) } },
|
|
53
|
+
{ scope: ["constant"], style: { foreground: RGBA.fromHex(resolved.syntaxNumber) } },
|
|
54
|
+
{ scope: ["property"], style: { foreground: RGBA.fromHex(resolved.syntaxVariable) } },
|
|
55
|
+
{ scope: ["class"], style: { foreground: RGBA.fromHex(resolved.syntaxType) } },
|
|
56
|
+
{ scope: ["parameter"], style: { foreground: RGBA.fromHex(resolved.syntaxVariable) } },
|
|
57
|
+
{
|
|
58
|
+
scope: ["punctuation", "punctuation.bracket"],
|
|
59
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxPunctuation) },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
scope: [
|
|
63
|
+
"variable.builtin",
|
|
64
|
+
"type.builtin",
|
|
65
|
+
"function.builtin",
|
|
66
|
+
"module.builtin",
|
|
67
|
+
"constant.builtin",
|
|
68
|
+
],
|
|
69
|
+
style: { foreground: RGBA.fromHex(resolved.error) },
|
|
70
|
+
},
|
|
71
|
+
{ scope: ["variable.super"], style: { foreground: RGBA.fromHex(resolved.error) } },
|
|
72
|
+
{
|
|
73
|
+
scope: ["string.escape", "string.regexp"],
|
|
74
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword) },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
scope: ["keyword.directive"],
|
|
78
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword), italic: true },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
scope: ["punctuation.special"],
|
|
82
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxOperator) },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
scope: ["keyword.modifier"],
|
|
86
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword), italic: true },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
scope: ["keyword.exception"],
|
|
90
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxKeyword), italic: true },
|
|
91
|
+
},
|
|
92
|
+
// Markdown
|
|
93
|
+
{
|
|
94
|
+
scope: [
|
|
95
|
+
"markup.heading",
|
|
96
|
+
"markup.heading.1",
|
|
97
|
+
"markup.heading.2",
|
|
98
|
+
"markup.heading.3",
|
|
99
|
+
"markup.heading.4",
|
|
100
|
+
"markup.heading.5",
|
|
101
|
+
"markup.heading.6",
|
|
102
|
+
],
|
|
103
|
+
style: { foreground: RGBA.fromHex(resolved.markdownHeading), bold: true },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
scope: ["markup.bold", "markup.strong"],
|
|
107
|
+
style: { foreground: RGBA.fromHex(resolved.markdownStrong), bold: true },
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
scope: ["markup.italic"],
|
|
111
|
+
style: { foreground: RGBA.fromHex(resolved.markdownEmph), italic: true },
|
|
112
|
+
},
|
|
113
|
+
{ scope: ["markup.list"], style: { foreground: RGBA.fromHex(resolved.markdownListItem) } },
|
|
114
|
+
{
|
|
115
|
+
scope: ["markup.quote"],
|
|
116
|
+
style: { foreground: RGBA.fromHex(resolved.markdownBlockQuote), italic: true },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
scope: ["markup.raw", "markup.raw.block"],
|
|
120
|
+
style: { foreground: RGBA.fromHex(resolved.markdownCode) },
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
scope: ["markup.raw.inline"],
|
|
124
|
+
style: {
|
|
125
|
+
foreground: RGBA.fromHex(resolved.markdownCode),
|
|
126
|
+
background: RGBA.fromHex(resolved.background),
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
scope: ["markup.link"],
|
|
131
|
+
style: { foreground: RGBA.fromHex(resolved.markdownLink), underline: true },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
scope: ["markup.link.label"],
|
|
135
|
+
style: { foreground: RGBA.fromHex(resolved.markdownLinkText), underline: true },
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
scope: ["markup.link.url"],
|
|
139
|
+
style: { foreground: RGBA.fromHex(resolved.markdownLink), underline: true },
|
|
140
|
+
},
|
|
141
|
+
{ scope: ["label"], style: { foreground: RGBA.fromHex(resolved.markdownLinkText) } },
|
|
142
|
+
{ scope: ["spell", "nospell"], style: { foreground: RGBA.fromHex(resolved.text) } },
|
|
143
|
+
{ scope: ["conceal"], style: { foreground: RGBA.fromHex(resolved.textMuted) } },
|
|
144
|
+
{
|
|
145
|
+
scope: ["string.special", "string.special.url"],
|
|
146
|
+
style: { foreground: RGBA.fromHex(resolved.markdownLink), underline: true },
|
|
147
|
+
},
|
|
148
|
+
{ scope: ["character"], style: { foreground: RGBA.fromHex(resolved.syntaxString) } },
|
|
149
|
+
{ scope: ["float"], style: { foreground: RGBA.fromHex(resolved.syntaxNumber) } },
|
|
150
|
+
{
|
|
151
|
+
scope: ["comment.error"],
|
|
152
|
+
style: { foreground: RGBA.fromHex(resolved.error), italic: true, bold: true },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
scope: ["comment.warning"],
|
|
156
|
+
style: { foreground: RGBA.fromHex(resolved.warning), italic: true, bold: true },
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
scope: ["comment.todo", "comment.note"],
|
|
160
|
+
style: { foreground: RGBA.fromHex(resolved.info), italic: true, bold: true },
|
|
161
|
+
},
|
|
162
|
+
{ scope: ["namespace"], style: { foreground: RGBA.fromHex(resolved.syntaxType) } },
|
|
163
|
+
{ scope: ["field"], style: { foreground: RGBA.fromHex(resolved.syntaxVariable) } },
|
|
164
|
+
{
|
|
165
|
+
scope: ["type.definition"],
|
|
166
|
+
style: { foreground: RGBA.fromHex(resolved.syntaxType), bold: true },
|
|
167
|
+
},
|
|
168
|
+
{ scope: ["keyword.export"], style: { foreground: RGBA.fromHex(resolved.syntaxKeyword) } },
|
|
169
|
+
{ scope: ["attribute", "annotation"], style: { foreground: RGBA.fromHex(resolved.warning) } },
|
|
170
|
+
{ scope: ["tag"], style: { foreground: RGBA.fromHex(resolved.error) } },
|
|
171
|
+
{ scope: ["tag.attribute"], style: { foreground: RGBA.fromHex(resolved.syntaxKeyword) } },
|
|
172
|
+
{ scope: ["tag.delimiter"], style: { foreground: RGBA.fromHex(resolved.syntaxOperator) } },
|
|
173
|
+
{ scope: ["markup.strikethrough"], style: { foreground: RGBA.fromHex(resolved.textMuted) } },
|
|
174
|
+
{
|
|
175
|
+
scope: ["markup.underline"],
|
|
176
|
+
style: { foreground: RGBA.fromHex(resolved.text), underline: true },
|
|
177
|
+
},
|
|
178
|
+
{ scope: ["markup.list.checked"], style: { foreground: RGBA.fromHex(resolved.success) } },
|
|
179
|
+
{ scope: ["markup.list.unchecked"], style: { foreground: RGBA.fromHex(resolved.textMuted) } },
|
|
180
|
+
{
|
|
181
|
+
scope: ["diff.plus"],
|
|
182
|
+
style: {
|
|
183
|
+
foreground: RGBA.fromHex(resolved.diffAdded),
|
|
184
|
+
background: RGBA.fromHex(resolved.diffAddedBg),
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
scope: ["diff.minus"],
|
|
189
|
+
style: {
|
|
190
|
+
foreground: RGBA.fromHex(resolved.diffRemoved),
|
|
191
|
+
background: RGBA.fromHex(resolved.diffRemovedBg),
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
scope: ["diff.delta"],
|
|
196
|
+
style: {
|
|
197
|
+
foreground: RGBA.fromHex(resolved.diffContext),
|
|
198
|
+
background: RGBA.fromHex(resolved.diffContextBg),
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{ scope: ["error"], style: { foreground: RGBA.fromHex(resolved.error), bold: true } },
|
|
202
|
+
{ scope: ["warning"], style: { foreground: RGBA.fromHex(resolved.warning), bold: true } },
|
|
203
|
+
{ scope: ["info"], style: { foreground: RGBA.fromHex(resolved.info) } },
|
|
204
|
+
{ scope: ["debug"], style: { foreground: RGBA.fromHex(resolved.textMuted) } },
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function buildSyntaxStyle(resolved: ResolvedTheme): SyntaxStyle {
|
|
209
|
+
return SyntaxStyle.fromTheme(getSyntaxRules(resolved))
|
|
210
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Theme JSON format (OpenCode-compatible)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
type HexColor = `#${string}`
|
|
6
|
+
type RefName = string
|
|
7
|
+
type Variant = { dark: HexColor | RefName; light: HexColor | RefName }
|
|
8
|
+
type ColorValue = HexColor | RefName | Variant
|
|
9
|
+
|
|
10
|
+
export interface ThemeJSON {
|
|
11
|
+
$schema?: string
|
|
12
|
+
defs?: Record<string, HexColor | RefName>
|
|
13
|
+
theme: Record<string, ColorValue>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Resolved theme — all colors resolved to hex strings
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
export interface ResolvedTheme {
|
|
21
|
+
// UI
|
|
22
|
+
primary: string
|
|
23
|
+
secondary: string
|
|
24
|
+
accent: string
|
|
25
|
+
error: string
|
|
26
|
+
warning: string
|
|
27
|
+
success: string
|
|
28
|
+
info: string
|
|
29
|
+
text: string
|
|
30
|
+
textMuted: string
|
|
31
|
+
background: string
|
|
32
|
+
backgroundPanel: string
|
|
33
|
+
backgroundElement: string
|
|
34
|
+
border: string
|
|
35
|
+
borderActive: string
|
|
36
|
+
borderSubtle: string
|
|
37
|
+
// Diff
|
|
38
|
+
diffAdded: string
|
|
39
|
+
diffRemoved: string
|
|
40
|
+
diffContext: string
|
|
41
|
+
diffHunkHeader: string
|
|
42
|
+
diffHighlightAdded: string
|
|
43
|
+
diffHighlightRemoved: string
|
|
44
|
+
diffAddedBg: string
|
|
45
|
+
diffRemovedBg: string
|
|
46
|
+
diffContextBg: string
|
|
47
|
+
diffLineNumber: string
|
|
48
|
+
diffAddedLineNumberBg: string
|
|
49
|
+
diffRemovedLineNumberBg: string
|
|
50
|
+
// Markdown
|
|
51
|
+
markdownText: string
|
|
52
|
+
markdownHeading: string
|
|
53
|
+
markdownLink: string
|
|
54
|
+
markdownLinkText: string
|
|
55
|
+
markdownCode: string
|
|
56
|
+
markdownBlockQuote: string
|
|
57
|
+
markdownEmph: string
|
|
58
|
+
markdownStrong: string
|
|
59
|
+
markdownHorizontalRule: string
|
|
60
|
+
markdownListItem: string
|
|
61
|
+
markdownListEnumeration: string
|
|
62
|
+
markdownImage: string
|
|
63
|
+
markdownImageText: string
|
|
64
|
+
markdownCodeBlock: string
|
|
65
|
+
// Cursor/Selection
|
|
66
|
+
cursorLine: string
|
|
67
|
+
selection: string
|
|
68
|
+
// Syntax
|
|
69
|
+
syntaxComment: string
|
|
70
|
+
syntaxKeyword: string
|
|
71
|
+
syntaxFunction: string
|
|
72
|
+
syntaxVariable: string
|
|
73
|
+
syntaxString: string
|
|
74
|
+
syntaxNumber: string
|
|
75
|
+
syntaxType: string
|
|
76
|
+
syntaxOperator: string
|
|
77
|
+
syntaxPunctuation: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// All keys of ResolvedTheme for iteration
|
|
81
|
+
export const RESOLVED_KEYS: (keyof ResolvedTheme)[] = [
|
|
82
|
+
"primary",
|
|
83
|
+
"secondary",
|
|
84
|
+
"accent",
|
|
85
|
+
"error",
|
|
86
|
+
"warning",
|
|
87
|
+
"success",
|
|
88
|
+
"info",
|
|
89
|
+
"text",
|
|
90
|
+
"textMuted",
|
|
91
|
+
"background",
|
|
92
|
+
"backgroundPanel",
|
|
93
|
+
"backgroundElement",
|
|
94
|
+
"border",
|
|
95
|
+
"borderActive",
|
|
96
|
+
"borderSubtle",
|
|
97
|
+
"cursorLine",
|
|
98
|
+
"selection",
|
|
99
|
+
"diffAdded",
|
|
100
|
+
"diffRemoved",
|
|
101
|
+
"diffContext",
|
|
102
|
+
"diffHunkHeader",
|
|
103
|
+
"diffHighlightAdded",
|
|
104
|
+
"diffHighlightRemoved",
|
|
105
|
+
"diffAddedBg",
|
|
106
|
+
"diffRemovedBg",
|
|
107
|
+
"diffContextBg",
|
|
108
|
+
"diffLineNumber",
|
|
109
|
+
"diffAddedLineNumberBg",
|
|
110
|
+
"diffRemovedLineNumberBg",
|
|
111
|
+
"markdownText",
|
|
112
|
+
"markdownHeading",
|
|
113
|
+
"markdownLink",
|
|
114
|
+
"markdownLinkText",
|
|
115
|
+
"markdownCode",
|
|
116
|
+
"markdownBlockQuote",
|
|
117
|
+
"markdownEmph",
|
|
118
|
+
"markdownStrong",
|
|
119
|
+
"markdownHorizontalRule",
|
|
120
|
+
"markdownListItem",
|
|
121
|
+
"markdownListEnumeration",
|
|
122
|
+
"markdownImage",
|
|
123
|
+
"markdownImageText",
|
|
124
|
+
"markdownCodeBlock",
|
|
125
|
+
"syntaxComment",
|
|
126
|
+
"syntaxKeyword",
|
|
127
|
+
"syntaxFunction",
|
|
128
|
+
"syntaxVariable",
|
|
129
|
+
"syntaxString",
|
|
130
|
+
"syntaxNumber",
|
|
131
|
+
"syntaxType",
|
|
132
|
+
"syntaxOperator",
|
|
133
|
+
"syntaxPunctuation",
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
// Fallbacks used when a theme key is missing
|
|
137
|
+
export const FALLBACKS: Record<string, string> = {
|
|
138
|
+
primary: "#808080",
|
|
139
|
+
secondary: "#808080",
|
|
140
|
+
accent: "#808080",
|
|
141
|
+
error: "#808080",
|
|
142
|
+
warning: "#808080",
|
|
143
|
+
success: "#808080",
|
|
144
|
+
info: "#808080",
|
|
145
|
+
text: "#d4d4d4",
|
|
146
|
+
textMuted: "#808080",
|
|
147
|
+
background: "#1e1e1e",
|
|
148
|
+
backgroundPanel: "#1e1e1e",
|
|
149
|
+
backgroundElement: "#1e1e1e",
|
|
150
|
+
cursorLine: "#1e1e1e",
|
|
151
|
+
selection: "#1e1e1e",
|
|
152
|
+
border: "#808080",
|
|
153
|
+
borderActive: "#808080",
|
|
154
|
+
borderSubtle: "#808080",
|
|
155
|
+
diffAdded: "#4fd6be",
|
|
156
|
+
diffRemoved: "#c53b53",
|
|
157
|
+
diffContext: "#808080",
|
|
158
|
+
diffHunkHeader: "#808080",
|
|
159
|
+
diffHighlightAdded: "#4fd6be",
|
|
160
|
+
diffHighlightRemoved: "#c53b53",
|
|
161
|
+
diffAddedBg: "#1e3a1e",
|
|
162
|
+
diffRemovedBg: "#3a1e1e",
|
|
163
|
+
diffContextBg: "#1e1e1e",
|
|
164
|
+
diffLineNumber: "#808080",
|
|
165
|
+
diffAddedLineNumberBg: "#1e3a1e",
|
|
166
|
+
diffRemovedLineNumberBg: "#3a1e1e",
|
|
167
|
+
markdownText: "#d4d4d4",
|
|
168
|
+
markdownHeading: "#808080",
|
|
169
|
+
markdownLink: "#808080",
|
|
170
|
+
markdownLinkText: "#808080",
|
|
171
|
+
markdownCode: "#808080",
|
|
172
|
+
markdownBlockQuote: "#808080",
|
|
173
|
+
markdownEmph: "#808080",
|
|
174
|
+
markdownStrong: "#808080",
|
|
175
|
+
markdownHorizontalRule: "#808080",
|
|
176
|
+
markdownListItem: "#808080",
|
|
177
|
+
markdownListEnumeration: "#808080",
|
|
178
|
+
markdownImage: "#808080",
|
|
179
|
+
markdownImageText: "#808080",
|
|
180
|
+
markdownCodeBlock: "#d4d4d4",
|
|
181
|
+
syntaxComment: "#808080",
|
|
182
|
+
syntaxKeyword: "#808080",
|
|
183
|
+
syntaxFunction: "#808080",
|
|
184
|
+
syntaxVariable: "#808080",
|
|
185
|
+
syntaxString: "#808080",
|
|
186
|
+
syntaxNumber: "#808080",
|
|
187
|
+
syntaxType: "#808080",
|
|
188
|
+
syntaxOperator: "#808080",
|
|
189
|
+
syntaxPunctuation: "#808080",
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
// Resolution
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
|
|
196
|
+
export function resolveTheme(json: ThemeJSON, mode: "dark" | "light"): ResolvedTheme {
|
|
197
|
+
const defs = json.defs ?? {}
|
|
198
|
+
|
|
199
|
+
function resolveColor(c: ColorValue): string {
|
|
200
|
+
if (typeof c === "string") {
|
|
201
|
+
if (c === "transparent" || c === "none") return "#00000000"
|
|
202
|
+
if (c.startsWith("#")) return c
|
|
203
|
+
if (defs[c] != null) return resolveColor(defs[c] as ColorValue)
|
|
204
|
+
if (json.theme[c] !== undefined) return resolveColor(json.theme[c] as ColorValue)
|
|
205
|
+
return "#808080"
|
|
206
|
+
}
|
|
207
|
+
return resolveColor(c[mode])
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const result = {} as Record<string, string>
|
|
211
|
+
for (const key of RESOLVED_KEYS) {
|
|
212
|
+
const val = json.theme[key]
|
|
213
|
+
result[key] = val !== undefined ? resolveColor(val) : (FALLBACKS[key] ?? "#808080")
|
|
214
|
+
}
|
|
215
|
+
// Dynamic fallbacks that reference other resolved keys
|
|
216
|
+
if (json.theme["cursorLine"] === undefined) result.cursorLine = result.backgroundElement
|
|
217
|
+
if (json.theme["selection"] === undefined) result.selection = result.backgroundPanel
|
|
218
|
+
return result as unknown as ResolvedTheme
|
|
219
|
+
}
|
package/dist/theme.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AACd,OAAO,EAAQ,WAAW,EAA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