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