@fluixi-css/core 1.0.0-next.1 → 1.0.0-next.2

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 (48) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/reset.css +174 -152
  3. package/dist/src/css-parser.cjs +6 -1
  4. package/dist/src/css-parser.cjs.map +1 -1
  5. package/dist/src/css-parser.js +6 -2
  6. package/dist/src/css-parser.js.map +1 -1
  7. package/dist/src/css-parser.mjs +6 -1
  8. package/dist/src/css-parser.mjs.map +1 -1
  9. package/dist/src/engine/apply.d.ts +2 -0
  10. package/dist/src/engine/apply.js +75 -0
  11. package/dist/src/engine/apply.js.map +1 -0
  12. package/dist/src/engine/ast.js +25 -2
  13. package/dist/src/engine/ast.js.map +1 -1
  14. package/dist/src/engine/compile.js +48 -10
  15. package/dist/src/engine/compile.js.map +1 -1
  16. package/dist/src/engine/directives.js +45 -19
  17. package/dist/src/engine/directives.js.map +1 -1
  18. package/dist/src/engine/index.d.ts +4 -0
  19. package/dist/src/engine/index.js +6 -0
  20. package/dist/src/engine/index.js.map +1 -1
  21. package/dist/src/engine/log.d.ts +6 -0
  22. package/dist/src/engine/log.js +42 -0
  23. package/dist/src/engine/log.js.map +1 -0
  24. package/dist/src/engine/registry.d.ts +5 -4
  25. package/dist/src/engine/registry.js +2 -2
  26. package/dist/src/engine/registry.js.map +1 -1
  27. package/dist/src/engine/transform.d.ts +22 -0
  28. package/dist/src/engine/transform.js +34 -9
  29. package/dist/src/engine/transform.js.map +1 -1
  30. package/dist/src/engine/utilities/backgrounds.js +11 -0
  31. package/dist/src/engine/utilities/backgrounds.js.map +1 -1
  32. package/dist/src/engine/utilities/borders.js +60 -1
  33. package/dist/src/engine/utilities/borders.js.map +1 -1
  34. package/dist/src/engine/utilities/layout.js +25 -0
  35. package/dist/src/engine/utilities/layout.js.map +1 -1
  36. package/dist/src/engine/utilities/spacing.js +25 -1
  37. package/dist/src/engine/utilities/spacing.js.map +1 -1
  38. package/dist/src/engine/utilities/typography.js +7 -0
  39. package/dist/src/engine/utilities/typography.js.map +1 -1
  40. package/dist/src/engine/variants.js +25 -6
  41. package/dist/src/engine/variants.js.map +1 -1
  42. package/dist/src/index.cjs +619 -179
  43. package/dist/src/index.cjs.map +1 -1
  44. package/dist/src/index.mjs +618 -180
  45. package/dist/src/index.mjs.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +1 -1
  48. package/reset.css +174 -152
@@ -275,6 +275,34 @@ var Writer = /*#__PURE__*/function () {
275
275
  });
276
276
  }
277
277
  }
278
+
279
+ // Emit verbatim text (a passed-through author slice or the reset) mapping each
280
+ // of its lines to consecutive source lines — so multi-line blocks are covered,
281
+ // not just their first line.
282
+ }, {
283
+ key: "emitMapped",
284
+ value: function emitMapped(text, loc) {
285
+ if (!this.map) {
286
+ this.emit(text);
287
+ return;
288
+ }
289
+ var lines = text.split('\n');
290
+ for (var i = 0; i < lines.length; i++) {
291
+ this.map.addMapping({
292
+ source: loc.source,
293
+ original: {
294
+ line: loc.line + i,
295
+ column: i === 0 ? loc.column : 0
296
+ },
297
+ generated: {
298
+ line: this.line,
299
+ column: this.column
300
+ }
301
+ });
302
+ this.emit(lines[i]);
303
+ if (i < lines.length - 1) this.emit('\n');
304
+ }
305
+ }
278
306
  }]);
279
307
  }();
280
308
  function stringify(nodes) {
@@ -330,8 +358,8 @@ function write(node, depth, opts, w) {
330
358
  }
331
359
  if (node.kind === 'raw') {
332
360
  w.emit(pad);
333
- w.mark(node.loc);
334
- w.emit("".concat(node.text).concat(nl));
361
+ if (node.loc) w.emitMapped(node.text, node.loc);else w.emit(node.text);
362
+ w.emit(nl);
335
363
  return;
336
364
  }
337
365
  var header = node.kind === 'rule' ? node.selector : "@".concat(node.name).concat(node.params ? ' ' + node.params : '');
@@ -673,6 +701,298 @@ function splitRootValue(base, ctx) {
673
701
  };
674
702
  }
675
703
 
