@aalis/api-webui 0.11.0 → 0.12.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.
@@ -0,0 +1,469 @@
1
+ /** 主题文件的格式名 */
2
+ export declare const THEME_FILE_FORMAT = "aalis-theme";
3
+ /** 主题文件的格式版本:令牌表改名时加一,旧版本的文件按版本迁移 */
4
+ export declare const THEME_FILE_VERSION = 1;
5
+ /**
6
+ * 颜色令牌表,名字即 CSS 自定义属性名。fill 系列是半透明的叠加底,放在任何底色上都成立;
7
+ * 图表色给关系图等分类着色,语法色给代码高亮
8
+ */
9
+ export declare const THEME_TOKENS: readonly ["--color-bg", "--color-bg-side", "--color-bg-rail", "--color-surface-raised", "--color-fill-1", "--color-fill-2", "--color-fill-3", "--color-border", "--color-border-control", "--color-text", "--color-text-2", "--color-text-3", "--color-text-disabled", "--color-accent", "--color-accent-hover", "--color-on-accent", "--color-accent-text", "--color-accent-subtle", "--color-focus", "--color-mark", "--color-danger", "--color-danger-hover", "--color-danger-text", "--color-danger-subtle", "--color-warning-text", "--color-warning-subtle", "--color-success-text", "--color-success-subtle", "--color-scrim", "--color-shadow", "--color-chart-1", "--color-chart-2", "--color-chart-3", "--color-chart-4", "--color-chart-5", "--color-chart-6", "--color-syntax-keyword", "--color-syntax-string", "--color-syntax-number", "--color-syntax-comment", "--color-syntax-function", "--color-syntax-type"];
10
+ export type ThemeToken = (typeof THEME_TOKENS)[number];
11
+ export type ThemeKind = 'dark' | 'light';
12
+ /** 主题文件:没写的令牌按同种类的偏中性主题补 */
13
+ export interface ThemeFile {
14
+ format: typeof THEME_FILE_FORMAT;
15
+ version: typeof THEME_FILE_VERSION;
16
+ name: string;
17
+ kind: ThemeKind;
18
+ colors: Partial<Record<ThemeToken, string>>;
19
+ }
20
+ /** 校验过的主题:每个令牌都有值 */
21
+ export interface Theme {
22
+ name: string;
23
+ kind: ThemeKind;
24
+ colors: Record<ThemeToken, string>;
25
+ }
26
+ export type ThemeParseResult = {
27
+ ok: true;
28
+ theme: Theme;
29
+ } | {
30
+ ok: false;
31
+ errors: string[];
32
+ };
33
+ /**
34
+ * `webui:theme` 贡献点的 spec:插件交一份主题文件,经 `contributions.contribute('webui:theme', { id, theme })` 登记,
35
+ * 随激活撤回。id 是局部名,与插件实例 id 合成全局键。主题只是数据,与导入的主题文件走同一套校验(parseTheme),
36
+ * 不合格式的不列出,webui-server 记一条告警
37
+ */
38
+ export interface ThemeContribution {
39
+ id: string;
40
+ theme: ThemeFile;
41
+ }
42
+ declare module '@aalis/api-contributions' {
43
+ interface ContributionPointMap {
44
+ 'webui:theme': ThemeContribution;
45
+ }
46
+ }
47
+ /** GET /api/themes 的一项:贡献点的全局键(`<插件实例 id>/<局部 id>`)、提供它的插件实例与校验过的主题 */
48
+ export interface PluginTheme {
49
+ id: string;
50
+ instance: string;
51
+ theme: Theme;
52
+ }
53
+ /** 内置主题:随包带的主题文件,键是主题 id(配色名加种类) */
54
+ export declare const BUILTIN_THEMES: {
55
+ 'calm-dark': {
56
+ format: string;
57
+ version: number;
58
+ name: string;
59
+ kind: string;
60
+ colors: {
61
+ "--color-bg": string;
62
+ "--color-bg-side": string;
63
+ "--color-bg-rail": string;
64
+ "--color-surface-raised": string;
65
+ "--color-fill-1": string;
66
+ "--color-fill-2": string;
67
+ "--color-fill-3": string;
68
+ "--color-border": string;
69
+ "--color-border-control": string;
70
+ "--color-text": string;
71
+ "--color-text-2": string;
72
+ "--color-text-3": string;
73
+ "--color-text-disabled": string;
74
+ "--color-accent": string;
75
+ "--color-accent-hover": string;
76
+ "--color-on-accent": string;
77
+ "--color-accent-text": string;
78
+ "--color-accent-subtle": string;
79
+ "--color-focus": string;
80
+ "--color-mark": string;
81
+ "--color-danger": string;
82
+ "--color-danger-hover": string;
83
+ "--color-danger-text": string;
84
+ "--color-danger-subtle": string;
85
+ "--color-warning-text": string;
86
+ "--color-warning-subtle": string;
87
+ "--color-success-text": string;
88
+ "--color-success-subtle": string;
89
+ "--color-scrim": string;
90
+ "--color-shadow": string;
91
+ "--color-chart-1": string;
92
+ "--color-chart-2": string;
93
+ "--color-chart-3": string;
94
+ "--color-chart-4": string;
95
+ "--color-chart-5": string;
96
+ "--color-chart-6": string;
97
+ "--color-syntax-keyword": string;
98
+ "--color-syntax-string": string;
99
+ "--color-syntax-number": string;
100
+ "--color-syntax-comment": string;
101
+ "--color-syntax-function": string;
102
+ "--color-syntax-type": string;
103
+ };
104
+ };
105
+ 'calm-light': {
106
+ format: string;
107
+ version: number;
108
+ name: string;
109
+ kind: string;
110
+ colors: {
111
+ "--color-bg": string;
112
+ "--color-bg-side": string;
113
+ "--color-bg-rail": string;
114
+ "--color-surface-raised": string;
115
+ "--color-fill-1": string;
116
+ "--color-fill-2": string;
117
+ "--color-fill-3": string;
118
+ "--color-border": string;
119
+ "--color-border-control": string;
120
+ "--color-text": string;
121
+ "--color-text-2": string;
122
+ "--color-text-3": string;
123
+ "--color-text-disabled": string;
124
+ "--color-accent": string;
125
+ "--color-accent-hover": string;
126
+ "--color-on-accent": string;
127
+ "--color-accent-text": string;
128
+ "--color-accent-subtle": string;
129
+ "--color-focus": string;
130
+ "--color-mark": string;
131
+ "--color-danger": string;
132
+ "--color-danger-hover": string;
133
+ "--color-danger-text": string;
134
+ "--color-danger-subtle": string;
135
+ "--color-warning-text": string;
136
+ "--color-warning-subtle": string;
137
+ "--color-success-text": string;
138
+ "--color-success-subtle": string;
139
+ "--color-scrim": string;
140
+ "--color-shadow": string;
141
+ "--color-chart-1": string;
142
+ "--color-chart-2": string;
143
+ "--color-chart-3": string;
144
+ "--color-chart-4": string;
145
+ "--color-chart-5": string;
146
+ "--color-chart-6": string;
147
+ "--color-syntax-keyword": string;
148
+ "--color-syntax-string": string;
149
+ "--color-syntax-number": string;
150
+ "--color-syntax-comment": string;
151
+ "--color-syntax-function": string;
152
+ "--color-syntax-type": string;
153
+ };
154
+ };
155
+ 'aalis-dark': {
156
+ format: string;
157
+ version: number;
158
+ name: string;
159
+ kind: string;
160
+ colors: {
161
+ "--color-bg": string;
162
+ "--color-bg-side": string;
163
+ "--color-bg-rail": string;
164
+ "--color-surface-raised": string;
165
+ "--color-fill-1": string;
166
+ "--color-fill-2": string;
167
+ "--color-fill-3": string;
168
+ "--color-border": string;
169
+ "--color-border-control": string;
170
+ "--color-text": string;
171
+ "--color-text-2": string;
172
+ "--color-text-3": string;
173
+ "--color-text-disabled": string;
174
+ "--color-accent": string;
175
+ "--color-accent-hover": string;
176
+ "--color-on-accent": string;
177
+ "--color-accent-text": string;
178
+ "--color-accent-subtle": string;
179
+ "--color-focus": string;
180
+ "--color-mark": string;
181
+ "--color-danger": string;
182
+ "--color-danger-hover": string;
183
+ "--color-danger-text": string;
184
+ "--color-danger-subtle": string;
185
+ "--color-warning-text": string;
186
+ "--color-warning-subtle": string;
187
+ "--color-success-text": string;
188
+ "--color-success-subtle": string;
189
+ "--color-scrim": string;
190
+ "--color-shadow": string;
191
+ "--color-chart-1": string;
192
+ "--color-chart-2": string;
193
+ "--color-chart-3": string;
194
+ "--color-chart-4": string;
195
+ "--color-chart-5": string;
196
+ "--color-chart-6": string;
197
+ "--color-syntax-keyword": string;
198
+ "--color-syntax-string": string;
199
+ "--color-syntax-number": string;
200
+ "--color-syntax-comment": string;
201
+ "--color-syntax-function": string;
202
+ "--color-syntax-type": string;
203
+ };
204
+ };
205
+ 'aalis-light': {
206
+ format: string;
207
+ version: number;
208
+ name: string;
209
+ kind: string;
210
+ colors: {
211
+ "--color-bg": string;
212
+ "--color-bg-side": string;
213
+ "--color-bg-rail": string;
214
+ "--color-surface-raised": string;
215
+ "--color-fill-1": string;
216
+ "--color-fill-2": string;
217
+ "--color-fill-3": string;
218
+ "--color-border": string;
219
+ "--color-border-control": string;
220
+ "--color-text": string;
221
+ "--color-text-2": string;
222
+ "--color-text-3": string;
223
+ "--color-text-disabled": string;
224
+ "--color-accent": string;
225
+ "--color-accent-hover": string;
226
+ "--color-on-accent": string;
227
+ "--color-accent-text": string;
228
+ "--color-accent-subtle": string;
229
+ "--color-focus": string;
230
+ "--color-mark": string;
231
+ "--color-danger": string;
232
+ "--color-danger-hover": string;
233
+ "--color-danger-text": string;
234
+ "--color-danger-subtle": string;
235
+ "--color-warning-text": string;
236
+ "--color-warning-subtle": string;
237
+ "--color-success-text": string;
238
+ "--color-success-subtle": string;
239
+ "--color-scrim": string;
240
+ "--color-shadow": string;
241
+ "--color-chart-1": string;
242
+ "--color-chart-2": string;
243
+ "--color-chart-3": string;
244
+ "--color-chart-4": string;
245
+ "--color-chart-5": string;
246
+ "--color-chart-6": string;
247
+ "--color-syntax-keyword": string;
248
+ "--color-syntax-string": string;
249
+ "--color-syntax-number": string;
250
+ "--color-syntax-comment": string;
251
+ "--color-syntax-function": string;
252
+ "--color-syntax-type": string;
253
+ };
254
+ };
255
+ 'brand-dark': {
256
+ format: string;
257
+ version: number;
258
+ name: string;
259
+ kind: string;
260
+ colors: {
261
+ "--color-bg": string;
262
+ "--color-bg-side": string;
263
+ "--color-bg-rail": string;
264
+ "--color-surface-raised": string;
265
+ "--color-fill-1": string;
266
+ "--color-fill-2": string;
267
+ "--color-fill-3": string;
268
+ "--color-border": string;
269
+ "--color-border-control": string;
270
+ "--color-text": string;
271
+ "--color-text-2": string;
272
+ "--color-text-3": string;
273
+ "--color-text-disabled": string;
274
+ "--color-accent": string;
275
+ "--color-accent-hover": string;
276
+ "--color-on-accent": string;
277
+ "--color-accent-text": string;
278
+ "--color-accent-subtle": string;
279
+ "--color-focus": string;
280
+ "--color-mark": string;
281
+ "--color-danger": string;
282
+ "--color-danger-hover": string;
283
+ "--color-danger-text": string;
284
+ "--color-danger-subtle": string;
285
+ "--color-warning-text": string;
286
+ "--color-warning-subtle": string;
287
+ "--color-success-text": string;
288
+ "--color-success-subtle": string;
289
+ "--color-scrim": string;
290
+ "--color-shadow": string;
291
+ "--color-chart-1": string;
292
+ "--color-chart-2": string;
293
+ "--color-chart-3": string;
294
+ "--color-chart-4": string;
295
+ "--color-chart-5": string;
296
+ "--color-chart-6": string;
297
+ "--color-syntax-keyword": string;
298
+ "--color-syntax-string": string;
299
+ "--color-syntax-number": string;
300
+ "--color-syntax-comment": string;
301
+ "--color-syntax-function": string;
302
+ "--color-syntax-type": string;
303
+ };
304
+ };
305
+ 'brand-light': {
306
+ format: string;
307
+ version: number;
308
+ name: string;
309
+ kind: string;
310
+ colors: {
311
+ "--color-bg": string;
312
+ "--color-bg-side": string;
313
+ "--color-bg-rail": string;
314
+ "--color-surface-raised": string;
315
+ "--color-fill-1": string;
316
+ "--color-fill-2": string;
317
+ "--color-fill-3": string;
318
+ "--color-border": string;
319
+ "--color-border-control": string;
320
+ "--color-text": string;
321
+ "--color-text-2": string;
322
+ "--color-text-3": string;
323
+ "--color-text-disabled": string;
324
+ "--color-accent": string;
325
+ "--color-accent-hover": string;
326
+ "--color-on-accent": string;
327
+ "--color-accent-text": string;
328
+ "--color-accent-subtle": string;
329
+ "--color-focus": string;
330
+ "--color-mark": string;
331
+ "--color-danger": string;
332
+ "--color-danger-hover": string;
333
+ "--color-danger-text": string;
334
+ "--color-danger-subtle": string;
335
+ "--color-warning-text": string;
336
+ "--color-warning-subtle": string;
337
+ "--color-success-text": string;
338
+ "--color-success-subtle": string;
339
+ "--color-scrim": string;
340
+ "--color-shadow": string;
341
+ "--color-chart-1": string;
342
+ "--color-chart-2": string;
343
+ "--color-chart-3": string;
344
+ "--color-chart-4": string;
345
+ "--color-chart-5": string;
346
+ "--color-chart-6": string;
347
+ "--color-syntax-keyword": string;
348
+ "--color-syntax-string": string;
349
+ "--color-syntax-number": string;
350
+ "--color-syntax-comment": string;
351
+ "--color-syntax-function": string;
352
+ "--color-syntax-type": string;
353
+ };
354
+ };
355
+ 'neutral-dark': {
356
+ format: string;
357
+ version: number;
358
+ name: string;
359
+ kind: string;
360
+ colors: {
361
+ "--color-bg": string;
362
+ "--color-bg-side": string;
363
+ "--color-bg-rail": string;
364
+ "--color-surface-raised": string;
365
+ "--color-fill-1": string;
366
+ "--color-fill-2": string;
367
+ "--color-fill-3": string;
368
+ "--color-border": string;
369
+ "--color-border-control": string;
370
+ "--color-text": string;
371
+ "--color-text-2": string;
372
+ "--color-text-3": string;
373
+ "--color-text-disabled": string;
374
+ "--color-accent": string;
375
+ "--color-accent-hover": string;
376
+ "--color-on-accent": string;
377
+ "--color-accent-text": string;
378
+ "--color-accent-subtle": string;
379
+ "--color-focus": string;
380
+ "--color-mark": string;
381
+ "--color-danger": string;
382
+ "--color-danger-hover": string;
383
+ "--color-danger-text": string;
384
+ "--color-danger-subtle": string;
385
+ "--color-warning-text": string;
386
+ "--color-warning-subtle": string;
387
+ "--color-success-text": string;
388
+ "--color-success-subtle": string;
389
+ "--color-scrim": string;
390
+ "--color-shadow": string;
391
+ "--color-chart-1": string;
392
+ "--color-chart-2": string;
393
+ "--color-chart-3": string;
394
+ "--color-chart-4": string;
395
+ "--color-chart-5": string;
396
+ "--color-chart-6": string;
397
+ "--color-syntax-keyword": string;
398
+ "--color-syntax-string": string;
399
+ "--color-syntax-number": string;
400
+ "--color-syntax-comment": string;
401
+ "--color-syntax-function": string;
402
+ "--color-syntax-type": string;
403
+ };
404
+ };
405
+ 'neutral-light': {
406
+ format: string;
407
+ version: number;
408
+ name: string;
409
+ kind: string;
410
+ colors: {
411
+ "--color-bg": string;
412
+ "--color-bg-side": string;
413
+ "--color-bg-rail": string;
414
+ "--color-surface-raised": string;
415
+ "--color-fill-1": string;
416
+ "--color-fill-2": string;
417
+ "--color-fill-3": string;
418
+ "--color-border": string;
419
+ "--color-border-control": string;
420
+ "--color-text": string;
421
+ "--color-text-2": string;
422
+ "--color-text-3": string;
423
+ "--color-text-disabled": string;
424
+ "--color-accent": string;
425
+ "--color-accent-hover": string;
426
+ "--color-on-accent": string;
427
+ "--color-accent-text": string;
428
+ "--color-accent-subtle": string;
429
+ "--color-focus": string;
430
+ "--color-mark": string;
431
+ "--color-danger": string;
432
+ "--color-danger-hover": string;
433
+ "--color-danger-text": string;
434
+ "--color-danger-subtle": string;
435
+ "--color-warning-text": string;
436
+ "--color-warning-subtle": string;
437
+ "--color-success-text": string;
438
+ "--color-success-subtle": string;
439
+ "--color-scrim": string;
440
+ "--color-shadow": string;
441
+ "--color-chart-1": string;
442
+ "--color-chart-2": string;
443
+ "--color-chart-3": string;
444
+ "--color-chart-4": string;
445
+ "--color-chart-5": string;
446
+ "--color-chart-6": string;
447
+ "--color-syntax-keyword": string;
448
+ "--color-syntax-string": string;
449
+ "--color-syntax-number": string;
450
+ "--color-syntax-comment": string;
451
+ "--color-syntax-function": string;
452
+ "--color-syntax-type": string;
453
+ };
454
+ };
455
+ };
456
+ export type BuiltinThemeId = keyof typeof BUILTIN_THEMES;
457
+ /** 跟随系统时默认的深色与浅色主题,也是补齐缺失令牌的来源 */
458
+ export declare const DEFAULT_THEMES: Readonly<Record<ThemeKind, BuiltinThemeId>>;
459
+ /** 校验一份主题文件(已按 JSON 解析):不合格式的列出全部原因 */
460
+ export declare function parseTheme(value: unknown): ThemeParseResult;
461
+ export interface ContrastIssue {
462
+ pair: string;
463
+ /** 算出的对比度,保留两位小数 */
464
+ ratio: number;
465
+ minimum: number;
466
+ }
467
+ /** 按 WCAG 2 的对比度公式检查主题,列出不达标的组合;没有不达标的回空数组 */
468
+ export declare function themeContrastIssues(theme: Theme): ContrastIssue[];
469
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAsBA,eAAe;AACf,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAC/C,qCAAqC;AACrC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAKpC;;;GAGG;AACH,eAAO,MAAM,YAAY,m4BAyEf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;A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