@csszyx/runtime 0.9.9 → 0.10.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/README.md +14 -22
- package/dist/index.cjs +518 -52
- package/dist/index.d.cts +186 -75
- package/dist/index.d.mts +186 -75
- package/dist/index.mjs +511 -52
- package/dist/lite.cjs +0 -4
- package/dist/lite.d.cts +1 -15
- package/dist/lite.d.mts +1 -15
- package/dist/lite.mjs +1 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transform as transform$1 } from '@csszyx/compiler/browser';
|
|
1
|
+
import { MAX_SZ_DEPTH, SzDepthError, transform as transform$1, isForbiddenSzKey } from '@csszyx/compiler/browser';
|
|
2
2
|
export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
3
3
|
|
|
4
4
|
function verifyRecoveryToken(element, manifest) {
|
|
@@ -92,6 +92,25 @@ function disableCSRRecovery() {
|
|
|
92
92
|
function isCSRRecoveryAllowed() {
|
|
93
93
|
return state.recoveryAllowed;
|
|
94
94
|
}
|
|
95
|
+
const MAX_MANGLE_MAP_ENTRIES = 1e5;
|
|
96
|
+
function isValidMangleMap(value) {
|
|
97
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const entries = Object.entries(value);
|
|
101
|
+
if (entries.length > MAX_MANGLE_MAP_ENTRIES) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
for (const [key, val] of entries) {
|
|
105
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (typeof key !== "string" || typeof val !== "string") {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
95
114
|
function loadMangleMapFromDOM() {
|
|
96
115
|
if (typeof document === "undefined") {
|
|
97
116
|
return null;
|
|
@@ -102,7 +121,14 @@ function loadMangleMapFromDOM() {
|
|
|
102
121
|
}
|
|
103
122
|
try {
|
|
104
123
|
const content = scriptElement.textContent || "";
|
|
105
|
-
|
|
124
|
+
const parsed = JSON.parse(content);
|
|
125
|
+
if (!isValidMangleMap(parsed)) {
|
|
126
|
+
console.error(
|
|
127
|
+
"[csszyx] Mangle map failed schema validation (not a plain string\u2192string map); ignoring it."
|
|
128
|
+
);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return parsed;
|
|
106
132
|
} catch (error) {
|
|
107
133
|
console.error("Failed to parse mangle map:", error);
|
|
108
134
|
return null;
|
|
@@ -116,6 +142,24 @@ function verifyMangleChecksum(expectedChecksum) {
|
|
|
116
142
|
const actualChecksum = htmlElement.getAttribute("data-sz-checksum");
|
|
117
143
|
return actualChecksum === expectedChecksum;
|
|
118
144
|
}
|
|
145
|
+
async function computeMangleChecksumAsync(map) {
|
|
146
|
+
const canonical = Object.keys(map).sort().map((key) => `${key}:${map[key]}`).join("|");
|
|
147
|
+
const bytes = new TextEncoder().encode(canonical);
|
|
148
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
149
|
+
let hex = "";
|
|
150
|
+
for (const b of new Uint8Array(digest)) {
|
|
151
|
+
hex += b.toString(16).padStart(2, "0");
|
|
152
|
+
}
|
|
153
|
+
return hex.slice(0, 16);
|
|
154
|
+
}
|
|
155
|
+
async function verifyMangleChecksumAsync(expectedChecksum, map) {
|
|
156
|
+
const target = map ?? loadMangleMapFromDOM();
|
|
157
|
+
if (!target) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const actual = await computeMangleChecksumAsync(target);
|
|
161
|
+
return actual === expectedChecksum;
|
|
162
|
+
}
|
|
119
163
|
function verifyMangleMapIntegrity() {
|
|
120
164
|
if (typeof document === "undefined") {
|
|
121
165
|
return false;
|
|
@@ -132,12 +176,23 @@ function verifyMangleMapIntegrity() {
|
|
|
132
176
|
return false;
|
|
133
177
|
}
|
|
134
178
|
try {
|
|
135
|
-
const
|
|
179
|
+
const parsed = JSON.parse(scriptElement.textContent || "{}");
|
|
180
|
+
if (!isValidMangleMap(parsed)) {
|
|
181
|
+
console.error(
|
|
182
|
+
"[csszyx] Mangle map failed schema validation; treating integrity as invalid."
|
|
183
|
+
);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const mangleMap = parsed;
|
|
136
187
|
if (typeof window !== "undefined" && "verify_mangle_checksum" in window) {
|
|
137
188
|
const isValid = window.verify_mangle_checksum(mangleMap, checksum);
|
|
138
189
|
return isValid;
|
|
139
190
|
}
|
|
140
|
-
|
|
191
|
+
if (process.env.NODE_ENV !== "production") {
|
|
192
|
+
console.warn(
|
|
193
|
+
"[csszyx] WASM core not loaded \u2014 mangle map checksum is unverified (schema-validated only). This is detection, not authentication."
|
|
194
|
+
);
|
|
195
|
+
}
|
|
141
196
|
return true;
|
|
142
197
|
} catch (error) {
|
|
143
198
|
console.error("[csszyx] Failed to verify mangle map:", error);
|
|
@@ -275,6 +330,12 @@ function transform(szProp) {
|
|
|
275
330
|
return res;
|
|
276
331
|
}
|
|
277
332
|
function _sz(...classes) {
|
|
333
|
+
return szJoin(classes, 0);
|
|
334
|
+
}
|
|
335
|
+
function szJoin(classes, depth) {
|
|
336
|
+
if (depth >= MAX_SZ_DEPTH) {
|
|
337
|
+
throw new SzDepthError();
|
|
338
|
+
}
|
|
278
339
|
if (classes.length === 1) {
|
|
279
340
|
const cls = classes[0];
|
|
280
341
|
if (typeof cls === "string") {
|
|
@@ -284,7 +345,7 @@ function _sz(...classes) {
|
|
|
284
345
|
return "";
|
|
285
346
|
}
|
|
286
347
|
if (Array.isArray(cls)) {
|
|
287
|
-
return
|
|
348
|
+
return szJoin(cls, depth + 1);
|
|
288
349
|
}
|
|
289
350
|
const res = transform(cls);
|
|
290
351
|
return typeof res === "string" ? res : res.className;
|
|
@@ -297,7 +358,7 @@ function _sz(...classes) {
|
|
|
297
358
|
continue;
|
|
298
359
|
}
|
|
299
360
|
if (Array.isArray(cls)) {
|
|
300
|
-
const str2 =
|
|
361
|
+
const str2 = szJoin(cls, depth + 1);
|
|
301
362
|
if (!str2) {
|
|
302
363
|
continue;
|
|
303
364
|
}
|
|
@@ -321,50 +382,13 @@ function _sz(...classes) {
|
|
|
321
382
|
}
|
|
322
383
|
return result;
|
|
323
384
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
if (!value) {
|
|
327
|
-
return "";
|
|
328
|
-
}
|
|
329
|
-
if (typeof value === "string") {
|
|
330
|
-
return value;
|
|
331
|
-
}
|
|
332
|
-
if (Array.isArray(value)) {
|
|
333
|
-
return _sz(...value);
|
|
334
|
-
}
|
|
335
|
-
const res = transform(value);
|
|
336
|
-
return typeof res === "string" ? res : res.className;
|
|
385
|
+
function _szMerge(...classes) {
|
|
386
|
+
return szMergeJoin(classes, 0);
|
|
337
387
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (condition) {
|
|
342
|
-
if (!value) {
|
|
343
|
-
return "";
|
|
344
|
-
}
|
|
345
|
-
if (typeof value === "string") {
|
|
346
|
-
return value;
|
|
347
|
-
}
|
|
348
|
-
if (Array.isArray(value)) {
|
|
349
|
-
return _sz(...value);
|
|
350
|
-
}
|
|
351
|
-
const res2 = transform(value);
|
|
352
|
-
return typeof res2 === "string" ? res2 : res2.className;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
if (!defaultValue) {
|
|
356
|
-
return "";
|
|
388
|
+
function szMergeJoin(classes, depth) {
|
|
389
|
+
if (depth >= MAX_SZ_DEPTH) {
|
|
390
|
+
throw new SzDepthError();
|
|
357
391
|
}
|
|
358
|
-
if (typeof defaultValue === "string") {
|
|
359
|
-
return defaultValue;
|
|
360
|
-
}
|
|
361
|
-
if (Array.isArray(defaultValue)) {
|
|
362
|
-
return _sz(...defaultValue);
|
|
363
|
-
}
|
|
364
|
-
const res = transform(defaultValue);
|
|
365
|
-
return typeof res === "string" ? res : res.className;
|
|
366
|
-
}
|
|
367
|
-
function _szMerge(...classes) {
|
|
368
392
|
const seen = /* @__PURE__ */ new Set();
|
|
369
393
|
const result = [];
|
|
370
394
|
for (let i = 0; i < classes.length; i++) {
|
|
@@ -373,7 +397,7 @@ function _szMerge(...classes) {
|
|
|
373
397
|
continue;
|
|
374
398
|
}
|
|
375
399
|
if (Array.isArray(cls)) {
|
|
376
|
-
const str2 =
|
|
400
|
+
const str2 = szMergeJoin(cls, depth + 1);
|
|
377
401
|
if (!str2) {
|
|
378
402
|
continue;
|
|
379
403
|
}
|
|
@@ -435,13 +459,445 @@ function _sz3(a, b, c) {
|
|
|
435
459
|
return result;
|
|
436
460
|
}
|
|
437
461
|
|
|
438
|
-
|
|
462
|
+
const BOX_ROLE_TOKENS = /* @__PURE__ */ new Map([
|
|
463
|
+
["absolute", { role: "outer", category: "position" }],
|
|
464
|
+
["antialiased", { role: "inner", category: "text" }],
|
|
465
|
+
["block", { role: "inner", category: "display" }],
|
|
466
|
+
["capitalize", { role: "inner", category: "text" }],
|
|
467
|
+
["collapse", { role: "outer", category: "visibility" }],
|
|
468
|
+
["container", { role: "outer", category: "sizing" }],
|
|
469
|
+
["contents", { role: "inner", category: "display" }],
|
|
470
|
+
["diagonal-fractions", { role: "inner", category: "text" }],
|
|
471
|
+
["divide-x-reverse", { role: "outer", category: "divide" }],
|
|
472
|
+
["divide-y-reverse", { role: "outer", category: "divide" }],
|
|
473
|
+
["fixed", { role: "outer", category: "position" }],
|
|
474
|
+
["flex", { role: "inner", category: "display" }],
|
|
475
|
+
["flow-root", { role: "inner", category: "display" }],
|
|
476
|
+
["grid", { role: "inner", category: "display" }],
|
|
477
|
+
["hidden", { role: "inner", category: "display" }],
|
|
478
|
+
["inline", { role: "inner", category: "display" }],
|
|
479
|
+
["inline-block", { role: "inner", category: "display" }],
|
|
480
|
+
["inline-flex", { role: "inner", category: "display" }],
|
|
481
|
+
["inline-grid", { role: "inner", category: "display" }],
|
|
482
|
+
["invisible", { role: "outer", category: "visibility" }],
|
|
483
|
+
["isolate", { role: "outer", category: "position" }],
|
|
484
|
+
["italic", { role: "inner", category: "text" }],
|
|
485
|
+
["line-through", { role: "inner", category: "text" }],
|
|
486
|
+
["lining-nums", { role: "inner", category: "text" }],
|
|
487
|
+
["list-item", { role: "inner", category: "display" }],
|
|
488
|
+
["lowercase", { role: "inner", category: "text" }],
|
|
489
|
+
["no-underline", { role: "inner", category: "text" }],
|
|
490
|
+
["normal-case", { role: "inner", category: "text" }],
|
|
491
|
+
["not-italic", { role: "inner", category: "text" }],
|
|
492
|
+
["not-sr-only", { role: "outer", category: "visibility" }],
|
|
493
|
+
["oldstyle-nums", { role: "inner", category: "text" }],
|
|
494
|
+
["ordinal", { role: "inner", category: "text" }],
|
|
495
|
+
["overline", { role: "inner", category: "text" }],
|
|
496
|
+
["proportional-nums", { role: "inner", category: "text" }],
|
|
497
|
+
["prose", { role: "inner", category: "text" }],
|
|
498
|
+
["prose-invert", { role: "inner", category: "text" }],
|
|
499
|
+
["relative", { role: "outer", category: "position" }],
|
|
500
|
+
["slashed-zero", { role: "inner", category: "text" }],
|
|
501
|
+
["space-x-reverse", { role: "inner", category: "space" }],
|
|
502
|
+
["space-y-reverse", { role: "inner", category: "space" }],
|
|
503
|
+
["sr-only", { role: "outer", category: "visibility" }],
|
|
504
|
+
["stacked-fractions", { role: "inner", category: "text" }],
|
|
505
|
+
["static", { role: "outer", category: "position" }],
|
|
506
|
+
["sticky", { role: "outer", category: "position" }],
|
|
507
|
+
["subpixel-antialiased", { role: "inner", category: "text" }],
|
|
508
|
+
["table", { role: "inner", category: "display" }],
|
|
509
|
+
["table-cell", { role: "inner", category: "display" }],
|
|
510
|
+
["table-row", { role: "inner", category: "display" }],
|
|
511
|
+
["tabular-nums", { role: "inner", category: "text" }],
|
|
512
|
+
["truncate", { role: "inner", category: "text" }],
|
|
513
|
+
["underline", { role: "inner", category: "text" }],
|
|
514
|
+
["uppercase", { role: "inner", category: "text" }],
|
|
515
|
+
["visible", { role: "outer", category: "visibility" }]
|
|
516
|
+
]);
|
|
517
|
+
const BOX_ROLE_PREFIXES = [
|
|
518
|
+
["backdrop-brightness", { role: "outer", category: "backdrop" }],
|
|
519
|
+
["backdrop-hue-rotate", { role: "outer", category: "backdrop" }],
|
|
520
|
+
["forced-color-adjust", { role: "outer", category: "color-scheme" }],
|
|
521
|
+
["backdrop-grayscale", { role: "outer", category: "backdrop" }],
|
|
522
|
+
["perspective-origin", { role: "outer", category: "transform" }],
|
|
523
|
+
["backdrop-contrast", { role: "outer", category: "backdrop" }],
|
|
524
|
+
["backdrop-saturate", { role: "outer", category: "backdrop" }],
|
|
525
|
+
["backdrop-opacity", { role: "outer", category: "backdrop" }],
|
|
526
|
+
["border-spacing-x", { role: "outer", category: "border" }],
|
|
527
|
+
["border-spacing-y", { role: "outer", category: "border" }],
|
|
528
|
+
["scrollbar-gutter", { role: "inner", category: "scroll" }],
|
|
529
|
+
["underline-offset", { role: "inner", category: "text" }],
|
|
530
|
+
["animation-delay", { role: "outer", category: "transition" }],
|
|
531
|
+
["backdrop-filter", { role: "outer", category: "backdrop" }],
|
|
532
|
+
["backdrop-invert", { role: "outer", category: "backdrop" }],
|
|
533
|
+
["scrollbar-thumb", { role: "inner", category: "scroll" }],
|
|
534
|
+
["scrollbar-track", { role: "inner", category: "scroll" }],
|
|
535
|
+
["backdrop-sepia", { role: "outer", category: "backdrop" }],
|
|
536
|
+
["border-spacing", { role: "outer", category: "border" }],
|
|
537
|
+
["box-decoration", { role: "outer", category: "fragmentation" }],
|
|
538
|
+
["font-smoothing", { role: "inner", category: "text" }],
|
|
539
|
+
["outline-offset", { role: "outer", category: "outline" }],
|
|
540
|
+
["pointer-events", { role: "inner", category: "interaction" }],
|
|
541
|
+
["backdrop-blur", { role: "outer", category: "backdrop" }],
|
|
542
|
+
["font-features", { role: "inner", category: "text" }],
|
|
543
|
+
["justify-items", { role: "inner", category: "alignment" }],
|
|
544
|
+
["mask-position", { role: "outer", category: "mask" }],
|
|
545
|
+
["place-content", { role: "inner", category: "alignment" }],
|
|
546
|
+
["break-before", { role: "outer", category: "fragmentation" }],
|
|
547
|
+
["break-inside", { role: "outer", category: "fragmentation" }],
|
|
548
|
+
["field-sizing", { role: "inner", category: "interaction" }],
|
|
549
|
+
["font-stretch", { role: "inner", category: "text" }],
|
|
550
|
+
["inset-shadow", { role: "inner", category: "shadow" }],
|
|
551
|
+
["justify-self", { role: "inner", category: "alignment" }],
|
|
552
|
+
["overscroll-x", { role: "inner", category: "overscroll" }],
|
|
553
|
+
["overscroll-y", { role: "inner", category: "overscroll" }],
|
|
554
|
+
["break-after", { role: "outer", category: "fragmentation" }],
|
|
555
|
+
["drop-shadow", { role: "outer", category: "filter" }],
|
|
556
|
+
["mask-origin", { role: "outer", category: "mask" }],
|
|
557
|
+
["mask-repeat", { role: "outer", category: "mask" }],
|
|
558
|
+
["perspective", { role: "outer", category: "transform" }],
|
|
559
|
+
["place-items", { role: "inner", category: "alignment" }],
|
|
560
|
+
["ring-offset", { role: "outer", category: "ring" }],
|
|
561
|
+
["text-shadow", { role: "inner", category: "text" }],
|
|
562
|
+
["translate-x", { role: "outer", category: "transform" }],
|
|
563
|
+
["translate-y", { role: "outer", category: "transform" }],
|
|
564
|
+
["translate-z", { role: "outer", category: "transform" }],
|
|
565
|
+
["will-change", { role: "inner", category: "interaction" }],
|
|
566
|
+
["appearance", { role: "inner", category: "interaction" }],
|
|
567
|
+
["brightness", { role: "outer", category: "filter" }],
|
|
568
|
+
["decoration", { role: "inner", category: "text" }],
|
|
569
|
+
["font-style", { role: "inner", category: "text" }],
|
|
570
|
+
["hue-rotate", { role: "outer", category: "filter" }],
|
|
571
|
+
["inset-ring", { role: "inner", category: "ring" }],
|
|
572
|
+
["line-clamp", { role: "inner", category: "text" }],
|
|
573
|
+
["list-image", { role: "inner", category: "list" }],
|
|
574
|
+
["max-inline", { role: "outer", category: "sizing" }],
|
|
575
|
+
["min-inline", { role: "outer", category: "sizing" }],
|
|
576
|
+
["overflow-x", { role: "inner", category: "overflow" }],
|
|
577
|
+
["overflow-y", { role: "inner", category: "overflow" }],
|
|
578
|
+
["overscroll", { role: "inner", category: "overscroll" }],
|
|
579
|
+
["place-self", { role: "inner", category: "alignment" }],
|
|
580
|
+
["rounded-bl", { role: "outer", category: "rounded" }],
|
|
581
|
+
["rounded-br", { role: "outer", category: "rounded" }],
|
|
582
|
+
["rounded-ee", { role: "outer", category: "rounded" }],
|
|
583
|
+
["rounded-es", { role: "outer", category: "rounded" }],
|
|
584
|
+
["rounded-se", { role: "outer", category: "rounded" }],
|
|
585
|
+
["rounded-ss", { role: "outer", category: "rounded" }],
|
|
586
|
+
["rounded-tl", { role: "outer", category: "rounded" }],
|
|
587
|
+
["rounded-tr", { role: "outer", category: "rounded" }],
|
|
588
|
+
["scroll-mbe", { role: "inner", category: "scroll" }],
|
|
589
|
+
["scroll-mbs", { role: "inner", category: "scroll" }],
|
|
590
|
+
["scroll-pbe", { role: "inner", category: "scroll" }],
|
|
591
|
+
["scroll-pbs", { role: "inner", category: "scroll" }],
|
|
592
|
+
["transition", { role: "outer", category: "transition" }],
|
|
593
|
+
["visibility", { role: "outer", category: "visibility" }],
|
|
594
|
+
["whitespace", { role: "inner", category: "text" }],
|
|
595
|
+
["auto-cols", { role: "inner", category: "grid" }],
|
|
596
|
+
["auto-rows", { role: "inner", category: "grid" }],
|
|
597
|
+
["bg-origin", { role: "outer", category: "bg" }],
|
|
598
|
+
["border-be", { role: "outer", category: "border" }],
|
|
599
|
+
["border-bs", { role: "outer", category: "border" }],
|
|
600
|
+
["col-start", { role: "inner", category: "grid" }],
|
|
601
|
+
["grayscale", { role: "outer", category: "filter" }],
|
|
602
|
+
["grid-cols", { role: "inner", category: "grid" }],
|
|
603
|
+
["grid-flow", { role: "inner", category: "grid" }],
|
|
604
|
+
["grid-rows", { role: "inner", category: "grid" }],
|
|
605
|
+
["isolation", { role: "outer", category: "position" }],
|
|
606
|
+
["mask-clip", { role: "outer", category: "mask" }],
|
|
607
|
+
["mask-from", { role: "outer", category: "mask" }],
|
|
608
|
+
["mask-size", { role: "outer", category: "mask" }],
|
|
609
|
+
["max-block", { role: "outer", category: "sizing" }],
|
|
610
|
+
["min-block", { role: "outer", category: "sizing" }],
|
|
611
|
+
["mix-blend", { role: "outer", category: "blend" }],
|
|
612
|
+
["rounded-b", { role: "outer", category: "rounded" }],
|
|
613
|
+
["rounded-e", { role: "outer", category: "rounded" }],
|
|
614
|
+
["rounded-l", { role: "outer", category: "rounded" }],
|
|
615
|
+
["rounded-r", { role: "outer", category: "rounded" }],
|
|
616
|
+
["rounded-s", { role: "outer", category: "rounded" }],
|
|
617
|
+
["rounded-t", { role: "outer", category: "rounded" }],
|
|
618
|
+
["row-start", { role: "inner", category: "grid" }],
|
|
619
|
+
["scroll-mb", { role: "inner", category: "scroll" }],
|
|
620
|
+
["scroll-me", { role: "inner", category: "scroll" }],
|
|
621
|
+
["scroll-ml", { role: "inner", category: "scroll" }],
|
|
622
|
+
["scroll-mr", { role: "inner", category: "scroll" }],
|
|
623
|
+
["scroll-ms", { role: "inner", category: "scroll" }],
|
|
624
|
+
["scroll-mt", { role: "inner", category: "scroll" }],
|
|
625
|
+
["scroll-mx", { role: "inner", category: "scroll" }],
|
|
626
|
+
["scroll-my", { role: "inner", category: "scroll" }],
|
|
627
|
+
["scroll-pb", { role: "inner", category: "scroll" }],
|
|
628
|
+
["scroll-pe", { role: "inner", category: "scroll" }],
|
|
629
|
+
["scroll-pl", { role: "inner", category: "scroll" }],
|
|
630
|
+
["scroll-pr", { role: "inner", category: "scroll" }],
|
|
631
|
+
["scroll-ps", { role: "inner", category: "scroll" }],
|
|
632
|
+
["scroll-pt", { role: "inner", category: "scroll" }],
|
|
633
|
+
["scroll-px", { role: "inner", category: "scroll" }],
|
|
634
|
+
["scroll-py", { role: "inner", category: "scroll" }],
|
|
635
|
+
["scrollbar", { role: "inner", category: "scroll" }],
|
|
636
|
+
["transform", { role: "outer", category: "transform" }],
|
|
637
|
+
["translate", { role: "outer", category: "transform" }],
|
|
638
|
+
["backface", { role: "outer", category: "transform" }],
|
|
639
|
+
["bg-blend", { role: "outer", category: "bg" }],
|
|
640
|
+
["border-b", { role: "outer", category: "border" }],
|
|
641
|
+
["border-e", { role: "outer", category: "border" }],
|
|
642
|
+
["border-l", { role: "outer", category: "border" }],
|
|
643
|
+
["border-r", { role: "outer", category: "border" }],
|
|
644
|
+
["border-s", { role: "outer", category: "border" }],
|
|
645
|
+
["border-t", { role: "outer", category: "border" }],
|
|
646
|
+
["border-x", { role: "outer", category: "border" }],
|
|
647
|
+
["border-y", { role: "outer", category: "border" }],
|
|
648
|
+
["col-span", { role: "inner", category: "grid" }],
|
|
649
|
+
["contrast", { role: "outer", category: "filter" }],
|
|
650
|
+
["divide-x", { role: "outer", category: "divide" }],
|
|
651
|
+
["divide-y", { role: "outer", category: "divide" }],
|
|
652
|
+
["duration", { role: "outer", category: "transition" }],
|
|
653
|
+
["inset-be", { role: "outer", category: "position" }],
|
|
654
|
+
["inset-bs", { role: "outer", category: "position" }],
|
|
655
|
+
["mask-via", { role: "outer", category: "mask" }],
|
|
656
|
+
["overflow", { role: "inner", category: "overflow" }],
|
|
657
|
+
["position", { role: "outer", category: "position" }],
|
|
658
|
+
["rotate-x", { role: "outer", category: "transform" }],
|
|
659
|
+
["rotate-y", { role: "outer", category: "transform" }],
|
|
660
|
+
["rotate-z", { role: "outer", category: "transform" }],
|
|
661
|
+
["row-span", { role: "inner", category: "grid" }],
|
|
662
|
+
["saturate", { role: "outer", category: "filter" }],
|
|
663
|
+
["scroll-m", { role: "inner", category: "scroll" }],
|
|
664
|
+
["scroll-p", { role: "inner", category: "scroll" }],
|
|
665
|
+
["tracking", { role: "inner", category: "text" }],
|
|
666
|
+
["animate", { role: "outer", category: "transition" }],
|
|
667
|
+
["bg-clip", { role: "outer", category: "bg" }],
|
|
668
|
+
["caption", { role: "inner", category: "table" }],
|
|
669
|
+
["col-end", { role: "inner", category: "grid" }],
|
|
670
|
+
["columns", { role: "inner", category: "columns" }],
|
|
671
|
+
["content", { role: "inner", category: "text" }],
|
|
672
|
+
["display", { role: "inner", category: "display" }],
|
|
673
|
+
["hyphens", { role: "inner", category: "text" }],
|
|
674
|
+
["inset-e", { role: "outer", category: "position" }],
|
|
675
|
+
["inset-s", { role: "outer", category: "position" }],
|
|
676
|
+
["inset-x", { role: "outer", category: "position" }],
|
|
677
|
+
["inset-y", { role: "outer", category: "position" }],
|
|
678
|
+
["justify", { role: "inner", category: "alignment" }],
|
|
679
|
+
["leading", { role: "inner", category: "text" }],
|
|
680
|
+
["mask-to", { role: "outer", category: "mask" }],
|
|
681
|
+
["opacity", { role: "outer", category: "opacity" }],
|
|
682
|
+
["outline", { role: "outer", category: "outline" }],
|
|
683
|
+
["rounded", { role: "outer", category: "rounded" }],
|
|
684
|
+
["row-end", { role: "inner", category: "grid" }],
|
|
685
|
+
["scale-x", { role: "outer", category: "transform" }],
|
|
686
|
+
["scale-y", { role: "outer", category: "transform" }],
|
|
687
|
+
["scale-z", { role: "outer", category: "transform" }],
|
|
688
|
+
["space-x", { role: "inner", category: "space" }],
|
|
689
|
+
["space-y", { role: "inner", category: "space" }],
|
|
690
|
+
["accent", { role: "inner", category: "accent" }],
|
|
691
|
+
["aspect", { role: "outer", category: "sizing" }],
|
|
692
|
+
["border", { role: "outer", category: "border" }],
|
|
693
|
+
["bottom", { role: "outer", category: "position" }],
|
|
694
|
+
["cursor", { role: "inner", category: "interaction" }],
|
|
695
|
+
["divide", { role: "outer", category: "divide" }],
|
|
696
|
+
["filter", { role: "outer", category: "filter" }],
|
|
697
|
+
["indent", { role: "inner", category: "text" }],
|
|
698
|
+
["inline", { role: "outer", category: "sizing" }],
|
|
699
|
+
["invert", { role: "outer", category: "filter" }],
|
|
700
|
+
["object", { role: "inner", category: "object" }],
|
|
701
|
+
["origin", { role: "outer", category: "transform" }],
|
|
702
|
+
["resize", { role: "inner", category: "interaction" }],
|
|
703
|
+
["rotate", { role: "outer", category: "transform" }],
|
|
704
|
+
["scheme", { role: "outer", category: "color-scheme" }],
|
|
705
|
+
["scroll", { role: "inner", category: "scroll" }],
|
|
706
|
+
["select", { role: "inner", category: "interaction" }],
|
|
707
|
+
["shadow", { role: "outer", category: "shadow" }],
|
|
708
|
+
["shrink", { role: "inner", category: "flex" }],
|
|
709
|
+
["skew-x", { role: "outer", category: "transform" }],
|
|
710
|
+
["skew-y", { role: "outer", category: "transform" }],
|
|
711
|
+
["stroke", { role: "inner", category: "svg" }],
|
|
712
|
+
["align", { role: "inner", category: "text" }],
|
|
713
|
+
["basis", { role: "inner", category: "flex" }],
|
|
714
|
+
["block", { role: "outer", category: "sizing" }],
|
|
715
|
+
["break", { role: "inner", category: "text" }],
|
|
716
|
+
["caret", { role: "inner", category: "accent" }],
|
|
717
|
+
["clear", { role: "outer", category: "position" }],
|
|
718
|
+
["delay", { role: "outer", category: "transition" }],
|
|
719
|
+
["float", { role: "outer", category: "position" }],
|
|
720
|
+
["gap-x", { role: "inner", category: "gap" }],
|
|
721
|
+
["gap-y", { role: "inner", category: "gap" }],
|
|
722
|
+
["inset", { role: "outer", category: "position" }],
|
|
723
|
+
["items", { role: "inner", category: "alignment" }],
|
|
724
|
+
["max-h", { role: "outer", category: "sizing" }],
|
|
725
|
+
["max-w", { role: "outer", category: "sizing" }],
|
|
726
|
+
["min-h", { role: "outer", category: "sizing" }],
|
|
727
|
+
["min-w", { role: "outer", category: "sizing" }],
|
|
728
|
+
["order", { role: "inner", category: "flex" }],
|
|
729
|
+
["right", { role: "outer", category: "position" }],
|
|
730
|
+
["scale", { role: "outer", category: "transform" }],
|
|
731
|
+
["sepia", { role: "outer", category: "filter" }],
|
|
732
|
+
["table", { role: "inner", category: "table" }],
|
|
733
|
+
["touch", { role: "inner", category: "touch" }],
|
|
734
|
+
["blur", { role: "outer", category: "filter" }],
|
|
735
|
+
["ease", { role: "outer", category: "transition" }],
|
|
736
|
+
["fill", { role: "inner", category: "svg" }],
|
|
737
|
+
["flex", { role: "inner", category: "flex" }],
|
|
738
|
+
["font", { role: "inner", category: "text" }],
|
|
739
|
+
["from", { role: "outer", category: "gradient" }],
|
|
740
|
+
["grow", { role: "inner", category: "flex" }],
|
|
741
|
+
["left", { role: "outer", category: "position" }],
|
|
742
|
+
["list", { role: "inner", category: "list" }],
|
|
743
|
+
["mask", { role: "outer", category: "mask" }],
|
|
744
|
+
["ring", { role: "outer", category: "ring" }],
|
|
745
|
+
["self", { role: "inner", category: "alignment" }],
|
|
746
|
+
["size", { role: "outer", category: "sizing" }],
|
|
747
|
+
["snap", { role: "inner", category: "snap" }],
|
|
748
|
+
["text", { role: "inner", category: "text" }],
|
|
749
|
+
["wrap", { role: "inner", category: "text" }],
|
|
750
|
+
["zoom", { role: "outer", category: "transform" }],
|
|
751
|
+
["box", { role: "outer", category: "sizing" }],
|
|
752
|
+
["col", { role: "inner", category: "grid" }],
|
|
753
|
+
["gap", { role: "inner", category: "gap" }],
|
|
754
|
+
["mbe", { role: "outer", category: "margin" }],
|
|
755
|
+
["mbs", { role: "outer", category: "margin" }],
|
|
756
|
+
["pbe", { role: "inner", category: "padding" }],
|
|
757
|
+
["pbs", { role: "inner", category: "padding" }],
|
|
758
|
+
["row", { role: "inner", category: "grid" }],
|
|
759
|
+
["tab", { role: "inner", category: "text" }],
|
|
760
|
+
["top", { role: "outer", category: "position" }],
|
|
761
|
+
["via", { role: "outer", category: "gradient" }],
|
|
762
|
+
["bg", { role: "outer", category: "bg" }],
|
|
763
|
+
["mb", { role: "outer", category: "margin" }],
|
|
764
|
+
["me", { role: "outer", category: "margin" }],
|
|
765
|
+
["ml", { role: "outer", category: "margin" }],
|
|
766
|
+
["mr", { role: "outer", category: "margin" }],
|
|
767
|
+
["ms", { role: "outer", category: "margin" }],
|
|
768
|
+
["mt", { role: "outer", category: "margin" }],
|
|
769
|
+
["mx", { role: "outer", category: "margin" }],
|
|
770
|
+
["my", { role: "outer", category: "margin" }],
|
|
771
|
+
["pb", { role: "inner", category: "padding" }],
|
|
772
|
+
["pe", { role: "inner", category: "padding" }],
|
|
773
|
+
["pl", { role: "inner", category: "padding" }],
|
|
774
|
+
["pr", { role: "inner", category: "padding" }],
|
|
775
|
+
["ps", { role: "inner", category: "padding" }],
|
|
776
|
+
["pt", { role: "inner", category: "padding" }],
|
|
777
|
+
["px", { role: "inner", category: "padding" }],
|
|
778
|
+
["py", { role: "inner", category: "padding" }],
|
|
779
|
+
["to", { role: "outer", category: "gradient" }],
|
|
780
|
+
["h", { role: "outer", category: "sizing" }],
|
|
781
|
+
["m", { role: "outer", category: "margin" }],
|
|
782
|
+
["p", { role: "inner", category: "padding" }],
|
|
783
|
+
["w", { role: "outer", category: "sizing" }],
|
|
784
|
+
["z", { role: "outer", category: "position" }]
|
|
785
|
+
];
|
|
786
|
+
|
|
787
|
+
function stripVariant(token) {
|
|
788
|
+
let depth = 0;
|
|
789
|
+
for (let i = token.length - 1; i >= 0; i--) {
|
|
790
|
+
const ch = token[i];
|
|
791
|
+
if (ch === "]" || ch === ")") depth++;
|
|
792
|
+
else if (ch === "[" || ch === "(") depth--;
|
|
793
|
+
else if (ch === ":" && depth === 0) return token.slice(i + 1);
|
|
794
|
+
}
|
|
795
|
+
return token;
|
|
796
|
+
}
|
|
797
|
+
function normalizeBase(base) {
|
|
798
|
+
let b = base;
|
|
799
|
+
if (b.startsWith("!")) b = b.slice(1);
|
|
800
|
+
if (b.endsWith("!")) b = b.slice(0, -1);
|
|
801
|
+
if (b.startsWith("-")) b = b.slice(1);
|
|
802
|
+
return b;
|
|
803
|
+
}
|
|
804
|
+
function inspect(token) {
|
|
805
|
+
const base = normalizeBase(stripVariant(token));
|
|
806
|
+
if (!base) return void 0;
|
|
807
|
+
const exact = BOX_ROLE_TOKENS.get(base);
|
|
808
|
+
if (exact) return { ...exact, base, value: base };
|
|
809
|
+
for (const [prefix, entry] of BOX_ROLE_PREFIXES) {
|
|
810
|
+
if (base === prefix) return { ...entry, base, value: "" };
|
|
811
|
+
if (base.startsWith(`${prefix}-`)) {
|
|
812
|
+
return { ...entry, base, value: base.slice(prefix.length + 1) };
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return void 0;
|
|
816
|
+
}
|
|
817
|
+
function classify(token) {
|
|
818
|
+
const info = inspect(token);
|
|
819
|
+
return info ? { role: info.role, category: info.category } : void 0;
|
|
820
|
+
}
|
|
821
|
+
function matches(info, selector) {
|
|
822
|
+
if (!info) return false;
|
|
823
|
+
if (typeof selector === "object") {
|
|
824
|
+
return Object.entries(selector).every(
|
|
825
|
+
([category, value]) => info.category === category && info.value === value
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
if (selector === "outer" || selector === "inner") {
|
|
829
|
+
return info.role === selector;
|
|
830
|
+
}
|
|
831
|
+
if (selector === "content") return info.role === "inner";
|
|
832
|
+
if (selector === info.category) return true;
|
|
833
|
+
if (info.base === selector) return true;
|
|
834
|
+
return info.base.startsWith(`${selector}-`);
|
|
835
|
+
}
|
|
836
|
+
function anyMatch(info, selectors) {
|
|
837
|
+
return selectors.some((s) => matches(info, s));
|
|
838
|
+
}
|
|
839
|
+
function tokenize(className) {
|
|
840
|
+
return className.split(/\s+/).filter(Boolean);
|
|
841
|
+
}
|
|
842
|
+
function splitBox(className, options = {}) {
|
|
843
|
+
const forceInner = options.inner ?? [];
|
|
844
|
+
const forceOuter = options.outer ?? [];
|
|
845
|
+
const fallback = options.fallback ?? "outer";
|
|
846
|
+
const outer = [];
|
|
847
|
+
const inner = [];
|
|
848
|
+
for (const token of tokenize(className)) {
|
|
849
|
+
const info = inspect(token);
|
|
850
|
+
let role;
|
|
851
|
+
if (anyMatch(info, forceInner)) role = "inner";
|
|
852
|
+
else if (anyMatch(info, forceOuter)) role = "outer";
|
|
853
|
+
else role = info ? info.role : fallback;
|
|
854
|
+
(role === "outer" ? outer : inner).push(token);
|
|
855
|
+
}
|
|
856
|
+
return { outer: outer.join(" "), inner: inner.join(" ") };
|
|
857
|
+
}
|
|
858
|
+
function has(classes, selector) {
|
|
859
|
+
return tokenize(classes).some((t) => matches(inspect(t), selector));
|
|
860
|
+
}
|
|
861
|
+
function pick(classes, selector) {
|
|
862
|
+
return tokenize(classes).filter((t) => matches(inspect(t), selector)).join(" ");
|
|
863
|
+
}
|
|
864
|
+
function omit(classes, selector) {
|
|
865
|
+
return tokenize(classes).filter((t) => !matches(inspect(t), selector)).join(" ");
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const warned = /* @__PURE__ */ new Set();
|
|
869
|
+
const RAW_SZ_WARNING = '[csszyx] A raw `sz` object reached the runtime and was dropped before it could leak to the DOM as sz="[object Object]".\nThis means the file was not compiled \u2014 its `sz` produces no CSS. If it lives in a workspace package, add that package to `compilePackages`; otherwise check that the bundler is not skipping the file.';
|
|
870
|
+
function warnRawSz() {
|
|
871
|
+
if (warned.has(RAW_SZ_WARNING)) return;
|
|
872
|
+
warned.add(RAW_SZ_WARNING);
|
|
873
|
+
console.warn(RAW_SZ_WARNING);
|
|
874
|
+
}
|
|
875
|
+
function stripSzProps(props) {
|
|
876
|
+
if (props == null || typeof props !== "object" || !("sz" in props)) {
|
|
877
|
+
return props;
|
|
878
|
+
}
|
|
879
|
+
const { sz, ...rest } = props;
|
|
880
|
+
if (process.env.NODE_ENV !== "production") {
|
|
881
|
+
if (sz !== null && typeof sz === "object") {
|
|
882
|
+
warnRawSz();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return rest;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
function deepMerge(target, source, depth = 0) {
|
|
889
|
+
if (depth >= MAX_SZ_DEPTH) {
|
|
890
|
+
throw new SzDepthError();
|
|
891
|
+
}
|
|
439
892
|
const result = { ...target };
|
|
440
893
|
for (const key of Object.keys(source)) {
|
|
894
|
+
if (isForbiddenSzKey(key)) {
|
|
895
|
+
continue;
|
|
896
|
+
}
|
|
441
897
|
const sv = source[key];
|
|
442
898
|
const tv = target[key];
|
|
443
899
|
if (sv !== null && sv !== void 0 && typeof sv === "object" && !Array.isArray(sv) && tv !== null && tv !== void 0 && typeof tv === "object" && !Array.isArray(tv)) {
|
|
444
|
-
result[key] = deepMerge(tv, sv);
|
|
900
|
+
result[key] = deepMerge(tv, sv, depth + 1);
|
|
445
901
|
} else {
|
|
446
902
|
result[key] = sv;
|
|
447
903
|
}
|
|
@@ -454,6 +910,9 @@ function szv(config) {
|
|
|
454
910
|
const resolved = { ...config.defaultVariants };
|
|
455
911
|
if (selection) {
|
|
456
912
|
for (const key of Object.keys(selection)) {
|
|
913
|
+
if (isForbiddenSzKey(key)) {
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
457
916
|
const val = selection[key];
|
|
458
917
|
if (val !== null && val !== void 0) {
|
|
459
918
|
resolved[key] = val;
|
|
@@ -515,4 +974,4 @@ function resetRuntime() {
|
|
|
515
974
|
runtimeState.initialized = false;
|
|
516
975
|
}
|
|
517
976
|
|
|
518
|
-
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3,
|
|
977
|
+
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, pick, resetRuntime, splitBox, startHydration, stripSzProps, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|