704
+ // Turns a parsed atom into CSS. Returns null when the utility or any of its
705
+ // variants aren't registered, so an unknown class simply produces nothing.
706
+ function compileAtom(atom, reg) {
707
+ var produced = producedFor(atom, reg);
708
+ if (!produced || produced.length === 0) return null;
709
+ var flat = [];
710
+ var nested = [];
711
+ var _iterator = _createForOfIteratorHelper(produced),
712
+ _step;
713
+ try {
714
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
715
+ var node = _step.value;
716
+ if (node.kind === 'declaration') flat.push(node);else nested.push(node);
717
+ }
718
+ } catch (err) {
719
+ _iterator.e(err);
720
+ } finally {
721
+ _iterator.f();
722
+ }
723
+ if (atom.important) {
724
+ var _iterator2 = _createForOfIteratorHelper(flat),
725
+ _step2;
726
+ try {
727
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
728
+ var d = _step2.value;
729
+ d.important = true;
730
+ }
731
+ } catch (err) {
732
+ _iterator2.e(err);
733
+ } finally {
734
+ _iterator2.f();
735
+ }
736
+ var _iterator3 = _createForOfIteratorHelper(nested),
737
+ _step3;
738
+ try {
739
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
740
+ var n = _step3.value;
741
+ markImportant$1(n.nodes);
742
+ }
743
+ } catch (err) {
744
+ _iterator3.e(err);
745
+ } finally {
746
+ _iterator3.f();
747
+ }
748
+ }
749
+ var selector = '.' + escapeClass(atom.raw);
750
+ var atRules = [];
751
+ var _iterator4 = _createForOfIteratorHelper(atom.variants),
752
+ _step4;
753
+ try {
754
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
755
+ var variant = _step4.value;
756
+ var wrap = resolveVariant(variant, reg);
757
+ if (!wrap) return null;
758
+ if (wrap.selector) selector = substitute(wrap.selector, selector);
759
+ if (wrap.atRule) atRules.push(wrap.atRule);
760
+ }
761
+
762
+ // Flat declarations sit on the utility's own selector; nested rules weave that
763
+ // selector into their `&` (`space-x-4` → `.space-x-4 > :not([hidden]) ~ …`).
764
+ } catch (err) {
765
+ _iterator4.e(err);
766
+ } finally {
767
+ _iterator4.f();
768
+ }
769
+ var nodes = [];
770
+ if (flat.length) nodes.push(rule(selector, flat));
771
+ for (var _i = 0, _nested = nested; _i < _nested.length; _i++) {
772
+ var _n = _nested[_i];
773
+ nodes.push(rule(substitute(_n.selector, selector), _n.nodes));
774
+ }
775
+ for (var _i2 = 0, _atRules = atRules; _i2 < _atRules.length; _i2++) {
776
+ var ar = _atRules[_i2];
777
+ nodes = [atRule(ar.name, ar.params, nodes)];
778
+ }
779
+ return nodes;
780
+ }
781
+ function markImportant$1(nodes) {
782
+ var _iterator5 = _createForOfIteratorHelper(nodes),
783
+ _step5;
784
+ try {
785
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
786
+ var n = _step5.value;
787
+ if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant$1(n.nodes);
788
+ }
789
+ } catch (err) {
790
+ _iterator5.e(err);
791
+ } finally {
792
+ _iterator5.f();
793
+ }
794
+ }
795
+ function producedFor(atom, reg) {
796
+ if (atom.kind === 'arbitrary-property') {
797
+ return [decl(atom.property, atom.value)];
798
+ }
799
+ if (atom.kind === 'static') {
800
+ // Clone: static templates are shared, and `!important` / `&`-weaving mutate.
801
+ var products = reg.getRule(atom.root);
802
+ return products ? products.map(cloneProduct) : null;
803
+ }
804
+ var handler = reg.getDynamicRule(atom.root);
805
+ if (!handler) return null;
806
+ return handler({
807
+ value: atom.value,
808
+ modifier: atom.modifier,
809
+ negative: atom.negative,
810
+ theme: reg.theme
811
+ });
812
+ }
813
+ function cloneProduct(n) {
814
+ return n.kind === 'declaration' ? _objectSpread2({}, n) : cloneNode(n);
815
+ }
816
+ function cloneNode(n) {
817
+ if (n.kind === 'declaration') return _objectSpread2({}, n);
818
+ if (n.kind === 'rule') return rule(n.selector, n.nodes.map(cloneNode));
819
+ if (n.kind === 'at-rule') return atRule(n.name, n.params, n.nodes.map(cloneNode));
820
+ return _objectSpread2({}, n);
821
+ }
822
+ function resolveVariant(variant, reg) {
823
+ if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
824
+ if (variant.kind === 'static') return reg.getVariant(variant.root);
825
+ // functional: a null value means it's really a static variant (hover, md, …).
826
+ if (variant.value === null) return reg.getVariant(variant.root);
827
+ var handler = reg.getDynamicVariant(variant.root);
828
+ return handler ? handler(variant.value, variant.modifier) : null;
829
+ }
830
+
831
+ // `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
832
+ // A bare selector with no `&` is attached to the element.
833
+ function arbitraryVariant(source) {
834
+ if (source[0] === '@') {
835
+ var cut = source.search(/[\s(]/);
836
+ var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
837
+ var params = cut === -1 ? '' : source.slice(cut).trim();
838
+ return {
839
+ atRule: {
840
+ name: name,
841
+ params: params
842
+ }
843
+ };
844
+ }
845
+ var sel = spacesFromUnderscores(source);
846
+ return {
847
+ selector: sel.includes('&') ? sel : "&".concat(sel)
848
+ };
849
+ }
850
+ function spacesFromUnderscores(s) {
851
+ return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
852
+ }
853
+ function substitute(template, current) {
854
+ return template.replace(/&/g, current);
855
+ }
856
+
857
+ // Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
858
+ // class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
859
+ function escapeClass(name) {
860
+ return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
861
+ return '\\' + c;
862
+ });
863
+ }
864
+
865
+ // `@apply a b c;` — inline the declarations those utilities produce into the
866
+ // surrounding rule. Operates on author-CSS text (which `transform` passes through
867
+ // verbatim), replacing each `@apply` at-rule in place. Flat utilities inline as
868
+ // declarations; utilities that need their own selector (variants like `hover:` /
869
+ // `group-hover:`, child-combinators like `space-x`, at-rule variants like `md:`)
870
+ // emit a nested rule with `&` bound to the applying selector.
871
+ var APPLY_RE = /@apply\s+([^;{}]+);/g;
872
+ function expandApply(css, reg) {
873
+ if (!css.includes('@apply')) return css;
874
+ return css.replace(APPLY_RE, function (_match, listRaw) {
875
+ var list = listRaw.trim();
876
+ // A trailing `!important` marks every inlined declaration (Tailwind semantics).
877
+ var important = false;
878
+ var bang = list.match(/!important\s*$/);
879
+ if (bang) {
880
+ important = true;
881
+ list = list.slice(0, bang.index).trim();
882
+ }
883
+ var decls = [];
884
+ var rules = [];
885
+ var _iterator = _createForOfIteratorHelper(list.split(/\s+/)),
886
+ _step;
887
+ try {
888
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
889
+ var token = _step.value;
890
+ if (!token) continue;
891
+ var out = compileForApply(token, reg, important);
892
+ if (!out) continue;
893
+ if (out.decls) decls.push.apply(decls, _toConsumableArray(out.decls));
894
+ if (out.rule) rules.push(out.rule);
895
+ }
896
+ // Flat declarations first, then nested rules — same order as authored.
897
+ } catch (err) {
898
+ _iterator.e(err);
899
+ } finally {
900
+ _iterator.f();
901
+ }
902
+ return [].concat(decls, rules).join(' ');
903
+ });
904
+ }
905
+ function compileForApply(cls, reg, important) {
906
+ var atom = parseAtom(cls, reg);
907
+ if (!atom) return null;
908
+ var compiled = compileAtom(atom, reg);
909
+ if (!compiled || compiled.length === 0) return null;
910
+ var classSelector = '.' + escapeClass(atom.raw);
911
+
912
+ // A plain utility — one rule on the class itself with only declarations — inlines
913
+ // straight into the applying rule.
914
+ if (compiled.length === 1 && compiled[0].kind === 'rule' && compiled[0].selector === classSelector) {
915
+ var flat = compiled[0].nodes;
916
+ if (flat.every(function (n) {
917
+ return n.kind === 'declaration';
918
+ })) {
919
+ return {
920
+ decls: flat.map(function (n) {
921
+ return declText(n, important);
922
+ })
923
+ };
924
+ }
925
+ }
926
+
927
+ // Everything else keeps its structure but nests: swap the class's own selector
928
+ // for `&`, so `hover:` → `&:hover`, `group-hover:` → `.group:hover &`, `md:` →
929
+ // `@media(...) { & { … } }`.
930
+ if (important) markImportant(compiled);
931
+ var text = stringify(compiled, {
932
+ minify: false
933
+ }).split(classSelector).join('&');
934
+ return {
935
+ rule: text
936
+ };
937
+ }
938
+ function declText(d, important) {
939
+ return "".concat(d.property, ": ").concat(d.value).concat(important || d.important ? ' !important' : '', ";");
940
+ }
941
+ function markImportant(nodes) {
942
+ var _iterator2 = _createForOfIteratorHelper(nodes),
943
+ _step2;
944
+ try {
945
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
946
+ var n = _step2.value;
947
+ if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant(n.nodes);
948
+ }
949
+ } catch (err) {
950
+ _iterator2.e(err);
951
+ } finally {
952
+ _iterator2.f();
953
+ }
954
+ }
955
+
956
+ // Renders a `transform()` result as a compact, colourised build line for the
957
+ // Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays
958
+ // side-effect free — the plugins own the actual `console.log`.
959
+
960
+ var ANSI = {
961
+ reset: '\x1b[0m',
962
+ dim: '\x1b[2m',
963
+ bold: '\x1b[1m',
964
+ cyan: '\x1b[36m',
965
+ green: '\x1b[32m',
966
+ yellow: '\x1b[33m',
967
+ red: '\x1b[31m'
968
+ };
969
+ function paint(code, s, color) {
970
+ return color ? code + s + ANSI.reset : s;
971
+ }
972
+ function humanBytes(n) {
973
+ return n < 1024 ? "".concat(n, " B") : "".concat((n / 1024).toFixed(1), " kB");
974
+ }
975
+ function humanMs(ms) {
976
+ return ms < 1 ? "".concat(ms * 1000 | 0, " \xB5s") : ms < 1000 ? "".concat(ms.toFixed(1), " ms") : "".concat((ms / 1000).toFixed(2), " s");
977
+ }
978
+
979
+ // Green under 10 ms, yellow under 50 ms, red beyond — a quick "is it fast?" cue.
980
+ function timeColor(ms) {
981
+ return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;
982
+ }
983
+ function formatBuildLog(label, stats) {
984
+ var _options$color;
985
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
986
+ var color = (_options$color = options.color) !== null && _options$color !== void 0 ? _options$color : true;
987
+ var head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);
988
+ var name = paint(ANSI.bold, label, color);
989
+ var time = paint(timeColor(stats.ms), humanMs(stats.ms), color);
990
+ var parts = ["".concat(stats.utilities, " ").concat(stats.utilities === 1 ? 'utility' : 'utilities'), "".concat(stats.scanned, " scanned"), humanBytes(stats.bytes)];
991
+ if (stats.sources) parts.push("".concat(stats.sources, " ").concat(stats.sources === 1 ? 'source' : 'sources'));
992
+ var detail = paint(ANSI.dim, parts.join(' · '), color);
993
+ return "".concat(head, " ").concat(name, " ").concat(time, "\n ").concat(detail);
994
+ }
995
+
676
996
  // The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
