windrunner 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,71 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var index_exports = {};
21
21
  __export(index_exports, {
22
22
  compileClass: () => compileClass,
23
+ compileCriticalCss: () => compileCriticalCss,
23
24
  createWindrunner: () => createWindrunner,
24
25
  defineResponsiveUtilities: () => defineResponsiveUtilities,
25
26
  defineUtilities: () => defineUtilities,
27
+ extractClassNames: () => extractClassNames,
26
28
  parseClass: () => parseClass,
27
29
  plugin: () => plugin,
28
30
  windrunner: () => windrunner
29
31
  });
30
32
  module.exports = __toCommonJS(index_exports);
31
33
 
32
- // src/variants.js
33
- var variants = {
34
- accentColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
35
- accessibility: ["hover", "focus"],
36
- aspect: ["hover", "focus"],
37
- backgroundColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
38
- blur: ["hover", "focus"],
39
- borderColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
40
- boxShadow: ["hover", "focus"],
41
- brightness: ["hover", "focus"],
42
- caretColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
43
- contrast: ["hover", "focus"],
44
- dropShadow: ["hover", "focus"],
45
- fill: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
46
- flexBasis: ["hover", "focus"],
47
- gradientColorStops: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
48
- grayscale: ["hover", "focus"],
49
- hueRotate: ["hover", "focus"],
50
- insetRing: ["hover", "focus"],
51
- insetShadow: ["hover", "focus"],
52
- invert: ["hover", "focus"],
53
- opacity: ["hover", "focus"],
54
- outlineColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
55
- outlineOffset: ["hover", "focus"],
56
- outlineStyle: ["hover", "focus"],
57
- outlineWidth: ["hover", "focus"],
58
- placeholderColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
59
- ringColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
60
- ringOffsetColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
61
- ringOffsetWidth: ["hover", "focus"],
62
- ringWidth: ["hover", "focus"],
63
- rotate: ["hover", "focus"],
64
- saturate: ["hover", "focus"],
65
- scale: ["hover", "focus"],
66
- sepia: ["hover", "focus"],
67
- skew: ["hover", "focus"],
68
- stroke: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
69
- strokeWidth: ["hover", "focus"],
70
- textColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
71
- textDecoration: ["focus", "hover"],
72
- textDecorationColor: ["focus", "hover", "not-hover", "not-focus", "not-disabled"],
73
- textDecorationStyle: ["focus", "hover"],
74
- textDecorationThickness: ["focus", "hover"],
75
- textShadowBlur: ["hover", "focus"],
76
- textShadowColor: ["hover", "focus", "not-hover", "not-focus", "not-disabled"],
77
- textShadowOpacity: ["hover", "focus"],
78
- textShadowX: ["hover", "focus"],
79
- textShadowY: ["hover", "focus"],
80
- touchAction: ["hover", "focus"],
81
- mask: ["hover", "focus"],
82
- transform3d: ["hover", "focus"],
83
- translate: ["hover", "focus"],
84
- zIndex: ["hover", "focus"]
85
- };
86
- var variants_default = variants;
87
-
88
34
  // src/theme.js
