@jsonup/themes 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Cocova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @jsonup/themes
2
+
3
+ 供 `jsonup` 生态系统使用的主题系统和 CSS 变量。
4
+
5
+ ## 特性
6
+
7
+ - **亮色与暗色模式**:内置支持亮色(Light)和暗色(Dark)主题。
8
+ - **高度可定制**:易于使用 CSS 变量进行扩展或覆盖。
9
+ - **GitHub 主题**:开箱即用,内置了 GitHub Light 和 GitHub Dark 主题。
10
+
11
+ ## 安装
12
+
13
+ ```bash
14
+ npm install @jsonup/themes
15
+ # 或
16
+ pnpm add @jsonup/themes
17
+ # 或
18
+ yarn add @jsonup/themes
19
+ ```
20
+
21
+ ## 基础用法
22
+
23
+ 搭配 `@jsonup/vue` 使用:
24
+
25
+ ```vue
26
+ <script setup>
27
+ import { githubDark } from "@jsonup/themes";
28
+ import { JsonupViewer } from "@jsonup/vue";
29
+ </script>
30
+
31
+ <template>
32
+ <JsonupViewer :data="{}" :theme="githubDark" />
33
+ </template>
34
+ ```
35
+
36
+ ## 许可证
37
+
38
+ [MIT](../../LICENSE)
@@ -0,0 +1,255 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Jsonup 主题类型
4
+ * 'light' 表示亮色主题,'dark' 表示暗色主题
5
+ */
6
+ type JsonupThemeType = 'light' | 'dark';
7
+ /**
8
+ * Jsonup 语法高亮的作用域
9
+ * 对应不同的 JSON 节点类型和标点符号
10
+ */
11
+ type JsonupThemeScope = 'string' | 'number' | 'boolean' | 'null' | 'property' | 'punctuation.quote.key' | 'punctuation.quote.string' | 'punctuation.quote' | 'punctuation.colon' | 'punctuation.comma' | 'punctuation.bracket' | 'meta.line-number' | 'meta.summary' | 'storage.object' | 'storage.array';
12
+ /**
13
+ * Jsonup 主题配置接口
14
+ */
15
+ interface JsonupTheme {
16
+ /** 主题名称 */
17
+ name: string;
18
+ /** 主题类型(亮色/暗色) */
19
+ type: JsonupThemeType;
20
+ /** 基础颜色配置 */
21
+ colors: JsonupColors;
22
+ /** 词法单元(Token)的颜色配置数组 */
23
+ tokenColors: JsonupTokenColor[];
24
+ }
25
+ /**
26
+ * Jsonup 基础颜色配置接口
27
+ */
28
+ interface JsonupColors {
29
+ /** 背景色 */
30
+ background?: string;
31
+ /** 前景色(默认文本颜色) */
32
+ foreground?: string;
33
+ /** 行号颜色 */
34
+ lineNumber?: string;
35
+ /** 摘要/折叠提示文字颜色 */
36
+ summary?: string;
37
+ }
38
+ /**
39
+ * 词法单元颜色配置接口
40
+ */
41
+ interface JsonupTokenColor {
42
+ /** 匹配的作用域,可以是单个作用域或作用域数组 */
43
+ scope: JsonupThemeScope | JsonupThemeScope[];
44
+ /** 针对该作用域的样式设置 */
45
+ settings: JsonupTokenSettings;
46
+ }
47
+ /**
48
+ * 词法单元的样式设置接口
49
+ */
50
+ interface JsonupTokenSettings {
51
+ /** 前景色 */
52
+ foreground?: string;
53
+ }
54
+ /**
55
+ * Jsonup 主题映射的 CSS 变量记录类型
56
+ */
57
+ type JsonupThemeCssVars = Partial<Record<JsonupThemeCssVarName, string>>;
58
+ /**
59
+ * Jsonup 内部使用的 CSS 变量名称类型
60
+ */
61
+ type JsonupThemeCssVarName = '--jv-background' | '--jv-foreground' | '--jv-line-number' | '--jv-summary' | '--jv-property' | '--jv-string' | '--jv-number' | '--jv-boolean' | '--jv-null' | '--jv-punctuation-quote-key' | '--jv-punctuation-quote-string' | '--jv-punctuation-quote' | '--jv-punctuation-colon' | '--jv-punctuation-comma' | '--jv-punctuation-bracket' | '--jv-storage-object' | '--jv-storage-array';
62
+ //#endregion
63
+ //#region src/css-vars.d.ts
64
+ /**
65
+ * 将 Jsonup 主题对象转换为 CSS 变量对象
66
+ *
67
+ * @param theme - 要转换的 Jsonup 主题对象,如果为 undefined 或 null 则返回空对象
68
+ * @returns 包含映射后 CSS 变量名及其对应颜色值的对象
69
+ */
70
+ declare function useCssVars(theme?: JsonupTheme | null): JsonupThemeCssVars;
71
+ //#endregion
72
+ //#region src/theme-options.d.ts
73
+ /**
74
+ * Jsonup 主题选项接口
75
+ */
76
+ interface JsonupThemeOption {
77
+ /**
78
+ * 主题显示名称
79
+ */
80
+ label: string;
81
+ /**
82
+ * 主题值(标识符)
83
+ */
84
+ value: string;
85
+ /**
86
+ * 具体的主题配置对象
87
+ */
88
+ theme: JsonupTheme;
89
+ }
90
+ /**
91
+ * 所有预设主题的选项列表
92
+ */
93
+ declare const themeOptions: JsonupThemeOption[];
94
+ /**
95
+ * 根据主题值查找对应的主题配置
96
+ *
97
+ * @param value - 要查找的主题值(标识符)
98
+ * @returns 查找到的主题配置对象,如果未找到则返回 undefined
99
+ */
100
+ declare function findTheme(value?: string): JsonupTheme | undefined;
101
+ /**
102
+ * 以键值对形式导出的所有主题对象字典
103
+ * 键为主题值,值为主题配置对象
104
+ */
105
+ declare const themes: Record<string, JsonupTheme>;
106
+ //#endregion
107
+ //#region src/themes/andromeeda.d.ts
108
+ declare const Andromeeda: JsonupTheme;
109
+ //#endregion
110
+ //#region src/themes/aurora-x.d.ts
111
+ declare const AuroraX: JsonupTheme;
112
+ //#endregion
113
+ //#region src/themes/ayu-dark.d.ts
114
+ declare const AyuDark: JsonupTheme;
115
+ //#endregion
116
+ //#region src/themes/ayu-light.d.ts
117
+ declare const AyuLight: JsonupTheme;
118
+ //#endregion
119
+ //#region src/themes/ayu-mirage.d.ts
120
+ declare const AyuMirage: JsonupTheme;
121
+ //#endregion
122
+ //#region src/themes/dark-plus.d.ts
123
+ declare const DarkPlus: JsonupTheme;
124
+ //#endregion
125
+ //#region src/themes/define-theme.d.ts
126
+ /**
127
+ * 内置主题的颜色配置接口
128
+ * 包含构建一个完整 Jsonup 主题所需的各项颜色属性
129
+ */
130
+ interface BuiltinThemeColors {
131
+ /** 背景色 */
132
+ background: string;
133
+ /** 前景色(默认文本颜色) */
134
+ foreground: string;
135
+ /** 行号颜色 */
136
+ lineNumber: string;
137
+ /** 摘要/折叠提示颜色 */
138
+ summary: string;
139
+ /** 属性键名颜色 */
140
+ property: string;
141
+ /** 字符串值颜色 */
142
+ string: string;
143
+ /** 数字值颜色 */
144
+ number: string;
145
+ /** 布尔值颜色 */
146
+ boolean: string;
147
+ /** Null 值颜色 */
148
+ null: string;
149
+ /** 标点符号颜色(如引号、冒号、逗号) */
150
+ punctuation: string;
151
+ }
152
+ /**
153
+ * 快速定义并生成一个 Jsonup 主题对象
154
+ *
155
+ * @param name - 主题名称
156
+ * @param type - 主题类型(亮色/暗色)
157
+ * @param colors - 内置主题的基础和语法高亮颜色配置
158
+ * @returns 构建完成的 Jsonup 主题配置对象
159
+ */
160
+ declare function defineTheme(name: string, type: JsonupThemeType, colors: BuiltinThemeColors): JsonupTheme;
161
+ //#endregion
162
+ //#region src/themes/dracula-soft.d.ts
163
+ declare const DraculaSoft: JsonupTheme;
164
+ //#endregion
165
+ //#region src/themes/dracula.d.ts
166
+ declare const Dracula: JsonupTheme;
167
+ //#endregion
168
+ //#region src/themes/everforest-dark.d.ts
169
+ declare const EverforestDark: JsonupTheme;
170
+ //#endregion
171
+ //#region src/themes/everforest-light.d.ts
172
+ declare const EverforestLight: JsonupTheme;
173
+ //#endregion
174
+ //#region src/themes/github-dark-dimmed.d.ts
175
+ declare const GithubDarkDimmed: JsonupTheme;
176
+ //#endregion
177
+ //#region src/themes/github-dark-high-contrast.d.ts
178
+ declare const GithubDarkHighContrast: JsonupTheme;
179
+ //#endregion
180
+ //#region src/themes/github-dark.d.ts
181
+ declare const GithubDark: JsonupTheme;
182
+ //#endregion
183
+ //#region src/themes/github-light-high-contrast.d.ts
184
+ declare const GithubLightHighContrast: JsonupTheme;
185
+ //#endregion
186
+ //#region src/themes/github-light.d.ts
187
+ declare const GithubLight: JsonupTheme;
188
+ //#endregion
189
+ //#region src/themes/gruvbox-dark-hard.d.ts
190
+ declare const GruvboxDarkHard: JsonupTheme;
191
+ //#endregion
192
+ //#region src/themes/gruvbox-dark-medium.d.ts
193
+ declare const GruvboxDarkMedium: JsonupTheme;
194
+ //#endregion
195
+ //#region src/themes/light-plus.d.ts
196
+ declare const LightPlus: JsonupTheme;
197
+ //#endregion
198
+ //#region src/themes/material-theme-darker.d.ts
199
+ declare const MaterialThemeDarker: JsonupTheme;
200
+ //#endregion
201
+ //#region src/themes/material-theme-lighter.d.ts
202
+ declare const MaterialThemeLighter: JsonupTheme;
203
+ //#endregion
204
+ //#region src/themes/material-theme-ocean.d.ts
205
+ declare const MaterialThemeOcean: JsonupTheme;
206
+ //#endregion
207
+ //#region src/themes/material-theme-palenight.d.ts
208
+ declare const MaterialThemePalenight: JsonupTheme;
209
+ //#endregion
210
+ //#region src/themes/material-theme.d.ts
211
+ declare const MaterialTheme: JsonupTheme;
212
+ //#endregion
213
+ //#region src/themes/min-dark.d.ts
214
+ declare const MinDark: JsonupTheme;
215
+ //#endregion
216
+ //#region src/themes/min-light.d.ts
217
+ declare const MinLight: JsonupTheme;
218
+ //#endregion
219
+ //#region src/themes/night-owl-light.d.ts
220
+ declare const NightOwlLight: JsonupTheme;
221
+ //#endregion
222
+ //#region src/themes/night-owl.d.ts
223
+ declare const NightOwl: JsonupTheme;
224
+ //#endregion
225
+ //#region src/themes/one-dark-pro.d.ts
226
+ declare const OneDarkPro: JsonupTheme;
227
+ //#endregion
228
+ //#region src/themes/one-dark.d.ts
229
+ declare const OneDark: JsonupTheme;
230
+ //#endregion
231
+ //#region src/themes/one-light.d.ts
232
+ declare const OneLight: JsonupTheme;
233
+ //#endregion
234
+ //#region src/themes/slack-dark.d.ts
235
+ declare const SlackDark: JsonupTheme;
236
+ //#endregion
237
+ //#region src/themes/slack-ochin.d.ts
238
+ declare const SlackOchin: JsonupTheme;
239
+ //#endregion
240
+ //#region src/themes/snazzy-light.d.ts
241
+ declare const SnazzyLight: JsonupTheme;
242
+ //#endregion
243
+ //#region src/themes/solarized-dark.d.ts
244
+ declare const SolarizedDark: JsonupTheme;
245
+ //#endregion
246
+ //#region src/themes/solarized-light.d.ts
247
+ declare const SolarizedLight: JsonupTheme;
248
+ //#endregion
249
+ //#region src/themes/vitesse-dark.d.ts
250
+ declare const VitesseDark: JsonupTheme;
251
+ //#endregion
252
+ //#region src/themes/vitesse-light.d.ts
253
+ declare const VitesseLight: JsonupTheme;
254
+ //#endregion
255
+ export { Andromeeda, AuroraX, AyuDark, AyuLight, AyuMirage, DarkPlus, Dracula, DraculaSoft, EverforestDark, EverforestLight, GithubDark, GithubDarkDimmed, GithubDarkHighContrast, GithubLight, GithubLightHighContrast, GruvboxDarkHard, GruvboxDarkMedium, type JsonupColors, type JsonupTheme, type JsonupThemeCssVarName, type JsonupThemeCssVars, type JsonupThemeScope, type JsonupThemeType, type JsonupTokenColor, type JsonupTokenSettings, LightPlus, MaterialTheme, MaterialThemeDarker, MaterialThemeLighter, MaterialThemeOcean, MaterialThemePalenight, MinDark, MinLight, NightOwl, NightOwlLight, OneDark, OneDarkPro, OneLight, SlackDark, SlackOchin, SnazzyLight, SolarizedDark, SolarizedLight, VitesseDark, VitesseLight, defineTheme, findTheme, themeOptions, themes, useCssVars };
package/dist/index.mjs ADDED
@@ -0,0 +1,831 @@
1
+ //#region src/css-vars.ts
2
+ const COLOR_VAR_MAP = {
3
+ background: "--jv-background",
4
+ foreground: "--jv-foreground",
5
+ lineNumber: "--jv-line-number",
6
+ summary: "--jv-summary"
7
+ };
8
+ const SCOPE_VAR_MAP = {
9
+ "string": "--jv-string",
10
+ "number": "--jv-number",
11
+ "boolean": "--jv-boolean",
12
+ "null": "--jv-null",
13
+ "property": "--jv-property",
14
+ "punctuation.quote.key": "--jv-punctuation-quote-key",
15
+ "punctuation.quote.string": "--jv-punctuation-quote-string",
16
+ "punctuation.quote": "--jv-punctuation-quote",
17
+ "punctuation.colon": "--jv-punctuation-colon",
18
+ "punctuation.comma": "--jv-punctuation-comma",
19
+ "punctuation.bracket": "--jv-punctuation-bracket",
20
+ "meta.line-number": "--jv-line-number",
21
+ "meta.summary": "--jv-summary",
22
+ "storage.object": "--jv-storage-object",
23
+ "storage.array": "--jv-storage-array"
24
+ };
25
+ /**
26
+ * 将 Jsonup 主题对象转换为 CSS 变量对象
27
+ *
28
+ * @param theme - 要转换的 Jsonup 主题对象,如果为 undefined 或 null 则返回空对象
29
+ * @returns 包含映射后 CSS 变量名及其对应颜色值的对象
30
+ */
31
+ function useCssVars(theme) {
32
+ if (!theme) return {};
33
+ const cssVars = {};
34
+ for (const [colorName, cssVarName] of Object.entries(COLOR_VAR_MAP)) {
35
+ const value = theme.colors[colorName];
36
+ if (value) cssVars[cssVarName] = value;
37
+ }
38
+ for (const tokenColor of theme.tokenColors) {
39
+ const scopes = Array.isArray(tokenColor.scope) ? tokenColor.scope : [tokenColor.scope];
40
+ const foreground = tokenColor.settings.foreground;
41
+ if (!foreground) continue;
42
+ for (const scope of scopes) cssVars[SCOPE_VAR_MAP[scope]] = foreground;
43
+ }
44
+ return cssVars;
45
+ }
46
+ //#endregion
47
+ //#region src/themes/define-theme.ts
48
+ /**
49
+ * 快速定义并生成一个 Jsonup 主题对象
50
+ *
51
+ * @param name - 主题名称
52
+ * @param type - 主题类型(亮色/暗色)
53
+ * @param colors - 内置主题的基础和语法高亮颜色配置
54
+ * @returns 构建完成的 Jsonup 主题配置对象
55
+ */
56
+ function defineTheme(name, type, colors) {
57
+ return {
58
+ name,
59
+ type,
60
+ colors: {
61
+ background: colors.background,
62
+ foreground: colors.foreground,
63
+ lineNumber: colors.lineNumber,
64
+ summary: colors.summary
65
+ },
66
+ tokenColors: [
67
+ {
68
+ scope: "property",
69
+ settings: { foreground: colors.property }
70
+ },
71
+ {
72
+ scope: "string",
73
+ settings: { foreground: colors.string }
74
+ },
75
+ {
76
+ scope: "number",
77
+ settings: { foreground: colors.number }
78
+ },
79
+ {
80
+ scope: "boolean",
81
+ settings: { foreground: colors.boolean }
82
+ },
83
+ {
84
+ scope: "null",
85
+ settings: { foreground: colors.null }
86
+ },
87
+ {
88
+ scope: [
89
+ "punctuation.quote",
90
+ "punctuation.colon",
91
+ "punctuation.comma"
92
+ ],
93
+ settings: { foreground: colors.punctuation }
94
+ },
95
+ {
96
+ scope: "punctuation.bracket",
97
+ settings: { foreground: colors.foreground }
98
+ },
99
+ {
100
+ scope: ["storage.object", "storage.array"],
101
+ settings: { foreground: colors.foreground }
102
+ }
103
+ ]
104
+ };
105
+ }
106
+ //#endregion
107
+ //#region src/themes/andromeeda.ts
108
+ const Andromeeda = defineTheme("andromeeda", "dark", {
109
+ background: "#23262E",
110
+ foreground: "#D5CED9",
111
+ lineNumber: "#746F77",
112
+ summary: "#746F77",
113
+ property: "#00E8C6",
114
+ string: "#D5CED9",
115
+ number: "#D5CED9",
116
+ boolean: "#F39C12",
117
+ null: "#F39C12",
118
+ punctuation: "#D5CED9"
119
+ });
120
+ //#endregion
121
+ //#region src/themes/aurora-x.ts
122
+ const AuroraX = defineTheme("aurora-x", "dark", {
123
+ background: "#07090F",
124
+ foreground: "#576DAF",
125
+ lineNumber: "#262E47BB",
126
+ summary: "#576DAF79",
127
+ property: "#C792EA",
128
+ string: "#EEFFFF",
129
+ number: "#EEFFFF",
130
+ boolean: "#C792EA",
131
+ null: "#C792EA",
132
+ punctuation: "#546E7A"
133
+ });
134
+ //#endregion
135
+ //#region src/themes/ayu-dark.ts
136
+ const AyuDark = defineTheme("ayu-dark", "dark", {
137
+ background: "#10141C",
138
+ foreground: "#BFBDB6",
139
+ lineNumber: "#5A6378A6",
140
+ summary: "#5A6378",
141
+ property: "#FFB454",
142
+ string: "#AAD94C",
143
+ number: "#AAD94C",
144
+ boolean: "#D2A6FF",
145
+ null: "#D2A6FF",
146
+ punctuation: "#BFBDB6B3"
147
+ });
148
+ //#endregion
149
+ //#region src/themes/ayu-light.ts
150
+ const AyuLight = defineTheme("ayu-light", "light", {
151
+ background: "#FCFCFC",
152
+ foreground: "#5C6166",
153
+ lineNumber: "#828E9F66",
154
+ summary: "#828E9F",
155
+ property: "#EBA400",
156
+ string: "#86B300",
157
+ number: "#86B300",
158
+ boolean: "#A37ACC",
159
+ null: "#A37ACC",
160
+ punctuation: "#5C6166B3"
161
+ });
162
+ //#endregion
163
+ //#region src/themes/ayu-mirage.ts
164
+ const AyuMirage = defineTheme("ayu-mirage", "dark", {
165
+ background: "#242936",
166
+ foreground: "#CCCAC2",
167
+ lineNumber: "#707A8C80",
168
+ summary: "#707A8C",
169
+ property: "#FFCD66",
170
+ string: "#D5FF80",
171
+ number: "#D5FF80",
172
+ boolean: "#DFBFFF",
173
+ null: "#DFBFFF",
174
+ punctuation: "#CCCAC2B3"
175
+ });
176
+ //#endregion
177
+ //#region src/themes/dark-plus.ts
178
+ const DarkPlus = defineTheme("dark-plus", "dark", {
179
+ background: "#1E1E1E",
180
+ foreground: "#D4D4D4",
181
+ lineNumber: "#858585",
182
+ summary: "#808080",
183
+ property: "#9CDCFE",
184
+ string: "#CE9178",
185
+ number: "#B5CEA8",
186
+ boolean: "#569CD6",
187
+ null: "#569CD6",
188
+ punctuation: "#D4D4D4"
189
+ });
190
+ //#endregion
191
+ //#region src/themes/dracula-soft.ts
192
+ const DraculaSoft = defineTheme("dracula-soft", "dark", {
193
+ background: "#282A36",
194
+ foreground: "#F6F6F4",
195
+ lineNumber: "#7B7F8B",
196
+ summary: "#7B7F8B",
197
+ property: "#F286C4",
198
+ string: "#F6C177",
199
+ number: "#BF9EEE",
200
+ boolean: "#BF9EEE",
201
+ null: "#BF9EEE",
202
+ punctuation: "#97E1F1"
203
+ });
204
+ //#endregion
205
+ //#region src/themes/dracula.ts
206
+ const Dracula = defineTheme("dracula", "dark", {
207
+ background: "#282A36",
208
+ foreground: "#F8F8F2",
209
+ lineNumber: "#6272A4",
210
+ summary: "#6272A4",
211
+ property: "#FF79C6",
212
+ string: "#F1FA8C",
213
+ number: "#BD93F9",
214
+ boolean: "#BD93F9",
215
+ null: "#BD93F9",
216
+ punctuation: "#8BE9FD"
217
+ });
218
+ //#endregion
219
+ //#region src/themes/everforest-dark.ts
220
+ const EverforestDark = defineTheme("everforest-dark", "dark", {
221
+ background: "#2D353B",
222
+ foreground: "#D3C6AA",
223
+ lineNumber: "#7F897DA0",
224
+ summary: "#859289",
225
+ property: "#DBBC7F",
226
+ string: "#A7C080",
227
+ number: "#D699B6",
228
+ boolean: "#E67E80",
229
+ null: "#E67E80",
230
+ punctuation: "#9DA9A0"
231
+ });
232
+ //#endregion
233
+ //#region src/themes/everforest-light.ts
234
+ const EverforestLight = defineTheme("everforest-light", "light", {
235
+ background: "#FDF6E3",
236
+ foreground: "#5C6A72",
237
+ lineNumber: "#A4AD9EA0",
238
+ summary: "#939F91",
239
+ property: "#DFA000",
240
+ string: "#8DA101",
241
+ number: "#D699B6",
242
+ boolean: "#F85552",
243
+ null: "#F85552",
244
+ punctuation: "#939F91"
245
+ });
246
+ //#endregion
247
+ //#region src/themes/github-dark-dimmed.ts
248
+ const GithubDarkDimmed = defineTheme("github-dark-dimmed", "dark", {
249
+ background: "#22272E",
250
+ foreground: "#ADBAC7",
251
+ lineNumber: "#636E7B",
252
+ summary: "#768390",
253
+ property: "#6CB6FF",
254
+ string: "#96D0FF",
255
+ number: "#F47067",
256
+ boolean: "#F47067",
257
+ null: "#F47067",
258
+ punctuation: "#768390"
259
+ });
260
+ //#endregion
261
+ //#region src/themes/github-dark-high-contrast.ts
262
+ const GithubDarkHighContrast = defineTheme("github-dark-high-contrast", "dark", {
263
+ background: "#0A0C10",
264
+ foreground: "#F0F3F6",
265
+ lineNumber: "#9EA7B3",
266
+ summary: "#9EA7B3",
267
+ property: "#91CBFF",
268
+ string: "#ADDCFF",
269
+ number: "#FF9492",
270
+ boolean: "#FF9492",
271
+ null: "#FF9492",
272
+ punctuation: "#BDC4CC"
273
+ });
274
+ //#endregion
275
+ //#region src/themes/github-dark.ts
276
+ const GithubDark = defineTheme("github-dark", "dark", {
277
+ background: "#24292E",
278
+ foreground: "#E1E4E8",
279
+ lineNumber: "#444D56",
280
+ summary: "#959DA5",
281
+ property: "#79B8FF",
282
+ string: "#9ECBFF",
283
+ number: "#79B8FF",
284
+ boolean: "#79B8FF",
285
+ null: "#79B8FF",
286
+ punctuation: "#E1E4E8"
287
+ });
288
+ //#endregion
289
+ //#region src/themes/github-light-high-contrast.ts
290
+ const GithubLightHighContrast = defineTheme("github-light-high-contrast", "light", {
291
+ background: "#FFFFFF",
292
+ foreground: "#0E1116",
293
+ lineNumber: "#88929D",
294
+ summary: "#66707B",
295
+ property: "#023B95",
296
+ string: "#0A3069",
297
+ number: "#A0111F",
298
+ boolean: "#A0111F",
299
+ null: "#A0111F",
300
+ punctuation: "#66707B"
301
+ });
302
+ //#endregion
303
+ //#region src/themes/github-light.ts
304
+ const GithubLight = defineTheme("github-light", "light", {
305
+ background: "#FFFFFF",
306
+ foreground: "#24292E",
307
+ lineNumber: "#8C959F",
308
+ summary: "#656D76",
309
+ property: "#116329",
310
+ string: "#0A3069",
311
+ number: "#CF222E",
312
+ boolean: "#CF222E",
313
+ null: "#CF222E",
314
+ punctuation: "#6E7781"
315
+ });
316
+ //#endregion
317
+ //#region src/themes/gruvbox-dark-hard.ts
318
+ const GruvboxDarkHard = defineTheme("gruvbox-dark-hard", "dark", {
319
+ background: "#1D2021",
320
+ foreground: "#EBDBB2",
321
+ lineNumber: "#665C54",
322
+ summary: "#928374",
323
+ property: "#FABD2F",
324
+ string: "#B8BB26",
325
+ number: "#D3869B",
326
+ boolean: "#FB4934",
327
+ null: "#FB4934",
328
+ punctuation: "#928374"
329
+ });
330
+ //#endregion
331
+ //#region src/themes/gruvbox-dark-medium.ts
332
+ const GruvboxDarkMedium = defineTheme("gruvbox-dark-medium", "dark", {
333
+ background: "#282828",
334
+ foreground: "#EBDBB2",
335
+ lineNumber: "#665C54",
336
+ summary: "#928374",
337
+ property: "#FABD2F",
338
+ string: "#B8BB26",
339
+ number: "#D3869B",
340
+ boolean: "#FB4934",
341
+ null: "#FB4934",
342
+ punctuation: "#928374"
343
+ });
344
+ //#endregion
345
+ //#region src/themes/light-plus.ts
346
+ const LightPlus = defineTheme("light-plus", "light", {
347
+ background: "#FFFFFF",
348
+ foreground: "#000000",
349
+ lineNumber: "#237893",
350
+ summary: "#6A737D",
351
+ property: "#0451A5",
352
+ string: "#A31515",
353
+ number: "#098658",
354
+ boolean: "#0000FF",
355
+ null: "#0000FF",
356
+ punctuation: "#000000"
357
+ });
358
+ //#endregion
359
+ //#region src/themes/material-theme-darker.ts
360
+ const MaterialThemeDarker = defineTheme("material-theme-darker", "dark", {
361
+ background: "#212121",
362
+ foreground: "#EEFFFF",
363
+ lineNumber: "#424242",
364
+ summary: "#A6ACCD",
365
+ property: "#F07178",
366
+ string: "#C3E88D",
367
+ number: "#89DDFF",
368
+ boolean: "#FF9CAC",
369
+ null: "#FF9CAC",
370
+ punctuation: "#89DDFF"
371
+ });
372
+ //#endregion
373
+ //#region src/themes/material-theme-lighter.ts
374
+ const MaterialThemeLighter = defineTheme("material-theme-lighter", "light", {
375
+ background: "#FAFAFA",
376
+ foreground: "#90A4AE",
377
+ lineNumber: "#CFD8DC",
378
+ summary: "#8796B0",
379
+ property: "#E53935",
380
+ string: "#91B859",
381
+ number: "#39ADB5",
382
+ boolean: "#FF5370",
383
+ null: "#FF5370",
384
+ punctuation: "#39ADB5"
385
+ });
386
+ //#endregion
387
+ //#region src/themes/material-theme-ocean.ts
388
+ const MaterialThemeOcean = defineTheme("material-theme-ocean", "dark", {
389
+ background: "#0F111A",
390
+ foreground: "#BABED8",
391
+ lineNumber: "#3B3F5180",
392
+ summary: "#A6ACCD",
393
+ property: "#F07178",
394
+ string: "#C3E88D",
395
+ number: "#89DDFF",
396
+ boolean: "#FF9CAC",
397
+ null: "#FF9CAC",
398
+ punctuation: "#89DDFF"
399
+ });
400
+ //#endregion
401
+ //#region src/themes/material-theme-palenight.ts
402
+ const MaterialThemePalenight = defineTheme("material-theme-palenight", "dark", {
403
+ background: "#292D3E",
404
+ foreground: "#BABED8",
405
+ lineNumber: "#3A3F58",
406
+ summary: "#A6ACCD",
407
+ property: "#F07178",
408
+ string: "#C3E88D",
409
+ number: "#89DDFF",
410
+ boolean: "#FF9CAC",
411
+ null: "#FF9CAC",
412
+ punctuation: "#89DDFF"
413
+ });
414
+ //#endregion
415
+ //#region src/themes/material-theme.ts
416
+ const MaterialTheme = defineTheme("material-theme", "dark", {
417
+ background: "#263238",
418
+ foreground: "#EEFFFF",
419
+ lineNumber: "#465A64",
420
+ summary: "#A6ACCD",
421
+ property: "#F07178",
422
+ string: "#C3E88D",
423
+ number: "#89DDFF",
424
+ boolean: "#FF9CAC",
425
+ null: "#FF9CAC",
426
+ punctuation: "#89DDFF"
427
+ });
428
+ //#endregion
429
+ //#region src/themes/min-dark.ts
430
+ const MinDark = defineTheme("min-dark", "dark", {
431
+ background: "#1F1F1F",
432
+ foreground: "#888888",
433
+ lineNumber: "#727272",
434
+ summary: "#888888",
435
+ property: "#79B8FF",
436
+ string: "#9DB1C5",
437
+ number: "#79B8FF",
438
+ boolean: "#B392F0",
439
+ null: "#B392F0",
440
+ punctuation: "#F97583"
441
+ });
442
+ //#endregion
443
+ //#region src/themes/min-light.ts
444
+ const MinLight = defineTheme("min-light", "light", {
445
+ background: "#FFFFFF",
446
+ foreground: "#212121",
447
+ lineNumber: "#CCCCCC",
448
+ summary: "#757575",
449
+ property: "#1976D2",
450
+ string: "#2B5581",
451
+ number: "#1976D2",
452
+ boolean: "#24292E",
453
+ null: "#24292E",
454
+ punctuation: "#D32F2F"
455
+ });
456
+ //#endregion
457
+ //#region src/themes/night-owl-light.ts
458
+ const NightOwlLight = defineTheme("night-owl-light", "light", {
459
+ background: "#FBFBFB",
460
+ foreground: "#403F53",
461
+ lineNumber: "#90A7B2",
462
+ summary: "#989FB1",
463
+ property: "#4876D6",
464
+ string: "#4876D6",
465
+ number: "#4876D6",
466
+ boolean: "#4876D6",
467
+ null: "#4876D6",
468
+ punctuation: "#989FB1"
469
+ });
470
+ //#endregion
471
+ //#region src/themes/night-owl.ts
472
+ const NightOwl = defineTheme("night-owl", "dark", {
473
+ background: "#011627",
474
+ foreground: "#D6DEEB",
475
+ lineNumber: "#4B6479",
476
+ summary: "#637777",
477
+ property: "#7FDBCA",
478
+ string: "#C789D6",
479
+ number: "#C5E478",
480
+ boolean: "#FF5874",
481
+ null: "#FF5874",
482
+ punctuation: "#80CBC4"
483
+ });
484
+ //#endregion
485
+ //#region src/themes/one-dark-pro.ts
486
+ const OneDarkPro = defineTheme("one-dark-pro", "dark", {
487
+ background: "#282C34",
488
+ foreground: "#ABB2BF",
489
+ lineNumber: "#495162",
490
+ summary: "#7F848E",
491
+ property: "#D19A66",
492
+ string: "#98C379",
493
+ number: "#D19A66",
494
+ boolean: "#56B6C2",
495
+ null: "#C678DD",
496
+ punctuation: "#ABB2BF"
497
+ });
498
+ //#endregion
499
+ //#region src/themes/one-dark.ts
500
+ const OneDark = defineTheme("one-dark", "dark", {
501
+ background: "#282C34",
502
+ foreground: "#ABB2BF",
503
+ lineNumber: "#495162",
504
+ summary: "#7F848E",
505
+ property: "#E06C75",
506
+ string: "#98C379",
507
+ number: "#D19A66",
508
+ boolean: "#56B6C2",
509
+ null: "#56B6C2",
510
+ punctuation: "#ABB2BF"
511
+ });
512
+ //#endregion
513
+ //#region src/themes/one-light.ts
514
+ const OneLight = defineTheme("one-light", "light", {
515
+ background: "#FAFAFA",
516
+ foreground: "#6a6a6a",
517
+ lineNumber: "#9D9D9F",
518
+ summary: "#A0A1A7",
519
+ property: "#E45649",
520
+ string: "#50A14F",
521
+ number: "#986801",
522
+ boolean: "#0184BC",
523
+ null: "#0184BC",
524
+ punctuation: "#383A42"
525
+ });
526
+ //#endregion
527
+ //#region src/themes/slack-dark.ts
528
+ const SlackDark = defineTheme("slack-dark", "dark", {
529
+ background: "#222222",
530
+ foreground: "#E6E6E6",
531
+ lineNumber: "#6A6A6A",
532
+ summary: "#8C8C8C",
533
+ property: "#9CDCFE",
534
+ string: "#CE9178",
535
+ number: "#569CD6",
536
+ boolean: "#569CD6",
537
+ null: "#569CD6",
538
+ punctuation: "#D4D4D4"
539
+ });
540
+ //#endregion
541
+ //#region src/themes/slack-ochin.ts
542
+ const SlackOchin = defineTheme("slack-ochin", "light", {
543
+ background: "#FFF",
544
+ foreground: "#000",
545
+ lineNumber: "#B9B9B9",
546
+ summary: "#616161",
547
+ property: "#DF8618",
548
+ string: "#110000",
549
+ number: "#174781",
550
+ boolean: "#7B30D0",
551
+ null: "#7B30D0",
552
+ punctuation: "#034C7C"
553
+ });
554
+ //#endregion
555
+ //#region src/themes/snazzy-light.ts
556
+ const SnazzyLight = defineTheme("snazzy-light", "light", {
557
+ background: "#FAFBFC",
558
+ foreground: "#565869",
559
+ lineNumber: "#9194A2AA",
560
+ summary: "#686968",
561
+ property: "#9194A2",
562
+ string: "#11658F",
563
+ number: "#11658F",
564
+ boolean: "#F767BB",
565
+ null: "#F767BB",
566
+ punctuation: "#00A39F"
567
+ });
568
+ //#endregion
569
+ //#region src/themes/solarized-dark.ts
570
+ const SolarizedDark = defineTheme("solarized-dark", "dark", {
571
+ background: "#002B36",
572
+ foreground: "#839496",
573
+ lineNumber: "#586E75",
574
+ summary: "#586E75",
575
+ property: "#93A1A1",
576
+ string: "#2AA198",
577
+ number: "#D33682",
578
+ boolean: "#859900",
579
+ null: "#859900",
580
+ punctuation: "#586E75"
581
+ });
582
+ //#endregion
583
+ //#region src/themes/solarized-light.ts
584
+ const SolarizedLight = defineTheme("solarized-light", "light", {
585
+ background: "#FDF6E3",
586
+ foreground: "#657B83",
587
+ lineNumber: "#93A1A1",
588
+ summary: "#93A1A1",
589
+ property: "#93A1A1",
590
+ string: "#2AA198",
591
+ number: "#D33682",
592
+ boolean: "#859900",
593
+ null: "#859900",
594
+ punctuation: "#93A1A1"
595
+ });
596
+ //#endregion
597
+ //#region src/themes/vitesse-dark.ts
598
+ const VitesseDark = defineTheme("vitesse-dark", "dark", {
599
+ background: "#121212",
600
+ foreground: "#DBD7CAEE",
601
+ lineNumber: "#DEDCD550",
602
+ summary: "#DEDCD590",
603
+ property: "#B8A965",
604
+ string: "#758575DD",
605
+ number: "#C99076",
606
+ boolean: "#CB7676",
607
+ null: "#CB7676",
608
+ punctuation: "#A1A19A"
609
+ });
610
+ //#endregion
611
+ //#region src/themes/vitesse-light.ts
612
+ const VitesseLight = defineTheme("vitesse-light", "light", {
613
+ background: "#FFFFFF",
614
+ foreground: "#393A34",
615
+ lineNumber: "#393A3450",
616
+ summary: "#393A3490",
617
+ property: "#998418",
618
+ string: "#A0ADA0",
619
+ number: "#A65E2B",
620
+ boolean: "#AB5959",
621
+ null: "#AB5959",
622
+ punctuation: "#8C8C84"
623
+ });
624
+ //#endregion
625
+ //#region src/theme-options.ts
626
+ /**
627
+ * 所有预设主题的选项列表
628
+ */
629
+ const themeOptions = [
630
+ {
631
+ label: "Andromeeda",
632
+ value: "andromeeda",
633
+ theme: Andromeeda
634
+ },
635
+ {
636
+ label: "Aurora X",
637
+ value: "aurora-x",
638
+ theme: AuroraX
639
+ },
640
+ {
641
+ label: "Ayu Dark",
642
+ value: "ayu-dark",
643
+ theme: AyuDark
644
+ },
645
+ {
646
+ label: "Ayu Light",
647
+ value: "ayu-light",
648
+ theme: AyuLight
649
+ },
650
+ {
651
+ label: "Ayu Mirage",
652
+ value: "ayu-mirage",
653
+ theme: AyuMirage
654
+ },
655
+ {
656
+ label: "Dark Plus",
657
+ value: "dark-plus",
658
+ theme: DarkPlus
659
+ },
660
+ {
661
+ label: "Dracula Theme",
662
+ value: "dracula",
663
+ theme: Dracula
664
+ },
665
+ {
666
+ label: "Dracula Theme Soft",
667
+ value: "dracula-soft",
668
+ theme: DraculaSoft
669
+ },
670
+ {
671
+ label: "Everforest Dark",
672
+ value: "everforest-dark",
673
+ theme: EverforestDark
674
+ },
675
+ {
676
+ label: "Everforest Light",
677
+ value: "everforest-light",
678
+ theme: EverforestLight
679
+ },
680
+ {
681
+ label: "GitHub Dark",
682
+ value: "github-dark",
683
+ theme: GithubDark
684
+ },
685
+ {
686
+ label: "GitHub Dark Dimmed",
687
+ value: "github-dark-dimmed",
688
+ theme: GithubDarkDimmed
689
+ },
690
+ {
691
+ label: "GitHub Dark High Contrast",
692
+ value: "github-dark-high-contrast",
693
+ theme: GithubDarkHighContrast
694
+ },
695
+ {
696
+ label: "GitHub Light",
697
+ value: "github-light",
698
+ theme: GithubLight
699
+ },
700
+ {
701
+ label: "GitHub Light High Contrast",
702
+ value: "github-light-high-contrast",
703
+ theme: GithubLightHighContrast
704
+ },
705
+ {
706
+ label: "Gruvbox Dark Hard",
707
+ value: "gruvbox-dark-hard",
708
+ theme: GruvboxDarkHard
709
+ },
710
+ {
711
+ label: "Gruvbox Dark Medium",
712
+ value: "gruvbox-dark-medium",
713
+ theme: GruvboxDarkMedium
714
+ },
715
+ {
716
+ label: "Light Plus",
717
+ value: "light-plus",
718
+ theme: LightPlus
719
+ },
720
+ {
721
+ label: "Material Theme",
722
+ value: "material-theme",
723
+ theme: MaterialTheme
724
+ },
725
+ {
726
+ label: "Material Theme Darker",
727
+ value: "material-theme-darker",
728
+ theme: MaterialThemeDarker
729
+ },
730
+ {
731
+ label: "Material Theme Lighter",
732
+ value: "material-theme-lighter",
733
+ theme: MaterialThemeLighter
734
+ },
735
+ {
736
+ label: "Material Theme Ocean",
737
+ value: "material-theme-ocean",
738
+ theme: MaterialThemeOcean
739
+ },
740
+ {
741
+ label: "Material Theme Palenight",
742
+ value: "material-theme-palenight",
743
+ theme: MaterialThemePalenight
744
+ },
745
+ {
746
+ label: "Min Dark",
747
+ value: "min-dark",
748
+ theme: MinDark
749
+ },
750
+ {
751
+ label: "Min Light",
752
+ value: "min-light",
753
+ theme: MinLight
754
+ },
755
+ {
756
+ label: "Night Owl",
757
+ value: "night-owl",
758
+ theme: NightOwl
759
+ },
760
+ {
761
+ label: "Night Owl Light",
762
+ value: "night-owl-light",
763
+ theme: NightOwlLight
764
+ },
765
+ {
766
+ label: "One Dark",
767
+ value: "one-dark",
768
+ theme: OneDark
769
+ },
770
+ {
771
+ label: "One Dark Pro",
772
+ value: "one-dark-pro",
773
+ theme: OneDarkPro
774
+ },
775
+ {
776
+ label: "One Light",
777
+ value: "one-light",
778
+ theme: OneLight
779
+ },
780
+ {
781
+ label: "Slack Dark",
782
+ value: "slack-dark",
783
+ theme: SlackDark
784
+ },
785
+ {
786
+ label: "Slack Ochin",
787
+ value: "slack-ochin",
788
+ theme: SlackOchin
789
+ },
790
+ {
791
+ label: "Snazzy Light",
792
+ value: "snazzy-light",
793
+ theme: SnazzyLight
794
+ },
795
+ {
796
+ label: "Solarized Dark",
797
+ value: "solarized-dark",
798
+ theme: SolarizedDark
799
+ },
800
+ {
801
+ label: "Solarized Light",
802
+ value: "solarized-light",
803
+ theme: SolarizedLight
804
+ },
805
+ {
806
+ label: "Vitesse Dark",
807
+ value: "vitesse-dark",
808
+ theme: VitesseDark
809
+ },
810
+ {
811
+ label: "Vitesse Light",
812
+ value: "vitesse-light",
813
+ theme: VitesseLight
814
+ }
815
+ ];
816
+ /**
817
+ * 根据主题值查找对应的主题配置
818
+ *
819
+ * @param value - 要查找的主题值(标识符)
820
+ * @returns 查找到的主题配置对象,如果未找到则返回 undefined
821
+ */
822
+ function findTheme(value) {
823
+ return value ? themeOptions.find((item) => item.value === value)?.theme : void 0;
824
+ }
825
+ /**
826
+ * 以键值对形式导出的所有主题对象字典
827
+ * 键为主题值,值为主题配置对象
828
+ */
829
+ const themes = Object.fromEntries(themeOptions.map((item) => [item.value, item.theme]));
830
+ //#endregion
831
+ export { Andromeeda, AuroraX, AyuDark, AyuLight, AyuMirage, DarkPlus, Dracula, DraculaSoft, EverforestDark, EverforestLight, GithubDark, GithubDarkDimmed, GithubDarkHighContrast, GithubLight, GithubLightHighContrast, GruvboxDarkHard, GruvboxDarkMedium, LightPlus, MaterialTheme, MaterialThemeDarker, MaterialThemeLighter, MaterialThemeOcean, MaterialThemePalenight, MinDark, MinLight, NightOwl, NightOwlLight, OneDark, OneDarkPro, OneLight, SlackDark, SlackOchin, SnazzyLight, SolarizedDark, SolarizedLight, VitesseDark, VitesseLight, defineTheme, findTheme, themeOptions, themes, useCssVars };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@jsonup/themes",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Theming system and CSS variables for the jsonup ecosystem.",
6
+ "author": {
7
+ "name": "Michael Cocova",
8
+ "email": "michael.cocova@gmail.com"
9
+ },
10
+ "license": "MIT",
11
+ "homepage": "https://github.com/michaelcocova/jsonup#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/michaelcocova/jsonup.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/michaelcocova/jsonup/issues"
18
+ },
19
+ "exports": {
20
+ ".": "./dist/index.mjs",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "devDependencies": {
27
+ "tsdown": "^0.22.0",
28
+ "typescript": "^6.0.3"
29
+ },
30
+ "scripts": {
31
+ "build": "tsdown",
32
+ "dev": "tsdown --watch",
33
+ "test": "vitest run"
34
+ }
35
+ }