677
997
  // `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
678
998
  // `var()` references, so the tokens stay live and themeable at runtime.
@@ -1076,8 +1396,13 @@ var CssParser = /*#__PURE__*/function () {
1076
1396
  case 'counter-style':
1077
1397
  case 'viewport':
1078
1398
  case 'theme':
1079
- case 'utility':
1080
1399
  return 'declarations';
1400
+ // `@utility` bodies mix flat declarations with nested rules
1401
+ // (`&:hover`, `&::-webkit-scrollbar`); `rule` mode does the
1402
+ // declaration-vs-nesting lookahead. (`mixed` would read every line
1403
+ // as a selector and corrupt the block.)
1404
+ case 'utility':
1405
+ return 'rule';
1081
1406
  case 'media':
1082
1407
  case 'supports':
1083
1408
  case 'container':
@@ -2244,53 +2569,84 @@ function registerUtility(atRule, reg) {
2244
2569
  var _atRule$preludeText;
2245
2570
  var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
2246
2571
  if (!name || !atRule.block) return;
2247
- var decls = atRule.block.children.filter(function (c) {
2248
- return c.type === 'declaration';
2249
- }).map(function (d) {
2250
- var _d$rawValue;
2251
- return decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true);
2252
- });
2253
- if (decls.length === 0) return;
2572
+
2573
+ // Flat declarations plus any nested rules (`&:hover`, `&::-webkit-scrollbar`);
2574
+ // the nested `&` is later woven with the utility's own selector by the compiler.
2575
+ var products = toProducts(atRule.block.children);
2576
+ if (products.length === 0) return;
2254
2577
 
2255
2578
  // A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
2256
2579
  if (name.endsWith('-*')) {
2257
2580
  var root = name.slice(0, -2);
2258
2581
  if (root) reg.dynamicRule(root, function (ctx) {
2259
- return resolveDeclarations(decls, ctx);
2582
+ return resolveProducts(products, ctx);
2260
2583
  });
2261
2584
  return;
2262
2585
  }
2263
- reg.rule(name, decls);
2586
+ reg.rule(name, products);
2264
2587
  }
