@tachui/core 0.8.20 → 0.8.22
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/assets/index.d.ts +20 -1
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js +234 -210
- package/dist/bundles/assets.d.ts +1 -1
- package/dist/bundles/assets.d.ts.map +1 -1
- package/dist/common.js +401 -397
- package/dist/essential.js +403 -399
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +405 -401
- package/dist/modifiers/index.d.ts +1 -1
- package/dist/modifiers/index.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/dist/assets/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { L as
|
|
3
|
-
import { J as
|
|
1
|
+
import { A as p } from "../index-JQ1sW1SK.js";
|
|
2
|
+
import { L as it, R as ot, k as lt } from "../index-JQ1sW1SK.js";
|
|
3
|
+
import { J as C, K as S, k as x } from "../theme-CRLPHryV.js";
|
|
4
4
|
export * from "@tachui/types/assets";
|
|
5
|
-
var
|
|
6
|
-
const E = class
|
|
5
|
+
var H = Object.defineProperty, M = (i, t, e) => t in i ? H(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, y = (i, t, e) => M(i, typeof t != "symbol" ? t + "" : t, e);
|
|
6
|
+
const E = class a extends p {
|
|
7
7
|
constructor(t) {
|
|
8
|
-
if (super(t.name),
|
|
8
|
+
if (super(t.name), y(this, "default"), y(this, "light"), y(this, "dark"), !t.default)
|
|
9
9
|
throw new Error(
|
|
10
10
|
`ColorAsset "${t.name}" must specify a default color`
|
|
11
11
|
);
|
|
12
|
-
const e =
|
|
12
|
+
const e = a.validateColor(t.default);
|
|
13
13
|
if (!e.isValid)
|
|
14
14
|
throw new Error(
|
|
15
15
|
`Invalid default color format for asset "${t.name}": ${e.error}`
|
|
16
16
|
);
|
|
17
17
|
if (t.light) {
|
|
18
|
-
const r =
|
|
18
|
+
const r = a.validateColor(t.light);
|
|
19
19
|
if (!r.isValid)
|
|
20
20
|
throw new Error(
|
|
21
21
|
`Invalid light color format for asset "${t.name}": ${r.error}`
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
if (t.dark) {
|
|
25
|
-
const r =
|
|
25
|
+
const r = a.validateColor(t.dark);
|
|
26
26
|
if (!r.isValid)
|
|
27
27
|
throw new Error(
|
|
28
28
|
`Invalid dark color format for asset "${t.name}": ${r.error}`
|
|
@@ -31,7 +31,7 @@ const E = class n extends b {
|
|
|
31
31
|
this.default = t.default, this.light = t.light, this.dark = t.dark;
|
|
32
32
|
}
|
|
33
33
|
static init(t) {
|
|
34
|
-
return new
|
|
34
|
+
return new a(t);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Validates a color string format
|
|
@@ -44,32 +44,32 @@ const E = class n extends b {
|
|
|
44
44
|
error: "Color must be a non-empty string"
|
|
45
45
|
};
|
|
46
46
|
const e = t.trim();
|
|
47
|
-
if (
|
|
47
|
+
if (a.HEX_REGEX.test(e))
|
|
48
48
|
return { isValid: !0, format: "hex" };
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
49
|
+
if (a.RGB_REGEX.test(e)) {
|
|
50
|
+
const n = e.match(a.RGB_REGEX), [, s, o, c] = n.map(Number);
|
|
51
51
|
return s <= 255 && o <= 255 && c <= 255 ? { isValid: !0, format: "rgb" } : {
|
|
52
52
|
isValid: !1,
|
|
53
53
|
error: "RGB values must be between 0 and 255"
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
return u <= 255 && h <= 255 && f <= 255 &&
|
|
56
|
+
if (a.RGBA_REGEX.test(e)) {
|
|
57
|
+
const n = e.match(a.RGBA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
|
|
58
|
+
return u <= 255 && h <= 255 && f <= 255 && d >= 0 && d <= 1 ? { isValid: !0, format: "rgba" } : {
|
|
59
59
|
isValid: !1,
|
|
60
60
|
error: "RGBA values must be: RGB 0-255, alpha 0-1"
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
if (
|
|
64
|
-
const
|
|
63
|
+
if (a.HSL_REGEX.test(e)) {
|
|
64
|
+
const n = e.match(a.HSL_REGEX), [, s, o, c] = n.map(Number);
|
|
65
65
|
return s <= 360 && o <= 100 && c <= 100 ? { isValid: !0, format: "hsl" } : {
|
|
66
66
|
isValid: !1,
|
|
67
67
|
error: "HSL values must be: H 0-360, S/L 0-100%"
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
return u <= 360 && h <= 100 && f <= 100 &&
|
|
70
|
+
if (a.HSLA_REGEX.test(e)) {
|
|
71
|
+
const n = e.match(a.HSLA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
|
|
72
|
+
return u <= 360 && h <= 100 && f <= 100 && d >= 0 && d <= 1 ? { isValid: !0, format: "hsla" } : {
|
|
73
73
|
isValid: !1,
|
|
74
74
|
error: "HSLA values must be: H 0-360, S/L 0-100%, alpha 0-1"
|
|
75
75
|
};
|
|
@@ -108,67 +108,67 @@ const E = class n extends b {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
static getCurrentTheme() {
|
|
111
|
-
return
|
|
111
|
+
return C();
|
|
112
112
|
}
|
|
113
113
|
opacity(t) {
|
|
114
114
|
if (!this.isFiniteInput(t, "opacity(alpha)"))
|
|
115
115
|
return this;
|
|
116
|
-
const e =
|
|
117
|
-
return new
|
|
116
|
+
const e = a.clamp(t, 0, 1);
|
|
117
|
+
return new a({
|
|
118
118
|
name: this.name,
|
|
119
|
-
default:
|
|
120
|
-
light: this.light ?
|
|
121
|
-
dark: this.dark ?
|
|
119
|
+
default: a.applyAlpha(this.default, e),
|
|
120
|
+
light: this.light ? a.applyAlpha(this.light, e) : void 0,
|
|
121
|
+
dark: this.dark ? a.applyAlpha(this.dark, e) : void 0
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
saturate(t) {
|
|
125
125
|
if (!this.isFiniteInput(t, "saturate(amount)"))
|
|
126
126
|
return this;
|
|
127
|
-
const e =
|
|
128
|
-
return new
|
|
127
|
+
const e = a.clamp(t, -1, 1);
|
|
128
|
+
return new a({
|
|
129
129
|
name: this.name,
|
|
130
|
-
default:
|
|
131
|
-
light: this.light ?
|
|
132
|
-
dark: this.dark ?
|
|
130
|
+
default: a.applySaturation(this.default, e),
|
|
131
|
+
light: this.light ? a.applySaturation(this.light, e) : void 0,
|
|
132
|
+
dark: this.dark ? a.applySaturation(this.dark, e) : void 0
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
brighten(t) {
|
|
136
136
|
if (!this.isFiniteInput(t, "brighten(amount)"))
|
|
137
137
|
return this;
|
|
138
|
-
const e =
|
|
139
|
-
return new
|
|
138
|
+
const e = a.clamp(t, -1, 1);
|
|
139
|
+
return new a({
|
|
140
140
|
name: this.name,
|
|
141
|
-
default:
|
|
142
|
-
light: this.light ?
|
|
143
|
-
dark: this.dark ?
|
|
141
|
+
default: a.applyBrightness(this.default, e),
|
|
142
|
+
light: this.light ? a.applyBrightness(this.light, e) : void 0,
|
|
143
|
+
dark: this.dark ? a.applyBrightness(this.dark, e) : void 0
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
contrast(t) {
|
|
147
147
|
if (!this.isFiniteInput(t, "contrast(amount)"))
|
|
148
148
|
return this;
|
|
149
|
-
const e =
|
|
150
|
-
return new
|
|
149
|
+
const e = a.clamp(t, -1, 1);
|
|
150
|
+
return new a({
|
|
151
151
|
name: this.name,
|
|
152
|
-
default:
|
|
153
|
-
light: this.light ?
|
|
154
|
-
dark: this.dark ?
|
|
152
|
+
default: a.applyContrast(this.default, e),
|
|
153
|
+
light: this.light ? a.applyContrast(this.light, e) : void 0,
|
|
154
|
+
dark: this.dark ? a.applyContrast(this.dark, e) : void 0
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
rotateHue(t) {
|
|
158
158
|
if (!this.isFiniteInput(t, "rotateHue(degrees)"))
|
|
159
159
|
return this;
|
|
160
160
|
const e = (t % 360 + 360) % 360;
|
|
161
|
-
return new
|
|
161
|
+
return new a({
|
|
162
162
|
name: this.name,
|
|
163
|
-
default:
|
|
164
|
-
light: this.light ?
|
|
165
|
-
dark: this.dark ?
|
|
163
|
+
default: a.applyHueRotation(this.default, e),
|
|
164
|
+
light: this.light ? a.applyHueRotation(this.light, e) : void 0,
|
|
165
|
+
dark: this.dark ? a.applyHueRotation(this.dark, e) : void 0
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
resolve() {
|
|
169
169
|
const t = x() !== null;
|
|
170
170
|
let e;
|
|
171
|
-
return t ? e =
|
|
171
|
+
return t ? e = S()() : e = a.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
|
|
172
172
|
}
|
|
173
173
|
isFiniteInput(t, e) {
|
|
174
174
|
if (Number.isFinite(t))
|
|
@@ -189,111 +189,111 @@ const E = class n extends b {
|
|
|
189
189
|
return `color-mix(in srgb, ${t} ${r}%, transparent)`;
|
|
190
190
|
}
|
|
191
191
|
static applyAlpha(t, e) {
|
|
192
|
-
const r = t.trim(),
|
|
193
|
-
if (r.match(
|
|
194
|
-
const [f,
|
|
195
|
-
return `rgba(${f}, ${
|
|
192
|
+
const r = t.trim(), n = a.formatAlpha(e);
|
|
193
|
+
if (r.match(a.HEX_REGEX)) {
|
|
194
|
+
const [f, d, m] = a.parseHex(r);
|
|
195
|
+
return `rgba(${f}, ${d}, ${m}, ${n})`;
|
|
196
196
|
}
|
|
197
|
-
const o = r.match(
|
|
197
|
+
const o = r.match(a.RGB_REGEX);
|
|
198
198
|
if (o) {
|
|
199
|
-
const [, f,
|
|
200
|
-
return `rgba(${f}, ${
|
|
199
|
+
const [, f, d, m] = o.map(Number);
|
|
200
|
+
return `rgba(${f}, ${d}, ${m}, ${n})`;
|
|
201
201
|
}
|
|
202
|
-
const c = r.match(
|
|
202
|
+
const c = r.match(a.RGBA_REGEX);
|
|
203
203
|
if (c) {
|
|
204
|
-
const [, f,
|
|
205
|
-
return `rgba(${f}, ${
|
|
204
|
+
const [, f, d, m] = c.map(Number);
|
|
205
|
+
return `rgba(${f}, ${d}, ${m}, ${n})`;
|
|
206
206
|
}
|
|
207
|
-
const l = r.match(
|
|
207
|
+
const l = r.match(a.HSL_REGEX);
|
|
208
208
|
if (l) {
|
|
209
|
-
const [, f,
|
|
210
|
-
return `hsla(${f}, ${
|
|
209
|
+
const [, f, d, m] = l.map(Number);
|
|
210
|
+
return `hsla(${f}, ${d}%, ${m}%, ${n})`;
|
|
211
211
|
}
|
|
212
|
-
const u = r.match(
|
|
212
|
+
const u = r.match(a.HSLA_REGEX);
|
|
213
213
|
if (u) {
|
|
214
|
-
const [, f,
|
|
215
|
-
return `hsla(${f}, ${
|
|
214
|
+
const [, f, d, m] = u.map(Number);
|
|
215
|
+
return `hsla(${f}, ${d}%, ${m}%, ${n})`;
|
|
216
216
|
}
|
|
217
|
-
const h =
|
|
217
|
+
const h = a.NAMED_COLOR_RGB[r.toLowerCase()];
|
|
218
218
|
if (h) {
|
|
219
|
-
const [f,
|
|
220
|
-
return `rgba(${f}, ${
|
|
219
|
+
const [f, d, m] = h;
|
|
220
|
+
return `rgba(${f}, ${d}, ${m}, ${n})`;
|
|
221
221
|
}
|
|
222
|
-
return
|
|
222
|
+
return a.toColorMix(r, e);
|
|
223
223
|
}
|
|
224
224
|
static parseHex(t) {
|
|
225
|
-
const [e, r,
|
|
226
|
-
return [e, r,
|
|
225
|
+
const [e, r, n] = a.parseHexWithAlpha(t);
|
|
226
|
+
return [e, r, n];
|
|
227
227
|
}
|
|
228
228
|
static parseHexWithAlpha(t) {
|
|
229
|
-
const e = t.slice(1), r = e.length === 3 ? e.split("").map((l) => `${l}${l}`).join("") : e.length === 8 ? e.slice(0, 6) : e,
|
|
230
|
-
return [s, o, c,
|
|
229
|
+
const e = t.slice(1), r = e.length === 3 ? e.split("").map((l) => `${l}${l}`).join("") : e.length === 8 ? e.slice(0, 6) : e, n = e.length === 8 ? Number.parseInt(e.slice(6, 8), 16) / 255 : 1, s = Number.parseInt(r.slice(0, 2), 16), o = Number.parseInt(r.slice(2, 4), 16), c = Number.parseInt(r.slice(4, 6), 16);
|
|
230
|
+
return [s, o, c, n];
|
|
231
231
|
}
|
|
232
232
|
static applySaturation(t, e) {
|
|
233
|
-
const r =
|
|
233
|
+
const r = a.parseColorToHsla(t);
|
|
234
234
|
if (!r)
|
|
235
235
|
return t;
|
|
236
|
-
const
|
|
237
|
-
return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${
|
|
236
|
+
const n = e >= 0 ? r.s + (1 - r.s) * e : r.s * (1 + e), s = a.clamp(n, 0, 1), [o, c, l] = a.hslToRgb(r.h, s, r.l);
|
|
237
|
+
return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
|
|
238
238
|
}
|
|
239
239
|
static applyBrightness(t, e) {
|
|
240
|
-
const r =
|
|
240
|
+
const r = a.parseColorToRgba(t);
|
|
241
241
|
if (!r)
|
|
242
242
|
return t;
|
|
243
|
-
const
|
|
243
|
+
const n = (l) => {
|
|
244
244
|
const u = e >= 0 ? l + (255 - l) * e : l * (1 + e);
|
|
245
|
-
return Math.round(
|
|
246
|
-
}, s =
|
|
247
|
-
return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${
|
|
245
|
+
return Math.round(a.clamp(u, 0, 255));
|
|
246
|
+
}, s = n(r.r), o = n(r.g), c = n(r.b);
|
|
247
|
+
return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
|
|
248
248
|
}
|
|
249
249
|
static applyContrast(t, e) {
|
|
250
|
-
const r =
|
|
250
|
+
const r = a.parseColorToRgba(t);
|
|
251
251
|
if (!r)
|
|
252
252
|
return t;
|
|
253
|
-
const
|
|
254
|
-
const f = (u / 255 - 0.5) *
|
|
255
|
-
return Math.round(
|
|
253
|
+
const n = 1 + e, s = (u) => {
|
|
254
|
+
const f = (u / 255 - 0.5) * n + 0.5;
|
|
255
|
+
return Math.round(a.clamp(f, 0, 1) * 255);
|
|
256
256
|
}, o = s(r.r), c = s(r.g), l = s(r.b);
|
|
257
|
-
return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${
|
|
257
|
+
return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
|
|
258
258
|
}
|
|
259
259
|
static applyHueRotation(t, e) {
|
|
260
|
-
const r =
|
|
260
|
+
const r = a.parseColorToHsla(t);
|
|
261
261
|
if (!r)
|
|
262
262
|
return t;
|
|
263
|
-
const
|
|
264
|
-
return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${
|
|
263
|
+
const n = (r.h + e) % 360, [s, o, c] = a.hslToRgb(n, r.s, r.l);
|
|
264
|
+
return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
|
|
265
265
|
}
|
|
266
266
|
static parseColorToRgba(t) {
|
|
267
267
|
const e = t.trim();
|
|
268
|
-
if (
|
|
269
|
-
const [l, u, h, f] =
|
|
268
|
+
if (a.HEX_REGEX.test(e)) {
|
|
269
|
+
const [l, u, h, f] = a.parseHexWithAlpha(e);
|
|
270
270
|
return { r: l, g: u, b: h, a: f };
|
|
271
271
|
}
|
|
272
|
-
const r = e.match(
|
|
272
|
+
const r = e.match(a.RGB_REGEX);
|
|
273
273
|
if (r) {
|
|
274
274
|
const [, l, u, h] = r.map(Number);
|
|
275
275
|
return { r: l, g: u, b: h, a: 1 };
|
|
276
276
|
}
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
279
|
-
const [, l, u, h, f] =
|
|
277
|
+
const n = e.match(a.RGBA_REGEX);
|
|
278
|
+
if (n) {
|
|
279
|
+
const [, l, u, h, f] = n;
|
|
280
280
|
return { r: Number(l), g: Number(u), b: Number(h), a: Number(f) };
|
|
281
281
|
}
|
|
282
|
-
const s = e.match(
|
|
282
|
+
const s = e.match(a.HSL_REGEX);
|
|
283
283
|
if (s) {
|
|
284
|
-
const [, l, u, h] = s.map(Number), [f,
|
|
285
|
-
return { r: f, g:
|
|
284
|
+
const [, l, u, h] = s.map(Number), [f, d, m] = a.hslToRgb(l, u / 100, h / 100);
|
|
285
|
+
return { r: f, g: d, b: m, a: 1 };
|
|
286
286
|
}
|
|
287
|
-
const o = e.match(
|
|
287
|
+
const o = e.match(a.HSLA_REGEX);
|
|
288
288
|
if (o) {
|
|
289
|
-
const [, l, u, h, f] = o, [
|
|
289
|
+
const [, l, u, h, f] = o, [d, m, G] = a.hslToRgb(
|
|
290
290
|
Number(l),
|
|
291
291
|
Number(u) / 100,
|
|
292
292
|
Number(h) / 100
|
|
293
293
|
);
|
|
294
|
-
return { r:
|
|
294
|
+
return { r: d, g: m, b: G, a: Number(f) };
|
|
295
295
|
}
|
|
296
|
-
const c =
|
|
296
|
+
const c = a.NAMED_COLOR_RGB[e.toLowerCase()];
|
|
297
297
|
if (c) {
|
|
298
298
|
const [l, u, h, f] = c;
|
|
299
299
|
return { r: l, g: u, b: h, a: f };
|
|
@@ -301,51 +301,51 @@ const E = class n extends b {
|
|
|
301
301
|
return null;
|
|
302
302
|
}
|
|
303
303
|
static parseColorToHsla(t) {
|
|
304
|
-
const e = t.trim(), r = e.match(
|
|
304
|
+
const e = t.trim(), r = e.match(a.HSL_REGEX);
|
|
305
305
|
if (r) {
|
|
306
306
|
const [, u, h, f] = r.map(Number);
|
|
307
307
|
return { h: u, s: h / 100, l: f / 100, a: 1 };
|
|
308
308
|
}
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
const [, u, h, f,
|
|
309
|
+
const n = e.match(a.HSLA_REGEX);
|
|
310
|
+
if (n) {
|
|
311
|
+
const [, u, h, f, d] = n;
|
|
312
312
|
return {
|
|
313
313
|
h: Number(u),
|
|
314
314
|
s: Number(h) / 100,
|
|
315
315
|
l: Number(f) / 100,
|
|
316
|
-
a: Number(
|
|
316
|
+
a: Number(d)
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
-
const s =
|
|
319
|
+
const s = a.parseColorToRgba(e);
|
|
320
320
|
if (!s)
|
|
321
321
|
return null;
|
|
322
|
-
const [o, c, l] =
|
|
322
|
+
const [o, c, l] = a.rgbToHsl(s.r, s.g, s.b);
|
|
323
323
|
return { h: o, s: c, l, a: s.a };
|
|
324
324
|
}
|
|
325
325
|
static rgbToHsl(t, e, r) {
|
|
326
|
-
const
|
|
326
|
+
const n = t / 255, s = e / 255, o = r / 255, c = Math.max(n, s, o), l = Math.min(n, s, o), u = c - l;
|
|
327
327
|
let h = 0;
|
|
328
|
-
const f = (c + l) / 2,
|
|
329
|
-
return u !== 0 && (c ===
|
|
328
|
+
const f = (c + l) / 2, d = u === 0 ? 0 : u / (1 - Math.abs(2 * f - 1));
|
|
329
|
+
return u !== 0 && (c === n ? h = (s - o) / u % 6 : c === s ? h = (o - n) / u + 2 : h = (n - s) / u + 4, h *= 60, h < 0 && (h += 360)), [h, d, f];
|
|
330
330
|
}
|
|
331
331
|
static hslToRgb(t, e, r) {
|
|
332
|
-
const
|
|
332
|
+
const n = (t % 360 + 360) % 360, s = (1 - Math.abs(2 * r - 1)) * e, o = s * (1 - Math.abs(n / 60 % 2 - 1)), c = r - s / 2;
|
|
333
333
|
let l = 0, u = 0, h = 0;
|
|
334
|
-
|
|
335
|
-
const f = Math.round((l + c) * 255),
|
|
336
|
-
return [f,
|
|
334
|
+
n < 60 ? (l = s, u = o) : n < 120 ? (l = o, u = s) : n < 180 ? (u = s, h = o) : n < 240 ? (u = o, h = s) : n < 300 ? (l = o, h = s) : (l = s, h = o);
|
|
335
|
+
const f = Math.round((l + c) * 255), d = Math.round((u + c) * 255), m = Math.round((h + c) * 255);
|
|
336
|
+
return [f, d, m];
|
|
337
337
|
}
|
|
338
338
|
static rgbToHex(t, e, r) {
|
|
339
|
-
const
|
|
340
|
-
return `#${
|
|
339
|
+
const n = (s) => s.toString(16).padStart(2, "0");
|
|
340
|
+
return `#${n(t)}${n(e)}${n(r)}`.toUpperCase();
|
|
341
341
|
}
|
|
342
342
|
};
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
y(E, "HEX_REGEX", /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/);
|
|
344
|
+
y(E, "RGB_REGEX", /^rgb\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)$/i);
|
|
345
|
+
y(E, "RGBA_REGEX", /^rgba\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
|
|
346
|
+
y(E, "HSL_REGEX", /^hsl\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*\)$/i);
|
|
347
|
+
y(E, "HSLA_REGEX", /^hsla\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
|
|
348
|
+
y(E, "NAMED_COLOR_RGB", {
|
|
349
349
|
transparent: [0, 0, 0, 0],
|
|
350
350
|
black: [0, 0, 0, 1],
|
|
351
351
|
white: [255, 255, 255, 1],
|
|
@@ -371,10 +371,10 @@ p(E, "NAMED_COLOR_RGB", {
|
|
|
371
371
|
fuchsia: [255, 0, 255, 1]
|
|
372
372
|
});
|
|
373
373
|
let g = E;
|
|
374
|
-
var
|
|
375
|
-
class F extends
|
|
374
|
+
var L = Object.defineProperty, P = (i, t, e) => t in i ? L(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, A = (i, t, e) => P(i, typeof t != "symbol" ? t + "" : t, e);
|
|
375
|
+
class F extends p {
|
|
376
376
|
constructor(t) {
|
|
377
|
-
if (super(t.name),
|
|
377
|
+
if (super(t.name), A(this, "default"), A(this, "light"), A(this, "dark"), A(this, "alt"), A(this, "placeholder"), !t.default)
|
|
378
378
|
throw new Error(`ImageAsset "${t.name}" must specify a default image path`);
|
|
379
379
|
this.default = t.default, this.light = t.light, this.dark = t.dark, this.alt = t.options?.alt, this.placeholder = t.options?.placeholder;
|
|
380
380
|
}
|
|
@@ -382,12 +382,12 @@ class F extends b {
|
|
|
382
382
|
return new F(t);
|
|
383
383
|
}
|
|
384
384
|
static getCurrentTheme() {
|
|
385
|
-
return
|
|
385
|
+
return C();
|
|
386
386
|
}
|
|
387
387
|
resolve() {
|
|
388
388
|
const t = x() !== null;
|
|
389
389
|
let e;
|
|
390
|
-
return t ? e =
|
|
390
|
+
return t ? e = S()() : e = F.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
|
|
391
391
|
}
|
|
392
392
|
// Additional accessors
|
|
393
393
|
get src() {
|
|
@@ -403,21 +403,21 @@ class F extends b {
|
|
|
403
403
|
return this.default;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
var
|
|
407
|
-
class w extends
|
|
408
|
-
constructor(t, e = [], r = "",
|
|
409
|
-
super(r || t),
|
|
406
|
+
var X = Object.defineProperty, T = (i, t, e) => t in i ? X(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, v = (i, t, e) => T(i, typeof t != "symbol" ? t + "" : t, e);
|
|
407
|
+
class w extends p {
|
|
408
|
+
constructor(t, e = [], r = "", n = {}) {
|
|
409
|
+
super(r || t), v(this, "family"), v(this, "fallbacks"), v(this, "options"), v(this, "loaded", !1), v(this, "loadPromise", null), this.family = t, this.fallbacks = e, this.options = {
|
|
410
410
|
loading: "lazy",
|
|
411
411
|
fontDisplay: "swap",
|
|
412
412
|
preconnect: !0,
|
|
413
|
-
...
|
|
413
|
+
...n
|
|
414
414
|
}, this.options.loading === "eager" && this.load();
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* Static factory method for SwiftUI-style initialization
|
|
418
418
|
*/
|
|
419
|
-
static init(t, e = [], r,
|
|
420
|
-
return new w(t, e, r,
|
|
419
|
+
static init(t, e = [], r, n = {}) {
|
|
420
|
+
return new w(t, e, r, n);
|
|
421
421
|
}
|
|
422
422
|
/**
|
|
423
423
|
* Get the full font-family CSS value including fallbacks
|
|
@@ -443,18 +443,18 @@ class w extends b {
|
|
|
443
443
|
if (t) {
|
|
444
444
|
if (e && typeof document < "u" && document.querySelector)
|
|
445
445
|
try {
|
|
446
|
-
const
|
|
447
|
-
if (!document.querySelector(`link[rel="preconnect"][href="${
|
|
446
|
+
const n = new URL(t).origin;
|
|
447
|
+
if (!document.querySelector(`link[rel="preconnect"][href="${n}"]`)) {
|
|
448
448
|
const s = document.createElement("link");
|
|
449
|
-
s.rel = "preconnect", s.href =
|
|
449
|
+
s.rel = "preconnect", s.href = n, s.crossOrigin = "anonymous", document.head.appendChild(s);
|
|
450
450
|
}
|
|
451
451
|
} catch {
|
|
452
452
|
}
|
|
453
453
|
if (t.endsWith(".css") || t.includes("fonts.googleapis.com") ? await this.loadFontCSS(t) : await this.loadFontFile(t), "fonts" in document)
|
|
454
454
|
try {
|
|
455
455
|
await document.fonts.ready;
|
|
456
|
-
const
|
|
457
|
-
document.fonts.check(
|
|
456
|
+
const n = `16px ${this.family.includes(" ") ? `"${this.family}"` : this.family}`;
|
|
457
|
+
document.fonts.check(n) || console.warn(`⚠️ Font "${this.family}" may not have loaded correctly`);
|
|
458
458
|
} catch {
|
|
459
459
|
}
|
|
460
460
|
}
|
|
@@ -480,7 +480,7 @@ class w extends b {
|
|
|
480
480
|
* Load a font file directly and create @font-face rule
|
|
481
481
|
*/
|
|
482
482
|
async loadFontFile(t) {
|
|
483
|
-
const { fontFormat: e, fontDisplay: r, weightRange:
|
|
483
|
+
const { fontFormat: e, fontDisplay: r, weightRange: n, widthRange: s } = this.options;
|
|
484
484
|
let o = "";
|
|
485
485
|
e ? o = `format('${e}')` : t.endsWith(".woff2") ? o = "format('woff2')" : t.endsWith(".woff") ? o = "format('woff')" : t.endsWith(".ttf") && (o = "format('truetype')");
|
|
486
486
|
let c = `
|
|
@@ -489,7 +489,7 @@ class w extends b {
|
|
|
489
489
|
src: url("${t}") ${o};
|
|
490
490
|
font-display: ${r || "swap"};
|
|
491
491
|
`;
|
|
492
|
-
|
|
492
|
+
n && (c += `font-weight: ${n[0]} ${n[1]};
|
|
493
493
|
`), s && (c += `font-stretch: ${s[0]}% ${s[1]}%;
|
|
494
494
|
`), c += "}";
|
|
495
495
|
const l = document.createElement("style");
|
|
@@ -497,7 +497,7 @@ class w extends b {
|
|
|
497
497
|
try {
|
|
498
498
|
const u = new FontFace(this.family, `url(${t})`, {
|
|
499
499
|
display: r || "swap",
|
|
500
|
-
weight:
|
|
500
|
+
weight: n ? `${n[0]} ${n[1]}` : void 0,
|
|
501
501
|
stretch: s ? `${s[0]}% ${s[1]}%` : void 0
|
|
502
502
|
});
|
|
503
503
|
await u.load(), document.fonts.add(u);
|
|
@@ -523,7 +523,7 @@ class w extends b {
|
|
|
523
523
|
return this.options.loading === "lazy" && !this.loaded && this.options.fontUrl && this.load(), this.value;
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
const
|
|
526
|
+
const q = {
|
|
527
527
|
ultraLight: 100,
|
|
528
528
|
thin: 200,
|
|
529
529
|
light: 300,
|
|
@@ -533,7 +533,7 @@ const D = {
|
|
|
533
533
|
bold: 700,
|
|
534
534
|
heavy: 800,
|
|
535
535
|
black: 900
|
|
536
|
-
},
|
|
536
|
+
}, z = {
|
|
537
537
|
ultraCondensed: 50,
|
|
538
538
|
extraCondensed: 62.5,
|
|
539
539
|
condensed: 75,
|
|
@@ -550,11 +550,11 @@ const D = {
|
|
|
550
550
|
cursive: ["cursive"],
|
|
551
551
|
fantasy: ["fantasy"]
|
|
552
552
|
};
|
|
553
|
-
function
|
|
553
|
+
function U(i = "sansSerif", t) {
|
|
554
554
|
return new w("", [...R[i]], t || `system-${i}`);
|
|
555
555
|
}
|
|
556
|
-
function
|
|
557
|
-
const
|
|
556
|
+
function j(i, t = [400], e, r = {}) {
|
|
557
|
+
const n = t.join(";"), o = `https://fonts.googleapis.com/css2?family=${i.replace(/\s+/g, "+")}:wght@${n}&display=swap`;
|
|
558
558
|
return new w(
|
|
559
559
|
i,
|
|
560
560
|
[...R.sansSerif],
|
|
@@ -566,9 +566,9 @@ function U(i, t = [400], e, r = {}) {
|
|
|
566
566
|
}
|
|
567
567
|
);
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function K(i, t, e, r = [...R.sansSerif], n) {
|
|
570
570
|
const s = {};
|
|
571
|
-
return e.slant && (s.slnt = e.slant), e.optical && (s.opsz = e.optical), e.custom && Object.assign(s, e.custom), new w(i, r,
|
|
571
|
+
return e.slant && (s.slnt = e.slant), e.optical && (s.opsz = e.optical), e.custom && Object.assign(s, e.custom), new w(i, r, n, {
|
|
572
572
|
fontUrl: t,
|
|
573
573
|
weightRange: e.weight,
|
|
574
574
|
widthRange: e.width,
|
|
@@ -576,10 +576,10 @@ function j(i, t, e, r = [...R.sansSerif], a) {
|
|
|
576
576
|
fontDisplay: "swap"
|
|
577
577
|
});
|
|
578
578
|
}
|
|
579
|
-
var
|
|
580
|
-
class
|
|
579
|
+
var B = Object.defineProperty, V = (i, t, e) => t in i ? B(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, I = (i, t, e) => V(i, t + "", e);
|
|
580
|
+
class O {
|
|
581
581
|
constructor() {
|
|
582
|
-
|
|
582
|
+
I(this, "assets", /* @__PURE__ */ new Map());
|
|
583
583
|
}
|
|
584
584
|
add(t, e) {
|
|
585
585
|
this.assets.set(t, e);
|
|
@@ -601,14 +601,14 @@ class V {
|
|
|
601
601
|
const r = this.assets.get(e);
|
|
602
602
|
if (r)
|
|
603
603
|
return r instanceof g ? new Proxy(r, {
|
|
604
|
-
get: (
|
|
605
|
-
has: (
|
|
604
|
+
get: (n, s) => s === "light" || s === "dark" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
|
|
605
|
+
has: (n, s) => s === "resolve" ? !0 : s in n
|
|
606
606
|
}) : r instanceof F ? new Proxy(r, {
|
|
607
|
-
get: (
|
|
608
|
-
has: (
|
|
607
|
+
get: (n, s) => s === "lightSrc" || s === "darkSrc" || s === "src" || s === "defaultSrc" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
|
|
608
|
+
has: (n, s) => s === "resolve" ? !0 : s in n
|
|
609
609
|
}) : r instanceof w ? new Proxy(r, {
|
|
610
|
-
get: (
|
|
611
|
-
has: (
|
|
610
|
+
get: (n, s) => s === "family" || s === "fallbacks" || s === "options" ? n[s] : s === "resolve" ? () => n.resolve() : s === "toString" || s === "valueOf" ? () => n.resolve() : n[s],
|
|
611
|
+
has: (n, s) => s === "resolve" ? !0 : s in n
|
|
612
612
|
}) : r;
|
|
613
613
|
},
|
|
614
614
|
// Add ownKeys handler to support Object.keys() enumeration
|
|
@@ -619,29 +619,29 @@ class V {
|
|
|
619
619
|
);
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
const
|
|
623
|
-
function
|
|
622
|
+
const b = new O(), N = b.asProxy(), J = N;
|
|
623
|
+
function $(...i) {
|
|
624
624
|
if (i.length === 0)
|
|
625
625
|
throw new Error("registerAsset requires at least one argument");
|
|
626
626
|
const t = i[0], e = i[1];
|
|
627
|
-
if (typeof t == "string" && e instanceof
|
|
628
|
-
return
|
|
629
|
-
if (t instanceof
|
|
630
|
-
return
|
|
631
|
-
if (t instanceof
|
|
632
|
-
return
|
|
633
|
-
if (t instanceof
|
|
634
|
-
return
|
|
635
|
-
if (t instanceof
|
|
627
|
+
if (typeof t == "string" && e instanceof p && i.length === 2)
|
|
628
|
+
return b.add(t, e), e;
|
|
629
|
+
if (t instanceof p && typeof e == "string" && i.length === 2)
|
|
630
|
+
return b.add(e, t), t;
|
|
631
|
+
if (t instanceof p && i.length === 1)
|
|
632
|
+
return b.add(t.name, t), t;
|
|
633
|
+
if (t instanceof p && e === void 0 && i.length === 2)
|
|
634
|
+
return b.add(t.name, t), t;
|
|
635
|
+
if (t instanceof p && i.length > 1) {
|
|
636
636
|
const r = [];
|
|
637
|
-
i.forEach((
|
|
638
|
-
if (!(
|
|
637
|
+
i.forEach((n, s) => {
|
|
638
|
+
if (!(n instanceof p))
|
|
639
639
|
throw new Error(
|
|
640
640
|
`registerAsset variadic argument at index ${s} must be an Asset`
|
|
641
641
|
);
|
|
642
|
-
r.push(
|
|
643
|
-
}), r.forEach((
|
|
644
|
-
|
|
642
|
+
r.push(n);
|
|
643
|
+
}), r.forEach((n) => {
|
|
644
|
+
b.add(n.name, n);
|
|
645
645
|
});
|
|
646
646
|
return;
|
|
647
647
|
} else
|
|
@@ -649,7 +649,7 @@ function y(...i) {
|
|
|
649
649
|
"registerAsset requires either (name, asset), (asset), (asset, overrideName), or (...assets)"
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Q(i, t, e = "") {
|
|
653
653
|
return g.init({
|
|
654
654
|
default: i,
|
|
655
655
|
light: i,
|
|
@@ -657,100 +657,124 @@ function J(i, t, e = "") {
|
|
|
657
657
|
name: e
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function Y(i, t, e, r = "", n) {
|
|
661
661
|
return F.init({
|
|
662
662
|
default: i,
|
|
663
663
|
light: t,
|
|
664
664
|
dark: e,
|
|
665
665
|
name: r,
|
|
666
|
-
options:
|
|
666
|
+
options: n
|
|
667
667
|
});
|
|
668
668
|
}
|
|
669
|
-
function
|
|
669
|
+
function Z(i, t = [], e = "", r) {
|
|
670
670
|
return w.init(i, t, e, r);
|
|
671
671
|
}
|
|
672
|
-
function
|
|
673
|
-
const i =
|
|
672
|
+
function _() {
|
|
673
|
+
const i = b.getAll(), t = [];
|
|
674
674
|
for (const [e, r] of i) {
|
|
675
|
-
let
|
|
676
|
-
r instanceof g ?
|
|
675
|
+
let n = "custom";
|
|
676
|
+
r instanceof g ? n = "color" : r instanceof F ? n = "image" : r instanceof w && (n = "font"), t.push({
|
|
677
677
|
name: e,
|
|
678
|
-
type:
|
|
678
|
+
type: n,
|
|
679
679
|
asset: r
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
return t.sort((e, r) => e.name.localeCompare(r.name));
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
return
|
|
684
|
+
function tt(i) {
|
|
685
|
+
return b.get(i);
|
|
686
|
+
}
|
|
687
|
+
function k(i) {
|
|
688
|
+
if (i instanceof g)
|
|
689
|
+
return !0;
|
|
690
|
+
if (!i || typeof i != "object")
|
|
691
|
+
return !1;
|
|
692
|
+
const t = i;
|
|
693
|
+
return typeof t.resolve == "function" && typeof t.opacity == "function" && typeof t.saturate == "function" && typeof t.brighten == "function" && typeof t.contrast == "function" && typeof t.rotateHue == "function";
|
|
694
|
+
}
|
|
695
|
+
function et(i) {
|
|
696
|
+
const t = N[i];
|
|
697
|
+
return k(t) ? t : void 0;
|
|
698
|
+
}
|
|
699
|
+
function rt(i, t = "asset") {
|
|
700
|
+
if (!k(i))
|
|
701
|
+
throw new Error(`Asset "${t}" is not a ColorAsset`);
|
|
702
|
+
return i;
|
|
703
|
+
}
|
|
704
|
+
function st() {
|
|
705
|
+
return Array.from(b.getAll().keys()).sort();
|
|
686
706
|
}
|
|
687
|
-
|
|
707
|
+
$(g.init({
|
|
688
708
|
default: "#007AFF",
|
|
689
709
|
light: "#007AFF",
|
|
690
710
|
dark: "#0A84FF",
|
|
691
711
|
name: "systemBlue"
|
|
692
712
|
}));
|
|
693
|
-
|
|
713
|
+
$(g.init({
|
|
694
714
|
default: "#34C759",
|
|
695
715
|
light: "#34C759",
|
|
696
716
|
dark: "#30D158",
|
|
697
717
|
name: "systemGreen"
|
|
698
718
|
}));
|
|
699
|
-
|
|
719
|
+
$(g.init({
|
|
700
720
|
default: "#FF3B30",
|
|
701
721
|
light: "#FF3B30",
|
|
702
722
|
dark: "#FF453A",
|
|
703
723
|
name: "systemRed"
|
|
704
724
|
}));
|
|
705
|
-
|
|
725
|
+
$(g.init({
|
|
706
726
|
default: "#FF9500",
|
|
707
727
|
light: "#FF9500",
|
|
708
728
|
dark: "#FF9F0A",
|
|
709
729
|
name: "systemOrange"
|
|
710
730
|
}));
|
|
711
|
-
|
|
731
|
+
$(g.init({
|
|
712
732
|
default: "#5856D6",
|
|
713
733
|
light: "#5856D6",
|
|
714
734
|
dark: "#5E5CE6",
|
|
715
735
|
name: "systemPurple"
|
|
716
736
|
}));
|
|
717
|
-
|
|
737
|
+
$(g.init({
|
|
718
738
|
default: "#FF2D55",
|
|
719
739
|
light: "#FF2D55",
|
|
720
740
|
dark: "#FF375F",
|
|
721
741
|
name: "systemPink"
|
|
722
742
|
}));
|
|
723
|
-
|
|
743
|
+
$(g.init({
|
|
724
744
|
default: "#8E8E93",
|
|
725
745
|
name: "systemGray"
|
|
726
746
|
}));
|
|
727
|
-
|
|
747
|
+
$(g.init({
|
|
728
748
|
default: "#000000",
|
|
729
749
|
name: "systemBlack"
|
|
730
750
|
}));
|
|
731
|
-
|
|
751
|
+
$(g.init({
|
|
732
752
|
default: "#FFFFFF",
|
|
733
753
|
name: "systemWhite"
|
|
734
754
|
}));
|
|
735
755
|
export {
|
|
736
|
-
|
|
737
|
-
|
|
756
|
+
p as Asset,
|
|
757
|
+
J as Assets,
|
|
738
758
|
g as ColorAsset,
|
|
739
759
|
w as FontAsset,
|
|
740
|
-
|
|
741
|
-
|
|
760
|
+
q as FontWeight,
|
|
761
|
+
z as FontWidth,
|
|
742
762
|
F as ImageAsset,
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
763
|
+
it as LinearGradient,
|
|
764
|
+
ot as RadialGradient,
|
|
765
|
+
lt as StateGradient,
|
|
746
766
|
R as SystemFonts,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
767
|
+
rt as asColorAsset,
|
|
768
|
+
Q as createColorAsset,
|
|
769
|
+
Z as createFontAsset,
|
|
770
|
+
j as createGoogleFont,
|
|
771
|
+
Y as createImageAsset,
|
|
772
|
+
U as createSystemFont,
|
|
773
|
+
K as createVariableFont,
|
|
774
|
+
tt as getAsset,
|
|
775
|
+
_ as getAssetInfo,
|
|
776
|
+
et as getColorAsset,
|
|
777
|
+
k as isColorAsset,
|
|
778
|
+
st as listAssetNames,
|
|
779
|
+
$ as registerAsset
|
|
756
780
|
};
|