rainbowindex 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -0
- package/README.md +27 -4
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -1
- package/dist/chunk-3HRMFZGE.mjs +19 -0
- package/dist/{chunk-AZXWJ625.mjs → chunk-53WD6U2X.mjs} +826 -610
- package/dist/{chunk-IE6N76PW.mjs → chunk-6GTG5SZJ.mjs} +5269 -4660
- package/dist/{chunk-AUWGHSTO.mjs → chunk-IYIUS7AE.mjs} +64 -126
- package/dist/{chunk-SOMDX7V6.mjs → chunk-KRZL4IDK.mjs} +337 -421
- package/dist/chunk-WYMCN5OC.mjs +244 -0
- package/dist/cli.mjs +280 -277
- package/dist/{index-CfDtWufj.d.ts → context-ruu2x_jR.d.ts} +15 -70
- package/dist/editor.d.ts +98 -28
- package/dist/editor.mjs +37 -8
- package/dist/{index-DK6APAGD.d.ts → index-Dp6i5TSv.d.ts} +16 -12
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/safelist-D9-Plqta.d.ts +109 -0
- package/dist/vite.mjs +80 -83
- package/package.json +2 -1
- package/dist/chunk-RHOQSN2B.mjs +0 -691
- package/dist/safelist-CH3_PywB.d.ts +0 -43
|
@@ -625,6 +625,90 @@ function devWarn(message) {
|
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
// src/merge/props.ts
|
|
628
|
+
var PADDING_MAP = Object.freeze({
|
|
629
|
+
p: ["padding"],
|
|
630
|
+
px: ["padding-inline"],
|
|
631
|
+
py: ["padding-block"],
|
|
632
|
+
pt: ["padding-block-start"],
|
|
633
|
+
pb: ["padding-block-end"],
|
|
634
|
+
pl: ["padding-inline-start"],
|
|
635
|
+
pr: ["padding-inline-end"],
|
|
636
|
+
ps: ["padding-inline-start"],
|
|
637
|
+
pe: ["padding-inline-end"],
|
|
638
|
+
pbs: ["padding-block-start"],
|
|
639
|
+
pbe: ["padding-block-end"]
|
|
640
|
+
});
|
|
641
|
+
var MARGIN_MAP = Object.freeze({
|
|
642
|
+
m: ["margin"],
|
|
643
|
+
mx: ["margin-inline"],
|
|
644
|
+
my: ["margin-block"],
|
|
645
|
+
mt: ["margin-block-start"],
|
|
646
|
+
mb: ["margin-block-end"],
|
|
647
|
+
ml: ["margin-inline-start"],
|
|
648
|
+
mr: ["margin-inline-end"],
|
|
649
|
+
ms: ["margin-inline-start"],
|
|
650
|
+
me: ["margin-inline-end"],
|
|
651
|
+
mbs: ["margin-block-start"],
|
|
652
|
+
mbe: ["margin-block-end"]
|
|
653
|
+
});
|
|
654
|
+
var GAP_MAP = Object.freeze({
|
|
655
|
+
gap: ["gap"],
|
|
656
|
+
"gap-x": ["column-gap"],
|
|
657
|
+
"gap-y": ["row-gap"]
|
|
658
|
+
});
|
|
659
|
+
var INSET_MAP = Object.freeze({
|
|
660
|
+
inset: ["inset"],
|
|
661
|
+
"inset-x": ["inset-inline"],
|
|
662
|
+
"inset-y": ["inset-block"],
|
|
663
|
+
top: ["inset-block-start"],
|
|
664
|
+
bottom: ["inset-block-end"],
|
|
665
|
+
left: ["inset-inline-start"],
|
|
666
|
+
right: ["inset-inline-end"],
|
|
667
|
+
start: ["inset-inline-start"],
|
|
668
|
+
end: ["inset-inline-end"],
|
|
669
|
+
"inset-s": ["inset-inline-start"],
|
|
670
|
+
"inset-e": ["inset-inline-end"],
|
|
671
|
+
"inset-bs": ["inset-block-start"],
|
|
672
|
+
"inset-be": ["inset-block-end"]
|
|
673
|
+
});
|
|
674
|
+
var SCROLL_MARGIN_MAP = Object.freeze({
|
|
675
|
+
"scroll-m": ["scroll-margin"],
|
|
676
|
+
"scroll-mx": ["scroll-margin-inline"],
|
|
677
|
+
"scroll-my": ["scroll-margin-block"],
|
|
678
|
+
"scroll-mt": ["scroll-margin-block-start"],
|
|
679
|
+
"scroll-mb": ["scroll-margin-block-end"],
|
|
680
|
+
"scroll-ml": ["scroll-margin-inline-start"],
|
|
681
|
+
"scroll-mr": ["scroll-margin-inline-end"],
|
|
682
|
+
"scroll-ms": ["scroll-margin-inline-start"],
|
|
683
|
+
"scroll-me": ["scroll-margin-inline-end"],
|
|
684
|
+
"scroll-mbs": ["scroll-margin-block-start"],
|
|
685
|
+
"scroll-mbe": ["scroll-margin-block-end"]
|
|
686
|
+
});
|
|
687
|
+
var SCROLL_PADDING_MAP = Object.freeze({
|
|
688
|
+
"scroll-p": ["scroll-padding"],
|
|
689
|
+
"scroll-px": ["scroll-padding-inline"],
|
|
690
|
+
"scroll-py": ["scroll-padding-block"],
|
|
691
|
+
"scroll-pt": ["scroll-padding-block-start"],
|
|
692
|
+
"scroll-pb": ["scroll-padding-block-end"],
|
|
693
|
+
"scroll-pl": ["scroll-padding-inline-start"],
|
|
694
|
+
"scroll-pr": ["scroll-padding-inline-end"],
|
|
695
|
+
"scroll-ps": ["scroll-padding-inline-start"],
|
|
696
|
+
"scroll-pe": ["scroll-padding-inline-end"],
|
|
697
|
+
"scroll-pbs": ["scroll-padding-block-start"],
|
|
698
|
+
"scroll-pbe": ["scroll-padding-block-end"]
|
|
699
|
+
});
|
|
700
|
+
var BORDER_DIR_PROPS = Object.freeze({
|
|
701
|
+
"border-t": ["border-block-start-width"],
|
|
702
|
+
"border-b": ["border-block-end-width"],
|
|
703
|
+
"border-l": ["border-inline-start-width"],
|
|
704
|
+
"border-r": ["border-inline-end-width"],
|
|
705
|
+
"border-s": ["border-inline-start-width"],
|
|
706
|
+
"border-e": ["border-inline-end-width"],
|
|
707
|
+
"border-bs": ["border-block-start-width"],
|
|
708
|
+
"border-be": ["border-block-end-width"],
|
|
709
|
+
"border-x": ["border-inline-width"],
|
|
710
|
+
"border-y": ["border-block-width"]
|
|
711
|
+
});
|
|
628
712
|
var BUILTIN_STATIC_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
629
713
|
// Grow/shrink
|
|
630
714
|
grow: ["flex-grow"],
|
|
@@ -680,17 +764,9 @@ var BUILTIN_STATIC_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
680
764
|
"scale-none": ["scale"],
|
|
681
765
|
// Perspective
|
|
682
766
|
"perspective-none": ["perspective"],
|
|
683
|
-
// Border width (static, directional — per-side logical props
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
"border-l": ["border-inline-start-width"],
|
|
687
|
-
"border-r": ["border-inline-end-width"],
|
|
688
|
-
"border-s": ["border-inline-start-width"],
|
|
689
|
-
"border-e": ["border-inline-end-width"],
|
|
690
|
-
"border-bs": ["border-block-start-width"],
|
|
691
|
-
"border-be": ["border-block-end-width"],
|
|
692
|
-
"border-x": ["border-inline-width"],
|
|
693
|
-
"border-y": ["border-block-width"],
|
|
767
|
+
// Border width (static, directional — per-side logical props; the bare
|
|
768
|
+
// static forms claim the same properties as the dynamic prefix entries)
|
|
769
|
+
...BORDER_DIR_PROPS,
|
|
694
770
|
// Border collapse
|
|
695
771
|
"border-collapse": ["border-collapse"],
|
|
696
772
|
"border-separate": ["border-collapse"],
|
|
@@ -1448,82 +1524,26 @@ addAll(
|
|
|
1448
1524
|
],
|
|
1449
1525
|
["mix-blend-mode"]
|
|
1450
1526
|
);
|
|
1527
|
+
var FLUID_EXCLUDED_PREFIXES = /* @__PURE__ */ new Set(["inset-s", "inset-e", "inset-bs", "inset-be"]);
|
|
1528
|
+
var FLUID_SPACING_PROPS = (() => {
|
|
1529
|
+
const rows = {};
|
|
1530
|
+
for (const map of [PADDING_MAP, MARGIN_MAP, GAP_MAP, INSET_MAP]) {
|
|
1531
|
+
for (const [prefix, props] of Object.entries(map)) {
|
|
1532
|
+
if (FLUID_EXCLUDED_PREFIXES.has(prefix)) continue;
|
|
1533
|
+
rows[`${prefix}-fluid`] = props;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
return Object.freeze(rows);
|
|
1537
|
+
})();
|
|
1451
1538
|
var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1452
|
-
// Spacing
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
pb: ["padding-block-end"],
|
|
1458
|
-
pl: ["padding-inline-start"],
|
|
1459
|
-
pr: ["padding-inline-end"],
|
|
1460
|
-
ps: ["padding-inline-start"],
|
|
1461
|
-
pe: ["padding-inline-end"],
|
|
1462
|
-
pbs: ["padding-block-start"],
|
|
1463
|
-
pbe: ["padding-block-end"],
|
|
1464
|
-
m: ["margin"],
|
|
1465
|
-
mx: ["margin-inline"],
|
|
1466
|
-
my: ["margin-block"],
|
|
1467
|
-
mt: ["margin-block-start"],
|
|
1468
|
-
mb: ["margin-block-end"],
|
|
1469
|
-
ml: ["margin-inline-start"],
|
|
1470
|
-
mr: ["margin-inline-end"],
|
|
1471
|
-
ms: ["margin-inline-start"],
|
|
1472
|
-
me: ["margin-inline-end"],
|
|
1473
|
-
mbs: ["margin-block-start"],
|
|
1474
|
-
mbe: ["margin-block-end"],
|
|
1475
|
-
gap: ["gap"],
|
|
1476
|
-
"gap-x": ["column-gap"],
|
|
1477
|
-
"gap-y": ["row-gap"],
|
|
1478
|
-
"p-fluid": ["padding"],
|
|
1479
|
-
"px-fluid": ["padding-inline"],
|
|
1480
|
-
"py-fluid": ["padding-block"],
|
|
1481
|
-
"pt-fluid": ["padding-block-start"],
|
|
1482
|
-
"pb-fluid": ["padding-block-end"],
|
|
1483
|
-
"pl-fluid": ["padding-inline-start"],
|
|
1484
|
-
"pr-fluid": ["padding-inline-end"],
|
|
1485
|
-
"ps-fluid": ["padding-inline-start"],
|
|
1486
|
-
"pe-fluid": ["padding-inline-end"],
|
|
1487
|
-
"pbs-fluid": ["padding-block-start"],
|
|
1488
|
-
"pbe-fluid": ["padding-block-end"],
|
|
1489
|
-
"m-fluid": ["margin"],
|
|
1490
|
-
"mx-fluid": ["margin-inline"],
|
|
1491
|
-
"my-fluid": ["margin-block"],
|
|
1492
|
-
"mt-fluid": ["margin-block-start"],
|
|
1493
|
-
"mb-fluid": ["margin-block-end"],
|
|
1494
|
-
"ml-fluid": ["margin-inline-start"],
|
|
1495
|
-
"mr-fluid": ["margin-inline-end"],
|
|
1496
|
-
"ms-fluid": ["margin-inline-start"],
|
|
1497
|
-
"me-fluid": ["margin-inline-end"],
|
|
1498
|
-
"mbs-fluid": ["margin-block-start"],
|
|
1499
|
-
"mbe-fluid": ["margin-block-end"],
|
|
1500
|
-
"gap-fluid": ["gap"],
|
|
1501
|
-
"gap-x-fluid": ["column-gap"],
|
|
1502
|
-
"gap-y-fluid": ["row-gap"],
|
|
1503
|
-
"inset-fluid": ["inset"],
|
|
1504
|
-
"inset-x-fluid": ["inset-inline"],
|
|
1505
|
-
"inset-y-fluid": ["inset-block"],
|
|
1506
|
-
"top-fluid": ["inset-block-start"],
|
|
1507
|
-
"bottom-fluid": ["inset-block-end"],
|
|
1508
|
-
"left-fluid": ["inset-inline-start"],
|
|
1509
|
-
"right-fluid": ["inset-inline-end"],
|
|
1510
|
-
"start-fluid": ["inset-inline-start"],
|
|
1511
|
-
"end-fluid": ["inset-inline-end"],
|
|
1539
|
+
// Spacing (family maps shared with utilities/spacing.ts — see header above)
|
|
1540
|
+
...PADDING_MAP,
|
|
1541
|
+
...MARGIN_MAP,
|
|
1542
|
+
...GAP_MAP,
|
|
1543
|
+
...FLUID_SPACING_PROPS,
|
|
1512
1544
|
"space-x": ["~space:margin-inline-start", "~space:margin-inline-end"],
|
|
1513
1545
|
"space-y": ["~space:margin-block-start", "~space:margin-block-end"],
|
|
1514
|
-
|
|
1515
|
-
"inset-x": ["inset-inline"],
|
|
1516
|
-
"inset-y": ["inset-block"],
|
|
1517
|
-
"inset-s": ["inset-inline-start"],
|
|
1518
|
-
"inset-e": ["inset-inline-end"],
|
|
1519
|
-
"inset-bs": ["inset-block-start"],
|
|
1520
|
-
"inset-be": ["inset-block-end"],
|
|
1521
|
-
top: ["inset-block-start"],
|
|
1522
|
-
bottom: ["inset-block-end"],
|
|
1523
|
-
left: ["inset-inline-start"],
|
|
1524
|
-
right: ["inset-inline-end"],
|
|
1525
|
-
start: ["inset-inline-start"],
|
|
1526
|
-
end: ["inset-inline-end"],
|
|
1546
|
+
...INSET_MAP,
|
|
1527
1547
|
// Sizing
|
|
1528
1548
|
w: ["width"],
|
|
1529
1549
|
h: ["height"],
|
|
@@ -1627,16 +1647,7 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1627
1647
|
// Borders — these also appear in BUILTIN_STATIC_PROPS for the bare static
|
|
1628
1648
|
// form (e.g. `border-t` → default 1px width). The prefix entries here handle
|
|
1629
1649
|
// the dynamic form (e.g. `border-t-2`, `border-t-red-500`) via resolvePropsWith().
|
|
1630
|
-
|
|
1631
|
-
"border-b": ["border-block-end-width"],
|
|
1632
|
-
"border-l": ["border-inline-start-width"],
|
|
1633
|
-
"border-r": ["border-inline-end-width"],
|
|
1634
|
-
"border-s": ["border-inline-start-width"],
|
|
1635
|
-
"border-e": ["border-inline-end-width"],
|
|
1636
|
-
"border-bs": ["border-block-start-width"],
|
|
1637
|
-
"border-be": ["border-block-end-width"],
|
|
1638
|
-
"border-x": ["border-inline-width"],
|
|
1639
|
-
"border-y": ["border-block-width"],
|
|
1650
|
+
...BORDER_DIR_PROPS,
|
|
1640
1651
|
// Table border-spacing — composable: shared border-spacing + per-axis slot var.
|
|
1641
1652
|
"border-spacing": ["border-spacing", "--ri-border-spacing-x", "--ri-border-spacing-y"],
|
|
1642
1653
|
"border-spacing-x": ["border-spacing", "--ri-border-spacing-x"],
|
|
@@ -1701,29 +1712,9 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1701
1712
|
"slide-out-to-bottom": ["--ri-exit-translate-y"],
|
|
1702
1713
|
"slide-out-to-left": ["--ri-exit-translate-x"],
|
|
1703
1714
|
"slide-out-to-right": ["--ri-exit-translate-x"],
|
|
1704
|
-
// Scroll margin/padding
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
"scroll-my": ["scroll-margin-block"],
|
|
1708
|
-
"scroll-mt": ["scroll-margin-block-start"],
|
|
1709
|
-
"scroll-mb": ["scroll-margin-block-end"],
|
|
1710
|
-
"scroll-ml": ["scroll-margin-inline-start"],
|
|
1711
|
-
"scroll-mr": ["scroll-margin-inline-end"],
|
|
1712
|
-
"scroll-ms": ["scroll-margin-inline-start"],
|
|
1713
|
-
"scroll-me": ["scroll-margin-inline-end"],
|
|
1714
|
-
"scroll-mbs": ["scroll-margin-block-start"],
|
|
1715
|
-
"scroll-mbe": ["scroll-margin-block-end"],
|
|
1716
|
-
"scroll-p": ["scroll-padding"],
|
|
1717
|
-
"scroll-px": ["scroll-padding-inline"],
|
|
1718
|
-
"scroll-py": ["scroll-padding-block"],
|
|
1719
|
-
"scroll-pt": ["scroll-padding-block-start"],
|
|
1720
|
-
"scroll-pb": ["scroll-padding-block-end"],
|
|
1721
|
-
"scroll-pl": ["scroll-padding-inline-start"],
|
|
1722
|
-
"scroll-pr": ["scroll-padding-inline-end"],
|
|
1723
|
-
"scroll-ps": ["scroll-padding-inline-start"],
|
|
1724
|
-
"scroll-pe": ["scroll-padding-inline-end"],
|
|
1725
|
-
"scroll-pbs": ["scroll-padding-block-start"],
|
|
1726
|
-
"scroll-pbe": ["scroll-padding-block-end"],
|
|
1715
|
+
// Scroll margin/padding (family maps shared with utilities/spacing.ts)
|
|
1716
|
+
...SCROLL_MARGIN_MAP,
|
|
1717
|
+
...SCROLL_PADDING_MAP,
|
|
1727
1718
|
// Backdrop filter — each function gets a unique CSS variable so they coexist
|
|
1728
1719
|
"backdrop-filter": ["backdrop-filter"],
|
|
1729
1720
|
"backdrop-blur": ["--ri-backdrop-blur", "backdrop-filter"],
|
|
@@ -1793,75 +1784,23 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1793
1784
|
"position-area": ["position-area"],
|
|
1794
1785
|
"anchor-scope": ["anchor-scope"]
|
|
1795
1786
|
});
|
|
1796
|
-
var
|
|
1797
|
-
"
|
|
1798
|
-
"border-block-width",
|
|
1799
|
-
"border-block-start-width",
|
|
1800
|
-
"border-block-end-width",
|
|
1801
|
-
"border-inline-start-width",
|
|
1802
|
-
"border-inline-end-width"
|
|
1803
|
-
]);
|
|
1804
|
-
var BORDER_STYLE_LONGHANDS = Object.freeze([
|
|
1805
|
-
"border-inline-style",
|
|
1806
|
-
"border-block-style",
|
|
1807
|
-
"border-block-start-style",
|
|
1808
|
-
"border-block-end-style",
|
|
1809
|
-
"border-inline-start-style",
|
|
1810
|
-
"border-inline-end-style"
|
|
1811
|
-
]);
|
|
1812
|
-
var BORDER_COLOR_LONGHANDS = Object.freeze([
|
|
1813
|
-
"border-inline-color",
|
|
1814
|
-
"border-block-color",
|
|
1815
|
-
"border-block-start-color",
|
|
1816
|
-
"border-block-end-color",
|
|
1817
|
-
"border-inline-start-color",
|
|
1818
|
-
"border-inline-end-color"
|
|
1819
|
-
]);
|
|
1820
|
-
var OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1821
|
-
padding: [
|
|
1822
|
-
"padding-inline",
|
|
1823
|
-
"padding-block",
|
|
1824
|
-
"padding-block-start",
|
|
1825
|
-
"padding-block-end",
|
|
1826
|
-
"padding-inline-start",
|
|
1827
|
-
"padding-inline-end"
|
|
1828
|
-
],
|
|
1787
|
+
var DIRECT_OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1788
|
+
padding: ["padding-inline", "padding-block"],
|
|
1829
1789
|
"padding-inline": ["padding-inline-start", "padding-inline-end"],
|
|
1830
1790
|
"padding-block": ["padding-block-start", "padding-block-end"],
|
|
1831
|
-
margin: [
|
|
1832
|
-
"margin-inline",
|
|
1833
|
-
"margin-block",
|
|
1834
|
-
"margin-block-start",
|
|
1835
|
-
"margin-block-end",
|
|
1836
|
-
"margin-inline-start",
|
|
1837
|
-
"margin-inline-end"
|
|
1838
|
-
],
|
|
1791
|
+
margin: ["margin-inline", "margin-block"],
|
|
1839
1792
|
"margin-inline": ["margin-inline-start", "margin-inline-end"],
|
|
1840
1793
|
"margin-block": ["margin-block-start", "margin-block-end"],
|
|
1841
1794
|
gap: ["column-gap", "row-gap"],
|
|
1842
|
-
inset: [
|
|
1843
|
-
"inset-inline",
|
|
1844
|
-
"inset-block",
|
|
1845
|
-
"inset-block-start",
|
|
1846
|
-
"inset-block-end",
|
|
1847
|
-
"inset-inline-start",
|
|
1848
|
-
"inset-inline-end"
|
|
1849
|
-
],
|
|
1795
|
+
inset: ["inset-inline", "inset-block"],
|
|
1850
1796
|
"inset-inline": ["inset-inline-start", "inset-inline-end"],
|
|
1851
1797
|
"inset-block": ["inset-block-start", "inset-block-end"],
|
|
1852
|
-
"border-width":
|
|
1798
|
+
"border-width": ["border-inline-width", "border-block-width"],
|
|
1853
1799
|
"border-inline-width": ["border-inline-start-width", "border-inline-end-width"],
|
|
1854
1800
|
"border-block-width": ["border-block-start-width", "border-block-end-width"],
|
|
1855
1801
|
// Full `border` shorthand ([border:…] arbitrary properties / custom
|
|
1856
|
-
// utilities) —
|
|
1857
|
-
border: [
|
|
1858
|
-
"border-width",
|
|
1859
|
-
"border-style",
|
|
1860
|
-
"border-color",
|
|
1861
|
-
...BORDER_WIDTH_LONGHANDS,
|
|
1862
|
-
...BORDER_STYLE_LONGHANDS,
|
|
1863
|
-
...BORDER_COLOR_LONGHANDS
|
|
1864
|
-
],
|
|
1802
|
+
// utilities) — the closure reaches every width/style/color leaf.
|
|
1803
|
+
border: ["border-width", "border-style", "border-color"],
|
|
1865
1804
|
"border-radius": [
|
|
1866
1805
|
"border-start-start-radius",
|
|
1867
1806
|
"border-start-end-radius",
|
|
@@ -1870,28 +1809,23 @@ var OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1870
1809
|
],
|
|
1871
1810
|
overflow: ["overflow-x", "overflow-y"],
|
|
1872
1811
|
"overscroll-behavior": ["overscroll-behavior-x", "overscroll-behavior-y"],
|
|
1873
|
-
"border-color":
|
|
1812
|
+
"border-color": ["border-inline-color", "border-block-color"],
|
|
1874
1813
|
"border-inline-color": ["border-inline-start-color", "border-inline-end-color"],
|
|
1875
1814
|
"border-block-color": ["border-block-start-color", "border-block-end-color"],
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
"
|
|
1880
|
-
"
|
|
1881
|
-
"
|
|
1882
|
-
"
|
|
1883
|
-
"
|
|
1815
|
+
// Unlike width/color, the style intermediates have no OVERRIDES entries of
|
|
1816
|
+
// their own (nothing claims them alone), so this entry stays flat.
|
|
1817
|
+
"border-style": [
|
|
1818
|
+
"border-inline-style",
|
|
1819
|
+
"border-block-style",
|
|
1820
|
+
"border-block-start-style",
|
|
1821
|
+
"border-block-end-style",
|
|
1822
|
+
"border-inline-start-style",
|
|
1823
|
+
"border-inline-end-style"
|
|
1884
1824
|
],
|
|
1825
|
+
"scroll-margin": ["scroll-margin-inline", "scroll-margin-block"],
|
|
1885
1826
|
"scroll-margin-inline": ["scroll-margin-inline-start", "scroll-margin-inline-end"],
|
|
1886
1827
|
"scroll-margin-block": ["scroll-margin-block-start", "scroll-margin-block-end"],
|
|
1887
|
-
"scroll-padding": [
|
|
1888
|
-
"scroll-padding-inline",
|
|
1889
|
-
"scroll-padding-block",
|
|
1890
|
-
"scroll-padding-block-start",
|
|
1891
|
-
"scroll-padding-block-end",
|
|
1892
|
-
"scroll-padding-inline-start",
|
|
1893
|
-
"scroll-padding-inline-end"
|
|
1894
|
-
],
|
|
1828
|
+
"scroll-padding": ["scroll-padding-inline", "scroll-padding-block"],
|
|
1895
1829
|
"scroll-padding-inline": ["scroll-padding-inline-start", "scroll-padding-inline-end"],
|
|
1896
1830
|
"scroll-padding-block": ["scroll-padding-block-start", "scroll-padding-block-end"],
|
|
1897
1831
|
flex: ["flex-grow", "flex-shrink", "flex-basis"],
|
|
@@ -1957,6 +1891,22 @@ var OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1957
1891
|
"--ri-backdrop-hue-rotate"
|
|
1958
1892
|
]
|
|
1959
1893
|
});
|
|
1894
|
+
var OVERRIDES = (() => {
|
|
1895
|
+
const closed = /* @__PURE__ */ Object.create(null);
|
|
1896
|
+
for (const key of Object.keys(DIRECT_OVERRIDES)) {
|
|
1897
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1898
|
+
const stack = [...DIRECT_OVERRIDES[key]];
|
|
1899
|
+
while (stack.length > 0) {
|
|
1900
|
+
const prop = stack.pop();
|
|
1901
|
+
if (prop === void 0 || seen.has(prop)) continue;
|
|
1902
|
+
seen.add(prop);
|
|
1903
|
+
const next = DIRECT_OVERRIDES[prop];
|
|
1904
|
+
if (next !== void 0) stack.push(...next);
|
|
1905
|
+
}
|
|
1906
|
+
closed[key] = Object.freeze([...seen]);
|
|
1907
|
+
}
|
|
1908
|
+
return closed;
|
|
1909
|
+
})();
|
|
1960
1910
|
Object.freeze(BUILTIN_STATIC_PROPS);
|
|
1961
1911
|
Object.freeze(PREFIX_PROPS);
|
|
1962
1912
|
Object.freeze(OVERRIDES);
|
|
@@ -2059,16 +2009,6 @@ function buildFirstSegmentMap(prefixes) {
|
|
|
2059
2009
|
var PREFIX_FIRST_SEGMENT_MAP = buildFirstSegmentMap(SORTED_PREFIXES);
|
|
2060
2010
|
|
|
2061
2011
|
// src/brackets.ts
|
|
2062
|
-
function evictLRU(cache, maxSize) {
|
|
2063
|
-
if (cache.size < maxSize) return;
|
|
2064
|
-
const evictCount = maxSize >> 2;
|
|
2065
|
-
let count = 0;
|
|
2066
|
-
for (const key of cache.keys()) {
|
|
2067
|
-
if (count >= evictCount) break;
|
|
2068
|
-
cache.delete(key);
|
|
2069
|
-
count++;
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
2012
|
function scanBracketAware(input, onChar, options) {
|
|
2073
2013
|
const reverse = options?.reverse ?? false;
|
|
2074
2014
|
let depth = 0;
|
|
@@ -2101,7 +2041,7 @@ function scanBracketAware(input, onChar, options) {
|
|
|
2101
2041
|
}
|
|
2102
2042
|
}
|
|
2103
2043
|
|
|
2104
|
-
// src/merge/
|
|
2044
|
+
// src/merge/resolve.ts
|
|
2105
2045
|
var DEFAULT_TEXT_SIZES = [
|
|
2106
2046
|
"xs",
|
|
2107
2047
|
"sm",
|
|
@@ -2152,9 +2092,7 @@ for (const [prefix, sides, end] of MASK_STOP_FAMILIES) {
|
|
|
2152
2092
|
for (const side of sides) positionProps.push(`--ri-mask-${side}-${end}-position`);
|
|
2153
2093
|
Object.freeze(positionProps);
|
|
2154
2094
|
const colorProps = PREFIX_PROPS[prefix];
|
|
2155
|
-
MASK_STOP_DUAL_MODES[prefix] =
|
|
2156
|
-
resolve: (value) => isMaskStopPositionValue(value) ? positionProps : colorProps
|
|
2157
|
-
};
|
|
2095
|
+
MASK_STOP_DUAL_MODES[prefix] = (value) => isMaskStopPositionValue(value) ? positionProps : colorProps;
|
|
2158
2096
|
}
|
|
2159
2097
|
var TEXT_SIZE_PROPS = Object.freeze(["font-size", "line-height"]);
|
|
2160
2098
|
var FONT_FAMILY_PROPS = Object.freeze([
|
|
@@ -2163,6 +2101,7 @@ var FONT_FAMILY_PROPS = Object.freeze([
|
|
|
2163
2101
|
"font-variation-settings"
|
|
2164
2102
|
]);
|
|
2165
2103
|
var MASK_RADIAL_SIZE_PROPS = Object.freeze(["--ri-mask-radial-size"]);
|
|
2104
|
+
var STROKE_WIDTH_PROPS = Object.freeze(["stroke-width"]);
|
|
2166
2105
|
var BG_IMAGE_PROPS = Object.freeze(["background-image"]);
|
|
2167
2106
|
var BORDER_COLOR_PROPS = Object.freeze(["border-color"]);
|
|
2168
2107
|
var OUTLINE_COLOR_PROPS = Object.freeze(["outline-color"]);
|
|
@@ -2170,78 +2109,64 @@ var OUTLINE_STYLE_PROPS = Object.freeze(["outline-style"]);
|
|
|
2170
2109
|
var DECORATION_COLOR_PROPS = Object.freeze(["text-decoration-color"]);
|
|
2171
2110
|
var RE_SIGNED_INT = /^-?\d+$/;
|
|
2172
2111
|
var RE_UNSIGNED_INT = /^\d+$/;
|
|
2173
|
-
var
|
|
2112
|
+
var RE_DECIMAL = /^\d+(?:[._]\d+)?$/;
|
|
2174
2113
|
function colorOrDefault(prefix, colorProps) {
|
|
2175
2114
|
const defaultProps = PREFIX_PROPS[prefix];
|
|
2176
|
-
return
|
|
2177
|
-
resolve: (value, _textSizes2, _fontFamilies2, colorNames) => isColorValue(value, void 0, colorNames) ? colorProps : defaultProps
|
|
2178
|
-
};
|
|
2115
|
+
return (value, _textSizes2, _fontFamilies2, colorNames) => isColorValue(value, void 0, colorNames) ? colorProps : defaultProps;
|
|
2179
2116
|
}
|
|
2180
2117
|
var DUAL_MODE_PREFIXES = {
|
|
2181
2118
|
...MASK_STOP_DUAL_MODES,
|
|
2182
2119
|
// mask-radial-[<size>] sets the size var; mask-radial-[<value>] is a full image.
|
|
2183
|
-
"mask-radial":
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
const base = stripTextModifier(value);
|
|
2189
|
-
if (textSizes.has(base) || base.startsWith("[") && !isColorValue(base, textSizes, colorNames)) {
|
|
2190
|
-
return TEXT_SIZE_PROPS;
|
|
2191
|
-
}
|
|
2192
|
-
return PREFIX_PROPS.text;
|
|
2120
|
+
"mask-radial": (value) => isMaskRadialSizeValue(value) ? MASK_RADIAL_SIZE_PROPS : PREFIX_PROPS["mask-radial"],
|
|
2121
|
+
text: (value, textSizes, _fontFamilies2, colorNames) => {
|
|
2122
|
+
const base = stripTextModifier(value);
|
|
2123
|
+
if (textSizes.has(base) || base.startsWith("[") && !isColorValue(base, textSizes, colorNames)) {
|
|
2124
|
+
return TEXT_SIZE_PROPS;
|
|
2193
2125
|
}
|
|
2126
|
+
return PREFIX_PROPS.text;
|
|
2194
2127
|
},
|
|
2195
|
-
font: {
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
return PREFIX_PROPS.font;
|
|
2199
|
-
}
|
|
2128
|
+
font: (value, _textSizes2, fontFamilies) => {
|
|
2129
|
+
if (fontFamilies.has(value) || isFontFamilyValue(value)) return FONT_FAMILY_PROPS;
|
|
2130
|
+
return PREFIX_PROPS.font;
|
|
2200
2131
|
},
|
|
2201
|
-
border:
|
|
2202
|
-
|
|
2132
|
+
border: (value, _textSizes2, _fontFamilies2, colorNames) => isColorValue(value, void 0, colorNames) ? BORDER_COLOR_PROPS : PREFIX_PROPS.border,
|
|
2133
|
+
outline: (value, _textSizes2, _fontFamilies2, colorNames) => {
|
|
2134
|
+
if (isColorValue(value, void 0, colorNames)) return OUTLINE_COLOR_PROPS;
|
|
2135
|
+
if (RE_SIGNED_INT.test(value) || value.startsWith("[") && !isColorValue(value))
|
|
2136
|
+
return PREFIX_PROPS.outline;
|
|
2137
|
+
return OUTLINE_STYLE_PROPS;
|
|
2203
2138
|
},
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
return
|
|
2210
|
-
|
|
2139
|
+
// Width-vs-color, mirroring svg.ts's generate-side dispatch: decimals
|
|
2140
|
+
// (stroke-2, stroke-1.5) and non-color arbitraries (stroke-[3px]) emit
|
|
2141
|
+
// stroke-width; every color-shaped value emits the `stroke` paint property.
|
|
2142
|
+
stroke: (value, _textSizes2, _fontFamilies2, colorNames) => {
|
|
2143
|
+
if (RE_DECIMAL.test(value) || value.startsWith("[") && !isColorValue(value, void 0, colorNames))
|
|
2144
|
+
return STROKE_WIDTH_PROPS;
|
|
2145
|
+
return PREFIX_PROPS.stroke;
|
|
2211
2146
|
},
|
|
2212
|
-
decoration: {
|
|
2213
|
-
|
|
2214
|
-
if (value.startsWith("(length:") || value.startsWith("[length:"))
|
|
2215
|
-
return PREFIX_PROPS.decoration;
|
|
2216
|
-
if (value.startsWith("(")) return DECORATION_COLOR_PROPS;
|
|
2217
|
-
if (RE_UNSIGNED_INT.test(value) || value.startsWith("[") && !isColorValue(value))
|
|
2218
|
-
return PREFIX_PROPS.decoration;
|
|
2219
|
-
if (isColorValue(value, void 0, colorNames)) return DECORATION_COLOR_PROPS;
|
|
2147
|
+
decoration: (value, _textSizes2, _fontFamilies2, colorNames) => {
|
|
2148
|
+
if (value.startsWith("(length:") || value.startsWith("[length:"))
|
|
2220
2149
|
return PREFIX_PROPS.decoration;
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
// so a color-first check would misclassify it) and background-color
|
|
2227
|
-
// for everything else — never the full `background` shorthand.
|
|
2228
|
-
resolve: (value) => isImageValue(value) ? BG_IMAGE_PROPS : PREFIX_PROPS.bg
|
|
2150
|
+
if (value.startsWith("(")) return DECORATION_COLOR_PROPS;
|
|
2151
|
+
if (RE_UNSIGNED_INT.test(value) || value.startsWith("[") && !isColorValue(value))
|
|
2152
|
+
return PREFIX_PROPS.decoration;
|
|
2153
|
+
if (isColorValue(value, void 0, colorNames)) return DECORATION_COLOR_PROPS;
|
|
2154
|
+
return PREFIX_PROPS.decoration;
|
|
2229
2155
|
},
|
|
2156
|
+
// Image-first to mirror colorGenerator's dispatch: the engine emits
|
|
2157
|
+
// background-image for image-shaped values (bg-[url(#x)] contains "#",
|
|
2158
|
+
// so a color-first check would misclassify it) and background-color
|
|
2159
|
+
// for everything else — never the full `background` shorthand.
|
|
2160
|
+
bg: (value) => isImageValue(value) ? BG_IMAGE_PROPS : PREFIX_PROPS.bg,
|
|
2230
2161
|
shadow: colorOrDefault("shadow", Object.freeze(["--ri-shadow-color"])),
|
|
2231
2162
|
"inset-shadow": colorOrDefault("inset-shadow", Object.freeze(["--ri-inset-shadow-color"])),
|
|
2232
2163
|
ring: colorOrDefault("ring", Object.freeze(["--ri-ring-color"])),
|
|
2233
2164
|
"inset-ring": colorOrDefault("inset-ring", Object.freeze(["--ri-inset-ring-color"])),
|
|
2234
2165
|
"text-shadow": colorOrDefault("text-shadow", Object.freeze(["--ri-text-shadow-color"])),
|
|
2235
2166
|
"drop-shadow": colorOrDefault("drop-shadow", Object.freeze(["--ri-drop-shadow-color"])),
|
|
2236
|
-
from:
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
via: {
|
|
2240
|
-
resolve: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["via-position"] : PREFIX_PROPS.via
|
|
2241
|
-
},
|
|
2242
|
-
to: {
|
|
2243
|
-
resolve: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["to-position"] : PREFIX_PROPS.to
|
|
2244
|
-
}
|
|
2167
|
+
from: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["from-position"] : PREFIX_PROPS.from,
|
|
2168
|
+
via: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["via-position"] : PREFIX_PROPS.via,
|
|
2169
|
+
to: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["to-position"] : PREFIX_PROPS.to
|
|
2245
2170
|
};
|
|
2246
2171
|
var DIRECTIONAL_BORDER_COLOR_PROPS = new Map(
|
|
2247
2172
|
[
|
|
@@ -2257,14 +2182,6 @@ var DIRECTIONAL_BORDER_COLOR_PROPS = new Map(
|
|
|
2257
2182
|
"border-y"
|
|
2258
2183
|
].map((prefix) => [prefix, Object.freeze([PREFIX_PROPS[prefix][0].replace("width", "color")])])
|
|
2259
2184
|
);
|
|
2260
|
-
var _customStaticProps = {};
|
|
2261
|
-
var _textSizes = new Set(DEFAULT_TEXT_SIZES);
|
|
2262
|
-
var _fontFamilies = new Set(DEFAULT_FONT_FAMILIES);
|
|
2263
|
-
var _colorNames = /* @__PURE__ */ new Set();
|
|
2264
|
-
var _latestSnapshot = null;
|
|
2265
|
-
var RI_CACHE_MAX = 500;
|
|
2266
|
-
var RI_CACHE_KEY_MAX_LEN = 2048;
|
|
2267
|
-
var _riCache = /* @__PURE__ */ new Map();
|
|
2268
2185
|
function resolvePropsWith(utility, customStaticProps, textSizes, fontFamilies, colorNames) {
|
|
2269
2186
|
if (utility.charCodeAt(0) === 91) {
|
|
2270
2187
|
const colonIdx = utility.indexOf(":");
|
|
@@ -2292,7 +2209,7 @@ function resolvePropsWith(utility, customStaticProps, textSizes, fontFamilies, c
|
|
|
2292
2209
|
const value = exact ? "" : name.slice(prefix.length + 1);
|
|
2293
2210
|
const dualMode = DUAL_MODE_PREFIXES[prefix];
|
|
2294
2211
|
if (dualMode) {
|
|
2295
|
-
return dualMode
|
|
2212
|
+
return dualMode(value, textSizes, fontFamilies, colorNames);
|
|
2296
2213
|
}
|
|
2297
2214
|
const directionalColor = DIRECTIONAL_BORDER_COLOR_PROPS.get(prefix);
|
|
2298
2215
|
if (directionalColor && isColorValue(value, void 0, colorNames)) {
|
|
@@ -2303,9 +2220,91 @@ function resolvePropsWith(utility, customStaticProps, textSizes, fontFamilies, c
|
|
|
2303
2220
|
}
|
|
2304
2221
|
return null;
|
|
2305
2222
|
}
|
|
2223
|
+
|
|
2224
|
+
// src/merge/context.ts
|
|
2225
|
+
var _customStaticProps = {};
|
|
2226
|
+
var _textSizes = new Set(DEFAULT_TEXT_SIZES);
|
|
2227
|
+
var _fontFamilies = new Set(DEFAULT_FONT_FAMILIES);
|
|
2228
|
+
var _colorNames = /* @__PURE__ */ new Set();
|
|
2229
|
+
var _latestSnapshot = null;
|
|
2230
|
+
function hasFinalizedSnapshot() {
|
|
2231
|
+
return _latestSnapshot !== null;
|
|
2232
|
+
}
|
|
2233
|
+
var defaultRiCache = /* @__PURE__ */ new Map();
|
|
2306
2234
|
function resolveProps(utility) {
|
|
2307
2235
|
return resolvePropsWith(utility, _customStaticProps, _textSizes, _fontFamilies, _colorNames);
|
|
2308
2236
|
}
|
|
2237
|
+
function resolverFor(snapshot) {
|
|
2238
|
+
const snap = snapshot ?? _latestSnapshot ?? {
|
|
2239
|
+
customStaticProps: _customStaticProps,
|
|
2240
|
+
textSizes: _textSizes,
|
|
2241
|
+
fontFamilies: _fontFamilies,
|
|
2242
|
+
colorNames: _colorNames
|
|
2243
|
+
};
|
|
2244
|
+
return (utility) => resolvePropsWith(
|
|
2245
|
+
utility,
|
|
2246
|
+
snap.customStaticProps,
|
|
2247
|
+
snap.textSizes,
|
|
2248
|
+
snap.fontFamilies,
|
|
2249
|
+
snap.colorNames
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
function createCompilationContext() {
|
|
2253
|
+
return {
|
|
2254
|
+
customStaticProps: {},
|
|
2255
|
+
textSizes: new Set(DEFAULT_TEXT_SIZES),
|
|
2256
|
+
fontFamilies: new Set(DEFAULT_FONT_FAMILIES),
|
|
2257
|
+
colorNames: /* @__PURE__ */ new Set()
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
function registerCustomUtility(ctx, name, properties) {
|
|
2261
|
+
if (IS_DEV) {
|
|
2262
|
+
if (!name) {
|
|
2263
|
+
devWarn("[RI-1301] registerCustomUtility() called with empty name \u2014 skipping.");
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (properties.length === 0) {
|
|
2267
|
+
devWarn(
|
|
2268
|
+
`[RI-1302] registerCustomUtility("${name}") called with no CSS properties \u2014 the utility won't participate in conflict resolution.`
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
ctx.customStaticProps[name] = properties;
|
|
2273
|
+
}
|
|
2274
|
+
function registerCustomTextSizes(ctx, sizes) {
|
|
2275
|
+
for (const s of sizes) ctx.textSizes.add(s);
|
|
2276
|
+
}
|
|
2277
|
+
function registerCustomFontFamilies(ctx, families) {
|
|
2278
|
+
for (const f of families) ctx.fontFamilies.add(f);
|
|
2279
|
+
}
|
|
2280
|
+
function registerColorNames(ctx, names) {
|
|
2281
|
+
for (const n of names) ctx.colorNames.add(n);
|
|
2282
|
+
}
|
|
2283
|
+
function snapshotCompilationContext(ctx) {
|
|
2284
|
+
return {
|
|
2285
|
+
customStaticProps: Object.fromEntries(
|
|
2286
|
+
Object.entries(ctx.customStaticProps).map(([k, v]) => [k, [...v]])
|
|
2287
|
+
),
|
|
2288
|
+
textSizes: new Set(ctx.textSizes),
|
|
2289
|
+
fontFamilies: new Set(ctx.fontFamilies),
|
|
2290
|
+
colorNames: new Set(ctx.colorNames)
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
function finalizeCompilationContext(ctx) {
|
|
2294
|
+
const snapshot = snapshotCompilationContext(ctx);
|
|
2295
|
+
_customStaticProps = snapshot.customStaticProps;
|
|
2296
|
+
_textSizes = snapshot.textSizes;
|
|
2297
|
+
_fontFamilies = snapshot.fontFamilies;
|
|
2298
|
+
_colorNames = snapshot.colorNames;
|
|
2299
|
+
defaultRiCache.clear();
|
|
2300
|
+
_latestSnapshot = snapshot;
|
|
2301
|
+
return snapshot;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
// src/merge/index.ts
|
|
2305
|
+
var RI_CACHE_MAX = 500;
|
|
2306
|
+
var RI_CACHE_KEY_MAX_LEN = 2048;
|
|
2307
|
+
var WS_SPLIT_RE = /\s+/;
|
|
2309
2308
|
function findVariantSplit(cls) {
|
|
2310
2309
|
if (cls.indexOf(":") === -1) return -1;
|
|
2311
2310
|
let lastColon = -1;
|
|
@@ -2387,6 +2386,16 @@ function mergeUncached(classes, resolve, trace) {
|
|
|
2387
2386
|
result.reverse();
|
|
2388
2387
|
return result.join(" ");
|
|
2389
2388
|
}
|
|
2389
|
+
function evictLRU(cache, maxSize) {
|
|
2390
|
+
if (cache.size < maxSize) return;
|
|
2391
|
+
const evictCount = maxSize >> 2;
|
|
2392
|
+
let count = 0;
|
|
2393
|
+
for (const key of cache.keys()) {
|
|
2394
|
+
if (count >= evictCount) break;
|
|
2395
|
+
cache.delete(key);
|
|
2396
|
+
count++;
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2390
2399
|
function lruGet(cache, key) {
|
|
2391
2400
|
const cached = cache.get(key);
|
|
2392
2401
|
if (cached !== void 0) {
|
|
@@ -2411,16 +2420,19 @@ function mergeClasses(classes, resolve, cache) {
|
|
|
2411
2420
|
return output;
|
|
2412
2421
|
}
|
|
2413
2422
|
function mergeFrom(inputs, resolve, cache) {
|
|
2414
|
-
let
|
|
2423
|
+
let fastPath = true;
|
|
2424
|
+
let rawKey = "";
|
|
2415
2425
|
for (let i = 0; i < inputs.length; i++) {
|
|
2416
2426
|
const input = inputs[i];
|
|
2417
|
-
if (typeof input
|
|
2418
|
-
|
|
2427
|
+
if (typeof input === "string") {
|
|
2428
|
+
if (input !== "") rawKey = rawKey === "" ? input : `${rawKey}\0${input}`;
|
|
2429
|
+
} else if (input) {
|
|
2430
|
+
fastPath = false;
|
|
2419
2431
|
break;
|
|
2420
2432
|
}
|
|
2421
2433
|
}
|
|
2422
|
-
if (
|
|
2423
|
-
|
|
2434
|
+
if (fastPath) {
|
|
2435
|
+
if (rawKey === "") return "";
|
|
2424
2436
|
if (rawKey.length <= RI_CACHE_KEY_MAX_LEN) {
|
|
2425
2437
|
const cached = lruGet(cache, rawKey);
|
|
2426
2438
|
if (cached !== void 0) return cached;
|
|
@@ -2442,80 +2454,51 @@ function detectSSR() {
|
|
|
2442
2454
|
return _isSSR;
|
|
2443
2455
|
}
|
|
2444
2456
|
var WARNING_THROTTLE_MS = 6e4;
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
var _totalClassesWarningLastMs = Number.NEGATIVE_INFINITY;
|
|
2449
|
-
var _nonStringWarningLastMs = Number.NEGATIVE_INFINITY;
|
|
2450
|
-
function ri(...inputs) {
|
|
2451
|
-
if (detectSSR()) {
|
|
2457
|
+
function throttledWarn(message, emit = console.warn) {
|
|
2458
|
+
let last = Number.NEGATIVE_INFINITY;
|
|
2459
|
+
return (...args) => {
|
|
2452
2460
|
const now = Date.now();
|
|
2453
|
-
if (now -
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
console.warn(
|
|
2457
|
-
"[RI-2004] ri() called in an SSR environment before any compilation has finalized. The default ri() export reads module-level state that has not been initialized. Custom utilities, text sizes, and font families will not be recognized. Use createRi(snapshot) for concurrent-safe class merging. See: https://rainbowindex.dev/docs/ssr"
|
|
2458
|
-
);
|
|
2459
|
-
} else {
|
|
2460
|
-
console.warn(
|
|
2461
|
-
"[RI-2004] The default ri() export uses module-level state and is not safe for concurrent SSR requests. Use createRi(snapshot) for isolation. See: https://rainbowindex.dev/docs/ssr\nThis warning repeats every 60 s until resolved. In production SSR, switch to createRi(snapshot) to prevent silent data corruption between concurrent requests."
|
|
2462
|
-
);
|
|
2463
|
-
}
|
|
2461
|
+
if (now - last >= WARNING_THROTTLE_MS) {
|
|
2462
|
+
last = now;
|
|
2463
|
+
emit(message(...args));
|
|
2464
2464
|
}
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
var warnSSRUsage = throttledWarn(
|
|
2468
|
+
() => !hasFinalizedSnapshot() ? (
|
|
2469
|
+
// No compilation has ever finalized — module-level state is uninitialized
|
|
2470
|
+
// defaults. In SSR this almost certainly means ri() is being called without
|
|
2471
|
+
// a preceding compile pass, which will produce incorrect merge results
|
|
2472
|
+
// for custom utilities, text sizes, and font families.
|
|
2473
|
+
"[RI-2004] ri() called in an SSR environment before any compilation has finalized. The default ri() export reads module-level state that has not been initialized. Custom utilities, text sizes, and font families will not be recognized. Use createRi(snapshot) for concurrent-safe class merging. See: https://rainbowindex.dev/docs/ssr"
|
|
2474
|
+
) : "[RI-2004] The default ri() export uses module-level state and is not safe for concurrent SSR requests. Use createRi(snapshot) for isolation. See: https://rainbowindex.dev/docs/ssr\nThis warning repeats every 60 s until resolved. In production SSR, switch to createRi(snapshot) to prevent silent data corruption between concurrent requests."
|
|
2475
|
+
);
|
|
2476
|
+
var warnFlattenDepth = throttledWarn(
|
|
2477
|
+
() => `[RI-2011] ri() input nesting exceeds maximum depth of ${MAX_FLATTEN_DEPTH}. Deeply nested inputs are silently dropped. Flatten your class arrays to avoid this limit.`
|
|
2478
|
+
);
|
|
2479
|
+
var warnTotalClasses = throttledWarn(
|
|
2480
|
+
() => `[RI-2012] ri() input exceeds ${MAX_TOTAL_CLASSES} class limit. Excess classes are dropped to prevent memory exhaustion.`
|
|
2481
|
+
);
|
|
2482
|
+
var warnClassLength = throttledWarn(
|
|
2483
|
+
(cls) => `[RI-2006] Class name exceeds ${MAX_CLASS_NAME_LENGTH} character limit and was dropped: "${cls.slice(0, 40)}\u2026". This is a safety guard against adversarial input in SSR. If this is intentional, shorten the class name.`
|
|
2484
|
+
);
|
|
2485
|
+
var warnNonStringInput = throttledWarn(
|
|
2486
|
+
(input) => `ri() inputs must be strings, arrays, or falsy \u2014 got ${typeof input}; value skipped. Object syntax ({ class: condition }) is not supported; use \`condition && "class"\` instead.`,
|
|
2487
|
+
devWarn
|
|
2488
|
+
);
|
|
2489
|
+
function ri(...inputs) {
|
|
2490
|
+
if (detectSSR()) {
|
|
2491
|
+
warnSSRUsage();
|
|
2465
2492
|
}
|
|
2466
|
-
return mergeFrom(inputs, resolveProps,
|
|
2493
|
+
return mergeFrom(inputs, resolveProps, defaultRiCache);
|
|
2467
2494
|
}
|
|
2468
2495
|
function createRi(snapshot) {
|
|
2469
|
-
const
|
|
2470
|
-
customStaticProps: _customStaticProps,
|
|
2471
|
-
textSizes: _textSizes,
|
|
2472
|
-
fontFamilies: _fontFamilies,
|
|
2473
|
-
colorNames: _colorNames
|
|
2474
|
-
};
|
|
2496
|
+
const resolve = resolverFor(snapshot);
|
|
2475
2497
|
const cache = /* @__PURE__ */ new Map();
|
|
2476
|
-
const resolve = (utility) => resolvePropsWith(
|
|
2477
|
-
utility,
|
|
2478
|
-
snap.customStaticProps,
|
|
2479
|
-
snap.textSizes,
|
|
2480
|
-
snap.fontFamilies,
|
|
2481
|
-
snap.colorNames
|
|
2482
|
-
);
|
|
2483
2498
|
return function boundRi(...inputs) {
|
|
2484
2499
|
return mergeFrom(inputs, resolve, cache);
|
|
2485
2500
|
};
|
|
2486
2501
|
}
|
|
2487
|
-
function analyzeMerge(classes, snapshot) {
|
|
2488
|
-
const snap = snapshot ?? _latestSnapshot ?? {
|
|
2489
|
-
customStaticProps: _customStaticProps,
|
|
2490
|
-
textSizes: _textSizes,
|
|
2491
|
-
fontFamilies: _fontFamilies,
|
|
2492
|
-
colorNames: _colorNames
|
|
2493
|
-
};
|
|
2494
|
-
const resolve = (utility) => resolvePropsWith(
|
|
2495
|
-
utility,
|
|
2496
|
-
snap.customStaticProps,
|
|
2497
|
-
snap.textSizes,
|
|
2498
|
-
snap.fontFamilies,
|
|
2499
|
-
snap.colorNames
|
|
2500
|
-
);
|
|
2501
|
-
const trace = { claimers: /* @__PURE__ */ new Map(), dropped: [] };
|
|
2502
|
-
const output = mergeUncached(classes, resolve, trace);
|
|
2503
|
-
trace.dropped.sort((a, b) => a.index - b.index);
|
|
2504
|
-
const droppedIndexes = new Set(trace.dropped.map((d) => d.index));
|
|
2505
|
-
const kept = [];
|
|
2506
|
-
for (let i = 0; i < classes.length; i++) {
|
|
2507
|
-
if (!droppedIndexes.has(i)) kept.push(i);
|
|
2508
|
-
}
|
|
2509
|
-
return {
|
|
2510
|
-
output,
|
|
2511
|
-
kept,
|
|
2512
|
-
dropped: trace.dropped.map((d) => ({
|
|
2513
|
-
index: d.index,
|
|
2514
|
-
className: classes[d.index],
|
|
2515
|
-
overriddenBy: d.overriddenBy
|
|
2516
|
-
}))
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
2502
|
var MAX_FLATTEN_DEPTH = 10;
|
|
2520
2503
|
var MAX_CLASS_NAME_LENGTH = 500;
|
|
2521
2504
|
var MAX_TOTAL_CLASSES = 1e4;
|
|
@@ -2533,50 +2516,26 @@ function flattenInputs(inputs) {
|
|
|
2533
2516
|
if (!input) continue;
|
|
2534
2517
|
if (Array.isArray(input)) {
|
|
2535
2518
|
if (depth + 1 > MAX_FLATTEN_DEPTH) {
|
|
2536
|
-
|
|
2537
|
-
if (now - _depthWarningLastMs >= WARNING_THROTTLE_MS) {
|
|
2538
|
-
_depthWarningLastMs = now;
|
|
2539
|
-
console.warn(
|
|
2540
|
-
`[RI-2011] ri() input nesting exceeds maximum depth of ${MAX_FLATTEN_DEPTH}. Deeply nested inputs are silently dropped. Flatten your class arrays to avoid this limit.`
|
|
2541
|
-
);
|
|
2542
|
-
}
|
|
2519
|
+
warnFlattenDepth();
|
|
2543
2520
|
continue;
|
|
2544
2521
|
}
|
|
2545
2522
|
stack.push([input, 0, depth + 1]);
|
|
2546
2523
|
} else if (typeof input !== "string") {
|
|
2547
2524
|
if (IS_DEV) {
|
|
2548
|
-
|
|
2549
|
-
if (now - _nonStringWarningLastMs >= WARNING_THROTTLE_MS) {
|
|
2550
|
-
_nonStringWarningLastMs = now;
|
|
2551
|
-
devWarn(
|
|
2552
|
-
`ri() inputs must be strings, arrays, or falsy \u2014 got ${typeof input}; value skipped. Object syntax ({ class: condition }) is not supported; use \`condition && "class"\` instead.`
|
|
2553
|
-
);
|
|
2554
|
-
}
|
|
2525
|
+
warnNonStringInput(input);
|
|
2555
2526
|
}
|
|
2556
2527
|
} else {
|
|
2557
2528
|
const trimmed = input.trim();
|
|
2558
2529
|
if (trimmed) {
|
|
2559
2530
|
for (const cls of splitBracketAware(trimmed)) {
|
|
2560
2531
|
if (result.length >= MAX_TOTAL_CLASSES) {
|
|
2561
|
-
|
|
2562
|
-
if (now - _totalClassesWarningLastMs >= WARNING_THROTTLE_MS) {
|
|
2563
|
-
_totalClassesWarningLastMs = now;
|
|
2564
|
-
console.warn(
|
|
2565
|
-
`[RI-2012] ri() input exceeds ${MAX_TOTAL_CLASSES} class limit. Excess classes are dropped to prevent memory exhaustion.`
|
|
2566
|
-
);
|
|
2567
|
-
}
|
|
2532
|
+
warnTotalClasses();
|
|
2568
2533
|
return result;
|
|
2569
2534
|
}
|
|
2570
2535
|
if (cls.length <= MAX_CLASS_NAME_LENGTH) {
|
|
2571
2536
|
result.push(cls);
|
|
2572
2537
|
} else {
|
|
2573
|
-
|
|
2574
|
-
if (now - _classLenWarningLastMs >= WARNING_THROTTLE_MS) {
|
|
2575
|
-
_classLenWarningLastMs = now;
|
|
2576
|
-
console.warn(
|
|
2577
|
-
`[RI-2006] Class name exceeds ${MAX_CLASS_NAME_LENGTH} character limit and was dropped: "${cls.slice(0, 40)}\u2026". This is a safety guard against adversarial input in SSR. If this is intentional, shorten the class name.`
|
|
2578
|
-
);
|
|
2579
|
-
}
|
|
2538
|
+
warnClassLength(cls);
|
|
2580
2539
|
}
|
|
2581
2540
|
}
|
|
2582
2541
|
}
|
|
@@ -2617,57 +2576,6 @@ function splitBracketAware(input) {
|
|
|
2617
2576
|
if (tokenStart !== -1) result.push(input.slice(tokenStart));
|
|
2618
2577
|
return result;
|
|
2619
2578
|
}
|
|
2620
|
-
function createCompilationContext() {
|
|
2621
|
-
return {
|
|
2622
|
-
customStaticProps: {},
|
|
2623
|
-
textSizes: new Set(DEFAULT_TEXT_SIZES),
|
|
2624
|
-
fontFamilies: new Set(DEFAULT_FONT_FAMILIES),
|
|
2625
|
-
colorNames: /* @__PURE__ */ new Set()
|
|
2626
|
-
};
|
|
2627
|
-
}
|
|
2628
|
-
function registerCustomUtility(ctx, name, properties) {
|
|
2629
|
-
if (IS_DEV) {
|
|
2630
|
-
if (!name) {
|
|
2631
|
-
devWarn("[RI-1301] registerCustomUtility() called with empty name \u2014 skipping.");
|
|
2632
|
-
return;
|
|
2633
|
-
}
|
|
2634
|
-
if (properties.length === 0) {
|
|
2635
|
-
devWarn(
|
|
2636
|
-
`[RI-1302] registerCustomUtility("${name}") called with no CSS properties \u2014 the utility won't participate in conflict resolution.`
|
|
2637
|
-
);
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
ctx.customStaticProps[name] = properties;
|
|
2641
|
-
}
|
|
2642
|
-
function registerCustomTextSizes(ctx, sizes) {
|
|
2643
|
-
for (const s of sizes) ctx.textSizes.add(s);
|
|
2644
|
-
}
|
|
2645
|
-
function registerCustomFontFamilies(ctx, families) {
|
|
2646
|
-
for (const f of families) ctx.fontFamilies.add(f);
|
|
2647
|
-
}
|
|
2648
|
-
function registerColorNames(ctx, names) {
|
|
2649
|
-
for (const n of names) ctx.colorNames.add(n);
|
|
2650
|
-
}
|
|
2651
|
-
function snapshotCompilationContext(ctx) {
|
|
2652
|
-
return {
|
|
2653
|
-
customStaticProps: Object.fromEntries(
|
|
2654
|
-
Object.entries(ctx.customStaticProps).map(([k, v]) => [k, [...v]])
|
|
2655
|
-
),
|
|
2656
|
-
textSizes: new Set(ctx.textSizes),
|
|
2657
|
-
fontFamilies: new Set(ctx.fontFamilies),
|
|
2658
|
-
colorNames: new Set(ctx.colorNames)
|
|
2659
|
-
};
|
|
2660
|
-
}
|
|
2661
|
-
function finalizeCompilationContext(ctx) {
|
|
2662
|
-
const snapshot = snapshotCompilationContext(ctx);
|
|
2663
|
-
_customStaticProps = snapshot.customStaticProps;
|
|
2664
|
-
_textSizes = snapshot.textSizes;
|
|
2665
|
-
_fontFamilies = snapshot.fontFamilies;
|
|
2666
|
-
_colorNames = snapshot.colorNames;
|
|
2667
|
-
_riCache.clear();
|
|
2668
|
-
_latestSnapshot = snapshot;
|
|
2669
|
-
return snapshot;
|
|
2670
|
-
}
|
|
2671
2579
|
|
|
2672
2580
|
export {
|
|
2673
2581
|
isValidColorSuffix,
|
|
@@ -2698,6 +2606,13 @@ export {
|
|
|
2698
2606
|
DEFAULT_TRACKING,
|
|
2699
2607
|
DEFAULT_LEADING,
|
|
2700
2608
|
defaultTheme,
|
|
2609
|
+
PADDING_MAP,
|
|
2610
|
+
MARGIN_MAP,
|
|
2611
|
+
GAP_MAP,
|
|
2612
|
+
INSET_MAP,
|
|
2613
|
+
SCROLL_MARGIN_MAP,
|
|
2614
|
+
SCROLL_PADDING_MAP,
|
|
2615
|
+
BORDER_DIR_PROPS,
|
|
2701
2616
|
COLOR_FUNCTION_ALTERNATION,
|
|
2702
2617
|
SPECIAL_COLORS,
|
|
2703
2618
|
isMaskRadialSizeValue,
|
|
@@ -2709,14 +2624,15 @@ export {
|
|
|
2709
2624
|
IS_DEV,
|
|
2710
2625
|
devWarn,
|
|
2711
2626
|
DEFAULT_TEXT_SIZES,
|
|
2712
|
-
|
|
2713
|
-
createRi,
|
|
2714
|
-
analyzeMerge,
|
|
2627
|
+
resolverFor,
|
|
2715
2628
|
createCompilationContext,
|
|
2716
2629
|
registerCustomUtility,
|
|
2717
2630
|
registerCustomTextSizes,
|
|
2718
2631
|
registerCustomFontFamilies,
|
|
2719
2632
|
registerColorNames,
|
|
2720
2633
|
snapshotCompilationContext,
|
|
2721
|
-
finalizeCompilationContext
|
|
2634
|
+
finalizeCompilationContext,
|
|
2635
|
+
mergeUncached,
|
|
2636
|
+
ri,
|
|
2637
|
+
createRi
|
|
2722
2638
|
};
|