@styleframe/core 3.0.0 → 3.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @styleframe/core
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#120](https://github.com/styleframe-dev/styleframe/pull/120) [`fa48802`](https://github.com/styleframe-dev/styleframe/commit/fa488027d32956e20fa26dc92ee1a3b3583671ad) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add hash-based utility class names for arbitrary CSS values containing whitespace. Values like `transition: 'all 0.3s ease'` now produce valid CSS class names using a deterministic hash (e.g., `_transition:2f7a3b1`) instead of invalid bracket notation with spaces.
8
+
3
9
  ## 3.0.0
4
10
 
5
11
  ### Major Changes
@@ -282,6 +282,15 @@ export declare function getUtility(root: Root, name: string): UtilityFactory;
282
282
 
283
283
  export declare function getVariable(root: Container, name: string): Variable;
284
284
 
285
+ /**
286
+ * Generates a deterministic, CSS-safe hash string from an arbitrary value.
287
+ * Uses DJB2 algorithm for fast, low-collision hashing.
288
+ *
289
+ * @param value - The string value to hash
290
+ * @returns A lowercase hex string of 7 characters (e.g., "a1b2c3d")
291
+ */
292
+ export declare function hashValue(value: string): string;
293
+
285
294
  export declare function isAtRule(value: unknown): value is AtRule;
286
295
 
287
296
  export declare function isContainer(value: unknown): value is Container;
