@csszyx/runtime 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -783,6 +783,338 @@ const BOX_ROLE_PREFIXES = [
783
783
  ["w", { role: "outer", category: "sizing" }],
784
784
  ["z", { role: "outer", category: "position" }]
785
785
  ];
786
+ const BOX_ROLE_BY_KEY = /* @__PURE__ */ new Map([
787
+ ["accent", { role: "inner", category: "accent" }],
788
+ ["align", { role: "inner", category: "text" }],
789
+ ["animate", { role: "outer", category: "transition" }],
790
+ ["animationDelay", { role: "outer", category: "transition" }],
791
+ ["appearance", { role: "inner", category: "interaction" }],
792
+ ["aspect", { role: "outer", category: "sizing" }],
793
+ ["autoCols", { role: "inner", category: "grid" }],
794
+ ["autoRows", { role: "inner", category: "grid" }],
795
+ ["backdropBlur", { role: "outer", category: "backdrop" }],
796
+ ["backdropBrightness", { role: "outer", category: "backdrop" }],
797
+ ["backdropContrast", { role: "outer", category: "backdrop" }],
798
+ ["backdropFilter", { role: "outer", category: "backdrop" }],
799
+ ["backdropGrayscale", { role: "outer", category: "backdrop" }],
800
+ ["backdropHueRotate", { role: "outer", category: "backdrop" }],
801
+ ["backdropInvert", { role: "outer", category: "backdrop" }],
802
+ ["backdropOpacity", { role: "outer", category: "backdrop" }],
803
+ ["backdropSaturate", { role: "outer", category: "backdrop" }],
804
+ ["backdropSepia", { role: "outer", category: "backdrop" }],
805
+ ["backface", { role: "outer", category: "transform" }],
806
+ ["basis", { role: "inner", category: "flex" }],
807
+ ["bg", { role: "outer", category: "bg" }],
808
+ ["bgAttach", { role: "outer", category: "bg" }],
809
+ ["bgBlend", { role: "outer", category: "bg" }],
810
+ ["bgClip", { role: "outer", category: "bg" }],
811
+ ["bgImg", { role: "outer", category: "bg" }],
812
+ ["bgOrigin", { role: "outer", category: "bg" }],
813
+ ["bgPos", { role: "outer", category: "bg" }],
814
+ ["bgRepeat", { role: "outer", category: "bg" }],
815
+ ["bgSize", { role: "outer", category: "bg" }],
816
+ ["blockSize", { role: "outer", category: "sizing" }],
817
+ ["blur", { role: "outer", category: "filter" }],
818
+ ["border", { role: "outer", category: "border" }],
819
+ ["borderB", { role: "outer", category: "border" }],
820
+ ["borderBColor", { role: "outer", category: "border" }],
821
+ ["borderBe", { role: "outer", category: "border" }],
822
+ ["borderBs", { role: "outer", category: "border" }],
823
+ ["borderCollapse", { role: "outer", category: "border" }],
824
+ ["borderColor", { role: "outer", category: "border" }],
825
+ ["borderE", { role: "outer", category: "border" }],
826
+ ["borderL", { role: "outer", category: "border" }],
827
+ ["borderLColor", { role: "outer", category: "border" }],
828
+ ["borderR", { role: "outer", category: "border" }],
829
+ ["borderRColor", { role: "outer", category: "border" }],
830
+ ["borderS", { role: "outer", category: "border" }],
831
+ ["borderSpacing", { role: "outer", category: "border" }],
832
+ ["borderSpacingX", { role: "outer", category: "border" }],
833
+ ["borderSpacingY", { role: "outer", category: "border" }],
834
+ ["borderStyle", { role: "outer", category: "border" }],
835
+ ["borderT", { role: "outer", category: "border" }],
836
+ ["borderTColor", { role: "outer", category: "border" }],
837
+ ["borderX", { role: "outer", category: "border" }],
838
+ ["borderXColor", { role: "outer", category: "border" }],
839
+ ["borderY", { role: "outer", category: "border" }],
840
+ ["borderYColor", { role: "outer", category: "border" }],
841
+ ["bottom", { role: "outer", category: "position" }],
842
+ ["box", { role: "outer", category: "sizing" }],
843
+ ["boxDecoration", { role: "outer", category: "fragmentation" }],
844
+ ["break", { role: "inner", category: "text" }],
845
+ ["breakAfter", { role: "outer", category: "fragmentation" }],
846
+ ["breakBefore", { role: "outer", category: "fragmentation" }],
847
+ ["breakInside", { role: "outer", category: "fragmentation" }],
848
+ ["brightness", { role: "outer", category: "filter" }],
849
+ ["caption", { role: "inner", category: "table" }],
850
+ ["caret", { role: "inner", category: "accent" }],
851
+ ["clear", { role: "outer", category: "position" }],
852
+ ["col", { role: "inner", category: "grid" }],
853
+ ["colEnd", { role: "inner", category: "grid" }],
854
+ ["color", { role: "inner", category: "text" }],
855
+ ["colSpan", { role: "inner", category: "grid" }],
856
+ ["colStart", { role: "inner", category: "grid" }],
857
+ ["columns", { role: "inner", category: "columns" }],
858
+ ["container", { role: "outer", category: "sizing" }],
859
+ ["content", { role: "inner", category: "text" }],
860
+ ["contrast", { role: "outer", category: "filter" }],
861
+ ["cursor", { role: "inner", category: "interaction" }],
862
+ ["decoration", { role: "inner", category: "text" }],
863
+ ["decorationColor", { role: "inner", category: "text" }],
864
+ ["decorationStyle", { role: "inner", category: "text" }],
865
+ ["decorationThickness", { role: "inner", category: "text" }],
866
+ ["delay", { role: "outer", category: "transition" }],
867
+ ["diagonalFractions", { role: "inner", category: "text" }],
868
+ ["display", { role: "inner", category: "display" }],
869
+ ["divideColor", { role: "outer", category: "divide" }],
870
+ ["divideStyle", { role: "outer", category: "divide" }],
871
+ ["divideX", { role: "outer", category: "divide" }],
872
+ ["divideXReverse", { role: "outer", category: "divide" }],
873
+ ["divideY", { role: "outer", category: "divide" }],
874
+ ["divideYReverse", { role: "outer", category: "divide" }],
875
+ ["dropShadow", { role: "outer", category: "filter" }],
876
+ ["dropShadowColor", { role: "outer", category: "filter" }],
877
+ ["duration", { role: "outer", category: "transition" }],
878
+ ["ease", { role: "outer", category: "transition" }],
879
+ ["end", { role: "outer", category: "position" }],
880
+ ["fieldSizing", { role: "inner", category: "interaction" }],
881
+ ["fill", { role: "inner", category: "svg" }],
882
+ ["filter", { role: "outer", category: "filter" }],
883
+ ["flex", { role: "inner", category: "flex" }],
884
+ ["flexDir", { role: "inner", category: "flex" }],
885
+ ["flexWrap", { role: "inner", category: "flex" }],
886
+ ["float", { role: "outer", category: "position" }],
887
+ ["fontFamily", { role: "inner", category: "text" }],
888
+ ["fontFeatures", { role: "inner", category: "text" }],
889
+ ["fontSmoothing", { role: "inner", category: "text" }],
890
+ ["fontStretch", { role: "inner", category: "text" }],
891
+ ["fontStyle", { role: "inner", category: "text" }],
892
+ ["forcedColorAdjust", { role: "outer", category: "color-scheme" }],
893
+ ["from", { role: "outer", category: "gradient" }],
894
+ ["gap", { role: "inner", category: "gap" }],
895
+ ["gapX", { role: "inner", category: "gap" }],
896
+ ["gapY", { role: "inner", category: "gap" }],
897
+ ["grayscale", { role: "outer", category: "filter" }],
898
+ ["gridCols", { role: "inner", category: "grid" }],
899
+ ["gridFlow", { role: "inner", category: "grid" }],
900
+ ["gridRows", { role: "inner", category: "grid" }],
901
+ ["grow", { role: "inner", category: "flex" }],
902
+ ["h", { role: "outer", category: "sizing" }],
903
+ ["hueRotate", { role: "outer", category: "filter" }],
904
+ ["hyphens", { role: "inner", category: "text" }],
905
+ ["indent", { role: "inner", category: "text" }],
906
+ ["inlineSize", { role: "outer", category: "sizing" }],
907
+ ["inset", { role: "outer", category: "position" }],
908
+ ["insetBe", { role: "outer", category: "position" }],
909
+ ["insetBs", { role: "outer", category: "position" }],
910
+ ["insetE", { role: "outer", category: "position" }],
911
+ ["insetRing", { role: "inner", category: "ring" }],
912
+ ["insetRingColor", { role: "inner", category: "ring" }],
913
+ ["insetS", { role: "outer", category: "position" }],
914
+ ["insetShadow", { role: "inner", category: "shadow" }],
915
+ ["insetShadowColor", { role: "inner", category: "shadow" }],
916
+ ["insetX", { role: "outer", category: "position" }],
917
+ ["insetY", { role: "outer", category: "position" }],
918
+ ["invert", { role: "outer", category: "filter" }],
919
+ ["isolation", { role: "outer", category: "position" }],
920
+ ["items", { role: "inner", category: "alignment" }],
921
+ ["justify", { role: "inner", category: "alignment" }],
922
+ ["justifyItems", { role: "inner", category: "alignment" }],
923
+ ["justifySelf", { role: "inner", category: "alignment" }],
924
+ ["leading", { role: "inner", category: "text" }],
925
+ ["left", { role: "outer", category: "position" }],
926
+ ["lineClamp", { role: "inner", category: "text" }],
927
+ ["liningNums", { role: "inner", category: "text" }],
928
+ ["list", { role: "inner", category: "list" }],
929
+ ["listImg", { role: "inner", category: "list" }],
930
+ ["listPos", { role: "inner", category: "list" }],
931
+ ["m", { role: "outer", category: "margin" }],
932
+ ["mask", { role: "outer", category: "mask" }],
933
+ ["maskClip", { role: "outer", category: "mask" }],
934
+ ["maskFrom", { role: "outer", category: "mask" }],
935
+ ["maskOrigin", { role: "outer", category: "mask" }],
936
+ ["maskPos", { role: "outer", category: "mask" }],
937
+ ["maskRepeat", { role: "outer", category: "mask" }],
938
+ ["maskShape", { role: "outer", category: "mask" }],
939
+ ["maskSize", { role: "outer", category: "mask" }],
940
+ ["maskTo", { role: "outer", category: "mask" }],
941
+ ["maskVia", { role: "outer", category: "mask" }],
942
+ ["maxBlockSize", { role: "outer", category: "sizing" }],
943
+ ["maxH", { role: "outer", category: "sizing" }],
944
+ ["maxInlineSize", { role: "outer", category: "sizing" }],
945
+ ["maxW", { role: "outer", category: "sizing" }],
946
+ ["mb", { role: "outer", category: "margin" }],
947
+ ["mbe", { role: "outer", category: "margin" }],
948
+ ["mbs", { role: "outer", category: "margin" }],
949
+ ["me", { role: "outer", category: "margin" }],
950
+ ["minBlockSize", { role: "outer", category: "sizing" }],
951
+ ["minH", { role: "outer", category: "sizing" }],
952
+ ["minInlineSize", { role: "outer", category: "sizing" }],
953
+ ["minW", { role: "outer", category: "sizing" }],
954
+ ["mixBlend", { role: "outer", category: "blend" }],
955
+ ["ml", { role: "outer", category: "margin" }],
956
+ ["mr", { role: "outer", category: "margin" }],
957
+ ["ms", { role: "outer", category: "margin" }],
958
+ ["mt", { role: "outer", category: "margin" }],
959
+ ["mx", { role: "outer", category: "margin" }],
960
+ ["my", { role: "outer", category: "margin" }],
961
+ ["notSrOnly", { role: "outer", category: "visibility" }],
962
+ ["objectFit", { role: "inner", category: "object" }],
963
+ ["objectPos", { role: "inner", category: "object" }],
964
+ ["oldstyleNums", { role: "inner", category: "text" }],
965
+ ["opacity", { role: "outer", category: "opacity" }],
966
+ ["order", { role: "inner", category: "flex" }],
967
+ ["ordinal", { role: "inner", category: "text" }],
968
+ ["origin", { role: "outer", category: "transform" }],
969
+ ["outline", { role: "outer", category: "outline" }],
970
+ ["outlineColor", { role: "outer", category: "outline" }],
971
+ ["outlineOffset", { role: "outer", category: "outline" }],
972
+ ["outlineStyle", { role: "outer", category: "outline" }],
973
+ ["overflow", { role: "inner", category: "overflow" }],
974
+ ["overflowX", { role: "inner", category: "overflow" }],
975
+ ["overflowY", { role: "inner", category: "overflow" }],
976
+ ["overscroll", { role: "inner", category: "overscroll" }],
977
+ ["overscrollX", { role: "inner", category: "overscroll" }],
978
+ ["overscrollY", { role: "inner", category: "overscroll" }],
979
+ ["p", { role: "inner", category: "padding" }],
980
+ ["pb", { role: "inner", category: "padding" }],
981
+ ["pbe", { role: "inner", category: "padding" }],
982
+ ["pbs", { role: "inner", category: "padding" }],
983
+ ["pe", { role: "inner", category: "padding" }],
984
+ ["perspective", { role: "outer", category: "transform" }],
985
+ ["perspectiveOrigin", { role: "outer", category: "transform" }],
986
+ ["pl", { role: "inner", category: "padding" }],
987
+ ["placeContent", { role: "inner", category: "alignment" }],
988
+ ["placeItems", { role: "inner", category: "alignment" }],
989
+ ["placeSelf", { role: "inner", category: "alignment" }],
990
+ ["pointerEvents", { role: "inner", category: "interaction" }],
991
+ ["position", { role: "outer", category: "position" }],
992
+ ["pr", { role: "inner", category: "padding" }],
993
+ ["proportionalNums", { role: "inner", category: "text" }],
994
+ ["prose", { role: "inner", category: "text" }],
995
+ ["proseInvert", { role: "inner", category: "text" }],
996
+ ["ps", { role: "inner", category: "padding" }],
997
+ ["pt", { role: "inner", category: "padding" }],
998
+ ["px", { role: "inner", category: "padding" }],
999
+ ["py", { role: "inner", category: "padding" }],
1000
+ ["resize", { role: "inner", category: "interaction" }],
1001
+ ["right", { role: "outer", category: "position" }],
1002
+ ["ring", { role: "outer", category: "ring" }],
1003
+ ["ringColor", { role: "outer", category: "ring" }],
1004
+ ["ringOffset", { role: "outer", category: "ring" }],
1005
+ ["ringOffsetColor", { role: "outer", category: "ring" }],
1006
+ ["rotate", { role: "outer", category: "transform" }],
1007
+ ["rotateX", { role: "outer", category: "transform" }],
1008
+ ["rotateY", { role: "outer", category: "transform" }],
1009
+ ["rotateZ", { role: "outer", category: "transform" }],
1010
+ ["rounded", { role: "outer", category: "rounded" }],
1011
+ ["roundedB", { role: "outer", category: "rounded" }],
1012
+ ["roundedBl", { role: "outer", category: "rounded" }],
1013
+ ["roundedBr", { role: "outer", category: "rounded" }],
1014
+ ["roundedE", { role: "outer", category: "rounded" }],
1015
+ ["roundedEe", { role: "outer", category: "rounded" }],
1016
+ ["roundedEs", { role: "outer", category: "rounded" }],
1017
+ ["roundedL", { role: "outer", category: "rounded" }],
1018
+ ["roundedR", { role: "outer", category: "rounded" }],
1019
+ ["roundedS", { role: "outer", category: "rounded" }],
1020
+ ["roundedSe", { role: "outer", category: "rounded" }],
1021
+ ["roundedSs", { role: "outer", category: "rounded" }],
1022
+ ["roundedT", { role: "outer", category: "rounded" }],
1023
+ ["roundedTl", { role: "outer", category: "rounded" }],
1024
+ ["roundedTr", { role: "outer", category: "rounded" }],
1025
+ ["row", { role: "inner", category: "grid" }],
1026
+ ["rowEnd", { role: "inner", category: "grid" }],
1027
+ ["rowSpan", { role: "inner", category: "grid" }],
1028
+ ["rowStart", { role: "inner", category: "grid" }],
1029
+ ["saturate", { role: "outer", category: "filter" }],
1030
+ ["scale", { role: "outer", category: "transform" }],
1031
+ ["scaleX", { role: "outer", category: "transform" }],
1032
+ ["scaleY", { role: "outer", category: "transform" }],
1033
+ ["scaleZ", { role: "outer", category: "transform" }],
1034
+ ["scheme", { role: "outer", category: "color-scheme" }],
1035
+ ["scroll", { role: "inner", category: "scroll" }],
1036
+ ["scrollbar", { role: "inner", category: "scroll" }],
1037
+ ["scrollbarGutter", { role: "inner", category: "scroll" }],
1038
+ ["scrollbarThumb", { role: "inner", category: "scroll" }],
1039
+ ["scrollbarTrack", { role: "inner", category: "scroll" }],
1040
+ ["scrollM", { role: "inner", category: "scroll" }],
1041
+ ["scrollMb", { role: "inner", category: "scroll" }],
1042
+ ["scrollMbe", { role: "inner", category: "scroll" }],
1043
+ ["scrollMbs", { role: "inner", category: "scroll" }],
1044
+ ["scrollMe", { role: "inner", category: "scroll" }],
1045
+ ["scrollMl", { role: "inner", category: "scroll" }],
1046
+ ["scrollMr", { role: "inner", category: "scroll" }],
1047
+ ["scrollMs", { role: "inner", category: "scroll" }],
1048
+ ["scrollMt", { role: "inner", category: "scroll" }],
1049
+ ["scrollMx", { role: "inner", category: "scroll" }],
1050
+ ["scrollMy", { role: "inner", category: "scroll" }],
1051
+ ["scrollP", { role: "inner", category: "scroll" }],
1052
+ ["scrollPb", { role: "inner", category: "scroll" }],
1053
+ ["scrollPbe", { role: "inner", category: "scroll" }],
1054
+ ["scrollPbs", { role: "inner", category: "scroll" }],
1055
+ ["scrollPe", { role: "inner", category: "scroll" }],
1056
+ ["scrollPl", { role: "inner", category: "scroll" }],
1057
+ ["scrollPr", { role: "inner", category: "scroll" }],
1058
+ ["scrollPs", { role: "inner", category: "scroll" }],
1059
+ ["scrollPt", { role: "inner", category: "scroll" }],
1060
+ ["scrollPx", { role: "inner", category: "scroll" }],
1061
+ ["scrollPy", { role: "inner", category: "scroll" }],
1062
+ ["select", { role: "inner", category: "interaction" }],
1063
+ ["self", { role: "inner", category: "alignment" }],
1064
+ ["sepia", { role: "outer", category: "filter" }],
1065
+ ["shadow", { role: "outer", category: "shadow" }],
1066
+ ["shadowColor", { role: "outer", category: "shadow" }],
1067
+ ["shrink", { role: "inner", category: "flex" }],
1068
+ ["size", { role: "outer", category: "sizing" }],
1069
+ ["skewX", { role: "outer", category: "transform" }],
1070
+ ["skewY", { role: "outer", category: "transform" }],
1071
+ ["slashedZero", { role: "inner", category: "text" }],
1072
+ ["snapAlign", { role: "inner", category: "snap" }],
1073
+ ["snapStop", { role: "inner", category: "snap" }],
1074
+ ["snapType", { role: "inner", category: "snap" }],
1075
+ ["spaceX", { role: "inner", category: "space" }],
1076
+ ["spaceXReverse", { role: "inner", category: "space" }],
1077
+ ["spaceY", { role: "inner", category: "space" }],
1078
+ ["spaceYReverse", { role: "inner", category: "space" }],
1079
+ ["srOnly", { role: "outer", category: "visibility" }],
1080
+ ["stackedFractions", { role: "inner", category: "text" }],
1081
+ ["start", { role: "outer", category: "position" }],
1082
+ ["stroke", { role: "inner", category: "svg" }],
1083
+ ["strokeWidth", { role: "inner", category: "svg" }],
1084
+ ["tableLayout", { role: "inner", category: "table" }],
1085
+ ["tabSize", { role: "inner", category: "text" }],
1086
+ ["tabularNums", { role: "inner", category: "text" }],
1087
+ ["text", { role: "inner", category: "text" }],
1088
+ ["textAlign", { role: "inner", category: "text" }],
1089
+ ["textOverflow", { role: "inner", category: "text" }],
1090
+ ["textShadow", { role: "inner", category: "text" }],
1091
+ ["textShadowColor", { role: "inner", category: "text" }],
1092
+ ["textTransform", { role: "inner", category: "text" }],
1093
+ ["textWrap", { role: "inner", category: "text" }],
1094
+ ["to", { role: "outer", category: "gradient" }],
1095
+ ["top", { role: "outer", category: "position" }],
1096
+ ["touch", { role: "inner", category: "touch" }],
1097
+ ["tracking", { role: "inner", category: "text" }],
1098
+ ["transform", { role: "outer", category: "transform" }],
1099
+ ["transformStyle", { role: "outer", category: "transform" }],
1100
+ ["transition", { role: "outer", category: "transition" }],
1101
+ ["transitionBehavior", { role: "outer", category: "transition" }],
1102
+ ["translate", { role: "outer", category: "transform" }],
1103
+ ["translateX", { role: "outer", category: "transform" }],
1104
+ ["translateY", { role: "outer", category: "transform" }],
1105
+ ["translateZ", { role: "outer", category: "transform" }],
1106
+ ["truncate", { role: "inner", category: "text" }],
1107
+ ["underlineOffset", { role: "inner", category: "text" }],
1108
+ ["via", { role: "outer", category: "gradient" }],
1109
+ ["visibility", { role: "outer", category: "visibility" }],
1110
+ ["w", { role: "outer", category: "sizing" }],
1111
+ ["weight", { role: "inner", category: "text" }],
1112
+ ["whitespace", { role: "inner", category: "text" }],
1113
+ ["willChange", { role: "inner", category: "interaction" }],
1114
+ ["wrap", { role: "inner", category: "text" }],
1115
+ ["z", { role: "outer", category: "position" }],
1116
+ ["zoom", { role: "outer", category: "transform" }]
1117
+ ]);
786
1118
 