2265
-
2266
- // Applies a functional utility's declaration templates to one atom. `--value()`
2267
- // is required — if it can't resolve, the whole utility is dropped (returns null).
2268
- // `--modifier()` is optional — a declaration using it is skipped when there's no
2269
- // matching modifier, so `text-lg` and `text-lg/7` share one definition.
2270
- function resolveDeclarations(templates, ctx) {
2588
+ function toProducts(children) {
2271
2589
  var out = [];
2272
- var _iterator2 = _createForOfIteratorHelper(templates),
2590
+ var _iterator2 = _createForOfIteratorHelper(children),
2273
2591
  _step2;
2274
2592
  try {
2275
2593
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2276
- var t = _step2.value;
2277
- var withValue = replaceFn(t.value, '--value', function (args) {
2278
- return resolveValue(args, ctx);
2279
- });
2280
- if (withValue === null) return null;
2281
- var withModifier = replaceFn(withValue, '--modifier', function (args) {
2282
- return resolveModifier(args, ctx);
2283
- });
2284
- if (withModifier === null) continue;
2285
- out.push(_objectSpread2(_objectSpread2({}, t), {}, {
2286
- value: withModifier
2287
- }));
2594
+ var c = _step2.value;
2595
+ if (c.type === 'declaration') {
2596
+ var _d$rawValue;
2597
+ var d = c;
2598
+ out.push(decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true));
2599
+ } else if (c.type === 'rule') {
2600
+ var _r$declarations, _r$children, _r$rawSelector;
2601
+ var r = c;
2602
+ // The parser splits a rule's own declarations from its nested rules; a
2603
+ // utility body wants both, declarations first.
2604
+ var kids = [].concat(_toConsumableArray((_r$declarations = r.declarations) !== null && _r$declarations !== void 0 ? _r$declarations : []), _toConsumableArray((_r$children = r.children) !== null && _r$children !== void 0 ? _r$children : []));
2605
+ out.push(rule(((_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : '').trim(), toProducts(kids)));
2606
+ }
2288
2607
  }
2289
2608
  } catch (err) {
2290
2609
  _iterator2.e(err);
2291
2610
  } finally {
2292
2611
  _iterator2.f();
2293
2612
  }
2613
+ return out;
2614
+ }
2615
+
2616
+ // Applies a functional utility's templates to one atom, walking nested rules too.
2617
+ // `--value()` is required — if it can't resolve, the whole utility is dropped
2618
+ // (returns null). `--modifier()` is optional — a declaration using it is skipped
2619
+ // when there's no matching modifier, so `text-lg` and `text-lg/7` share one def.
2620
+ function resolveProducts(templates, ctx) {
2621
+ var out = [];
2622
+ var _iterator3 = _createForOfIteratorHelper(templates),
2623
+ _step3;
2624
+ try {
2625
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2626
+ var t = _step3.value;
2627
+ if (t.kind === 'declaration') {
2628
+ var withValue = replaceFn(t.value, '--value', function (args) {
2629
+ return resolveValue(args, ctx);
2630
+ });
2631
+ if (withValue === null) return null;
2632
+ var withModifier = replaceFn(withValue, '--modifier', function (args) {
2633
+ return resolveModifier(args, ctx);
2634
+ });
2635
+ if (withModifier === null) continue;
2636
+ out.push(_objectSpread2(_objectSpread2({}, t), {}, {
2637
+ value: withModifier
2638
+ }));
2639
+ } else {
2640
+ var inner = resolveProducts(t.nodes, ctx);
2641
+ if (inner === null) return null;
2642
+ out.push(rule(t.selector, inner));
2643
+ }
2644
+ }
2645
+ } catch (err) {
2646
+ _iterator3.e(err);
2647
+ } finally {
2648
+ _iterator3.f();
2649
+ }
2294
2650
  return out.length ? out : null;
2295
2651
  }
2296
2652
  function resolveValue(args, ctx) {
@@ -2468,6 +2824,10 @@ function wrapFor(condition) {
2468
2824
  };
2469
2825
  }
2470
2826
 
2827
+ // A utility produces declarations on its own selector, and/or nested rules whose
2828
+ // `&` is woven with that selector — the latter is how child-combinator utilities
2829
+ // like `space-x`/`divide-y` reach `& > * + *`.
2830
+
2471
2831
  // A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
2472
2832
  // the rule in an at-rule (`@media`, `@supports`). It may do both.
2473
2833
 
