dsh-theme-escook 1.0.4 → 1.0.5

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.
@@ -27,339 +27,280 @@ var client_exports = {};
27
27
  __export(client_exports, {
28
28
  THEME_SCHEMES: () => THEME_SCHEMES,
29
29
  apply: () => apply,
30
- default: () => activate
30
+ default: () => activate,
31
+ inject: () => inject
31
32
  });
32
33
  module.exports = __toCommonJS(client_exports);
33
- var THEME_SCHEMES = {
34
- "dark": {
35
- name: "escook Dark (\u7ECF\u5178\u6697\u9ED1 \xB7 \u6807\u5FD7\u6696\u9633\u6A59)",
36
- desc: "VS Code \u5F6C\u54E5\u7ECF\u5178\u6696\u8C03\u6781\u5BA2\u6DF1\u7070\u642D\u914D\u6807\u5FD7\u6696\u9633\u6A59\uFF0C\u6B63\u7EDF\u8010\u770B\u957F\u6548\u62A4\u773C",
34
+
35
+ // client/palette.js
36
+ var PALETTES = {
37
+ dark: {
38
+ name: "\u7ECF\u5178\u6697\u9ED1",
37
39
  type: "dark",
38
- colorPreview: "#ef820c",
39
- bgPreview: "#252526",
40
- css: `
41
- :root, html, body, body[data-ds-dark-theme], [data-theme="escook-dark"] {
42
- --dsw-alias-bg-base: #252526 !important;
43
- --dsw-alias-bg-layer-1: #202021 !important;
44
- --dsw-alias-bg-layer-2: #29292c !important;
45
- --dsw-alias-bg-layer-3: #2d2d30 !important;
46
- --dsw-alias-bg-module-platform: #2d2d30 !important;
47
- --dsw-alias-bg-multi-select: #2d2d30 !important;
48
- --dsw-alias-bg-overlay: #333333 !important;
49
- --dsw-specific-selector: #2d2d30 !important;
50
- --dsw-alias-bg-mask-1: rgba(18, 18, 20, 0.75) !important;
51
- --dsw-specific-sidebar-fill: #202021 !important;
52
- --dsw-specific-sidebar-nav-item-hover: rgba(239, 130, 12, 0.1) !important;
53
- --dsw-specific-sidebar-nav-item-active: rgba(239, 130, 12, 0.2) !important;
54
- --dsw-specific-sidebar-nav-item-active-accent: #ef820c !important;
55
- --dsw-specific-input-major: #29292c !important;
56
- --dsw-specific-bubble: #29292c !important;
57
- --dsw-specific-menu: #202021 !important;
58
- --dsw-hovercard-bg: #29292c !important;
59
- --dsw-alias-tooltip-bg: #1c1c1d !important;
60
- --dsw-alias-button-elevated-fill: #2f2f33 !important;
61
- --dsw-alias-button-floating-hover: #38383c !important;
62
- --dsw-alias-brand-primary: #ef820c !important;
63
- --dsw-alias-button-primary-fill: #ef820c !important;
64
- --dsw-alias-button-primary-hover: #ff9940 !important;
65
- --dsw-alias-label-primary-foreground: #ffffff !important;
66
- --dsw-alias-label-primary: #fafafa !important;
67
- --dsw-alias-label-secondary: #cccccc !important;
68
- --dsw-alias-label-tertiary: #888888 !important;
69
- --dsw-alias-label-dimmed: #555555 !important;
70
- --dsw-alias-label-caption: #888888 !important;
71
- --dsw-alias-interactive-bg-hover: rgba(239, 130, 12, 0.1) !important;
72
- --dsw-alias-interactive-bg-active: rgba(239, 130, 12, 0.2) !important;
73
- --dsw-alias-border-l1: #333333 !important;
74
- --dsw-alias-border-l2: #2a2a2a !important;
75
- --dsw-alias-border-l3: #3e3e3e !important;
76
- --dsw-alias-border-l4: #555555 !important;
77
- --dsw-alias-markdown-code-block: #1c1c1d !important;
78
- --dsw-alias-markdown-code-block-banner: #252526 !important;
79
- --dsw-alias-scrollbar-bg-l2: #333333 !important;
80
- --dsw-alias-scrollbar-hover-l2: #ef820c !important;
81
- }
82
- body, body[data-ds-dark-theme] { background-color: #252526 !important; color: #fafafa !important; }
83
- pre, code, [class*="codeBlock"] {
84
- background-color: #1c1c1d !important;
85
- color: #fafafa !important;
86
- border-color: #333333 !important;
87
- }
88
- [class*="selector"], [class*="themeCube"] {
89
- color: #fafafa !important;
90
- background-color: #2d2d30 !important;
91
- }
92
- [class*="selected"], [class*="themeCube"]:hover {
93
- border-color: #ef820c !important;
94
- }
95
- `
40
+ bg: "#252526",
41
+ sidebar: "#202021",
42
+ surface: "#29292c",
43
+ layer: "#2d2d30",
44
+ hover: "#363638",
45
+ selected: "#403628",
46
+ accent: "#ef820c",
47
+ accentHover: "#ff9940",
48
+ brand: "#ef820c",
49
+ foreground: "#202021",
50
+ text: "#fafafa",
51
+ secondary: "#cccccc",
52
+ muted: "#b6b6bd",
53
+ border: "#606065",
54
+ code: "#1c1c1d"
96
55
  },
97
56
  "dark-soft": {
98
- name: "escook Dark Soft (\u67D4\u548C\u6697\u9ED1 \xB7 \u67D4\u5149\u5976\u674F\u9EC4)",
99
- desc: "Ayu \u7ECF\u5178\u6DF1\u6D77\u84DD\u7070\u5E95\u8272\u642D\u914D\u6E29\u6DA6\u5976\u674F\u9EC4\uFF0C\u7EC6\u817B\u67D4\u548C\u957F\u6548\u9632\u75B2\u52B3",
57
+ name: "\u67D4\u548C\u6697\u9ED1",
100
58
  type: "dark",
101
- colorPreview: "#ffcc66",
102
- bgPreview: "#1f2430",
103
- css: `
104
- :root, html, body, body[data-ds-dark-theme], [data-theme="escook-dark-soft"] {
105
- --dsw-alias-bg-base: #1f2430 !important;
106
- --dsw-alias-bg-layer-1: #191e28 !important;
107
- --dsw-alias-bg-layer-2: #232834 !important;
108
- --dsw-alias-bg-layer-3: #262c3b !important;
109
- --dsw-alias-bg-module-platform: #262c3b !important;
110
- --dsw-alias-bg-multi-select: #262c3b !important;
111
- --dsw-alias-bg-overlay: #333a4c !important;
112
- --dsw-specific-selector: #262c3b !important;
113
- --dsw-alias-bg-mask-1: rgba(16, 20, 28, 0.7) !important;
114
- --dsw-specific-sidebar-fill: #191e28 !important;
115
- --dsw-specific-sidebar-nav-item-hover: rgba(255, 204, 102, 0.1) !important;
116
- --dsw-specific-sidebar-nav-item-active: rgba(255, 204, 102, 0.18) !important;
117
- --dsw-specific-sidebar-nav-item-active-accent: #ffcc66 !important;
118
- --dsw-specific-input-major: #232834 !important;
119
- --dsw-specific-bubble: #232834 !important;
120
- --dsw-specific-menu: #191e28 !important;
121
- --dsw-hovercard-bg: #191e28 !important;
122
- --dsw-alias-tooltip-bg: #171b24 !important;
123
- --dsw-alias-button-elevated-fill: #2b3140 !important;
124
- --dsw-alias-button-floating-hover: #333a4c !important;
125
- --dsw-alias-brand-primary: #ffcc66 !important;
126
- --dsw-alias-button-primary-fill: #ffcc66 !important;
127
- --dsw-alias-button-primary-hover: #ffd580 !important;
128
- --dsw-alias-label-primary-foreground: #1f2430 !important;
129
- --dsw-alias-label-primary: #cbccc6 !important;
130
- --dsw-alias-label-secondary: #969aa4 !important;
131
- --dsw-alias-label-tertiary: #707a8c !important;
132
- --dsw-alias-label-dimmed: #515764 !important;
133
- --dsw-alias-label-caption: #707a8c !important;
134
- --dsw-alias-interactive-bg-hover: rgba(255, 204, 102, 0.1) !important;
135
- --dsw-alias-interactive-bg-active: rgba(255, 204, 102, 0.18) !important;
136
- --dsw-alias-border-l1: #373e4c !important;
137
- --dsw-alias-border-l2: #2d3340 !important;
138
- --dsw-alias-border-l3: #444c5e !important;
139
- --dsw-alias-border-l4: #515764 !important;
140
- --dsw-alias-markdown-code-block: #171b24 !important;
141
- --dsw-alias-markdown-code-block-banner: #1f2430 !important;
142
- --dsw-alias-scrollbar-bg-l2: #373e4c !important;
143
- --dsw-alias-scrollbar-hover-l2: #ffcc66 !important;
144
- }
145
- body, body[data-ds-dark-theme] { background-color: #1f2430 !important; color: #cbccc6 !important; }
146
- pre, code, [class*="codeBlock"] {
147
- background-color: #171b24 !important;
148
- color: #cbccc6 !important;
149
- border-color: #373e4c !important;
150
- }
151
- [class*="selector"], [class*="themeCube"] {
152
- color: #cbccc6 !important;
153
- background-color: #262c3b !important;
154
- }
155
- [class*="selected"], [class*="themeCube"]:hover {
156
- border-color: #ffcc66 !important;
157
- }
158
- `
59
+ bg: "#1f2430",
60
+ sidebar: "#191e28",
61
+ surface: "#232834",
62
+ layer: "#262c3b",
63
+ hover: "#333a4c",
64
+ selected: "#41404a",
65
+ accent: "#ffcc66",
66
+ accentHover: "#ffd580",
67
+ brand: "#ffcc66",
68
+ foreground: "#1f2430",
69
+ text: "#eceee9",
70
+ secondary: "#c1c5cf",
71
+ muted: "#b6bcc9",
72
+ border: "#68738a",
73
+ code: "#171b24"
159
74
  },
160
- "light": {
161
- name: "escook Light (\u7ECF\u5178\u6D45\u8272 \xB7 \u5178\u96C5\u7D2B\u7F57\u5170)",
162
- desc: "Solarized \u7ECF\u5178\u62A4\u773C\u6696\u7C73\u767D\u642D\u914D\u5178\u96C5\u7D2B\u7F57\u5170\u4E0E\u9752\u58A8\u6587\u672C\uFF0C\u6E29\u6DA6\u7EB8\u8D28\u4E66\u5377\u611F",
75
+ light: {
76
+ name: "\u7ECF\u5178\u6D45\u8272",
163
77
  type: "light",
164
- colorPreview: "#705697",
165
- bgPreview: "#fdf6e3",
166
- css: `
167
- :root, html, body, body[data-ds-dark-theme], [data-theme="escook-light"] {
168
- --dsw-alias-bg-base: #fdf6e3 !important;
169
- --dsw-alias-bg-layer-1: #f8f0d8 !important;
170
- --dsw-alias-bg-layer-2: #ffffff !important;
171
- --dsw-alias-bg-layer-3: #eee8d5 !important;
172
- --dsw-alias-bg-module-platform: #eee8d5 !important;
173
- --dsw-alias-bg-multi-select: #eee8d5 !important;
174
- --dsw-alias-bg-overlay: #e3dac6 !important;
175
- --dsw-specific-selector: #eee8d5 !important;
176
- --dsw-alias-bg-mask-1: rgba(50, 40, 60, 0.25) !important;
177
- --dsw-specific-sidebar-fill: #f8f0d8 !important;
178
- --dsw-specific-sidebar-nav-item-hover: rgba(112, 86, 151, 0.08) !important;
179
- --dsw-specific-sidebar-nav-item-active: rgba(112, 86, 151, 0.16) !important;
180
- --dsw-specific-sidebar-nav-item-active-accent: #705697 !important;
181
- --dsw-specific-input-major: #ffffff !important;
182
- --dsw-specific-bubble: #ffffff !important;
183
- --dsw-specific-menu: #ffffff !important;
184
- --dsw-hovercard-bg: #ffffff !important;
185
- --dsw-alias-tooltip-bg: #2b2638 !important;
186
- --dsw-alias-button-elevated-fill: #f4ecce !important;
187
- --dsw-alias-button-floating-hover: #ece2c4 !important;
188
- --dsw-alias-brand-primary: #705697 !important;
189
- --dsw-alias-button-primary-fill: #705697 !important;
190
- --dsw-alias-button-primary-hover: #876cad !important;
191
- --dsw-alias-label-primary-foreground: #ffffff !important;
192
- --dsw-alias-label-primary: #586e75 !important;
193
- --dsw-alias-label-secondary: #657b83 !important;
194
- --dsw-alias-label-tertiary: #93a1a1 !important;
195
- --dsw-alias-label-dimmed: #b58900 !important;
196
- --dsw-alias-label-caption: #93a1a1 !important;
197
- --dsw-alias-interactive-bg-hover: rgba(112, 86, 151, 0.08) !important;
198
- --dsw-alias-interactive-bg-active: rgba(112, 86, 151, 0.15) !important;
199
- --dsw-alias-border-l1: #e3dac6 !important;
200
- --dsw-alias-border-l2: #ece3cf !important;
201
- --dsw-alias-border-l3: #d8ceb8 !important;
202
- --dsw-alias-border-l4: #b58900 !important;
203
- --dsw-alias-markdown-code-block: #f5eed8 !important;
204
- --dsw-alias-markdown-code-block-banner: #ebe4cc !important;
205
- --dsw-alias-scrollbar-bg-l2: #e3dac6 !important;
206
- --dsw-alias-scrollbar-hover-l2: #705697 !important;
207
- }
208
- body, body[data-ds-dark-theme] { background-color: #fdf6e3 !important; color: #586e75 !important; }
209
- pre, code, [class*="codeBlock"] {
210
- background-color: #f5eed8 !important;
211
- color: #586e75 !important;
212
- border-color: #e3dac6 !important;
213
- }
214
- [class*="selector"], [class*="themeCube"] {
215
- color: #586e75 !important;
216
- background-color: #eee8d5 !important;
217
- }
218
- [class*="selected"], [class*="themeCube"]:hover {
219
- border-color: #705697 !important;
220
- }
221
- `
78
+ bg: "#fdf6e3",
79
+ sidebar: "#f8f0d8",
80
+ surface: "#ffffff",
81
+ layer: "#eee8d5",
82
+ hover: "#e9e2d2",
83
+ selected: "#e1d8cc",
84
+ accent: "#705697",
85
+ accentHover: "#654c89",
86
+ brand: "#705697",
87
+ foreground: "#ffffff",
88
+ text: "#35484f",
89
+ secondary: "#465a61",
90
+ muted: "#4c5e66",
91
+ border: "#8b8173",
92
+ code: "#f5eed8"
222
93
  },
223
94
  "light-soft": {
224
- name: "escook Light Soft (\u67D4\u548C\u6D45\u8272 \xB7 \u6D3B\u529B\u67D4\u548C\u6A59)",
225
- desc: "\u73B0\u4EE3\u6781\u7B80\u6E05\u900F\u6D45\u7070\u642D\u914D\u67D4\u548C\u6D3B\u529B\u6A59\uFF0C\u660E\u4EAE\u6E05\u723D\u4E0D\u523A\u773C",
95
+ name: "\u67D4\u548C\u6D45\u8272",
226
96
  type: "light",
227
- colorPreview: "#ff9940",
228
- bgPreview: "#fafafa",
229
- css: `
230
- :root, html, body, body[data-ds-dark-theme], [data-theme="escook-light-soft"] {
231
- --dsw-alias-bg-base: #fafafa !important;
232
- --dsw-alias-bg-layer-1: #f2f2f2 !important;
233
- --dsw-alias-bg-layer-2: #ffffff !important;
234
- --dsw-alias-bg-layer-3: #e8e8e8 !important;
235
- --dsw-alias-bg-module-platform: #e8e8e8 !important;
236
- --dsw-alias-bg-multi-select: #e8e8e8 !important;
237
- --dsw-alias-bg-overlay: #dcdcdc !important;
238
- --dsw-specific-selector: #e8e8e8 !important;
239
- --dsw-alias-bg-mask-1: rgba(0, 0, 0, 0.2) !important;
240
- --dsw-specific-sidebar-fill: #f2f2f2 !important;
241
- --dsw-specific-sidebar-nav-item-hover: rgba(255, 153, 64, 0.08) !important;
242
- --dsw-specific-sidebar-nav-item-active: rgba(255, 153, 64, 0.16) !important;
243
- --dsw-specific-sidebar-nav-item-active-accent: #ff9940 !important;
244
- --dsw-specific-input-major: #ffffff !important;
245
- --dsw-specific-bubble: #ffffff !important;
246
- --dsw-specific-menu: #ffffff !important;
247
- --dsw-hovercard-bg: #ffffff !important;
248
- --dsw-alias-tooltip-bg: #2d3748 !important;
249
- --dsw-alias-button-elevated-fill: #eaeaea !important;
250
- --dsw-alias-button-floating-hover: #e0e0e0 !important;
251
- --dsw-alias-brand-primary: #ff9940 !important;
252
- --dsw-alias-button-primary-fill: #ff9940 !important;
253
- --dsw-alias-button-primary-hover: #f58220 !important;
254
- --dsw-alias-label-primary-foreground: #ffffff !important;
255
- --dsw-alias-label-primary: #2d3748 !important;
256
- --dsw-alias-label-secondary: #4a5568 !important;
257
- --dsw-alias-label-tertiary: #718096 !important;
258
- --dsw-alias-label-dimmed: #a0aec0 !important;
259
- --dsw-alias-label-caption: #718096 !important;
260
- --dsw-alias-interactive-bg-hover: rgba(255, 153, 64, 0.08) !important;
261
- --dsw-alias-interactive-bg-active: rgba(255, 153, 64, 0.15) !important;
262
- --dsw-alias-border-l1: #dcdcdc !important;
263
- --dsw-alias-border-l2: #e8e8e8 !important;
264
- --dsw-alias-border-l3: #d0d0d0 !important;
265
- --dsw-alias-border-l4: #a0aec0 !important;
266
- --dsw-alias-markdown-code-block: #f0f2f5 !important;
267
- --dsw-alias-markdown-code-block-banner: #e6e9ee !important;
268
- --dsw-alias-scrollbar-bg-l2: #dcdcdc !important;
269
- --dsw-alias-scrollbar-hover-l2: #ff9940 !important;
270
- }
271
- body, body[data-ds-dark-theme] { background-color: #fafafa !important; color: #2d3748 !important; }
272
- pre, code, [class*="codeBlock"] {
273
- background-color: #f0f2f5 !important;
274
- color: #2d3748 !important;
275
- border-color: #dcdcdc !important;
276
- }
277
- [class*="selector"], [class*="themeCube"] {
278
- color: #2d3748 !important;
279
- background-color: #e8e8e8 !important;
280
- }
281
- [class*="selected"], [class*="themeCube"]:hover {
282
- border-color: #ff9940 !important;
283
- }
284
- `
97
+ bg: "#fafafa",
98
+ sidebar: "#f2f2f2",
99
+ surface: "#ffffff",
100
+ layer: "#e8e8e8",
101
+ hover: "#e4e4e4",
102
+ selected: "#f1dfca",
103
+ accent: "#ff9940",
104
+ accentHover: "#f58220",
105
+ brand: "#934400",
106
+ foreground: "#222936",
107
+ text: "#2d3748",
108
+ secondary: "#4a5568",
109
+ muted: "#505d70",
110
+ border: "#838b96",
111
+ code: "#f0f2f5"
285
112
  }
286
113
  };
287
- function activate(context) {
288
- if (typeof window !== "undefined" && window.__DSH_BUILTIN_THEMES__) {
289
- console.info("\u{1F338} [dsh-theme-escook] \u68C0\u6D4B\u5230\u5F53\u524D\u5904\u4E8E DSH Desktop \u684C\u9762\u7AEF\uFF0C\u6B63\u5728\u5C06\u63D2\u4EF6\u6700\u65B0\u4E3B\u9898\u77E9\u9635\u70ED\u540C\u6B65\u81F3\u5BA2\u6237\u7AEF...");
290
- const builtin = window.__DSH_BUILTIN_THEMES__;
291
- if (typeof builtin.registerThemes === "function") {
292
- builtin.registerThemes(THEME_SCHEMES);
293
- }
294
- const themeController2 = {
295
- schemes: Object.keys(THEME_SCHEMES),
296
- setScheme(key) {
297
- builtin.apply(key);
298
- },
299
- getCurrentScheme() {
300
- return builtin.getCurrent();
301
- },
302
- dispose() {
303
- if (window.__ESCOOK_THEME__ === themeController2) {
304
- delete window.__ESCOOK_THEME__;
305
- }
306
- }
307
- };
308
- window.__ESCOOK_THEME__ = themeController2;
309
- return themeController2;
310
- }
311
- const styleId = "dsh-theme-escook-styles";
312
- const storageKey = "dsh_theme_escook_scheme";
313
- let styleEl = document.getElementById(styleId);
314
- function applyScheme(key) {
315
- const validKey = THEME_SCHEMES[key] ? key : "dark-soft";
316
- const scheme = THEME_SCHEMES[validKey];
317
- if (!styleEl) {
318
- styleEl = document.createElement("style");
319
- styleEl.id = styleId;
320
- document.head.appendChild(styleEl);
114
+ function tokens(p) {
115
+ return {
116
+ "--dsw-alias-bg-base": p.bg,
117
+ "--dsw-alias-bg-layer-1": p.sidebar,
118
+ "--dsw-alias-bg-layer-2": p.surface,
119
+ "--dsw-alias-bg-layer-3": p.layer,
120
+ "--dsw-alias-bg-module-platform": p.layer,
121
+ "--dsw-alias-bg-multi-select": p.selected,
122
+ "--dsw-alias-bg-overlay": p.surface,
123
+ "--dsw-specific-selector": p.layer,
124
+ "--dsw-specific-sidebar-fill": p.sidebar,
125
+ "--dsw-specific-sidebar-nav-item-hover": p.hover,
126
+ "--dsw-specific-sidebar-nav-item-active": p.selected,
127
+ "--dsw-specific-sidebar-nav-item-active-accent": p.brand,
128
+ "--dsw-specific-input-major": p.surface,
129
+ "--dsw-specific-login-input": p.surface,
130
+ "--dsw-specific-bubble": p.surface,
131
+ "--dsw-specific-menu": p.surface,
132
+ "--dsw-menu-surface-fill": p.surface,
133
+ "--dsw-alias-menu-group-header-fill": p.surface,
134
+ "--dsw-alias-menu-icon": p.text,
135
+ "--dsw-hovercard-bg": p.surface,
136
+ "--dsw-alias-tooltip-bg": "#222936",
137
+ "--escook-tooltip-text": "#ffffff",
138
+ "--dsw-alias-button-elevated-fill": p.surface,
139
+ "--dsw-alias-button-floating-fill": p.surface,
140
+ "--dsw-alias-button-floating-hover": p.hover,
141
+ "--dsw-alias-button-ghost-active-fill": p.selected,
142
+ "--dsw-alias-button-ghost-active-hover": p.hover,
143
+ "--dsw-alias-button-ghost-active-border": p.border,
144
+ "--dsw-alias-brand-primary": p.brand,
145
+ "--dsw-alias-link": p.brand,
146
+ "--dsw-alias-button-primary-fill": p.accent,
147
+ "--dsw-alias-button-primary-hover": p.accentHover,
148
+ "--dsw-alias-label-primary-foreground": p.foreground,
149
+ "--dsw-alias-label-primary": p.text,
150
+ "--dsw-alias-label-primary-dimmed": p.secondary,
151
+ "--dsw-alias-label-primary-bluish": p.text,
152
+ "--dsw-alias-label-document-preview": p.secondary,
153
+ "--dsw-alias-label-secondary": p.secondary,
154
+ "--dsw-alias-label-tertiary": p.muted,
155
+ "--dsw-alias-label-dimmed": p.muted,
156
+ "--dsw-alias-label-caption": p.muted,
157
+ "--dsw-alias-interactive-bg-hover": p.hover,
158
+ "--dsw-alias-interactive-bg-active": p.selected,
159
+ "--dsw-alias-border-l1": p.border,
160
+ "--dsw-alias-border-l2": p.border,
161
+ "--dsw-alias-border-l3": p.border,
162
+ "--dsw-alias-border-l4": p.border,
163
+ "--dsw-alias-markdown-code-block": p.code,
164
+ "--dsw-alias-markdown-code-block-banner": p.layer,
165
+ "--dsw-alias-scrollbar-bg-l2": p.border,
166
+ "--dsw-alias-scrollbar-hover-l2": p.brand
167
+ };
168
+ }
169
+ var THEME_SCHEMES = Object.fromEntries(Object.entries(PALETTES).map(([key, palette]) => [key, {
170
+ id: `escook-${key}`,
171
+ name: palette.name,
172
+ type: palette.type,
173
+ colorPreview: palette.accent,
174
+ bgPreview: palette.bg,
175
+ tokens: tokens(palette)
176
+ }]));
177
+
178
+ // client/theme-settings.js
179
+ var import_react = require("react");
180
+ function ThemeSettings({ controller }) {
181
+ const selected = (0, import_react.useSyncExternalStore)(controller.subscribe, controller.getCurrentScheme, controller.getCurrentScheme);
182
+ const options = [...Object.entries(THEME_SCHEMES), ["application", { name: "\u8DDF\u968F\u5E94\u7528" }]];
183
+ return (0, import_react.createElement)(
184
+ "section",
185
+ { className: "escook-settings", "aria-label": "Escook \u4E3B\u9898" },
186
+ (0, import_react.createElement)("h3", null, "Escook \u4E3B\u9898"),
187
+ (0, import_react.createElement)("p", null, "\u9009\u62E9\u914D\u8272\u540E\u7ACB\u5373\u751F\u6548\u3002\u9009\u62E9\u201C\u8DDF\u968F\u5E94\u7528\u201D\u540E\uFF0C\u53EF\u4F7F\u7528\u4E0A\u65B9\u7684\u5E94\u7528\u5916\u89C2\u8BBE\u7F6E\u3002"),
188
+ (0, import_react.createElement)(
189
+ "div",
190
+ { className: "escook-settings-options", role: "group", "aria-label": "\u4E3B\u9898\u914D\u8272" },
191
+ options.map(([key, scheme]) => (0, import_react.createElement)("button", {
192
+ key,
193
+ type: "button",
194
+ "data-escook-scheme": key,
195
+ "aria-pressed": selected === key,
196
+ onClick: () => controller.setScheme(key)
197
+ }, scheme.bgPreview && (0, import_react.createElement)("span", {
198
+ className: "escook-settings-preview",
199
+ "aria-hidden": true,
200
+ style: { background: scheme.bgPreview, borderColor: scheme.colorPreview }
201
+ }, (0, import_react.createElement)("span", { style: { background: scheme.colorPreview } })), scheme.name))
202
+ )
203
+ );
204
+ }
205
+ var SETTINGS_CSS = `
206
+ .escook-settings{padding:16px 0;border-bottom:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}
207
+ .escook-settings h3{font-size:14px;font-weight:500;margin:0 0 8px}
208
+ .escook-settings p{font-size:13px;color:var(--dsw-alias-label-secondary);margin:0 0 12px;line-height:1.6}
209
+ .escook-settings-options{display:flex;flex-wrap:wrap;gap:8px}
210
+ .escook-settings-options button{display:flex;align-items:center;gap:8px;min-height:44px;padding:10px 14px;font:inherit;font-size:14px;border:1px solid var(--dsw-alias-border-l4);border-radius:10px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);cursor:pointer}
211
+ .escook-settings-options button:hover{background:var(--dsw-alias-interactive-bg-hover)}
212
+ .escook-settings-options button[aria-pressed="true"]{background:var(--dsw-alias-interactive-bg-active);border-color:var(--dsw-alias-brand-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary)}
213
+ .escook-settings-options button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}
214
+ .escook-settings-preview{display:inline-flex;justify-content:center;align-items:center;width:24px;height:24px;border:2px solid;border-radius:6px}
215
+ .escook-settings-preview span{width:10px;height:10px;border-radius:50%}
216
+ `;
217
+
218
+ // client/client.js
219
+ var inject = ["theme", "slots"];
220
+ var STORAGE_KEY = "dsh_theme_escook_scheme";
221
+ function activate(ctx) {
222
+ const cleanups = [];
223
+ const listeners = /* @__PURE__ */ new Set();
224
+ const previousPreference = ctx.theme.getTheme().preference;
225
+ let disposed = false;
226
+ const read = () => {
227
+ try {
228
+ return localStorage.getItem(STORAGE_KEY) || localStorage.getItem("dsh_selected_theme");
229
+ } catch {
230
+ return null;
321
231
  }
322
- styleEl.textContent = scheme.css;
323
- document.documentElement.setAttribute("data-dsh-theme", `escook-${validKey}`);
232
+ };
233
+ const save = (key) => {
324
234
  try {
325
- localStorage.setItem(storageKey, validKey);
326
- } catch (e) {
235
+ localStorage.setItem(STORAGE_KEY, key);
236
+ } catch {
327
237
  }
328
- console.info(`\u{1F338} [dsh-theme-escook] \u5F53\u524D\u6FC0\u6D3B\u914D\u8272: ${scheme.name}`);
329
- }
330
- let savedScheme = "dark-soft";
331
- try {
332
- savedScheme = localStorage.getItem(storageKey) || localStorage.getItem("dsh_selected_theme") || "dark-soft";
333
- } catch (e) {
334
- }
335
- applyScheme(savedScheme);
336
- const themeController = {
238
+ };
239
+ const current = () => Object.keys(THEME_SCHEMES).find((key) => THEME_SCHEMES[key].id === ctx.theme.getTheme().preference) || "application";
240
+ const controller = {
337
241
  schemes: Object.keys(THEME_SCHEMES),
338
- setScheme(key) {
339
- applyScheme(key);
242
+ subscribe(listener) {
243
+ listeners.add(listener);
244
+ return () => listeners.delete(listener);
340
245
  },
341
- getCurrentScheme() {
342
- try {
343
- return localStorage.getItem(storageKey) || "dark-soft";
344
- } catch (e) {
345
- return "dark-soft";
346
- }
246
+ getCurrentScheme: current,
247
+ setScheme(key) {
248
+ if (disposed) return;
249
+ if (key !== "application" && !THEME_SCHEMES[key]) throw new Error(`\u672A\u77E5 Escook \u4E3B\u9898\uFF1A${key}`);
250
+ ctx.theme.setTheme(key === "application" ? "system" : THEME_SCHEMES[key].id);
251
+ save(key);
347
252
  },
348
253
  dispose() {
349
- if (styleEl && styleEl.parentNode) {
350
- styleEl.parentNode.removeChild(styleEl);
351
- }
352
- document.documentElement.removeAttribute("data-dsh-theme");
353
- if (window.__ESCOOK_THEME__ === themeController) {
354
- delete window.__ESCOOK_THEME__;
355
- }
254
+ if (disposed) return;
255
+ disposed = true;
256
+ for (const cleanup of cleanups.reverse()) cleanup();
257
+ listeners.clear();
258
+ if (window.__ESCOOK_THEME__ === controller) delete window.__ESCOOK_THEME__;
356
259
  }
357
260
  };
358
- window.__ESCOOK_THEME__ = themeController;
359
- return themeController;
261
+ try {
262
+ for (const scheme of Object.values(THEME_SCHEMES)) {
263
+ cleanups.push(ctx.theme.register({ id: scheme.id, colorScheme: scheme.type, tokens: scheme.tokens }));
264
+ }
265
+ cleanups.push(() => {
266
+ if (current() !== "application") {
267
+ const available = ctx.theme.getTheme().themes?.some((theme) => theme.id === previousPreference);
268
+ ctx.theme.setTheme(available || previousPreference === "system" ? previousPreference : "system");
269
+ }
270
+ });
271
+ const style = document.createElement("style");
272
+ style.id = "dsh-theme-escook-settings";
273
+ style.textContent = SETTINGS_CSS;
274
+ document.head.appendChild(style);
275
+ cleanups.push(() => style.parentNode?.removeChild(style));
276
+ const saved = read();
277
+ if (saved !== "application") controller.setScheme(THEME_SCHEMES[saved] ? saved : "dark-soft");
278
+ let previousSnapshot = ctx.theme.getTheme();
279
+ cleanups.push(ctx.on("theme/change", (snapshot) => {
280
+ const previous = previousSnapshot;
281
+ previousSnapshot = snapshot;
282
+ if (Object.values(THEME_SCHEMES).some((scheme) => scheme.id === previous.preference) && snapshot.fontSize !== previous.fontSize && snapshot.preference !== previous.preference) {
283
+ ctx.theme.setTheme(previous.preference);
284
+ return;
285
+ }
286
+ save(current());
287
+ for (const listener of listeners) listener();
288
+ }));
289
+ cleanups.push(ctx.slots.inject("settings.general.item", () => ctx.slots.register({
290
+ name: "settings.general.item",
291
+ id: "dsh-theme-escook",
292
+ order: 12,
293
+ inject: () => ({ controller })
294
+ }, ThemeSettings)));
295
+ window.__ESCOOK_THEME__ = controller;
296
+ return controller;
297
+ } catch (error) {
298
+ controller.dispose();
299
+ throw error;
300
+ }
360
301
  }
361
- var apply = (context) => {
362
- const controller = activate(context);
302
+ var apply = (ctx) => {
303
+ const controller = activate(ctx);
363
304
  return () => controller.dispose();
364
305
  };
365
306