89
35
  var theme = {
90
36
  accentColor: ({ theme: theme2 }) => ({
@@ -1432,7 +1378,6 @@ var vars_default = vars;
1432
1378
 
1433
1379
  // src/config.js
1434
1380
  var configOptions = {
1435
- variants: variants_default,
1436
1381
  theme: theme_default,
1437
1382
  vars: vars_default
1438
1383
  };
@@ -1442,29 +1387,70 @@ var config_default = configOptions;
1442
1387
  function isFunction(fn) {
1443
1388
  return fn && {}.toString.call(fn) === "[object Function]";
1444
1389
  }
1390
+ var configCache = /* @__PURE__ */ new WeakMap();
1391
+ var defaultContextCache = null;
1392
+ function createLazyTheme(userTheme = {}, userThemeExtend = {}) {
1393
+ const resolved = /* @__PURE__ */ new Map();
1394
+ const defaultTheme = config_default.theme;
1395
+ return new Proxy({}, {
1396
+ get(_, key) {
1397
+ if (resolved.has(key)) {
1398
+ return resolved.get(key);
1399
+ }
1400
+ let value = Object.prototype.hasOwnProperty.call(userTheme, key) ? userTheme[key] : defaultTheme[key];
1401
+ if (isFunction(value)) {
1402
+ value = value({
1403
+ theme: (keyRef) => {
1404
+ if (resolved.has(keyRef)) return resolved.get(keyRef);
1405
+ return createLazyTheme(userTheme, userThemeExtend)[keyRef];
1406
+ }
1407
+ });
1408
+ }
1409
+ if (userThemeExtend[key]) {
1410
+ value = Object.assign({}, value, userThemeExtend[key]);
1411
+ }
1412
+ resolved.set(key, value);
1413
+ return value;
1414
+ },
1415
+ has(_, key) {
1416
+ return key in defaultTheme || key in userTheme;
1417
+ },
1418
+ ownKeys(_) {
1419
+ return [.../* @__PURE__ */ new Set([...Object.keys(defaultTheme), ...Object.keys(userTheme)])];
1420
+ },
1421
+ getOwnPropertyDescriptor(_, key) {
1422
+ if (key in defaultTheme || key in userTheme) {
1423
+ return {
1424
+ enumerable: true,
1425
+ configurable: true
1426
+ };
1427
+ }
1428
+ }
1429
+ });
1430
+ }
1445
1431
  function getConfigOptions(options = {}, pluginKeys = []) {
1432
+ if (!options || typeof options === "object" && Object.keys(options).length === 0) {
1433
+ if (!defaultContextCache) {
1434
+ defaultContextCache = {
1435
+ ...config_default,
1436
+ theme: createLazyTheme({}, {})
1437
+ };
1438
+ }
1439
+ return defaultContextCache;
1440
+ }
1441
+ if (configCache.has(options)) {
1442
+ return configCache.get(options);
1443
+ }
1446
1444
  const { theme: theme2 = {} } = options;
1447
1445
  const { extend: themeExtend = {} } = theme2;
1448
- const newTheme = {};
1449
- const themeKeys = Object.keys(config_default.theme);
1450
- themeKeys.forEach((key) => {
1451
- newTheme[key] = Object.prototype.hasOwnProperty.call(theme2, key) ? theme2[key] : config_default.theme[key];
1452
- });
1453
- themeKeys.forEach((key) => {
1454
- if (isFunction(newTheme[key])) {
1455
- newTheme[key] = newTheme[key]({
1456
- theme: (keyRef) => newTheme[keyRef]
1457
- });
1458
- }
1459
- if (themeExtend[key]) {
1460
- newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
1461
- }
1462
- });
1463
- return {
1446
+ const lazyTheme = createLazyTheme(theme2, themeExtend);
1447
+ const config = {
1464
1448
  ...config_default,
1465
1449
  ...options,
1466
- theme: newTheme
1450
+ theme: lazyTheme
1467
1451
  };
1452
+ configCache.set(options, config);
1453
+ return config;
1468
1454
  }
1469
1455
 
1470
1456
  // src/constants.js
@@ -1548,112 +1534,93 @@ function escapeCssIdentifier(value) {
1548
1534
  }
1549
1535
  function appendImportant(declaration, isImportant) {
1550
1536
  if (!isImportant) return declaration;
1551
- const entries = declaration.split(";").map((item) => item.trim()).filter(Boolean).map((item) => item.includes("!important") ? item : `${item} !important`);
1552
- return `${entries.join("; ")};`;
1537
+ return declaration.replace(/([^;{}]+);/g, (match, decl) => {
1538
+ const trimmed = decl.trim();
1539
+ if (!trimmed || trimmed.includes("!important")) return match;
1540
+ return `${trimmed} !important;`;
1541
+ });
1553
1542
  }
1554
1543
  function splitByVariantDelimiter(token) {
1555
1544
  const parts = [];
1556
- let current = "";
1545
+ let start = 0;
1557
1546
  let bracketDepth = 0;
1558
1547
  for (let i = 0; i < token.length; i += 1) {
1559
1548
  const char = token[i];
1560
- if (char === "[") bracketDepth += 1;
1561
- if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
1562
- if (char === ":" && bracketDepth === 0) {
1563
- parts.push(current);
1564
- current = "";
1565
- } else {
1566
- current += char;
1549
+ if (char === "[") {
1550
+ bracketDepth += 1;
1551
+ } else if (char === "]") {
1552
+ bracketDepth = Math.max(0, bracketDepth - 1);
1553
+ } else if (char === ":" && bracketDepth === 0) {
1554
+ parts.push(token.slice(start, i));
1555
+ start = i + 1;
1567
1556
  }
1568
1557
  }
1569
- if (current) parts.push(current);
1558
+ parts.push(token.slice(start));
1570
1559
  return parts;
1571
1560
  }
1572
1561
 
1573
1562
  // src/maps/layout.maps.js
1563
+ function createSimpleMap(prop, values, keyMap = {}) {
1564
+ const map = {};
1565
+ values.forEach((value) => {
1566
+ const key = keyMap[value] || value;
1567
+ map[key] = `${prop}: ${value};`;
1568
+ });
1569
+ return map;
1570
+ }
1574
1571
  var DISPLAY_MAP = {
1575
- block: "display: block;",
1576
- inline: "display: inline;",
1577
- "inline-block": "display: inline-block;",
1578
- flex: "display: flex;",
1579
- "inline-flex": "display: inline-flex;",
1580
- grid: "display: grid;",
1581
- "inline-grid": "display: inline-grid;",
1582
- hidden: "display: none;",
1583
- contents: "display: contents;",
1584
- "flow-root": "display: flow-root;",
1585
- "list-item": "display: list-item;",
1586
- table: "display: table;",
1587
- "inline-table": "display: inline-table;",
1588
- "table-caption": "display: table-caption;",
1589
- "table-cell": "display: table-cell;",
1590
- "table-column": "display: table-column;",
1591
- "table-column-group": "display: table-column-group;",
1592
- "table-footer-group": "display: table-footer-group;",
1593
- "table-header-group": "display: table-header-group;",
1594
- "table-row-group": "display: table-row-group;",
1595
- "table-row": "display: table-row;"
1596
- };
1597
- var POSITION_MAP = {
1598
- static: "position: static;",
1599
- fixed: "position: fixed;",
1600
- absolute: "position: absolute;",
1601
- relative: "position: relative;",
1602
- sticky: "position: sticky;"
1572
+ ...createSimpleMap("display", [
1573
+ "block",
1574
+ "inline",
1575
+ "inline-block",
1576
+ "flex",
1577
+ "inline-flex",
1578
+ "grid",
1579
+ "inline-grid",
1580
+ "contents",
1581
+ "flow-root",
1582
+ "list-item",
1583
+ "table",
1584
+ "inline-table",
1585
+ "table-caption",
1586
+ "table-cell",
1587
+ "table-column",
1588
+ "table-column-group",
1589
+ "table-footer-group",
1590
+ "table-header-group",
1591
+ "table-row-group",
1592
+ "table-row"
1593
+ ]),
1594
+ hidden: "display: none;"
1595
+ // Special case
1603
1596
  };
1597
+ var POSITION_MAP = createSimpleMap("position", [
1598
+ "static",
1599
+ "fixed",
1600
+ "absolute",
1601
+ "relative",
1602
+ "sticky"
1603
+ ]);
1604
1604
  var VISIBILITY_MAP = {
1605
- visible: "visibility: visible;",
1606
- invisible: "visibility: hidden;",
1607
- collapse: "visibility: collapse;"
1608
- };
1609
- var OVERFLOW_MAP = {
1610
- auto: "overflow: auto;",
1611
- hidden: "overflow: hidden;",
1612
- clip: "overflow: clip;",
1613
- visible: "overflow: visible;",
1614
- scroll: "overflow: scroll;"
1615
- };
1616
- var OVERFLOW_X_MAP = {
1617
- auto: "overflow-x: auto;",
1618
- hidden: "overflow-x: hidden;",
1619
- clip: "overflow-x: clip;",
1620
- visible: "overflow-x: visible;",
1621
- scroll: "overflow-x: scroll;"
1622
- };
1623
- var OVERFLOW_Y_MAP = {
1624
- auto: "overflow-y: auto;",
1625
- hidden: "overflow-y: hidden;",
1626
- clip: "overflow-y: clip;",
1627
- visible: "overflow-y: visible;",
1628
- scroll: "overflow-y: scroll;"
1629
- };
1630
- var OVERSCROLL_MAP = {
1631
- auto: "overscroll-behavior: auto;",
1632
- contain: "overscroll-behavior: contain;",
1633
- none: "overscroll-behavior: none;"
1634
- };
1635
- var OVERSCROLL_X_MAP = {
1636
- auto: "overscroll-behavior-x: auto;",
1637
- contain: "overscroll-behavior-x: contain;",
1638
- none: "overscroll-behavior-x: none;"
1639
- };
1640
- var OVERSCROLL_Y_MAP = {
1641
- auto: "overscroll-behavior-y: auto;",
1642
- contain: "overscroll-behavior-y: contain;",
1643
- none: "overscroll-behavior-y: none;"
1605
+ ...createSimpleMap("visibility", ["visible", "collapse"]),
1606
+ invisible: "visibility: hidden;"
1607
+ // Key differs from value
1644
1608
  };
1609
+ var OVERFLOW_VALUES = ["auto", "hidden", "clip", "visible", "scroll"];
1610
+ var OVERFLOW_MAP = createSimpleMap("overflow", OVERFLOW_VALUES);
1611
+ var OVERFLOW_X_MAP = createSimpleMap("overflow-x", OVERFLOW_VALUES);
1612
+ var OVERFLOW_Y_MAP = createSimpleMap("overflow-y", OVERFLOW_VALUES);
1613
+ var OVERSCROLL_VALUES = ["auto", "contain", "none"];
1614
+ var OVERSCROLL_MAP = createSimpleMap("overscroll-behavior", OVERSCROLL_VALUES);
1615
+ var OVERSCROLL_X_MAP = createSimpleMap("overscroll-behavior-x", OVERSCROLL_VALUES);
1616
+ var OVERSCROLL_Y_MAP = createSimpleMap("overscroll-behavior-y", OVERSCROLL_VALUES);
1645
1617
  var FLOAT_MAP = {
1646
- left: "float: left;",
1647
- right: "float: right;",
1648
- none: "float: none;",
1618
+ ...createSimpleMap("float", ["left", "right", "none"]),
1649
1619
  start: "float: inline-start;",
1650
1620
  end: "float: inline-end;"
1651
1621
  };
1652
1622
  var CLEAR_MAP = {
1653
- left: "clear: left;",
1654
- right: "clear: right;",
1655
- both: "clear: both;",
1656
- none: "clear: none;",
1623
+ ...createSimpleMap("clear", ["left", "right", "both", "none"]),
1657
1624
  start: "clear: inline-start;",
1658
1625
  end: "clear: inline-end;"
1659
1626
  };
@@ -1661,13 +1628,13 @@ var ISOLATION_MAP = {
1661
1628
  isolate: "isolation: isolate;",
1662
1629
  "isolation-auto": "isolation: auto;"
1663
1630
  };
1664
- var OBJECT_FIT_MAP = {
1665
- contain: "object-fit: contain;",
1666
- cover: "object-fit: cover;",
1667
- fill: "object-fit: fill;",
1668
- none: "object-fit: none;",
1669
- "scale-down": "object-fit: scale-down;"
1670
- };
1631
+ var OBJECT_FIT_MAP = createSimpleMap("object-fit", [
1632
+ "contain",
1633
+ "cover",
1634
+ "fill",
1635
+ "none",
1636
+ "scale-down"
1637
+ ]);
1671
1638
  var TRANSFORM_STYLE_MAP = {
1672
1639
  "transform-style-flat": "transform-style: flat;",
1673
1640
  "transform-style-3d": "transform-style: preserve-3d;",
@@ -1685,81 +1652,64 @@ var BOX_SIZING_MAP = {
1685
1652
  border: "box-sizing: border-box;",
1686
1653
  content: "box-sizing: content-box;"
1687
1654
  };
1655
+ var BREAK_AFTER_BEFORE_VALUES = [
1656
+ "auto",
1657
+ "avoid",
1658
+ "avoid-page",
1659
+ "avoid-column",
1660
+ "page",
1661
+ "left",
1662
+ "right",
1663
+ "recto",
1664
+ "verso"
1665
+ ];
1688
1666
  var BREAK_AFTER_MAP = {
1689
- auto: "break-after: auto;",
1690
- avoid: "break-after: avoid;",
1691
- "avoid-page": "break-after: avoid-page;",
1692
- "avoid-column": "break-after: avoid-column;",
1693
- page: "break-after: page;",
1694
- all: "break-after: all;",
1695
- left: "break-after: left;",
1696
- right: "break-after: right;",
1697
- recto: "break-after: recto;",
1698
- verso: "break-after: verso;"
1699
- };
1700
- var BREAK_BEFORE_MAP = {
1701
- auto: "break-before: auto;",
1702
- avoid: "break-before: avoid;",
1703
- "avoid-page": "break-before: avoid-page;",
1704
- "avoid-column": "break-before: avoid-column;",
1705
- page: "break-before: page;",
1706
- left: "break-before: left;",
1707
- right: "break-before: right;",
1708
- recto: "break-before: recto;",
1709
- verso: "break-before: verso;"
1710
- };
1711
- var BREAK_INSIDE_MAP = {
1712
- auto: "break-inside: auto;",
1713
- avoid: "break-inside: avoid;",
1714
- "avoid-page": "break-inside: avoid-page;",
1715
- "avoid-column": "break-inside: avoid-column;"
1716
- };
1717
- var BOX_DECORATION_BREAK_MAP = {
1718
- slice: "box-decoration-break: slice;",
1719
- clone: "box-decoration-break: clone;"
1720
- };
1721
- var HYPHENS_MAP = {
1722
- none: "hyphens: none;",
1723
- manual: "hyphens: manual;",
1724
- auto: "hyphens: auto;"
1725
- };
1726
- var COLOR_SCHEME_MAP = {
1727
- light: "color-scheme: light;",
1728
- dark: "color-scheme: dark;",
1729
- normal: "color-scheme: normal;"
1730
- };
1731
- var SCROLLBAR_COLOR_MAP = {
1732
- auto: "scrollbar-color: auto;",
1733
- transparent: "scrollbar-color: transparent;",
1734
- current: "scrollbar-color: currentColor;"
1735
- };
1736
- var SCROLLBAR_WIDTH_MAP = {
1737
- auto: "scrollbar-width: auto;",
1738
- thin: "scrollbar-width: thin;",
1739
- none: "scrollbar-width: none;"
1667
+ ...createSimpleMap("break-after", BREAK_AFTER_BEFORE_VALUES),
1668
+ all: "break-after: all;"
1740
1669
  };
1670
+ var BREAK_BEFORE_MAP = createSimpleMap("break-before", BREAK_AFTER_BEFORE_VALUES);
1671
+ var BREAK_INSIDE_MAP = createSimpleMap("break-inside", [
1672
+ "auto",
1673
+ "avoid",
1674
+ "avoid-page",
1675
+ "avoid-column"
1676
+ ]);
1677
+ var BOX_DECORATION_BREAK_MAP = createSimpleMap("box-decoration-break", [
1678
+ "slice",
1679
+ "clone"
1680
+ ]);
1681
+ var HYPHENS_MAP = createSimpleMap("hyphens", ["none", "manual", "auto"]);
1682
+ var COLOR_SCHEME_MAP = createSimpleMap("color-scheme", [
1683
+ "light",
1684
+ "dark",
1685
+ "normal"
1686
+ ]);
1687
+ var SCROLLBAR_COLOR_MAP = createSimpleMap("scrollbar-color", [
1688
+ "auto",
1689
+ "transparent",
1690
+ "current"
1691
+ ]);
1692
+ var SCROLLBAR_WIDTH_MAP = createSimpleMap("scrollbar-width", [
1693
+ "auto",
1694
+ "thin",
1695
+ "none"
1696
+ ]);
1741
1697
  var SCROLLBAR_GUTTER_MAP = {
1742
1698
  auto: "scrollbar-gutter: auto;",
1743
1699
  stable: "scrollbar-gutter: stable;",
1744
1700
  "stable-both-edges": "scrollbar-gutter: stable both-edges;",
1745
1701
  "both-edges": "scrollbar-gutter: both-edges;"
1746
1702
  };
1747
- var TABLE_LAYOUT_MAP = {
1748
- auto: "table-layout: auto;",
1749
- fixed: "table-layout: fixed;"
1750
- };
1751
- var CAPTION_SIDE_MAP = {
1752
- top: "caption-side: top;",
1753
- bottom: "caption-side: bottom;"
1754
- };
1755
- var BORDER_COLLAPSE_MAP = {
1756
- collapse: "border-collapse: collapse;",
1757
- separate: "border-collapse: separate;"
1758
- };
1759
- var SCROLL_BEHAVIOR_MAP = {
1760
- auto: "scroll-behavior: auto;",
1761
- smooth: "scroll-behavior: smooth;"
1762
- };
1703
+ var TABLE_LAYOUT_MAP = createSimpleMap("table-layout", ["auto", "fixed"]);
1704
+ var CAPTION_SIDE_MAP = createSimpleMap("caption-side", ["top", "bottom"]);
1705
+ var BORDER_COLLAPSE_MAP = createSimpleMap("border-collapse", [
1706
+ "collapse",
1707
+ "separate"
1708
+ ]);
1709
+ var SCROLL_BEHAVIOR_MAP = createSimpleMap("scroll-behavior", [
1710
+ "auto",
1711
+ "smooth"
1712
+ ]);
1763
1713
  var SIDE_PROPS = {
1764
1714
  "": [""],
1765
1715
  t: ["-top"],
@@ -1790,71 +1740,69 @@ var ROUNDED_PROPS = {
1790
1740
  };
1791
1741
 
1792
1742
  // src/maps/interactivity.maps.js
1793
- var CURSOR_MAP = {
1794
- auto: "cursor: auto;",
1795
- default: "cursor: default;",
1796
- pointer: "cursor: pointer;",
1797
- wait: "cursor: wait;",
1798
- text: "cursor: text;",
1799
- move: "cursor: move;",
1800
- help: "cursor: help;",
1801
- "not-allowed": "cursor: not-allowed;",
1802
- none: "cursor: none;",
1803
- "context-menu": "cursor: context-menu;",
1804
- progress: "cursor: progress;",
1805
- cell: "cursor: cell;",
1806
- crosshair: "cursor: crosshair;",
1807
- "vertical-text": "cursor: vertical-text;",
1808
- alias: "cursor: alias;",
1809
- copy: "cursor: copy;",
1810
- "no-drop": "cursor: no-drop;",
1811
- grab: "cursor: grab;",
1812
- grabbing: "cursor: grabbing;",
1813
- "all-scroll": "cursor: all-scroll;",
1814
- "zoom-in": "cursor: zoom-in;",
1815
- "zoom-out": "cursor: zoom-out;"
1816
- };
1817
- var POINTER_EVENTS_MAP = {
1818
- none: "pointer-events: none;",
1819
- auto: "pointer-events: auto;"
1820
- };
1821
- var USER_SELECT_MAP = {
1822
- none: "user-select: none;",
1823
- text: "user-select: text;",
1824
- all: "user-select: all;",
1825
- auto: "user-select: auto;"
1826
- };
1827
- var APPEARANCE_MAP = {
1828
- none: "appearance: none;",
1829
- auto: "appearance: auto;"
1830
- };
1831
- var TOUCH_ACTION_MAP = {
1832
- auto: "touch-action: auto;",
1833
- none: "touch-action: none;",
1834
- "pan-x": "touch-action: pan-x;",
1835
- "pan-left": "touch-action: pan-left;",
1836
- "pan-right": "touch-action: pan-right;",
1837
- "pan-y": "touch-action: pan-y;",
1838
- "pan-up": "touch-action: pan-up;",
1839
- "pan-down": "touch-action: pan-down;",
1840
- "pinch-zoom": "touch-action: pinch-zoom;",
1841
- manipulation: "touch-action: manipulation;"
1842
- };
1743
+ function createSimpleMap2(prop, values) {
1744
+ const map = {};
1745
+ values.forEach((value) => {
1746
+ map[value] = `${prop}: ${value};`;
1747
+ });
1748
+ return map;
1749
+ }
1750
+ var CURSOR_MAP = createSimpleMap2("cursor", [
1751
+ "auto",
1752
+ "default",
1753
+ "pointer",
1754
+ "wait",
1755
+ "text",
1756
+ "move",
1757
+ "help",
1758
+ "not-allowed",
1759
+ "none",
1760
+ "context-menu",
1761
+ "progress",
1762
+ "cell",
1763
+ "crosshair",
1764
+ "vertical-text",
1765
+ "alias",
1766
+ "copy",
1767
+ "no-drop",
1768
+ "grab",
1769
+ "grabbing",
1770
+ "all-scroll",
1771
+ "zoom-in",
1772
+ "zoom-out"
1773
+ ]);
1774
+ var POINTER_EVENTS_MAP = createSimpleMap2("pointer-events", ["none", "auto"]);
1775
+ var USER_SELECT_MAP = createSimpleMap2("user-select", [
1776
+ "none",
1777
+ "text",
1778
+ "all",
1779
+ "auto"
1780
+ ]);
1781
+ var APPEARANCE_MAP = createSimpleMap2("appearance", ["none", "auto"]);
1782
+ var TOUCH_ACTION_MAP = createSimpleMap2("touch-action", [
1783
+ "auto",
1784
+ "none",
1785
+ "pan-x",
1786
+ "pan-left",
1787
+ "pan-right",
1788
+ "pan-y",
1789
+ "pan-up",
1790
+ "pan-down",
1791
+ "pinch-zoom",
1792
+ "manipulation"
1793
+ ]);
1843
1794
  var OUTLINE_STYLE_MAP = {
1844
1795
  none: "outline: 2px solid transparent; outline-offset: 2px;",
1845
- solid: "outline-style: solid;",
1846
- dashed: "outline-style: dashed;",
1847
- dotted: "outline-style: dotted;",
1848
- double: "outline-style: double;"
1849
- };
1850
- var BORDER_STYLE_MAP = {
1851
- solid: "border-style: solid;",
1852
- dashed: "border-style: dashed;",
1853
- dotted: "border-style: dotted;",
1854
- double: "border-style: double;",
1855
- hidden: "border-style: hidden;",
1856
- none: "border-style: none;"
1796
+ ...createSimpleMap2("outline-style", ["solid", "dashed", "dotted", "double"])
1857
1797
  };
1798
+ var BORDER_STYLE_MAP = createSimpleMap2("border-style", [
1799
+ "solid",
1800
+ "dashed",
1801
+ "dotted",
1802
+ "double",
1803
+ "hidden",
1804
+ "none"
1805
+ ]);
1858
1806
  var TRANSITION_PROPERTY_MAP = {
1859
1807
  none: "none",
1860
1808
  all: "all",
@@ -3307,7 +3255,8 @@ function buildDivideDeclaration(baseToken, theme2) {
3307
3255
  // src/plugins.js
3308
3256
  var PluginRegistry = class {
3309
3257
  constructor() {
3310
- this.utilities = /* @__PURE__ */ new Map();
3258
+ this.exactUtilities = /* @__PURE__ */ new Map();
3259
+ this.regexUtilities = [];
3311
3260
  this.variants = /* @__PURE__ */ new Map();
3312
3261
  }
3313
3262
  /**
@@ -3316,7 +3265,11 @@ var PluginRegistry = class {
3316
3265
  * @param {Function|string} handler - Function that returns CSS or CSS string
3317
3266
  */
3318
3267
  addUtility(pattern, handler) {
3319
- this.utilities.set(pattern, handler);
3268
+ if (pattern instanceof RegExp) {
3269
+ this.regexUtilities.push([pattern, handler]);
3270
+ } else {
3271
+ this.exactUtilities.set(pattern, handler);
3272
+ }
3320
3273
  }
3321
3274
  /**
3322
3275
  * Register multiple utilities at once
@@ -3339,25 +3292,29 @@ var PluginRegistry = class {
3339
3292
  * Register multiple variants at once
3340
3293
  * @param {Object} variants - Object mapping names to handlers
3341
3294
  */
3342
- addVariants(variants2) {
3343
- Object.entries(variants2).forEach(([name, handler]) => {
3295
+ addVariants(variants) {
3296
+ Object.entries(variants).forEach(([name, handler]) => {
3344
3297
  this.addVariant(name, handler);
3345
3298
  });
3346
3299
  }
3347
3300
  /**
3348
3301
  * Check if a token matches any custom utility pattern
3302
+ * Optimized: O(1) fast path for exact matches, O(n) only for regex patterns
3349
3303
  * @param {string} token - The base token to match
3350
3304
  * @returns {Object|null} - { handler, match } or null
3351
3305
  */
3352
3306
  matchUtility(token) {
3353
- for (const [pattern, handler] of this.utilities) {
3354
- if (pattern instanceof RegExp) {
3355
- const match = pattern.exec(token);
3356
- if (match) {
3357
- return { handler, match };
3358
- }
3359
- } else if (pattern === token) {
3360
- return { handler, match: [token] };
3307
+ if (this.exactUtilities.has(token)) {
3308
+ return {
3309
+ handler: this.exactUtilities.get(token),
3310
+ match: [token]
3311
+ };
3312
+ }
3313
+ for (let i = 0; i < this.regexUtilities.length; i += 1) {
3314
+ const [pattern, handler] = this.regexUtilities[i];
3315
+ const match = pattern.exec(token);
3316
+ if (match) {
3317
+ return { handler, match };
3361
3318
  }
3362
3319
  }
3363
3320
  return null;
@@ -3374,7 +3331,10 @@ var PluginRegistry = class {
3374
3331
  * Get all registered utility patterns (for debugging)
3375
3332
  */
3376
3333
  getUtilities() {
3377
- return Array.from(this.utilities.keys());
3334
+ return [
3335
+ ...Array.from(this.exactUtilities.keys()),
3336
+ ...this.regexUtilities.map(([pattern]) => pattern)
3337
+ ];
3378
3338
  }
3379
3339
  /**
3380
3340
  * Get all registered variant names (for debugging)
@@ -3386,7 +3346,8 @@ var PluginRegistry = class {
3386
3346
  * Clear all registered plugins
3387
3347
  */
3388
3348
  clear() {
3389
- this.utilities.clear();
3349
+ this.exactUtilities.clear();
3350
+ this.regexUtilities = [];
3390
3351
  this.variants.clear();
3391
3352
  }
3392
3353
  };
@@ -3591,8 +3552,26 @@ function extractPrefix(token) {
3591
3552
  }
3592
3553
  return prefix;
3593
3554
  }
3555
+ var UNKNOWN_PREFIX_CACHE = /* @__PURE__ */ new Set();
3556
+ var MAX_UNKNOWN_CACHE_SIZE = 500;
3594
3557
  function checkAllBuilders(baseToken, theme2) {
3595
- return buildLayoutDeclaration(baseToken, theme2) || buildPositionInsetDeclaration(baseToken, theme2) || buildSpacingDeclaration(baseToken, theme2) || buildSpaceBetweenDeclaration(baseToken, theme2) || buildGapDeclaration(baseToken, theme2) || buildDimensionDeclaration(baseToken, theme2) || buildFlexGridDeclaration(baseToken, theme2) || buildBorderDeclaration(baseToken, theme2) || buildBorderRadiusDeclaration(baseToken, theme2) || buildBorderSpacingDeclaration(baseToken, theme2) || buildDivideDeclaration(baseToken, theme2) || buildOpacityDeclaration(baseToken, theme2) || buildShadowDeclaration(baseToken, theme2) || buildInsetShadowDeclaration(baseToken, theme2) || buildInsetRingDeclaration(baseToken, theme2) || buildRingDeclaration(baseToken, theme2) || buildRingOffsetDeclaration(baseToken, theme2) || buildTextShadowDeclaration(baseToken, theme2) || buildTransitionDeclaration(baseToken) || buildTransformDeclaration(baseToken, theme2) || buildFilterDeclaration(baseToken, theme2) || buildBackgroundDeclaration(baseToken, theme2) || buildGradientDeclaration(baseToken, theme2) || buildColorDeclaration(baseToken, theme2) || buildTypographyDeclaration(baseToken, theme2) || buildBlendingDeclaration(baseToken) || buildInteractivityDeclaration(baseToken, theme2) || buildAnimationDeclaration(baseToken) || buildMaskDeclaration(baseToken) || buildContainerQueryDeclaration(baseToken) || buildScrollSnapDeclaration(baseToken) || buildAccessibilityDeclaration(baseToken) || buildZoomDeclaration(baseToken, theme2) || buildForcedColorDeclaration(baseToken);
3558
+ const prefix = extractPrefix(baseToken);
3559
+ if (UNKNOWN_PREFIX_CACHE.has(prefix)) {
3560
+ return void 0;
3561
+ }
3562
+ const result = buildLayoutDeclaration(baseToken, theme2) || buildPositionInsetDeclaration(baseToken, theme2) || buildSpacingDeclaration(baseToken, theme2) || buildSpaceBetweenDeclaration(baseToken, theme2) || buildGapDeclaration(baseToken, theme2) || buildDimensionDeclaration(baseToken, theme2) || buildFlexGridDeclaration(baseToken, theme2) || buildBorderDeclaration(baseToken, theme2) || buildBorderRadiusDeclaration(baseToken, theme2) || buildBorderSpacingDeclaration(baseToken, theme2) || buildDivideDeclaration(baseToken, theme2) || buildOpacityDeclaration(baseToken, theme2) || buildShadowDeclaration(baseToken, theme2) || buildInsetShadowDeclaration(baseToken, theme2) || buildInsetRingDeclaration(baseToken, theme2) || buildRingDeclaration(baseToken, theme2) || buildRingOffsetDeclaration(baseToken, theme2) || buildTextShadowDeclaration(baseToken, theme2) || buildTransitionDeclaration(baseToken) || buildTransformDeclaration(baseToken, theme2) || buildFilterDeclaration(baseToken, theme2) || buildBackgroundDeclaration(baseToken, theme2) || buildGradientDeclaration(baseToken, theme2) || buildColorDeclaration(baseToken, theme2) || buildTypographyDeclaration(baseToken, theme2) || buildBlendingDeclaration(baseToken) || buildInteractivityDeclaration(baseToken, theme2) || buildAnimationDeclaration(baseToken) || buildMaskDeclaration(baseToken) || buildContainerQueryDeclaration(baseToken) || buildScrollSnapDeclaration(baseToken) || buildAccessibilityDeclaration(baseToken) || buildZoomDeclaration(baseToken, theme2) || buildForcedColorDeclaration(baseToken);
3563
+ if (!result && prefix) {
3564
+ if (UNKNOWN_PREFIX_CACHE.size >= MAX_UNKNOWN_CACHE_SIZE) {
3565
+ const toRemove = Math.floor(MAX_UNKNOWN_CACHE_SIZE / 2);
3566
+ const iterator = UNKNOWN_PREFIX_CACHE.values();
3567
+ for (let i = 0; i < toRemove; i += 1) {
3568
+ const value = iterator.next().value;
3569
+ if (value) UNKNOWN_PREFIX_CACHE.delete(value);
3570
+ }
3571
+ }
3572
+ UNKNOWN_PREFIX_CACHE.add(prefix);
3573
+ }
3574
+ return result;
3596
3575
  }
3597
3576
  function compileBaseToken(baseToken, theme2, pluginRegistry) {
3598
3577
  if (pluginRegistry) {
@@ -3621,9 +3600,75 @@ function compileBaseToken(baseToken, theme2, pluginRegistry) {
3621
3600
  }
3622
3601
  return checkAllBuilders(baseToken, theme2);
3623
3602
  }
3624
- function applyVariants(selector, variants2, pluginRegistry) {
3603
+ var VARIANT_MAP = /* @__PURE__ */ new Map([
3604
+ // Dark mode
3605
+ ["dark", (s) => `.dark ${s}`],
3606
+ // Pseudo-classes – interactive
3607
+ ["hover", (s) => `${s}:hover`],
3608
+ ["focus", (s) => `${s}:focus`],
3609
+ ["focus-visible", (s) => `${s}:focus-visible`],
3610
+ ["focus-within", (s) => `${s}:focus-within`],
3611
+ ["active", (s) => `${s}:active`],
3612
+ ["visited", (s) => `${s}:visited`],
3613
+ ["disabled", (s) => `${s}:disabled`],
3614
+ ["checked", (s) => `${s}:checked`],
3615
+ ["indeterminate", (s) => `${s}:indeterminate`],
3616
+ ["required", (s) => `${s}:required`],
3617
+ ["valid", (s) => `${s}:valid`],
3618
+ ["invalid", (s) => `${s}:invalid`],
3619
+ ["target", (s) => `${s}:target`],
3620
+ ["enabled", (s) => `${s}:enabled`],
3621
+ ["default", (s) => `${s}:default`],
3622
+ ["optional", (s) => `${s}:optional`],
3623
+ ["user-valid", (s) => `${s}:user-valid`],
3624
+ ["user-invalid", (s) => `${s}:user-invalid`],
3625
+ ["in-range", (s) => `${s}:in-range`],
3626
+ ["out-of-range", (s) => `${s}:out-of-range`],
3627
+ ["placeholder-shown", (s) => `${s}:placeholder-shown`],
3628
+ ["autofill", (s) => `${s}:autofill`],
3629
+ ["details-content", (s) => `${s}:details-content`],
3630
+ ["read-only", (s) => `${s}:read-only`],
3631
+ ["open", (s) => `${s}[open]`],
3632
+ // Pseudo-elements
3633
+ ["placeholder", (s) => `${s}::placeholder`],
3634
+ ["backdrop", (s) => `${s}::backdrop`],
3635
+ ["before", (s) => `${s}::before`],
3636
+ ["after", (s) => `${s}::after`],
3637
+ ["first-letter", (s) => `${s}::first-letter`],
3638
+ ["first-line", (s) => `${s}::first-line`],
3639
+ ["marker", (s) => `${s}::marker`],
3640
+ ["selection", (s) => `${s}::selection`],
3641
+ ["file", (s) => `${s}::file-selector-button`],
3642
+ // Structural pseudo-classes
3643
+ ["first", (s) => `${s}:first-child`],
3644
+ ["last", (s) => `${s}:last-child`],
3645
+ ["odd", (s) => `${s}:nth-child(odd)`],
3646
+ ["even", (s) => `${s}:nth-child(even)`],
3647
+ ["first-of-type", (s) => `${s}:first-of-type`],
3648
+ ["last-of-type", (s) => `${s}:last-of-type`],
3649
+ ["only", (s) => `${s}:only-child`],
3650
+ ["only-of-type", (s) => `${s}:only-of-type`],
3651
+ ["empty", (s) => `${s}:empty`],
3652
+ // Group & peer variants
3653
+ ["group-hover", (s) => `.group:hover ${s}`],
3654
+ ["group-focus", (s) => `.group:focus ${s}`],
3655
+ ["group-active", (s) => `.group:active ${s}`],
3656
+ ["peer-hover", (s) => `.peer:hover ~ ${s}`],
3657
+ ["peer-focus", (s) => `.peer:focus ~ ${s}`],
3658
+ ["peer-checked", (s) => `.peer:checked ~ ${s}`],
3659
+ ["peer-disabled", (s) => `.peer:disabled ~ ${s}`],
3660
+ // Negation variants
3661
+ ["not-hover", (s) => `${s}:not(:hover)`],
3662
+ ["not-focus", (s) => `${s}:not(:focus)`],
3663
+ ["not-disabled", (s) => `${s}:not(:disabled)`],
3664
+ ["not-checked", (s) => `${s}:not(:checked)`],
3665
+ // In-* variants (group-based)
3666
+ ["in-hover", (s) => `.group:hover ${s}`],
3667
+ ["in-focus", (s) => `.group:focus ${s}`]
3668
+ ]);
3669
+ function applyVariants(selector, variants, pluginRegistry) {
3625
3670
  let currentSelector = selector;
3626
- for (const variant of variants2) {
3671
+ for (const variant of variants) {
3627
3672
  if (pluginRegistry) {
3628
3673
  const customHandler = pluginRegistry.matchVariant(variant);
3629
3674
  if (customHandler) {
@@ -3638,180 +3683,11 @@ function applyVariants(selector, variants2, pluginRegistry) {
3638
3683
  }
3639
3684
  }
3640
3685
  }
3641
- switch (variant) {
3642
- case "dark":
3643
- currentSelector = `.dark ${currentSelector}`;
3644
- break;
3645
- case "hover":
3646
- currentSelector = `${currentSelector}:hover`;
3647
- break;
3648
- case "focus":
3649
- currentSelector = `${currentSelector}:focus`;
3650
- break;
3651
- case "focus-visible":
3652
- currentSelector = `${currentSelector}:focus-visible`;
3653
- break;
3654
- case "focus-within":
3655
- currentSelector = `${currentSelector}:focus-within`;
3656
- break;
3657
- case "active":
3658
- currentSelector = `${currentSelector}:active`;
3659
- break;
3660
- case "visited":
3661
- currentSelector = `${currentSelector}:visited`;
3662
- break;
3663
- case "disabled":
3664
- currentSelector = `${currentSelector}:disabled`;
3665
- break;
3666
- case "checked":
3667
- currentSelector = `${currentSelector}:checked`;
3668
- break;
3669
- case "indeterminate":
3670
- currentSelector = `${currentSelector}:indeterminate`;
3671
- break;
3672
- case "required":
3673
- currentSelector = `${currentSelector}:required`;
3674
- break;
3675
- case "valid":
3676
- currentSelector = `${currentSelector}:valid`;
3677
- break;
3678
- case "invalid":
3679
- currentSelector = `${currentSelector}:invalid`;
3680
- break;
3681
- case "target":
3682
- currentSelector = `${currentSelector}:target`;
3683
- break;
3684
- case "enabled":
3685
- currentSelector = `${currentSelector}:enabled`;
3686
- break;
3687
- case "default":
3688
- currentSelector = `${currentSelector}:default`;
3689
- break;
3690
- case "optional":
3691
- currentSelector = `${currentSelector}:optional`;
3692
- break;
3693
- case "user-valid":
3694
- currentSelector = `${currentSelector}:user-valid`;
3695
- break;
3696
- case "user-invalid":
3697
- currentSelector = `${currentSelector}:user-invalid`;
3698
- break;
3699
- case "in-range":
3700
- currentSelector = `${currentSelector}:in-range`;
3701
- break;
3702
- case "out-of-range":
3703
- currentSelector = `${currentSelector}:out-of-range`;
3704
- break;
3705
- case "placeholder-shown":
3706
- currentSelector = `${currentSelector}:placeholder-shown`;
3707
- break;
3708
- case "autofill":
3709
- currentSelector = `${currentSelector}:autofill`;
3710
- break;
3711
- case "details-content":
3712
- currentSelector = `${currentSelector}:details-content`;
3713
- break;
3714
- case "placeholder":
3715
- currentSelector = `${currentSelector}::placeholder`;
3716
- break;
3717
- case "backdrop":
3718
- currentSelector = `${currentSelector}::backdrop`;
3719
- break;
3720
- case "before":
3721
- currentSelector = `${currentSelector}::before`;
3722
- break;
3723
- case "after":
3724
- currentSelector = `${currentSelector}::after`;
3725
- break;
3726
- case "first-letter":
3727
- currentSelector = `${currentSelector}::first-letter`;
3728
- break;
3729
- case "first-line":
3730
- currentSelector = `${currentSelector}::first-line`;
3731
- break;
3732
- case "marker":
3733
- currentSelector = `${currentSelector}::marker`;
3734
- break;
3735
- case "selection":
3736
- currentSelector = `${currentSelector}::selection`;
3737
- break;
3738
- case "file":
3739
- currentSelector = `${currentSelector}::file-selector-button`;
3740
- break;
3741
- case "first":
3742
- currentSelector = `${currentSelector}:first-child`;
3743
- break;
3744
- case "last":
3745
- currentSelector = `${currentSelector}:last-child`;
3746
- break;
3747
- case "odd":
3748
- currentSelector = `${currentSelector}:nth-child(odd)`;
3749
- break;
3750
- case "even":
3751
- currentSelector = `${currentSelector}:nth-child(even)`;
3752
- break;
3753
- case "first-of-type":
3754
- currentSelector = `${currentSelector}:first-of-type`;
3755
- break;
3756
- case "last-of-type":
3757
- currentSelector = `${currentSelector}:last-of-type`;
3758
- break;
3759
- case "only":
3760
- currentSelector = `${currentSelector}:only-child`;
3761
- break;
3762
- case "only-of-type":
3763
- currentSelector = `${currentSelector}:only-of-type`;
3764
- break;
3765
- case "empty":
3766
- currentSelector = `${currentSelector}:empty`;
3767
- break;
3768
- case "read-only":
3769
- currentSelector = `${currentSelector}:read-only`;
3770
- break;
3771
- case "open":
3772
- currentSelector = `${currentSelector}[open]`;
3773
- break;
3774
- case "group-hover":
3775
- currentSelector = `.group:hover ${currentSelector}`;
3776
- break;
3777
- case "group-focus":
3778
- currentSelector = `.group:focus ${currentSelector}`;
3779
- break;
3780
- case "group-active":
3781
- currentSelector = `.group:active ${currentSelector}`;
3782
- break;
3783
- case "peer-hover":
3784
- currentSelector = `.peer:hover ~ ${currentSelector}`;
3785
- break;
3786
- case "peer-focus":
3787
- currentSelector = `.peer:focus ~ ${currentSelector}`;
3788
- break;
3789
- case "peer-checked":
3790
- currentSelector = `.peer:checked ~ ${currentSelector}`;
3791
- break;
3792
- case "peer-disabled":
3793
- currentSelector = `.peer:disabled ~ ${currentSelector}`;
3794
- break;
3795
- case "not-hover":
3796
- currentSelector = `${currentSelector}:not(:hover)`;
3797
- break;
3798
- case "not-focus":
3799
- currentSelector = `${currentSelector}:not(:focus)`;
3800
- break;
3801
- case "not-disabled":
3802
- currentSelector = `${currentSelector}:not(:disabled)`;
3803
- break;
3804
- case "not-checked":
3805
- currentSelector = `${currentSelector}:not(:checked)`;
3806
- break;
3807
- case "in-hover":
3808
- currentSelector = `.group:hover ${currentSelector}`;
3809
- break;
3810
- case "in-focus":
3811
- currentSelector = `.group:focus ${currentSelector}`;
3812
- break;
3813
- default:
3814
- return void 0;
3686
+ const builtinHandler = VARIANT_MAP.get(variant);
3687
+ if (builtinHandler) {
3688
+ currentSelector = builtinHandler(currentSelector);
3689
+ } else {
3690
+ return void 0;
3815
3691
  }
3816
3692
  }
3817
3693
  return currentSelector;
@@ -3827,7 +3703,7 @@ function resolveRuntimeContext(options = {}) {
3827
3703
  addUtility: (pattern, handler) => pluginRegistry.addUtility(pattern, handler),
3828
3704
  addUtilities: (utilities) => pluginRegistry.addUtilities(utilities),
3829
3705
  addVariant: (name, handler) => pluginRegistry.addVariant(name, handler),
3830
- addVariants: (variants2) => pluginRegistry.addVariants(variants2),
3706
+ addVariants: (variants) => pluginRegistry.addVariants(variants),
3831
3707
  theme: (key) => {
3832
3708
  if (!key) return config.theme || {};
3833
3709
  const keys = key.split(".");
@@ -3880,7 +3756,7 @@ function parseClass(className, screens = {}, containers = {}) {
3880
3756
  const parts = splitByVariantDelimiter(normalized);
3881
3757
  if (parts.length === 0) return null;
3882
3758
  const baseToken = parts[parts.length - 1];
3883
- const variants2 = [];
3759
+ const variants = [];
3884
3760
  let breakpoint = null;
3885
3761
  let containerBreakpoint = null;
3886
3762
  let starting = false;
@@ -3901,9 +3777,9 @@ function parseClass(className, screens = {}, containers = {}) {
3901
3777
  breakpoint = part;
3902
3778
  continue;
3903
3779
  }
3904
- variants2.push(part);
3780
+ variants.push(part);
3905
3781
  }
3906
- const result = { original: token, baseToken, variants: variants2, breakpoint, containerBreakpoint, important, starting };
3782
+ const result = { original: token, baseToken, variants, breakpoint, containerBreakpoint, important, starting };
3907
3783
  if (parseCache.size >= PARSE_CACHE_MAX_SIZE) {
3908
3784
  const firstKey = parseCache.keys().next().value;
3909
3785
  parseCache.delete(firstKey);
@@ -3939,6 +3815,30 @@ function compileRuntimeClassNameWithContext(className, context) {
3939
3815
  function compileClass(className, options = {}) {
3940
3816
  return compileRuntimeClassNameWithContext(className, resolveRuntimeContext(options));
3941
3817
  }
3818
+ function compileCriticalCss(classNames, options = {}) {
3819
+ const classList = typeof classNames === "string" ? classNames.split(/\s+/).filter(Boolean) : Array.isArray(classNames) ? classNames.flatMap(
3820
+ (str) => typeof str === "string" ? str.split(/\s+/).filter(Boolean) : []
3821
+ ) : [];
3822
+ const context = resolveRuntimeContext(options);
3823
+ const cssRules = /* @__PURE__ */ new Set();
3824
+ classList.forEach((className) => {
3825
+ const css = compileRuntimeClassNameWithContext(className, context);
3826
+ if (css) {
3827
+ cssRules.add(css);
3828
+ }
3829
+ });
3830
+ return Array.from(cssRules).join("\n");
3831
+ }
3832
+ function extractClassNames(html) {
3833
+ const classSet = /* @__PURE__ */ new Set();
3834
+ const classRegex = /class(?:Name)?=["']([^"']+)["']/g;
3835
+ let match;
3836
+ while ((match = classRegex.exec(html)) !== null) {
3837
+ const classes = match[1].split(/\s+/).filter(Boolean);
3838
+ classes.forEach((cls) => classSet.add(cls));
3839
+ }
3840
+ return Array.from(classSet);
3841
+ }
3942
3842
 
3943
3843
  // src/preflight.js
3944
3844
  var preflight = `
@@ -4012,6 +3912,9 @@ function createWindrunner(options = {}) {
4012
3912
  const preflight2 = options.preflight !== false;
4013
3913
  const compatMode = options.compatMode || "none";
4014
3914
  const compatStyleId = options.compatStyleId || `${styleId}-full`;
3915
+ const maxCacheSize = options.maxCacheSize || 1e4;
3916
+ const onError = typeof options.onError === "function" ? options.onError : null;
3917
+ const onCompile = typeof options.onCompile === "function" ? options.onCompile : null;
4015
3918
  const tailwindOptions = getBaseTailwindOptions(options);
4016
3919
  const context = resolveRuntimeContext(tailwindOptions);
4017
3920
  const cache = /* @__PURE__ */ new Map();
@@ -4057,6 +3960,10 @@ function createWindrunner(options = {}) {
4057
3960
  const compileWithCache = (className) => {
4058
3961
  if (cache.has(className)) return cache.get(className);
4059
3962
  const cssRule = compileRuntimeClassNameWithContext(className, context);
3963
+ if (cache.size >= maxCacheSize) {
3964
+ const firstKey = cache.keys().next().value;
3965
+ cache.delete(firstKey);
3966
+ }
4060
3967
  cache.set(className, cssRule);
4061
3968
  return cssRule;
4062
3969
  };
@@ -4079,8 +3986,19 @@ function createWindrunner(options = {}) {
4079
3986
  const cssRule = compileWithCache(className);
4080
3987
  if (!cssRule) {
4081
3988
  ensureCompatStyle();
3989
+ if (onError) {
3990
+ const parsed = parseClass(className, context.screens, context.containers);
3991
+ const errorContext = {
3992
+ reason: parsed ? "unknown-utility" : "parse-error",
3993
+ baseToken: parsed ? parsed.baseToken : className,
3994
+ variants: parsed ? parsed.variants : void 0,
3995
+ details: parsed ? `Could not compile utility "${parsed.baseToken}"${parsed.variants.length ? ` with variants: ${parsed.variants.join(", ")}` : ""}` : `Failed to parse class name "${className}"`
3996
+ };
3997
+ onError(className, errorContext);
3998
+ }
4082
3999
  } else {
4083
4000
  insertRule(cssRule);
4001
+ if (onCompile) onCompile(className, cssRule);
4084
4002
  }
4085
4003
  return cssRule;
4086
4004
  };
@@ -4101,9 +4019,39 @@ function createWindrunner(options = {}) {
4101
4019
  };
4102
4020
  const scan = (root = document) => {
4103
4021
  if (typeof document !== "object" || !root) return;
4104
- if (root.nodeType === 1) processElementTree(root);
4022
+ const startTime = typeof performance !== "undefined" ? performance.now() : Date.now();
4023
+ const scannedElements = /* @__PURE__ */ new Set();
4024
+ const foundClasses = /* @__PURE__ */ new Set();
4025
+ const initialRuleCount = insertedRules.size;
4026
+ if (root.nodeType === 1) {
4027
+ processElementTree(root);
4028
+ if (root.classList) {
4029
+ scannedElements.add(root);
4030
+ root.classList.forEach((cls) => foundClasses.add(cls));
4031
+ }
4032
+ }
4105
4033
  const elements = root.querySelectorAll ? root.querySelectorAll("[class]") : [];
4106
- elements.forEach((element) => processElement(element));
4034
+ elements.forEach((element) => {
4035
+ processElement(element);
4036
+ scannedElements.add(element);
4037
+ if (element.classList) {
4038
+ element.classList.forEach((cls) => foundClasses.add(cls));
4039
+ }
4040
+ });
4041
+ if (typeof options.onScanComplete === "function") {
4042
+ const endTime = typeof performance !== "undefined" ? performance.now() : Date.now();
4043
+ const stats = {
4044
+ elementCount: scannedElements.size,
4045
+ classCount: foundClasses.size,
4046
+ ruleCount: insertedRules.size - initialRuleCount,
4047
+ duration: endTime - startTime
4048
+ };
4049
+ if (typeof requestAnimationFrame === "function") {
4050
+ requestAnimationFrame(() => options.onScanComplete(stats));
4051
+ } else {
4052
+ setTimeout(() => options.onScanComplete(stats), 0);
4053
+ }
4054
+ }
4107
4055
  };
4108
4056
  const flushQueue = () => {
4109
4057
  scheduled = false;
@@ -4136,12 +4084,18 @@ function createWindrunner(options = {}) {
4136
4084
  });
4137
4085
  scheduleFlush();
4138
4086
  });
4139
- observer.observe(root, {
4140
- childList: true,
4141
- subtree: true,
4142
- attributes: true,
4143
- attributeFilter: ["class"]
4144
- });
4087
+ const observerConfig = options.observerOptions || {};
4088
+ const finalConfig = {
4089
+ childList: observerConfig.childList !== false,
4090
+ // default: true
4091
+ subtree: observerConfig.subtree !== false,
4092
+ // default: true
4093
+ attributes: observerConfig.attributes !== false,
4094
+ // default: true
4095
+ attributeFilter: observerConfig.attributeFilter || ["class"]
4096
+ // default: ["class"]
4097
+ };
4098
+ observer.observe(root, finalConfig);
4145
4099
  };
4146
4100
  const disconnect = () => {
4147
4101
  pendingElements.clear();
@@ -4183,6 +4137,16 @@ function createWindrunner(options = {}) {
4183
4137
  }
4184
4138
  runStart();
4185
4139
  };
4140
+ const clearCache = () => {
4141
+ cache.clear();
4142
+ };
4143
+ const getStats = () => ({
4144
+ cacheSize: cache.size,
4145
+ insertedRuleCount: insertedRules.size,
4146
+ pendingElementCount: pendingElements.size,
4147
+ isObserving: observer !== null,
4148
+ isCompatLoaded: compatLoaded
4149
+ });
4186
4150
  return {
4187
4151
  processClassName,
4188
4152
  processClassList,
@@ -4192,6 +4156,8 @@ function createWindrunner(options = {}) {
4192
4156
  flush,
4193
4157
  start,
4194
4158
  disconnect,
4159
+ clearCache,
4160
+ getStats,
4195
4161
  isCompatLoaded: () => compatLoaded,
4196
4162
  getCacheSize: () => cache.size,
4197
4163
  getInsertedRuleCount: () => insertedRules.size
@@ -4207,10 +4173,13 @@ function windrunner(options = {}) {
4207
4173
  // Annotate the CommonJS export names for ESM import in node:
4208
4174
  0 && (module.exports = {
4209
4175
  compileClass,
4176
+ compileCriticalCss,
4210
4177
  createWindrunner,
4211
4178
  defineResponsiveUtilities,
4212
4179
  defineUtilities,
4180
+ extractClassNames,
4213
4181
  parseClass,
4214
4182
  plugin,
4215
4183
  windrunner
4216
4184
  });
4185
+ //# sourceMappingURL=index.js.map