@@ -2498,8 +2858,8 @@ var Registry = /*#__PURE__*/function () {
2498
2858
  }
2499
2859
  return _createClass(Registry, [{
2500
2860
  key: "rule",
2501
- value: function rule(name, declarations) {
2502
- this.rules.set(name, declarations);
2861
+ value: function rule(name, products) {
2862
+ this.rules.set(name, products);
2503
2863
  return this;
2504
2864
  }
2505
2865
  }, {
@@ -2547,111 +2907,6 @@ var Registry = /*#__PURE__*/function () {
2547
2907
  }]);
2548
2908
  }();
2549
2909
 
2550
- // Turns a parsed atom into CSS. Returns null when the utility or any of its
2551
- // variants aren't registered, so an unknown class simply produces nothing.
2552
- function compileAtom(atom, reg) {
2553
- var declarations = declarationsFor(atom, reg);
2554
- if (!declarations || declarations.length === 0) return null;
2555
- if (atom.important) {
2556
- var _iterator = _createForOfIteratorHelper(declarations),
2557
- _step;
2558
- try {
2559
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2560
- var d = _step.value;
2561
- d.important = true;
2562
- }
2563
- } catch (err) {
2564
- _iterator.e(err);
2565
- } finally {
2566
- _iterator.f();
2567
- }
2568
- }
2569
- var selector = '.' + escapeClass(atom.raw);
2570
- var atRules = [];
2571
- var _iterator2 = _createForOfIteratorHelper(atom.variants),
2572
- _step2;
2573
- try {
2574
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2575
- var variant = _step2.value;
2576
- var wrap = resolveVariant(variant, reg);
2577
- if (!wrap) return null;
2578
- if (wrap.selector) selector = substitute(wrap.selector, selector);
2579
- if (wrap.atRule) atRules.push(wrap.atRule);
2580
- }
2581
- } catch (err) {
2582
- _iterator2.e(err);
2583
- } finally {
2584
- _iterator2.f();
2585
- }
2586
- var node = rule(selector, declarations);
2587
- for (var _i = 0, _atRules = atRules; _i < _atRules.length; _i++) {
2588
- var ar = _atRules[_i];
2589
- node = atRule(ar.name, ar.params, [node]);
2590
- }
2591
- return [node];
2592
- }
2593
- function declarationsFor(atom, reg) {
2594
- if (atom.kind === 'arbitrary-property') {
2595
- return [decl(atom.property, atom.value)];
2596
- }
2597
- if (atom.kind === 'static') {
2598
- var decls = reg.getRule(atom.root);
2599
- return decls ? decls.map(function (d) {
2600
- return _objectSpread2({}, d);
2601
- }) : null;
2602
- }
2603
- var handler = reg.getDynamicRule(atom.root);
2604
- if (!handler) return null;
2605
- return handler({
2606
- value: atom.value,
2607
- modifier: atom.modifier,
2608
- negative: atom.negative,
2609
- theme: reg.theme
2610
- });
2611
- }
2612
- function resolveVariant(variant, reg) {
2613
- if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
2614
- if (variant.kind === 'static') return reg.getVariant(variant.root);
2615
- // functional: a null value means it's really a static variant (hover, md, …).
2616
- if (variant.value === null) return reg.getVariant(variant.root);
2617
- var handler = reg.getDynamicVariant(variant.root);
2618
- return handler ? handler(variant.value, variant.modifier) : null;
2619
- }
2620
-
2621
- // `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
2622
- // A bare selector with no `&` is attached to the element.
2623
- function arbitraryVariant(source) {
2624
- if (source[0] === '@') {
2625
- var cut = source.search(/[\s(]/);
2626
- var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
2627
- var params = cut === -1 ? '' : source.slice(cut).trim();
2628
- return {
2629
- atRule: {
2630
- name: name,
2631
- params: params
2632
- }
2633
- };
2634
- }
2635
- var sel = spacesFromUnderscores(source);
2636
- return {
2637
- selector: sel.includes('&') ? sel : "&".concat(sel)
2638
- };
2639
- }
2640
- function spacesFromUnderscores(s) {
2641
- return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
2642
- }
2643
- function substitute(template, current) {
2644
- return template.replace(/&/g, current);
2645
- }
2646
-
2647
- // Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
2648
- // class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
2649
- function escapeClass(name) {
2650
- return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
2651
- return '\\' + c;
2652
- });
2653
- }
2654
-
2655
2910
  var Palettes = {
2656
2911
  "slate": {
2657
2912
  "50": "#f8fafc",
@@ -3126,6 +3381,23 @@ function registerBackgrounds(reg) {
3126
3381
  props(reg, 'background-image', {
3127
3382
  'bg-none': 'none'
3128
3383
  });
3384
+
3385
+ // Form-control colours.
3386
+ reg.dynamicRule('accent', function (_ref2) {
3387
+ var value = _ref2.value,
3388
+ modifier = _ref2.modifier,
3389
+ theme = _ref2.theme;
3390
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];
3391
+ var c = colorValue(value, modifier, theme);
3392
+ return c ? [decl('accent-color', c)] : null;
3393
+ });
3394
+ reg.dynamicRule('caret', function (_ref3) {
3395
+ var value = _ref3.value,
3396
+ modifier = _ref3.modifier,
3397
+ theme = _ref3.theme;
3398
+ var c = colorValue(value, modifier, theme);
3399
+ return c ? [decl('caret-color', c)] : null;
3400
+ });
3129
3401
  }
3130
3402
 
3131
3403
  function registerBorders(reg) {
@@ -3146,6 +3418,8 @@ function registerBorders(reg) {
3146
3418
  hidden: 'hidden',
3147
3419
  none: 'none'
3148
3420
  });
3421
+ divide(reg);
3422
+ ring(reg);
3149
3423
  rounded(reg, 'rounded', ['']);
3150
3424
  rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
3151
3425
  rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
@@ -3225,6 +3499,59 @@ function outline(reg) {
3225
3499
  });
