@filipgutica/ui 0.3.0 → 1.0.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.
package/dist/open-vsx.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ThemeValidationError as e, parseVsCodeTheme as t } from "./theme.js";
1
+ import { i as e, t } from "./theme-CIwueiir.js";
2
2
  import { parse as n } from "jsonc-parser";
3
3
  import { createHash as r } from "node:crypto";
4
4
  import i from "jszip";
@@ -237,18 +237,18 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
237
237
  }), "The packaged extension manifest");
238
238
  if ((typeof i.publisher == "string" && typeof i.name == "string" ? `${i.publisher}.${i.name}` : "").toLowerCase() !== n.toLowerCase() || i.version !== r) throw new y("integrity-failed", "The downloaded package does not match the selected Open VSX theme.");
239
239
  return i;
240
- }, G = async ({ zip: e, sizes: n, manifest: r, fallbackName: i }) => {
240
+ }, G = async ({ zip: t, sizes: n, manifest: r, fallbackName: i }) => {
241
241
  let a = w(r);
242
242
  if (a.length === 0 || a.length > g) throw new y("unsupported-extension", "That extension has no compatible color themes.");
243
243
  let o = [];
244
244
  for (let r of a) {
245
245
  if (typeof r.path != "string") throw new y("unsupported-extension", "A contributed theme has no valid path.");
246
246
  let a = A(r.path), s = await L({
247
- zip: e,
247
+ zip: t,
248
248
  sizes: n,
249
249
  path: a
250
250
  }), c = R(r.uiTheme), l = typeof r.label == "string" && r.label.trim() ? r.label.trim() : i;
251
- o.push(t({
251
+ o.push(e({
252
252
  source: JSON.stringify({
253
253
  ...s,
254
254
  name: l,
@@ -258,22 +258,21 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
258
258
  }));
259
259
  }
260
260
  return o;
261
- }, K = ({ fetchImpl: t = fetch } = {}) => {
262
- let n = E(t);
261
+ }, K = ({ description: e, name: t }) => {
262
+ let n = `${t} ${e}`;
263
+ return /\b(?:color\s+scheme|theme)\b/i.test(n) && !/\b(?:file\s+icons?|product\s+icons?|icon\s+theme|icons?)\b/i.test(n);
264
+ }, q = ({ fetchImpl: e = fetch } = {}) => {
265
+ let n = E(e);
263
266
  return {
264
267
  search: async (e) => {
265
268
  let t = e.trim();
266
- if (!t) return {
267
- status: "success",
268
- themes: []
269
- };
270
269
  if (t.length > 100) return {
271
270
  status: "error",
272
271
  message: "Search terms must be 100 characters or fewer."
273
272
  };
274
273
  try {
275
274
  let e = new URL(s);
276
- e.searchParams.set("query", t), e.searchParams.set("category", "Themes"), e.searchParams.set("sortBy", "downloadCount"), e.searchParams.set("sortOrder", "desc"), e.searchParams.set("size", "12");
275
+ t && e.searchParams.set("query", t), e.searchParams.set("category", "Themes"), e.searchParams.set("sortBy", "downloadCount"), e.searchParams.set("sortOrder", "desc"), e.searchParams.set("size", "12");
277
276
  let r = await n({
278
277
  url: e,
279
278
  limit: c,
@@ -281,26 +280,12 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
281
280
  tooLargeMessage: "Open VSX returned an unexpectedly large search response."
282
281
  }), i = JSON.parse(new TextDecoder().decode(r));
283
282
  if (!b(i) || !Array.isArray(i.extensions)) throw Error("invalid response");
284
- let a = i.extensions.flatMap((e) => {
285
- let t = D(e);
286
- return t ? [t] : [];
287
- }).slice(0, 12);
288
283
  return {
289
284
  status: "success",
290
- themes: (await Promise.all(a.map(async (e) => {
291
- try {
292
- let t = await B({
293
- request: n,
294
- extensionId: e.id
295
- });
296
- return await V({
297
- request: n,
298
- manifestUrl: t.manifestUrl
299
- }), e;
300
- } catch {
301
- return null;
302
- }
303
- }))).filter((e) => e !== null)
285
+ themes: i.extensions.flatMap((e) => {
286
+ let t = D(e);
287
+ return t && K(t) ? [t] : [];
288
+ }).slice(0, 12)
304
289
  };
305
290
  } catch {
306
291
  return {
@@ -309,19 +294,19 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
309
294
  };
310
295
  }
311
296
  },
312
- importTheme: async (t, r) => {
297
+ importTheme: async (e, r) => {
313
298
  try {
314
- let e = await B({
299
+ let t = await B({
315
300
  request: n,
316
- extensionId: t
301
+ extensionId: e
317
302
  });
318
303
  await V({
319
304
  request: n,
320
- manifestUrl: e.manifestUrl
305
+ manifestUrl: t.manifestUrl
321
306
  });
322
307
  let { zip: i, sizes: a } = await U(await H({
323
308
  request: n,
324
- ...e
309
+ ...t
325
310
  }));
326
311
  return {
327
312
  status: "success",
@@ -331,18 +316,18 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
331
316
  manifest: await W({
332
317
  zip: i,
333
318
  sizes: a,
334
- extensionId: t,
335
- version: e.version
319
+ extensionId: e,
320
+ version: t.version
336
321
  }),
337
- fallbackName: e.extensionName
322
+ fallbackName: t.extensionName
338
323
  }), r)
339
324
  };
340
- } catch (t) {
341
- return t instanceof e || t instanceof y ? {
325
+ } catch (e) {
326
+ return e instanceof t || e instanceof y ? {
342
327
  status: "error",
343
328
  error: {
344
- code: t.code,
345
- message: t.message
329
+ code: e.code,
330
+ message: e.message
346
331
  }
347
332
  } : {
348
333
  status: "error",
@@ -356,4 +341,4 @@ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `$
356
341
  };
357
342
  };
358
343
  //#endregion
359
- export { K as createOpenVsxThemeService };
344
+ export { q as createOpenVsxThemeService };
@@ -1,3 +1,5 @@
1
+ import type { SyntaxPalette } from './syntax.js';
2
+ export type { SyntaxPalette, SyntaxToken } from './syntax.js';
1
3
  export type ThemeAppearance = 'light' | 'dark' | 'high-contrast-light' | 'high-contrast-dark';
2
4
  export interface SemanticThemeTokens {
3
5
  pageBackground: string;
@@ -33,6 +35,7 @@ export interface NormalizedTheme {
33
35
  name: string;
34
36
  appearance: ThemeAppearance;
35
37
  tokens: SemanticThemeTokens;
38
+ syntax?: SyntaxPalette;
36
39
  }
37
40
  export type ThemeImportErrorCode = ThemeValidationErrorCode | 'file-too-large' | 'integrity-failed' | 'open-vsx-unavailable' | 'persistence-failed' | 'read-failed' | 'unsupported-extension' | 'unsupported-file-type';
38
41
  export interface ThemeImportError {
@@ -0,0 +1,5 @@
1
+ export declare const syntaxTokenNames: readonly ["comment", "keyword", "string", "number", "function", "type", "variable", "operator", "punctuation", "tag", "attribute"];
2
+ export type SyntaxToken = typeof syntaxTokenNames[number];
3
+ export type SyntaxPalette = Partial<Record<SyntaxToken, string>>;
4
+ /** The importer reduces provider scope names to our portable syntax palette. */
5
+ export declare const syntaxRolesForScope: (scope: string) => SyntaxToken[];
@@ -0,0 +1,462 @@
1
+ import { parse as e, printParseErrorCode as t } from "jsonc-parser";
2
+ //#region src/theme/syntax.ts
3
+ var n = [
4
+ "comment",
5
+ "keyword",
6
+ "string",
7
+ "number",
8
+ "function",
9
+ "type",
10
+ "variable",
11
+ "operator",
12
+ "punctuation",
13
+ "tag",
14
+ "attribute"
15
+ ], r = {
16
+ comment: ["comment"],
17
+ keyword: ["keyword", "storage"],
18
+ string: ["string"],
19
+ number: ["constant.numeric", "constant.language"],
20
+ function: ["entity.name.function", "support.function"],
21
+ type: [
22
+ "entity.name.type",
23
+ "entity.name.class",
24
+ "support.type",
25
+ "support.class"
26
+ ],
27
+ variable: ["variable"],
28
+ operator: ["keyword.operator"],
29
+ punctuation: ["punctuation"],
30
+ tag: ["entity.name.tag"],
31
+ attribute: ["entity.other.attribute-name"]
32
+ }, i = (e) => {
33
+ let t = n.map((t) => ({
34
+ role: t,
35
+ specificity: Math.max(0, ...r[t].filter((t) => e === t || e.startsWith(`${t}.`)).map((e) => e.length))
36
+ })), i = Math.max(...t.map((e) => e.specificity));
37
+ return t.filter((e) => e.specificity > 0 && e.specificity === i).map((e) => e.role);
38
+ }, a = class extends Error {
39
+ code;
40
+ constructor(e, t) {
41
+ super(t), this.name = "ThemeValidationError", this.code = e;
42
+ }
43
+ }, o = /* @__PURE__ */ "pageBackground.surface.surfaceRaised.surfaceMuted.textPrimary.textMuted.border.borderSubtle.link.accent.focus.buttonBackground.buttonForeground.buttonHoverBackground.inputBackground.inputForeground.inputBorder.inputPlaceholder.rowHoverBackground.rowSelectedBackground.rowSelectedForeground.codeBackground.codeForeground.error.warning.success.info.progress".split("."), s = /* @__PURE__ */ new Set(/* @__PURE__ */ "editor.background,editor.foreground,foreground,sideBar.background,panel.background,editorWidget.background,descriptionForeground,disabledForeground,panel.border,sideBar.border,contrastBorder,contrastActiveBorder,focusBorder,textLink.foreground,textLink.activeForeground,button.background,button.foreground,button.hoverBackground,input.background,input.foreground,input.border,input.placeholderForeground,list.hoverBackground,list.activeSelectionBackground,list.activeSelectionForeground,list.inactiveSelectionBackground,list.inactiveSelectionForeground,errorForeground,editorError.foreground,notificationsErrorIcon.foreground,notificationsWarningIcon.foreground,editorWarning.foreground,notificationsInfoIcon.foreground,editorInfo.foreground,testing.iconPassed,terminal.ansiGreen,progressBar.background".split(",")), c = {
44
+ pageBackground: "#EFF1F5",
45
+ surface: "#E6E9EF",
46
+ surfaceRaised: "#FFFFFF",
47
+ surfaceMuted: "#DCE0E8",
48
+ textPrimary: "#4C4F69",
49
+ textMuted: "#6C6F85",
50
+ border: "#ACB0BE",
51
+ borderSubtle: "#CCD0DA",
52
+ link: "#1E66F5",
53
+ accent: "#8839EF",
54
+ focus: "#1E66F5",
55
+ buttonBackground: "#1E66F5",
56
+ buttonForeground: "#FFFFFF",
57
+ buttonHoverBackground: "#1A5AD7",
58
+ inputBackground: "#FFFFFF",
59
+ inputForeground: "#4C4F69",
60
+ inputBorder: "#9CA0B0",
61
+ inputPlaceholder: "#7C7F93",
62
+ rowHoverBackground: "#DCE0E8",
63
+ rowSelectedBackground: "#D9E2FA",
64
+ rowSelectedForeground: "#4C4F69",
65
+ codeBackground: "#E6E9EF",
66
+ codeForeground: "#4C4F69",
67
+ error: "#D20F39",
68
+ warning: "#8A5600",
69
+ success: "#287D3C",
70
+ info: "#176B87",
71
+ progress: "#8839EF"
72
+ }, l = {
73
+ pageBackground: "#1E1E2E",
74
+ surface: "#181825",
75
+ surfaceRaised: "#242435",
76
+ surfaceMuted: "#313244",
77
+ textPrimary: "#CDD6F4",
78
+ textMuted: "#A6ADC8",
79
+ border: "#585B70",
80
+ borderSubtle: "#45475A",
81
+ link: "#89B4FA",
82
+ accent: "#CBA6F7",
83
+ focus: "#89B4FA",
84
+ buttonBackground: "#89B4FA",
85
+ buttonForeground: "#11111B",
86
+ buttonHoverBackground: "#B4BEFE",
87
+ inputBackground: "#11111B",
88
+ inputForeground: "#CDD6F4",
89
+ inputBorder: "#6C7086",
90
+ inputPlaceholder: "#9399B2",
91
+ rowHoverBackground: "#313244",
92
+ rowSelectedBackground: "#45475A",
93
+ rowSelectedForeground: "#CDD6F4",
94
+ codeBackground: "#11111B",
95
+ codeForeground: "#CDD6F4",
96
+ error: "#F38BA8",
97
+ warning: "#F9E2AF",
98
+ success: "#A6E3A1",
99
+ info: "#89DCEB",
100
+ progress: "#CBA6F7"
101
+ }, u = (e) => typeof e == "object" && !!e && !Array.isArray(e), d = (e) => typeof e == "string" && /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e), f = (e) => typeof e == "string" && /^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e), p = (e) => e.length === 4 || e.length === 5 ? `#${[...e.slice(1)].map((e) => e.repeat(2)).join("")}` : e, m = (e) => {
102
+ let t = {};
103
+ if (e === void 0) return t;
104
+ if (!Array.isArray(e)) throw new a("invalid-shape", "Theme tokenColors must be an array.");
105
+ for (let n of e) {
106
+ if (!u(n) || !u(n.settings)) throw new a("invalid-shape", "Each syntax rule must contain settings.");
107
+ let e = n.settings.foreground;
108
+ if (e === void 0) continue;
109
+ if (!d(e)) throw new a("invalid-color", "Syntax colors must be hexadecimal values.");
110
+ let r = typeof n.scope == "string" ? [n.scope] : n.scope;
111
+ if (r !== void 0) {
112
+ if (!Array.isArray(r) || !r.every((e) => typeof e == "string")) throw new a("invalid-shape", "Syntax scopes must be strings.");
113
+ for (let n of r.flatMap((e) => e.split(","))) {
114
+ let r = n.trim().split(/\s+/).at(-1) ?? "";
115
+ for (let n of i(r)) t[n] = p(e);
116
+ }
117
+ }
118
+ }
119
+ return t;
120
+ }, h = (e) => {
121
+ let t = e.length === 4 || e.length === 5 ? [...e.slice(1)].map((e) => e.repeat(2)).join("") : e.slice(1);
122
+ return [
123
+ Number.parseInt(t.slice(0, 2), 16),
124
+ Number.parseInt(t.slice(2, 4), 16),
125
+ Number.parseInt(t.slice(4, 6), 16),
126
+ t.length === 8 ? Number.parseInt(t.slice(6, 8), 16) / 255 : 1
127
+ ];
128
+ }, g = (e, t, n) => {
129
+ let [r, i, a] = h(n), o = (e) => {
130
+ let [t, n, o, s] = h(e);
131
+ return [
132
+ t * s + r * (1 - s),
133
+ n * s + i * (1 - s),
134
+ o * s + a * (1 - s)
135
+ ];
136
+ }, s = ([e, t, n]) => {
137
+ let r = [
138
+ e,
139
+ t,
140
+ n
141
+ ].map((e) => {
142
+ let t = e / 255;
143
+ return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
144
+ });
145
+ return .2126 * r[0] + .7152 * r[1] + .0722 * r[2];
146
+ }, c = s(o(e)), l = s(o(t));
147
+ return (Math.max(c, l) + .05) / (Math.min(c, l) + .05);
148
+ }, _ = ({ background: e, preferred: t, underlay: n }) => g(t, e, n) >= 4.5 ? t : [
149
+ t,
150
+ "#000000",
151
+ "#FFFFFF"
152
+ ].reduce((t, r) => g(r, e, n) > g(t, e, n) ? r : t), v = ({ color: e, against: t, fallback: n }) => g(e, t, t) >= 3 ? e : g(n, t, t) >= 3 ? n : _({
153
+ background: t,
154
+ preferred: n,
155
+ underlay: t
156
+ }), y = ({ color: e, background: t, underlay: n, fallback: r }) => g(e, t, n) >= 4.5 ? e : _({
157
+ background: t,
158
+ preferred: r,
159
+ underlay: n
160
+ }), b = ({ color: e, backgrounds: t, underlay: n, fallbacks: r }) => {
161
+ let i = [e, ...r];
162
+ return i.find((e) => t.every((t) => g(e, t, n) >= 4.5)) || i.reduce((e, r) => Math.min(...t.map((e) => g(r, e, n))) > Math.min(...t.map((t) => g(e, t, n))) ? r : e);
163
+ }, x = (e, t) => h(e)[3] === 1 ? e : t, S = (e) => {
164
+ let [t, n, r] = h(e);
165
+ return (.2126 * t + .7152 * n + .0722 * r) / 255 < .5 ? "dark" : "light";
166
+ }, C = (e, t) => {
167
+ if (e === void 0) return S(t);
168
+ if (e === "light") return "light";
169
+ if (e === "dark") return "dark";
170
+ if (e === "hc") return "high-contrast-dark";
171
+ if (e === "hcLight") return "high-contrast-light";
172
+ throw new a("unsupported-type", "The theme type must be \"light\", \"dark\", \"hc\", or \"hcLight\".");
173
+ }, w = (e, t, n) => {
174
+ for (let n of t) {
175
+ let t = e[n];
176
+ if (d(t)) return p(t);
177
+ }
178
+ return n;
179
+ }, T = (e, t) => {
180
+ let n = e.slice(0, t).split("\n");
181
+ return {
182
+ line: n.length,
183
+ column: (n.at(-1)?.length ?? 0) + 1
184
+ };
185
+ }, E = (e) => ((e.split(/[\\/]/).at(-1) ?? "Imported theme").replace(/\.jsonc?$/i, "") || "Imported theme").slice(0, 80), D = ({ colors: e, appearance: t, background: n, foreground: r }) => {
186
+ let i = t === "dark" || t === "high-contrast-dark" ? l : c, a = w(e, t.startsWith("high-contrast") ? [
187
+ "contrastBorder",
188
+ "contrastActiveBorder",
189
+ "panel.border",
190
+ "sideBar.border",
191
+ "focusBorder"
192
+ ] : [
193
+ "panel.border",
194
+ "sideBar.border",
195
+ "contrastBorder",
196
+ "input.border",
197
+ "focusBorder"
198
+ ], i.border), o = t.startsWith("high-contrast") ? v({
199
+ color: a,
200
+ against: n,
201
+ fallback: i.border
202
+ }) : a, s = w(e, [
203
+ "textLink.foreground",
204
+ "focusBorder",
205
+ "progressBar.background",
206
+ "button.background"
207
+ ], i.link), u = w(e, [
208
+ "focusBorder",
209
+ "progressBar.background",
210
+ "textLink.foreground",
211
+ "button.background"
212
+ ], s), d = _({
213
+ background: n,
214
+ preferred: r,
215
+ underlay: n
216
+ }), f = w(e, [
217
+ "sideBar.background",
218
+ "panel.background",
219
+ "editor.background"
220
+ ], i.surface), p = g(d, f, n) >= 4.5 ? f : n, m = w(e, [
221
+ "panel.background",
222
+ "sideBar.background",
223
+ "editorWidget.background",
224
+ "editor.background"
225
+ ], p), h = g(d, m, n) >= 4.5 ? m : p, x = b({
226
+ color: s,
227
+ backgrounds: [n, p],
228
+ underlay: n,
229
+ fallbacks: [i.link, d]
230
+ }), S = v({
231
+ color: u,
232
+ against: p,
233
+ fallback: i.accent
234
+ }), C = b({
235
+ color: w(e, [
236
+ "descriptionForeground",
237
+ "disabledForeground",
238
+ "foreground",
239
+ "editor.foreground"
240
+ ], i.textMuted),
241
+ backgrounds: [n, p],
242
+ underlay: n,
243
+ fallbacks: [i.textMuted, d]
244
+ }), T = w(e, [
245
+ "editorWidget.background",
246
+ "list.hoverBackground",
247
+ "sideBar.background",
248
+ "panel.background"
249
+ ], i.surfaceMuted), E = g(d, T, p) >= 4.5 && g(C, T, p) >= 4.5 ? T : p, D = w(e, ["button.background"], i.buttonBackground), O = _({
250
+ background: D,
251
+ preferred: w(e, ["button.foreground"], i.buttonForeground),
252
+ underlay: p
253
+ }), k = w(e, ["button.hoverBackground", "button.background"], i.buttonHoverBackground), A = g(O, k, p) >= 4.5 ? k : D, j = w(e, [
254
+ "focusBorder",
255
+ "contrastActiveBorder",
256
+ "textLink.activeForeground"
257
+ ], i.focus), M = w(e, [
258
+ "panel.border",
259
+ "sideBar.border",
260
+ "contrastBorder"
261
+ ], o), N = t.startsWith("high-contrast") ? v({
262
+ color: M,
263
+ against: p,
264
+ fallback: o
265
+ }) : M, P = w(e, ["input.background"], p), F = w(e, t.startsWith("high-contrast") ? [
266
+ "contrastBorder",
267
+ "input.border",
268
+ "focusBorder"
269
+ ] : [
270
+ "input.border",
271
+ "contrastBorder",
272
+ "focusBorder"
273
+ ], o), I = (t, r) => y({
274
+ color: w(e, t, r),
275
+ background: p,
276
+ underlay: n,
277
+ fallback: r
278
+ }), L = w(e, ["list.hoverBackground"], i.rowHoverBackground), R = g(d, L, p) >= 4.5 ? L : p;
279
+ return {
280
+ pageBackground: n,
281
+ surface: p,
282
+ surfaceRaised: h,
283
+ surfaceMuted: E,
284
+ textPrimary: d,
285
+ textMuted: C,
286
+ border: o,
287
+ borderSubtle: N,
288
+ link: x,
289
+ accent: S,
290
+ focus: v({
291
+ color: j,
292
+ against: n,
293
+ fallback: i.focus
294
+ }),
295
+ buttonBackground: D,
296
+ buttonForeground: O,
297
+ buttonHoverBackground: A,
298
+ inputBackground: P,
299
+ inputForeground: _({
300
+ background: P,
301
+ preferred: w(e, [
302
+ "input.foreground",
303
+ "editor.foreground",
304
+ "foreground"
305
+ ], d),
306
+ underlay: p
307
+ }),
308
+ inputBorder: t.startsWith("high-contrast") ? v({
309
+ color: F,
310
+ against: P,
311
+ fallback: o
312
+ }) : F,
313
+ inputPlaceholder: y({
314
+ color: w(e, ["input.placeholderForeground", "descriptionForeground"], C),
315
+ background: P,
316
+ underlay: p,
317
+ fallback: i.textMuted
318
+ }),
319
+ rowHoverBackground: R,
320
+ rowSelectedBackground: w(e, ["list.activeSelectionBackground", "list.inactiveSelectionBackground"], i.rowSelectedBackground),
321
+ rowSelectedForeground: _({
322
+ background: w(e, ["list.activeSelectionBackground", "list.inactiveSelectionBackground"], i.rowSelectedBackground),
323
+ preferred: w(e, ["list.activeSelectionForeground", "list.inactiveSelectionForeground"], i.rowSelectedForeground),
324
+ underlay: p
325
+ }),
326
+ codeBackground: w(e, ["editor.background"], i.codeBackground),
327
+ codeForeground: _({
328
+ background: w(e, ["editor.background"], i.codeBackground),
329
+ preferred: w(e, ["editor.foreground", "foreground"], i.codeForeground),
330
+ underlay: n
331
+ }),
332
+ error: I([
333
+ "errorForeground",
334
+ "notificationsErrorIcon.foreground",
335
+ "editorError.foreground"
336
+ ], i.error),
337
+ warning: I(["notificationsWarningIcon.foreground", "editorWarning.foreground"], i.warning),
338
+ success: I(["testing.iconPassed", "terminal.ansiGreen"], i.success),
339
+ info: I([
340
+ "notificationsInfoIcon.foreground",
341
+ "editorInfo.foreground",
342
+ "textLink.foreground"
343
+ ], i.info),
344
+ progress: v({
345
+ color: w(e, [
346
+ "progressBar.background",
347
+ "focusBorder",
348
+ "textLink.foreground"
349
+ ], S),
350
+ against: E,
351
+ fallback: i.progress
352
+ })
353
+ };
354
+ }, O = ({ source: n, fileName: r }) => {
355
+ let i = [], o = e(n, i, { allowTrailingComma: !0 }), f = i[0];
356
+ if (f) {
357
+ let { line: e, column: r } = T(n, f.offset);
358
+ throw new a("malformed-json", `The theme could not be parsed (${t(f.error)} at line ${e}, column ${r}).`);
359
+ }
360
+ if (!u(o)) throw new a("invalid-shape", "The theme file must contain a JSON object.");
361
+ if (o.name !== void 0 && typeof o.name != "string") throw new a("invalid-shape", "The theme name must be a string when provided.");
362
+ if (!u(o.colors)) throw new a("invalid-shape", "The theme must contain a \"colors\" object.");
363
+ let p = o.colors;
364
+ for (let e of s) {
365
+ let t = p[e];
366
+ if (t !== void 0 && !d(t)) throw new a("invalid-color", `The color for "${e}" must be a 3-, 4-, 6-, or 8-digit hexadecimal value.`);
367
+ }
368
+ let h = w(p, [
369
+ "editor.background",
370
+ "sideBar.background",
371
+ "panel.background"
372
+ ], ""), g = w(p, ["editor.foreground", "foreground"], "");
373
+ if (!h || !g) throw new a("missing-colors", "The theme must define a supported background color and foreground color.");
374
+ let _ = C(o.type, h), v = x(h, (_ === "dark" || _ === "high-contrast-dark" ? l : c).pageBackground);
375
+ return {
376
+ name: o.name?.trim().replace(/\s+/g, " ").slice(0, 80) || E(r),
377
+ appearance: _,
378
+ syntax: m(o.tokenColors),
379
+ tokens: D({
380
+ colors: p,
381
+ appearance: _,
382
+ background: v,
383
+ foreground: g
384
+ })
385
+ };
386
+ }, k = (e) => {
387
+ if (!u(e) || typeof e.name != "string" || e.name.trim().length === 0 || e.name.length > 80) return !1;
388
+ let t = e.appearance;
389
+ if (t !== "light" && t !== "dark" && t !== "high-contrast-light" && t !== "high-contrast-dark") return !1;
390
+ let r = e.tokens;
391
+ if (!u(r) || Object.keys(r).length !== o.length) return !1;
392
+ if (e.syntax !== void 0) {
393
+ if (!u(e.syntax)) return !1;
394
+ let t = e.syntax;
395
+ if (!Object.keys(t).every((e) => n.some((t) => t === e)) || !Object.values(t).every(f)) return !1;
396
+ }
397
+ return o.every((e) => f(r[e]));
398
+ }, A = {
399
+ pageBackground: "--color-bg",
400
+ surface: "--color-surface",
401
+ surfaceRaised: "--color-surface-raised",
402
+ surfaceMuted: "--color-surface-muted",
403
+ textPrimary: "--color-text",
404
+ textMuted: "--color-muted",
405
+ border: "--color-border",
406
+ borderSubtle: "--color-border-subtle",
407
+ link: "--color-link",
408
+ accent: "--color-accent",
409
+ focus: "--color-focus",
410
+ buttonBackground: "--color-button-bg",
411
+ buttonForeground: "--color-button-text",
412
+ buttonHoverBackground: "--color-button-hover",
413
+ inputBackground: "--color-input-bg",
414
+ inputForeground: "--color-input-text",
415
+ inputBorder: "--color-input-border",
416
+ inputPlaceholder: "--color-input-placeholder",
417
+ rowHoverBackground: "--color-row-hover",
418
+ rowSelectedBackground: "--color-row-selected",
419
+ rowSelectedForeground: "--color-row-selected-text",
420
+ codeBackground: "--color-code",
421
+ codeForeground: "--color-code-text",
422
+ error: "--color-error",
423
+ warning: "--color-warning",
424
+ success: "--color-success",
425
+ info: "--color-info",
426
+ progress: "--color-progress"
427
+ }, j = ({ root: e, theme: t }) => {
428
+ for (let n of o) {
429
+ let r = A[n];
430
+ t ? e.style.setProperty(r, t.tokens[n]) : e.style.removeProperty(r);
431
+ }
432
+ for (let r of n) {
433
+ let n = `--color-syntax-${r}`;
434
+ if (!t) {
435
+ e.style.removeProperty(n);
436
+ continue;
437
+ }
438
+ let i = {
439
+ comment: t.tokens.textMuted,
440
+ keyword: t.tokens.accent,
441
+ string: t.tokens.success,
442
+ number: t.tokens.warning,
443
+ function: t.tokens.link,
444
+ type: t.tokens.info,
445
+ variable: t.tokens.codeForeground,
446
+ operator: t.syntax?.keyword ?? t.tokens.codeForeground,
447
+ punctuation: t.tokens.codeForeground,
448
+ tag: t.tokens.link,
449
+ attribute: t.tokens.accent
450
+ };
451
+ e.style.setProperty(n, t.syntax?.[r] ?? y({
452
+ color: i[r],
453
+ background: t.tokens.codeBackground,
454
+ underlay: t.tokens.pageBackground,
455
+ fallback: t.tokens.codeForeground
456
+ }));
457
+ }
458
+ let r = t?.appearance;
459
+ e.classList.toggle("dark", r === "dark" || r === "high-contrast-dark"), e.classList.toggle("high-contrast", r === "high-contrast-light" || r === "high-contrast-dark");
460
+ };
461
+ //#endregion
462
+ export { A as a, O as i, j as n, o, k as r, a as t };