windrunner 1.1.2 → 1.1.4

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.esm.js CHANGED
@@ -21,14 +21,14 @@ var theme = {
21
21
  backgroundColor: ({ theme: theme2 }) => theme2("colors"),
22
22
  backgroundImage: {
23
23
  none: "none",
24
- "linear-to-t": "linear-gradient(to top, var(--tw-gradient-stops))",
25
- "linear-to-tr": "linear-gradient(to top right, var(--tw-gradient-stops))",
26
- "linear-to-r": "linear-gradient(to right, var(--tw-gradient-stops))",
27
- "linear-to-br": "linear-gradient(to bottom right, var(--tw-gradient-stops))",
28
- "linear-to-b": "linear-gradient(to bottom, var(--tw-gradient-stops))",
29
- "linear-to-bl": "linear-gradient(to bottom left, var(--tw-gradient-stops))",
30
- "linear-to-l": "linear-gradient(to left, var(--tw-gradient-stops))",
31
- "linear-to-tl": "linear-gradient(to top left, var(--tw-gradient-stops))"
24
+ "gradient-to-t": "linear-gradient(to top, var(--tw-gradient-stops))",
25
+ "gradient-to-tr": "linear-gradient(to top right, var(--tw-gradient-stops))",
26
+ "gradient-to-r": "linear-gradient(to right, var(--tw-gradient-stops))",
27
+ "gradient-to-br": "linear-gradient(to bottom right, var(--tw-gradient-stops))",
28
+ "gradient-to-b": "linear-gradient(to bottom, var(--tw-gradient-stops))",
29
+ "gradient-to-bl": "linear-gradient(to bottom left, var(--tw-gradient-stops))",
30
+ "gradient-to-l": "linear-gradient(to left, var(--tw-gradient-stops))",
31
+ "gradient-to-tl": "linear-gradient(to top left, var(--tw-gradient-stops))"
32
32
  },
33
33
  backgroundPosition: {
34
34
  bottom: "bottom",
@@ -1354,29 +1354,70 @@ var config_default = configOptions;
1354
1354
  function isFunction(fn) {
1355
1355
  return fn && {}.toString.call(fn) === "[object Function]";
1356
1356
  }
1357
+ var configCache = /* @__PURE__ */ new WeakMap();
1358
+ var defaultContextCache = null;
1359
+ function createLazyTheme(userTheme = {}, userThemeExtend = {}) {
1360
+ const resolved = /* @__PURE__ */ new Map();
1361
+ const defaultTheme = config_default.theme;
1362
+ return new Proxy({}, {
1363
+ get(_, key) {
1364
+ if (resolved.has(key)) {
1365
+ return resolved.get(key);
1366
+ }
1367
+ let value = Object.prototype.hasOwnProperty.call(userTheme, key) ? userTheme[key] : defaultTheme[key];
1368
+ if (isFunction(value)) {
1369
+ value = value({
1370
+ theme: (keyRef) => {
1371
+ if (resolved.has(keyRef)) return resolved.get(keyRef);
1372
+ return createLazyTheme(userTheme, userThemeExtend)[keyRef];
1373
+ }
1374
+ });
1375
+ }
1376
+ if (userThemeExtend[key]) {
1377
+ value = Object.assign({}, value, userThemeExtend[key]);
1378
+ }
1379
+ resolved.set(key, value);
1380
+ return value;
1381
+ },
1382
+ has(_, key) {
1383
+ return key in defaultTheme || key in userTheme;
1384
+ },
1385
+ ownKeys(_) {
1386
+ return [.../* @__PURE__ */ new Set([...Object.keys(defaultTheme), ...Object.keys(userTheme)])];
1387
+ },
1388
+ getOwnPropertyDescriptor(_, key) {
1389
+ if (key in defaultTheme || key in userTheme) {
1390
+ return {
1391
+ enumerable: true,
1392
+ configurable: true
1393
+ };
1394
+ }
1395
+ }
1396
+ });
1397
+ }
1357
1398
  function getConfigOptions(options = {}, pluginKeys = []) {
1399
+ if (!options || typeof options === "object" && Object.keys(options).length === 0) {
1400
+ if (!defaultContextCache) {
1401
+ defaultContextCache = {
1402
+ ...config_default,
1403
+ theme: createLazyTheme({}, {})
1404
+ };
1405
+ }
1406
+ return defaultContextCache;
1407
+ }
1408
+ if (configCache.has(options)) {
1409
+ return configCache.get(options);
1410
+ }
1358
1411
  const { theme: theme2 = {} } = options;
1359
1412
  const { extend: themeExtend = {} } = theme2;
1360
- const newTheme = {};
1361
- const themeKeys = Object.keys(config_default.theme);
1362
- themeKeys.forEach((key) => {
1363
- newTheme[key] = Object.prototype.hasOwnProperty.call(theme2, key) ? theme2[key] : config_default.theme[key];
1364
- });
1365
- themeKeys.forEach((key) => {
1366
- if (isFunction(newTheme[key])) {
1367
- newTheme[key] = newTheme[key]({
1368
- theme: (keyRef) => newTheme[keyRef]
1369
- });
1370
- }
1371
- if (themeExtend[key]) {
1372
- newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
1373
- }
1374
- });
1375
- return {
1413
+ const lazyTheme = createLazyTheme(theme2, themeExtend);
1414
+ const config = {
1376
1415
  ...config_default,
1377
1416
  ...options,
1378
- theme: newTheme
1417
+ theme: lazyTheme
1379
1418
  };
1419
+ configCache.set(options, config);
1420
+ return config;
1380
1421
  }
1381
1422
 
1382
1423
  // src/constants.js
@@ -1460,112 +1501,93 @@ function escapeCssIdentifier(value) {
1460
1501
  }
1461
1502
  function appendImportant(declaration, isImportant) {
1462
1503
  if (!isImportant) return declaration;
1463
- const entries = declaration.split(";").map((item) => item.trim()).filter(Boolean).map((item) => item.includes("!important") ? item : `${item} !important`);
1464
- return `${entries.join("; ")};`;
1504
+ return declaration.replace(/([^;{}]+);/g, (match, decl) => {
1505
+ const trimmed = decl.trim();
1506
+ if (!trimmed || trimmed.includes("!important")) return match;
1507
+ return `${trimmed} !important;`;
1508
+ });
1465
1509
  }
1466
1510
  function splitByVariantDelimiter(token) {
1467
1511
  const parts = [];
1468
- let current = "";
1512
+ let start = 0;
1469
1513
  let bracketDepth = 0;
1470
1514
  for (let i = 0; i < token.length; i += 1) {
1471
1515
  const char = token[i];
1472
- if (char === "[") bracketDepth += 1;
1473
- if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
1474
- if (char === ":" && bracketDepth === 0) {
1475
- parts.push(current);
1476
- current = "";
1477
- } else {
1478
- current += char;
1516
+ if (char === "[") {
1517
+ bracketDepth += 1;
1518
+ } else if (char === "]") {
1519
+ bracketDepth = Math.max(0, bracketDepth - 1);
1520
+ } else if (char === ":" && bracketDepth === 0) {
1521
+ parts.push(token.slice(start, i));
1522
+ start = i + 1;
1479
1523
  }
1480
1524
  }
1481
- if (current) parts.push(current);
1525
+ parts.push(token.slice(start));
1482
1526
  return parts;
1483
1527
  }
1484
1528
 
1485
1529
  // src/maps/layout.maps.js
1530
+ function createSimpleMap(prop, values, keyMap = {}) {
1531
+ const map = {};
1532
+ values.forEach((value) => {
1533
+ const key = keyMap[value] || value;
1534
+ map[key] = `${prop}: ${value};`;
1535
+ });
1536
+ return map;
1537
+ }
1486
1538
  var DISPLAY_MAP = {
1487
- block: "display: block;",
1488
- inline: "display: inline;",
1489
- "inline-block": "display: inline-block;",
1490
- flex: "display: flex;",
1491
- "inline-flex": "display: inline-flex;",
1492
- grid: "display: grid;",
1493
- "inline-grid": "display: inline-grid;",
1494
- hidden: "display: none;",
1495
- contents: "display: contents;",
1496
- "flow-root": "display: flow-root;",
1497
- "list-item": "display: list-item;",
1498
- table: "display: table;",
1499
- "inline-table": "display: inline-table;",
1500
- "table-caption": "display: table-caption;",
1501
- "table-cell": "display: table-cell;",
1502
- "table-column": "display: table-column;",
1503
- "table-column-group": "display: table-column-group;",
1504
- "table-footer-group": "display: table-footer-group;",
1505
- "table-header-group": "display: table-header-group;",
1506
- "table-row-group": "display: table-row-group;",
1507
- "table-row": "display: table-row;"
1508
- };
1509
- var POSITION_MAP = {
1510
- static: "position: static;",
1511
- fixed: "position: fixed;",
1512
- absolute: "position: absolute;",
1513
- relative: "position: relative;",
1514
- sticky: "position: sticky;"
1539
+ ...createSimpleMap("display", [
1540
+ "block",
1541
+ "inline",
1542
+ "inline-block",
1543
+ "flex",
1544
+ "inline-flex",
1545
+ "grid",
1546
+ "inline-grid",
1547
+ "contents",
1548
+ "flow-root",
1549
+ "list-item",
1550
+ "table",
1551
+ "inline-table",
1552
+ "table-caption",
1553
+ "table-cell",
1554
+ "table-column",
1555
+ "table-column-group",
1556
+ "table-footer-group",
1557
+ "table-header-group",
1558
+ "table-row-group",
1559
+ "table-row"
1560
+ ]),
1561
+ hidden: "display: none;"
1562
+ // Special case
1515
1563
  };
1564
+ var POSITION_MAP = createSimpleMap("position", [
1565
+ "static",
1566
+ "fixed",
1567
+ "absolute",
1568
+ "relative",
1569
+ "sticky"
1570
+ ]);
1516
1571
  var VISIBILITY_MAP = {
1517
- visible: "visibility: visible;",
1518
- invisible: "visibility: hidden;",
1519
- collapse: "visibility: collapse;"
1520
- };
1521
- var OVERFLOW_MAP = {
1522
- auto: "overflow: auto;",
1523
- hidden: "overflow: hidden;",
1524
- clip: "overflow: clip;",
1525
- visible: "overflow: visible;",
1526
- scroll: "overflow: scroll;"
1527
- };
1528
- var OVERFLOW_X_MAP = {
1529
- auto: "overflow-x: auto;",
1530
- hidden: "overflow-x: hidden;",
1531
- clip: "overflow-x: clip;",
1532
- visible: "overflow-x: visible;",
1533
- scroll: "overflow-x: scroll;"
1534
- };
1535
- var OVERFLOW_Y_MAP = {
1536
- auto: "overflow-y: auto;",
1537
- hidden: "overflow-y: hidden;",
1538
- clip: "overflow-y: clip;",
1539
- visible: "overflow-y: visible;",
1540
- scroll: "overflow-y: scroll;"
1541
- };
1542
- var OVERSCROLL_MAP = {
1543
- auto: "overscroll-behavior: auto;",
1544
- contain: "overscroll-behavior: contain;",
1545
- none: "overscroll-behavior: none;"
1546
- };
1547
- var OVERSCROLL_X_MAP = {
1548
- auto: "overscroll-behavior-x: auto;",
1549
- contain: "overscroll-behavior-x: contain;",
1550
- none: "overscroll-behavior-x: none;"
1551
- };
1552
- var OVERSCROLL_Y_MAP = {
1553
- auto: "overscroll-behavior-y: auto;",
1554
- contain: "overscroll-behavior-y: contain;",
1555
- none: "overscroll-behavior-y: none;"
1572
+ ...createSimpleMap("visibility", ["visible", "collapse"]),
1573
+ invisible: "visibility: hidden;"
1574
+ // Key differs from value
1556
1575
  };
1576
+ var OVERFLOW_VALUES = ["auto", "hidden", "clip", "visible", "scroll"];
1577
+ var OVERFLOW_MAP = createSimpleMap("overflow", OVERFLOW_VALUES);
1578
+ var OVERFLOW_X_MAP = createSimpleMap("overflow-x", OVERFLOW_VALUES);
1579
+ var OVERFLOW_Y_MAP = createSimpleMap("overflow-y", OVERFLOW_VALUES);
1580
+ var OVERSCROLL_VALUES = ["auto", "contain", "none"];
1581
+ var OVERSCROLL_MAP = createSimpleMap("overscroll-behavior", OVERSCROLL_VALUES);
1582
+ var OVERSCROLL_X_MAP = createSimpleMap("overscroll-behavior-x", OVERSCROLL_VALUES);
1583
+ var OVERSCROLL_Y_MAP = createSimpleMap("overscroll-behavior-y", OVERSCROLL_VALUES);
1557
1584
  var FLOAT_MAP = {
1558
- left: "float: left;",
1559
- right: "float: right;",
1560
- none: "float: none;",
1585
+ ...createSimpleMap("float", ["left", "right", "none"]),
1561
1586
  start: "float: inline-start;",
1562
1587
  end: "float: inline-end;"
1563
1588
  };
1564
1589
  var CLEAR_MAP = {
1565
- left: "clear: left;",
1566
- right: "clear: right;",
1567
- both: "clear: both;",
1568
- none: "clear: none;",
1590
+ ...createSimpleMap("clear", ["left", "right", "both", "none"]),
1569
1591
  start: "clear: inline-start;",
1570
1592
  end: "clear: inline-end;"
1571
1593
  };
@@ -1573,13 +1595,13 @@ var ISOLATION_MAP = {
1573
1595
  isolate: "isolation: isolate;",
1574
1596
  "isolation-auto": "isolation: auto;"
1575
1597
  };
1576
- var OBJECT_FIT_MAP = {
1577
- contain: "object-fit: contain;",
1578
- cover: "object-fit: cover;",
1579
- fill: "object-fit: fill;",
1580
- none: "object-fit: none;",
1581
- "scale-down": "object-fit: scale-down;"
1582
- };
1598
+ var OBJECT_FIT_MAP = createSimpleMap("object-fit", [
1599
+ "contain",
1600
+ "cover",
1601
+ "fill",
1602
+ "none",
1603
+ "scale-down"
1604
+ ]);
1583
1605
  var TRANSFORM_STYLE_MAP = {
1584
1606
  "transform-style-flat": "transform-style: flat;",
1585
1607
  "transform-style-3d": "transform-style: preserve-3d;",
@@ -1597,81 +1619,64 @@ var BOX_SIZING_MAP = {
1597
1619
  border: "box-sizing: border-box;",
1598
1620
  content: "box-sizing: content-box;"
1599
1621
  };
1622
+ var BREAK_AFTER_BEFORE_VALUES = [
1623
+ "auto",
1624
+ "avoid",
1625
+ "avoid-page",
1626
+ "avoid-column",
1627
+ "page",
1628
+ "left",
1629
+ "right",
1630
+ "recto",
1631
+ "verso"
1632
+ ];
1600
1633
  var BREAK_AFTER_MAP = {
1601
- auto: "break-after: auto;",
1602
- avoid: "break-after: avoid;",
1603
- "avoid-page": "break-after: avoid-page;",
1604
- "avoid-column": "break-after: avoid-column;",
1605
- page: "break-after: page;",
1606
- all: "break-after: all;",
1607
- left: "break-after: left;",
1608
- right: "break-after: right;",
1609
- recto: "break-after: recto;",
1610
- verso: "break-after: verso;"
1611
- };
1612
- var BREAK_BEFORE_MAP = {
1613
- auto: "break-before: auto;",
1614
- avoid: "break-before: avoid;",
1615
- "avoid-page": "break-before: avoid-page;",
1616
- "avoid-column": "break-before: avoid-column;",
1617
- page: "break-before: page;",
1618
- left: "break-before: left;",
1619
- right: "break-before: right;",
1620
- recto: "break-before: recto;",
1621
- verso: "break-before: verso;"
1622
- };
1623
- var BREAK_INSIDE_MAP = {
1624
- auto: "break-inside: auto;",
1625
- avoid: "break-inside: avoid;",
1626
- "avoid-page": "break-inside: avoid-page;",
1627
- "avoid-column": "break-inside: avoid-column;"
1628
- };
1629
- var BOX_DECORATION_BREAK_MAP = {
1630
- slice: "box-decoration-break: slice;",
1631
- clone: "box-decoration-break: clone;"
1632
- };
1633
- var HYPHENS_MAP = {
1634
- none: "hyphens: none;",
1635
- manual: "hyphens: manual;",
1636
- auto: "hyphens: auto;"
1637
- };
1638
- var COLOR_SCHEME_MAP = {
1639
- light: "color-scheme: light;",
1640
- dark: "color-scheme: dark;",
1641
- normal: "color-scheme: normal;"
1642
- };
1643
- var SCROLLBAR_COLOR_MAP = {
1644
- auto: "scrollbar-color: auto;",
1645
- transparent: "scrollbar-color: transparent;",
1646
- current: "scrollbar-color: currentColor;"
1647
- };
1648
- var SCROLLBAR_WIDTH_MAP = {
1649
- auto: "scrollbar-width: auto;",
1650
- thin: "scrollbar-width: thin;",
1651
- none: "scrollbar-width: none;"
1634
+ ...createSimpleMap("break-after", BREAK_AFTER_BEFORE_VALUES),
1635
+ all: "break-after: all;"
1652
1636
  };
1637
+ var BREAK_BEFORE_MAP = createSimpleMap("break-before", BREAK_AFTER_BEFORE_VALUES);
1638
+ var BREAK_INSIDE_MAP = createSimpleMap("break-inside", [
1639
+ "auto",
1640
+ "avoid",
1641
+ "avoid-page",
1642
+ "avoid-column"
1643
+ ]);
1644
+ var BOX_DECORATION_BREAK_MAP = createSimpleMap("box-decoration-break", [
1645
+ "slice",
1646
+ "clone"
1647
+ ]);
1648
+ var HYPHENS_MAP = createSimpleMap("hyphens", ["none", "manual", "auto"]);
1649
+ var COLOR_SCHEME_MAP = createSimpleMap("color-scheme", [
1650
+ "light",
1651
+ "dark",
1652
+ "normal"
1653
+ ]);
1654
+ var SCROLLBAR_COLOR_MAP = createSimpleMap("scrollbar-color", [
1655
+ "auto",
1656
+ "transparent",
1657
+ "current"
1658
+ ]);
1659
+ var SCROLLBAR_WIDTH_MAP = createSimpleMap("scrollbar-width", [
1660
+ "auto",
1661
+ "thin",
1662
+ "none"
1663
+ ]);
1653
1664
  var SCROLLBAR_GUTTER_MAP = {
1654
1665
  auto: "scrollbar-gutter: auto;",
1655
1666
  stable: "scrollbar-gutter: stable;",
1656
1667
  "stable-both-edges": "scrollbar-gutter: stable both-edges;",
1657
1668
  "both-edges": "scrollbar-gutter: both-edges;"
1658
1669
  };
1659
- var TABLE_LAYOUT_MAP = {
1660
- auto: "table-layout: auto;",
1661
- fixed: "table-layout: fixed;"
1662
- };
1663
- var CAPTION_SIDE_MAP = {
1664
- top: "caption-side: top;",
1665
- bottom: "caption-side: bottom;"
1666
- };
1667
- var BORDER_COLLAPSE_MAP = {
1668
- collapse: "border-collapse: collapse;",
1669
- separate: "border-collapse: separate;"
1670
- };
1671
- var SCROLL_BEHAVIOR_MAP = {
1672
- auto: "scroll-behavior: auto;",
1673
- smooth: "scroll-behavior: smooth;"
1674
- };
1670
+ var TABLE_LAYOUT_MAP = createSimpleMap("table-layout", ["auto", "fixed"]);
1671
+ var CAPTION_SIDE_MAP = createSimpleMap("caption-side", ["top", "bottom"]);
1672
+ var BORDER_COLLAPSE_MAP = createSimpleMap("border-collapse", [
1673
+ "collapse",
1674
+ "separate"
1675
+ ]);
1676
+ var SCROLL_BEHAVIOR_MAP = createSimpleMap("scroll-behavior", [
1677
+ "auto",
1678
+ "smooth"
1679
+ ]);
1675
1680
  var SIDE_PROPS = {
1676
1681
  "": [""],
1677
1682
  t: ["-top"],
@@ -1702,71 +1707,69 @@ var ROUNDED_PROPS = {
1702
1707
  };
1703
1708
 
1704
1709
  // src/maps/interactivity.maps.js
1705
- var CURSOR_MAP = {
1706
- auto: "cursor: auto;",
1707
- default: "cursor: default;",
1708
- pointer: "cursor: pointer;",
1709
- wait: "cursor: wait;",
1710
- text: "cursor: text;",
1711
- move: "cursor: move;",
1712
- help: "cursor: help;",
1713
- "not-allowed": "cursor: not-allowed;",
1714
- none: "cursor: none;",
1715
- "context-menu": "cursor: context-menu;",
1716
- progress: "cursor: progress;",
1717
- cell: "cursor: cell;",
1718
- crosshair: "cursor: crosshair;",
1719
- "vertical-text": "cursor: vertical-text;",
1720
- alias: "cursor: alias;",
1721
- copy: "cursor: copy;",
1722
- "no-drop": "cursor: no-drop;",
1723
- grab: "cursor: grab;",
1724
- grabbing: "cursor: grabbing;",
1725
- "all-scroll": "cursor: all-scroll;",
1726
- "zoom-in": "cursor: zoom-in;",
1727
- "zoom-out": "cursor: zoom-out;"
1728
- };
1729
- var POINTER_EVENTS_MAP = {
1730
- none: "pointer-events: none;",
1731
- auto: "pointer-events: auto;"
1732
- };
1733
- var USER_SELECT_MAP = {
1734
- none: "user-select: none;",
1735
- text: "user-select: text;",
1736
- all: "user-select: all;",
1737
- auto: "user-select: auto;"
1738
- };
1739
- var APPEARANCE_MAP = {
1740
- none: "appearance: none;",
1741
- auto: "appearance: auto;"
1742
- };
1743
- var TOUCH_ACTION_MAP = {
1744
- auto: "touch-action: auto;",
1745
- none: "touch-action: none;",
1746
- "pan-x": "touch-action: pan-x;",
1747
- "pan-left": "touch-action: pan-left;",
1748
- "pan-right": "touch-action: pan-right;",
1749
- "pan-y": "touch-action: pan-y;",
1750
- "pan-up": "touch-action: pan-up;",
1751
- "pan-down": "touch-action: pan-down;",
1752
- "pinch-zoom": "touch-action: pinch-zoom;",
1753
- manipulation: "touch-action: manipulation;"
1754
- };
1710
+ function createSimpleMap2(prop, values) {
1711
+ const map = {};
1712
+ values.forEach((value) => {
1713
+ map[value] = `${prop}: ${value};`;
1714
+ });
1715
+ return map;
1716
+ }
1717
+ var CURSOR_MAP = createSimpleMap2("cursor", [
1718
+ "auto",
1719
+ "default",
1720
+ "pointer",
1721
+ "wait",
1722
+ "text",
1723
+ "move",
1724
+ "help",
1725
+ "not-allowed",
1726
+ "none",
1727
+ "context-menu",
1728
+ "progress",
1729
+ "cell",
1730
+ "crosshair",
1731
+ "vertical-text",
1732
+ "alias",
1733
+ "copy",
1734
+ "no-drop",
1735
+ "grab",
1736
+ "grabbing",
1737
+ "all-scroll",
1738
+ "zoom-in",
1739
+ "zoom-out"
1740
+ ]);
1741
+ var POINTER_EVENTS_MAP = createSimpleMap2("pointer-events", ["none", "auto"]);
1742
+ var USER_SELECT_MAP = createSimpleMap2("user-select", [
1743
+ "none",
1744
+ "text",
1745
+ "all",
1746
+ "auto"
1747
+ ]);
1748
+ var APPEARANCE_MAP = createSimpleMap2("appearance", ["none", "auto"]);
1749
+ var TOUCH_ACTION_MAP = createSimpleMap2("touch-action", [
1750
+ "auto",
1751
+ "none",
1752
+ "pan-x",
1753
+ "pan-left",
1754
+ "pan-right",
1755
+ "pan-y",
1756
+ "pan-up",
1757
+ "pan-down",
1758
+ "pinch-zoom",
1759
+ "manipulation"
1760
+ ]);
1755
1761
  var OUTLINE_STYLE_MAP = {
1756
1762
  none: "outline: 2px solid transparent; outline-offset: 2px;",
1757
- solid: "outline-style: solid;",
1758
- dashed: "outline-style: dashed;",
1759
- dotted: "outline-style: dotted;",
1760
- double: "outline-style: double;"
1761
- };
1762
- var BORDER_STYLE_MAP = {
1763
- solid: "border-style: solid;",
1764
- dashed: "border-style: dashed;",
1765
- dotted: "border-style: dotted;",
1766
- double: "border-style: double;",
1767
- hidden: "border-style: hidden;",
1768
- none: "border-style: none;"
1763
+ ...createSimpleMap2("outline-style", ["solid", "dashed", "dotted", "double"])
1769
1764
  };
1765
+ var BORDER_STYLE_MAP = createSimpleMap2("border-style", [
1766
+ "solid",
1767
+ "dashed",
1768
+ "dotted",
1769
+ "double",
1770
+ "hidden",
1771
+ "none"
1772
+ ]);
1770
1773
  var TRANSITION_PROPERTY_MAP = {
1771
1774
  none: "none",
1772
1775
  all: "all",
@@ -2760,23 +2763,33 @@ function buildGradientDeclaration(baseToken, theme2) {
2760
2763
  const colors = theme2.gradientColorStops || theme2.colors || {};
2761
2764
  if (baseToken.startsWith("from-")) {
2762
2765
  const key = baseToken.slice(5);
2763
- if (key.endsWith("%")) return `--tw-gradient-from-position: ${key};`;
2766
+ if (key.endsWith("%") || /^\d+$/.test(key)) {
2767
+ return `--tw-gradient-from-position: ${key.endsWith("%") ? key : key + "%"};`;
2768
+ }
2764
2769
  const color = resolveColorWithOpacity(colors, key);
2765
2770
  if (color !== void 0) {
2766
- return `--tw-gradient-from: ${color}; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-via, transparent), var(--tw-gradient-to, transparent);`;
2771
+ return `--tw-gradient-from: ${color} var(--tw-gradient-from-position, 0%); --tw-gradient-to: transparent var(--tw-gradient-to-position, 100%); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);`;
2767
2772
  }
2768
2773
  }
2769
2774
  if (baseToken.startsWith("via-")) {
2770
2775
  const key = baseToken.slice(4);
2771
- if (key.endsWith("%")) return `--tw-gradient-via-position: ${key};`;
2776
+ if (key.endsWith("%") || /^\d+$/.test(key)) {
2777
+ return `--tw-gradient-via-position: ${key.endsWith("%") ? key : key + "%"};`;
2778
+ }
2772
2779
  const color = resolveColorWithOpacity(colors, key);
2773
- if (color !== void 0) return `--tw-gradient-via: ${color};`;
2780
+ if (color !== void 0) {
2781
+ return `--tw-gradient-to: transparent var(--tw-gradient-to-position, 100%); --tw-gradient-stops: var(--tw-gradient-from), ${color} var(--tw-gradient-via-position, 50%), var(--tw-gradient-to);`;
2782
+ }
2774
2783
  }
2775
2784
  if (baseToken.startsWith("to-")) {
2776
2785
  const key = baseToken.slice(3);
2777
- if (key.endsWith("%")) return `--tw-gradient-to-position: ${key};`;
2786
+ if (key.endsWith("%") || /^\d+$/.test(key)) {
2787
+ return `--tw-gradient-to-position: ${key.endsWith("%") ? key : key + "%"};`;
2788
+ }
2778
2789
  const color = resolveColorWithOpacity(colors, key);
2779
- if (color !== void 0) return `--tw-gradient-to: ${color};`;
2790
+ if (color !== void 0) {
2791
+ return `--tw-gradient-to: ${color} var(--tw-gradient-to-position, 100%);`;
2792
+ }
2780
2793
  }
2781
2794
  return void 0;
2782
2795
  }
@@ -3219,7 +3232,8 @@ function buildDivideDeclaration(baseToken, theme2) {
3219
3232
  // src/plugins.js
3220
3233
  var PluginRegistry = class {
3221
3234
  constructor() {
3222
- this.utilities = /* @__PURE__ */ new Map();
3235
+ this.exactUtilities = /* @__PURE__ */ new Map();
3236
+ this.regexUtilities = [];
3223
3237
  this.variants = /* @__PURE__ */ new Map();
3224
3238
  }
3225
3239
  /**
@@ -3228,7 +3242,11 @@ var PluginRegistry = class {
3228
3242
  * @param {Function|string} handler - Function that returns CSS or CSS string
3229
3243
  */
3230
3244
  addUtility(pattern, handler) {
3231
- this.utilities.set(pattern, handler);
3245
+ if (pattern instanceof RegExp) {
3246
+ this.regexUtilities.push([pattern, handler]);
3247
+ } else {
3248
+ this.exactUtilities.set(pattern, handler);
3249
+ }
3232
3250
  }
3233
3251
  /**
3234
3252
  * Register multiple utilities at once
@@ -3258,18 +3276,22 @@ var PluginRegistry = class {
3258
3276
  }
3259
3277
  /**
3260
3278
  * Check if a token matches any custom utility pattern
3279
+ * Optimized: O(1) fast path for exact matches, O(n) only for regex patterns
3261
3280
  * @param {string} token - The base token to match
3262
3281
  * @returns {Object|null} - { handler, match } or null
3263
3282
  */
3264
3283
  matchUtility(token) {
3265
- for (const [pattern, handler] of this.utilities) {
3266
- if (pattern instanceof RegExp) {
3267
- const match = pattern.exec(token);
3268
- if (match) {
3269
- return { handler, match };
3270
- }
3271
- } else if (pattern === token) {
3272
- return { handler, match: [token] };
3284
+ if (this.exactUtilities.has(token)) {
3285
+ return {
3286
+ handler: this.exactUtilities.get(token),
3287
+ match: [token]
3288
+ };
3289
+ }
3290
+ for (let i = 0; i < this.regexUtilities.length; i += 1) {
3291
+ const [pattern, handler] = this.regexUtilities[i];
3292
+ const match = pattern.exec(token);
3293
+ if (match) {
3294
+ return { handler, match };
3273
3295
  }
3274
3296
  }
3275
3297
  return null;
@@ -3286,7 +3308,10 @@ var PluginRegistry = class {
3286
3308
  * Get all registered utility patterns (for debugging)
3287
3309
  */
3288
3310
  getUtilities() {
3289
- return Array.from(this.utilities.keys());
3311
+ return [
3312
+ ...Array.from(this.exactUtilities.keys()),
3313
+ ...this.regexUtilities.map(([pattern]) => pattern)
3314
+ ];
3290
3315
  }
3291
3316
  /**
3292
3317
  * Get all registered variant names (for debugging)
@@ -3298,7 +3323,8 @@ var PluginRegistry = class {
3298
3323
  * Clear all registered plugins
3299
3324
  */
3300
3325
  clear() {
3301
- this.utilities.clear();
3326
+ this.exactUtilities.clear();
3327
+ this.regexUtilities = [];
3302
3328
  this.variants.clear();
3303
3329
  }
3304
3330
  };
@@ -3503,8 +3529,26 @@ function extractPrefix(token) {
3503
3529
  }
3504
3530
  return prefix;
3505
3531
  }
3532
+ var UNKNOWN_PREFIX_CACHE = /* @__PURE__ */ new Set();
3533
+ var MAX_UNKNOWN_CACHE_SIZE = 500;
3506
3534
  function checkAllBuilders(baseToken, theme2) {
3507
- 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);
3535
+ const prefix = extractPrefix(baseToken);
3536
+ if (UNKNOWN_PREFIX_CACHE.has(prefix)) {
3537
+ return void 0;
3538
+ }
3539
+ 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);
3540
+ if (!result && prefix) {
3541
+ if (UNKNOWN_PREFIX_CACHE.size >= MAX_UNKNOWN_CACHE_SIZE) {
3542
+ const toRemove = Math.floor(MAX_UNKNOWN_CACHE_SIZE / 2);
3543
+ const iterator = UNKNOWN_PREFIX_CACHE.values();
3544
+ for (let i = 0; i < toRemove; i += 1) {
3545
+ const value = iterator.next().value;
3546
+ if (value) UNKNOWN_PREFIX_CACHE.delete(value);
3547
+ }
3548
+ }
3549
+ UNKNOWN_PREFIX_CACHE.add(prefix);
3550
+ }
3551
+ return result;
3508
3552
  }
3509
3553
  function compileBaseToken(baseToken, theme2, pluginRegistry) {
3510
3554
  if (pluginRegistry) {
@@ -3748,6 +3792,30 @@ function compileRuntimeClassNameWithContext(className, context) {
3748
3792
  function compileClass(className, options = {}) {
3749
3793
  return compileRuntimeClassNameWithContext(className, resolveRuntimeContext(options));
3750
3794
  }
3795
+ function compileCriticalCss(classNames, options = {}) {
3796
+ const classList = typeof classNames === "string" ? classNames.split(/\s+/).filter(Boolean) : Array.isArray(classNames) ? classNames.flatMap(
3797
+ (str) => typeof str === "string" ? str.split(/\s+/).filter(Boolean) : []
3798
+ ) : [];
3799
+ const context = resolveRuntimeContext(options);
3800
+ const cssRules = /* @__PURE__ */ new Set();
3801
+ classList.forEach((className) => {
3802
+ const css = compileRuntimeClassNameWithContext(className, context);
3803
+ if (css) {
3804
+ cssRules.add(css);
3805
+ }
3806
+ });
3807
+ return Array.from(cssRules).join("\n");
3808
+ }
3809
+ function extractClassNames(html) {
3810
+ const classSet = /* @__PURE__ */ new Set();
3811
+ const classRegex = /class(?:Name)?=["']([^"']+)["']/g;
3812
+ let match;
3813
+ while ((match = classRegex.exec(html)) !== null) {
3814
+ const classes = match[1].split(/\s+/).filter(Boolean);
3815
+ classes.forEach((cls) => classSet.add(cls));
3816
+ }
3817
+ return Array.from(classSet);
3818
+ }
3751
3819
 
3752
3820
  // src/preflight.js
3753
3821
  var preflight = `
@@ -3895,7 +3963,16 @@ function createWindrunner(options = {}) {
3895
3963
  const cssRule = compileWithCache(className);
3896
3964
  if (!cssRule) {
3897
3965
  ensureCompatStyle();
3898
- if (onError) onError(className);
3966
+ if (onError) {
3967
+ const parsed = parseClass(className, context.screens, context.containers);
3968
+ const errorContext = {
3969
+ reason: parsed ? "unknown-utility" : "parse-error",
3970
+ baseToken: parsed ? parsed.baseToken : className,
3971
+ variants: parsed ? parsed.variants : void 0,
3972
+ details: parsed ? `Could not compile utility "${parsed.baseToken}"${parsed.variants.length ? ` with variants: ${parsed.variants.join(", ")}` : ""}` : `Failed to parse class name "${className}"`
3973
+ };
3974
+ onError(className, errorContext);
3975
+ }
3899
3976
  } else {
3900
3977
  insertRule(cssRule);
3901
3978
  if (onCompile) onCompile(className, cssRule);
@@ -3919,9 +3996,39 @@ function createWindrunner(options = {}) {
3919
3996
  };
3920
3997
  const scan = (root = document) => {
3921
3998
  if (typeof document !== "object" || !root) return;
3922
- if (root.nodeType === 1) processElementTree(root);
3999
+ const startTime = typeof performance !== "undefined" ? performance.now() : Date.now();
4000
+ const scannedElements = /* @__PURE__ */ new Set();
4001
+ const foundClasses = /* @__PURE__ */ new Set();
4002
+ const initialRuleCount = insertedRules.size;
4003
+ if (root.nodeType === 1) {
4004
+ processElementTree(root);
4005
+ if (root.classList) {
4006
+ scannedElements.add(root);
4007
+ root.classList.forEach((cls) => foundClasses.add(cls));
4008
+ }
4009
+ }
3923
4010
  const elements = root.querySelectorAll ? root.querySelectorAll("[class]") : [];
3924
- elements.forEach((element) => processElement(element));
4011
+ elements.forEach((element) => {
4012
+ processElement(element);
4013
+ scannedElements.add(element);
4014
+ if (element.classList) {
4015
+ element.classList.forEach((cls) => foundClasses.add(cls));
4016
+ }
4017
+ });
4018
+ if (typeof options.onScanComplete === "function") {
4019
+ const endTime = typeof performance !== "undefined" ? performance.now() : Date.now();
4020
+ const stats = {
4021
+ elementCount: scannedElements.size,
4022
+ classCount: foundClasses.size,
4023
+ ruleCount: insertedRules.size - initialRuleCount,
4024
+ duration: endTime - startTime
4025
+ };
4026
+ if (typeof requestAnimationFrame === "function") {
4027
+ requestAnimationFrame(() => options.onScanComplete(stats));
4028
+ } else {
4029
+ setTimeout(() => options.onScanComplete(stats), 0);
4030
+ }
4031
+ }
3925
4032
  };
3926
4033
  const flushQueue = () => {
3927
4034
  scheduled = false;
@@ -3954,12 +4061,18 @@ function createWindrunner(options = {}) {
3954
4061
  });
3955
4062
  scheduleFlush();
3956
4063
  });
3957
- observer.observe(root, {
3958
- childList: true,
3959
- subtree: true,
3960
- attributes: true,
3961
- attributeFilter: ["class"]
3962
- });
4064
+ const observerConfig = options.observerOptions || {};
4065
+ const finalConfig = {
4066
+ childList: observerConfig.childList !== false,
4067
+ // default: true
4068
+ subtree: observerConfig.subtree !== false,
4069
+ // default: true
4070
+ attributes: observerConfig.attributes !== false,
4071
+ // default: true
4072
+ attributeFilter: observerConfig.attributeFilter || ["class"]
4073
+ // default: ["class"]
4074
+ };
4075
+ observer.observe(root, finalConfig);
3963
4076
  };
3964
4077
  const disconnect = () => {
3965
4078
  pendingElements.clear();
@@ -4036,10 +4149,13 @@ function windrunner(options = {}) {
4036
4149
  }
4037
4150
  export {
4038
4151
  compileClass,
4152
+ compileCriticalCss,
4039
4153
  createWindrunner,
4040
4154
  defineResponsiveUtilities,
4041
4155
  defineUtilities,
4156
+ extractClassNames,
4042
4157
  parseClass,
4043
4158
  plugin,
4044
4159
  windrunner
4045
4160
  };
4161
+ //# sourceMappingURL=index.esm.js.map