3226
3500
  }
3227
3501
 
3502
+ // Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
3503
+ // set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
3504
+ // edge via a `--flx-divide-*-reverse` toggle.
3505
+ var BETWEEN$1 = '& > :not([hidden]) ~ :not([hidden])';
3506
+ function divide(reg) {
3507
+ divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
3508
+ divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
3509
+ reg.dynamicRule('divide', function (_ref4) {
3510
+ var value = _ref4.value,
3511
+ modifier = _ref4.modifier,
3512
+ theme = _ref4.theme;
3513
+ if (value === null) return null;
3514
+ var style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
3515
+ if (style) return [rule(BETWEEN$1, [decl('border-style', style)])];
3516
+ var color = colorFor(value, modifier, theme);
3517
+ return color ? [rule(BETWEEN$1, [decl('border-color', color)])] : null;
3518
+ });
3519
+ }
3520
+ var DIVIDE_STYLES = {
3521
+ solid: 'solid',
3522
+ dashed: 'dashed',
3523
+ dotted: 'dotted',
3524
+ "double": 'double',
3525
+ none: 'none'
3526
+ };
3527
+ function divideWidth(reg, axis, reverseProp, mainProp) {
3528
+ var flag = "--flx-divide-".concat(axis, "-reverse");
3529
+ reg.dynamicRule("divide-".concat(axis), function (_ref5) {
3530
+ var value = _ref5.value;
3531
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') return [rule(BETWEEN$1, [decl(flag, '1')])];
3532
+ var w = widthValue(value, '1px');
3533
+ if (w === null) return null;
3534
+ return [rule(BETWEEN$1, [decl(flag, '0'), decl(reverseProp, "calc(".concat(w, " * var(").concat(flag, "))")), decl(mainProp, "calc(".concat(w, " * calc(1 - var(").concat(flag, ")))"))])];
3535
+ });
3536
+ }
3537
+
3538
+ // A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
3539
+ // (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
3540
+ function ring(reg) {
3541
+ reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
3542
+ reg.dynamicRule('ring', function (_ref6) {
3543
+ var value = _ref6.value,
3544
+ modifier = _ref6.modifier,
3545
+ theme = _ref6.theme;
3546
+ var w = value === null ? '3px' : widthValue(value, null);
3547
+ if (w !== null) {
3548
+ return [decl('--flx-ring-shadow', "var(--flx-ring-inset) 0 0 0 calc(".concat(w, " + var(--flx-ring-offset-width)) var(--flx-ring-color)")), decl('box-shadow', 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)')];
3549
+ }
3550
+ var color = colorFor(value, modifier, theme);
3551
+ return color ? [decl('--flx-ring-color', color)] : null;
3552
+ });
3553
+ }
3554
+
3228
3555
  function registerEffects(reg) {
3229
3556
  reg.dynamicRule('shadow', function (_ref) {
3230
3557
  var value = _ref.value,
@@ -3709,6 +4036,36 @@ function registerLayout(reg) {
3709
4036
  if (value.value === 'auto') return [decl('z-index', 'auto')];
3710
4037
  return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
3711
4038
  });
4039
+ reg.dynamicRule('columns', function (_ref2) {
4040
+ var value = _ref2.value;
4041
+ if (!value) return null;
4042
+ if (value.kind === 'arbitrary') return [decl('columns', value.value)];
4043
+ if (value.value === 'auto' || /^\d+$/.test(value.value)) return [decl('columns', value.value)];
4044
+ return null;
4045
+ });
4046
+
4047
+ // Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
4048
+ // (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
4049
+ props(reg, 'scroll-snap-type', {
4050
+ 'snap-none': 'none',
4051
+ 'snap-x': 'x var(--flx-scroll-snap-strictness)',
4052
+ 'snap-y': 'y var(--flx-scroll-snap-strictness)',
4053
+ 'snap-both': 'both var(--flx-scroll-snap-strictness)'
4054
+ });
4055
+ props(reg, '--flx-scroll-snap-strictness', {
4056
+ 'snap-mandatory': 'mandatory',
4057
+ 'snap-proximity': 'proximity'
4058
+ });
4059
+ props(reg, 'scroll-snap-align', {
4060
+ 'snap-start': 'start',
4061
+ 'snap-end': 'end',
4062
+ 'snap-center': 'center',
4063
+ 'snap-align-none': 'none'
4064
+ });
4065
+ props(reg, 'scroll-snap-stop', {
4066
+ 'snap-normal': 'normal',
4067
+ 'snap-always': 'always'
4068
+ });
3712
4069
  }
3713
4070
  var OVERFLOW = {
3714
4071
  auto: 'auto',
@@ -3718,11 +4075,11 @@ var OVERFLOW = {
3718
4075
  scroll: 'scroll'
3719
4076
  };
3720
4077
  function inset(reg, root, props) {
3721
- reg.dynamicRule(root, function (_ref2) {
3722
- var value = _ref2.value,
3723
- negative = _ref2.negative,
3724
- modifier = _ref2.modifier,
3725
- theme = _ref2.theme;
4078
+ reg.dynamicRule(root, function (_ref3) {
4079
+ var value = _ref3.value,
4080
+ negative = _ref3.negative,
4081
+ modifier = _ref3.modifier,
4082
+ theme = _ref3.theme;
3726
4083
  if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3727
4084
  return decl(p, 'auto');
3728
4085
  });
@@ -3772,6 +4129,29 @@ function registerSpacing(reg) {
3772
4129
  props = _Object$entries$_i[1];
3773
4130
  spacing(reg, root, props, root[0] === 'm');
3774
4131
  }
4132
+ spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
4133
+ spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
4134
+ }
4135
+
4136
+ // Only the space *between* siblings, applied to every child after the first via
4137
+ // the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
4138
+ // margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
4139
+ var BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
4140
+ function spaceBetween(reg, axis, startProp, endProp) {
4141
+ var flag = "--flx-space-".concat(axis, "-reverse");
4142
+ reg.dynamicRule("space-".concat(axis), function (_ref) {
4143
+ var value = _ref.value,
4144
+ negative = _ref.negative,
4145
+ theme = _ref.theme;
4146
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
4147
+ return [rule(BETWEEN, [decl(flag, '1')])];
4148
+ }
4149
+ var v = sizeValue(value, theme, {
4150
+ negative: negative
4151
+ });
4152
+ if (!v) return null;
4153
+ return [rule(BETWEEN, [decl(flag, '0'), decl(startProp, "calc(".concat(v, " * calc(1 - var(").concat(flag, ")))")), decl(endProp, "calc(".concat(v, " * var(").concat(flag, "))"))])];
4154
+ });
3775
4155
  }
3776
4156
 
3777
4157
  // `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
@@ -3799,10 +4179,10 @@ var SPACING = {
3799
4179
  'scroll-p': ['scroll-padding']
3800
4180
  };
3801
4181
  function spacing(reg, root, props, allowAuto) {
3802
- reg.dynamicRule(root, function (_ref) {
3803
- var value = _ref.value,
3804
- negative = _ref.negative,
3805
- theme = _ref.theme;
4182
+ reg.dynamicRule(root, function (_ref2) {
4183
+ var value = _ref2.value,
4184
+ negative = _ref2.negative,
4185
+ theme = _ref2.theme;
3806
4186
  if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3807
4187
  return decl(p, 'auto');
3808
4188
  });
@@ -4056,6 +4436,12 @@ function registerTypography(reg) {
4056
4436
  var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
4057
4437
  return t ? [decl('letter-spacing', t)] : null;
4058
4438
  });
4439
+ reg.dynamicRule('content', function (_ref4) {
4440
+ var value = _ref4.value;
4441
+ if (!value) return null;
4442
+ if (value.kind === 'arbitrary') return [decl('content', value.value)];
4443
+ return value.value === 'none' ? [decl('content', 'none')] : null;
4444
+ });
4059
4445
  }
4060
4446
  var WEIGHTS = {
4061
4447
  thin: '100',
@@ -4144,6 +4530,18 @@ function registerVariants(reg) {
4144
4530
  reg.variant('ltr', {
4145
4531
  selector: '&:where([dir="ltr"], [dir="ltr"] *)'
4146
4532
  });
4533
+ reg.variant('*', {
4534
+ selector: '& > *'
4535
+ }); // direct children
4536
+ reg.variant('**', {
4537
+ selector: '& *'
4538
+ }); // all descendants
4539
+ reg.variant('open', {
4540
+ selector: '&:is([open], :open)'
4541
+ });
4542
+ reg.variant('inert', {
4543
+ selector: '&:is([inert], [inert] *)'
4544
+ });
4147
4545
  registerBreakpointVariants(reg);
4148
4546
 
4149
4547
  // `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
@@ -4161,11 +4559,11 @@ function registerVariants(reg) {
4161
4559
  reg.dynamicVariant('max', function (v) {
4162
4560
  return mediaWidth('max-width', width(v));
4163
4561
  });
4164
- reg.dynamicVariant('group', function (v) {
4165
- return relational(v, '.group', ' &');
4562
+ reg.dynamicVariant('group', function (v, m) {
4563
+ return relational(v, m, '.group', ' &');
4166
4564
  });
4167
- reg.dynamicVariant('peer', function (v) {
4168
- return relational(v, '.peer', ' ~ &');
4565
+ reg.dynamicVariant('peer', function (v, m) {
4566
+ return relational(v, m, '.peer', ' ~ &');
4169
4567
  });
4170
4568
  reg.dynamicVariant('data', function (v) {
4171
4569
  return named(v) ? {
@@ -4183,9 +4581,7 @@ function registerVariants(reg) {
4183
4581
  } : null;
4184
4582
  });
4185
4583
  reg.dynamicVariant('not', function (v) {
4186
- return named(v) ? {
4187
- selector: "&:not(".concat(named(v), ")")
4188
- } : null;
4584
+ return notVariant(reg, v);
4189
4585
  });
4190
4586
  reg.dynamicVariant('supports', function (v) {
4191
4587
  return named(v) ? {
@@ -4275,16 +4671,34 @@ function named(v) {
4275
4671
  }
4276
4672
 
4277
4673
  // `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
4278
- // is a pseudo-class, an arbitrary one is a raw selector fragment.
4279
- function relational(v, base, tail) {
4674
+ // is a pseudo-class, an arbitrary one is a raw selector fragment. A `/name`
4675
+ // modifier scopes to a named group/peer (`group-hover/item` → `.group\/item:hover`).
4676
+ function relational(v, m, base, tail) {
4280
4677
  var value = named(v);
4281
4678
  if (!value) return null;
4282
4679
  var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
4680
+ var scope = m ? "".concat(base, "\\/").concat(m.value) : base;
4283
4681
  return {
4284
- selector: "".concat(base).concat(cond).concat(tail)
4682
+ selector: "".concat(scope).concat(cond).concat(tail)
4285
4683
  };
4286
4684
  }
4287
4685
 
4686
+ // `not-hover` → `&:not(:hover)`, `not-first` → `&:not(:first-child)`: resolve the
4687
+ // inner variant's pseudo, so the selector is valid (not the literal name). Only
4688
+ // simple pseudo variants compose; `not-[…]` takes an arbitrary selector.
4689
+ function notVariant(reg, v) {
4690
+ var _reg$getVariant;
4691
+ var value = named(v);
4692
+ if (!value) return null;
4693
+ if (v.kind === 'arbitrary') return {
4694
+ selector: "&:not(".concat(value, ")")
4695
+ };
4696
+ var frag = (_reg$getVariant = reg.getVariant(value)) === null || _reg$getVariant === void 0 || (_reg$getVariant = _reg$getVariant.selector) === null || _reg$getVariant === void 0 ? void 0 : _reg$getVariant.replace(/^&/, '').trim();
4697
+ return frag && frag.startsWith(':') ? {
4698
+ selector: "&:not(".concat(frag, ")")
4699
+ } : null;
4700
+ }
4701
+
4288
4702
  // The batteries-included registry: the default token theme plus the utility
4289
4703
  // families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
4290
4704
  // build a bare `new Registry(theme)` and register their own.
@@ -4600,11 +5014,14 @@ var MARKER = 'fluixi';
4600
5014
  // directives are consumed, and an `@fluixi;` marker is replaced by the generated
4601
5015
  // token `:root` + utilities. With no marker the generated block is appended.
4602
5016
  function transform(input) {
4603
- var _options$registry, _options$classes, _options$from, _options$sources;
5017
+ var _options$registry, _options$classes, _options$from, _options$resetFrom, _options$sources;
4604
5018
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5019
+ var started = performance.now();
4605
5020
  var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
4606
- loadTheme(input, reg.theme);
5021
+ if (options.theme) loadTheme(options.theme, reg.theme);
5022
+ loadTheme(input, reg.theme); // the input's own @theme overrides the base
4607
5023
  registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides
5024
+ if (options.theme) loadDirectives(options.theme, reg);
4608
5025
  loadDirectives(input, reg);
4609
5026
  var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4610
5027
  var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
@@ -4706,7 +5123,8 @@ function transform(input) {
4706
5123
  var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
4707
5124
  var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
4708
5125
  if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
4709
- nodes.push(raw(input.slice(start.offset, end.offset), {
5126
+ var text = expandApply(input.slice(start.offset, end.offset), reg);
5127
+ nodes.push(raw(text, {
4710
5128
  source: from,
4711
5129
  line: start.line,
4712
5130
  column: Math.max(0, start.column - 1)
@@ -4719,30 +5137,48 @@ function transform(input) {
4719
5137
  _iterator5.f();
4720
5138
  }
4721
5139
  if (!injected) nodes.push.apply(nodes, generated);
4722
- if (options.reset) nodes.unshift(raw(options.reset));
5140
+ var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
5141
+ if (options.reset) nodes.unshift(raw(options.reset, {
5142
+ source: resetFrom,
5143
+ line: 1,
5144
+ column: 0
5145
+ }));
5146
+ var css;
5147
+ var map;
4723
5148
  if (options.sourceMap) {
4724
- var _stringifyWithMap = stringifyWithMap(nodes, {
4725
- minify: options.minify
4726
- }),
4727
- css = _stringifyWithMap.css,
4728
- map = _stringifyWithMap.map;
4729
- map.setSourceContent(from, input);
4730
- var json = map.toJSON();
5149
+ var out = stringifyWithMap(nodes, {
5150
+ minify: options.minify
5151
+ });
5152
+ css = out.css;
5153
+ out.map.setSourceContent(from, input);
5154
+ if (options.reset) out.map.setSourceContent(resetFrom, options.reset);
5155
+ var json = out.map.toJSON();
4731
5156
  json.file = from;
4732
- return {
4733
- css: css,
4734
- map: json,
4735
- classes: _toConsumableArray(classes),
4736
- sources: sources,
4737
- registry: reg
4738
- };
4739
- }
4740
- return {
4741
- css: stringify(nodes, {
5157
+ map = json;
5158
+ } else {
5159
+ css = stringify(nodes, {
4742
5160
  minify: options.minify
4743
- }),
5161
+ });
5162
+ }
5163
+ var stats = {
5164
+ ms: performance.now() - started,
5165
+ scanned: classes.size,
5166
+ utilities: rules.length,
5167
+ bytes: css.length,
5168
+ sources: sources.length
5169
+ };
5170
+ return map ? {
5171
+ css: css,
5172
+ map: map,
5173
+ classes: _toConsumableArray(classes),
5174
+ sources: sources,
5175
+ stats: stats,
5176
+ registry: reg
5177
+ } : {
5178
+ css: css,
4744
5179
  classes: _toConsumableArray(classes),
4745
5180
  sources: sources,
5181
+ stats: stats,
4746
5182
  registry: reg
4747
5183
  };
4748
5184
  }
@@ -4774,10 +5210,12 @@ function compile(input) {
4774
5210
  var _options$registry, _options$classes, _options$sources;
4775
5211
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4776
5212
  var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
5213
+ if (options.theme) loadTheme(options.theme, reg.theme);
4777
5214
  loadTheme(input, reg.theme);
4778
5215
  // Re-seed the named breakpoint variants so a `@theme` breakpoint override reaches
4779
5216
  // `sm:`/`md:`/… (they baked the default value at registry-creation time).
4780
5217
  registerBreakpointVariants(reg);
5218
+ if (options.theme) loadDirectives(options.theme, reg);
4781
5219
  loadDirectives(input, reg);
4782
5220
  var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4783
5221
  var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
@@ -4892,6 +5330,8 @@ exports.defaultTheme = defaultTheme;
4892
5330
  exports.emitTheme = emitTheme;
4893
5331
  exports.emitUiTheme = emitUiTheme;
4894
5332
  exports.escapeClass = escapeClass;
5333
+ exports.expandApply = expandApply;
5334
+ exports.formatBuildLog = formatBuildLog;
4895
5335
  exports.keywords = keywords;
4896
5336
  exports.loadDirectives = loadDirectives;
4897
5337
  exports.loadTheme = loadTheme;