787
1119
  function stripVariant(token) {
788
1120
  let depth = 0;
@@ -864,12 +1196,126 @@ function pick(classes, selector) {
864
1196
  function omit(classes, selector) {
865
1197
  return tokenize(classes).filter((t) => !matches(inspect(t), selector)).join(" ");
866
1198
  }
1199
+ function classifySzKey(key) {
1200
+ return BOX_ROLE_BY_KEY.get(key);
1201
+ }
1202
+ function isPlainObject$1(value) {
1203
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1204
+ }
1205
+ function matchesKey(key, entry, selector) {
1206
+ if (typeof selector === "object") {
1207
+ return !!entry && Object.keys(selector).every((category) => entry.category === category);
1208
+ }
1209
+ if (selector === "outer" || selector === "inner") return entry?.role === selector;
1210
+ if (selector === "content") return entry?.role === "inner";
1211
+ if (key === selector) return true;
1212
+ return !!entry && selector === entry.category;
1213
+ }
1214
+ function anyMatchKey(key, entry, selectors) {
1215
+ return selectors.some((s) => matchesKey(key, entry, s));
1216
+ }
1217
+ function mergeSzInto(target, source, depth) {
1218
+ if (depth >= MAX_SZ_DEPTH) throw new SzDepthError();
1219
+ for (const key of Object.keys(source)) {
1220
+ if (isForbiddenSzKey(key)) continue;
1221
+ const sv = source[key];
1222
+ const tv = target[key];
1223
+ target[key] = isPlainObject$1(sv) && isPlainObject$1(tv) ? mergeSzInto({ ...tv }, sv, depth + 1) : sv;
1224
+ }
1225
+ return target;
1226
+ }
1227
+ function flattenSz(sz, depth) {
1228
+ if (depth >= MAX_SZ_DEPTH) throw new SzDepthError();
1229
+ if (!sz) return {};
1230
+ if (typeof sz === "string") {
1231
+ if (process.env.NODE_ENV !== "production" && sz.trim()) {
1232
+ throw new TypeError(
1233
+ `splitBoxSz partitions sz objects, not raw class strings \u2014 use splitBox() for ${JSON.stringify(sz)}.`
1234
+ );
1235
+ }
1236
+ return {};
1237
+ }
1238
+ if (Array.isArray(sz)) {
1239
+ const acc = {};
1240
+ for (const part of sz) mergeSzInto(acc, flattenSz(part, depth + 1), depth + 1);
1241
+ return acc;
1242
+ }
1243
+ return sz;
1244
+ }
1245
+ function partitionSz(obj, options, outer, inner, depth) {
1246
+ if (depth >= MAX_SZ_DEPTH) throw new SzDepthError();
1247
+ const forceInner = options.inner ?? [];
1248
+ const forceOuter = options.outer ?? [];
1249
+ const fallback = options.fallback ?? "outer";
1250
+ for (const key of Object.keys(obj)) {
1251
+ if (isForbiddenSzKey(key)) continue;
1252
+ const value = obj[key];
1253
+ const entry = BOX_ROLE_BY_KEY.get(key);
1254
+ if (anyMatchKey(key, entry, forceInner)) {
1255
+ inner[key] = value;
1256
+ } else if (anyMatchKey(key, entry, forceOuter)) {
1257
+ outer[key] = value;
1258
+ } else if (entry) {
1259
+ (entry.role === "inner" ? inner : outer)[key] = value;
1260
+ } else if (isPlainObject$1(value)) {
1261
+ const subOuter = {};
1262
+ const subInner = {};
1263
+ partitionSz(value, options, subOuter, subInner, depth + 1);
1264
+ if (Object.keys(subOuter).length > 0) outer[key] = subOuter;
1265
+ if (Object.keys(subInner).length > 0) inner[key] = subInner;
1266
+ } else {
1267
+ (fallback === "inner" ? inner : outer)[key] = value;
1268
+ }
1269
+ }
1270
+ }
1271
+ function splitBoxSz(sz, options = {}) {
1272
+ const outer = {};
1273
+ const inner = {};
1274
+ partitionSz(flattenSz(sz, 0), options, outer, inner, 0);
1275
+ return { outer, inner };
1276
+ }
1277
+ function filterSz(obj, selector, keep, depth) {
1278
+ if (depth >= MAX_SZ_DEPTH) throw new SzDepthError();
1279
+ const result = {};
1280
+ for (const key of Object.keys(obj)) {
1281
+ if (isForbiddenSzKey(key)) continue;
1282
+ const value = obj[key];
1283
+ const entry = BOX_ROLE_BY_KEY.get(key);
1284
+ if (entry || !isPlainObject$1(value)) {
1285
+ if (matchesKey(key, entry, selector) === keep) result[key] = value;
1286
+ } else {
1287
+ const sub = filterSz(value, selector, keep, depth + 1);
1288
+ if (Object.keys(sub).length > 0) result[key] = sub;
1289
+ }
1290
+ }
1291
+ return result;
1292
+ }
1293
+ function hasSz(sz, selector) {
1294
+ const scan = (obj, depth) => {
1295
+ if (depth >= MAX_SZ_DEPTH) throw new SzDepthError();
1296
+ for (const key of Object.keys(obj)) {
1297
+ if (isForbiddenSzKey(key)) continue;
1298
+ const value = obj[key];
1299
+ const entry = BOX_ROLE_BY_KEY.get(key);
1300
+ if (matchesKey(key, entry, selector)) return true;
1301
+ if (!entry && isPlainObject$1(value) && scan(value, depth + 1)) return true;
1302
+ }
1303
+ return false;
1304
+ };
1305
+ return scan(flattenSz(sz, 0), 0);
1306
+ }
1307
+ function pickSz(sz, selector) {
1308
+ return filterSz(flattenSz(sz, 0), selector, true, 0);
1309
+ }
1310
+ function omitSz(sz, selector) {
1311
+ return filterSz(flattenSz(sz, 0), selector, false, 0);
1312
+ }
867
1313
 
868
- const warned = /* @__PURE__ */ new Set();
1314
+ const warned$1 = /* @__PURE__ */ new Set();
869
1315
  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
1316
  function warnRawSz() {
871
- if (warned.has(RAW_SZ_WARNING)) return;
872
- warned.add(RAW_SZ_WARNING);
1317
+ if (warned$1.has(RAW_SZ_WARNING)) return;
1318
+ warned$1.add(RAW_SZ_WARNING);
873
1319
  console.warn(RAW_SZ_WARNING);
874
1320
  }
875
1321
  function stripSzProps(props) {
@@ -885,6 +1331,18 @@ function stripSzProps(props) {
885
1331
  return rest;
886
1332
  }
887
1333
 
1334
+ const warned = /* @__PURE__ */ new Set();
1335
+ function devWarn(message) {
1336
+ if (process.env.NODE_ENV === "production") {
1337
+ return;
1338
+ }
1339
+ if (warned.has(message)) {
1340
+ return;
1341
+ }
1342
+ warned.add(message);
1343
+ console.warn(`[csszyx] ${message}`);
1344
+ }
1345
+
888
1346
  function deepMerge(target, source, depth = 0) {
889
1347
  if (depth >= MAX_SZ_DEPTH) {
890
1348
  throw new SzDepthError();
@@ -904,8 +1362,97 @@ function deepMerge(target, source, depth = 0) {
904
1362
  }
905
1363
  return result;
906
1364
  }
1365
+ function isPlainObject(value) {
1366
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1367
+ }
1368
+ function validateSzvConfig(config) {
1369
+ if (process.env.NODE_ENV === "production") {
1370
+ return true;
1371
+ }
1372
+ if (!isPlainObject(config)) {
1373
+ devWarn(`szv(config): config must be an object, got ${describe(config)}. Ignoring.`);
1374
+ return false;
1375
+ }
1376
+ if (config.base !== void 0 && !isPlainObject(config.base)) {
1377
+ devWarn(`szv(config): base must be an sz object, got ${describe(config.base)}.`);
1378
+ }
1379
+ if (!isPlainObject(config.variants)) {
1380
+ devWarn(
1381
+ `szv(config): variants is required and must be an object, got ${describe(config.variants)}. Ignoring.`
1382
+ );
1383
+ return false;
1384
+ }
1385
+ for (const dim of Object.keys(config.variants)) {
1386
+ const values = config.variants[dim];
1387
+ if (!isPlainObject(values)) {
1388
+ devWarn(
1389
+ `szv(config): variants.${dim} must be an object of values, got ${describe(values)}.`
1390
+ );
1391
+ continue;
1392
+ }
1393
+ for (const token of Object.keys(values)) {
1394
+ const v = values[token];
1395
+ if (v !== null && v !== void 0 && !isPlainObject(v)) {
1396
+ devWarn(
1397
+ `szv(config): variants.${dim}.${token} must be an sz object, got ${describe(v)}. It will be skipped.`
1398
+ );
1399
+ } else if (isPlainObject(v)) {
1400
+ assertBoundedDepth(v, `variants.${dim}.${token}`);
1401
+ }
1402
+ }
1403
+ }
1404
+ if (config.defaultVariants !== void 0 && !isPlainObject(config.defaultVariants)) {
1405
+ devWarn(
1406
+ `szv(config): defaultVariants must be an object, got ${describe(config.defaultVariants)}.`
1407
+ );
1408
+ }
1409
+ return true;
1410
+ }
1411
+ function assertBoundedDepth(obj, where, depth = 0) {
1412
+ if (depth >= MAX_SZ_DEPTH) {
1413
+ devWarn(
1414
+ `szv(config): ${where} nests deeper than ${MAX_SZ_DEPTH} levels; it will be rejected at render.`
1415
+ );
1416
+ return;
1417
+ }
1418
+ for (const key of Object.keys(obj)) {
1419
+ if (isForbiddenSzKey(key)) {
1420
+ devWarn(`szv(config): ${where} has a forbidden key "${key}"; it will be skipped.`);
1421
+ continue;
1422
+ }
1423
+ const v = obj[key];
1424
+ if (isPlainObject(v)) {
1425
+ assertBoundedDepth(v, `${where}.${key}`, depth + 1);
1426
+ }
1427
+ }
1428
+ }
1429
+ function describe(value) {
1430
+ if (value === null) return "null";
1431
+ if (Array.isArray(value)) return "an array";
1432
+ return typeof value;
1433
+ }
907
1434
  function szv(config) {
1435
+ const configValid = validateSzvConfig(config);
908
1436
  return function szVariantFn(selection) {
1437
+ if (!configValid) {
1438
+ return isPlainObject(config?.base) ? { ...config.base } : {};
1439
+ }
1440
+ if (process.env.NODE_ENV !== "production" && selection) {
1441
+ for (const key of Object.keys(selection)) {
1442
+ if (!(key in config.variants)) {
1443
+ devWarn(
1444
+ `szv()(selection): unknown variant "${key}" \u2014 not declared in config.variants.`
1445
+ );
1446
+ continue;
1447
+ }
1448
+ const val = selection[key];
1449
+ if (val !== null && val !== void 0 && !(String(val) in config.variants[key])) {
1450
+ devWarn(
1451
+ `szv()(selection): "${String(val)}" is not a value of variant "${key}" \u2014 it has no styles.`
1452
+ );
1453
+ }
1454
+ }
1455
+ }
909
1456
  let result = config.base ? { ...config.base } : {};
910
1457
  const resolved = { ...config.defaultVariants };
911
1458
  if (selection) {
@@ -919,13 +1466,13 @@ function szv(config) {
919
1466
  }
920
1467
  }
921
1468
  }
922
- for (const variantKey of Object.keys(config.variants)) {
1469
+ for (const variantKey of Object.keys(config.variants ?? {})) {
923
1470
  const selectedValue = resolved[variantKey];
924
1471
  if (selectedValue === null || selectedValue === void 0) {
925
1472
  continue;
926
1473
  }
927
1474
  const variantObj = config.variants[variantKey][selectedValue];
928
- if (variantObj) {
1475
+ if (isPlainObject(variantObj)) {
929
1476
  result = deepMerge(result, variantObj);
930
1477
  }
931
1478
  }
@@ -974,4 +1521,4 @@ function resetRuntime() {
974
1521
  runtimeState.initialized = false;
975
1522
  }
976
1523
 
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 };
1524
+ export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/runtime",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Runtime helpers and hydration guards for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -49,8 +49,8 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "@csszyx/compiler": "0.10.0",
53
- "@csszyx/core": "0.10.0"
52
+ "@csszyx/compiler": "0.10.2",
53
+ "@csszyx/core": "0.10.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^20.11.0",