@@ -10,42 +10,48 @@ function G(e) {
10
10
  function j(e) {
11
11
  return h(e, "reference");
12
12
  }
13
- function Ae(e) {
13
+ function je(e) {
14
14
  return h(e, "selector");
15
15
  }
16
- function je(e) {
16
+ function ve(e) {
17
17
  return h(e, "at-rule");
18
18
  }
19
- function ve(e) {
19
+ function we(e) {
20
20
  return h(e, "utility");
21
21
  }
22
22
  function I(e) {
23
23
  return h(e, "modifier");
24
24
  }
25
- function T(e) {
25
+ function E(e) {
26
26
  return h(e, "css");
27
27
  }
28
- function we(e) {
28
+ function ke(e) {
29
29
  return h(e, "theme");
30
30
  }
31
31
  function V(e) {
32
32
  return h(e, "root");
33
33
  }
34
- function ke(e) {
34
+ function Ve(e) {
35
35
  return h(e, "recipe");
36
36
  }
37
37
  function z(e) {
38
38
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
39
39
  }
40
40
  function D(e) {
41
- return z(e) || j(e) || T(e) || Array.isArray(e) && e.every(D);
41
+ return z(e) || j(e) || E(e) || Array.isArray(e) && e.every(D);
42
42
  }
43
43
  function Y(e) {
44
44
  return C(e) && "children" in e && "declarations" in e && "variables" in e;
45
45
  }
46
- function Ve(e) {
46
+ function Re(e) {
47
47
  return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
48
48
  }
49
+ function Z(e) {
50
+ let r = 5381;
51
+ for (let n = 0; n < e.length; n++)
52
+ r = (r << 5) + r + e.charCodeAt(n) & 4294967295;
53
+ return (r >>> 0).toString(16).padStart(7, "0").slice(0, 7);
54
+ }
49
55
  function P(e) {
50
56
  const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
51
57
  return (c) => {
@@ -67,14 +73,16 @@ function P(e) {
67
73
  break;
68
74
  }
69
75
  a = n(o);
70
- } else
71
- a = `[${c}]`;
76
+ } else {
77
+ const o = String(c).trim();
78
+ /\s/.test(o) ? a = Z(o) : a = `[${o}]`;
79
+ }
72
80
  return {
73
81
  [a]: s
74
82
  };
75
83
  };
76
84
  }
77
- function Z(e, r) {
85
+ function J(e, r) {
78
86
  return function(t, ...i) {
79
87
  return {
80
88
  type: "css",
@@ -95,19 +103,19 @@ function K(e, r) {
95
103
  return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
96
104
  };
97
105
  }
98
- function J(e, r) {
106
+ function Q(e, r) {
99
107
  const n = K(e, r);
100
108
  return function(i, c) {
101
109
  return n("media", i, c);
102
110
  };
103
111
  }
104
- function Q(e, r) {
112
+ function X(e, r) {
105
113
  const n = K(e, r);
106
114
  return function(i, c) {
107
115
  return n("keyframes", i, c);
108
116
  };
109
117
  }
110
- function X(e, r) {
118
+ function ee(e, r) {
111
119
  return function(t, i) {
112
120
  return G(t) ? {
113
121
  type: "reference",
@@ -120,7 +128,7 @@ function X(e, r) {
120
128
  };
121
129
  };
122
130
  }
123
- function ee(e, r) {
131
+ function te(e, r) {
124
132
  return function(t, i) {
125
133
  const c = {
126
134
  type: "selector",
@@ -132,7 +140,7 @@ function ee(e, r) {
132
140
  return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
133
141
  };
134
142
  }
135
- function te(e, r) {
143
+ function ne(e, r) {
136
144
  return function(t, i, c = {
137
145
  default: !1
138
146
  }) {
@@ -152,7 +160,7 @@ function te(e, r) {
152
160
  };
153
161
  }
154
162
  function v(e, r) {
155
- const n = te(e), t = ee(e, r), i = K(e, r), c = Q(r, r), s = J(e, r), a = X(), o = Z();
163
+ const n = ne(e), t = te(e, r), i = K(e, r), c = X(r, r), s = Q(e, r), a = ee(), o = J();
156
164
  return {
157
165
  variable: n,
158
166
  selector: t,
@@ -181,7 +189,7 @@ function R(e, r) {
181
189
  }
182
190
  return e;
183
191
  }
184
- function Re(e) {
192
+ function $e(e) {
185
193
  return e.charAt(0).toUpperCase() + e.slice(1);
186
194
  }
187
195
  function A(e) {
@@ -194,9 +202,9 @@ function A(e) {
194
202
  e.byteLength / e.BYTES_PER_ELEMENT || 1
195
203
  );
196
204
  }
197
- function ne(e) {
205
+ function re(e) {
198
206
  if (e = e || {}, e.circular)
199
- return re(e);
207
+ return ie(e);
200
208
  const r = /* @__PURE__ */ new Map();
201
209
  if (r.set(Date, (s) => new Date(s)), r.set(
202
210
  Map,
@@ -243,7 +251,7 @@ function ne(e) {
243
251
  return a;
244
252
  }
245
253
  }
246
- function re(e) {
254
+ function ie(e) {
247
255
  const r = [], n = [], t = /* @__PURE__ */ new Map();
248
256
  if (t.set(Date, (o) => new Date(o)), t.set(
249
257
  Map,
@@ -319,8 +327,8 @@ function re(e) {
319
327
  return r.pop(), n.pop(), f;
320
328
  }
321
329
  }
322
- const F = ne();
323
- function ie(e, r = 8) {
330
+ const F = re();
331
+ function se(e, r = 8) {
324
332
  const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
325
333
  let t = "";
326
334
  for (let i = 0; i < r; i++) {
@@ -329,19 +337,19 @@ function ie(e, r = 8) {
329
337
  }
330
338
  return e ? `${e}${t}` : t;
331
339
  }
332
- function $e(e, r) {
340
+ function Oe(e, r) {
333
341
  const n = e.variables.find((t) => t.name === r);
334
342
  if (!n)
335
343
  throw new Error(`Variable "${r}" not found`);
336
344
  return n;
337
345
  }
338
- function Oe(e, r) {
346
+ function Me(e, r) {
339
347
  const n = e.utilities.find((t) => t.name === r);
340
348
  if (!n)
341
349
  throw new Error(`Utility "${r}" not found`);
342
350
  return n;
343
351
  }
344
- function se(e, r) {
352
+ function oe(e, r) {
345
353
  const n = e.modifiers.find(
346
354
  (t) => t.key.includes(r)
347
355
  );
@@ -349,35 +357,35 @@ function se(e, r) {
349
357
  throw new Error(`Modifier "${r}" not found`);
350
358
  return n;
351
359
  }
352
- function N(e, r) {
360
+ function S(e, r) {
353
361
  if (e === r) return !0;
354
362
  if (typeof e != typeof r) return !1;
355
363
  if (e === null || r === null) return e === r;
356
364
  if (typeof e != "object" || typeof r != "object") return !1;
357
365
  if (Array.isArray(e) && Array.isArray(r))
358
- return e.length !== r.length ? !1 : e.every((n, t) => N(n, r[t]));
366
+ return e.length !== r.length ? !1 : e.every((n, t) => S(n, r[t]));
359
367
  if ("type" in e && "type" in r) {
360
368
  if (e.type !== r.type) return !1;
361
369
  if (j(e) && j(r))
362
- return e.name === r.name && N(e.fallback, r.fallback);
363
- if (T(e) && T(r))
364
- return N(e.value, r.value);
370
+ return e.name === r.name && S(e.fallback, r.fallback);
371
+ if (E(e) && E(r))
372
+ return S(e.value, r.value);
365
373
  }
366
374
  return !1;
367
375
  }
368
376
  const H = "__licenseRequired";
369
- function oe(e) {
370
- B(e) || Object.defineProperty(e, H, {
377
+ function ce(e) {
378
+ T(e) || Object.defineProperty(e, H, {
371
379
  value: !0,
372
380
  writable: !1,
373
381
  configurable: !1,
374
382
  enumerable: !0
375
383
  });
376
384
  }
377
- function B(e) {
385
+ function T(e) {
378
386
  return Object.prototype.hasOwnProperty.call(e, H);
379
387
  }
380
- function ce(e, r) {
388
+ function fe(e, r) {
381
389
  const n = [...e];
382
390
  for (const t of r) {
383
391
  const i = n.find(
@@ -387,7 +395,7 @@ function ce(e, r) {
387
395
  }
388
396
  return n;
389
397
  }
390
- function fe(e, r) {
398
+ function ae(e, r) {
391
399
  const n = [...e];
392
400
  for (const t of r) {
393
401
  const i = n.find(
@@ -402,7 +410,7 @@ function fe(e, r) {
402
410
  }
403
411
  function W(e, r) {
404
412
  return Object.keys(e).reduce(
405
- (n, t) => (t === "variables" ? n.variables = ce(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && V(n) && V(e) && V(r) ? n.themes = fe(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
413
+ (n, t) => (t === "variables" ? n.variables = fe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && V(n) && V(e) && V(r) ? n.themes = ae(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
406
414
  r[t]
407
415
  )), n),
408
416
  {
@@ -411,16 +419,16 @@ function W(e, r) {
411
419
  }
412
420
  );
413
421
  }
414
- function Me(e, ...r) {
422
+ function Fe(e, ...r) {
415
423
  return r.reduce((n, t) => {
416
424
  const i = {
417
425
  ...n,
418
426
  root: W(n.root, t.root)
419
427
  };
420
- return (B(n) || B(t)) && oe(i), i;
428
+ return (T(n) || T(t)) && ce(i), i;
421
429
  }, e);
422
430
  }
423
- function ae(e) {
431
+ function ue(e) {
424
432
  const r = [];
425
433
  function n(t, i) {
426
434
  i.length > 0 && r.push([...i].sort());
@@ -436,7 +444,7 @@ function ae(e) {
436
444
  }
437
445
  return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
438
446
  }
439
- function ue(e, r, n) {
447
+ function le(e, r, n) {
440
448
  const t = {
441
449
  ...e,
442
450
  modifiers: [...n.keys()]
@@ -450,7 +458,7 @@ function ue(e, r, n) {
450
458
  }), R(t.declarations, i);
451
459
  return t;
452
460
  }
453
- function le(e, r) {
461
+ function ye(e, r) {
454
462
  return function(t, i) {
455
463
  const c = {
456
464
  type: "modifier",
@@ -460,7 +468,7 @@ function le(e, r) {
460
468
  return r.modifiers.push(c), c;
461
469
  };
462
470
  }
463
- function ye() {
471
+ function de() {
464
472
  return {
465
473
  type: "root",
466
474
  declarations: {},
@@ -472,7 +480,7 @@ function ye() {
472
480
  themes: []
473
481
  };
474
482
  }
475
- function de(e, r) {
483
+ function me(e, r) {
476
484
  const n = P({ namespace: e });
477
485
  return (t) => {
478
486
  if (typeof t == "string" && t[0] === "@") {
@@ -504,14 +512,14 @@ function de(e, r) {
504
512
  return n(t);
505
513
  };
506
514
  }
507
- function me(e, r) {
515
+ function pe(e, r) {
508
516
  return function(t, i, c = {}) {
509
517
  const s = {
510
518
  type: "utility",
511
519
  name: t,
512
520
  factory: i,
513
521
  values: [],
514
- autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? de(c.namespace, r) : P(
522
+ autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? me(c.namespace, r) : P(
515
523
  c.namespace ? { namespace: c.namespace } : void 0
516
524
  )),
517
525
  namespace: c.namespace,
@@ -569,7 +577,7 @@ function me(e, r) {
569
577
  value: y,
570
578
  modifiers: []
571
579
  }), e.children.push(d)), o && o.length > 0) {
572
- const g = o.map((m) => m.key), O = ae(g).filter((m) => !s.values.find(
580
+ const g = o.map((m) => m.key), O = ue(g).filter((m) => !s.values.find(
573
581
  (b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k) => m.includes(k))
574
582
  )).reduce((m, b) => {
575
583
  const k = /* @__PURE__ */ new Map();
@@ -583,7 +591,7 @@ function me(e, r) {
583
591
  key: l,
584
592
  value: y,
585
593
  modifiers: b
586
- }), m.push(ue(d, r, k)), m;
594
+ }), m.push(le(d, r, k)), m;
587
595
  }, []);
588
596
  e.children.push(...O);
589
597
  }
@@ -593,7 +601,7 @@ function me(e, r) {
593
601
  return r.utilities.push(s), s.create;
594
602
  };
595
603
  }
596
- function pe(e, r) {
604
+ function he(e, r) {
597
605
  return function(t, i) {
598
606
  const c = r.themes.find((o) => o.name === t), s = c ?? {
599
607
  type: "theme",
@@ -607,26 +615,26 @@ function pe(e, r) {
607
615
  return i && i(a), s;
608
616
  };
609
617
  }
610
- function he(e, r) {
618
+ function ge(e, r) {
611
619
  return function(t) {
612
620
  const i = {
613
621
  type: "recipe",
614
622
  ...t
615
623
  };
616
- return i._runtime = ge(i, r), be(i, r), r.recipes.push(i), i;
624
+ return i._runtime = be(i, r), Ae(i, r), r.recipes.push(i), i;
617
625
  };
618
626
  }
619
627
  function _(e, r) {
620
628
  const n = e.autogenerate(r);
621
629
  return Object.keys(n)[0] ?? "default";
622
630
  }
623
- function x(e, r) {
631
+ function N(e, r) {
624
632
  const n = {};
625
633
  for (const [t, i] of Object.entries(e))
626
634
  if (L(i)) {
627
635
  const c = {};
628
636
  for (const [s, a] of Object.entries(i)) {
629
- const o = S(r, s);
637
+ const o = B(r, s);
630
638
  o ? c[s] = _(
631
639
  o,
632
640
  a
@@ -638,23 +646,23 @@ function x(e, r) {
638
646
  } else if (typeof i == "boolean")
639
647
  n[t] = i;
640
648
  else {
641
- const c = S(r, t);
649
+ const c = B(r, t);
642
650
  c ? n[t] = _(c, i) : console.warn(
643
651
  `[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
644
652
  );
645
653
  }
646
654
  return n;
647
655
  }
648
- function ge(e, r) {
656
+ function be(e, r) {
649
657
  const n = {};
650
- if (e.base && (n.base = x(e.base, r)), e.variants) {
658
+ if (e.base && (n.base = N(e.base, r)), e.variants) {
651
659
  const t = {};
652
660
  for (const [i, c] of Object.entries(e.variants)) {
653
661
  const s = {};
654
662
  for (const [a, o] of Object.entries(
655
663
  c
656
664
  ))
657
- o == null ? s[a] = null : s[a] = x(
665
+ o == null ? s[a] = null : s[a] = N(
658
666
  o,
659
667
  r
660
668
  );
@@ -664,13 +672,13 @@ function ge(e, r) {
664
672
  }
665
673
  return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
666
674
  match: { ...t.match },
667
- css: x(t.css, r)
675
+ css: N(t.css, r)
668
676
  }))), n;
669
677
  }
670
678
  function L(e) {
671
679
  return !j(e) && typeof e == "object" && e !== null;
672
680
  }
673
- function E(e, r) {
681
+ function x(e, r) {
674
682
  const n = (t, i, c) => {
675
683
  let s = r.get(t);
676
684
  s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
@@ -683,28 +691,28 @@ function E(e, r) {
683
691
  } else
684
692
  n(t, i, []);
685
693
  }
686
- function S(e, r) {
694
+ function B(e, r) {
687
695
  const n = e.utilities.find((i) => i.name === r);
688
696
  if (n)
689
697
  return n;
690
698
  const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
691
699
  return e.utilities.find((i) => i.name === t);
692
700
  }
693
- function be(e, r) {
701
+ function Ae(e, r) {
694
702
  const n = /* @__PURE__ */ new Map();
695
- if (e.base && E(e.base, n), e.variants)
703
+ if (e.base && x(e.base, n), e.variants)
696
704
  for (const i of Object.values(e.variants))
697
705
  for (const c of Object.values(i))
698
- E(
706
+ x(
699
707
  c,
700
708
  n
701
709
  );
702
710
  if (e.compoundVariants)
703
711
  for (const i of e.compoundVariants)
704
- i.css && E(i.css, n);
712
+ i.css && x(i.css, n);
705
713
  const t = /* @__PURE__ */ new Map();
706
714
  for (const [i, c] of n) {
707
- const s = S(r, i);
715
+ const s = B(r, i);
708
716
  if (!s) {
709
717
  console.warn(
710
718
  `[styleframe] Utility "${i}" not found in registry. Skipping.`
@@ -716,7 +724,7 @@ function be(e, r) {
716
724
  for (const f of a.modifiers) {
717
725
  if (!t.has(f))
718
726
  try {
719
- t.set(f, se(r, f));
727
+ t.set(f, oe(r, f));
720
728
  } catch {
721
729
  console.warn(
722
730
  `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
@@ -732,8 +740,8 @@ function be(e, r) {
732
740
  }
733
741
  }
734
742
  }
735
- function Fe(e) {
736
- const r = ie("sf-"), n = ye(), t = { ...e }, i = me(n, n), c = le(n, n), s = he(n, n), a = pe(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d } = v(n, n);
743
+ function Se(e) {
744
+ const r = se("sf-"), n = de(), t = { ...e }, i = pe(n, n), c = ye(n, n), s = ge(n, n), a = he(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d } = v(n, n);
737
745
  return {
738
746
  id: r,
739
747
  root: n,
@@ -752,52 +760,53 @@ function Fe(e) {
752
760
  };
753
761
  }
754
762
  export {
755
- ue as applyModifiers,
756
- Re as capitalizeFirst,
757
- ae as combineKeys,
763
+ le as applyModifiers,
764
+ $e as capitalizeFirst,
765
+ ue as combineKeys,
758
766
  K as createAtRuleFunction,
759
- Z as createCssFunction,
767
+ J as createCssFunction,
760
768
  v as createDeclarationsCallbackContext,
761
- Q as createKeyframesFunction,
762
- J as createMediaFunction,
763
- le as createModifierFunction,
764
- he as createRecipeFunction,
765
- X as createRefFunction,
766
- ye as createRoot,
767
- ee as createSelectorFunction,
768
- pe as createThemeFunction,
769
- me as createUtilityFunction,
770
- te as createVariableFunction,
769
+ X as createKeyframesFunction,
770
+ Q as createMediaFunction,
771
+ ye as createModifierFunction,
772
+ ge as createRecipeFunction,
773
+ ee as createRefFunction,
774
+ de as createRoot,
775
+ te as createSelectorFunction,
776
+ he as createThemeFunction,
777
+ pe as createUtilityFunction,
778
+ ne as createVariableFunction,
771
779
  F as deepClone,
772
- ie as generateRandomId,
773
- ge as generateRecipeRuntime,
774
- se as getModifier,
775
- Oe as getUtility,
776
- $e as getVariable,
777
- je as isAtRule,
778
- T as isCSS,
780
+ se as generateRandomId,
781
+ be as generateRecipeRuntime,
782
+ oe as getModifier,
783
+ Me as getUtility,
784
+ Oe as getVariable,
785
+ Z as hashValue,
786
+ ve as isAtRule,
787
+ E as isCSS,
779
788
  Y as isContainer,
780
789
  I as isModifier,
781
790
  C as isObject,
782
791
  z as isPrimitiveTokenValue,
783
- ke as isRecipe,
792
+ Ve as isRecipe,
784
793
  j as isRef,
785
794
  V as isRoot,
786
- Ae as isSelector,
787
- Ve as isStyleframe,
788
- we as isTheme,
795
+ je as isSelector,
796
+ Re as isStyleframe,
797
+ ke as isTheme,
789
798
  h as isToken,
790
- N as isTokenEqual,
799
+ S as isTokenEqual,
791
800
  D as isTokenValue,
792
- ve as isUtility,
801
+ we as isUtility,
793
802
  G as isVariable,
794
- Me as merge,
803
+ Fe as merge,
795
804
  W as mergeContainers,
796
- fe as mergeThemesArray,
797
- ce as mergeVariablesArray,
805
+ ae as mergeThemesArray,
806
+ fe as mergeVariablesArray,
798
807
  R as parseDeclarationsBlock,
799
- be as processRecipeUtilities,
800
- ne as rfdc,
801
- Fe as styleframe,
808
+ Ae as processRecipeUtilities,
809
+ re as rfdc,
810
+ Se as styleframe,
802
811
  P as transformUtilityKey
803
812
  };
@@ -1 +1 @@
1
- (function(u,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(u=typeof globalThis<"u"?globalThis:u||self,b(u.styleframe={}))})(this,(function(u){"use strict";function b(e){return typeof e=="object"&&e!==null}function h(e,r){return b(e)&&"type"in e&&e.type===r}function W(e){return h(e,"variable")}function v(e){return h(e,"reference")}function pe(e){return h(e,"selector")}function ge(e){return h(e,"at-rule")}function be(e){return h(e,"utility")}function q(e){return h(e,"modifier")}function M(e){return h(e,"css")}function Ae(e){return h(e,"theme")}function R(e){return h(e,"root")}function je(e){return h(e,"recipe")}function I(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function C(e){return I(e)||v(e)||M(e)||Array.isArray(e)&&e.every(C)}function L(e){return b(e)&&"children"in e&&"declarations"in e&&"variables"in e}function ve(e){return b(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&R(e.root)}function U(e){const r=typeof e=="function"?{replacer:e}:e??{},{replacer:n=c=>c,namespace:t}=r,i=Array.isArray(t)?t:t?[t]:[];return c=>{let s=c,a;if(typeof s=="string"&&s[0]==="@"){const o=s.slice(1),f=i.find(d=>o===d||o.startsWith(`${d}.`));let y,l;f?(y=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):i.length>0?(y=`${i[0]}.${o}`,l=o):(y=o,l=o),a=n(l),s={type:"reference",name:y}}else if(v(s)){let o=s.name;for(const f of i)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=n(o)}else a=`[${c}]`;return{[a]:s}}}function z(e,r){return function(t,...i){return{type:"css",value:t.reduce((s,a,o)=>(s.push(a),o<i.length&&s.push(i[o]),s),[])}}}function T(e,r){return function(t,i,c){const s={type:"at-rule",identifier:t,rule:i,declarations:{},variables:[],children:[]},a=k(s,r);return typeof c=="function"?s.declarations=c(a)??{}:c&&(s.declarations=c),V(s.declarations,a),e.children.push(s),s}}function G(e,r){const n=T(e,r);return function(i,c){return n("media",i,c)}}function Y(e,r){const n=T(e,r);return function(i,c){return n("keyframes",i,c)}}function Z(e,r){return function(t,i){return W(t)?{type:"reference",name:t.name,fallback:i}:{type:"reference",name:t,fallback:i}}}function J(e,r){return function(t,i){const c={type:"selector",query:t,declarations:{},variables:[],children:[]},s=k(c,r);return typeof i=="function"?c.declarations=i(s)??{}:L(i)?(c.variables=i.variables,c.declarations=i.declarations,c.children=i.children):c.declarations=i,V(c.declarations,s),e.children.push(c),c}}function Q(e,r){return function(t,i,c={default:!1}){const s=typeof t=="string"?t:t.name,a=e.variables.find(f=>f.name===s);if(c.default&&a)return a;if(a)return a.value=i,a;const o={type:"variable",name:s,value:i};return e.variables.push(o),o}}function k(e,r){const n=Q(e),t=J(e,r),i=T(e,r),c=Y(r,r),s=G(e,r),a=Z(),o=z();return{variable:n,selector:t,keyframes:c,atRule:i,media:s,ref:a,css:o}}function V(e,r){for(const n in e)if(n.startsWith("@")){const t=e[n];if(typeof t=="object"&&t!==null&&!C(t)){const i=n.replace(/^@(\w+).*/,"$1"),c=n.replace(`@${i}`,"").trim();r.atRule(i,c,t),delete e[n]}}else if(/^[.&:]/.test(n)||/^\d+%$/.test(n)||n==="from"||n==="to"){const t=e[n];typeof t=="object"&&(r.selector(n,t),delete e[n])}for(const n in e){const t=e[n];typeof t=="string"&&t[0]==="@"&&(e[n]=r.ref(t.slice(1)))}return e}function ke(e){return e.charAt(0).toUpperCase()+e.slice(1)}function w(e){if(e instanceof Buffer)return Buffer.from(e);const r=e.constructor;return new r(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function X(e){if(e=e||{},e.circular)return we(e);const r=new Map;if(r.set(Date,s=>new Date(s)),r.set(Map,(s,a)=>new Map(t(Array.from(s),a))),r.set(Set,(s,a)=>new Set(t(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)r.set(s[0],s[1]);let n;return e.proto?c:i;function t(s,a){const o=Object.keys(s),f=Array.from({length:o.length});for(let y=0;y<o.length;y++){const l=o[y],d=s[l];typeof d!="object"||d===null?f[l]=d:d.constructor!==Object&&(n=r.get(d.constructor))?f[l]=n(d,a):ArrayBuffer.isView(d)?f[l]=w(d):f[l]=a(d)}return f}function i(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,i);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,i);const a={};for(const o in s){if(Object.hasOwnProperty.call(s,o)===!1)continue;const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,i):ArrayBuffer.isView(f)?a[o]=w(f):a[o]=i(f)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,c);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,c);const a={};for(const o in s){const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,c):ArrayBuffer.isView(f)?a[o]=w(f):a[o]=c(f)}return a}}function we(e){const r=[],n=[],t=new Map;if(t.set(Date,o=>new Date(o)),t.set(Map,(o,f)=>new Map(c(Array.from(o),f))),t.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)t.set(o[0],o[1]);let i;return e.proto?a:s;function c(o,f){const y=Object.keys(o),l=Array.from({length:y.length});for(let d=0;d<y.length;d++){const g=y[d],m=o[g];if(typeof m!="object"||m===null)l[g]=m;else if(m.constructor!==Object&&(i=t.get(m.constructor)))l[g]=i(m,f);else if(ArrayBuffer.isView(m))l[g]=w(m);else{const F=r.indexOf(m);F!==-1?l[g]=n[F]:l[g]=f(m)}}return l}function s(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,s);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,s);const f={};r.push(o),n.push(f);for(const y in o){if(Object.hasOwnProperty.call(o,y)===!1)continue;const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,s);else if(ArrayBuffer.isView(l))f[y]=w(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=s(l)}}return r.pop(),n.pop(),f}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,a);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,a);const f={};r.push(o),n.push(f);for(const y in o){const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,a);else if(ArrayBuffer.isView(l))f[y]=w(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=a(l)}}return r.pop(),n.pop(),f}}const O=X();function x(e,r=8){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let i=0;i<r;i++){const c=Math.floor(Math.random()*n.length);t+=n[c]}return e?`${e}${t}`:t}function Re(e,r){const n=e.variables.find(t=>t.name===r);if(!n)throw new Error(`Variable "${r}" not found`);return n}function Ve(e,r){const n=e.utilities.find(t=>t.name===r);if(!n)throw new Error(`Utility "${r}" not found`);return n}function ee(e,r){const n=e.modifiers.find(t=>t.key.includes(r));if(!n)throw new Error(`Modifier "${r}" not found`);return n}function $(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(e===null||r===null)return e===r;if(typeof e!="object"||typeof r!="object")return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((n,t)=>$(n,r[t]));if("type"in e&&"type"in r){if(e.type!==r.type)return!1;if(v(e)&&v(r))return e.name===r.name&&$(e.fallback,r.fallback);if(M(e)&&M(r))return $(e.value,r.value)}return!1}const te="__licenseRequired";function Fe(e){E(e)||Object.defineProperty(e,te,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function E(e){return Object.prototype.hasOwnProperty.call(e,te)}function ne(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?i.value=t.value:n.push(t)}return n}function re(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?Object.assign(i,N(i,t)):n.push(t)}return n}function N(e,r){return Object.keys(e).reduce((n,t)=>(t==="variables"?n.variables=ne(e.variables,r.variables):t==="declarations"?n.declarations={...e.declarations,...r.declarations}:t==="themes"&&R(n)&&R(e)&&R(r)?n.themes=re(e.themes,r.themes):Array.isArray(e[t])&&(n[t]=e[t].concat(r[t])),n),{...e,...r})}function Me(e,...r){return r.reduce((n,t)=>{const i={...n,root:N(n.root,t.root)};return(E(n)||E(t))&&Fe(i),i},e)}function ie(e){const r=[];function n(t,i){i.length>0&&r.push([...i].sort());for(let c=t;c<e.length;c++){const s=e[c];if(s)if(s.length===1&&s[0])n(c+1,[...i,s[0]]);else for(const a of s)n(c+1,[...i,a])}}return n(0,[]),r.sort((t,i)=>t.length!==i.length?t.length-i.length:t.join(",").localeCompare(i.join(",")))}function se(e,r,n){const t={...e,modifiers:[...n.keys()]},i=k(t,r);for(const c of n.values())c.factory({...i,declarations:O(t.declarations),variables:O(t.variables),children:O(t.children)}),V(t.declarations,i);return t}function oe(e,r){return function(t,i){const c={type:"modifier",key:Array.isArray(t)?t:[t],factory:i};return r.modifiers.push(c),c}}function ce(){return{type:"root",declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[]}}function Te(e,r){const n=U({namespace:e});return t=>{if(typeof t=="string"&&t[0]==="@"){const i=t.slice(1),c=e.find(s=>i===s||i.startsWith(`${s}.`));if(c){const s=i.slice(c.length+1)||i;if(r.variables.some(a=>a.name===i))return{[s]:{type:"reference",name:i}}}else for(const s of e){const a=`${s}.${i}`;if(r.variables.some(o=>o.name===a))return{[i]:{type:"reference",name:a}}}return n(t)}return n(t)}}function fe(e,r){return function(t,i,c={}){const s={type:"utility",name:t,factory:i,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?Te(c.namespace,r):U(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(a,o=[])=>{let f=a;if(Array.isArray(a)){f={};for(const y of a){const l=s.autogenerate(y);f={...f,...l}}}for(const[y,l]of Object.entries(f)){let d=l;if(s.namespace&&v(l))if(r.variables.some(A=>A.name===l.name))d=l;else{const A=Array.isArray(s.namespace)?s.namespace:[s.namespace];let _=!1;for(const P of A){const p=`${P}.${y}`;if(p!==l.name&&r.variables.some(j=>j.name===p)){d={type:"reference",name:p},_=!0;break}}_||(d=y)}const g=s.values.find(A=>A.key===y&&A.modifiers.length===0),m={type:"utility",name:t,value:y,declarations:{},variables:[],children:[],modifiers:[]},F=k(m,r);if(m.declarations=i({...F,value:d})??{},V(m.declarations,F),g||(s.values.push({key:y,value:d,modifiers:[]}),e.children.push(m)),o&&o.length>0){const A=o.map(p=>p.key),P=ie(A).filter(p=>!s.values.find(j=>j.key===y&&j.modifiers.length===p.length&&j.modifiers.every(S=>p.includes(S)))).reduce((p,j)=>{const S=new Map;for(const he of j){const H=o.find($e=>$e.key.includes(he));H&&q(H)&&S.set(he,H)}return s.values.push({key:y,value:d,modifiers:j}),p.push(se(m,r,S)),p},[]);e.children.push(...P)}}}};return r.utilities.push(s),s.create}}function ae(e,r){return function(t,i){const c=r.themes.find(o=>o.name===t),s=c??{type:"theme",name:t,declarations:{},variables:[],children:[]};c||r.themes.push(s);const a=k(s,r);return i&&i(a),s}}function ue(e,r){return function(t){const i={type:"recipe",...t};return i._runtime=ye(i,r),me(i,r),r.recipes.push(i),i}}function le(e,r){const n=e.autogenerate(r);return Object.keys(n)[0]??"default"}function B(e,r){const n={};for(const[t,i]of Object.entries(e))if(de(i)){const c={};for(const[s,a]of Object.entries(i)){const o=D(r,s);o?c[s]=le(o,a):console.warn(`[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`)}n[t]=c}else if(typeof i=="boolean")n[t]=i;else{const c=D(r,t);c?n[t]=le(c,i):console.warn(`[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`)}return n}function ye(e,r){const n={};if(e.base&&(n.base=B(e.base,r)),e.variants){const t={};for(const[i,c]of Object.entries(e.variants)){const s={};for(const[a,o]of Object.entries(c))o==null?s[a]=null:s[a]=B(o,r);t[i]=s}n.variants=t}return e.defaultVariants&&(n.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(n.compoundVariants=e.compoundVariants.map(t=>({match:{...t.match},css:B(t.css,r)}))),n}function de(e){return!v(e)&&typeof e=="object"&&e!==null}function K(e,r){const n=(t,i,c)=>{let s=r.get(t);s||(s=[],r.set(t,s)),s.push({value:i,modifiers:c})};for(const[t,i]of Object.entries(e))if(de(i)){const c=t.split(":");for(const[s,a]of Object.entries(i))n(s,a,c)}else n(t,i,[])}function D(e,r){const n=e.utilities.find(i=>i.name===r);if(n)return n;const t=r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`);return e.utilities.find(i=>i.name===t)}function me(e,r){const n=new Map;if(e.base&&K(e.base,n),e.variants)for(const i of Object.values(e.variants))for(const c of Object.values(i))K(c,n);if(e.compoundVariants)for(const i of e.compoundVariants)i.css&&K(i.css,n);const t=new Map;for(const[i,c]of n){const s=D(r,i);if(!s){console.warn(`[styleframe] Utility "${i}" not found in registry. Skipping.`);continue}for(const a of c){const o=[];for(const f of a.modifiers){if(!t.has(f))try{t.set(f,ee(r,f))}catch{console.warn(`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`),t.set(f,null)}const y=t.get(f);y&&o.push(y)}s.create([a.value],o.length>0?o:void 0)}}}function Oe(e){const r=x("sf-"),n=ce(),t={...e},i=fe(n,n),c=oe(n,n),s=ue(n,n),a=ae(n,n),{variable:o,selector:f,atRule:y,keyframes:l,media:d,ref:g,css:m}=k(n,n);return{id:r,root:n,variable:o,selector:f,utility:i,modifier:c,recipe:s,theme:a,atRule:y,keyframes:l,media:d,ref:g,css:m,options:t}}u.applyModifiers=se,u.capitalizeFirst=ke,u.combineKeys=ie,u.createAtRuleFunction=T,u.createCssFunction=z,u.createDeclarationsCallbackContext=k,u.createKeyframesFunction=Y,u.createMediaFunction=G,u.createModifierFunction=oe,u.createRecipeFunction=ue,u.createRefFunction=Z,u.createRoot=ce,u.createSelectorFunction=J,u.createThemeFunction=ae,u.createUtilityFunction=fe,u.createVariableFunction=Q,u.deepClone=O,u.generateRandomId=x,u.generateRecipeRuntime=ye,u.getModifier=ee,u.getUtility=Ve,u.getVariable=Re,u.isAtRule=ge,u.isCSS=M,u.isContainer=L,u.isModifier=q,u.isObject=b,u.isPrimitiveTokenValue=I,u.isRecipe=je,u.isRef=v,u.isRoot=R,u.isSelector=pe,u.isStyleframe=ve,u.isTheme=Ae,u.isToken=h,u.isTokenEqual=$,u.isTokenValue=C,u.isUtility=be,u.isVariable=W,u.merge=Me,u.mergeContainers=N,u.mergeThemesArray=re,u.mergeVariablesArray=ne,u.parseDeclarationsBlock=V,u.processRecipeUtilities=me,u.rfdc=X,u.styleframe=Oe,u.transformUtilityKey=U,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(u,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(u=typeof globalThis<"u"?globalThis:u||self,b(u.styleframe={}))})(this,(function(u){"use strict";function b(e){return typeof e=="object"&&e!==null}function h(e,r){return b(e)&&"type"in e&&e.type===r}function W(e){return h(e,"variable")}function v(e){return h(e,"reference")}function ge(e){return h(e,"selector")}function be(e){return h(e,"at-rule")}function Ae(e){return h(e,"utility")}function q(e){return h(e,"modifier")}function M(e){return h(e,"css")}function je(e){return h(e,"theme")}function w(e){return h(e,"root")}function ve(e){return h(e,"recipe")}function I(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function C(e){return I(e)||v(e)||M(e)||Array.isArray(e)&&e.every(C)}function L(e){return b(e)&&"children"in e&&"declarations"in e&&"variables"in e}function ke(e){return b(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&w(e.root)}function z(e){let r=5381;for(let n=0;n<e.length;n++)r=(r<<5)+r+e.charCodeAt(n)&4294967295;return(r>>>0).toString(16).padStart(7,"0").slice(0,7)}function U(e){const r=typeof e=="function"?{replacer:e}:e??{},{replacer:n=c=>c,namespace:t}=r,i=Array.isArray(t)?t:t?[t]:[];return c=>{let s=c,a;if(typeof s=="string"&&s[0]==="@"){const o=s.slice(1),f=i.find(d=>o===d||o.startsWith(`${d}.`));let y,l;f?(y=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):i.length>0?(y=`${i[0]}.${o}`,l=o):(y=o,l=o),a=n(l),s={type:"reference",name:y}}else if(v(s)){let o=s.name;for(const f of i)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=n(o)}else{const o=String(c).trim();/\s/.test(o)?a=z(o):a=`[${o}]`}return{[a]:s}}}function G(e,r){return function(t,...i){return{type:"css",value:t.reduce((s,a,o)=>(s.push(a),o<i.length&&s.push(i[o]),s),[])}}}function T(e,r){return function(t,i,c){const s={type:"at-rule",identifier:t,rule:i,declarations:{},variables:[],children:[]},a=k(s,r);return typeof c=="function"?s.declarations=c(a)??{}:c&&(s.declarations=c),R(s.declarations,a),e.children.push(s),s}}function Y(e,r){const n=T(e,r);return function(i,c){return n("media",i,c)}}function Z(e,r){const n=T(e,r);return function(i,c){return n("keyframes",i,c)}}function J(e,r){return function(t,i){return W(t)?{type:"reference",name:t.name,fallback:i}:{type:"reference",name:t,fallback:i}}}function Q(e,r){return function(t,i){const c={type:"selector",query:t,declarations:{},variables:[],children:[]},s=k(c,r);return typeof i=="function"?c.declarations=i(s)??{}:L(i)?(c.variables=i.variables,c.declarations=i.declarations,c.children=i.children):c.declarations=i,R(c.declarations,s),e.children.push(c),c}}function X(e,r){return function(t,i,c={default:!1}){const s=typeof t=="string"?t:t.name,a=e.variables.find(f=>f.name===s);if(c.default&&a)return a;if(a)return a.value=i,a;const o={type:"variable",name:s,value:i};return e.variables.push(o),o}}function k(e,r){const n=X(e),t=Q(e,r),i=T(e,r),c=Z(r,r),s=Y(e,r),a=J(),o=G();return{variable:n,selector:t,keyframes:c,atRule:i,media:s,ref:a,css:o}}function R(e,r){for(const n in e)if(n.startsWith("@")){const t=e[n];if(typeof t=="object"&&t!==null&&!C(t)){const i=n.replace(/^@(\w+).*/,"$1"),c=n.replace(`@${i}`,"").trim();r.atRule(i,c,t),delete e[n]}}else if(/^[.&:]/.test(n)||/^\d+%$/.test(n)||n==="from"||n==="to"){const t=e[n];typeof t=="object"&&(r.selector(n,t),delete e[n])}for(const n in e){const t=e[n];typeof t=="string"&&t[0]==="@"&&(e[n]=r.ref(t.slice(1)))}return e}function Ve(e){return e.charAt(0).toUpperCase()+e.slice(1)}function V(e){if(e instanceof Buffer)return Buffer.from(e);const r=e.constructor;return new r(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function x(e){if(e=e||{},e.circular)return we(e);const r=new Map;if(r.set(Date,s=>new Date(s)),r.set(Map,(s,a)=>new Map(t(Array.from(s),a))),r.set(Set,(s,a)=>new Set(t(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)r.set(s[0],s[1]);let n;return e.proto?c:i;function t(s,a){const o=Object.keys(s),f=Array.from({length:o.length});for(let y=0;y<o.length;y++){const l=o[y],d=s[l];typeof d!="object"||d===null?f[l]=d:d.constructor!==Object&&(n=r.get(d.constructor))?f[l]=n(d,a):ArrayBuffer.isView(d)?f[l]=V(d):f[l]=a(d)}return f}function i(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,i);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,i);const a={};for(const o in s){if(Object.hasOwnProperty.call(s,o)===!1)continue;const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,i):ArrayBuffer.isView(f)?a[o]=V(f):a[o]=i(f)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,c);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,c);const a={};for(const o in s){const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,c):ArrayBuffer.isView(f)?a[o]=V(f):a[o]=c(f)}return a}}function we(e){const r=[],n=[],t=new Map;if(t.set(Date,o=>new Date(o)),t.set(Map,(o,f)=>new Map(c(Array.from(o),f))),t.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)t.set(o[0],o[1]);let i;return e.proto?a:s;function c(o,f){const y=Object.keys(o),l=Array.from({length:y.length});for(let d=0;d<y.length;d++){const g=y[d],m=o[g];if(typeof m!="object"||m===null)l[g]=m;else if(m.constructor!==Object&&(i=t.get(m.constructor)))l[g]=i(m,f);else if(ArrayBuffer.isView(m))l[g]=V(m);else{const F=r.indexOf(m);F!==-1?l[g]=n[F]:l[g]=f(m)}}return l}function s(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,s);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,s);const f={};r.push(o),n.push(f);for(const y in o){if(Object.hasOwnProperty.call(o,y)===!1)continue;const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,s);else if(ArrayBuffer.isView(l))f[y]=V(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=s(l)}}return r.pop(),n.pop(),f}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,a);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,a);const f={};r.push(o),n.push(f);for(const y in o){const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,a);else if(ArrayBuffer.isView(l))f[y]=V(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=a(l)}}return r.pop(),n.pop(),f}}const O=x();function ee(e,r=8){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let i=0;i<r;i++){const c=Math.floor(Math.random()*n.length);t+=n[c]}return e?`${e}${t}`:t}function Re(e,r){const n=e.variables.find(t=>t.name===r);if(!n)throw new Error(`Variable "${r}" not found`);return n}function Fe(e,r){const n=e.utilities.find(t=>t.name===r);if(!n)throw new Error(`Utility "${r}" not found`);return n}function te(e,r){const n=e.modifiers.find(t=>t.key.includes(r));if(!n)throw new Error(`Modifier "${r}" not found`);return n}function S(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(e===null||r===null)return e===r;if(typeof e!="object"||typeof r!="object")return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((n,t)=>S(n,r[t]));if("type"in e&&"type"in r){if(e.type!==r.type)return!1;if(v(e)&&v(r))return e.name===r.name&&S(e.fallback,r.fallback);if(M(e)&&M(r))return S(e.value,r.value)}return!1}const ne="__licenseRequired";function Me(e){E(e)||Object.defineProperty(e,ne,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function E(e){return Object.prototype.hasOwnProperty.call(e,ne)}function re(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?i.value=t.value:n.push(t)}return n}function ie(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?Object.assign(i,N(i,t)):n.push(t)}return n}function N(e,r){return Object.keys(e).reduce((n,t)=>(t==="variables"?n.variables=re(e.variables,r.variables):t==="declarations"?n.declarations={...e.declarations,...r.declarations}:t==="themes"&&w(n)&&w(e)&&w(r)?n.themes=ie(e.themes,r.themes):Array.isArray(e[t])&&(n[t]=e[t].concat(r[t])),n),{...e,...r})}function Te(e,...r){return r.reduce((n,t)=>{const i={...n,root:N(n.root,t.root)};return(E(n)||E(t))&&Me(i),i},e)}function se(e){const r=[];function n(t,i){i.length>0&&r.push([...i].sort());for(let c=t;c<e.length;c++){const s=e[c];if(s)if(s.length===1&&s[0])n(c+1,[...i,s[0]]);else for(const a of s)n(c+1,[...i,a])}}return n(0,[]),r.sort((t,i)=>t.length!==i.length?t.length-i.length:t.join(",").localeCompare(i.join(",")))}function oe(e,r,n){const t={...e,modifiers:[...n.keys()]},i=k(t,r);for(const c of n.values())c.factory({...i,declarations:O(t.declarations),variables:O(t.variables),children:O(t.children)}),R(t.declarations,i);return t}function ce(e,r){return function(t,i){const c={type:"modifier",key:Array.isArray(t)?t:[t],factory:i};return r.modifiers.push(c),c}}function fe(){return{type:"root",declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[]}}function Oe(e,r){const n=U({namespace:e});return t=>{if(typeof t=="string"&&t[0]==="@"){const i=t.slice(1),c=e.find(s=>i===s||i.startsWith(`${s}.`));if(c){const s=i.slice(c.length+1)||i;if(r.variables.some(a=>a.name===i))return{[s]:{type:"reference",name:i}}}else for(const s of e){const a=`${s}.${i}`;if(r.variables.some(o=>o.name===a))return{[i]:{type:"reference",name:a}}}return n(t)}return n(t)}}function ae(e,r){return function(t,i,c={}){const s={type:"utility",name:t,factory:i,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?Oe(c.namespace,r):U(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(a,o=[])=>{let f=a;if(Array.isArray(a)){f={};for(const y of a){const l=s.autogenerate(y);f={...f,...l}}}for(const[y,l]of Object.entries(f)){let d=l;if(s.namespace&&v(l))if(r.variables.some(A=>A.name===l.name))d=l;else{const A=Array.isArray(s.namespace)?s.namespace:[s.namespace];let _=!1;for(const P of A){const p=`${P}.${y}`;if(p!==l.name&&r.variables.some(j=>j.name===p)){d={type:"reference",name:p},_=!0;break}}_||(d=y)}const g=s.values.find(A=>A.key===y&&A.modifiers.length===0),m={type:"utility",name:t,value:y,declarations:{},variables:[],children:[],modifiers:[]},F=k(m,r);if(m.declarations=i({...F,value:d})??{},R(m.declarations,F),g||(s.values.push({key:y,value:d,modifiers:[]}),e.children.push(m)),o&&o.length>0){const A=o.map(p=>p.key),P=se(A).filter(p=>!s.values.find(j=>j.key===y&&j.modifiers.length===p.length&&j.modifiers.every($=>p.includes($)))).reduce((p,j)=>{const $=new Map;for(const pe of j){const H=o.find($e=>$e.key.includes(pe));H&&q(H)&&$.set(pe,H)}return s.values.push({key:y,value:d,modifiers:j}),p.push(oe(m,r,$)),p},[]);e.children.push(...P)}}}};return r.utilities.push(s),s.create}}function ue(e,r){return function(t,i){const c=r.themes.find(o=>o.name===t),s=c??{type:"theme",name:t,declarations:{},variables:[],children:[]};c||r.themes.push(s);const a=k(s,r);return i&&i(a),s}}function le(e,r){return function(t){const i={type:"recipe",...t};return i._runtime=de(i,r),he(i,r),r.recipes.push(i),i}}function ye(e,r){const n=e.autogenerate(r);return Object.keys(n)[0]??"default"}function B(e,r){const n={};for(const[t,i]of Object.entries(e))if(me(i)){const c={};for(const[s,a]of Object.entries(i)){const o=D(r,s);o?c[s]=ye(o,a):console.warn(`[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`)}n[t]=c}else if(typeof i=="boolean")n[t]=i;else{const c=D(r,t);c?n[t]=ye(c,i):console.warn(`[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`)}return n}function de(e,r){const n={};if(e.base&&(n.base=B(e.base,r)),e.variants){const t={};for(const[i,c]of Object.entries(e.variants)){const s={};for(const[a,o]of Object.entries(c))o==null?s[a]=null:s[a]=B(o,r);t[i]=s}n.variants=t}return e.defaultVariants&&(n.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(n.compoundVariants=e.compoundVariants.map(t=>({match:{...t.match},css:B(t.css,r)}))),n}function me(e){return!v(e)&&typeof e=="object"&&e!==null}function K(e,r){const n=(t,i,c)=>{let s=r.get(t);s||(s=[],r.set(t,s)),s.push({value:i,modifiers:c})};for(const[t,i]of Object.entries(e))if(me(i)){const c=t.split(":");for(const[s,a]of Object.entries(i))n(s,a,c)}else n(t,i,[])}function D(e,r){const n=e.utilities.find(i=>i.name===r);if(n)return n;const t=r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`);return e.utilities.find(i=>i.name===t)}function he(e,r){const n=new Map;if(e.base&&K(e.base,n),e.variants)for(const i of Object.values(e.variants))for(const c of Object.values(i))K(c,n);if(e.compoundVariants)for(const i of e.compoundVariants)i.css&&K(i.css,n);const t=new Map;for(const[i,c]of n){const s=D(r,i);if(!s){console.warn(`[styleframe] Utility "${i}" not found in registry. Skipping.`);continue}for(const a of c){const o=[];for(const f of a.modifiers){if(!t.has(f))try{t.set(f,te(r,f))}catch{console.warn(`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`),t.set(f,null)}const y=t.get(f);y&&o.push(y)}s.create([a.value],o.length>0?o:void 0)}}}function Se(e){const r=ee("sf-"),n=fe(),t={...e},i=ae(n,n),c=ce(n,n),s=le(n,n),a=ue(n,n),{variable:o,selector:f,atRule:y,keyframes:l,media:d,ref:g,css:m}=k(n,n);return{id:r,root:n,variable:o,selector:f,utility:i,modifier:c,recipe:s,theme:a,atRule:y,keyframes:l,media:d,ref:g,css:m,options:t}}u.applyModifiers=oe,u.capitalizeFirst=Ve,u.combineKeys=se,u.createAtRuleFunction=T,u.createCssFunction=G,u.createDeclarationsCallbackContext=k,u.createKeyframesFunction=Z,u.createMediaFunction=Y,u.createModifierFunction=ce,u.createRecipeFunction=le,u.createRefFunction=J,u.createRoot=fe,u.createSelectorFunction=Q,u.createThemeFunction=ue,u.createUtilityFunction=ae,u.createVariableFunction=X,u.deepClone=O,u.generateRandomId=ee,u.generateRecipeRuntime=de,u.getModifier=te,u.getUtility=Fe,u.getVariable=Re,u.hashValue=z,u.isAtRule=be,u.isCSS=M,u.isContainer=L,u.isModifier=q,u.isObject=b,u.isPrimitiveTokenValue=I,u.isRecipe=ve,u.isRef=v,u.isRoot=w,u.isSelector=ge,u.isStyleframe=ke,u.isTheme=je,u.isToken=h,u.isTokenEqual=S,u.isTokenValue=C,u.isUtility=Ae,u.isVariable=W,u.merge=Te,u.mergeContainers=N,u.mergeThemesArray=ie,u.mergeVariablesArray=re,u.parseDeclarationsBlock=R,u.processRecipeUtilities=he,u.rfdc=x,u.styleframe=Se,u.transformUtilityKey=U,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@styleframe/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "types": "./dist/styleframe.d.ts",
6
6
  "module": "./dist/styleframe.js",