@tachui/core 0.8.25 → 0.8.26

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.
Files changed (45) hide show
  1. package/dist/assets/ColorAsset.d.ts +1 -0
  2. package/dist/assets/ColorAsset.d.ts.map +1 -1
  3. package/dist/assets/FontAsset.d.ts +3 -0
  4. package/dist/assets/FontAsset.d.ts.map +1 -1
  5. package/dist/assets/ImageAsset.d.ts.map +1 -1
  6. package/dist/assets/index.d.ts +1 -0
  7. package/dist/assets/index.d.ts.map +1 -1
  8. package/dist/assets/index.js +196 -132
  9. package/dist/assets/ssr-context.d.ts +8 -0
  10. package/dist/assets/ssr-context.d.ts.map +1 -0
  11. package/dist/{binding-DCr-JHsC.js → binding-DNl4QUbT.js} +1 -1
  12. package/dist/common.js +388 -386
  13. package/dist/{component-BzvSm8rM.js → component-DR1wgdPH.js} +66 -69
  14. package/dist/{component-context-C7Y6Xu6h.js → component-context-BB80qzyZ.js} +66 -44
  15. package/dist/components/index.js +1 -1
  16. package/dist/{concatenated-component-CA54ng_j.js → concatenated-component-DisxEqg6.js} +123 -113
  17. package/dist/essential.js +390 -388
  18. package/dist/{factory-B1YXfgU1.js → factory-C2LUc2BF.js} +2 -2
  19. package/dist/full.js +390 -388
  20. package/dist/{index-CmQmIgPK.js → index-B1zQAJuG.js} +91 -89
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +390 -388
  24. package/dist/minimal-prod.js +2 -2
  25. package/dist/minimal.js +4 -4
  26. package/dist/modifiers/base.d.ts +17 -0
  27. package/dist/modifiers/base.d.ts.map +1 -1
  28. package/dist/modifiers/base.js +97 -67
  29. package/dist/modifiers/builder.js +1 -1
  30. package/dist/modifiers/index.js +2 -2
  31. package/dist/modifiers/registry.js +1 -1
  32. package/dist/{observed-object-DCoyucmV.js → observed-object-gKl1Kk85.js} +1 -1
  33. package/dist/{optimization-D9t53vNJ.js → optimization-CnRxoggr.js} +1 -1
  34. package/dist/{proxy-B7ZIqGd0.js → proxy-B6FFddJq.js} +1 -1
  35. package/dist/runtime/component-context.d.ts +2 -0
  36. package/dist/runtime/component-context.d.ts.map +1 -1
  37. package/dist/runtime/component.d.ts.map +1 -1
  38. package/dist/runtime/dom-bridge.js +2 -2
  39. package/dist/runtime/index.js +4 -4
  40. package/dist/runtime/lazy-component.d.ts.map +1 -1
  41. package/dist/runtime/renderer.d.ts.map +1 -1
  42. package/dist/runtime/renderer.js +1 -1
  43. package/dist/state/index.js +5 -5
  44. package/dist/version.js +1 -1
  45. package/package.json +3 -3
@@ -1,9 +1,22 @@
1
1
  import { A as p } from "../index-7vhCZc7g.js";
2
- import { L as ot, R as lt, k as ct } from "../index-7vhCZc7g.js";
3
- import { g as C, a as S } from "../theme-D5-09a8N.js";
4
- import { h as x } from "../signal-BRoiFOO7.js";
2
+ import { L as ut, R as ft, k as ht } from "../index-7vhCZc7g.js";
3
+ import { g as k, a as H } from "../theme-D5-09a8N.js";
4
+ import { h as N } from "../signal-BRoiFOO7.js";
5
5
  export * from "@tachui/types/assets";
