rafters 0.0.65 → 0.0.68
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.js +425 -703
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -735,10 +735,10 @@ function jsonStringifyReplacer(_, value) {
|
|
|
735
735
|
return value;
|
|
736
736
|
}
|
|
737
737
|
function cached(getter) {
|
|
738
|
-
const
|
|
738
|
+
const set3 = false;
|
|
739
739
|
return {
|
|
740
740
|
get value() {
|
|
741
|
-
if (!
|
|
741
|
+
if (!set3) {
|
|
742
742
|
const value = getter();
|
|
743
743
|
Object.defineProperty(this, "value", { value });
|
|
744
744
|
return value;
|
|
@@ -747,8 +747,8 @@ function cached(getter) {
|
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
749
|
}
|
|
750
|
-
function nullish(
|
|
751
|
-
return
|
|
750
|
+
function nullish(input) {
|
|
751
|
+
return input === null || input === void 0;
|
|
752
752
|
}
|
|
753
753
|
function cleanRegex(source) {
|
|
754
754
|
const start = source.startsWith("^") ? 1 : 0;
|
|
@@ -1203,29 +1203,29 @@ function finalizeIssue(iss, ctx, config2) {
|
|
|
1203
1203
|
}
|
|
1204
1204
|
return full;
|
|
1205
1205
|
}
|
|
1206
|
-
function getSizableOrigin(
|
|
1207
|
-
if (
|
|
1206
|
+
function getSizableOrigin(input) {
|
|
1207
|
+
if (input instanceof Set)
|
|
1208
1208
|
return "set";
|
|
1209
|
-
if (
|
|
1209
|
+
if (input instanceof Map)
|
|
1210
1210
|
return "map";
|
|
1211
|
-
if (
|
|
1211
|
+
if (input instanceof File)
|
|
1212
1212
|
return "file";
|
|
1213
1213
|
return "unknown";
|
|
1214
1214
|
}
|
|
1215
|
-
function getLengthableOrigin(
|
|
1216
|
-
if (Array.isArray(
|
|
1215
|
+
function getLengthableOrigin(input) {
|
|
1216
|
+
if (Array.isArray(input))
|
|
1217
1217
|
return "array";
|
|
1218
|
-
if (typeof
|
|
1218
|
+
if (typeof input === "string")
|
|
1219
1219
|
return "string";
|
|
1220
1220
|
return "unknown";
|
|
1221
1221
|
}
|
|
1222
1222
|
function issue(...args) {
|
|
1223
|
-
const [iss,
|
|
1223
|
+
const [iss, input, inst] = args;
|
|
1224
1224
|
if (typeof iss === "string") {
|
|
1225
1225
|
return {
|
|
1226
1226
|
message: iss,
|
|
1227
1227
|
code: "custom",
|
|
1228
|
-
input
|
|
1228
|
+
input,
|
|
1229
1229
|
inst
|
|
1230
1230
|
};
|
|
1231
1231
|
}
|
|
@@ -1759,23 +1759,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1759
1759
|
bag.pattern = integer;
|
|
1760
1760
|
});
|
|
1761
1761
|
inst._zod.check = (payload) => {
|
|
1762
|
-
const
|
|
1762
|
+
const input = payload.value;
|
|
1763
1763
|
if (isInt) {
|
|
1764
|
-
if (!Number.isInteger(
|
|
1764
|
+
if (!Number.isInteger(input)) {
|
|
1765
1765
|
payload.issues.push({
|
|
1766
1766
|
expected: origin,
|
|
1767
1767
|
format: def.format,
|
|
1768
1768
|
code: "invalid_type",
|
|
1769
1769
|
continue: false,
|
|
1770
|
-
input
|
|
1770
|
+
input,
|
|
1771
1771
|
inst
|
|
1772
1772
|
});
|
|
1773
1773
|
return;
|
|
1774
1774
|
}
|
|
1775
|
-
if (!Number.isSafeInteger(
|
|
1776
|
-
if (
|
|
1775
|
+
if (!Number.isSafeInteger(input)) {
|
|
1776
|
+
if (input > 0) {
|
|
1777
1777
|
payload.issues.push({
|
|
1778
|
-
input
|
|
1778
|
+
input,
|
|
1779
1779
|
code: "too_big",
|
|
1780
1780
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
1781
1781
|
note: "Integers must be within the safe integer range.",
|
|
@@ -1785,7 +1785,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1785
1785
|
});
|
|
1786
1786
|
} else {
|
|
1787
1787
|
payload.issues.push({
|
|
1788
|
-
input
|
|
1788
|
+
input,
|
|
1789
1789
|
code: "too_small",
|
|
1790
1790
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
1791
1791
|
note: "Integers must be within the safe integer range.",
|
|
@@ -1797,10 +1797,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1797
1797
|
return;
|
|
1798
1798
|
}
|
|
1799
1799
|
}
|
|
1800
|
-
if (
|
|
1800
|
+
if (input < minimum) {
|
|
1801
1801
|
payload.issues.push({
|
|
1802
1802
|
origin: "number",
|
|
1803
|
-
input
|
|
1803
|
+
input,
|
|
1804
1804
|
code: "too_small",
|
|
1805
1805
|
minimum,
|
|
1806
1806
|
inclusive: true,
|
|
@@ -1808,10 +1808,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1808
1808
|
continue: !def.abort
|
|
1809
1809
|
});
|
|
1810
1810
|
}
|
|
1811
|
-
if (
|
|
1811
|
+
if (input > maximum) {
|
|
1812
1812
|
payload.issues.push({
|
|
1813
1813
|
origin: "number",
|
|
1814
|
-
input
|
|
1814
|
+
input,
|
|
1815
1815
|
code: "too_big",
|
|
1816
1816
|
maximum,
|
|
1817
1817
|
inst
|
|
@@ -1829,11 +1829,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
1829
1829
|
bag.maximum = maximum;
|
|
1830
1830
|
});
|
|
1831
1831
|
inst._zod.check = (payload) => {
|
|
1832
|
-
const
|
|
1833
|
-
if (
|
|
1832
|
+
const input = payload.value;
|
|
1833
|
+
if (input < minimum) {
|
|
1834
1834
|
payload.issues.push({
|
|
1835
1835
|
origin: "bigint",
|
|
1836
|
-
input
|
|
1836
|
+
input,
|
|
1837
1837
|
code: "too_small",
|
|
1838
1838
|
minimum,
|
|
1839
1839
|
inclusive: true,
|
|
@@ -1841,10 +1841,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
1841
1841
|
continue: !def.abort
|
|
1842
1842
|
});
|
|
1843
1843
|
}
|
|
1844
|
-
if (
|
|
1844
|
+
if (input > maximum) {
|
|
1845
1845
|
payload.issues.push({
|
|
1846
1846
|
origin: "bigint",
|
|
1847
|
-
input
|
|
1847
|
+
input,
|
|
1848
1848
|
code: "too_big",
|
|
1849
1849
|
maximum,
|
|
1850
1850
|
inst
|
|
@@ -1865,16 +1865,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
|
|
|
1865
1865
|
inst2._zod.bag.maximum = def.maximum;
|
|
1866
1866
|
});
|
|
1867
1867
|
inst._zod.check = (payload) => {
|
|
1868
|
-
const
|
|
1869
|
-
const size =
|
|
1868
|
+
const input = payload.value;
|
|
1869
|
+
const size = input.size;
|
|
1870
1870
|
if (size <= def.maximum)
|
|
1871
1871
|
return;
|
|
1872
1872
|
payload.issues.push({
|
|
1873
|
-
origin: getSizableOrigin(
|
|
1873
|
+
origin: getSizableOrigin(input),
|
|
1874
1874
|
code: "too_big",
|
|
1875
1875
|
maximum: def.maximum,
|
|
1876
1876
|
inclusive: true,
|
|
1877
|
-
input
|
|
1877
|
+
input,
|
|
1878
1878
|
inst,
|
|
1879
1879
|
continue: !def.abort
|
|
1880
1880
|
});
|
|
@@ -1893,16 +1893,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
|
|
|
1893
1893
|
inst2._zod.bag.minimum = def.minimum;
|
|
1894
1894
|
});
|
|
1895
1895
|
inst._zod.check = (payload) => {
|
|
1896
|
-
const
|
|
1897
|
-
const size =
|
|
1896
|
+
const input = payload.value;
|
|
1897
|
+
const size = input.size;
|
|
1898
1898
|
if (size >= def.minimum)
|
|
1899
1899
|
return;
|
|
1900
1900
|
payload.issues.push({
|
|
1901
|
-
origin: getSizableOrigin(
|
|
1901
|
+
origin: getSizableOrigin(input),
|
|
1902
1902
|
code: "too_small",
|
|
1903
1903
|
minimum: def.minimum,
|
|
1904
1904
|
inclusive: true,
|
|
1905
|
-
input
|
|
1905
|
+
input,
|
|
1906
1906
|
inst,
|
|
1907
1907
|
continue: !def.abort
|
|
1908
1908
|
});
|
|
@@ -1922,13 +1922,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
|
|
|
1922
1922
|
bag.size = def.size;
|
|
1923
1923
|
});
|
|
1924
1924
|
inst._zod.check = (payload) => {
|
|
1925
|
-
const
|
|
1926
|
-
const size =
|
|
1925
|
+
const input = payload.value;
|
|
1926
|
+
const size = input.size;
|
|
1927
1927
|
if (size === def.size)
|
|
1928
1928
|
return;
|
|
1929
1929
|
const tooBig = size > def.size;
|
|
1930
1930
|
payload.issues.push({
|
|
1931
|
-
origin: getSizableOrigin(
|
|
1931
|
+
origin: getSizableOrigin(input),
|
|
1932
1932
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
1933
1933
|
inclusive: true,
|
|
1934
1934
|
exact: true,
|
|
@@ -1951,17 +1951,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
1951
1951
|
inst2._zod.bag.maximum = def.maximum;
|
|
1952
1952
|
});
|
|
1953
1953
|
inst._zod.check = (payload) => {
|
|
1954
|
-
const
|
|
1955
|
-
const length =
|
|
1954
|
+
const input = payload.value;
|
|
1955
|
+
const length = input.length;
|
|
1956
1956
|
if (length <= def.maximum)
|
|
1957
1957
|
return;
|
|
1958
|
-
const origin = getLengthableOrigin(
|
|
1958
|
+
const origin = getLengthableOrigin(input);
|
|
1959
1959
|
payload.issues.push({
|
|
1960
1960
|
origin,
|
|
1961
1961
|
code: "too_big",
|
|
1962
1962
|
maximum: def.maximum,
|
|
1963
1963
|
inclusive: true,
|
|
1964
|
-
input
|
|
1964
|
+
input,
|
|
1965
1965
|
inst,
|
|
1966
1966
|
continue: !def.abort
|
|
1967
1967
|
});
|
|
@@ -1980,17 +1980,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
1980
1980
|
inst2._zod.bag.minimum = def.minimum;
|
|
1981
1981
|
});
|
|
1982
1982
|
inst._zod.check = (payload) => {
|
|
1983
|
-
const
|
|
1984
|
-
const length =
|
|
1983
|
+
const input = payload.value;
|
|
1984
|
+
const length = input.length;
|
|
1985
1985
|
if (length >= def.minimum)
|
|
1986
1986
|
return;
|
|
1987
|
-
const origin = getLengthableOrigin(
|
|
1987
|
+
const origin = getLengthableOrigin(input);
|
|
1988
1988
|
payload.issues.push({
|
|
1989
1989
|
origin,
|
|
1990
1990
|
code: "too_small",
|
|
1991
1991
|
minimum: def.minimum,
|
|
1992
1992
|
inclusive: true,
|
|
1993
|
-
input
|
|
1993
|
+
input,
|
|
1994
1994
|
inst,
|
|
1995
1995
|
continue: !def.abort
|
|
1996
1996
|
});
|
|
@@ -2010,11 +2010,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
2010
2010
|
bag.length = def.length;
|
|
2011
2011
|
});
|
|
2012
2012
|
inst._zod.check = (payload) => {
|
|
2013
|
-
const
|
|
2014
|
-
const length =
|
|
2013
|
+
const input = payload.value;
|
|
2014
|
+
const length = input.length;
|
|
2015
2015
|
if (length === def.length)
|
|
2016
2016
|
return;
|
|
2017
|
-
const origin = getLengthableOrigin(
|
|
2017
|
+
const origin = getLengthableOrigin(input);
|
|
2018
2018
|
const tooBig = length > def.length;
|
|
2019
2019
|
payload.issues.push({
|
|
2020
2020
|
origin,
|
|
@@ -2673,15 +2673,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
2673
2673
|
payload.value = Number(payload.value);
|
|
2674
2674
|
} catch (_) {
|
|
2675
2675
|
}
|
|
2676
|
-
const
|
|
2677
|
-
if (typeof
|
|
2676
|
+
const input = payload.value;
|
|
2677
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
2678
2678
|
return payload;
|
|
2679
2679
|
}
|
|
2680
|
-
const received = typeof
|
|
2680
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
2681
2681
|
payload.issues.push({
|
|
2682
2682
|
expected: "number",
|
|
2683
2683
|
code: "invalid_type",
|
|
2684
|
-
input
|
|
2684
|
+
input,
|
|
2685
2685
|
inst,
|
|
2686
2686
|
...received ? { received } : {}
|
|
2687
2687
|
});
|
|
@@ -2701,13 +2701,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
2701
2701
|
payload.value = Boolean(payload.value);
|
|
2702
2702
|
} catch (_) {
|
|
2703
2703
|
}
|
|
2704
|
-
const
|
|
2705
|
-
if (typeof
|
|
2704
|
+
const input = payload.value;
|
|
2705
|
+
if (typeof input === "boolean")
|
|
2706
2706
|
return payload;
|
|
2707
2707
|
payload.issues.push({
|
|
2708
2708
|
expected: "boolean",
|
|
2709
2709
|
code: "invalid_type",
|
|
2710
|
-
input
|
|
2710
|
+
input,
|
|
2711
2711
|
inst
|
|
2712
2712
|
});
|
|
2713
2713
|
return payload;
|
|
@@ -2740,13 +2740,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) =>
|
|
|
2740
2740
|
var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
|
|
2741
2741
|
$ZodType.init(inst, def);
|
|
2742
2742
|
inst._zod.parse = (payload, _ctx) => {
|
|
2743
|
-
const
|
|
2744
|
-
if (typeof
|
|
2743
|
+
const input = payload.value;
|
|
2744
|
+
if (typeof input === "symbol")
|
|
2745
2745
|
return payload;
|
|
2746
2746
|
payload.issues.push({
|
|
2747
2747
|
expected: "symbol",
|
|
2748
2748
|
code: "invalid_type",
|
|
2749
|
-
input
|
|
2749
|
+
input,
|
|
2750
2750
|
inst
|
|
2751
2751
|
});
|
|
2752
2752
|
return payload;
|
|
@@ -2759,13 +2759,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
|
|
|
2759
2759
|
inst._zod.optin = "optional";
|
|
2760
2760
|
inst._zod.optout = "optional";
|
|
2761
2761
|
inst._zod.parse = (payload, _ctx) => {
|
|
2762
|
-
const
|
|
2763
|
-
if (typeof
|
|
2762
|
+
const input = payload.value;
|
|
2763
|
+
if (typeof input === "undefined")
|
|
2764
2764
|
return payload;
|
|
2765
2765
|
payload.issues.push({
|
|
2766
2766
|
expected: "undefined",
|
|
2767
2767
|
code: "invalid_type",
|
|
2768
|
-
input
|
|
2768
|
+
input,
|
|
2769
2769
|
inst
|
|
2770
2770
|
});
|
|
2771
2771
|
return payload;
|
|
@@ -2776,13 +2776,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
|
2776
2776
|
inst._zod.pattern = _null;
|
|
2777
2777
|
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
2778
2778
|
inst._zod.parse = (payload, _ctx) => {
|
|
2779
|
-
const
|
|
2780
|
-
if (
|
|
2779
|
+
const input = payload.value;
|
|
2780
|
+
if (input === null)
|
|
2781
2781
|
return payload;
|
|
2782
2782
|
payload.issues.push({
|
|
2783
2783
|
expected: "null",
|
|
2784
2784
|
code: "invalid_type",
|
|
2785
|
-
input
|
|
2785
|
+
input,
|
|
2786
2786
|
inst
|
|
2787
2787
|
});
|
|
2788
2788
|
return payload;
|
|
@@ -2811,13 +2811,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
2811
2811
|
var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
|
|
2812
2812
|
$ZodType.init(inst, def);
|
|
2813
2813
|
inst._zod.parse = (payload, _ctx) => {
|
|
2814
|
-
const
|
|
2815
|
-
if (typeof
|
|
2814
|
+
const input = payload.value;
|
|
2815
|
+
if (typeof input === "undefined")
|
|
2816
2816
|
return payload;
|
|
2817
2817
|
payload.issues.push({
|
|
2818
2818
|
expected: "void",
|
|
2819
2819
|
code: "invalid_type",
|
|
2820
|
-
input
|
|
2820
|
+
input,
|
|
2821
2821
|
inst
|
|
2822
2822
|
});
|
|
2823
2823
|
return payload;
|
|
@@ -2832,15 +2832,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
2832
2832
|
} catch (_err) {
|
|
2833
2833
|
}
|
|
2834
2834
|
}
|
|
2835
|
-
const
|
|
2836
|
-
const isDate =
|
|
2837
|
-
const isValidDate = isDate && !Number.isNaN(
|
|
2835
|
+
const input = payload.value;
|
|
2836
|
+
const isDate = input instanceof Date;
|
|
2837
|
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
|
2838
2838
|
if (isValidDate)
|
|
2839
2839
|
return payload;
|
|
2840
2840
|
payload.issues.push({
|
|
2841
2841
|
expected: "date",
|
|
2842
2842
|
code: "invalid_type",
|
|
2843
|
-
input
|
|
2843
|
+
input,
|
|
2844
2844
|
...isDate ? { received: "Invalid Date" } : {},
|
|
2845
2845
|
inst
|
|
2846
2846
|
});
|
|
@@ -2856,20 +2856,20 @@ function handleArrayResult(result, final, index) {
|
|
|
2856
2856
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
2857
2857
|
$ZodType.init(inst, def);
|
|
2858
2858
|
inst._zod.parse = (payload, ctx) => {
|
|
2859
|
-
const
|
|
2860
|
-
if (!Array.isArray(
|
|
2859
|
+
const input = payload.value;
|
|
2860
|
+
if (!Array.isArray(input)) {
|
|
2861
2861
|
payload.issues.push({
|
|
2862
2862
|
expected: "array",
|
|
2863
2863
|
code: "invalid_type",
|
|
2864
|
-
input
|
|
2864
|
+
input,
|
|
2865
2865
|
inst
|
|
2866
2866
|
});
|
|
2867
2867
|
return payload;
|
|
2868
2868
|
}
|
|
2869
|
-
payload.value = Array(
|
|
2869
|
+
payload.value = Array(input.length);
|
|
2870
2870
|
const proms = [];
|
|
2871
|
-
for (let i = 0; i <
|
|
2872
|
-
const item =
|
|
2871
|
+
for (let i = 0; i < input.length; i++) {
|
|
2872
|
+
const item = input[i];
|
|
2873
2873
|
const result = def.element._zod.run({
|
|
2874
2874
|
value: item,
|
|
2875
2875
|
issues: []
|
|
@@ -2886,12 +2886,12 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
2886
2886
|
return payload;
|
|
2887
2887
|
};
|
|
2888
2888
|
});
|
|
2889
|
-
function handlePropertyResult(result, final, key,
|
|
2889
|
+
function handlePropertyResult(result, final, key, input) {
|
|
2890
2890
|
if (result.issues.length) {
|
|
2891
2891
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
2892
2892
|
}
|
|
2893
2893
|
if (result.value === void 0) {
|
|
2894
|
-
if (key in
|
|
2894
|
+
if (key in input) {
|
|
2895
2895
|
final.value[key] = void 0;
|
|
2896
2896
|
}
|
|
2897
2897
|
} else {
|
|
@@ -2914,30 +2914,30 @@ function normalizeDef(def) {
|
|
|
2914
2914
|
optionalKeys: new Set(okeys)
|
|
2915
2915
|
};
|
|
2916
2916
|
}
|
|
2917
|
-
function handleCatchall(proms,
|
|
2917
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
2918
2918
|
const unrecognized = [];
|
|
2919
2919
|
const keySet = def.keySet;
|
|
2920
2920
|
const _catchall = def.catchall._zod;
|
|
2921
2921
|
const t = _catchall.def.type;
|
|
2922
|
-
for (const key of Object.keys(
|
|
2922
|
+
for (const key of Object.keys(input)) {
|
|
2923
2923
|
if (keySet.has(key))
|
|
2924
2924
|
continue;
|
|
2925
2925
|
if (t === "never") {
|
|
2926
2926
|
unrecognized.push(key);
|
|
2927
2927
|
continue;
|
|
2928
2928
|
}
|
|
2929
|
-
const r = _catchall.run({ value:
|
|
2929
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
2930
2930
|
if (r instanceof Promise) {
|
|
2931
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
2931
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
2932
2932
|
} else {
|
|
2933
|
-
handlePropertyResult(r, payload, key,
|
|
2933
|
+
handlePropertyResult(r, payload, key, input);
|
|
2934
2934
|
}
|
|
2935
2935
|
}
|
|
2936
2936
|
if (unrecognized.length) {
|
|
2937
2937
|
payload.issues.push({
|
|
2938
2938
|
code: "unrecognized_keys",
|
|
2939
2939
|
keys: unrecognized,
|
|
2940
|
-
input
|
|
2940
|
+
input,
|
|
2941
2941
|
inst
|
|
2942
2942
|
});
|
|
2943
2943
|
}
|
|
@@ -2981,12 +2981,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2981
2981
|
let value;
|
|
2982
2982
|
inst._zod.parse = (payload, ctx) => {
|
|
2983
2983
|
value ?? (value = _normalized.value);
|
|
2984
|
-
const
|
|
2985
|
-
if (!isObject2(
|
|
2984
|
+
const input = payload.value;
|
|
2985
|
+
if (!isObject2(input)) {
|
|
2986
2986
|
payload.issues.push({
|
|
2987
2987
|
expected: "object",
|
|
2988
2988
|
code: "invalid_type",
|
|
2989
|
-
input
|
|
2989
|
+
input,
|
|
2990
2990
|
inst
|
|
2991
2991
|
});
|
|
2992
2992
|
return payload;
|
|
@@ -2996,17 +2996,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2996
2996
|
const shape = value.shape;
|
|
2997
2997
|
for (const key of value.keys) {
|
|
2998
2998
|
const el = shape[key];
|
|
2999
|
-
const r = el._zod.run({ value:
|
|
2999
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
3000
3000
|
if (r instanceof Promise) {
|
|
3001
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
3001
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
3002
3002
|
} else {
|
|
3003
|
-
handlePropertyResult(r, payload, key,
|
|
3003
|
+
handlePropertyResult(r, payload, key, input);
|
|
3004
3004
|
}
|
|
3005
3005
|
}
|
|
3006
3006
|
if (!catchall) {
|
|
3007
3007
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
3008
3008
|
}
|
|
3009
|
-
return handleCatchall(proms,
|
|
3009
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
3010
3010
|
};
|
|
3011
3011
|
});
|
|
3012
3012
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -3064,12 +3064,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3064
3064
|
let value;
|
|
3065
3065
|
inst._zod.parse = (payload, ctx) => {
|
|
3066
3066
|
value ?? (value = _normalized.value);
|
|
3067
|
-
const
|
|
3068
|
-
if (!isObject2(
|
|
3067
|
+
const input = payload.value;
|
|
3068
|
+
if (!isObject2(input)) {
|
|
3069
3069
|
payload.issues.push({
|
|
3070
3070
|
expected: "object",
|
|
3071
3071
|
code: "invalid_type",
|
|
3072
|
-
input
|
|
3072
|
+
input,
|
|
3073
3073
|
inst
|
|
3074
3074
|
});
|
|
3075
3075
|
return payload;
|
|
@@ -3080,7 +3080,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3080
3080
|
payload = fastpass(payload, ctx);
|
|
3081
3081
|
if (!catchall)
|
|
3082
3082
|
return payload;
|
|
3083
|
-
return handleCatchall([],
|
|
3083
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
3084
3084
|
}
|
|
3085
3085
|
return superParse(payload, ctx);
|
|
3086
3086
|
};
|
|
@@ -3187,17 +3187,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3187
3187
|
return map2;
|
|
3188
3188
|
});
|
|
3189
3189
|
inst._zod.parse = (payload, ctx) => {
|
|
3190
|
-
const
|
|
3191
|
-
if (!isObject(
|
|
3190
|
+
const input = payload.value;
|
|
3191
|
+
if (!isObject(input)) {
|
|
3192
3192
|
payload.issues.push({
|
|
3193
3193
|
code: "invalid_type",
|
|
3194
3194
|
expected: "object",
|
|
3195
|
-
input
|
|
3195
|
+
input,
|
|
3196
3196
|
inst
|
|
3197
3197
|
});
|
|
3198
3198
|
return payload;
|
|
3199
3199
|
}
|
|
3200
|
-
const opt = disc.value.get(
|
|
3200
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
|
3201
3201
|
if (opt) {
|
|
3202
3202
|
return opt._zod.run(payload, ctx);
|
|
3203
3203
|
}
|
|
@@ -3209,7 +3209,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3209
3209
|
errors: [],
|
|
3210
3210
|
note: "No matching discriminator",
|
|
3211
3211
|
discriminator: def.discriminator,
|
|
3212
|
-
input
|
|
3212
|
+
input,
|
|
3213
3213
|
path: [def.discriminator],
|
|
3214
3214
|
inst
|
|
3215
3215
|
});
|
|
@@ -3219,9 +3219,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3219
3219
|
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
3220
3220
|
$ZodType.init(inst, def);
|
|
3221
3221
|
inst._zod.parse = (payload, ctx) => {
|
|
3222
|
-
const
|
|
3223
|
-
const left = def.left._zod.run({ value:
|
|
3224
|
-
const right = def.right._zod.run({ value:
|
|
3222
|
+
const input = payload.value;
|
|
3223
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
3224
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
3225
3225
|
const async = left instanceof Promise || right instanceof Promise;
|
|
3226
3226
|
if (async) {
|
|
3227
3227
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
@@ -3296,10 +3296,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3296
3296
|
const items = def.items;
|
|
3297
3297
|
const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
|
3298
3298
|
inst._zod.parse = (payload, ctx) => {
|
|
3299
|
-
const
|
|
3300
|
-
if (!Array.isArray(
|
|
3299
|
+
const input = payload.value;
|
|
3300
|
+
if (!Array.isArray(input)) {
|
|
3301
3301
|
payload.issues.push({
|
|
3302
|
-
input
|
|
3302
|
+
input,
|
|
3303
3303
|
inst,
|
|
3304
3304
|
expected: "tuple",
|
|
3305
3305
|
code: "invalid_type"
|
|
@@ -3309,12 +3309,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3309
3309
|
payload.value = [];
|
|
3310
3310
|
const proms = [];
|
|
3311
3311
|
if (!def.rest) {
|
|
3312
|
-
const tooBig =
|
|
3313
|
-
const tooSmall =
|
|
3312
|
+
const tooBig = input.length > items.length;
|
|
3313
|
+
const tooSmall = input.length < optStart - 1;
|
|
3314
3314
|
if (tooBig || tooSmall) {
|
|
3315
3315
|
payload.issues.push({
|
|
3316
3316
|
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
3317
|
-
input
|
|
3317
|
+
input,
|
|
3318
3318
|
inst,
|
|
3319
3319
|
origin: "array"
|
|
3320
3320
|
});
|
|
@@ -3324,12 +3324,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3324
3324
|
let i = -1;
|
|
3325
3325
|
for (const item of items) {
|
|
3326
3326
|
i++;
|
|
3327
|
-
if (i >=
|
|
3327
|
+
if (i >= input.length) {
|
|
3328
3328
|
if (i >= optStart)
|
|
3329
3329
|
continue;
|
|
3330
3330
|
}
|
|
3331
3331
|
const result = item._zod.run({
|
|
3332
|
-
value:
|
|
3332
|
+
value: input[i],
|
|
3333
3333
|
issues: []
|
|
3334
3334
|
}, ctx);
|
|
3335
3335
|
if (result instanceof Promise) {
|
|
@@ -3339,7 +3339,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
3341
|
if (def.rest) {
|
|
3342
|
-
const rest =
|
|
3342
|
+
const rest = input.slice(items.length);
|
|
3343
3343
|
for (const el of rest) {
|
|
3344
3344
|
i++;
|
|
3345
3345
|
const result = def.rest._zod.run({
|
|
@@ -3367,12 +3367,12 @@ function handleTupleResult(result, final, index) {
|
|
|
3367
3367
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
3368
3368
|
$ZodType.init(inst, def);
|
|
3369
3369
|
inst._zod.parse = (payload, ctx) => {
|
|
3370
|
-
const
|
|
3371
|
-
if (!isPlainObject(
|
|
3370
|
+
const input = payload.value;
|
|
3371
|
+
if (!isPlainObject(input)) {
|
|
3372
3372
|
payload.issues.push({
|
|
3373
3373
|
expected: "record",
|
|
3374
3374
|
code: "invalid_type",
|
|
3375
|
-
input
|
|
3375
|
+
input,
|
|
3376
3376
|
inst
|
|
3377
3377
|
});
|
|
3378
3378
|
return payload;
|
|
@@ -3383,7 +3383,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3383
3383
|
payload.value = {};
|
|
3384
3384
|
for (const key of values) {
|
|
3385
3385
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
3386
|
-
const result = def.valueType._zod.run({ value:
|
|
3386
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
3387
3387
|
if (result instanceof Promise) {
|
|
3388
3388
|
proms.push(result.then((result2) => {
|
|
3389
3389
|
if (result2.issues.length) {
|
|
@@ -3400,7 +3400,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3400
3400
|
}
|
|
3401
3401
|
}
|
|
3402
3402
|
let unrecognized;
|
|
3403
|
-
for (const key in
|
|
3403
|
+
for (const key in input) {
|
|
3404
3404
|
if (!values.has(key)) {
|
|
3405
3405
|
unrecognized = unrecognized ?? [];
|
|
3406
3406
|
unrecognized.push(key);
|
|
@@ -3409,14 +3409,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3409
3409
|
if (unrecognized && unrecognized.length > 0) {
|
|
3410
3410
|
payload.issues.push({
|
|
3411
3411
|
code: "unrecognized_keys",
|
|
3412
|
-
input
|
|
3412
|
+
input,
|
|
3413
3413
|
inst,
|
|
3414
3414
|
keys: unrecognized
|
|
3415
3415
|
});
|
|
3416
3416
|
}
|
|
3417
3417
|
} else {
|
|
3418
3418
|
payload.value = {};
|
|
3419
|
-
for (const key of Reflect.ownKeys(
|
|
3419
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
3420
3420
|
if (key === "__proto__")
|
|
3421
3421
|
continue;
|
|
3422
3422
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
@@ -3435,7 +3435,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3435
3435
|
payload.value[keyResult.value] = keyResult.value;
|
|
3436
3436
|
continue;
|
|
3437
3437
|
}
|
|
3438
|
-
const result = def.valueType._zod.run({ value:
|
|
3438
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
3439
3439
|
if (result instanceof Promise) {
|
|
3440
3440
|
proms.push(result.then((result2) => {
|
|
3441
3441
|
if (result2.issues.length) {
|
|
@@ -3460,27 +3460,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3460
3460
|
var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
3461
3461
|
$ZodType.init(inst, def);
|
|
3462
3462
|
inst._zod.parse = (payload, ctx) => {
|
|
3463
|
-
const
|
|
3464
|
-
if (!(
|
|
3463
|
+
const input = payload.value;
|
|
3464
|
+
if (!(input instanceof Map)) {
|
|
3465
3465
|
payload.issues.push({
|
|
3466
3466
|
expected: "map",
|
|
3467
3467
|
code: "invalid_type",
|
|
3468
|
-
input
|
|
3468
|
+
input,
|
|
3469
3469
|
inst
|
|
3470
3470
|
});
|
|
3471
3471
|
return payload;
|
|
3472
3472
|
}
|
|
3473
3473
|
const proms = [];
|
|
3474
3474
|
payload.value = /* @__PURE__ */ new Map();
|
|
3475
|
-
for (const [key, value] of
|
|
3475
|
+
for (const [key, value] of input) {
|
|
3476
3476
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
3477
3477
|
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
|
|
3478
3478
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
3479
3479
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
3480
|
-
handleMapResult(keyResult2, valueResult2, payload, key,
|
|
3480
|
+
handleMapResult(keyResult2, valueResult2, payload, key, input, inst, ctx);
|
|
3481
3481
|
}));
|
|
3482
3482
|
} else {
|
|
3483
|
-
handleMapResult(keyResult, valueResult, payload, key,
|
|
3483
|
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
|
3484
3484
|
}
|
|
3485
3485
|
}
|
|
3486
3486
|
if (proms.length)
|
|
@@ -3488,7 +3488,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
3488
3488
|
return payload;
|
|
3489
3489
|
};
|
|
3490
3490
|
});
|
|
3491
|
-
function handleMapResult(keyResult, valueResult, final, key,
|
|
3491
|
+
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
3492
3492
|
if (keyResult.issues.length) {
|
|
3493
3493
|
if (propertyKeyTypes.has(typeof key)) {
|
|
3494
3494
|
final.issues.push(...prefixIssues(key, keyResult.issues));
|
|
@@ -3496,7 +3496,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
3496
3496
|
final.issues.push({
|
|
3497
3497
|
code: "invalid_key",
|
|
3498
3498
|
origin: "map",
|
|
3499
|
-
input
|
|
3499
|
+
input,
|
|
3500
3500
|
inst,
|
|
3501
3501
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
3502
3502
|
});
|
|
@@ -3509,7 +3509,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
3509
3509
|
final.issues.push({
|
|
3510
3510
|
origin: "map",
|
|
3511
3511
|
code: "invalid_element",
|
|
3512
|
-
input
|
|
3512
|
+
input,
|
|
3513
3513
|
inst,
|
|
3514
3514
|
key,
|
|
3515
3515
|
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
@@ -3521,10 +3521,10 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
3521
3521
|
var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
3522
3522
|
$ZodType.init(inst, def);
|
|
3523
3523
|
inst._zod.parse = (payload, ctx) => {
|
|
3524
|
-
const
|
|
3525
|
-
if (!(
|
|
3524
|
+
const input = payload.value;
|
|
3525
|
+
if (!(input instanceof Set)) {
|
|
3526
3526
|
payload.issues.push({
|
|
3527
|
-
input
|
|
3527
|
+
input,
|
|
3528
3528
|
inst,
|
|
3529
3529
|
expected: "set",
|
|
3530
3530
|
code: "invalid_type"
|
|
@@ -3533,7 +3533,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
3533
3533
|
}
|
|
3534
3534
|
const proms = [];
|
|
3535
3535
|
payload.value = /* @__PURE__ */ new Set();
|
|
3536
|
-
for (const item of
|
|
3536
|
+
for (const item of input) {
|
|
3537
3537
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
3538
3538
|
if (result instanceof Promise) {
|
|
3539
3539
|
proms.push(result.then((result2) => handleSetResult(result2, payload)));
|
|
@@ -3558,14 +3558,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
3558
3558
|
inst._zod.values = valuesSet;
|
|
3559
3559
|
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
3560
3560
|
inst._zod.parse = (payload, _ctx) => {
|
|
3561
|
-
const
|
|
3562
|
-
if (valuesSet.has(
|
|
3561
|
+
const input = payload.value;
|
|
3562
|
+
if (valuesSet.has(input)) {
|
|
3563
3563
|
return payload;
|
|
3564
3564
|
}
|
|
3565
3565
|
payload.issues.push({
|
|
3566
3566
|
code: "invalid_value",
|
|
3567
3567
|
values,
|
|
3568
|
-
input
|
|
3568
|
+
input,
|
|
3569
3569
|
inst
|
|
3570
3570
|
});
|
|
3571
3571
|
return payload;
|
|
@@ -3579,14 +3579,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
3579
3579
|
inst._zod.values = new Set(def.values);
|
|
3580
3580
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
3581
3581
|
inst._zod.parse = (payload, _ctx) => {
|
|
3582
|
-
const
|
|
3583
|
-
if (inst._zod.values.has(
|
|
3582
|
+
const input = payload.value;
|
|
3583
|
+
if (inst._zod.values.has(input)) {
|
|
3584
3584
|
return payload;
|
|
3585
3585
|
}
|
|
3586
3586
|
payload.issues.push({
|
|
3587
3587
|
code: "invalid_value",
|
|
3588
3588
|
values: def.values,
|
|
3589
|
-
input
|
|
3589
|
+
input,
|
|
3590
3590
|
inst
|
|
3591
3591
|
});
|
|
3592
3592
|
return payload;
|
|
@@ -3595,13 +3595,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
3595
3595
|
var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
|
|
3596
3596
|
$ZodType.init(inst, def);
|
|
3597
3597
|
inst._zod.parse = (payload, _ctx) => {
|
|
3598
|
-
const
|
|
3599
|
-
if (
|
|
3598
|
+
const input = payload.value;
|
|
3599
|
+
if (input instanceof File)
|
|
3600
3600
|
return payload;
|
|
3601
3601
|
payload.issues.push({
|
|
3602
3602
|
expected: "file",
|
|
3603
3603
|
code: "invalid_type",
|
|
3604
|
-
input
|
|
3604
|
+
input,
|
|
3605
3605
|
inst
|
|
3606
3606
|
});
|
|
3607
3607
|
return payload;
|
|
@@ -3628,8 +3628,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
3628
3628
|
return payload;
|
|
3629
3629
|
};
|
|
3630
3630
|
});
|
|
3631
|
-
function handleOptionalResult(result,
|
|
3632
|
-
if (result.issues.length &&
|
|
3631
|
+
function handleOptionalResult(result, input) {
|
|
3632
|
+
if (result.issues.length && input === void 0) {
|
|
3633
3633
|
return { issues: [], value: void 0 };
|
|
3634
3634
|
}
|
|
3635
3635
|
return result;
|
|
@@ -4057,20 +4057,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
4057
4057
|
return payload;
|
|
4058
4058
|
};
|
|
4059
4059
|
inst._zod.check = (payload) => {
|
|
4060
|
-
const
|
|
4061
|
-
const r = def.fn(
|
|
4060
|
+
const input = payload.value;
|
|
4061
|
+
const r = def.fn(input);
|
|
4062
4062
|
if (r instanceof Promise) {
|
|
4063
|
-
return r.then((r2) => handleRefineResult(r2, payload,
|
|
4063
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
4064
4064
|
}
|
|
4065
|
-
handleRefineResult(r, payload,
|
|
4065
|
+
handleRefineResult(r, payload, input, inst);
|
|
4066
4066
|
return;
|
|
4067
4067
|
};
|
|
4068
4068
|
});
|
|
4069
|
-
function handleRefineResult(result, payload,
|
|
4069
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
4070
4070
|
if (!result) {
|
|
4071
4071
|
const _iss = {
|
|
4072
4072
|
code: "custom",
|
|
4073
|
-
input
|
|
4073
|
+
input,
|
|
4074
4074
|
inst,
|
|
4075
4075
|
// incorporates params.error into issue reporting
|
|
4076
4076
|
path: [...inst._zod.def.path ?? []],
|
|
@@ -10385,16 +10385,16 @@ function _overwrite(tx) {
|
|
|
10385
10385
|
});
|
|
10386
10386
|
}
|
|
10387
10387
|
function _normalize(form) {
|
|
10388
|
-
return _overwrite((
|
|
10388
|
+
return _overwrite((input) => input.normalize(form));
|
|
10389
10389
|
}
|
|
10390
10390
|
function _trim() {
|
|
10391
|
-
return _overwrite((
|
|
10391
|
+
return _overwrite((input) => input.trim());
|
|
10392
10392
|
}
|
|
10393
10393
|
function _toLowerCase() {
|
|
10394
|
-
return _overwrite((
|
|
10394
|
+
return _overwrite((input) => input.toLowerCase());
|
|
10395
10395
|
}
|
|
10396
10396
|
function _toUpperCase() {
|
|
10397
|
-
return _overwrite((
|
|
10397
|
+
return _overwrite((input) => input.toUpperCase());
|
|
10398
10398
|
}
|
|
10399
10399
|
function _array(Class2, element, params) {
|
|
10400
10400
|
return new Class2({
|
|
@@ -10636,8 +10636,8 @@ function _stringbool(Classes, _params) {
|
|
|
10636
10636
|
type: "pipe",
|
|
10637
10637
|
in: stringSchema,
|
|
10638
10638
|
out: booleanSchema,
|
|
10639
|
-
transform: ((
|
|
10640
|
-
let data =
|
|
10639
|
+
transform: ((input, payload) => {
|
|
10640
|
+
let data = input;
|
|
10641
10641
|
if (params.case !== "sensitive")
|
|
10642
10642
|
data = data.toLowerCase();
|
|
10643
10643
|
if (truthySet.has(data)) {
|
|
@@ -10656,8 +10656,8 @@ function _stringbool(Classes, _params) {
|
|
|
10656
10656
|
return {};
|
|
10657
10657
|
}
|
|
10658
10658
|
}),
|
|
10659
|
-
reverseTransform: ((
|
|
10660
|
-
if (
|
|
10659
|
+
reverseTransform: ((input, _payload) => {
|
|
10660
|
+
if (input === true) {
|
|
10661
10661
|
return truthyArray[0] || "true";
|
|
10662
10662
|
} else {
|
|
10663
10663
|
return falsyArray[0] || "false";
|
|
@@ -11368,21 +11368,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11368
11368
|
}
|
|
11369
11369
|
}
|
|
11370
11370
|
};
|
|
11371
|
-
function toJSONSchema(
|
|
11372
|
-
if (
|
|
11371
|
+
function toJSONSchema(input, _params) {
|
|
11372
|
+
if (input instanceof $ZodRegistry) {
|
|
11373
11373
|
const gen2 = new JSONSchemaGenerator(_params);
|
|
11374
11374
|
const defs = {};
|
|
11375
|
-
for (const entry of
|
|
11375
|
+
for (const entry of input._idmap.entries()) {
|
|
11376
11376
|
const [_, schema] = entry;
|
|
11377
11377
|
gen2.process(schema);
|
|
11378
11378
|
}
|
|
11379
11379
|
const schemas = {};
|
|
11380
11380
|
const external = {
|
|
11381
|
-
registry:
|
|
11381
|
+
registry: input,
|
|
11382
11382
|
uri: _params?.uri,
|
|
11383
11383
|
defs
|
|
11384
11384
|
};
|
|
11385
|
-
for (const entry of
|
|
11385
|
+
for (const entry of input._idmap.entries()) {
|
|
11386
11386
|
const [key, schema] = entry;
|
|
11387
11387
|
schemas[key] = gen2.emit(schema, {
|
|
11388
11388
|
..._params,
|
|
@@ -11398,8 +11398,8 @@ function toJSONSchema(input2, _params) {
|
|
|
11398
11398
|
return { schemas };
|
|
11399
11399
|
}
|
|
11400
11400
|
const gen = new JSONSchemaGenerator(_params);
|
|
11401
|
-
gen.process(
|
|
11402
|
-
return gen.emit(
|
|
11401
|
+
gen.process(input);
|
|
11402
|
+
return gen.emit(input, _params);
|
|
11403
11403
|
}
|
|
11404
11404
|
function isTransforming(_schema, _ctx) {
|
|
11405
11405
|
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
@@ -18278,6 +18278,39 @@ function generateAccessibilityMetadata(scale2) {
|
|
|
18278
18278
|
}
|
|
18279
18279
|
return metadata;
|
|
18280
18280
|
}
|
|
18281
|
+
var CONTRAST_WHITE = { l: 1, c: 0, h: 0, alpha: 1 };
|
|
18282
|
+
var CONTRAST_BLACK = { l: 0, c: 0, h: 0, alpha: 1 };
|
|
18283
|
+
var WCAG_AA_NORMAL = 4.5;
|
|
18284
|
+
var WCAG_AAA_NORMAL = 7;
|
|
18285
|
+
function assembleWcagAccessibility(scale2, reference) {
|
|
18286
|
+
const meta = generateAccessibilityMetadata([...scale2]);
|
|
18287
|
+
const onWhiteRatio = calculateWCAGContrast(reference, CONTRAST_WHITE);
|
|
18288
|
+
const onBlackRatio = calculateWCAGContrast(reference, CONTRAST_BLACK);
|
|
18289
|
+
return {
|
|
18290
|
+
wcagAA: meta.wcagAA,
|
|
18291
|
+
wcagAAA: meta.wcagAAA,
|
|
18292
|
+
onWhite: {
|
|
18293
|
+
wcagAA: onWhiteRatio >= WCAG_AA_NORMAL,
|
|
18294
|
+
wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL,
|
|
18295
|
+
contrastRatio: onWhiteRatio,
|
|
18296
|
+
aa: meta.onWhite.aa,
|
|
18297
|
+
aaa: meta.onWhite.aaa
|
|
18298
|
+
},
|
|
18299
|
+
onBlack: {
|
|
18300
|
+
wcagAA: onBlackRatio >= WCAG_AA_NORMAL,
|
|
18301
|
+
wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL,
|
|
18302
|
+
contrastRatio: onBlackRatio,
|
|
18303
|
+
aa: meta.onBlack.aa,
|
|
18304
|
+
aaa: meta.onBlack.aaa
|
|
18305
|
+
}
|
|
18306
|
+
};
|
|
18307
|
+
}
|
|
18308
|
+
function rebakeAccessibility(value) {
|
|
18309
|
+
if (!("scale" in value) || !Array.isArray(value.scale)) return value;
|
|
18310
|
+
const reference = value.scale[5] ?? value.scale[0];
|
|
18311
|
+
if (!reference) return value;
|
|
18312
|
+
return { ...value, accessibility: assembleWcagAccessibility(value.scale, reference) };
|
|
18313
|
+
}
|
|
18281
18314
|
|
|
18282
18315
|
// ../color-utils/src/analysis.ts
|
|
18283
18316
|
function isLightColor(color) {
|
|
@@ -21136,9 +21169,9 @@ var SemanticSelectionError = class extends Error {
|
|
|
21136
21169
|
};
|
|
21137
21170
|
var STATE_USES = ["hover", "active", "focus", "disabled"];
|
|
21138
21171
|
var STATE_RANK_STEP = {
|
|
21139
|
-
hover: (rank) => rank +
|
|
21140
|
-
active: (rank) => rank + 2,
|
|
21141
|
-
focus: (rank) => rank +
|
|
21172
|
+
hover: (rank, _l, s) => rank + s,
|
|
21173
|
+
active: (rank, _l, s) => rank + 2 * s,
|
|
21174
|
+
focus: (rank, _l, s) => rank + s,
|
|
21142
21175
|
disabled: (_rank, ladder) => closestRankTo(ladder, 5)
|
|
21143
21176
|
};
|
|
21144
21177
|
function partnerForBase(pairs, base) {
|
|
@@ -21284,7 +21317,7 @@ function semanticFor(family, options) {
|
|
|
21284
21317
|
tier: (fromAAA ? exactAAA : exactAA) !== void 0 ? "pair-exact" : "pair-nearest"
|
|
21285
21318
|
};
|
|
21286
21319
|
}
|
|
21287
|
-
function statePair(use, from) {
|
|
21320
|
+
function statePair(use, from, dark) {
|
|
21288
21321
|
const precomputed = refs.stateReferences?.[use];
|
|
21289
21322
|
if (precomputed) {
|
|
21290
21323
|
return {
|
|
@@ -21303,7 +21336,8 @@ function semanticFor(family, options) {
|
|
|
21303
21336
|
const base = requireIndex(from, familyName);
|
|
21304
21337
|
const ladder = collectLadder(aaaPairs);
|
|
21305
21338
|
const baseRank = closestRankTo(ladder, base);
|
|
21306
|
-
const
|
|
21339
|
+
const sign = dark ? -1 : 1;
|
|
21340
|
+
const targetRank = STATE_RANK_STEP[use](baseRank, ladder, sign);
|
|
21307
21341
|
const clampedRank = Math.max(0, Math.min(ladder.length - 1, targetRank));
|
|
21308
21342
|
const targetIndex = ladder[clampedRank];
|
|
21309
21343
|
if (targetIndex === void 0) {
|
|
@@ -21365,11 +21399,11 @@ function semanticFor(family, options) {
|
|
|
21365
21399
|
pair(request) {
|
|
21366
21400
|
const level = request.level ?? "AAA";
|
|
21367
21401
|
if (request.use === "foreground") return foregroundPair(request.from, level);
|
|
21368
|
-
return statePair(request.use, request.from);
|
|
21402
|
+
return statePair(request.use, request.from, request.dark);
|
|
21369
21403
|
},
|
|
21370
|
-
states(from) {
|
|
21404
|
+
states(from, dark) {
|
|
21371
21405
|
const out = {};
|
|
21372
|
-
for (const use of STATE_USES) out[use] = statePair(use, from);
|
|
21406
|
+
for (const use of STATE_USES) out[use] = statePair(use, from, dark);
|
|
21373
21407
|
return out;
|
|
21374
21408
|
},
|
|
21375
21409
|
invert
|
|
@@ -21385,9 +21419,7 @@ function buildColorValue(oklch2, options = {}) {
|
|
|
21385
21419
|
(v) => v !== void 0
|
|
21386
21420
|
);
|
|
21387
21421
|
const harmony = generateHarmony(oklch2);
|
|
21388
|
-
const
|
|
21389
|
-
const contrastOnWhite = calculateWCAGContrast(oklch2, WHITE);
|
|
21390
|
-
const contrastOnBlack = calculateWCAGContrast(oklch2, BLACK);
|
|
21422
|
+
const wcagAccessibility = assembleWcagAccessibility(scale2, oklch2);
|
|
21391
21423
|
const apcaOnWhite = calculateAPCAContrast(oklch2, WHITE);
|
|
21392
21424
|
const apcaOnBlack = calculateAPCAContrast(oklch2, BLACK);
|
|
21393
21425
|
const temperature = getColorTemperature(oklch2);
|
|
@@ -21416,22 +21448,7 @@ function buildColorValue(oklch2, options = {}) {
|
|
|
21416
21448
|
},
|
|
21417
21449
|
// Accessibility
|
|
21418
21450
|
accessibility: {
|
|
21419
|
-
|
|
21420
|
-
wcagAAA: accessibilityMeta.wcagAAA,
|
|
21421
|
-
onWhite: {
|
|
21422
|
-
wcagAA: contrastOnWhite >= 4.5,
|
|
21423
|
-
wcagAAA: contrastOnWhite >= 7,
|
|
21424
|
-
contrastRatio: contrastOnWhite,
|
|
21425
|
-
aa: accessibilityMeta.onWhite.aa,
|
|
21426
|
-
aaa: accessibilityMeta.onWhite.aaa
|
|
21427
|
-
},
|
|
21428
|
-
onBlack: {
|
|
21429
|
-
wcagAA: contrastOnBlack >= 4.5,
|
|
21430
|
-
wcagAAA: contrastOnBlack >= 7,
|
|
21431
|
-
contrastRatio: contrastOnBlack,
|
|
21432
|
-
aa: accessibilityMeta.onBlack.aa,
|
|
21433
|
-
aaa: accessibilityMeta.onBlack.aaa
|
|
21434
|
-
},
|
|
21451
|
+
...wcagAccessibility,
|
|
21435
21452
|
apca: {
|
|
21436
21453
|
onWhite: apcaOnWhite,
|
|
21437
21454
|
onBlack: apcaOnBlack,
|
|
@@ -21498,6 +21515,10 @@ var ComponentCategorySchema = external_exports.object({
|
|
|
21498
21515
|
description: external_exports.string().optional()
|
|
21499
21516
|
});
|
|
21500
21517
|
|
|
21518
|
+
// ../shared/src/fill-signature.ts
|
|
21519
|
+
var RESERVED_FILL_SEGMENTS = ["to", "via", "from"];
|
|
21520
|
+
var SEPARATOR = `-${RESERVED_FILL_SEGMENTS[0]}-`;
|
|
21521
|
+
|
|
21501
21522
|
// ../shared/src/types.ts
|
|
21502
21523
|
var COMPUTED = Symbol.for(
|
|
21503
21524
|
"rafters.computed"
|
|
@@ -22383,10 +22404,8 @@ function groupTokens(tokens) {
|
|
|
22383
22404
|
depth: [],
|
|
22384
22405
|
motion: [],
|
|
22385
22406
|
breakpoint: [],
|
|
22386
|
-
elevation: [],
|
|
22387
22407
|
focus: [],
|
|
22388
22408
|
"typography-composite": [],
|
|
22389
|
-
fill: [],
|
|
22390
22409
|
other: []
|
|
22391
22410
|
};
|
|
22392
22411
|
for (const token of tokens) {
|
|
@@ -22418,18 +22437,12 @@ function groupTokens(tokens) {
|
|
|
22418
22437
|
case "breakpoint":
|
|
22419
22438
|
groups.breakpoint.push(token);
|
|
22420
22439
|
break;
|
|
22421
|
-
case "elevation":
|
|
22422
|
-
groups.elevation.push(token);
|
|
22423
|
-
break;
|
|
22424
22440
|
case "focus":
|
|
22425
22441
|
groups.focus.push(token);
|
|
22426
22442
|
break;
|
|
22427
22443
|
case "typography-composite":
|
|
22428
22444
|
groups["typography-composite"].push(token);
|
|
22429
22445
|
break;
|
|
22430
|
-
case "fill":
|
|
22431
|
-
groups.fill.push(token);
|
|
22432
|
-
break;
|
|
22433
22446
|
default:
|
|
22434
22447
|
groups.other.push(token);
|
|
22435
22448
|
}
|
|
@@ -22582,14 +22595,6 @@ function generateThemeBlock(groups) {
|
|
|
22582
22595
|
}
|
|
22583
22596
|
lines.push("");
|
|
22584
22597
|
}
|
|
22585
|
-
if (groups.elevation.length > 0) {
|
|
22586
|
-
for (const token of groups.elevation) {
|
|
22587
|
-
const value = tokenValueToCSS(token);
|
|
22588
|
-
if (value === null) continue;
|
|
22589
|
-
lines.push(` --${token.name}: ${value};`);
|
|
22590
|
-
}
|
|
22591
|
-
lines.push("");
|
|
22592
|
-
}
|
|
22593
22598
|
if (groups.focus.length > 0) {
|
|
22594
22599
|
for (const token of groups.focus) {
|
|
22595
22600
|
const value = tokenValueToCSS(token);
|
|
@@ -22598,13 +22603,6 @@ function generateThemeBlock(groups) {
|
|
|
22598
22603
|
}
|
|
22599
22604
|
lines.push("");
|
|
22600
22605
|
}
|
|
22601
|
-
if (groups.fill.length > 0) {
|
|
22602
|
-
for (const token of groups.fill) {
|
|
22603
|
-
const value = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
|
|
22604
|
-
lines.push(` --${token.name}: ${value};`);
|
|
22605
|
-
}
|
|
22606
|
-
lines.push("");
|
|
22607
|
-
}
|
|
22608
22606
|
if (groups.other.length > 0) {
|
|
22609
22607
|
for (const token of groups.other) {
|
|
22610
22608
|
const value = tokenValueToCSS(token);
|
|
@@ -22719,6 +22717,17 @@ function generateAnimationTokens(motionTokens) {
|
|
|
22719
22717
|
}
|
|
22720
22718
|
return lines.join("\n");
|
|
22721
22719
|
}
|
|
22720
|
+
function generateDepthUtilities(depthTokens) {
|
|
22721
|
+
if (depthTokens.length === 0) return "";
|
|
22722
|
+
const lines = ["/* Depth (z-index) utilities -- words over numbers */"];
|
|
22723
|
+
for (const token of depthTokens) {
|
|
22724
|
+
if (typeof token.value !== "string" || !/^-?\d+$/.test(token.value)) continue;
|
|
22725
|
+
lines.push(`@utility z-${token.name} {`);
|
|
22726
|
+
lines.push(` z-index: var(--${token.name});`);
|
|
22727
|
+
lines.push("}");
|
|
22728
|
+
}
|
|
22729
|
+
return lines.join("\n");
|
|
22730
|
+
}
|
|
22722
22731
|
function generateTypographyCompositeUtilities(compositeTokens) {
|
|
22723
22732
|
if (compositeTokens.length === 0) {
|
|
22724
22733
|
return "";
|
|
@@ -22836,6 +22845,11 @@ function tokensToTailwind(tokens, options = {}, typographyOverrides = []) {
|
|
|
22836
22845
|
sections.push("");
|
|
22837
22846
|
sections.push(typographyUtilities);
|
|
22838
22847
|
}
|
|
22848
|
+
const depthUtilities = generateDepthUtilities(groups.depth);
|
|
22849
|
+
if (depthUtilities) {
|
|
22850
|
+
sections.push("");
|
|
22851
|
+
sections.push(depthUtilities);
|
|
22852
|
+
}
|
|
22839
22853
|
const overrideCSS = generateTypographyOverrideCSS(typographyOverrides);
|
|
22840
22854
|
if (overrideCSS) {
|
|
22841
22855
|
sections.push("");
|
|
@@ -22938,14 +22952,6 @@ function generateVarsRootBlock(groups) {
|
|
|
22938
22952
|
}
|
|
22939
22953
|
lines.push("");
|
|
22940
22954
|
}
|
|
22941
|
-
if (groups.elevation.length > 0) {
|
|
22942
|
-
for (const token of groups.elevation) {
|
|
22943
|
-
const value = tokenValueToCSS(token);
|
|
22944
|
-
if (value === null) continue;
|
|
22945
|
-
lines.push(` --rafters-${token.name}: ${value};`);
|
|
22946
|
-
}
|
|
22947
|
-
lines.push("");
|
|
22948
|
-
}
|
|
22949
22955
|
if (groups.focus.length > 0) {
|
|
22950
22956
|
for (const token of groups.focus) {
|
|
22951
22957
|
const value = tokenValueToCSS(token);
|
|
@@ -22954,13 +22960,6 @@ function generateVarsRootBlock(groups) {
|
|
|
22954
22960
|
}
|
|
22955
22961
|
lines.push("");
|
|
22956
22962
|
}
|
|
22957
|
-
if (groups.fill.length > 0) {
|
|
22958
|
-
for (const token of groups.fill) {
|
|
22959
|
-
const value = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
|
|
22960
|
-
lines.push(` --rafters-${token.name}: ${value};`);
|
|
22961
|
-
}
|
|
22962
|
-
lines.push("");
|
|
22963
|
-
}
|
|
22964
22963
|
if (groups.other.length > 0) {
|
|
22965
22964
|
for (const token of groups.other) {
|
|
22966
22965
|
const value = tokenValueToCSS(token);
|
|
@@ -23276,15 +23275,6 @@ var DEPTH_LEVELS = [
|
|
|
23276
23275
|
"tooltip",
|
|
23277
23276
|
"overlay"
|
|
23278
23277
|
];
|
|
23279
|
-
var ELEVATION_LEVELS = [
|
|
23280
|
-
"surface",
|
|
23281
|
-
"raised",
|
|
23282
|
-
"overlay",
|
|
23283
|
-
"sticky",
|
|
23284
|
-
"modal",
|
|
23285
|
-
"popover",
|
|
23286
|
-
"tooltip"
|
|
23287
|
-
];
|
|
23288
23278
|
var MOTION_DURATION_SCALE = ["instant", "fast", "normal", "slow", "slower"];
|
|
23289
23279
|
var EASING_CURVES = [
|
|
23290
23280
|
"linear",
|
|
@@ -23559,8 +23549,8 @@ function generateColorTokens(_config, colorScales) {
|
|
|
23559
23549
|
}
|
|
23560
23550
|
var WHITE2 = { l: 1, c: 0, h: 0, alpha: 1 };
|
|
23561
23551
|
var BLACK2 = { l: 0, c: 0, h: 0, alpha: 1 };
|
|
23562
|
-
var
|
|
23563
|
-
var
|
|
23552
|
+
var WCAG_AA_NORMAL2 = 4.5;
|
|
23553
|
+
var WCAG_AAA_NORMAL2 = 7;
|
|
23564
23554
|
var FAMILY_REFERENCE_INDEX = 5;
|
|
23565
23555
|
function buildColorAccessibility(scale2) {
|
|
23566
23556
|
const meta = generateAccessibilityMetadata(scale2);
|
|
@@ -23574,15 +23564,15 @@ function buildColorAccessibility(scale2) {
|
|
|
23574
23564
|
wcagAA: meta.wcagAA,
|
|
23575
23565
|
wcagAAA: meta.wcagAAA,
|
|
23576
23566
|
onWhite: {
|
|
23577
|
-
wcagAA: onWhiteRatio >=
|
|
23578
|
-
wcagAAA: onWhiteRatio >=
|
|
23567
|
+
wcagAA: onWhiteRatio >= WCAG_AA_NORMAL2,
|
|
23568
|
+
wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL2,
|
|
23579
23569
|
contrastRatio: onWhiteRatio,
|
|
23580
23570
|
aa: meta.onWhite.aa,
|
|
23581
23571
|
aaa: meta.onWhite.aaa
|
|
23582
23572
|
},
|
|
23583
23573
|
onBlack: {
|
|
23584
|
-
wcagAA: onBlackRatio >=
|
|
23585
|
-
wcagAAA: onBlackRatio >=
|
|
23574
|
+
wcagAA: onBlackRatio >= WCAG_AA_NORMAL2,
|
|
23575
|
+
wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL2,
|
|
23586
23576
|
contrastRatio: onBlackRatio,
|
|
23587
23577
|
aa: meta.onBlack.aa,
|
|
23588
23578
|
aaa: meta.onBlack.aaa
|
|
@@ -23717,7 +23707,9 @@ var DEFAULT_DEPTH_DEFINITIONS = {
|
|
|
23717
23707
|
stackingContext: false
|
|
23718
23708
|
},
|
|
23719
23709
|
dropdown: {
|
|
23720
|
-
|
|
23710
|
+
// The shadcn menu-content band (z-50): menu content must beat sticky
|
|
23711
|
+
// chrome and survive opening inside a dialog; DOM order breaks ties.
|
|
23712
|
+
value: 50,
|
|
23721
23713
|
meaning: "Dropdown menus and select options",
|
|
23722
23714
|
contexts: ["dropdowns", "select-menus", "autocomplete"],
|
|
23723
23715
|
stackingContext: true
|
|
@@ -23759,7 +23751,9 @@ var DEFAULT_DEPTH_DEFINITIONS = {
|
|
|
23759
23751
|
stackingContext: true
|
|
23760
23752
|
},
|
|
23761
23753
|
overlay: {
|
|
23762
|
-
|
|
23754
|
+
// Backdrops dim BEHIND the modal they serve: below modal (40), above
|
|
23755
|
+
// fixed chrome (30) so the dim still covers sticky/fixed elements.
|
|
23756
|
+
value: 35,
|
|
23763
23757
|
meaning: "Overlay backdrops - screen-dimming layers behind modals",
|
|
23764
23758
|
contexts: ["modal-backdrop", "drawer-backdrop", "sheet-backdrop"],
|
|
23765
23759
|
stackingContext: true
|
|
@@ -23861,109 +23855,6 @@ var DEFAULT_SHADOW_DEFINITIONS = {
|
|
|
23861
23855
|
contexts: ["critical-modals", "overlays", "drawer-panels"]
|
|
23862
23856
|
}
|
|
23863
23857
|
};
|
|
23864
|
-
var DEFAULT_FILL_DEFINITIONS = {
|
|
23865
|
-
surface: {
|
|
23866
|
-
color: "neutral-900",
|
|
23867
|
-
foreground: "neutral-100",
|
|
23868
|
-
meaning: "Primary content surface",
|
|
23869
|
-
contexts: ["surface"]
|
|
23870
|
-
},
|
|
23871
|
-
panel: {
|
|
23872
|
-
color: "neutral-800",
|
|
23873
|
-
opacity: 0.95,
|
|
23874
|
-
foreground: "neutral-100",
|
|
23875
|
-
meaning: "Elevated panel",
|
|
23876
|
-
contexts: ["surface"]
|
|
23877
|
-
},
|
|
23878
|
-
overlay: {
|
|
23879
|
-
color: "neutral-950",
|
|
23880
|
-
opacity: 0.8,
|
|
23881
|
-
backdropBlur: "sm",
|
|
23882
|
-
foreground: "neutral-50",
|
|
23883
|
-
meaning: "Modal backdrop",
|
|
23884
|
-
contexts: ["surface"]
|
|
23885
|
-
},
|
|
23886
|
-
glass: {
|
|
23887
|
-
color: "neutral-900",
|
|
23888
|
-
opacity: 0.6,
|
|
23889
|
-
backdropBlur: "md",
|
|
23890
|
-
foreground: "neutral-100",
|
|
23891
|
-
meaning: "Glass morphism",
|
|
23892
|
-
contexts: ["surface"]
|
|
23893
|
-
},
|
|
23894
|
-
primary: {
|
|
23895
|
-
color: "primary",
|
|
23896
|
-
foreground: "primary-foreground",
|
|
23897
|
-
meaning: "Primary brand surface",
|
|
23898
|
-
contexts: ["surface", "text"]
|
|
23899
|
-
},
|
|
23900
|
-
muted: {
|
|
23901
|
-
color: "muted",
|
|
23902
|
-
foreground: "muted-foreground",
|
|
23903
|
-
meaning: "Subdued surface for secondary content",
|
|
23904
|
-
contexts: ["surface"]
|
|
23905
|
-
},
|
|
23906
|
-
hero: {
|
|
23907
|
-
gradient: {
|
|
23908
|
-
direction: "to-b",
|
|
23909
|
-
stops: [{ color: "primary" }, { color: "primary", opacity: 0 }]
|
|
23910
|
-
},
|
|
23911
|
-
foreground: "primary-foreground",
|
|
23912
|
-
meaning: "Hero fade gradient",
|
|
23913
|
-
contexts: ["surface", "text"]
|
|
23914
|
-
}
|
|
23915
|
-
};
|
|
23916
|
-
var DEFAULT_ELEVATION_DEFINITIONS = {
|
|
23917
|
-
surface: {
|
|
23918
|
-
depth: "depth-base",
|
|
23919
|
-
shadow: "shadow-none",
|
|
23920
|
-
meaning: "Surface level - flat, in-flow elements",
|
|
23921
|
-
contexts: ["page-content", "inline-elements", "flat-cards"],
|
|
23922
|
-
useCase: "Default level for content that doesn't need elevation"
|
|
23923
|
-
},
|
|
23924
|
-
raised: {
|
|
23925
|
-
depth: "depth-base",
|
|
23926
|
-
shadow: "shadow-sm",
|
|
23927
|
-
meaning: "Slightly raised - subtle depth without z-index change",
|
|
23928
|
-
contexts: ["cards", "panels", "list-items"],
|
|
23929
|
-
useCase: "Cards and containers that need subtle visual separation"
|
|
23930
|
-
},
|
|
23931
|
-
overlay: {
|
|
23932
|
-
depth: "depth-dropdown",
|
|
23933
|
-
shadow: "shadow",
|
|
23934
|
-
meaning: "Overlay level - dropdowns and menus",
|
|
23935
|
-
contexts: ["dropdowns", "select-menus", "autocomplete", "context-menus"],
|
|
23936
|
-
useCase: "Elements that appear over content but aren't blocking"
|
|
23937
|
-
},
|
|
23938
|
-
sticky: {
|
|
23939
|
-
depth: "depth-sticky",
|
|
23940
|
-
shadow: "shadow-md",
|
|
23941
|
-
meaning: "Sticky level - persistent navigation",
|
|
23942
|
-
contexts: ["sticky-header", "sticky-sidebar", "floating-nav"],
|
|
23943
|
-
useCase: "Elements that stick to viewport edges during scroll"
|
|
23944
|
-
},
|
|
23945
|
-
modal: {
|
|
23946
|
-
depth: "depth-modal",
|
|
23947
|
-
shadow: "shadow-lg",
|
|
23948
|
-
meaning: "Modal level - blocking dialogs",
|
|
23949
|
-
contexts: ["modals", "dialogs", "sheets", "drawers"],
|
|
23950
|
-
useCase: "Elements that block interaction with content below"
|
|
23951
|
-
},
|
|
23952
|
-
popover: {
|
|
23953
|
-
depth: "depth-popover",
|
|
23954
|
-
shadow: "shadow-xl",
|
|
23955
|
-
meaning: "Popover level - above modals",
|
|
23956
|
-
contexts: ["popovers", "nested-dialogs", "command-palette"],
|
|
23957
|
-
useCase: "Elements that can appear above modals (rare)"
|
|
23958
|
-
},
|
|
23959
|
-
tooltip: {
|
|
23960
|
-
depth: "depth-tooltip",
|
|
23961
|
-
shadow: "shadow-lg",
|
|
23962
|
-
meaning: "Tooltip level - highest common UI",
|
|
23963
|
-
contexts: ["tooltips", "toast-notifications", "snackbars"],
|
|
23964
|
-
useCase: "Transient information that appears above everything"
|
|
23965
|
-
}
|
|
23966
|
-
};
|
|
23967
23858
|
var DEFAULT_DURATION_DEFINITIONS = {
|
|
23968
23859
|
instant: {
|
|
23969
23860
|
step: "instant",
|
|
@@ -24441,7 +24332,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
24441
24332
|
// Card surfaces
|
|
24442
24333
|
card: {
|
|
24443
24334
|
light: { family: "neutral", position: "50" },
|
|
24444
|
-
dark: { family: "neutral", position: "
|
|
24335
|
+
dark: { family: "neutral", position: "700" },
|
|
24445
24336
|
meaning: "Card and contained surface background",
|
|
24446
24337
|
contexts: ["cards", "modals", "dialogs", "panels"],
|
|
24447
24338
|
do: ["Use for elevated surfaces"],
|
|
@@ -24457,7 +24348,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
24457
24348
|
},
|
|
24458
24349
|
"card-hover": {
|
|
24459
24350
|
light: { family: "neutral", position: "100" },
|
|
24460
|
-
dark: { family: "neutral", position: "
|
|
24351
|
+
dark: { family: "neutral", position: "600" },
|
|
24461
24352
|
meaning: "Card hover state background",
|
|
24462
24353
|
contexts: ["card-hover"],
|
|
24463
24354
|
do: ["Use for card hover states"],
|
|
@@ -24465,16 +24356,48 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
24465
24356
|
},
|
|
24466
24357
|
"card-border": {
|
|
24467
24358
|
light: { family: "neutral", position: "200" },
|
|
24468
|
-
dark: { family: "neutral", position: "
|
|
24359
|
+
dark: { family: "neutral", position: "500" },
|
|
24469
24360
|
meaning: "Card border color",
|
|
24470
24361
|
contexts: ["card-borders"],
|
|
24471
24362
|
do: ["Use for card borders"],
|
|
24472
24363
|
never: ["Use for dividers within cards"]
|
|
24473
24364
|
},
|
|
24365
|
+
panel: {
|
|
24366
|
+
light: { family: "neutral", position: "100" },
|
|
24367
|
+
dark: { family: "neutral", position: "800" },
|
|
24368
|
+
meaning: "Elevated panel surface -- one level above the page",
|
|
24369
|
+
contexts: ["panels", "toolbars", "headers", "docks"],
|
|
24370
|
+
do: ["Use for persistent elevated chrome", "Pair with panel-foreground"],
|
|
24371
|
+
never: ["Use for page-level backgrounds", "Stack directly on card without a border"]
|
|
24372
|
+
},
|
|
24373
|
+
"panel-foreground": {
|
|
24374
|
+
light: { family: "neutral", position: "950" },
|
|
24375
|
+
dark: { family: "neutral", position: "50" },
|
|
24376
|
+
meaning: "Text and icons on panel surfaces",
|
|
24377
|
+
contexts: ["panel-text"],
|
|
24378
|
+
do: ["Use on panel backgrounds"],
|
|
24379
|
+
never: ["Use on page background"]
|
|
24380
|
+
},
|
|
24381
|
+
"panel-hover": {
|
|
24382
|
+
light: { family: "neutral", position: "200" },
|
|
24383
|
+
dark: { family: "neutral", position: "700" },
|
|
24384
|
+
meaning: "Panel surface hover state",
|
|
24385
|
+
contexts: ["panel-interaction"],
|
|
24386
|
+
do: ["Use for hoverable panel regions"],
|
|
24387
|
+
never: ["Use as a resting surface"]
|
|
24388
|
+
},
|
|
24389
|
+
"panel-border": {
|
|
24390
|
+
light: { family: "neutral", position: "200" },
|
|
24391
|
+
dark: { family: "neutral", position: "600" },
|
|
24392
|
+
meaning: "Borders separating panel from surrounding surfaces",
|
|
24393
|
+
contexts: ["panel-edges"],
|
|
24394
|
+
do: ["Use to delimit panels"],
|
|
24395
|
+
never: ["Use as text color"]
|
|
24396
|
+
},
|
|
24474
24397
|
// Popover surfaces
|
|
24475
24398
|
popover: {
|
|
24476
24399
|
light: { family: "neutral", position: "50" },
|
|
24477
|
-
dark: { family: "neutral", position: "
|
|
24400
|
+
dark: { family: "neutral", position: "700" },
|
|
24478
24401
|
meaning: "Popover and dropdown background",
|
|
24479
24402
|
contexts: ["dropdowns", "tooltips", "menus"],
|
|
24480
24403
|
do: ["Use for floating elements"],
|
|
@@ -25589,7 +25512,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
25589
25512
|
// ============================================================================
|
|
25590
25513
|
sidebar: {
|
|
25591
25514
|
light: { family: "neutral", position: "50" },
|
|
25592
|
-
dark: { family: "neutral", position: "
|
|
25515
|
+
dark: { family: "neutral", position: "900" },
|
|
25593
25516
|
meaning: "Sidebar background",
|
|
25594
25517
|
contexts: ["navigation-sidebar", "side-panels"],
|
|
25595
25518
|
do: ["Use for sidebar backgrounds"],
|
|
@@ -25677,7 +25600,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
25677
25600
|
},
|
|
25678
25601
|
"sidebar-item": {
|
|
25679
25602
|
light: { family: "neutral", position: "50" },
|
|
25680
|
-
dark: { family: "neutral", position: "
|
|
25603
|
+
dark: { family: "neutral", position: "900" },
|
|
25681
25604
|
meaning: "Sidebar item background",
|
|
25682
25605
|
contexts: ["sidebar-items"],
|
|
25683
25606
|
do: ["Use for sidebar item backgrounds"],
|
|
@@ -25760,7 +25683,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
25760
25683
|
// ============================================================================
|
|
25761
25684
|
nav: {
|
|
25762
25685
|
light: { family: "neutral", position: "50" },
|
|
25763
|
-
dark: { family: "neutral", position: "
|
|
25686
|
+
dark: { family: "neutral", position: "900" },
|
|
25764
25687
|
meaning: "Navigation background",
|
|
25765
25688
|
contexts: ["navbars", "breadcrumbs", "tabs"],
|
|
25766
25689
|
do: ["Use for navigation backgrounds"],
|
|
@@ -25859,7 +25782,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
|
|
|
25859
25782
|
},
|
|
25860
25783
|
"table-header": {
|
|
25861
25784
|
light: { family: "neutral", position: "100" },
|
|
25862
|
-
dark: { family: "neutral", position: "
|
|
25785
|
+
dark: { family: "neutral", position: "800" },
|
|
25863
25786
|
meaning: "Table header background",
|
|
25864
25787
|
contexts: ["table-headers"],
|
|
25865
25788
|
do: ["Use for table header backgrounds"],
|
|
@@ -26194,187 +26117,6 @@ function generateDepthTokens(_config, depthDefs) {
|
|
|
26194
26117
|
};
|
|
26195
26118
|
}
|
|
26196
26119
|
|
|
26197
|
-
// ../design-tokens/src/generators/elevation.ts
|
|
26198
|
-
function generateElevationTokens(_config, elevationDefs) {
|
|
26199
|
-
const tokens = [];
|
|
26200
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
26201
|
-
for (const level of ELEVATION_LEVELS) {
|
|
26202
|
-
const def = elevationDefs[level];
|
|
26203
|
-
if (!def) continue;
|
|
26204
|
-
const scaleIndex = ELEVATION_LEVELS.indexOf(level);
|
|
26205
|
-
tokens.push({
|
|
26206
|
-
name: `elevation-${level}`,
|
|
26207
|
-
value: JSON.stringify({
|
|
26208
|
-
depth: `var(--${def.depth})`,
|
|
26209
|
-
shadow: `var(--${def.shadow})`
|
|
26210
|
-
}),
|
|
26211
|
-
category: "elevation",
|
|
26212
|
-
namespace: "elevation",
|
|
26213
|
-
semanticMeaning: def.meaning,
|
|
26214
|
-
usageContext: def.contexts,
|
|
26215
|
-
scalePosition: scaleIndex,
|
|
26216
|
-
elevationLevel: level,
|
|
26217
|
-
shadowToken: def.shadow,
|
|
26218
|
-
dependsOn: [def.depth, def.shadow],
|
|
26219
|
-
description: `${def.useCase}. Combines ${def.depth} with ${def.shadow}.`,
|
|
26220
|
-
generatedAt: timestamp,
|
|
26221
|
-
containerQueryAware: false,
|
|
26222
|
-
userOverride: null,
|
|
26223
|
-
usagePatterns: {
|
|
26224
|
-
do: [
|
|
26225
|
-
`Use for ${def.contexts.slice(0, 2).join(", ")}`,
|
|
26226
|
-
"Apply both z-index and shadow together"
|
|
26227
|
-
],
|
|
26228
|
-
never: [
|
|
26229
|
-
"Mix elevation levels within same component",
|
|
26230
|
-
"Use without considering stacking context"
|
|
26231
|
-
]
|
|
26232
|
-
}
|
|
26233
|
-
});
|
|
26234
|
-
tokens.push({
|
|
26235
|
-
name: `elevation-${level}-z`,
|
|
26236
|
-
value: `var(--${def.depth})`,
|
|
26237
|
-
category: "elevation",
|
|
26238
|
-
namespace: "elevation",
|
|
26239
|
-
semanticMeaning: `Z-index component of ${level} elevation`,
|
|
26240
|
-
dependsOn: [def.depth],
|
|
26241
|
-
description: `Z-index for ${level} elevation level.`,
|
|
26242
|
-
generatedAt: timestamp,
|
|
26243
|
-
containerQueryAware: false,
|
|
26244
|
-
userOverride: null
|
|
26245
|
-
});
|
|
26246
|
-
tokens.push({
|
|
26247
|
-
name: `elevation-${level}-shadow`,
|
|
26248
|
-
value: `var(--${def.shadow})`,
|
|
26249
|
-
category: "elevation",
|
|
26250
|
-
namespace: "elevation",
|
|
26251
|
-
semanticMeaning: `Shadow component of ${level} elevation`,
|
|
26252
|
-
dependsOn: [def.shadow],
|
|
26253
|
-
description: `Shadow for ${level} elevation level.`,
|
|
26254
|
-
generatedAt: timestamp,
|
|
26255
|
-
containerQueryAware: false,
|
|
26256
|
-
userOverride: null
|
|
26257
|
-
});
|
|
26258
|
-
}
|
|
26259
|
-
tokens.push({
|
|
26260
|
-
name: "elevation-scale",
|
|
26261
|
-
value: JSON.stringify({
|
|
26262
|
-
levels: Object.fromEntries(
|
|
26263
|
-
Object.entries(elevationDefs).map(([k, v]) => [k, { depth: v.depth, shadow: v.shadow }])
|
|
26264
|
-
),
|
|
26265
|
-
note: "Each elevation level pairs z-index with appropriate shadow"
|
|
26266
|
-
}),
|
|
26267
|
-
category: "elevation",
|
|
26268
|
-
namespace: "elevation",
|
|
26269
|
-
semanticMeaning: "Elevation scale reference",
|
|
26270
|
-
description: "Complete elevation scale showing depth/shadow pairings.",
|
|
26271
|
-
generatedAt: timestamp,
|
|
26272
|
-
containerQueryAware: false,
|
|
26273
|
-
userOverride: null
|
|
26274
|
-
});
|
|
26275
|
-
return {
|
|
26276
|
-
namespace: "elevation",
|
|
26277
|
-
tokens
|
|
26278
|
-
};
|
|
26279
|
-
}
|
|
26280
|
-
|
|
26281
|
-
// ../design-tokens/src/generators/fill.ts
|
|
26282
|
-
function validateFillDef(name, def) {
|
|
26283
|
-
if (!def.color && !def.gradient) {
|
|
26284
|
-
return `Fill "${name}" must have either a color or gradient field`;
|
|
26285
|
-
}
|
|
26286
|
-
if (def.gradient) {
|
|
26287
|
-
if (!def.gradient.stops || def.gradient.stops.length < 2) {
|
|
26288
|
-
return `Fill "${name}" gradient must have at least 2 stops`;
|
|
26289
|
-
}
|
|
26290
|
-
}
|
|
26291
|
-
if (def.opacity !== void 0 && (def.opacity < 0 || def.opacity > 1)) {
|
|
26292
|
-
return `Fill "${name}" opacity must be between 0 and 1`;
|
|
26293
|
-
}
|
|
26294
|
-
const validBlurSizes = ["sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
26295
|
-
if (def.backdropBlur && !validBlurSizes.includes(def.backdropBlur)) {
|
|
26296
|
-
return `Fill "${name}" backdropBlur must be one of: ${validBlurSizes.join(", ")}`;
|
|
26297
|
-
}
|
|
26298
|
-
return null;
|
|
26299
|
-
}
|
|
26300
|
-
function serializeFillValue(def) {
|
|
26301
|
-
const parts = {};
|
|
26302
|
-
if (def.color) parts.color = def.color;
|
|
26303
|
-
if (def.opacity !== void 0) parts.opacity = def.opacity;
|
|
26304
|
-
if (def.foreground) parts.foreground = def.foreground;
|
|
26305
|
-
if (def.backdropBlur) parts.backdropBlur = def.backdropBlur;
|
|
26306
|
-
if (def.gradient) parts.gradient = def.gradient;
|
|
26307
|
-
return JSON.stringify(parts);
|
|
26308
|
-
}
|
|
26309
|
-
function generateFillTokens(_config, fillDefinitions) {
|
|
26310
|
-
const tokens = [];
|
|
26311
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
26312
|
-
const fillNames = Object.keys(fillDefinitions);
|
|
26313
|
-
for (const [name, def] of Object.entries(fillDefinitions)) {
|
|
26314
|
-
const error47 = validateFillDef(name, def);
|
|
26315
|
-
if (error47) {
|
|
26316
|
-
throw new Error(error47);
|
|
26317
|
-
}
|
|
26318
|
-
const dependsOn = [];
|
|
26319
|
-
if (def.color) {
|
|
26320
|
-
dependsOn.push(def.color);
|
|
26321
|
-
}
|
|
26322
|
-
if (def.foreground) {
|
|
26323
|
-
dependsOn.push(def.foreground);
|
|
26324
|
-
}
|
|
26325
|
-
if (def.gradient) {
|
|
26326
|
-
for (const stop of def.gradient.stops) {
|
|
26327
|
-
dependsOn.push(stop.color);
|
|
26328
|
-
}
|
|
26329
|
-
}
|
|
26330
|
-
tokens.push({
|
|
26331
|
-
name: `fill-${name}`,
|
|
26332
|
-
value: serializeFillValue(def),
|
|
26333
|
-
category: "fill",
|
|
26334
|
-
namespace: "fill",
|
|
26335
|
-
semanticMeaning: def.meaning,
|
|
26336
|
-
usageContext: def.contexts,
|
|
26337
|
-
dependsOn: dependsOn.length > 0 ? dependsOn : void 0,
|
|
26338
|
-
description: buildDescription(name, def),
|
|
26339
|
-
generatedAt: timestamp,
|
|
26340
|
-
containerQueryAware: true,
|
|
26341
|
-
scalePosition: fillNames.indexOf(name),
|
|
26342
|
-
userOverride: null,
|
|
26343
|
-
usagePatterns: {
|
|
26344
|
-
do: [
|
|
26345
|
-
`Use fill="${name}" on surface components (Container, Card) for ${def.meaning.toLowerCase()}`,
|
|
26346
|
-
...def.gradient ? [`Use color="${name}" on Typography for gradient text effect`] : []
|
|
26347
|
-
],
|
|
26348
|
-
never: [
|
|
26349
|
-
"Do not use raw bg-* classes when a fill token exists for the purpose",
|
|
26350
|
-
"Do not hardcode opacity values -- use the fill token instead"
|
|
26351
|
-
]
|
|
26352
|
-
}
|
|
26353
|
-
});
|
|
26354
|
-
}
|
|
26355
|
-
return {
|
|
26356
|
-
namespace: "fill",
|
|
26357
|
-
tokens
|
|
26358
|
-
};
|
|
26359
|
-
}
|
|
26360
|
-
function buildDescription(name, def) {
|
|
26361
|
-
const parts = [`Fill token "${name}"`];
|
|
26362
|
-
if (def.color && def.opacity !== void 0 && def.opacity < 1) {
|
|
26363
|
-
parts.push(`-- ${def.color} at ${Math.round(def.opacity * 100)}% opacity`);
|
|
26364
|
-
} else if (def.color) {
|
|
26365
|
-
parts.push(`-- solid ${def.color}`);
|
|
26366
|
-
}
|
|
26367
|
-
if (def.backdropBlur) {
|
|
26368
|
-
parts.push(`with backdrop-blur-${def.backdropBlur}`);
|
|
26369
|
-
}
|
|
26370
|
-
if (def.gradient) {
|
|
26371
|
-
const stops = def.gradient.stops.map((s) => s.color).join(" to ");
|
|
26372
|
-
parts.push(`-- gradient ${def.gradient.direction}: ${stops}`);
|
|
26373
|
-
}
|
|
26374
|
-
parts.push(`(${def.meaning})`);
|
|
26375
|
-
return parts.join(" ");
|
|
26376
|
-
}
|
|
26377
|
-
|
|
26378
26120
|
// ../design-tokens/src/generators/focus.ts
|
|
26379
26121
|
function pxToRem(px) {
|
|
26380
26122
|
const rem = Math.round(px / 16 * 1e3) / 1e3;
|
|
@@ -27430,19 +27172,6 @@ function generateRadiusTokens(config2, radiusDefs) {
|
|
|
27430
27172
|
}
|
|
27431
27173
|
|
|
27432
27174
|
// ../design-tokens/src/generators/semantic.ts
|
|
27433
|
-
var POSITION_TO_INDEX2 = {
|
|
27434
|
-
"50": 0,
|
|
27435
|
-
"100": 1,
|
|
27436
|
-
"200": 2,
|
|
27437
|
-
"300": 3,
|
|
27438
|
-
"400": 4,
|
|
27439
|
-
"500": 5,
|
|
27440
|
-
"600": 6,
|
|
27441
|
-
"700": 7,
|
|
27442
|
-
"800": 8,
|
|
27443
|
-
"900": 9,
|
|
27444
|
-
"950": 10
|
|
27445
|
-
};
|
|
27446
27175
|
var FOREGROUND_SUFFIXES = ["-foreground", "-text", "-contrast"];
|
|
27447
27176
|
var STATE_SUFFIXES = ["-hover", "-active", "-focus", "-disabled"];
|
|
27448
27177
|
function toColorRef(mapping) {
|
|
@@ -27472,7 +27201,7 @@ function deriveDerivation(name, lightRef, knownTokens) {
|
|
|
27472
27201
|
}
|
|
27473
27202
|
}
|
|
27474
27203
|
}
|
|
27475
|
-
const scalePosition =
|
|
27204
|
+
const scalePosition = POSITION_TO_INDEX[lightRef.position];
|
|
27476
27205
|
if (scalePosition === void 0) {
|
|
27477
27206
|
throw new Error(
|
|
27478
27207
|
`semantic generator: token "${name}" has unknown scale position "${lightRef.position}"`
|
|
@@ -27509,13 +27238,20 @@ function derivationParent(derivation, suffix = "") {
|
|
|
27509
27238
|
return `${derivation.against}${suffix}`;
|
|
27510
27239
|
}
|
|
27511
27240
|
}
|
|
27512
|
-
function deriveDarkBinding(derivation, parentName) {
|
|
27241
|
+
function deriveDarkBinding(derivation, parentName, darkRef) {
|
|
27513
27242
|
switch (derivation.kind) {
|
|
27514
|
-
case "scale":
|
|
27243
|
+
case "scale": {
|
|
27244
|
+
const scalePosition = POSITION_TO_INDEX[darkRef.position];
|
|
27245
|
+
if (scalePosition === void 0) {
|
|
27246
|
+
throw new Error(
|
|
27247
|
+
`semantic generator: invalid designed dark position "${darkRef.position}" for ${parentName}`
|
|
27248
|
+
);
|
|
27249
|
+
}
|
|
27515
27250
|
return {
|
|
27516
|
-
plugin: "
|
|
27517
|
-
input: {
|
|
27251
|
+
plugin: "scale",
|
|
27252
|
+
input: { familyName: darkRef.family, scalePosition }
|
|
27518
27253
|
};
|
|
27254
|
+
}
|
|
27519
27255
|
case "state":
|
|
27520
27256
|
return {
|
|
27521
27257
|
plugin: "state",
|
|
@@ -27539,7 +27275,7 @@ function generateSemanticTokens(_config) {
|
|
|
27539
27275
|
const binding = derivationToBinding(derivation);
|
|
27540
27276
|
const parent = derivationParent(derivation);
|
|
27541
27277
|
const darkName = `${name}--dark`;
|
|
27542
|
-
const darkBinding = deriveDarkBinding(derivation, name);
|
|
27278
|
+
const darkBinding = deriveDarkBinding(derivation, name, darkRef);
|
|
27543
27279
|
const darkParent = derivationParent(derivation, "--dark");
|
|
27544
27280
|
const dependsOn = [parent, darkName];
|
|
27545
27281
|
tokens.push({
|
|
@@ -28227,14 +27963,6 @@ function createGeneratorDefs(colorPaletteBases) {
|
|
|
28227
27963
|
DEFAULT_DELAY_DEFINITIONS
|
|
28228
27964
|
)
|
|
28229
27965
|
},
|
|
28230
|
-
{
|
|
28231
|
-
name: "fill",
|
|
28232
|
-
generate: (_config) => generateFillTokens(_config, DEFAULT_FILL_DEFINITIONS)
|
|
28233
|
-
},
|
|
28234
|
-
{
|
|
28235
|
-
name: "elevation",
|
|
28236
|
-
generate: (config2) => generateElevationTokens(config2, DEFAULT_ELEVATION_DEFINITIONS)
|
|
28237
|
-
},
|
|
28238
27966
|
{
|
|
28239
27967
|
name: "focus",
|
|
28240
27968
|
generate: (config2) => generateFocusTokens(config2, DEFAULT_FOCUS_CONFIGS)
|
|
@@ -28335,15 +28063,15 @@ var TokenGraph = class {
|
|
|
28335
28063
|
...extras?.binding ? { binding: extras.binding } : {}
|
|
28336
28064
|
});
|
|
28337
28065
|
}
|
|
28338
|
-
bind(name, pluginName,
|
|
28066
|
+
bind(name, pluginName, input) {
|
|
28339
28067
|
const plugin = this.requirePlugin(pluginName);
|
|
28340
|
-
plugin.inputSchema.parse(
|
|
28341
|
-
const directDeps = plugin.dependsOn(
|
|
28068
|
+
plugin.inputSchema.parse(input);
|
|
28069
|
+
const directDeps = plugin.dependsOn(input);
|
|
28342
28070
|
this.assertNoCycle(name, directDeps);
|
|
28343
28071
|
this.takeSnapshot();
|
|
28344
|
-
const value = plugin.transform(
|
|
28072
|
+
const value = plugin.transform(input, (n2) => this.get(n2));
|
|
28345
28073
|
plugin.outputSchema.parse(value);
|
|
28346
|
-
this.nodes.set(name, { name, value, binding: { plugin: pluginName, input
|
|
28074
|
+
this.nodes.set(name, { name, value, binding: { plugin: pluginName, input } });
|
|
28347
28075
|
this.cascadeFrom(name);
|
|
28348
28076
|
}
|
|
28349
28077
|
get(name) {
|
|
@@ -28888,11 +28616,11 @@ var TokenRegistry = class {
|
|
|
28888
28616
|
}
|
|
28889
28617
|
this.graph.set(name, value, options);
|
|
28890
28618
|
}
|
|
28891
|
-
bind(name, pluginName,
|
|
28619
|
+
bind(name, pluginName, input) {
|
|
28892
28620
|
if (!this.metadata.has(name)) {
|
|
28893
28621
|
throw new UnknownTokenError(name);
|
|
28894
28622
|
}
|
|
28895
|
-
this.graph.bind(name, pluginName,
|
|
28623
|
+
this.graph.bind(name, pluginName, input);
|
|
28896
28624
|
}
|
|
28897
28625
|
get(name) {
|
|
28898
28626
|
const node = this.graph.node(name);
|
|
@@ -29046,8 +28774,8 @@ function definePlugin(spec) {
|
|
|
29046
28774
|
name: spec.name,
|
|
29047
28775
|
inputSchema: spec.inputSchema,
|
|
29048
28776
|
outputSchema: spec.outputSchema,
|
|
29049
|
-
dependsOn: (
|
|
29050
|
-
transform: (
|
|
28777
|
+
dependsOn: (input) => spec.dependsOn(input),
|
|
28778
|
+
transform: (input, get3) => spec.transform(input, get3)
|
|
29051
28779
|
};
|
|
29052
28780
|
}
|
|
29053
28781
|
|
|
@@ -29060,11 +28788,11 @@ var calcPlugin = definePlugin({
|
|
|
29060
28788
|
name: "calc",
|
|
29061
28789
|
inputSchema: CalcInputSchema,
|
|
29062
28790
|
outputSchema: external_exports.string(),
|
|
29063
|
-
dependsOn: (
|
|
29064
|
-
transform: (
|
|
29065
|
-
let expression =
|
|
28791
|
+
dependsOn: (input) => input.tokens,
|
|
28792
|
+
transform: (input, get3) => {
|
|
28793
|
+
let expression = input.expression;
|
|
29066
28794
|
let detectedUnit = "";
|
|
29067
|
-
for (const tokenName of
|
|
28795
|
+
for (const tokenName of input.tokens) {
|
|
29068
28796
|
const tokenValue = get3(tokenName);
|
|
29069
28797
|
if (typeof tokenValue !== "string") {
|
|
29070
28798
|
throw new Error(`calc plugin: token "${tokenName}" value is not a string`);
|
|
@@ -29097,10 +28825,10 @@ var contrastPlugin = definePlugin({
|
|
|
29097
28825
|
name: "contrast",
|
|
29098
28826
|
inputSchema: ContrastInputSchema,
|
|
29099
28827
|
outputSchema: ColorReferenceSchema,
|
|
29100
|
-
dependsOn: (
|
|
29101
|
-
transform: (
|
|
29102
|
-
const { sem, resolved } = requireSemanticParent(
|
|
29103
|
-
const pair = sem.pair({ use: "foreground", from: resolved.ref.position, level:
|
|
28828
|
+
dependsOn: (input) => [input.against],
|
|
28829
|
+
transform: (input, get3) => {
|
|
28830
|
+
const { sem, resolved } = requireSemanticParent(input.against, get3, "contrast");
|
|
28831
|
+
const pair = sem.pair({ use: "foreground", from: resolved.ref.position, level: input.level });
|
|
29104
28832
|
return { family: pair.to.family, position: pair.to.position };
|
|
29105
28833
|
}
|
|
29106
28834
|
});
|
|
@@ -29113,9 +28841,9 @@ var invertPlugin = definePlugin({
|
|
|
29113
28841
|
name: "invert",
|
|
29114
28842
|
inputSchema: InvertInputSchema,
|
|
29115
28843
|
outputSchema: ColorReferenceSchema,
|
|
29116
|
-
dependsOn: (
|
|
29117
|
-
transform: (
|
|
29118
|
-
const { sem, resolved } = requireSemanticParent(
|
|
28844
|
+
dependsOn: (input) => [input.fromToken],
|
|
28845
|
+
transform: (input, get3) => {
|
|
28846
|
+
const { sem, resolved } = requireSemanticParent(input.fromToken, get3, "invert");
|
|
29119
28847
|
const lightPair = sem.pair({ use: "foreground", from: resolved.ref.position });
|
|
29120
28848
|
const darkPair = sem.invert(lightPair);
|
|
29121
28849
|
return { family: resolved.familyName, position: darkPair.from.position };
|
|
@@ -29131,15 +28859,15 @@ var scalePlugin = definePlugin({
|
|
|
29131
28859
|
name: "scale",
|
|
29132
28860
|
inputSchema: ScaleInputSchema,
|
|
29133
28861
|
outputSchema: ColorReferenceSchema,
|
|
29134
|
-
dependsOn: (
|
|
29135
|
-
transform: (
|
|
29136
|
-
const result = resolveFamily(
|
|
28862
|
+
dependsOn: (input) => [input.familyName],
|
|
28863
|
+
transform: (input, get3) => {
|
|
28864
|
+
const result = resolveFamily(input.familyName, get3);
|
|
29137
28865
|
if (!result) {
|
|
29138
|
-
throw new Error(`scale plugin: family "${
|
|
28866
|
+
throw new Error(`scale plugin: family "${input.familyName}" not found in registry`);
|
|
29139
28867
|
}
|
|
29140
|
-
const position = SCALE_POSITIONS[
|
|
28868
|
+
const position = SCALE_POSITIONS[input.scalePosition];
|
|
29141
28869
|
if (position === void 0) {
|
|
29142
|
-
throw new Error(`scale plugin: invalid position index ${
|
|
28870
|
+
throw new Error(`scale plugin: invalid position index ${input.scalePosition}`);
|
|
29143
28871
|
}
|
|
29144
28872
|
return { family: result.familyName, position };
|
|
29145
28873
|
}
|
|
@@ -29155,10 +28883,11 @@ var statePlugin = definePlugin({
|
|
|
29155
28883
|
name: "state",
|
|
29156
28884
|
inputSchema: StateInputSchema,
|
|
29157
28885
|
outputSchema: ColorReferenceSchema,
|
|
29158
|
-
dependsOn: (
|
|
29159
|
-
transform: (
|
|
29160
|
-
const
|
|
29161
|
-
const
|
|
28886
|
+
dependsOn: (input) => [input.from],
|
|
28887
|
+
transform: (input, get3) => {
|
|
28888
|
+
const dark = input.from.includes("--dark");
|
|
28889
|
+
const { sem, resolved } = requireSemanticParent(input.from, get3, "state");
|
|
28890
|
+
const pair = sem.pair({ use: input.stateType, from: resolved.ref.position, dark });
|
|
29162
28891
|
return { family: pair.to.family, position: pair.to.position };
|
|
29163
28892
|
}
|
|
29164
28893
|
});
|
|
@@ -29170,12 +28899,86 @@ async function backupCss(cssPath) {
|
|
|
29170
28899
|
await copyFile(cssPath, backupPath);
|
|
29171
28900
|
return backupPath;
|
|
29172
28901
|
}
|
|
28902
|
+
function cleanSourceCssBlocks(content) {
|
|
28903
|
+
function parseBlocks(src) {
|
|
28904
|
+
const blocks = [];
|
|
28905
|
+
let depth = 0;
|
|
28906
|
+
const headerStack = [];
|
|
28907
|
+
let segmentStart = 0;
|
|
28908
|
+
for (let i = 0; i < src.length; i++) {
|
|
28909
|
+
const ch = src.charAt(i);
|
|
28910
|
+
if (ch === "{") {
|
|
28911
|
+
headerStack.push(segmentStart);
|
|
28912
|
+
depth++;
|
|
28913
|
+
if (depth >= 1) {
|
|
28914
|
+
blocks.push({
|
|
28915
|
+
headerStart: segmentStart,
|
|
28916
|
+
bodyStart: i + 1,
|
|
28917
|
+
end: -1,
|
|
28918
|
+
header: src.slice(segmentStart, i).trim()
|
|
28919
|
+
});
|
|
28920
|
+
}
|
|
28921
|
+
segmentStart = i + 1;
|
|
28922
|
+
} else if (ch === "}") {
|
|
28923
|
+
depth--;
|
|
28924
|
+
const open = blocks.slice().reverse().find((b2) => b2.end === -1);
|
|
28925
|
+
if (open) open.end = i + 1;
|
|
28926
|
+
headerStack.pop();
|
|
28927
|
+
segmentStart = i + 1;
|
|
28928
|
+
} else if (ch === ";") {
|
|
28929
|
+
segmentStart = i + 1;
|
|
28930
|
+
}
|
|
28931
|
+
}
|
|
28932
|
+
return blocks.filter((b2) => b2.end !== -1);
|
|
28933
|
+
}
|
|
28934
|
+
function isContentEmpty(body) {
|
|
28935
|
+
return body.replace(/\/\*[\s\S]*?\*\//g, "").trim().length === 0;
|
|
28936
|
+
}
|
|
28937
|
+
let out = content;
|
|
28938
|
+
for (let pass = 0; pass < 10; pass++) {
|
|
28939
|
+
const blocks = parseBlocks(out);
|
|
28940
|
+
let edited = false;
|
|
28941
|
+
for (const block of blocks.sort((a2, b2) => b2.headerStart - a2.headerStart)) {
|
|
28942
|
+
const header = block.header;
|
|
28943
|
+
if (/^@theme\s+inline$/.test(header)) {
|
|
28944
|
+
out = out.slice(0, block.headerStart) + out.slice(block.end);
|
|
28945
|
+
edited = true;
|
|
28946
|
+
break;
|
|
28947
|
+
}
|
|
28948
|
+
if (header === ":root" || /(^|,)\s*:root\s*$/.test(header)) {
|
|
28949
|
+
const body = out.slice(block.bodyStart, block.end - 1);
|
|
28950
|
+
const cleanedBody = body.replace(/--[\w-]+\s*:[^;{}]*;?/g, "");
|
|
28951
|
+
if (isContentEmpty(cleanedBody)) {
|
|
28952
|
+
out = out.slice(0, block.headerStart) + out.slice(block.end);
|
|
28953
|
+
edited = true;
|
|
28954
|
+
break;
|
|
28955
|
+
}
|
|
28956
|
+
if (cleanedBody !== body) {
|
|
28957
|
+
out = out.slice(0, block.bodyStart) + cleanedBody + out.slice(block.end - 1);
|
|
28958
|
+
edited = true;
|
|
28959
|
+
break;
|
|
28960
|
+
}
|
|
28961
|
+
continue;
|
|
28962
|
+
}
|
|
28963
|
+
if (header.startsWith("@media") || header.startsWith("@supports")) {
|
|
28964
|
+
const body = out.slice(block.bodyStart, block.end - 1);
|
|
28965
|
+
if (isContentEmpty(body)) {
|
|
28966
|
+
out = out.slice(0, block.headerStart) + out.slice(block.end);
|
|
28967
|
+
edited = true;
|
|
28968
|
+
break;
|
|
28969
|
+
}
|
|
28970
|
+
}
|
|
28971
|
+
}
|
|
28972
|
+
if (!edited) break;
|
|
28973
|
+
}
|
|
28974
|
+
return out.replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n");
|
|
28975
|
+
}
|
|
29173
28976
|
async function stripImportedDeclarations(cwd, cssPath, importedNames) {
|
|
29174
28977
|
if (importedNames.length === 0) return;
|
|
29175
28978
|
const fullPath = join7(cwd, cssPath);
|
|
29176
28979
|
const content = await readFile4(fullPath, "utf-8");
|
|
29177
28980
|
const pattern = new RegExp(importedNames.map((n2) => `^\\s*--${n2}[^;]*;\\s*$`).join("|"), "gm");
|
|
29178
|
-
const cleaned = content.replace(pattern, "");
|
|
28981
|
+
const cleaned = cleanSourceCssBlocks(content.replace(pattern, ""));
|
|
29179
28982
|
const collapsed = cleaned.replace(/\n{3,}/g, "\n\n");
|
|
29180
28983
|
await writeFile2(fullPath, collapsed);
|
|
29181
28984
|
}
|
|
@@ -29357,6 +29160,8 @@ async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2, framewor
|
|
|
29357
29160
|
existingConfig.compositesPath = frameworkPaths.composites;
|
|
29358
29161
|
existingConfig.rulesPath = frameworkPaths.rules;
|
|
29359
29162
|
}
|
|
29163
|
+
await rm(join7(paths.tokens, "elevation.rafters.json"), { force: true });
|
|
29164
|
+
await rm(join7(paths.tokens, "fill.rafters.json"), { force: true });
|
|
29360
29165
|
const registry2 = loadRegistryFromDir(paths.tokens, REGISTRY_PLUGINS);
|
|
29361
29166
|
if (registry2.size() === 0) {
|
|
29362
29167
|
throw new Error("No tokens found. Cannot regenerate without existing tokens.");
|
|
@@ -30677,97 +30482,9 @@ async function mcp(options) {
|
|
|
30677
30482
|
await startMcpServer(workspaces, defaultWorkspace);
|
|
30678
30483
|
}
|
|
30679
30484
|
|
|
30680
|
-
// src/commands/
|
|
30485
|
+
// src/commands/studio.ts
|
|
30681
30486
|
import { existsSync as existsSync7 } from "fs";
|
|
30682
30487
|
import { resolve as resolve5 } from "path";
|
|
30683
|
-
import { input } from "@inquirer/prompts";
|
|
30684
|
-
var TokenValueSchema = external_exports.union([external_exports.string(), ColorValueSchema, ColorReferenceSchema]);
|
|
30685
|
-
async function set3(name, value, options) {
|
|
30686
|
-
setAgentMode(options.agent ?? false);
|
|
30687
|
-
const dir = resolve5(options.raftersDir ?? ".rafters/tokens");
|
|
30688
|
-
if (!existsSync7(dir)) {
|
|
30689
|
-
throw new Error(`tokens directory not found: ${dir}`);
|
|
30690
|
-
}
|
|
30691
|
-
let reason = options.reason;
|
|
30692
|
-
if (!reason) {
|
|
30693
|
-
if (isAgentMode()) {
|
|
30694
|
-
throw new Error("rafters set requires --reason in agent mode");
|
|
30695
|
-
}
|
|
30696
|
-
reason = await input({
|
|
30697
|
-
message: "Reason for this change (recorded with userOverride):",
|
|
30698
|
-
validate: (v) => v.trim().length > 0 ? true : "A reason is required"
|
|
30699
|
-
});
|
|
30700
|
-
}
|
|
30701
|
-
const parsedValue = bakeAccessibility(parseValue(value));
|
|
30702
|
-
const registry2 = loadRegistryFromDir(dir, [
|
|
30703
|
-
scalePlugin,
|
|
30704
|
-
contrastPlugin,
|
|
30705
|
-
invertPlugin,
|
|
30706
|
-
statePlugin
|
|
30707
|
-
]);
|
|
30708
|
-
if (!registry2.has(name)) {
|
|
30709
|
-
throw new Error(`token "${name}" not found in ${dir}`);
|
|
30710
|
-
}
|
|
30711
|
-
const previous = registry2.get(name)?.value;
|
|
30712
|
-
registry2.set(name, parsedValue, { reason });
|
|
30713
|
-
saveRegistryToDir(dir, registry2);
|
|
30714
|
-
log({
|
|
30715
|
-
event: "token.set",
|
|
30716
|
-
name,
|
|
30717
|
-
previous,
|
|
30718
|
-
next: parsedValue,
|
|
30719
|
-
reason
|
|
30720
|
-
});
|
|
30721
|
-
}
|
|
30722
|
-
var WHITE3 = { l: 1, c: 0, h: 0, alpha: 1 };
|
|
30723
|
-
var BLACK3 = { l: 0, c: 0, h: 0, alpha: 1 };
|
|
30724
|
-
var WCAG_AA_NORMAL2 = 4.5;
|
|
30725
|
-
var WCAG_AAA_NORMAL2 = 7;
|
|
30726
|
-
function bakeAccessibility(value) {
|
|
30727
|
-
if (typeof value !== "object" || value === null) return value;
|
|
30728
|
-
if (!("scale" in value) || !Array.isArray(value.scale)) return value;
|
|
30729
|
-
const colorValue = value;
|
|
30730
|
-
const meta = generateAccessibilityMetadata(colorValue.scale);
|
|
30731
|
-
const reference = colorValue.scale[5] ?? colorValue.scale[0];
|
|
30732
|
-
if (!reference) return value;
|
|
30733
|
-
const onWhiteRatio = calculateWCAGContrast(reference, WHITE3);
|
|
30734
|
-
const onBlackRatio = calculateWCAGContrast(reference, BLACK3);
|
|
30735
|
-
const accessibility = {
|
|
30736
|
-
wcagAA: meta.wcagAA,
|
|
30737
|
-
wcagAAA: meta.wcagAAA,
|
|
30738
|
-
onWhite: {
|
|
30739
|
-
wcagAA: onWhiteRatio >= WCAG_AA_NORMAL2,
|
|
30740
|
-
wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL2,
|
|
30741
|
-
contrastRatio: onWhiteRatio,
|
|
30742
|
-
aa: meta.onWhite.aa,
|
|
30743
|
-
aaa: meta.onWhite.aaa
|
|
30744
|
-
},
|
|
30745
|
-
onBlack: {
|
|
30746
|
-
wcagAA: onBlackRatio >= WCAG_AA_NORMAL2,
|
|
30747
|
-
wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL2,
|
|
30748
|
-
contrastRatio: onBlackRatio,
|
|
30749
|
-
aa: meta.onBlack.aa,
|
|
30750
|
-
aaa: meta.onBlack.aaa
|
|
30751
|
-
}
|
|
30752
|
-
};
|
|
30753
|
-
return { ...colorValue, accessibility };
|
|
30754
|
-
}
|
|
30755
|
-
function parseValue(raw) {
|
|
30756
|
-
const trimmed = raw.trim();
|
|
30757
|
-
if (trimmed.startsWith("{")) {
|
|
30758
|
-
try {
|
|
30759
|
-
const parsed = JSON.parse(trimmed);
|
|
30760
|
-
const result = TokenValueSchema.safeParse(parsed);
|
|
30761
|
-
if (result.success) return result.data;
|
|
30762
|
-
} catch {
|
|
30763
|
-
}
|
|
30764
|
-
}
|
|
30765
|
-
return raw;
|
|
30766
|
-
}
|
|
30767
|
-
|
|
30768
|
-
// src/commands/studio.ts
|
|
30769
|
-
import { existsSync as existsSync8 } from "fs";
|
|
30770
|
-
import { resolve as resolve6 } from "path";
|
|
30771
30488
|
|
|
30772
30489
|
// ../studio/src/api/vite-plugin.ts
|
|
30773
30490
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
@@ -30917,7 +30634,7 @@ function getNamespacePatchSchema(namespace) {
|
|
|
30917
30634
|
}
|
|
30918
30635
|
var MAX_BODY_SIZE = 1024 * 1024;
|
|
30919
30636
|
function readJsonBody(req) {
|
|
30920
|
-
return new Promise((
|
|
30637
|
+
return new Promise((resolve6, reject) => {
|
|
30921
30638
|
let body = "";
|
|
30922
30639
|
let size = 0;
|
|
30923
30640
|
req.on("data", (chunk) => {
|
|
@@ -30930,7 +30647,7 @@ function readJsonBody(req) {
|
|
|
30930
30647
|
});
|
|
30931
30648
|
req.on("end", () => {
|
|
30932
30649
|
try {
|
|
30933
|
-
|
|
30650
|
+
resolve6(body ? JSON.parse(body) : {});
|
|
30934
30651
|
} catch {
|
|
30935
30652
|
reject(new Error("Invalid JSON body"));
|
|
30936
30653
|
}
|
|
@@ -31057,6 +30774,9 @@ async function handlePostToken(req, res, name, registry2) {
|
|
|
31057
30774
|
...existingToken,
|
|
31058
30775
|
...patchResult.data
|
|
31059
30776
|
};
|
|
30777
|
+
if (mergedToken.value && typeof mergedToken.value === "object" && "scale" in mergedToken.value) {
|
|
30778
|
+
mergedToken.value = rebakeAccessibility(mergedToken.value);
|
|
30779
|
+
}
|
|
31060
30780
|
const tokenResult = TokenSchema.safeParse(mergedToken);
|
|
31061
30781
|
if (!tokenResult.success) {
|
|
31062
30782
|
res.statusCode = 400;
|
|
@@ -31251,7 +30971,7 @@ function studioApiPlugin() {
|
|
|
31251
30971
|
client.send("rafters:token-updated", { ok: false, error: String(error47) });
|
|
31252
30972
|
}
|
|
31253
30973
|
});
|
|
31254
|
-
server.middlewares.use((req, res, next) => {
|
|
30974
|
+
server.middlewares.use(async (req, res, next) => {
|
|
31255
30975
|
let pathname;
|
|
31256
30976
|
try {
|
|
31257
30977
|
pathname = new URL(req.url ?? "", "http://localhost").pathname;
|
|
@@ -31327,13 +31047,16 @@ function studioApiPlugin() {
|
|
|
31327
31047
|
return;
|
|
31328
31048
|
}
|
|
31329
31049
|
if (req.method === "POST") {
|
|
31330
|
-
|
|
31050
|
+
try {
|
|
31051
|
+
await handlePostToken(req, res, name, registry2);
|
|
31052
|
+
if (res.statusCode < 400) await persistAndNotify();
|
|
31053
|
+
} catch (error47) {
|
|
31331
31054
|
console.log(`[rafters] Unhandled error in POST /api/tokens/${name}: ${error47}`);
|
|
31332
31055
|
if (!res.headersSent) {
|
|
31333
31056
|
res.statusCode = 500;
|
|
31334
31057
|
res.end(JSON.stringify({ ok: false, error: "Internal server error" }));
|
|
31335
31058
|
}
|
|
31336
|
-
}
|
|
31059
|
+
}
|
|
31337
31060
|
return;
|
|
31338
31061
|
}
|
|
31339
31062
|
const token = registry2.get(name);
|
|
@@ -31372,13 +31095,16 @@ function studioApiPlugin() {
|
|
|
31372
31095
|
return;
|
|
31373
31096
|
}
|
|
31374
31097
|
if (req.method === "POST") {
|
|
31375
|
-
|
|
31098
|
+
try {
|
|
31099
|
+
await handlePostTokens(req, res, registry2);
|
|
31100
|
+
if (res.statusCode < 400) await persistAndNotify();
|
|
31101
|
+
} catch (error47) {
|
|
31376
31102
|
console.log(`[rafters] Unhandled error in POST /api/tokens: ${error47}`);
|
|
31377
31103
|
if (!res.headersSent) {
|
|
31378
31104
|
res.statusCode = 500;
|
|
31379
31105
|
res.end(JSON.stringify({ ok: false, error: "Internal server error" }));
|
|
31380
31106
|
}
|
|
31381
|
-
}
|
|
31107
|
+
}
|
|
31382
31108
|
return;
|
|
31383
31109
|
}
|
|
31384
31110
|
handleGetTokens(req.url ?? "", res, registry2, initialized);
|
|
@@ -31395,7 +31121,7 @@ import { createServer } from "vite";
|
|
|
31395
31121
|
async function studio() {
|
|
31396
31122
|
const cwd = process.cwd();
|
|
31397
31123
|
const paths = getRaftersPaths(cwd);
|
|
31398
|
-
if (!
|
|
31124
|
+
if (!existsSync7(paths.root)) {
|
|
31399
31125
|
console.error('No .rafters/ directory found. Run "rafters init" first.');
|
|
31400
31126
|
process.exit(1);
|
|
31401
31127
|
}
|
|
@@ -31412,7 +31138,7 @@ async function studio() {
|
|
|
31412
31138
|
},
|
|
31413
31139
|
resolve: {
|
|
31414
31140
|
alias: {
|
|
31415
|
-
"@rafters-output":
|
|
31141
|
+
"@rafters-output": resolve5(cwd, ".rafters", "output")
|
|
31416
31142
|
}
|
|
31417
31143
|
}
|
|
31418
31144
|
});
|
|
@@ -31429,10 +31155,6 @@ program.command("init").description("Initialize .rafters/ with default tokens an
|
|
|
31429
31155
|
).option("--agent", "Output JSON for machine consumption").action(withErrorHandler(init));
|
|
31430
31156
|
program.command("add").description("Add rafters components to the project").argument("[components...]", "Component names to add").option("--list", "List available components").option("--overwrite", "Overwrite existing component files").option("--update", "Re-fetch named components from registry").option("--update-all", "Re-fetch all installed components from registry").option("--registry-url <url>", "Custom registry URL").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(add));
|
|
31431
31157
|
program.command("mcp").description("Start MCP server for AI agent access (stdio)").option("--project-root <path>", "Explicit project root (skips .rafters/ discovery)").action(mcp);
|
|
31432
|
-
program.command("set").description("Set a token value. Records userOverride and cascades to dependents.").argument("<name>", "Token name").argument("<value>", "New value (string, or JSON for ColorValue/ColorReference)").option(
|
|
31433
|
-
"--reason <text>",
|
|
31434
|
-
"Reason for the change (recorded with userOverride; prompted if missing in non-agent mode)"
|
|
31435
|
-
).option("--rafters-dir <path>", "Directory of .rafters.json files", ".rafters/tokens").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(set3));
|
|
31436
31158
|
program.command("studio").description("Open Studio UI for visual token editing").action(studio);
|
|
31437
31159
|
program.parse();
|
|
31438
31160
|
/*! Bundled license information:
|