rainbowindex 0.6.0 → 0.7.0
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 +543 -0
- package/LICENSE +16 -17
- package/NOTICE.md +106 -0
- package/README.md +219 -65
- package/dist/browser.d.ts +4 -2
- package/dist/browser.mjs +12 -4
- package/dist/chunk-2T7V5XLK.mjs +912 -0
- package/dist/chunk-6OORICWF.mjs +16 -0
- package/dist/{chunk-KSNYSR3C.mjs → chunk-FJOZJIKB.mjs} +2499 -329
- package/dist/chunk-L56IRO7A.mjs +491 -0
- package/dist/chunk-PZDVDEZJ.mjs +196 -0
- package/dist/{chunk-3LWJTLOJ.mjs → chunk-RC6DDE4L.mjs} +23 -15
- package/dist/chunk-TQJYVQPE.mjs +217 -0
- package/dist/chunk-W756NVYI.mjs +33 -0
- package/dist/chunk-WBESS2ZD.mjs +598 -0
- package/dist/{chunk-3HRMFZGE.mjs → chunk-X66Z2YHT.mjs} +2 -1
- package/dist/{chunk-6U4IOFOS.mjs → chunk-XQGSG2HK.mjs} +199 -555
- package/dist/cli.mjs +1077 -123
- package/dist/{index-DSgpB6bS.d.ts → context-DcBtnnan.d.ts} +47 -103
- package/dist/editor.d.ts +71 -433
- package/dist/editor.mjs +51 -368
- package/dist/eslint.d.ts +16 -0
- package/dist/eslint.mjs +32 -0
- package/dist/{index-4Kyaq3IZ.d.ts → imports-C9esHd5Q.d.ts} +78 -84
- package/dist/index-CNqdL5U0.d.ts +56 -0
- package/dist/index-Czx-EUwh.d.ts +138 -0
- package/dist/index-DW8YSxTz.d.ts +104 -0
- package/dist/index.d.ts +46 -5
- package/dist/index.mjs +33 -9
- package/dist/oxlint.d.ts +21 -3
- package/dist/oxlint.mjs +19 -1
- package/dist/recipe.d.ts +111 -0
- package/dist/recipe.mjs +71 -0
- package/dist/safelist-CH3_PywB.d.ts +43 -0
- package/dist/session-CMaskdB7.d.ts +543 -0
- package/dist/tailwind.css +644 -0
- package/dist/theme-CIZiGlce.d.ts +115 -0
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +266 -118
- package/package.json +27 -5
- package/dist/chunk-WK6S4HTC.mjs +0 -1921
- package/dist/chunk-ZR7XJMUN.mjs +0 -251
- package/dist/safelist-CGCtF-Fr.d.ts +0 -96
|
@@ -5,7 +5,7 @@ function devWarn(message) {
|
|
|
5
5
|
if (!IS_PROD) console.warn(message);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
// src/
|
|
8
|
+
// src/utilities/property-maps.ts
|
|
9
9
|
var PADDING_MAP = Object.freeze({
|
|
10
10
|
p: ["padding"],
|
|
11
11
|
px: ["padding-inline"],
|
|
@@ -90,6 +90,34 @@ var BORDER_DIR_PROPS = Object.freeze({
|
|
|
90
90
|
"border-x": ["border-inline-width"],
|
|
91
91
|
"border-y": ["border-block-width"]
|
|
92
92
|
});
|
|
93
|
+
var FILTER_SLOTS = Object.freeze([
|
|
94
|
+
"--ri-blur",
|
|
95
|
+
"--ri-brightness",
|
|
96
|
+
"--ri-contrast",
|
|
97
|
+
"--ri-grayscale",
|
|
98
|
+
"--ri-hue-rotate",
|
|
99
|
+
"--ri-invert",
|
|
100
|
+
"--ri-saturate",
|
|
101
|
+
"--ri-sepia",
|
|
102
|
+
"--ri-drop-shadow"
|
|
103
|
+
]);
|
|
104
|
+
var BACKDROP_FILTER_SLOTS = Object.freeze([
|
|
105
|
+
"--ri-backdrop-blur",
|
|
106
|
+
"--ri-backdrop-brightness",
|
|
107
|
+
"--ri-backdrop-contrast",
|
|
108
|
+
"--ri-backdrop-grayscale",
|
|
109
|
+
"--ri-backdrop-hue-rotate",
|
|
110
|
+
"--ri-backdrop-invert",
|
|
111
|
+
"--ri-backdrop-saturate",
|
|
112
|
+
"--ri-backdrop-sepia",
|
|
113
|
+
"--ri-backdrop-opacity"
|
|
114
|
+
]);
|
|
115
|
+
var FILTER_COMPOSED = FILTER_SLOTS.map((slot) => `var(${slot}, )`).join(" ");
|
|
116
|
+
var BACKDROP_FILTER_COMPOSED = BACKDROP_FILTER_SLOTS.map((slot) => `var(${slot}, )`).join(
|
|
117
|
+
" "
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// src/merge/static-props.ts
|
|
93
121
|
var BUILTIN_STATIC_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
94
122
|
// Grow/shrink
|
|
95
123
|
grow: ["flex-grow"],
|
|
@@ -141,6 +169,9 @@ var BUILTIN_STATIC_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
141
169
|
"transform-3d": ["transform-style"],
|
|
142
170
|
// Translate/rotate/scale none
|
|
143
171
|
"translate-none": ["translate"],
|
|
172
|
+
// `translate-3d` only opts into the Z axis; it claims the same property, so
|
|
173
|
+
// a later `translate-none` still wins and two of them dedupe.
|
|
174
|
+
"translate-3d": ["translate"],
|
|
144
175
|
"rotate-none": ["rotate"],
|
|
145
176
|
"scale-none": ["scale"],
|
|
146
177
|
// Perspective
|
|
@@ -187,14 +218,22 @@ var BUILTIN_STATIC_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
187
218
|
// Divide-between reverse flags (scoped so they compose with divide-x/divide-y)
|
|
188
219
|
"divide-x-reverse": ["~divide:--ri-divide-x-reverse"],
|
|
189
220
|
"divide-y-reverse": ["~divide:--ri-divide-y-reverse"],
|
|
190
|
-
// Backdrop filter (static)
|
|
191
|
-
|
|
221
|
+
// Backdrop filter (static). `backdrop-blur-none` clears the blur slot and
|
|
222
|
+
// nothing else, so it claims what every other backdrop-blur spelling claims
|
|
223
|
+
// — that is what lets it dedupe against `backdrop-blur-lg` while leaving a
|
|
224
|
+
// `backdrop-invert` beside it alone.
|
|
225
|
+
"backdrop-blur-none": ["--ri-backdrop-blur", "backdrop-filter"],
|
|
226
|
+
// Bare `backdrop-filter` enables the chain without contributing to it, so it
|
|
227
|
+
// claims the shorthand alone and composes with every function to its left.
|
|
228
|
+
"backdrop-filter": ["backdrop-filter"],
|
|
192
229
|
"backdrop-grayscale": ["--ri-backdrop-grayscale", "backdrop-filter"],
|
|
193
230
|
"backdrop-invert": ["--ri-backdrop-invert", "backdrop-filter"],
|
|
194
231
|
"backdrop-sepia": ["--ri-backdrop-sepia", "backdrop-filter"],
|
|
195
232
|
// Filter (static) — filter-none resets all filters
|
|
196
|
-
"filter-none": ["filter"],
|
|
197
|
-
"backdrop-filter-none": ["backdrop-filter"],
|
|
233
|
+
"filter-none": ["filter", ...FILTER_SLOTS],
|
|
234
|
+
"backdrop-filter-none": ["backdrop-filter", ...BACKDROP_FILTER_SLOTS],
|
|
235
|
+
// Bare `filter`, as above: enables, does not reset.
|
|
236
|
+
filter: ["filter"],
|
|
198
237
|
grayscale: ["--ri-grayscale", "filter"],
|
|
199
238
|
invert: ["--ri-invert", "filter"],
|
|
200
239
|
sepia: ["--ri-sepia", "filter"],
|
|
@@ -890,6 +929,9 @@ addAll(
|
|
|
890
929
|
],
|
|
891
930
|
["mix-blend-mode"]
|
|
892
931
|
);
|
|
932
|
+
Object.freeze(BUILTIN_STATIC_PROPS);
|
|
933
|
+
|
|
934
|
+
// src/merge/prefix-props.ts
|
|
893
935
|
var FLUID_EXCLUDED_PREFIXES = /* @__PURE__ */ new Set(["inset-s", "inset-e", "inset-bs", "inset-be"]);
|
|
894
936
|
var FLUID_SPACING_PROPS = (() => {
|
|
895
937
|
const rows = {};
|
|
@@ -986,6 +1028,14 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
986
1028
|
"inset-shadow": ["box-shadow", "--ri-inset-shadow"],
|
|
987
1029
|
ring: ["box-shadow", "--ri-ring-shadow"],
|
|
988
1030
|
"inset-ring": ["box-shadow", "--ri-inset-ring-shadow"],
|
|
1031
|
+
// `ring-offset-*` claims its own slots and NOT `box-shadow`, which is the
|
|
1032
|
+
// whole reason it composes: the offset layer joins a chain some other class
|
|
1033
|
+
// already emits the shorthand for. A claim on `box-shadow` here would let
|
|
1034
|
+
// `ring-offset-2` dominate the `ring-2` doing the visible work — which is
|
|
1035
|
+
// what happened before this row existed, when the family fell into the
|
|
1036
|
+
// `ring` prefix and `ri("ring-2 ring-offset-2 ring-offset-white")` returned
|
|
1037
|
+
// just `"ring-offset-white"`.
|
|
1038
|
+
"ring-offset": ["--ri-ring-offset-width", "--ri-ring-offset-shadow"],
|
|
989
1039
|
// text-shadow is its own property (not part of the box-shadow composition)
|
|
990
1040
|
"text-shadow": ["text-shadow"],
|
|
991
1041
|
opacity: ["opacity"],
|
|
@@ -1004,7 +1054,9 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1004
1054
|
"skew-y": ["transform", "--ri-skew-y"],
|
|
1005
1055
|
transform: ["transform"],
|
|
1006
1056
|
zoom: ["zoom"],
|
|
1007
|
-
filter
|
|
1057
|
+
// `filter-[v]` replaces the chain outright, so it claims every slot. The
|
|
1058
|
+
// bare `filter` static above is matched first and claims only the shorthand.
|
|
1059
|
+
filter: ["filter", ...FILTER_SLOTS],
|
|
1008
1060
|
brightness: ["--ri-brightness", "filter"],
|
|
1009
1061
|
contrast: ["--ri-contrast", "filter"],
|
|
1010
1062
|
saturate: ["--ri-saturate", "filter"],
|
|
@@ -1088,7 +1140,7 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1088
1140
|
...SCROLL_MARGIN_MAP,
|
|
1089
1141
|
...SCROLL_PADDING_MAP,
|
|
1090
1142
|
// Backdrop filter — each function gets a unique CSS variable so they coexist
|
|
1091
|
-
"backdrop-filter": ["backdrop-filter"],
|
|
1143
|
+
"backdrop-filter": ["backdrop-filter", ...BACKDROP_FILTER_SLOTS],
|
|
1092
1144
|
"backdrop-blur": ["--ri-backdrop-blur", "backdrop-filter"],
|
|
1093
1145
|
"backdrop-brightness": ["--ri-backdrop-brightness", "backdrop-filter"],
|
|
1094
1146
|
"backdrop-contrast": ["--ri-backdrop-contrast", "backdrop-filter"],
|
|
@@ -1137,6 +1189,11 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1137
1189
|
decoration: ["text-decoration-thickness"],
|
|
1138
1190
|
accent: ["accent-color"],
|
|
1139
1191
|
caret: ["caret-color"],
|
|
1192
|
+
// Scoped, like `divide`: the declaration is `color`, but it lands inside
|
|
1193
|
+
// `&::placeholder`, so it never conflicts with `text-*`. Without the
|
|
1194
|
+
// `~placeholder:` scope both would claim `color` and the merger would drop
|
|
1195
|
+
// one of `text-red-500 placeholder-gray-400`.
|
|
1196
|
+
placeholder: ["~placeholder:color"],
|
|
1140
1197
|
// Composable scrollbar-color (shared scrollbar-color + per-part slot var).
|
|
1141
1198
|
"scrollbar-thumb": ["scrollbar-color", "--ri-scrollbar-thumb"],
|
|
1142
1199
|
"scrollbar-track": ["scrollbar-color", "--ri-scrollbar-track"],
|
|
@@ -1156,6 +1213,9 @@ var PREFIX_PROPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1156
1213
|
"position-area": ["position-area"],
|
|
1157
1214
|
"anchor-scope": ["anchor-scope"]
|
|
1158
1215
|
});
|
|
1216
|
+
Object.freeze(PREFIX_PROPS);
|
|
1217
|
+
|
|
1218
|
+
// src/merge/props.ts
|
|
1159
1219
|
var DIRECT_OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1160
1220
|
padding: ["padding-inline", "padding-block"],
|
|
1161
1221
|
"padding-inline": ["padding-inline-start", "padding-inline-end"],
|
|
@@ -1238,30 +1298,15 @@ var DIRECT_OVERRIDES = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
|
1238
1298
|
],
|
|
1239
1299
|
"place-items": ["align-items", "justify-items"],
|
|
1240
1300
|
"place-content": ["align-content", "justify-content"],
|
|
1241
|
-
"place-self": ["align-self", "justify-self"]
|
|
1242
|
-
// filter
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
"--ri-grayscale",
|
|
1251
|
-
"--ri-invert",
|
|
1252
|
-
"--ri-sepia"
|
|
1253
|
-
],
|
|
1254
|
-
"backdrop-filter": [
|
|
1255
|
-
"--ri-backdrop-blur",
|
|
1256
|
-
"--ri-backdrop-brightness",
|
|
1257
|
-
"--ri-backdrop-contrast",
|
|
1258
|
-
"--ri-backdrop-saturate",
|
|
1259
|
-
"--ri-backdrop-grayscale",
|
|
1260
|
-
"--ri-backdrop-invert",
|
|
1261
|
-
"--ri-backdrop-sepia",
|
|
1262
|
-
"--ri-backdrop-opacity",
|
|
1263
|
-
"--ri-backdrop-hue-rotate"
|
|
1264
|
-
]
|
|
1301
|
+
"place-self": ["align-self", "justify-self"]
|
|
1302
|
+
// NOTE: `filter` and `backdrop-filter` deliberately have NO row here.
|
|
1303
|
+
// This table is keyed on the CSS property, and every composable member of
|
|
1304
|
+
// those families emits the shared shorthand as its second declaration — so
|
|
1305
|
+
// a row here made `grayscale` claim `--ri-blur`, and `ri("blur-sm
|
|
1306
|
+
// grayscale")` returned `"grayscale"`. The whole family annihilated itself,
|
|
1307
|
+
// which is the opposite of the composition the slot variables exist for.
|
|
1308
|
+
// The spellings that really do replace the chain claim the slots directly
|
|
1309
|
+
// instead; see FILTER_SLOTS.
|
|
1265
1310
|
});
|
|
1266
1311
|
var OVERRIDES = (() => {
|
|
1267
1312
|
const closed = /* @__PURE__ */ Object.create(null);
|
|
@@ -1279,9 +1324,31 @@ var OVERRIDES = (() => {
|
|
|
1279
1324
|
}
|
|
1280
1325
|
return closed;
|
|
1281
1326
|
})();
|
|
1282
|
-
Object.freeze(BUILTIN_STATIC_PROPS);
|
|
1283
|
-
Object.freeze(PREFIX_PROPS);
|
|
1284
1327
|
Object.freeze(OVERRIDES);
|
|
1328
|
+
var BUILTIN_STATIC_KEYS = new Set(Object.keys(BUILTIN_STATIC_PROPS));
|
|
1329
|
+
var PREFIX_PROP_KEYS = new Set(Object.keys(PREFIX_PROPS));
|
|
1330
|
+
var SORTED_PREFIXES = Object.keys(PREFIX_PROPS).sort((a, b) => b.length - a.length);
|
|
1331
|
+
function buildFirstSegmentMap(prefixes) {
|
|
1332
|
+
const map = /* @__PURE__ */ new Map();
|
|
1333
|
+
for (const prefix of prefixes) {
|
|
1334
|
+
const dashIdx = prefix.indexOf("-");
|
|
1335
|
+
const firstSeg = dashIdx === -1 ? prefix : prefix.slice(0, dashIdx);
|
|
1336
|
+
const existing = map.get(firstSeg);
|
|
1337
|
+
if (existing) {
|
|
1338
|
+
existing.push(prefix);
|
|
1339
|
+
} else {
|
|
1340
|
+
map.set(firstSeg, [prefix]);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
const frozen = /* @__PURE__ */ new Map();
|
|
1344
|
+
for (const [key, arr] of map) {
|
|
1345
|
+
frozen.set(key, Object.freeze(arr));
|
|
1346
|
+
}
|
|
1347
|
+
return frozen;
|
|
1348
|
+
}
|
|
1349
|
+
var PREFIX_FIRST_SEGMENT_MAP = buildFirstSegmentMap(SORTED_PREFIXES);
|
|
1350
|
+
|
|
1351
|
+
// src/merge/value-kinds.ts
|
|
1285
1352
|
var RE_COLOR_SHADE = /^[a-z]+(?:-[a-z]+)*-\d{2,3}$/;
|
|
1286
1353
|
var COLOR_FUNCTION_ALTERNATION = "oklch|oklab|rgb|rgba|hsl|hsla|hwb|lab|lch|color|light-dark";
|
|
1287
1354
|
var RE_ARBITRARY_COLOR = new RegExp(`[#]|(?:${COLOR_FUNCTION_ALTERNATION})\\s*\\(`);
|
|
@@ -1357,28 +1424,6 @@ function isFontFamilyValue(value) {
|
|
|
1357
1424
|
}
|
|
1358
1425
|
return false;
|
|
1359
1426
|
}
|
|
1360
|
-
var BUILTIN_STATIC_KEYS = new Set(Object.keys(BUILTIN_STATIC_PROPS));
|
|
1361
|
-
var PREFIX_PROP_KEYS = new Set(Object.keys(PREFIX_PROPS));
|
|
1362
|
-
var SORTED_PREFIXES = Object.keys(PREFIX_PROPS).sort((a, b) => b.length - a.length);
|
|
1363
|
-
function buildFirstSegmentMap(prefixes) {
|
|
1364
|
-
const map = /* @__PURE__ */ new Map();
|
|
1365
|
-
for (const prefix of prefixes) {
|
|
1366
|
-
const dashIdx = prefix.indexOf("-");
|
|
1367
|
-
const firstSeg = dashIdx === -1 ? prefix : prefix.slice(0, dashIdx);
|
|
1368
|
-
const existing = map.get(firstSeg);
|
|
1369
|
-
if (existing) {
|
|
1370
|
-
existing.push(prefix);
|
|
1371
|
-
} else {
|
|
1372
|
-
map.set(firstSeg, [prefix]);
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
const frozen = /* @__PURE__ */ new Map();
|
|
1376
|
-
for (const [key, arr] of map) {
|
|
1377
|
-
frozen.set(key, Object.freeze(arr));
|
|
1378
|
-
}
|
|
1379
|
-
return frozen;
|
|
1380
|
-
}
|
|
1381
|
-
var PREFIX_FIRST_SEGMENT_MAP = buildFirstSegmentMap(SORTED_PREFIXES);
|
|
1382
1427
|
|
|
1383
1428
|
// src/brackets.ts
|
|
1384
1429
|
function scanBracketAware(input, onChar, options) {
|
|
@@ -1471,10 +1516,18 @@ var DECORATION_COLOR_PROPS = Object.freeze(["text-decoration-color"]);
|
|
|
1471
1516
|
var RE_SIGNED_INT = /^-?\d+$/;
|
|
1472
1517
|
var RE_UNSIGNED_INT = /^\d+$/;
|
|
1473
1518
|
var RE_DECIMAL = /^\d+(?:[._]\d+)?$/;
|
|
1474
|
-
function colorOrDefault(prefix, colorProps) {
|
|
1519
|
+
function colorOrDefault(prefix, colorProps, hasInitial = false) {
|
|
1475
1520
|
const defaultProps = PREFIX_PROPS[prefix];
|
|
1476
|
-
return (value, _textSizes2, _fontFamilies2, colorNames) => isColorValue(value, void 0, colorNames) ? colorProps : defaultProps;
|
|
1521
|
+
return (value, _textSizes2, _fontFamilies2, colorNames) => hasInitial && value === "initial" || isColorValue(value, void 0, colorNames) ? colorProps : defaultProps;
|
|
1477
1522
|
}
|
|
1523
|
+
var RING_INSET_PROPS = Object.freeze(["--ri-ring-inset"]);
|
|
1524
|
+
var RING_COLOR_PROPS = Object.freeze(["--ri-ring-color"]);
|
|
1525
|
+
var RING_DEFAULT_PROPS = PREFIX_PROPS.ring;
|
|
1526
|
+
var RING_DUAL_MODE = (value, _textSizes2, _fontFamilies2, colorNames) => {
|
|
1527
|
+
if (isColorValue(value, void 0, colorNames)) return RING_COLOR_PROPS;
|
|
1528
|
+
if (value === "inset") return RING_INSET_PROPS;
|
|
1529
|
+
return RING_DEFAULT_PROPS;
|
|
1530
|
+
};
|
|
1478
1531
|
var DUAL_MODE_PREFIXES = {
|
|
1479
1532
|
...MASK_STOP_DUAL_MODES,
|
|
1480
1533
|
// mask-radial-[<size>] sets the size var; mask-radial-[<value>] is a full image.
|
|
@@ -1519,11 +1572,12 @@ var DUAL_MODE_PREFIXES = {
|
|
|
1519
1572
|
// so a color-first check would misclassify it) and background-color
|
|
1520
1573
|
// for everything else — never the full `background` shorthand.
|
|
1521
1574
|
bg: (value) => isImageValue(value) ? BG_IMAGE_PROPS : PREFIX_PROPS.bg,
|
|
1522
|
-
shadow: colorOrDefault("shadow", Object.freeze(["--ri-shadow-color"])),
|
|
1523
|
-
"
|
|
1524
|
-
|
|
1575
|
+
shadow: colorOrDefault("shadow", Object.freeze(["--ri-shadow-color"]), true),
|
|
1576
|
+
"ring-offset": colorOrDefault("ring-offset", Object.freeze(["--ri-ring-offset-color"])),
|
|
1577
|
+
"inset-shadow": colorOrDefault("inset-shadow", Object.freeze(["--ri-inset-shadow-color"]), true),
|
|
1578
|
+
ring: RING_DUAL_MODE,
|
|
1525
1579
|
"inset-ring": colorOrDefault("inset-ring", Object.freeze(["--ri-inset-ring-color"])),
|
|
1526
|
-
"text-shadow": colorOrDefault("text-shadow", Object.freeze(["--ri-text-shadow-color"])),
|
|
1580
|
+
"text-shadow": colorOrDefault("text-shadow", Object.freeze(["--ri-text-shadow-color"]), true),
|
|
1527
1581
|
"drop-shadow": colorOrDefault("drop-shadow", Object.freeze(["--ri-drop-shadow-color"])),
|
|
1528
1582
|
from: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["from-position"] : PREFIX_PROPS.from,
|
|
1529
1583
|
via: (value) => isGradientPositionValue(value) ? PREFIX_PROPS["via-position"] : PREFIX_PROPS.via,
|
|
@@ -1701,8 +1755,7 @@ function snapshotCompilationContext(ctx) {
|
|
|
1701
1755
|
colorNames: new Set(ctx.colorNames)
|
|
1702
1756
|
};
|
|
1703
1757
|
}
|
|
1704
|
-
function
|
|
1705
|
-
const snapshot = snapshotCompilationContext(ctx);
|
|
1758
|
+
function publishSnapshot(snapshot) {
|
|
1706
1759
|
_customStaticProps = snapshot.customStaticProps;
|
|
1707
1760
|
_customFunctionalProps = snapshot.customFunctionalProps;
|
|
1708
1761
|
_textSizes = snapshot.textSizes;
|
|
@@ -1710,8 +1763,52 @@ function finalizeCompilationContext(ctx) {
|
|
|
1710
1763
|
_colorNames = snapshot.colorNames;
|
|
1711
1764
|
defaultRiCache.clear();
|
|
1712
1765
|
_latestSnapshot = snapshot;
|
|
1766
|
+
}
|
|
1767
|
+
function finalizeCompilationContext(ctx) {
|
|
1768
|
+
const snapshot = snapshotCompilationContext(ctx);
|
|
1769
|
+
publishSnapshot(snapshot);
|
|
1713
1770
|
return snapshot;
|
|
1714
1771
|
}
|
|
1772
|
+
var SNAPSHOT_FORMAT = 1;
|
|
1773
|
+
function serializeSnapshot(snapshot) {
|
|
1774
|
+
return {
|
|
1775
|
+
format: SNAPSHOT_FORMAT,
|
|
1776
|
+
customStaticProps: Object.fromEntries(
|
|
1777
|
+
Object.entries(snapshot.customStaticProps).map(([k, v]) => [k, [...v]]).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0)
|
|
1778
|
+
),
|
|
1779
|
+
// Already tuples, and already ordered longest-root-first — an order the
|
|
1780
|
+
// resolver depends on, so it is preserved rather than sorted.
|
|
1781
|
+
customFunctionalProps: snapshot.customFunctionalProps.map(
|
|
1782
|
+
([root, props]) => [root, [...props]]
|
|
1783
|
+
),
|
|
1784
|
+
textSizes: [...snapshot.textSizes].sort(),
|
|
1785
|
+
fontFamilies: [...snapshot.fontFamilies].sort(),
|
|
1786
|
+
colorNames: [...snapshot.colorNames].sort()
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
function hydrateSnapshot(data) {
|
|
1790
|
+
if (data?.format !== SNAPSHOT_FORMAT) {
|
|
1791
|
+
devWarn(
|
|
1792
|
+
`[RI-2007] The generated theme snapshot was written for format ${String(data?.format)}, but this version of rainbowindex reads format ${SNAPSHOT_FORMAT}. Its theme was ignored, so \`ri()\` will guess at project-defined sizes and colours. Re-run \`rainbowindex generate-snapshot\`, or update the plugin that generates it.`
|
|
1793
|
+
);
|
|
1794
|
+
return {
|
|
1795
|
+
customStaticProps: {},
|
|
1796
|
+
customFunctionalProps: [],
|
|
1797
|
+
textSizes: /* @__PURE__ */ new Set(),
|
|
1798
|
+
// The three built-in slots are always live: an absent list means "no
|
|
1799
|
+
// snapshot said otherwise", not "no font slots exist".
|
|
1800
|
+
fontFamilies: new Set(DEFAULT_FONT_FAMILIES),
|
|
1801
|
+
colorNames: /* @__PURE__ */ new Set()
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
return {
|
|
1805
|
+
customStaticProps: data.customStaticProps,
|
|
1806
|
+
customFunctionalProps: data.customFunctionalProps,
|
|
1807
|
+
textSizes: new Set(data.textSizes),
|
|
1808
|
+
fontFamilies: new Set(data.fontFamilies),
|
|
1809
|
+
colorNames: new Set(data.colorNames)
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1715
1812
|
|
|
1716
1813
|
// src/merge/index.ts
|
|
1717
1814
|
var RI_CACHE_KEY_MAX_LEN = 2048;
|
|
@@ -1808,7 +1905,7 @@ function mergeClasses(classes, resolve, cache) {
|
|
|
1808
1905
|
if (useCache) cache.put(cacheKey, output);
|
|
1809
1906
|
return output;
|
|
1810
1907
|
}
|
|
1811
|
-
function mergeFrom(inputs, resolve, cache) {
|
|
1908
|
+
function mergeFrom(inputs, resolve, cache, warnUnthemed = false) {
|
|
1812
1909
|
let fastPath = true;
|
|
1813
1910
|
let rawKey = "";
|
|
1814
1911
|
for (let i = 0; i < inputs.length; i++) {
|
|
@@ -1826,6 +1923,7 @@ function mergeFrom(inputs, resolve, cache) {
|
|
|
1826
1923
|
const cached = cache.get(rawKey);
|
|
1827
1924
|
if (cached !== void 0) return cached;
|
|
1828
1925
|
const classes2 = flattenInputs(inputs);
|
|
1926
|
+
if (warnUnthemed && classes2.length > 1) warnUnpublishedTheme(classes2, resolve);
|
|
1829
1927
|
const output = classes2.length === 0 ? "" : classes2.length === 1 ? classes2[0] : mergeUncached(classes2, resolve);
|
|
1830
1928
|
cache.put(rawKey, output);
|
|
1831
1929
|
return output;
|
|
@@ -1834,14 +1932,9 @@ function mergeFrom(inputs, resolve, cache) {
|
|
|
1834
1932
|
const classes = flattenInputs(inputs);
|
|
1835
1933
|
if (classes.length === 0) return "";
|
|
1836
1934
|
if (classes.length === 1) return classes[0];
|
|
1935
|
+
if (warnUnthemed) warnUnpublishedTheme(classes, resolve);
|
|
1837
1936
|
return mergeClasses(classes, resolve, cache);
|
|
1838
1937
|
}
|
|
1839
|
-
var _isSSR = null;
|
|
1840
|
-
function detectSSR() {
|
|
1841
|
-
if (_isSSR !== null) return _isSSR;
|
|
1842
|
-
_isSSR = typeof window === "undefined" && typeof process !== "undefined" && !!process.versions?.node;
|
|
1843
|
-
return _isSSR;
|
|
1844
|
-
}
|
|
1845
1938
|
var WARNING_THROTTLE_MS = 6e4;
|
|
1846
1939
|
function throttledWarn(message, emit = console.warn) {
|
|
1847
1940
|
let last = Number.NEGATIVE_INFINITY;
|
|
@@ -1853,15 +1946,32 @@ function throttledWarn(message, emit = console.warn) {
|
|
|
1853
1946
|
}
|
|
1854
1947
|
};
|
|
1855
1948
|
}
|
|
1856
|
-
var
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
);
|
|
1949
|
+
var _warnedNoSnapshot = false;
|
|
1950
|
+
function shouldCheckSnapshot() {
|
|
1951
|
+
return !_warnedNoSnapshot && !hasFinalizedSnapshot();
|
|
1952
|
+
}
|
|
1953
|
+
function isThemeDependent(cls, resolve) {
|
|
1954
|
+
const splitIdx = findVariantSplit(cls);
|
|
1955
|
+
let utility = splitIdx === -1 ? cls : cls.slice(splitIdx + 1);
|
|
1956
|
+
if (utility.charCodeAt(utility.length - 1) === 33) utility = utility.slice(0, -1);
|
|
1957
|
+
if (utility.charCodeAt(0) === 45) utility = utility.slice(1);
|
|
1958
|
+
return utility.startsWith("text-") || utility.startsWith("font-") || resolve(utility) === null;
|
|
1959
|
+
}
|
|
1960
|
+
function warnUnpublishedTheme(classes, resolve) {
|
|
1961
|
+
if (_warnedNoSnapshot || hasFinalizedSnapshot()) return;
|
|
1962
|
+
let offender;
|
|
1963
|
+
for (const cls of classes) {
|
|
1964
|
+
if (isThemeDependent(cls, resolve)) {
|
|
1965
|
+
offender = cls;
|
|
1966
|
+
break;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
if (offender === void 0) return;
|
|
1970
|
+
_warnedNoSnapshot = true;
|
|
1971
|
+
console.warn(
|
|
1972
|
+
`[RI-2004] ri() merged "${offender}" with no theme published, so its meaning was guessed. Since 0.6.0 text sizes, weights, font slots, and color names are all project-defined, and without them a size can be read as a color and dropped. With Vite this is automatic \u2014 check the plugin is installed. Otherwise run \`rainbowindex generate-snapshot\` and import the generated module once at startup, or pass a snapshot to createRi(snapshot). This warns once per process. See: https://rainbowindex.dev/docs/ssr`
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1865
1975
|
var warnFlattenDepth = throttledWarn(
|
|
1866
1976
|
() => `[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.`
|
|
1867
1977
|
);
|
|
@@ -1876,10 +1986,7 @@ var warnNonStringInput = throttledWarn(
|
|
|
1876
1986
|
devWarn
|
|
1877
1987
|
);
|
|
1878
1988
|
function ri(...inputs) {
|
|
1879
|
-
|
|
1880
|
-
warnSSRUsage();
|
|
1881
|
-
}
|
|
1882
|
-
return mergeFrom(inputs, resolveProps, defaultRiCache);
|
|
1989
|
+
return mergeFrom(inputs, resolveProps, defaultRiCache, shouldCheckSnapshot());
|
|
1883
1990
|
}
|
|
1884
1991
|
function createRi(snapshot) {
|
|
1885
1992
|
const resolve = resolverFor(snapshot);
|
|
@@ -1966,458 +2073,6 @@ function splitBracketAware(input) {
|
|
|
1966
2073
|
return result;
|
|
1967
2074
|
}
|
|
1968
2075
|
|
|
1969
|
-
// src/theme/colors.ts
|
|
1970
|
-
function isValidColorSuffix(n) {
|
|
1971
|
-
return Number.isInteger(n) && n >= 1 && n <= 999;
|
|
1972
|
-
}
|
|
1973
|
-
var STOP_LO = 50;
|
|
1974
|
-
var STOP_STEP = 50;
|
|
1975
|
-
var L_PROFILE = [
|
|
1976
|
-
0.9668,
|
|
1977
|
-
// 50
|
|
1978
|
-
0.936756,
|
|
1979
|
-
// 100
|
|
1980
|
-
0.905984,
|
|
1981
|
-
// 150
|
|
1982
|
-
0.87442,
|
|
1983
|
-
// 200
|
|
1984
|
-
0.841988,
|
|
1985
|
-
// 250
|
|
1986
|
-
0.808602,
|
|
1987
|
-
// 300
|
|
1988
|
-
0.774158,
|
|
1989
|
-
// 350
|
|
1990
|
-
0.73853,
|
|
1991
|
-
// 400
|
|
1992
|
-
0.701568,
|
|
1993
|
-
// 450
|
|
1994
|
-
0.663082,
|
|
1995
|
-
// 500
|
|
1996
|
-
0.622832,
|
|
1997
|
-
// 550
|
|
1998
|
-
0.580504,
|
|
1999
|
-
// 600
|
|
2000
|
-
0.535677,
|
|
2001
|
-
// 650
|
|
2002
|
-
0.487755,
|
|
2003
|
-
// 700
|
|
2004
|
-
0.435847,
|
|
2005
|
-
// 750
|
|
2006
|
-
0.378506,
|
|
2007
|
-
// 800
|
|
2008
|
-
0.313034,
|
|
2009
|
-
// 850
|
|
2010
|
-
0.232988,
|
|
2011
|
-
// 900
|
|
2012
|
-
0.045
|
|
2013
|
-
// 950
|
|
2014
|
-
];
|
|
2015
|
-
var REF_CHROMA = 0.05;
|
|
2016
|
-
var C_REF = [
|
|
2017
|
-
0.006863863034589374,
|
|
2018
|
-
// 50
|
|
2019
|
-
0.01319862716849036,
|
|
2020
|
-
// 100
|
|
2021
|
-
0.019388384668336325,
|
|
2022
|
-
// 150
|
|
2023
|
-
0.025429811853816625,
|
|
2024
|
-
// 200
|
|
2025
|
-
0.03131716290796655,
|
|
2026
|
-
// 250
|
|
2027
|
-
0.03704281264548738,
|
|
2028
|
-
// 300
|
|
2029
|
-
0.04259815284255128,
|
|
2030
|
-
// 350
|
|
2031
|
-
0.04797259847240491,
|
|
2032
|
-
// 400
|
|
2033
|
-
0.053139652622711774,
|
|
2034
|
-
// 450
|
|
2035
|
-
0.05807254410984486,
|
|
2036
|
-
// 500
|
|
2037
|
-
0.057890440330825195,
|
|
2038
|
-
// 550
|
|
2039
|
-
0.05222950205066024,
|
|
2040
|
-
// 600
|
|
2041
|
-
0.04663166172903349,
|
|
2042
|
-
// 650
|
|
2043
|
-
0.04108661482545571,
|
|
2044
|
-
// 700
|
|
2045
|
-
0.035584106512529856,
|
|
2046
|
-
// 750
|
|
2047
|
-
0.030108630901677546,
|
|
2048
|
-
// 800
|
|
2049
|
-
0.02463007273923548,
|
|
2050
|
-
// 850
|
|
2051
|
-
0.01911062262055484,
|
|
2052
|
-
// 900
|
|
2053
|
-
0.013470720217073236
|
|
2054
|
-
// 950
|
|
2055
|
-
];
|
|
2056
|
-
var H_DRIFT = [
|
|
2057
|
-
-0.93815866691077,
|
|
2058
|
-
// 50
|
|
2059
|
-
-0.88308454198904,
|
|
2060
|
-
// 100
|
|
2061
|
-
-0.82986570023714,
|
|
2062
|
-
// 150
|
|
2063
|
-
-0.77925524218887,
|
|
2064
|
-
// 200
|
|
2065
|
-
-0.73231968077941,
|
|
2066
|
-
// 250
|
|
2067
|
-
-0.69055370894147,
|
|
2068
|
-
// 300
|
|
2069
|
-
-0.65608113228225,
|
|
2070
|
-
// 350
|
|
2071
|
-
-0.6319804472577,
|
|
2072
|
-
// 400
|
|
2073
|
-
-0.62282301825498,
|
|
2074
|
-
// 450
|
|
2075
|
-
-0.63542113918918,
|
|
2076
|
-
// 500
|
|
2077
|
-
-0.65047025648765,
|
|
2078
|
-
// 550
|
|
2079
|
-
-0.64293938410323,
|
|
2080
|
-
// 600
|
|
2081
|
-
-0.63626978185344,
|
|
2082
|
-
// 650
|
|
2083
|
-
-0.63057786221076,
|
|
2084
|
-
// 700
|
|
2085
|
-
-0.62611168444876,
|
|
2086
|
-
// 750
|
|
2087
|
-
-0.62332854799372,
|
|
2088
|
-
// 800
|
|
2089
|
-
-0.62317507759171,
|
|
2090
|
-
// 850
|
|
2091
|
-
-0.62789446720379,
|
|
2092
|
-
// 900
|
|
2093
|
-
-0.64378251527182
|
|
2094
|
-
// 950
|
|
2095
|
-
];
|
|
2096
|
-
function sampleProfile(values, suffix, monotone) {
|
|
2097
|
-
const last = values.length - 1;
|
|
2098
|
-
const fx = (suffix - STOP_LO) / STOP_STEP;
|
|
2099
|
-
if (fx <= 0) return values[0] + (values[1] - values[0]) * fx;
|
|
2100
|
-
if (fx >= last) return values[last] + (values[last] - values[last - 1]) * (fx - last);
|
|
2101
|
-
const i = Math.floor(fx);
|
|
2102
|
-
const t = fx - i;
|
|
2103
|
-
if (t === 0) return values[i];
|
|
2104
|
-
const seg = values[i + 1] - values[i];
|
|
2105
|
-
const tangent = (k) => {
|
|
2106
|
-
if (k <= 0) return values[1] - values[0];
|
|
2107
|
-
if (k >= last) return values[last] - values[last - 1];
|
|
2108
|
-
return (values[k + 1] - values[k - 1]) / 2;
|
|
2109
|
-
};
|
|
2110
|
-
let m0 = tangent(i);
|
|
2111
|
-
let m1 = tangent(i + 1);
|
|
2112
|
-
if (monotone) {
|
|
2113
|
-
if (seg === 0) {
|
|
2114
|
-
m0 = 0;
|
|
2115
|
-
m1 = 0;
|
|
2116
|
-
} else {
|
|
2117
|
-
const a = m0 / seg;
|
|
2118
|
-
const b = m1 / seg;
|
|
2119
|
-
const s = a * a + b * b;
|
|
2120
|
-
if (s > 9) {
|
|
2121
|
-
const tau = 3 / Math.sqrt(s);
|
|
2122
|
-
m0 = tau * a * seg;
|
|
2123
|
-
m1 = tau * b * seg;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
const t2 = t * t;
|
|
2128
|
-
const t3 = t2 * t;
|
|
2129
|
-
return (2 * t3 - 3 * t2 + 1) * values[i] + (t3 - 2 * t2 + t) * m0 + (-2 * t3 + 3 * t2) * values[i + 1] + (t3 - t2) * m1;
|
|
2130
|
-
}
|
|
2131
|
-
function lightnessFromSuffix(suffix) {
|
|
2132
|
-
return Math.min(0.98, Math.max(0.02, sampleProfile(L_PROFILE, suffix, true)));
|
|
2133
|
-
}
|
|
2134
|
-
var DEFAULT_COLORS = Object.freeze({
|
|
2135
|
-
theme: {
|
|
2136
|
-
type: "generative",
|
|
2137
|
-
chroma: 0,
|
|
2138
|
-
hue: 0,
|
|
2139
|
-
parabolic: false,
|
|
2140
|
-
chromaBoost: false
|
|
2141
|
-
}
|
|
2142
|
-
});
|
|
2143
|
-
var DEFAULT_DARK_CONFIG = {
|
|
2144
|
-
mode: "auto",
|
|
2145
|
-
// 0 → dark keeps the light stop's chroma exactly (same tone in both modes).
|
|
2146
|
-
// Raise it via `@color dark { chroma-boost }` for punchier dark-mode colors.
|
|
2147
|
-
chromaBoost: 0,
|
|
2148
|
-
hueShift: 0
|
|
2149
|
-
};
|
|
2150
|
-
var GAMUT_CLAMP_ITERATIONS = 20;
|
|
2151
|
-
function oklchToOklab(l, c, h) {
|
|
2152
|
-
const hRad = h * Math.PI / 180;
|
|
2153
|
-
return [l, c * Math.cos(hRad), c * Math.sin(hRad)];
|
|
2154
|
-
}
|
|
2155
|
-
function oklabToLinearSrgb(l, a, b) {
|
|
2156
|
-
const l_ = l + 0.3963377774 * a + 0.2158037573 * b;
|
|
2157
|
-
const m_ = l - 0.1055613458 * a - 0.0638541728 * b;
|
|
2158
|
-
const s_ = l - 0.0894841775 * a - 1.291485548 * b;
|
|
2159
|
-
const lc = l_ * l_ * l_;
|
|
2160
|
-
const mc = m_ * m_ * m_;
|
|
2161
|
-
const sc = s_ * s_ * s_;
|
|
2162
|
-
const r = 4.0767416621 * lc - 3.3077115913 * mc + 0.2309699292 * sc;
|
|
2163
|
-
const g = -1.2684380046 * lc + 2.6097574011 * mc - 0.3413193965 * sc;
|
|
2164
|
-
const bv = -0.0041960863 * lc - 0.7034186147 * mc + 1.707614701 * sc;
|
|
2165
|
-
return [r, g, bv];
|
|
2166
|
-
}
|
|
2167
|
-
function isInSrgbGamut(l, c, h) {
|
|
2168
|
-
const [la, a, b] = oklchToOklab(l, c, h);
|
|
2169
|
-
const [r, g, bv] = oklabToLinearSrgb(la, a, b);
|
|
2170
|
-
const eps = 1e-3;
|
|
2171
|
-
return r >= -eps && r <= 1 + eps && g >= -eps && g <= 1 + eps && bv >= -eps && bv <= 1 + eps;
|
|
2172
|
-
}
|
|
2173
|
-
function gamutSafeChroma(l, requestedChroma, h) {
|
|
2174
|
-
if (requestedChroma <= 0) return 0;
|
|
2175
|
-
if (isInSrgbGamut(l, requestedChroma, h)) return requestedChroma;
|
|
2176
|
-
let lo = 0;
|
|
2177
|
-
let hi = requestedChroma;
|
|
2178
|
-
for (let i = 0; i < GAMUT_CLAMP_ITERATIONS; i++) {
|
|
2179
|
-
const mid = (lo + hi) / 2;
|
|
2180
|
-
if (isInSrgbGamut(l, mid, h)) {
|
|
2181
|
-
lo = mid;
|
|
2182
|
-
} else {
|
|
2183
|
-
hi = mid;
|
|
2184
|
-
}
|
|
2185
|
-
if (hi - lo < 5e-4) break;
|
|
2186
|
-
}
|
|
2187
|
-
return lo;
|
|
2188
|
-
}
|
|
2189
|
-
var APCA_MAIN_TRC = 2.4;
|
|
2190
|
-
var APCA_NORM_BG = 0.56;
|
|
2191
|
-
var APCA_NORM_TXT = 0.57;
|
|
2192
|
-
var APCA_REV_TXT = 0.62;
|
|
2193
|
-
var APCA_REV_BG = 0.65;
|
|
2194
|
-
var APCA_BLK_THRS = 0.022;
|
|
2195
|
-
var APCA_BLK_CLMP = Math.SQRT2;
|
|
2196
|
-
var APCA_SCALE = 1.14;
|
|
2197
|
-
var APCA_LO_BOW_OFFSET = 0.027;
|
|
2198
|
-
var APCA_LO_WOB_OFFSET = 0.027;
|
|
2199
|
-
var APCA_DELTA_Y_MIN = 5e-4;
|
|
2200
|
-
var APCA_LO_CLIP = 0.1;
|
|
2201
|
-
function linearToSrgb(c) {
|
|
2202
|
-
const x = Math.max(0, Math.min(1, c));
|
|
2203
|
-
return x <= 31308e-7 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - 0.055;
|
|
2204
|
-
}
|
|
2205
|
-
function oklchToApcaY(l, c, h) {
|
|
2206
|
-
const [la, a, b] = oklchToOklab(l, c, h);
|
|
2207
|
-
const [lr, lg, lb] = oklabToLinearSrgb(la, a, b);
|
|
2208
|
-
const r = linearToSrgb(lr);
|
|
2209
|
-
const g = linearToSrgb(lg);
|
|
2210
|
-
const bv = linearToSrgb(lb);
|
|
2211
|
-
return 0.2126 * r ** APCA_MAIN_TRC + 0.7152 * g ** APCA_MAIN_TRC + 0.0722 * bv ** APCA_MAIN_TRC;
|
|
2212
|
-
}
|
|
2213
|
-
function apcaContrast(yText, yBg) {
|
|
2214
|
-
if (yText < 0 || yBg < 0) return 0;
|
|
2215
|
-
if (Math.max(yText, yBg) < APCA_BLK_THRS) return 0;
|
|
2216
|
-
const txtY = yText < APCA_BLK_THRS ? yText + (APCA_BLK_THRS - yText) ** APCA_BLK_CLMP : yText;
|
|
2217
|
-
const bgY = yBg < APCA_BLK_THRS ? yBg + (APCA_BLK_THRS - yBg) ** APCA_BLK_CLMP : yBg;
|
|
2218
|
-
if (Math.abs(bgY - txtY) < APCA_DELTA_Y_MIN) return 0;
|
|
2219
|
-
if (bgY > txtY) {
|
|
2220
|
-
const sapc2 = (bgY ** APCA_NORM_BG - txtY ** APCA_NORM_TXT) * APCA_SCALE;
|
|
2221
|
-
return sapc2 < APCA_LO_CLIP ? 0 : (sapc2 - APCA_LO_BOW_OFFSET) * 100;
|
|
2222
|
-
}
|
|
2223
|
-
const sapc = (bgY ** APCA_REV_BG - txtY ** APCA_REV_TXT) * APCA_SCALE;
|
|
2224
|
-
return sapc > -APCA_LO_CLIP ? 0 : (sapc + APCA_LO_WOB_OFFSET) * 100;
|
|
2225
|
-
}
|
|
2226
|
-
var _stopMemo = /* @__PURE__ */ new WeakMap();
|
|
2227
|
-
function generateStop(def, suffix) {
|
|
2228
|
-
let bySuffix = _stopMemo.get(def);
|
|
2229
|
-
if (!bySuffix) {
|
|
2230
|
-
bySuffix = /* @__PURE__ */ new Map();
|
|
2231
|
-
_stopMemo.set(def, bySuffix);
|
|
2232
|
-
}
|
|
2233
|
-
const cached = bySuffix.get(suffix);
|
|
2234
|
-
if (cached) return cached;
|
|
2235
|
-
const stop = computeStop(def, suffix);
|
|
2236
|
-
bySuffix.set(suffix, stop);
|
|
2237
|
-
return stop;
|
|
2238
|
-
}
|
|
2239
|
-
function computeStop(def, suffix) {
|
|
2240
|
-
const roundedL = Math.round(lightnessFromSuffix(suffix) * 1e3) / 1e3;
|
|
2241
|
-
const h = def.chroma > 0 ? def.hue + sampleProfile(H_DRIFT, suffix, false) : def.hue;
|
|
2242
|
-
const roundedH = Math.round(h * 1e3) / 1e3;
|
|
2243
|
-
const shapedChroma = def.parabolic === false ? def.chroma : def.chroma * sampleProfile(C_REF, suffix, false) / REF_CHROMA;
|
|
2244
|
-
const safeC = gamutSafeChroma(roundedL, shapedChroma, roundedH);
|
|
2245
|
-
const roundedC = Math.floor(safeC * 1e4) / 1e4;
|
|
2246
|
-
return {
|
|
2247
|
-
stop: suffix,
|
|
2248
|
-
l: roundedL,
|
|
2249
|
-
c: roundedC,
|
|
2250
|
-
h: roundedH
|
|
2251
|
-
};
|
|
2252
|
-
}
|
|
2253
|
-
function computeDarkStop(def, suffix, darkConfig, darkOverride) {
|
|
2254
|
-
const lightStop = generateStop(def, suffix);
|
|
2255
|
-
const darkL = generateStop(def, 1e3 - suffix).l;
|
|
2256
|
-
let extraChroma = 0;
|
|
2257
|
-
let extraHue = 0;
|
|
2258
|
-
if (darkOverride?.strategy === "shift") {
|
|
2259
|
-
extraChroma = darkOverride.chromaDelta;
|
|
2260
|
-
extraHue = darkOverride.hueDelta;
|
|
2261
|
-
}
|
|
2262
|
-
const darkH = lightStop.h + darkConfig.hueShift + extraHue;
|
|
2263
|
-
const globalChromaBoost = def.chromaBoost !== false ? darkConfig.chromaBoost : 0;
|
|
2264
|
-
const requestedChroma = lightStop.c + globalChromaBoost + extraChroma;
|
|
2265
|
-
const darkC = Math.floor(gamutSafeChroma(darkL, requestedChroma, darkH) * 1e4) / 1e4;
|
|
2266
|
-
return { stop: suffix, l: darkL, c: darkC, h: darkH };
|
|
2267
|
-
}
|
|
2268
|
-
function formatOklch(l, c, h) {
|
|
2269
|
-
return `oklch(${l} ${c} ${h})`;
|
|
2270
|
-
}
|
|
2271
|
-
function generateColorVariables(name, def, suffixes, darkConfig = DEFAULT_DARK_CONFIG, darkOverride) {
|
|
2272
|
-
const vars = [];
|
|
2273
|
-
const strategy = darkOverride?.strategy ?? "mirror";
|
|
2274
|
-
for (const suffix of suffixes) {
|
|
2275
|
-
const lightStop = generateStop(def, suffix);
|
|
2276
|
-
const lightValue = formatOklch(lightStop.l, lightStop.c, lightStop.h);
|
|
2277
|
-
if (darkConfig.mode === "off" || strategy === "fixed") {
|
|
2278
|
-
if (darkConfig.mode === "off") {
|
|
2279
|
-
vars.push(`--color-${name}-${suffix}: ${lightValue};`);
|
|
2280
|
-
} else {
|
|
2281
|
-
vars.push(`--color-${name}-${suffix}: light-dark(${lightValue}, ${lightValue});`);
|
|
2282
|
-
}
|
|
2283
|
-
} else {
|
|
2284
|
-
const darkStop = computeDarkStop(def, suffix, darkConfig, darkOverride);
|
|
2285
|
-
const darkValue = formatOklch(darkStop.l, darkStop.c, darkStop.h);
|
|
2286
|
-
vars.push(`--color-${name}-${suffix}: light-dark(${lightValue}, ${darkValue});`);
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
return vars;
|
|
2290
|
-
}
|
|
2291
|
-
var SEMANTIC_COLORS = Object.freeze([
|
|
2292
|
-
"--color-paper: light-dark(oklch(1 0 0), oklch(0 0 0));",
|
|
2293
|
-
"--color-ink: light-dark(oklch(0 0 0), oklch(1 0 0));"
|
|
2294
|
-
]);
|
|
2295
|
-
var DEFAULT_PALETTE_CONTRAST_LC = 60;
|
|
2296
|
-
function checkPaletteContrast(colors, usedColorStops, options = {}) {
|
|
2297
|
-
const minLc = options.minLc ?? DEFAULT_PALETTE_CONTRAST_LC;
|
|
2298
|
-
const warnings = [];
|
|
2299
|
-
const paperY = oklchToApcaY(1, 0, 0);
|
|
2300
|
-
const inkY = oklchToApcaY(0, 0, 0);
|
|
2301
|
-
for (const [name, def] of Object.entries(colors)) {
|
|
2302
|
-
if (def.type !== "generative") continue;
|
|
2303
|
-
const stops = usedColorStops.get(name);
|
|
2304
|
-
if (!stops || stops.size === 0) continue;
|
|
2305
|
-
const sorted = [...stops].sort((a, b) => a - b);
|
|
2306
|
-
for (const suffix of sorted) {
|
|
2307
|
-
const stop = generateStop(def, suffix);
|
|
2308
|
-
const fgY = oklchToApcaY(stop.l, stop.c, stop.h);
|
|
2309
|
-
const lcPaper = Math.abs(apcaContrast(fgY, paperY));
|
|
2310
|
-
const lcInk = Math.abs(apcaContrast(fgY, inkY));
|
|
2311
|
-
const best = Math.max(lcPaper, lcInk);
|
|
2312
|
-
if (best < minLc) {
|
|
2313
|
-
warnings.push(
|
|
2314
|
-
`[RI-1106] @color "${name}-${suffix}" has low APCA contrast (best |Lc| ${best.toFixed(0)} < ${minLc}; paper ${lcPaper.toFixed(0)}, ink ${lcInk.toFixed(0)}). Stop is unsuitable as text on either --color-paper or --color-ink \u2014 use a darker (lower suffix) or lighter (higher suffix) variant for text roles.`
|
|
2315
|
-
);
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
return warnings;
|
|
2320
|
-
}
|
|
2321
|
-
function generateAllColorVariables(colors = DEFAULT_COLORS, darkConfig = DEFAULT_DARK_CONFIG, usedColorStops) {
|
|
2322
|
-
const allVars = [];
|
|
2323
|
-
allVars.push(...SEMANTIC_COLORS);
|
|
2324
|
-
for (const [name, def] of Object.entries(colors)) {
|
|
2325
|
-
switch (def.type) {
|
|
2326
|
-
case "generative": {
|
|
2327
|
-
const suffixes = usedColorStops?.get(name);
|
|
2328
|
-
if (!suffixes || suffixes.size === 0) break;
|
|
2329
|
-
const sorted = [...suffixes].sort((a, b) => a - b);
|
|
2330
|
-
allVars.push(...generateColorVariables(name, def, sorted, darkConfig, def.dark));
|
|
2331
|
-
break;
|
|
2332
|
-
}
|
|
2333
|
-
case "explicit": {
|
|
2334
|
-
allVars.push(`--color-${name}: ${def.value};`);
|
|
2335
|
-
break;
|
|
2336
|
-
}
|
|
2337
|
-
case "pair": {
|
|
2338
|
-
if (darkConfig.mode === "off") {
|
|
2339
|
-
allVars.push(`--color-${name}: ${def.light};`);
|
|
2340
|
-
} else {
|
|
2341
|
-
allVars.push(`--color-${name}: light-dark(${def.light}, ${def.dark});`);
|
|
2342
|
-
}
|
|
2343
|
-
break;
|
|
2344
|
-
}
|
|
2345
|
-
case "alias": {
|
|
2346
|
-
const source = colors[def.source];
|
|
2347
|
-
if (source && source.type === "generative") {
|
|
2348
|
-
const suffixes = usedColorStops?.get(name);
|
|
2349
|
-
if (!suffixes || suffixes.size === 0) break;
|
|
2350
|
-
const sorted = [...suffixes].sort((a, b) => a - b);
|
|
2351
|
-
for (const suffix of sorted) {
|
|
2352
|
-
allVars.push(`--color-${name}-${suffix}: var(--color-${def.source}-${suffix});`);
|
|
2353
|
-
}
|
|
2354
|
-
} else if (source) {
|
|
2355
|
-
allVars.push(`--color-${name}: var(--color-${def.source});`);
|
|
2356
|
-
}
|
|
2357
|
-
break;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return allVars;
|
|
2362
|
-
}
|
|
2363
|
-
function generateThemeOverrides(colors, usedThemeSuffixes) {
|
|
2364
|
-
if (!Object.hasOwn(colors, "theme")) return [];
|
|
2365
|
-
if (!usedThemeSuffixes || usedThemeSuffixes.size === 0) return [];
|
|
2366
|
-
const sorted = [...usedThemeSuffixes].sort((a, b) => a - b);
|
|
2367
|
-
const blocks = [];
|
|
2368
|
-
for (const [name, def] of Object.entries(colors)) {
|
|
2369
|
-
if (name === "theme") continue;
|
|
2370
|
-
if (def.type !== "generative") continue;
|
|
2371
|
-
if (!def.inline) continue;
|
|
2372
|
-
const vars = [];
|
|
2373
|
-
for (const suffix of sorted) {
|
|
2374
|
-
vars.push(` --color-theme-${suffix}: var(--color-${name}-${suffix});`);
|
|
2375
|
-
}
|
|
2376
|
-
const safeName = name.replace(/[\\"'\]]/g, "");
|
|
2377
|
-
if (!safeName) continue;
|
|
2378
|
-
blocks.push(`[data-theme="${safeName}"] {
|
|
2379
|
-
${vars.join("\n")}
|
|
2380
|
-
}`);
|
|
2381
|
-
}
|
|
2382
|
-
return blocks;
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
// src/theme/index.ts
|
|
2386
|
-
var CORNER_SHAPE_KEYWORDS = [
|
|
2387
|
-
"round",
|
|
2388
|
-
"scoop",
|
|
2389
|
-
"bevel",
|
|
2390
|
-
"notch",
|
|
2391
|
-
"square",
|
|
2392
|
-
"squircle"
|
|
2393
|
-
];
|
|
2394
|
-
var DEFAULT_CORNER_SCALE = {
|
|
2395
|
-
round: 1,
|
|
2396
|
-
square: 1,
|
|
2397
|
-
notch: 1,
|
|
2398
|
-
bevel: 0.8,
|
|
2399
|
-
scoop: 1.2,
|
|
2400
|
-
squircle: 1.6
|
|
2401
|
-
};
|
|
2402
|
-
var DEFAULT_SUPERELLIPSE_SCALE = 1.6;
|
|
2403
|
-
var defaultTheme = Object.freeze({
|
|
2404
|
-
spacing: {
|
|
2405
|
-
base: "0.25rem"
|
|
2406
|
-
},
|
|
2407
|
-
colors: DEFAULT_COLORS,
|
|
2408
|
-
// Every named scale below ships empty: the tokens come from @text,
|
|
2409
|
-
// @breakpoint, @shadow, @weight, @ease, @animate and @blur. @fluid carries
|
|
2410
|
-
// no viewport range until one is declared, so fluid utilities stay inert.
|
|
2411
|
-
text: {},
|
|
2412
|
-
breakpoints: {},
|
|
2413
|
-
shadows: {},
|
|
2414
|
-
weights: {},
|
|
2415
|
-
easing: {},
|
|
2416
|
-
fluid: {},
|
|
2417
|
-
animations: {},
|
|
2418
|
-
blur: {}
|
|
2419
|
-
});
|
|
2420
|
-
|
|
2421
2076
|
export {
|
|
2422
2077
|
IS_DEV,
|
|
2423
2078
|
devWarn,
|
|
@@ -2428,14 +2083,16 @@ export {
|
|
|
2428
2083
|
SCROLL_MARGIN_MAP,
|
|
2429
2084
|
SCROLL_PADDING_MAP,
|
|
2430
2085
|
BORDER_DIR_PROPS,
|
|
2086
|
+
FILTER_COMPOSED,
|
|
2087
|
+
BACKDROP_FILTER_COMPOSED,
|
|
2088
|
+
BUILTIN_STATIC_KEYS,
|
|
2089
|
+
PREFIX_PROP_KEYS,
|
|
2090
|
+
buildFirstSegmentMap,
|
|
2431
2091
|
COLOR_FUNCTION_ALTERNATION,
|
|
2432
2092
|
SPECIAL_COLORS,
|
|
2433
2093
|
isMaskRadialSizeValue,
|
|
2434
2094
|
RE_IMAGE_VALUE,
|
|
2435
2095
|
isFontFamilyValue,
|
|
2436
|
-
BUILTIN_STATIC_KEYS,
|
|
2437
|
-
PREFIX_PROP_KEYS,
|
|
2438
|
-
buildFirstSegmentMap,
|
|
2439
2096
|
resolverFor,
|
|
2440
2097
|
createCompilationContext,
|
|
2441
2098
|
registerCustomUtility,
|
|
@@ -2443,24 +2100,11 @@ export {
|
|
|
2443
2100
|
registerCustomFontFamilies,
|
|
2444
2101
|
registerColorNames,
|
|
2445
2102
|
snapshotCompilationContext,
|
|
2103
|
+
publishSnapshot,
|
|
2446
2104
|
finalizeCompilationContext,
|
|
2105
|
+
serializeSnapshot,
|
|
2106
|
+
hydrateSnapshot,
|
|
2447
2107
|
mergeUncached,
|
|
2448
2108
|
ri,
|
|
2449
|
-
createRi
|
|
2450
|
-
isValidColorSuffix,
|
|
2451
|
-
DEFAULT_COLORS,
|
|
2452
|
-
DEFAULT_DARK_CONFIG,
|
|
2453
|
-
oklchToOklab,
|
|
2454
|
-
oklabToLinearSrgb,
|
|
2455
|
-
linearToSrgb,
|
|
2456
|
-
generateStop,
|
|
2457
|
-
computeDarkStop,
|
|
2458
|
-
formatOklch,
|
|
2459
|
-
checkPaletteContrast,
|
|
2460
|
-
generateAllColorVariables,
|
|
2461
|
-
generateThemeOverrides,
|
|
2462
|
-
CORNER_SHAPE_KEYWORDS,
|
|
2463
|
-
DEFAULT_CORNER_SCALE,
|
|
2464
|
-
DEFAULT_SUPERELLIPSE_SCALE,
|
|
2465
|
-
defaultTheme
|
|
2109
|
+
createRi
|
|
2466
2110
|
};
|