6
- 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 S = Symbol.for("tachui.ssr.assetHeadCollector");
7
+ function C() {
8
+ return globalThis[S];
9
+ }
10
+ function j(i, t) {
11
+ const e = globalThis, r = e[S];
12
+ i ? e[S] = i : delete e[S];
13
+ try {
14
+ return t();
15
+ } finally {
16
+ r ? e[S] = r : delete e[S];
17
+ }
18
+ }
19
+ var M = Object.defineProperty, T = (i, t, e) => t in i ? M(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, y = (i, t, e) => T(i, typeof t != "symbol" ? t + "" : t, e);
7
20
  const E = class a extends p {
8
21
  constructor(t) {
9
22
  if (super(t.name), y(this, "default"), y(this, "light"), y(this, "dark"), !t.default)
@@ -48,29 +61,29 @@ const E = class a extends p {
48
61
  if (a.HEX_REGEX.test(e))
49
62
  return { isValid: !0, format: "hex" };
50
63
  if (a.RGB_REGEX.test(e)) {
51
- const n = e.match(a.RGB_REGEX), [, s, o, c] = n.map(Number);
52
- return s <= 255 && o <= 255 && c <= 255 ? { isValid: !0, format: "rgb" } : {
64
+ const n = e.match(a.RGB_REGEX), [, s, o, l] = n.map(Number);
65
+ return s <= 255 && o <= 255 && l <= 255 ? { isValid: !0, format: "rgb" } : {
53
66
  isValid: !1,
54
67
  error: "RGB values must be between 0 and 255"
55
68
  };
56
69
  }
57
70
  if (a.RGBA_REGEX.test(e)) {
58
- const n = e.match(a.RGBA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
59
- return u <= 255 && h <= 255 && f <= 255 && d >= 0 && d <= 1 ? { isValid: !0, format: "rgba" } : {
71
+ const n = e.match(a.RGBA_REGEX), [, s, o, l, c] = n, u = Number(s), f = Number(o), h = Number(l), d = Number(c);
72
+ return u <= 255 && f <= 255 && h <= 255 && d >= 0 && d <= 1 ? { isValid: !0, format: "rgba" } : {
60
73
  isValid: !1,
61
74
  error: "RGBA values must be: RGB 0-255, alpha 0-1"
62
75
  };
63
76
  }
64
77
  if (a.HSL_REGEX.test(e)) {
65
- const n = e.match(a.HSL_REGEX), [, s, o, c] = n.map(Number);
66
- return s <= 360 && o <= 100 && c <= 100 ? { isValid: !0, format: "hsl" } : {
78
+ const n = e.match(a.HSL_REGEX), [, s, o, l] = n.map(Number);
79
+ return s <= 360 && o <= 100 && l <= 100 ? { isValid: !0, format: "hsl" } : {
67
80
  isValid: !1,
68
81
  error: "HSL values must be: H 0-360, S/L 0-100%"
69
82
  };
70
83
  }
71
84
  if (a.HSLA_REGEX.test(e)) {
72
- const n = e.match(a.HSLA_REGEX), [, s, o, c, l] = n, u = Number(s), h = Number(o), f = Number(c), d = Number(l);
73
- return u <= 360 && h <= 100 && f <= 100 && d >= 0 && d <= 1 ? { isValid: !0, format: "hsla" } : {
85
+ const n = e.match(a.HSLA_REGEX), [, s, o, l, c] = n, u = Number(s), f = Number(o), h = Number(l), d = Number(c);
86
+ return u <= 360 && f <= 100 && h <= 100 && d >= 0 && d <= 1 ? { isValid: !0, format: "hsla" } : {
74
87
  isValid: !1,
75
88
  error: "HSLA values must be: H 0-360, S/L 0-100%, alpha 0-1"
76
89
  };
@@ -109,7 +122,7 @@ const E = class a extends p {
109
122
  };
110
123
  }
111
124
  static getCurrentTheme() {
112
- return C();
125
+ return k();
113
126
  }
114
127
  opacity(t) {
115
128
  if (!this.isFiniteInput(t, "opacity(alpha)"))
@@ -167,9 +180,15 @@ const E = class a extends p {
167
180
  });
168
181
  }
169
182
  resolve() {
170
- const t = x() !== null;
183
+ const t = N() !== null;
171
184
  let e;
172
- return t ? e = S()() : e = a.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
185
+ t ? e = H()() : e = a.getCurrentTheme();
186
+ const r = C();
187
+ return r && r.addStyle(this.toSSRVariableBlock()), e === "dark" ? this.dark || this.default : this.light || this.default;
188
+ }
189
+ toSSRVariableBlock() {
190
+ const t = `--tachui-color-${this.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "asset"}`, e = this.light || this.default, r = this.dark || this.default;
191
+ return `:root{${t}:${e};}@media (prefers-color-scheme: dark){:root{${t}:${r};}}`;
173
192
  }
174
193
  isFiniteInput(t, e) {
175
194
  if (Number.isFinite(t))
@@ -192,33 +211,33 @@ const E = class a extends p {
192
211
  static applyAlpha(t, e) {
193
212
  const r = t.trim(), n = a.formatAlpha(e);
194
213
  if (r.match(a.HEX_REGEX)) {
195
- const [f, d, m] = a.parseHex(r);
196
- return `rgba(${f}, ${d}, ${m}, ${n})`;
214
+ const [h, d, m] = a.parseHex(r);
215
+ return `rgba(${h}, ${d}, ${m}, ${n})`;
197
216
  }
198
217
  const o = r.match(a.RGB_REGEX);
199
218
  if (o) {
200
- const [, f, d, m] = o.map(Number);
201
- return `rgba(${f}, ${d}, ${m}, ${n})`;
219
+ const [, h, d, m] = o.map(Number);
220
+ return `rgba(${h}, ${d}, ${m}, ${n})`;
202
221
  }
203
- const c = r.match(a.RGBA_REGEX);
204
- if (c) {
205
- const [, f, d, m] = c.map(Number);
206
- return `rgba(${f}, ${d}, ${m}, ${n})`;
207
- }
208
- const l = r.match(a.HSL_REGEX);
222
+ const l = r.match(a.RGBA_REGEX);
209
223
  if (l) {
210
- const [, f, d, m] = l.map(Number);
211
- return `hsla(${f}, ${d}%, ${m}%, ${n})`;
224
+ const [, h, d, m] = l.map(Number);
225
+ return `rgba(${h}, ${d}, ${m}, ${n})`;
226
+ }
227
+ const c = r.match(a.HSL_REGEX);
228
+ if (c) {
229
+ const [, h, d, m] = c.map(Number);
230
+ return `hsla(${h}, ${d}%, ${m}%, ${n})`;
212
231
  }
213
232
  const u = r.match(a.HSLA_REGEX);
214
233
  if (u) {
215
- const [, f, d, m] = u.map(Number);
216
- return `hsla(${f}, ${d}%, ${m}%, ${n})`;
234
+ const [, h, d, m] = u.map(Number);
235
+ return `hsla(${h}, ${d}%, ${m}%, ${n})`;
217
236
  }
218
- const h = a.NAMED_COLOR_RGB[r.toLowerCase()];
219
- if (h) {
220
- const [f, d, m] = h;
221
- return `rgba(${f}, ${d}, ${m}, ${n})`;
237
+ const f = a.NAMED_COLOR_RGB[r.toLowerCase()];
238
+ if (f) {
239
+ const [h, d, m] = f;
240
+ return `rgba(${h}, ${d}, ${m}, ${n})`;
222
241
  }
223
242
  return a.toColorMix(r, e);
224
243
  }
@@ -227,114 +246,114 @@ const E = class a extends p {
227
246
  return [e, r, n];
228
247
  }
229
248
  static parseHexWithAlpha(t) {
230
- 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);
231
- return [s, o, c, n];
249
+ const e = t.slice(1), r = e.length === 3 ? e.split("").map((c) => `${c}${c}`).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), l = Number.parseInt(r.slice(4, 6), 16);
250
+ return [s, o, l, n];
232
251
  }
233
252
  static applySaturation(t, e) {
234
253
  const r = a.parseColorToHsla(t);
235
254
  if (!r)
236
255
  return t;
237
- 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);
238
- return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
256
+ const n = e >= 0 ? r.s + (1 - r.s) * e : r.s * (1 + e), s = a.clamp(n, 0, 1), [o, l, c] = a.hslToRgb(r.h, s, r.l);
257
+ return r.a < 1 ? `rgba(${o}, ${l}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, l, c);
239
258
  }
240
259
  static applyBrightness(t, e) {
241
260
  const r = a.parseColorToRgba(t);
242
261
  if (!r)
243
262
  return t;
244
- const n = (l) => {
245
- const u = e >= 0 ? l + (255 - l) * e : l * (1 + e);
263
+ const n = (c) => {
264
+ const u = e >= 0 ? c + (255 - c) * e : c * (1 + e);
246
265
  return Math.round(a.clamp(u, 0, 255));
247
- }, s = n(r.r), o = n(r.g), c = n(r.b);
248
- return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
266
+ }, s = n(r.r), o = n(r.g), l = n(r.b);
267
+ return r.a < 1 ? `rgba(${s}, ${o}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, l);
249
268
  }
250
269
  static applyContrast(t, e) {
251
270
  const r = a.parseColorToRgba(t);
252
271
  if (!r)
253
272
  return t;
254
273
  const n = 1 + e, s = (u) => {
255
- const f = (u / 255 - 0.5) * n + 0.5;
256
- return Math.round(a.clamp(f, 0, 1) * 255);
257
- }, o = s(r.r), c = s(r.g), l = s(r.b);
258
- return r.a < 1 ? `rgba(${o}, ${c}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, c, l);
274
+ const h = (u / 255 - 0.5) * n + 0.5;
275
+ return Math.round(a.clamp(h, 0, 1) * 255);
276
+ }, o = s(r.r), l = s(r.g), c = s(r.b);
277
+ return r.a < 1 ? `rgba(${o}, ${l}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(o, l, c);
259
278
  }
260
279
  static applyHueRotation(t, e) {
261
280
  const r = a.parseColorToHsla(t);
262
281
  if (!r)
263
282
  return t;
264
- const n = (r.h + e) % 360, [s, o, c] = a.hslToRgb(n, r.s, r.l);
265
- return r.a < 1 ? `rgba(${s}, ${o}, ${c}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, c);
283
+ const n = (r.h + e) % 360, [s, o, l] = a.hslToRgb(n, r.s, r.l);
284
+ return r.a < 1 ? `rgba(${s}, ${o}, ${l}, ${a.formatAlpha(r.a)})` : a.rgbToHex(s, o, l);
266
285
  }
267
286
  static parseColorToRgba(t) {
268
287
  const e = t.trim();
269
288
  if (a.HEX_REGEX.test(e)) {
270
- const [l, u, h, f] = a.parseHexWithAlpha(e);
271
- return { r: l, g: u, b: h, a: f };
289
+ const [c, u, f, h] = a.parseHexWithAlpha(e);
290
+ return { r: c, g: u, b: f, a: h };
272
291
  }
273
292
  const r = e.match(a.RGB_REGEX);
274
293
  if (r) {
275
- const [, l, u, h] = r.map(Number);
276
- return { r: l, g: u, b: h, a: 1 };
294
+ const [, c, u, f] = r.map(Number);
295
+ return { r: c, g: u, b: f, a: 1 };
277
296
  }
278
297
  const n = e.match(a.RGBA_REGEX);
279
298
  if (n) {
280
- const [, l, u, h, f] = n;
281
- return { r: Number(l), g: Number(u), b: Number(h), a: Number(f) };
299
+ const [, c, u, f, h] = n;
300
+ return { r: Number(c), g: Number(u), b: Number(f), a: Number(h) };
282
301
  }
283
302
  const s = e.match(a.HSL_REGEX);
284
303
  if (s) {
285
- const [, l, u, h] = s.map(Number), [f, d, m] = a.hslToRgb(l, u / 100, h / 100);
286
- return { r: f, g: d, b: m, a: 1 };
304
+ const [, c, u, f] = s.map(Number), [h, d, m] = a.hslToRgb(c, u / 100, f / 100);
305
+ return { r: h, g: d, b: m, a: 1 };
287
306
  }
288
307
  const o = e.match(a.HSLA_REGEX);
289
308
  if (o) {
290
- const [, l, u, h, f] = o, [d, m, k] = a.hslToRgb(
291
- Number(l),
309
+ const [, c, u, f, h] = o, [d, m, L] = a.hslToRgb(
310
+ Number(c),
292
311
  Number(u) / 100,
293
- Number(h) / 100
312
+ Number(f) / 100
294
313
  );
295
- return { r: d, g: m, b: k, a: Number(f) };
314
+ return { r: d, g: m, b: L, a: Number(h) };
296
315
  }
297
- const c = a.NAMED_COLOR_RGB[e.toLowerCase()];
298
- if (c) {
299
- const [l, u, h, f] = c;
300
- return { r: l, g: u, b: h, a: f };
316
+ const l = a.NAMED_COLOR_RGB[e.toLowerCase()];
317
+ if (l) {
318
+ const [c, u, f, h] = l;
319
+ return { r: c, g: u, b: f, a: h };
301
320
  }
302
321
  return null;
303
322
  }
304
323
  static parseColorToHsla(t) {
305
324
  const e = t.trim(), r = e.match(a.HSL_REGEX);
306
325
  if (r) {
307
- const [, u, h, f] = r.map(Number);
308
- return { h: u, s: h / 100, l: f / 100, a: 1 };
326
+ const [, u, f, h] = r.map(Number);
327
+ return { h: u, s: f / 100, l: h / 100, a: 1 };
309
328
  }
310
329
  const n = e.match(a.HSLA_REGEX);
311
330
  if (n) {
312
- const [, u, h, f, d] = n;
331
+ const [, u, f, h, d] = n;
313
332
  return {
314
333
  h: Number(u),
315
- s: Number(h) / 100,
316
- l: Number(f) / 100,
334
+ s: Number(f) / 100,
335
+ l: Number(h) / 100,
317
336
  a: Number(d)
318
337
  };
319
338
  }
320
339
  const s = a.parseColorToRgba(e);
321
340
  if (!s)
322
341
  return null;
323
- const [o, c, l] = a.rgbToHsl(s.r, s.g, s.b);
324
- return { h: o, s: c, l, a: s.a };
342
+ const [o, l, c] = a.rgbToHsl(s.r, s.g, s.b);
343
+ return { h: o, s: l, l: c, a: s.a };
325
344
  }
326
345
  static rgbToHsl(t, e, r) {
327
- 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;
328
- let h = 0;
329
- const f = (c + l) / 2, d = u === 0 ? 0 : u / (1 - Math.abs(2 * f - 1));
330
- 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];
346
+ const n = t / 255, s = e / 255, o = r / 255, l = Math.max(n, s, o), c = Math.min(n, s, o), u = l - c;
347
+ let f = 0;
348
+ const h = (l + c) / 2, d = u === 0 ? 0 : u / (1 - Math.abs(2 * h - 1));
349
+ return u !== 0 && (l === n ? f = (s - o) / u % 6 : l === s ? f = (o - n) / u + 2 : f = (n - s) / u + 4, f *= 60, f < 0 && (f += 360)), [f, d, h];
331
350
  }
332
351
  static hslToRgb(t, e, r) {
333
- 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;
334
- let l = 0, u = 0, h = 0;
335
- 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);
336
- const f = Math.round((l + c) * 255), d = Math.round((u + c) * 255), m = Math.round((h + c) * 255);
337
- return [f, d, m];
352
+ const n = (t % 360 + 360) % 360, s = (1 - Math.abs(2 * r - 1)) * e, o = s * (1 - Math.abs(n / 60 % 2 - 1)), l = r - s / 2;
353
+ let c = 0, u = 0, f = 0;
354
+ n < 60 ? (c = s, u = o) : n < 120 ? (c = o, u = s) : n < 180 ? (u = s, f = o) : n < 240 ? (u = o, f = s) : n < 300 ? (c = o, f = s) : (c = s, f = o);
355
+ const h = Math.round((c + l) * 255), d = Math.round((u + l) * 255), m = Math.round((f + l) * 255);
356
+ return [h, d, m];
338
357
  }
339
358
  static rgbToHex(t, e, r) {
340
359
  const n = (s) => s.toString(16).padStart(2, "0");
@@ -372,10 +391,10 @@ y(E, "NAMED_COLOR_RGB", {
372
391
  fuchsia: [255, 0, 255, 1]
373
392
  });
374
393
  let g = E;
375
- 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);
394
+ var P = Object.defineProperty, X = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, R = (i, t, e) => X(i, typeof t != "symbol" ? t + "" : t, e);
376
395
  class F extends p {
377
396
  constructor(t) {
378
- if (super(t.name), A(this, "default"), A(this, "light"), A(this, "dark"), A(this, "alt"), A(this, "placeholder"), !t.default)
397
+ if (super(t.name), R(this, "default"), R(this, "light"), R(this, "dark"), R(this, "alt"), R(this, "placeholder"), !t.default)
379
398
  throw new Error(`ImageAsset "${t.name}" must specify a default image path`);
380
399
  this.default = t.default, this.light = t.light, this.dark = t.dark, this.alt = t.options?.alt, this.placeholder = t.options?.placeholder;
381
400
  }
@@ -383,12 +402,16 @@ class F extends p {
383
402
  return new F(t);
384
403
  }
385
404
  static getCurrentTheme() {
386
- return C();
405
+ return k();
387
406
  }
388
407
  resolve() {
389
- const t = x() !== null;
408
+ const t = N() !== null;
390
409
  let e;
391
- return t ? e = S()() : e = F.getCurrentTheme(), e === "dark" ? this.dark || this.default : this.light || this.default;
410
+ t ? e = H()() : e = F.getCurrentTheme();
411
+ const r = e === "dark" ? this.dark || this.default : this.light || this.default, n = C();
412
+ return n && n.addLink(
413
+ `<link rel="preload" href="${r}" as="image">`
414
+ ), r;
392
415
  }
393
416
  // Additional accessors
394
417
  get src() {
@@ -404,10 +427,10 @@ class F extends p {
404
427
  return this.default;
405
428
  }
406
429
  }
407
- 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);
430
+ var V = Object.defineProperty, B = (i, t, e) => t in i ? V(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, A = (i, t, e) => B(i, typeof t != "symbol" ? t + "" : t, e);
408
431
  class w extends p {
409
432
  constructor(t, e = [], r = "", n = {}) {
410
- 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 = {
433
+ super(r || t), A(this, "family"), A(this, "fallbacks"), A(this, "options"), A(this, "loaded", !1), A(this, "loadPromise", null), this.family = t, this.fallbacks = e, this.options = {
411
434
  loading: "lazy",
412
435
  fontDisplay: "swap",
413
436
  preconnect: !0,
@@ -484,17 +507,17 @@ class w extends p {
484
507
  const { fontFormat: e, fontDisplay: r, weightRange: n, widthRange: s } = this.options;
485
508
  let o = "";
486
509
  e ? o = `format('${e}')` : t.endsWith(".woff2") ? o = "format('woff2')" : t.endsWith(".woff") ? o = "format('woff')" : t.endsWith(".ttf") && (o = "format('truetype')");
487
- let c = `
510
+ let l = `
488
511
  @font-face {
489
512
  font-family: "${this.family}";
490
513
  src: url("${t}") ${o};
491
514
  font-display: ${r || "swap"};
492
515
  `;
493
- n && (c += `font-weight: ${n[0]} ${n[1]};
494
- `), s && (c += `font-stretch: ${s[0]}% ${s[1]}%;
495
- `), c += "}";
496
- const l = document.createElement("style");
497
- if (l.textContent = c, document.head.appendChild(l), "FontFace" in window)
516
+ n && (l += `font-weight: ${n[0]} ${n[1]};
517
+ `), s && (l += `font-stretch: ${s[0]}% ${s[1]}%;
518
+ `), l += "}";
519
+ const c = document.createElement("style");
520
+ if (c.textContent = l, document.head.appendChild(c), "FontFace" in window)
498
521
  try {
499
522
  const u = new FontFace(this.family, `url(${t})`, {
500
523
  display: r || "swap",
@@ -521,10 +544,49 @@ class w extends p {
521
544
  * Resolve the font value (required by Asset base class)
522
545
  */
523
546
  resolve() {
524
- return this.options.loading === "lazy" && !this.loaded && this.options.fontUrl && this.load(), this.value;
547
+ const t = C();
548
+ return t && this.options.fontUrl && this.collectSSRHeadEntries(t), this.options.loading === "lazy" && !this.loaded && this.options.fontUrl && (t || this.load()), this.value;
549
+ }
550
+ collectSSRHeadEntries(t) {
551
+ const { fontUrl: e, preconnect: r } = this.options;
552
+ if (!t || !e)
553
+ return;
554
+ if (r)
555
+ try {
556
+ const o = new URL(e).origin;
557
+ t.addLink(
558
+ `<link rel="preconnect" href="${o}" crossorigin="anonymous">`
559
+ );
560
+ } catch {
561
+ }
562
+ if (e.endsWith(".css") || e.includes("fonts.googleapis.com")) {
563
+ t.addLink(`<link rel="stylesheet" href="${e}">`);
564
+ return;
565
+ }
566
+ const n = this.getFontMimeType(e), s = n ? ` type="${n}"` : "";
567
+ t.addLink(
568
+ `<link rel="preload" href="${e}" as="font"${s} crossorigin="anonymous">`
569
+ ), t.addStyle(this.buildFontFaceRule(e).trim());
570
+ }
571
+ getFontMimeType(t) {
572
+ if (t.endsWith(".woff2")) return "font/woff2";
573
+ if (t.endsWith(".woff")) return "font/woff";
574
+ if (t.endsWith(".ttf")) return "font/ttf";
575
+ if (t.endsWith(".otf")) return "font/otf";
576
+ }
577
+ buildFontFaceRule(t) {
578
+ const { fontFormat: e, fontDisplay: r, weightRange: n, widthRange: s } = this.options;
579
+ let o = "";
580
+ e ? o = `format('${e}')` : t.endsWith(".woff2") ? o = "format('woff2')" : t.endsWith(".woff") ? o = "format('woff')" : t.endsWith(".ttf") && (o = "format('truetype')");
581
+ const l = [
582
+ `font-family: "${this.family}";`,
583
+ `src: url("${t}")${o ? ` ${o}` : ""};`,
584
+ `font-display: ${r || "swap"};`
585
+ ];
586
+ return n && l.push(`font-weight: ${n[0]} ${n[1]};`), s && l.push(`font-stretch: ${s[0]}% ${s[1]}%;`), `@font-face { ${l.join(" ")} }`;
525
587
  }
526
588
  }
527
- const z = {
589
+ const K = {
528
590
  ultraLight: 100,
529
591
  thin: 200,
530
592
  light: 300,
@@ -534,7 +596,7 @@ const z = {
534
596
  bold: 700,
535
597
  heavy: 800,
536
598
  black: 900
537
- }, U = {
599
+ }, Y = {
538
600
  ultraCondensed: 50,
539
601
  extraCondensed: 62.5,
540
602
  condensed: 75,
@@ -544,21 +606,21 @@ const z = {
544
606
  expanded: 125,
545
607
  extraExpanded: 150,
546
608
  ultraExpanded: 200
547
- }, R = {
609
+ }, v = {
548
610
  sansSerif: ["system-ui", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", "Arial", "sans-serif"],
549
611
  serif: ["Georgia", "Cambria", "Times New Roman", "Times", "serif"],
550
612
  monospace: ["ui-monospace", "SFMono-Regular", "SF Mono", "Consolas", "Liberation Mono", "Menlo", "Courier", "monospace"],
551
613
  cursive: ["cursive"],
552
614
  fantasy: ["fantasy"]
553
615
  };
554
- function j(i = "sansSerif", t) {
555
- return new w("", [...R[i]], t || `system-${i}`);
616
+ function J(i = "sansSerif", t) {
617
+ return new w("", [...v[i]], t || `system-${i}`);
556
618
  }
557
- function K(i, t = [400], e, r = {}) {
619
+ function Q(i, t = [400], e, r = {}) {
558
620
  const n = t.join(";"), o = `https://fonts.googleapis.com/css2?family=${i.replace(/\s+/g, "+")}:wght@${n}&display=swap`;
559
621
  return new w(
560
622
  i,
561
- [...R.sansSerif],
623
+ [...v.sansSerif],
562
624
  e || i.toLowerCase().replace(/\s+/g, "-"),
563
625
  {
564
626
  ...r,
@@ -567,7 +629,7 @@ function K(i, t = [400], e, r = {}) {
567
629
  }
568
630
  );
569
631
  }
570
- function J(i, t, e, r = [...R.sansSerif], n) {
632
+ function Z(i, t, e, r = [...v.sansSerif], n) {
571
633
  const s = {};
572
634
  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, {
573
635
  fontUrl: t,
@@ -577,8 +639,8 @@ function J(i, t, e, r = [...R.sansSerif], n) {
577
639
  fontDisplay: "swap"
578
640
  });
579
641
  }
580
- 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);
581
- class O {
642
+ var W = Object.defineProperty, O = (i, t, e) => t in i ? W(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, I = (i, t, e) => O(i, t + "", e);
643
+ class D {
582
644
  constructor() {
583
645
  I(this, "assets", /* @__PURE__ */ new Map());
584
646
  }
@@ -620,7 +682,7 @@ class O {
620
682
  );
621
683
  }
622
684
  }
623
- const b = new O(), N = b.asProxy(), Q = N;
685
+ const b = new D(), x = b.asProxy(), _ = x;
624
686
  function $(...i) {
625
687
  if (i.length === 0)
626
688
  throw new Error("registerAsset requires at least one argument");
@@ -650,7 +712,7 @@ function $(...i) {
650
712
  "registerAsset requires either (name, asset), (asset), (asset, overrideName), or (...assets)"
651
713
  );
652
714
  }
653
- function Y(i, t, e = "") {
715
+ function tt(i, t, e = "") {
654
716
  return g.init({
655
717
  default: i,
656
718
  light: i,
@@ -658,7 +720,7 @@ function Y(i, t, e = "") {
658
720
  name: e
659
721
  });
660
722
  }
661
- function Z(i, t, e, r = "", n) {
723
+ function et(i, t, e, r = "", n) {
662
724
  return F.init({
663
725
  default: i,
664
726
  light: t,
@@ -667,10 +729,10 @@ function Z(i, t, e, r = "", n) {
667
729
  options: n
668
730
  });
669
731
  }
670
- function _(i, t = [], e = "", r) {
732
+ function rt(i, t = [], e = "", r) {
671
733
  return w.init(i, t, e, r);
672
734
  }
673
- function tt() {
735
+ function st() {
674
736
  const i = b.getAll(), t = [];
675
737
  for (const [e, r] of i) {
676
738
  let n = "custom";
@@ -682,7 +744,7 @@ function tt() {
682
744
  }
683
745
  return t.sort((e, r) => e.name.localeCompare(r.name));
684
746
  }
685
- function et(i) {
747
+ function nt(i) {
686
748
  return b.get(i);
687
749
  }
688
750
  function G(i) {
@@ -693,16 +755,16 @@ function G(i) {
693
755
  const t = i;
694
756
  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";
695
757
  }
696
- function rt(i) {
697
- const t = N[i];
758
+ function at(i) {
759
+ const t = x[i];
698
760
  return G(t) ? t : void 0;
699
761
  }
700
- function st(i, t = "asset") {
762
+ function it(i, t = "asset") {
701
763
  if (!G(i))
702
764
  throw new Error(`Asset "${t}" is not a ColorAsset`);
703
765
  return i;
704
766
  }
705
- function nt() {
767
+ function ot() {
706
768
  return Array.from(b.getAll().keys()).sort();
707
769
  }
708
770
  $(g.init({
@@ -755,27 +817,29 @@ $(g.init({
755
817
  }));
756
818
  export {
757
819
  p as Asset,
758
- Q as Assets,
820
+ _ as Assets,
759
821
  g as ColorAsset,
760
822
  w as FontAsset,
761
- z as FontWeight,
762
- U as FontWidth,
823
+ K as FontWeight,
824
+ Y as FontWidth,
763
825
  F as ImageAsset,
764
- ot as LinearGradient,
765
- lt as RadialGradient,
766
- ct as StateGradient,
767
- R as SystemFonts,
768
- st as asColorAsset,
769
- Y as createColorAsset,
770
- _ as createFontAsset,
771
- K as createGoogleFont,
772
- Z as createImageAsset,
773
- j as createSystemFont,
774
- J as createVariableFont,
775
- et as getAsset,
776
- tt as getAssetInfo,
777
- rt as getColorAsset,
826
+ ut as LinearGradient,
827
+ ft as RadialGradient,
828
+ ht as StateGradient,
829
+ v as SystemFonts,
830
+ it as asColorAsset,
831
+ tt as createColorAsset,
832
+ rt as createFontAsset,
833
+ Q as createGoogleFont,
834
+ et as createImageAsset,
835
+ J as createSystemFont,
836
+ Z as createVariableFont,
837
+ nt as getAsset,
838
+ st as getAssetInfo,
839
+ at as getColorAsset,
840
+ C as getSSRAssetHeadCollector,
778
841
  G as isColorAsset,
779
- nt as listAssetNames,
780
- $ as registerAsset
842
+ ot as listAssetNames,
843
+ $ as registerAsset,
844
+ j as withSSRAssetHeadCollector
781
845
  };
@@ -0,0 +1,8 @@
1
+ export interface SSRAssetHeadCollector {
2
+ addLink: (tag: string) => void;
3
+ addStyle: (styleContent: string) => void;
4
+ addMeta: (tag: string) => void;
5
+ }
6
+ export declare function getSSRAssetHeadCollector(): SSRAssetHeadCollector | undefined;
7
+ export declare function withSSRAssetHeadCollector<T>(collector: SSRAssetHeadCollector | undefined, callback: () => T): T;
8
+ //# sourceMappingURL=ssr-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-context.d.ts","sourceRoot":"","sources":["../../src/assets/ssr-context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAQD,wBAAgB,wBAAwB,IAAI,qBAAqB,GAAG,SAAS,CAE5E;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,SAAS,EAAE,qBAAqB,GAAG,SAAS,EAC5C,QAAQ,EAAE,MAAM,CAAC,GAChB,CAAC,CAqBH"}
@@ -1,6 +1,6 @@
1
1
  import { d as l, j as f } from "./signal-BRoiFOO7.js";
2
2
  import { c as w } from "./effect-DgNm6jk9.js";
3
- import { g as m } from "./component-context-C7Y6Xu6h.js";
3
+ import { g as m } from "./component-context-BB80qzyZ.js";
4
4
  var b = Object.defineProperty, $ = (e, t, n) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, _ = (e, t, n) => $(e, typeof t != "symbol" ? t + "" : t, n);
5
5
  class y {
6
6
  constructor(t, n, r, s = {}) {