@filipgutica/ui 0.2.2 → 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,38 +1,38 @@
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";
5
5
  //#region src/open-vsx/index.ts
6
- var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144, l = 262144, u = 1048576, d = 20971520, f = 5e3, p = 104857600, m = 200, h = 40, g = 8, _ = 15e3, v = class extends Error {
6
+ var a = "https://open-vsx.org", o = "https://openvsx.eclipsecontent.org", s = `${a}/api/-/search`, c = 524288, l = 262144, u = 262144, d = 1048576, f = 20971520, p = 5e3, m = 104857600, h = 200, g = 40, _ = 8, v = 15e3, y = class extends Error {
7
7
  code;
8
8
  constructor(e, t) {
9
9
  super(t), this.name = "OpenVsxThemeError", this.code = e;
10
10
  }
11
- }, y = (e) => typeof e == "object" && !!e && !Array.isArray(e), b = (e, t) => {
11
+ }, b = (e) => typeof e == "object" && !!e && !Array.isArray(e), x = (e, t) => {
12
12
  let r = [], i = n(e, r, { allowTrailingComma: !0 });
13
- if (r.length > 0 || !y(i)) throw new v("unsupported-extension", `${t} is not valid JSON.`);
13
+ if (r.length > 0 || !b(i)) throw new y("unsupported-extension", `${t} is not valid JSON.`);
14
14
  return i;
15
- }, x = (e) => {
15
+ }, S = (e, { allowResourceOrigin: t = !1 } = {}) => {
16
16
  if (typeof e != "string") return null;
17
17
  try {
18
- let t = new URL(e);
19
- return t.origin.toLowerCase() === a ? t.toString() : null;
18
+ let n = new URL(e), r = n.origin.toLowerCase();
19
+ return r === a || t && r === o ? n.toString() : null;
20
20
  } catch {
21
21
  return null;
22
22
  }
23
- }, S = (e) => {
23
+ }, C = (e) => {
24
24
  let t = /^([a-z0-9][a-z0-9_-]{0,99})\.([a-z0-9][a-z0-9_-]{0,99})$/i.exec(e);
25
- if (!t?.[1] || !t[2]) throw new v("unsupported-extension", "The selected Open VSX extension identifier is invalid.");
25
+ if (!t?.[1] || !t[2]) throw new y("unsupported-extension", "The selected Open VSX extension identifier is invalid.");
26
26
  return [t[1], t[2]];
27
- }, C = (e) => {
28
- let t = y(e.contributes) ? e.contributes : null;
29
- return Array.isArray(t?.themes) ? t.themes.filter(y) : [];
30
- }, w = async (e, t, n) => {
27
+ }, w = (e) => {
28
+ let t = b(e.contributes) ? e.contributes : null;
29
+ return Array.isArray(t?.themes) ? t.themes.filter(b) : [];
30
+ }, T = async (e, t, n) => {
31
31
  let r = Number(e.headers.get("content-length"));
32
- if (Number.isFinite(r) && r > t) throw new v("file-too-large", n);
32
+ if (Number.isFinite(r) && r > t) throw new y("file-too-large", n);
33
33
  if (!e.body) {
34
34
  let r = new Uint8Array(await e.arrayBuffer());
35
- if (r.byteLength > t) throw new v("file-too-large", n);
35
+ if (r.byteLength > t) throw new y("file-too-large", n);
36
36
  return r;
37
37
  }
38
38
  let i = e.body.getReader(), a = [], o = 0;
@@ -40,7 +40,7 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
40
40
  for (;;) {
41
41
  let { done: e, value: r } = await i.read();
42
42
  if (e) break;
43
- if (o += r.byteLength, o > t) throw await i.cancel(), new v("file-too-large", n);
43
+ if (o += r.byteLength, o > t) throw await i.cancel(), new y("file-too-large", n);
44
44
  a.push(r);
45
45
  }
46
46
  } finally {
@@ -49,24 +49,24 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
49
49
  let s = new Uint8Array(o), c = 0;
50
50
  for (let e of a) s.set(e, c), c += e.byteLength;
51
51
  return s;
52
- }, T = (e) => async ({ url: t, limit: n, failureMessage: r, tooLargeMessage: i }) => {
53
- let a = new AbortController(), o = setTimeout(() => a.abort(), _);
52
+ }, E = (e) => async ({ url: t, limit: n, failureMessage: r, tooLargeMessage: i, allowResourceOrigin: a = !1 }) => {
53
+ let o = new AbortController(), s = setTimeout(() => o.abort(), v);
54
54
  try {
55
- let o = x(String(t));
56
- if (!o) throw new v("open-vsx-unavailable", r);
57
- let s = await e(o, {
55
+ let s = S(String(t), { allowResourceOrigin: a });
56
+ if (!s) throw new y("open-vsx-unavailable", r);
57
+ let c = await e(s, {
58
58
  redirect: "follow",
59
- signal: a.signal
59
+ signal: o.signal
60
60
  });
61
- if (!x(s.url || o) || !s.ok) throw new v("open-vsx-unavailable", r);
62
- return await w(s, n, i);
61
+ if (!S(c.url || s, { allowResourceOrigin: a }) || !c.ok) throw new y("open-vsx-unavailable", r);
62
+ return await T(c, n, i);
63
63
  } catch (e) {
64
- throw e instanceof v ? e : new v("open-vsx-unavailable", a.signal.aborted ? "Open VSX took too long to respond." : r);
64
+ throw e instanceof y ? e : new y("open-vsx-unavailable", o.signal.aborted ? "Open VSX took too long to respond." : r);
65
65
  } finally {
66
- clearTimeout(o);
66
+ clearTimeout(s);
67
67
  }
68
- }, E = (e) => {
69
- if (!y(e)) return null;
68
+ }, D = (e) => {
69
+ if (!b(e)) return null;
70
70
  let t = typeof e.namespace == "string" ? e.namespace.trim() : "", n = typeof e.name == "string" ? e.name.trim() : "";
71
71
  if (!t || !n) return null;
72
72
  let r = typeof e.displayName == "string" && e.displayName.trim() ? e.displayName.trim() : n;
@@ -77,49 +77,49 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
77
77
  description: typeof e.description == "string" ? e.description.slice(0, 300) : "",
78
78
  downloadCount: typeof e.downloadCount == "number" && Number.isFinite(e.downloadCount) ? Math.max(0, e.downloadCount) : 0
79
79
  };
80
- }, D = (e) => {
81
- if (e.length > 1024 || e.includes("\0") || e.startsWith("/") || /^[a-z]:/i.test(e)) throw new v("unsupported-extension", "A theme path is not safe.");
82
- }, O = ({ path: e, initialSegments: t, minimumDepth: n }) => {
83
- D(e);
80
+ }, O = (e) => {
81
+ if (e.length > 1024 || e.includes("\0") || e.startsWith("/") || /^[a-z]:/i.test(e)) throw new y("unsupported-extension", "A theme path is not safe.");
82
+ }, k = ({ path: e, initialSegments: t, minimumDepth: n }) => {
83
+ O(e);
84
84
  let r = [...t];
85
85
  for (let t of e.replaceAll("\\", "/").split("/")) if (!(!t || t === ".")) {
86
86
  if (t === "..") {
87
- if (r.length <= n) throw new v("unsupported-extension", "A theme path escapes its package.");
87
+ if (r.length <= n) throw new y("unsupported-extension", "A theme path escapes its package.");
88
88
  r.pop();
89
89
  } else r.push(t);
90
90
  }
91
91
  return r.join("/");
92
- }, k = (e, t = "extension/") => {
92
+ }, A = (e, t = "extension/") => {
93
93
  let n = t.split("/").slice(0, -1);
94
- return n[0] !== "extension" && n.unshift("extension"), O({
94
+ return n[0] !== "extension" && n.unshift("extension"), k({
95
95
  path: e,
96
96
  initialSegments: n,
97
97
  minimumDepth: 1
98
98
  });
99
- }, A = (e) => {
100
- let t = O({
99
+ }, j = (e) => {
100
+ let t = k({
101
101
  path: e,
102
102
  initialSegments: [],
103
103
  minimumDepth: 0
104
104
  });
105
- if (!t) throw new v("unsupported-extension", "The extension package has an invalid file name.");
105
+ if (!t) throw new y("unsupported-extension", "The extension package has an invalid file name.");
106
106
  return t;
107
- }, j = (e) => {
107
+ }, M = (e) => {
108
108
  let t = e.byteLength, n = Math.max(0, t - 65557), r = t - 22;
109
109
  for (; r >= n && (e.getUint32(r, !0) !== 101010256 || r + 22 + e.getUint16(r + 20, !0) !== t);) --r;
110
- if (r < n) throw new v("unsupported-extension", "The extension package is not a valid ZIP file.");
110
+ if (r < n) throw new y("unsupported-extension", "The extension package is not a valid ZIP file.");
111
111
  return r;
112
- }, M = (e) => {
113
- let t = j(e), n = e.getUint32(t + 12, !0), r = e.getUint32(t + 16, !0), i = r + n;
114
- if (i !== t || i > e.byteLength) throw new v("unsupported-extension", "The extension package has an invalid ZIP directory.");
112
+ }, N = (e) => {
113
+ let t = M(e), n = e.getUint32(t + 12, !0), r = e.getUint32(t + 16, !0), i = r + n;
114
+ if (i !== t || i > e.byteLength) throw new y("unsupported-extension", "The extension package has an invalid ZIP directory.");
115
115
  return {
116
116
  start: r,
117
117
  end: i
118
118
  };
119
- }, N = ({ bytes: e, view: t, offset: n, directoryEnd: r }) => {
120
- if (n + 46 > r || t.getUint32(n, !0) !== 33639248) throw new v("unsupported-extension", "The extension package has an invalid ZIP directory.");
119
+ }, P = ({ bytes: e, view: t, offset: n, directoryEnd: r }) => {
120
+ if (n + 46 > r || t.getUint32(n, !0) !== 33639248) throw new y("unsupported-extension", "The extension package has an invalid ZIP directory.");
121
121
  let i = t.getUint32(n + 20, !0), a = t.getUint32(n + 24, !0), o = t.getUint16(n + 28, !0), s = t.getUint16(n + 30, !0), c = t.getUint16(n + 32, !0), l = n + 46 + o + s + c;
122
- if (l > r || i === 4294967295 || a === 4294967295 || a > 0 && (i === 0 || a / i > m)) throw new v("unsupported-extension", "The extension package has unsafe ZIP metadata.");
122
+ if (l > r || i === 4294967295 || a === 4294967295 || a > 0 && (i === 0 || a / i > h)) throw new y("unsupported-extension", "The extension package has unsafe ZIP metadata.");
123
123
  try {
124
124
  return {
125
125
  name: new TextDecoder("utf-8", { fatal: !0 }).decode(e.subarray(n + 46, n + 46 + o)),
@@ -127,32 +127,32 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
127
127
  nextOffset: l
128
128
  };
129
129
  } catch {
130
- throw new v("unsupported-extension", "The extension package has an invalid file name.");
130
+ throw new y("unsupported-extension", "The extension package has an invalid file name.");
131
131
  }
132
- }, P = (e) => {
133
- let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = M(t), r = /* @__PURE__ */ new Map(), i = 0, a = 0, o = n.start;
132
+ }, F = (e) => {
133
+ let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = N(t), r = /* @__PURE__ */ new Map(), i = 0, a = 0, o = n.start;
134
134
  for (; o < n.end;) {
135
- if (a += 1, a > f) throw new v("unsupported-extension", "The extension package has an invalid ZIP directory.");
136
- let s = N({
135
+ if (a += 1, a > p) throw new y("unsupported-extension", "The extension package has an invalid ZIP directory.");
136
+ let s = P({
137
137
  bytes: e,
138
138
  view: t,
139
139
  offset: o,
140
140
  directoryEnd: n.end
141
141
  });
142
- if (i += s.uncompressed, i > p) throw new v("file-too-large", "The extension package expands beyond the safe limit.");
143
- r.set(A(s.name), s.uncompressed), o = s.nextOffset;
142
+ if (i += s.uncompressed, i > m) throw new y("file-too-large", "The extension package expands beyond the safe limit.");
143
+ r.set(j(s.name), s.uncompressed), o = s.nextOffset;
144
144
  }
145
145
  return r;
146
- }, F = async ({ zip: e, sizes: t, path: n, description: r }) => {
146
+ }, I = async ({ zip: e, sizes: t, path: n, description: r }) => {
147
147
  let i = t.get(n);
148
- if (i === void 0) throw new v("unsupported-extension", `${r} is missing.`);
149
- if (i > u) throw new v("file-too-large", `${r} is too large.`);
148
+ if (i === void 0) throw new y("unsupported-extension", `${r} is missing.`);
149
+ if (i > d) throw new y("file-too-large", `${r} is too large.`);
150
150
  let a = e.file(n);
151
- if (!a) throw new v("unsupported-extension", `${r} is missing.`);
151
+ if (!a) throw new y("unsupported-extension", `${r} is missing.`);
152
152
  return a.async("string");
153
- }, I = async ({ zip: e, sizes: t, path: n, ancestors: r = /* @__PURE__ */ new Set() }) => {
154
- if (r.size >= g || r.has(n)) throw new v("unsupported-extension", "Theme includes are cyclic or too deeply nested.");
155
- let i = b(await F({
153
+ }, L = async ({ zip: e, sizes: t, path: n, ancestors: r = /* @__PURE__ */ new Set() }) => {
154
+ if (r.size >= _ || r.has(n)) throw new y("unsupported-extension", "Theme includes are cyclic or too deeply nested.");
155
+ let i = x(await I({
156
156
  zip: e,
157
157
  sizes: t,
158
158
  path: n,
@@ -161,91 +161,94 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
161
161
  if (typeof i.include != "string") return i;
162
162
  let a = new Set(r);
163
163
  a.add(n);
164
- let o = await I({
164
+ let o = await L({
165
165
  zip: e,
166
166
  sizes: t,
167
- path: k(i.include, n),
167
+ path: A(i.include, n),
168
168
  ancestors: a
169
169
  });
170
170
  return {
171
171
  ...o,
172
172
  ...i,
173
173
  colors: {
174
- ...y(o.colors) ? o.colors : {},
175
- ...y(i.colors) ? i.colors : {}
174
+ ...b(o.colors) ? o.colors : {},
175
+ ...b(i.colors) ? i.colors : {}
176
176
  }
177
177
  };
178
- }, L = (e) => e === "vs" ? "light" : e === "vs-dark" ? "dark" : e === "hc-black" ? "hc" : e === "hc-light" ? "hcLight" : null, R = (e, t) => e.find((e) => t === "dark" ? e.appearance === "dark" || e.appearance === "high-contrast-dark" : e.appearance === "light" || e.appearance === "high-contrast-light") ?? e[0], z = async ({ request: e, extensionId: t }) => {
179
- let [n, r] = S(t), i = await e({
178
+ }, R = (e) => e === "vs" ? "light" : e === "vs-dark" ? "dark" : e === "hc-black" ? "hc" : e === "hc-light" ? "hcLight" : null, z = (e, t) => e.find((e) => t === "dark" ? e.appearance === "dark" || e.appearance === "high-contrast-dark" : e.appearance === "light" || e.appearance === "high-contrast-light") ?? e[0], B = async ({ request: e, extensionId: t }) => {
179
+ let [n, r] = C(t), i = await e({
180
180
  url: `${a}/api/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,
181
- limit: c,
181
+ limit: l,
182
182
  failureMessage: "Open VSX theme details are unavailable right now.",
183
183
  tooLargeMessage: "Open VSX returned unexpectedly large theme details."
184
184
  }), o = JSON.parse(new TextDecoder().decode(i));
185
- if (!y(o) || !y(o.files)) throw new v("unsupported-extension", "Open VSX returned malformed theme details.");
186
- let s = x(o.files.manifest), l = x(o.files.download), u = x(o.files.sha256), d = typeof o.version == "string" ? o.version : "";
187
- if (!s || !l || !u || !d) throw new v("unsupported-extension", "Open VSX returned malformed theme details.");
185
+ if (!b(o) || !b(o.files)) throw new y("unsupported-extension", "Open VSX returned malformed theme details.");
186
+ let s = { allowResourceOrigin: !0 }, c = S(o.files.manifest, s), u = S(o.files.download, s), d = S(o.files.sha256, s), f = typeof o.version == "string" ? o.version : "";
187
+ if (!c || !u || !d || !f) throw new y("unsupported-extension", "Open VSX returned malformed theme details.");
188
188
  return {
189
189
  extensionName: r,
190
- manifestUrl: s,
191
- packageUrl: l,
192
- checksumUrl: u,
193
- version: d
190
+ manifestUrl: c,
191
+ packageUrl: u,
192
+ checksumUrl: d,
193
+ version: f
194
194
  };
195
- }, B = async ({ request: e, manifestUrl: t }) => {
195
+ }, V = async ({ request: e, manifestUrl: t }) => {
196
196
  let n = await e({
197
197
  url: t,
198
- limit: l,
198
+ limit: u,
199
199
  failureMessage: "That extension has no readable manifest.",
200
- tooLargeMessage: "That extension manifest is too large."
201
- }), r = C(b(new TextDecoder().decode(n), "The extension manifest"));
202
- if (r.length === 0 || r.length > h) throw new v("unsupported-extension", "That extension does not contain a supported number of color themes.");
203
- }, V = async ({ request: e, packageUrl: t, checksumUrl: n }) => {
200
+ tooLargeMessage: "That extension manifest is too large.",
201
+ allowResourceOrigin: !0
202
+ }), r = w(x(new TextDecoder().decode(n), "The extension manifest"));
203
+ if (r.length === 0 || r.length > g) throw new y("unsupported-extension", "That extension does not contain a supported number of color themes.");
204
+ }, H = async ({ request: e, packageUrl: t, checksumUrl: n }) => {
204
205
  let [i, a] = await Promise.all([e({
205
206
  url: t,
206
- limit: d,
207
+ limit: f,
207
208
  failureMessage: "That Open VSX theme could not be downloaded.",
208
- tooLargeMessage: "That theme extension is too large to import safely."
209
+ tooLargeMessage: "That theme extension is too large to import safely.",
210
+ allowResourceOrigin: !0
209
211
  }), e({
210
212
  url: n,
211
213
  limit: 256,
212
214
  failureMessage: "That Open VSX theme has no readable checksum.",
213
- tooLargeMessage: "That Open VSX checksum response is invalid."
215
+ tooLargeMessage: "That Open VSX checksum response is invalid.",
216
+ allowResourceOrigin: !0
214
217
  })]), o = new TextDecoder().decode(a).trim().split(/\s+/)[0], s = r("sha256").update(i).digest("hex");
215
- if (!o || !/^[a-f\d]{64}$/i.test(o)) throw new v("integrity-failed", "That Open VSX theme has an invalid checksum.");
216
- if (o.toLowerCase() !== s) throw new v("integrity-failed", "That Open VSX theme failed its integrity check.");
218
+ if (!o || !/^[a-f\d]{64}$/i.test(o)) throw new y("integrity-failed", "That Open VSX theme has an invalid checksum.");
219
+ if (o.toLowerCase() !== s) throw new y("integrity-failed", "That Open VSX theme failed its integrity check.");
217
220
  return i;
218
- }, H = async (e) => {
219
- let t = P(e);
221
+ }, U = async (e) => {
222
+ let t = F(e);
220
223
  try {
221
224
  return {
222
225
  zip: await i.loadAsync(e),
223
226
  sizes: t
224
227
  };
225
228
  } catch {
226
- throw new v("unsupported-extension", "That extension package could not be opened.");
229
+ throw new y("unsupported-extension", "That extension package could not be opened.");
227
230
  }
228
- }, U = async ({ zip: e, sizes: t, extensionId: n, version: r }) => {
229
- let i = b(await F({
231
+ }, W = async ({ zip: e, sizes: t, extensionId: n, version: r }) => {
232
+ let i = x(await I({
230
233
  zip: e,
231
234
  sizes: t,
232
235
  path: "extension/package.json",
233
236
  description: "The packaged extension manifest"
234
237
  }), "The packaged extension manifest");
235
- if ((typeof i.publisher == "string" && typeof i.name == "string" ? `${i.publisher}.${i.name}` : "").toLowerCase() !== n.toLowerCase() || i.version !== r) throw new v("integrity-failed", "The downloaded package does not match the selected Open VSX theme.");
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.");
236
239
  return i;
237
- }, W = async ({ zip: e, sizes: n, manifest: r, fallbackName: i }) => {
238
- let a = C(r);
239
- if (a.length === 0 || a.length > h) throw new v("unsupported-extension", "That extension has no compatible color themes.");
240
+ }, G = async ({ zip: t, sizes: n, manifest: r, fallbackName: i }) => {
241
+ let a = w(r);
242
+ if (a.length === 0 || a.length > g) throw new y("unsupported-extension", "That extension has no compatible color themes.");
240
243
  let o = [];
241
244
  for (let r of a) {
242
- if (typeof r.path != "string") throw new v("unsupported-extension", "A contributed theme has no valid path.");
243
- let a = k(r.path), s = await I({
244
- zip: e,
245
+ if (typeof r.path != "string") throw new y("unsupported-extension", "A contributed theme has no valid path.");
246
+ let a = A(r.path), s = await L({
247
+ zip: t,
245
248
  sizes: n,
246
249
  path: a
247
- }), c = L(r.uiTheme), l = typeof r.label == "string" && r.label.trim() ? r.label.trim() : i;
248
- o.push(t({
250
+ }), c = R(r.uiTheme), l = typeof r.label == "string" && r.label.trim() ? r.label.trim() : i;
251
+ o.push(e({
249
252
  source: JSON.stringify({
250
253
  ...s,
251
254
  name: l,
@@ -255,34 +258,33 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
255
258
  }));
256
259
  }
257
260
  return o;
258
- }, G = ({ fetchImpl: t = fetch } = {}) => {
259
- let n = T(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);
260
266
  return {
261
267
  search: async (e) => {
262
268
  let t = e.trim();
263
- if (!t) return {
264
- status: "success",
265
- themes: []
266
- };
267
269
  if (t.length > 100) return {
268
270
  status: "error",
269
271
  message: "Search terms must be 100 characters or fewer."
270
272
  };
271
273
  try {
272
- let e = new URL(o);
273
- 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");
274
+ let e = new URL(s);
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");
274
276
  let r = await n({
275
277
  url: e,
276
- limit: s,
278
+ limit: c,
277
279
  failureMessage: "Open VSX search is unavailable right now.",
278
280
  tooLargeMessage: "Open VSX returned an unexpectedly large search response."
279
281
  }), i = JSON.parse(new TextDecoder().decode(r));
280
- if (!y(i) || !Array.isArray(i.extensions)) throw Error("invalid response");
282
+ if (!b(i) || !Array.isArray(i.extensions)) throw Error("invalid response");
281
283
  return {
282
284
  status: "success",
283
285
  themes: i.extensions.flatMap((e) => {
284
- let t = E(e);
285
- return t ? [t] : [];
286
+ let t = D(e);
287
+ return t && K(t) ? [t] : [];
286
288
  }).slice(0, 12)
287
289
  };
288
290
  } catch {
@@ -292,40 +294,40 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
292
294
  };
293
295
  }
294
296
  },
295
- importTheme: async (t, r) => {
297
+ importTheme: async (e, r) => {
296
298
  try {
297
- let e = await z({
299
+ let t = await B({
298
300
  request: n,
299
- extensionId: t
301
+ extensionId: e
300
302
  });
301
- await B({
303
+ await V({
302
304
  request: n,
303
- manifestUrl: e.manifestUrl
305
+ manifestUrl: t.manifestUrl
304
306
  });
305
- let { zip: i, sizes: a } = await H(await V({
307
+ let { zip: i, sizes: a } = await U(await H({
306
308
  request: n,
307
- ...e
309
+ ...t
308
310
  }));
309
311
  return {
310
312
  status: "success",
311
- theme: R(await W({
313
+ theme: z(await G({
312
314
  zip: i,
313
315
  sizes: a,
314
- manifest: await U({
316
+ manifest: await W({
315
317
  zip: i,
316
318
  sizes: a,
317
- extensionId: t,
318
- version: e.version
319
+ extensionId: e,
320
+ version: t.version
319
321
  }),
320
- fallbackName: e.extensionName
322
+ fallbackName: t.extensionName
321
323
  }), r)
322
324
  };
323
- } catch (t) {
324
- return t instanceof e || t instanceof v ? {
325
+ } catch (e) {
326
+ return e instanceof t || e instanceof y ? {
325
327
  status: "error",
326
328
  error: {
327
- code: t.code,
328
- message: t.message
329
+ code: e.code,
330
+ message: e.message
329
331
  }
330
332
  } : {
331
333
  status: "error",
@@ -339,4 +341,4 @@ var a = "https://open-vsx.org", o = `${a}/api/-/search`, s = 524288, c = 262144,
339
341
  };
340
342
  };
341
343
  //#endregion
342
- export { G 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[];