@salty-css/core 0.2.1 → 0.2.2-refactor-vite-8.4
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/astro-component-Ov1RH0CO.js +4 -0
- package/dist/astro-component-r0qEcF1p.cjs +14 -0
- package/{bin → dist/bin}/bin-util.d.ts +1 -0
- package/dist/bin/bin-util.d.ts.map +1 -0
- package/{bin → dist/bin}/commands/build.d.ts +1 -0
- package/dist/bin/commands/build.d.ts.map +1 -0
- package/{bin → dist/bin}/commands/generate.d.ts +1 -0
- package/dist/bin/commands/generate.d.ts.map +1 -0
- package/{bin → dist/bin}/commands/init.d.ts +1 -0
- package/dist/bin/commands/init.d.ts.map +1 -0
- package/{bin → dist/bin}/commands/update.d.ts +1 -0
- package/dist/bin/commands/update.d.ts.map +1 -0
- package/{bin → dist/bin}/commands/version.d.ts +1 -0
- package/dist/bin/commands/version.d.ts.map +1 -0
- package/{bin → dist/bin}/confirm-install.d.ts +1 -0
- package/dist/bin/confirm-install.d.ts.map +1 -0
- package/{bin → dist/bin}/context.d.ts +1 -0
- package/dist/bin/context.d.ts.map +1 -0
- package/{bin → dist/bin}/detection/css-file.d.ts +1 -0
- package/dist/bin/detection/css-file.d.ts.map +1 -0
- package/{bin → dist/bin}/frameworks/astro.d.ts +1 -0
- package/dist/bin/frameworks/astro.d.ts.map +1 -0
- package/{bin → dist/bin}/frameworks/index.d.ts +1 -0
- package/dist/bin/frameworks/index.d.ts.map +1 -0
- package/{bin → dist/bin}/frameworks/react.d.ts +1 -0
- package/dist/bin/frameworks/react.d.ts.map +1 -0
- package/{bin → dist/bin}/frameworks/types.d.ts +1 -0
- package/dist/bin/frameworks/types.d.ts.map +1 -0
- package/dist/bin/index.cjs +2 -0
- package/dist/bin/index.d.ts +3 -0
- package/dist/bin/index.d.ts.map +1 -0
- package/dist/bin/index.js +5 -0
- package/{bin → dist/bin}/integrations/astro.d.ts +1 -0
- package/dist/bin/integrations/astro.d.ts.map +1 -0
- package/{bin → dist/bin}/integrations/eslint.d.ts +1 -0
- package/dist/bin/integrations/eslint.d.ts.map +1 -0
- package/{bin → dist/bin}/integrations/index.d.ts +1 -0
- package/dist/bin/integrations/index.d.ts.map +1 -0
- package/{bin → dist/bin}/integrations/next.d.ts +1 -0
- package/dist/bin/integrations/next.d.ts.map +1 -0
- package/{bin → dist/bin}/integrations/types.d.ts +1 -0
- package/dist/bin/integrations/types.d.ts.map +1 -0
- package/{bin → dist/bin}/integrations/vite.d.ts +1 -0
- package/dist/bin/integrations/vite.d.ts.map +1 -0
- package/{bin → dist/bin}/logger.d.ts +1 -0
- package/dist/bin/logger.d.ts.map +1 -0
- package/dist/bin/main.cjs +1 -0
- package/{bin → dist/bin}/main.d.ts +1 -0
- package/dist/bin/main.d.ts.map +1 -0
- package/dist/bin/main.js +2 -0
- package/{bin → dist/bin}/package-json.d.ts +1 -0
- package/dist/bin/package-json.d.ts.map +1 -0
- package/{bin → dist/bin}/path-defaults.d.ts +1 -0
- package/dist/bin/path-defaults.d.ts.map +1 -0
- package/{bin → dist/bin}/prettier.d.ts +1 -0
- package/dist/bin/prettier.d.ts.map +1 -0
- package/{bin → dist/bin}/saltyrc.d.ts +1 -0
- package/dist/bin/saltyrc.d.ts.map +1 -0
- package/dist/bin/templates.d.ts +15 -0
- package/dist/bin/templates.d.ts.map +1 -0
- package/dist/chunk-CMqjfN_6.cjs +1 -0
- package/dist/compiler/get-files.cjs +1 -0
- package/{compiler → dist/compiler}/get-files.d.ts +1 -0
- package/dist/compiler/get-files.d.ts.map +1 -0
- package/dist/compiler/get-files.js +15 -0
- package/dist/compiler/get-function-range.cjs +1 -0
- package/{compiler → dist/compiler}/get-function-range.d.ts +1 -0
- package/dist/compiler/get-function-range.d.ts.map +1 -0
- package/dist/compiler/get-function-range.js +17 -0
- package/dist/compiler/helpers.cjs +1 -0
- package/{compiler → dist/compiler}/helpers.d.ts +1 -0
- package/dist/compiler/helpers.d.ts.map +1 -0
- package/dist/compiler/helpers.js +24 -0
- package/{compiler → dist/compiler}/resolve-import.d.ts +1 -0
- package/dist/compiler/resolve-import.d.ts.map +1 -0
- package/dist/compiler/salty-compiler.cjs +1 -0
- package/{compiler → dist/compiler}/salty-compiler.d.ts +1 -0
- package/dist/compiler/salty-compiler.d.ts.map +1 -0
- package/dist/compiler/salty-compiler.js +2 -0
- package/{config → dist/config}/define-config.d.ts +1 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/index.cjs +1 -0
- package/{config → dist/config}/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +5 -0
- package/dist/css/index.cjs +1 -0
- package/{css → dist/css}/index.d.ts +1 -0
- package/dist/css/index.d.ts.map +1 -0
- package/dist/css/index.js +5 -0
- package/dist/css/keyframes.cjs +1 -0
- package/{css → dist/css}/keyframes.d.ts +1 -0
- package/dist/css/keyframes.d.ts.map +1 -0
- package/dist/css/keyframes.js +30 -0
- package/dist/css/media.cjs +1 -0
- package/{css → dist/css}/media.d.ts +1 -0
- package/dist/css/media.d.ts.map +1 -0
- package/dist/css/media.js +84 -0
- package/dist/css/merge.cjs +1 -0
- package/{css → dist/css}/merge.d.ts +1 -0
- package/dist/css/merge.d.ts.map +1 -0
- package/dist/css/merge.js +20 -0
- package/dist/css/token.cjs +1 -0
- package/{css → dist/css}/token.d.ts +1 -0
- package/dist/css/token.d.ts.map +1 -0
- package/dist/css/token.js +4 -0
- package/{factories → dist/factories}/define-font.d.ts +1 -0
- package/dist/factories/define-font.d.ts.map +1 -0
- package/{factories → dist/factories}/define-global-styles.d.ts +1 -0
- package/dist/factories/define-global-styles.d.ts.map +1 -0
- package/{factories → dist/factories}/define-import.d.ts +1 -0
- package/dist/factories/define-import.d.ts.map +1 -0
- package/{factories → dist/factories}/define-media-query.d.ts +1 -0
- package/dist/factories/define-media-query.d.ts.map +1 -0
- package/{factories → dist/factories}/define-templates.d.ts +1 -0
- package/dist/factories/define-templates.d.ts.map +1 -0
- package/{factories → dist/factories}/define-variables.d.ts +1 -0
- package/dist/factories/define-variables.d.ts.map +1 -0
- package/dist/factories/index.cjs +1 -0
- package/{factories → dist/factories}/index.d.ts +1 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +149 -0
- package/{generators → dist/generators}/class-name-generator.d.ts +1 -0
- package/dist/generators/class-name-generator.d.ts.map +1 -0
- package/dist/generators/index.cjs +1 -0
- package/{generators → dist/generators}/index.d.ts +1 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +2 -0
- package/{generators → dist/generators}/styled-generator.d.ts +1 -0
- package/dist/generators/styled-generator.d.ts.map +1 -0
- package/{generators → dist/generators}/styles-generator.d.ts +1 -0
- package/dist/generators/styles-generator.d.ts.map +1 -0
- package/dist/generators-CrK45F8i.js +112 -0
- package/dist/generators-eEKEtyAm.cjs +1 -0
- package/{helpers → dist/helpers}/color.d.ts +1 -0
- package/dist/helpers/color.d.ts.map +1 -0
- package/dist/helpers/index.cjs +1 -0
- package/{helpers → dist/helpers}/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +33 -0
- package/{helpers → dist/helpers}/viewport-clamp.d.ts +1 -0
- package/dist/helpers/viewport-clamp.d.ts.map +1 -0
- package/dist/instances/classname-instance.cjs +1 -0
- package/{instances → dist/instances}/classname-instance.d.ts +1 -0
- package/dist/instances/classname-instance.d.ts.map +1 -0
- package/dist/instances/classname-instance.js +18 -0
- package/dist/main-DGpSu6zK.js +545 -0
- package/dist/main-LnoqOq21.cjs +11 -0
- package/dist/maybe.d.ts +2 -0
- package/dist/maybe.d.ts.map +1 -0
- package/dist/parse-styles-2rwbF9j_.cjs +3 -0
- package/dist/parse-styles-Bz0otiZ-.js +336 -0
- package/dist/parsers/index.cjs +3 -0
- package/{parsers → dist/parsers}/index.d.ts +1 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +79 -0
- package/{parsers → dist/parsers}/parse-modifiers.d.ts +1 -0
- package/dist/parsers/parse-modifiers.d.ts.map +1 -0
- package/{parsers → dist/parsers}/parse-styles.d.ts +1 -0
- package/dist/parsers/parse-styles.d.ts.map +1 -0
- package/{parsers → dist/parsers}/parse-templates.d.ts +1 -0
- package/dist/parsers/parse-templates.d.ts.map +1 -0
- package/{parsers → dist/parsers}/parse-tokens.d.ts +1 -0
- package/dist/parsers/parse-tokens.d.ts.map +1 -0
- package/{parsers → dist/parsers}/parser-regexes.d.ts +1 -0
- package/dist/parsers/parser-regexes.d.ts.map +1 -0
- package/{parsers → dist/parsers}/parser-types.d.ts +1 -0
- package/dist/parsers/parser-types.d.ts.map +1 -0
- package/{parsers → dist/parsers}/property-name-check.d.ts +1 -0
- package/dist/parsers/property-name-check.d.ts.map +1 -0
- package/{parsers → dist/parsers}/resolve-template-variants.d.ts +1 -0
- package/dist/parsers/resolve-template-variants.d.ts.map +1 -0
- package/{parsers → dist/parsers}/strict.d.ts +1 -0
- package/dist/parsers/strict.d.ts.map +1 -0
- package/{parsers → dist/parsers}/unit-check.d.ts +1 -0
- package/dist/parsers/unit-check.d.ts.map +1 -0
- package/dist/runtime/index.cjs +2 -0
- package/{runtime → dist/runtime}/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +20 -0
- package/dist/salty-compiler-Bvd0OKHz.cjs +33 -0
- package/dist/salty-compiler-CvQ-rsex.js +484 -0
- package/dist/salty.config-B0ZiRpHR.cjs +7 -0
- package/dist/salty.config-DWF4i7K0.js +4 -0
- package/dist/server/index.cjs +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +12 -0
- package/{server → dist/server}/should-restart.d.ts +1 -0
- package/dist/server/should-restart.d.ts.map +1 -0
- package/{styled-file-Cda3EeR6.js → dist/styled-file-BCbAEzBB.cjs} +2 -5
- package/dist/styled-file-C_4eLAdV.js +4 -0
- package/dist/styled-file-DQHLzmuL.js +4 -0
- package/{styled-file-DLcgYmGN.js → dist/styled-file-DorArlCk.cjs} +2 -5
- package/{templates → dist/templates}/salty-reset.d.ts +1 -0
- package/dist/templates/salty-reset.d.ts.map +1 -0
- package/dist/templates-BGHLaAOm.cjs +1 -0
- package/dist/templates-DWWLjEiU.js +4 -0
- package/{types → dist/types}/cli-types.d.ts +1 -0
- package/dist/types/cli-types.d.ts.map +1 -0
- package/{types → dist/types}/config-types.d.ts +1 -0
- package/dist/types/config-types.d.ts.map +1 -0
- package/{types → dist/types}/font-types.d.ts +1 -0
- package/dist/types/font-types.d.ts.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/{types → dist/types}/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +0 -0
- package/{types → dist/types}/util-types.d.ts +1 -0
- package/dist/types/util-types.d.ts.map +1 -0
- package/{util → dist/util}/camel-case.d.ts +1 -0
- package/dist/util/camel-case.d.ts.map +1 -0
- package/{util → dist/util}/dash-case.d.ts +1 -0
- package/dist/util/dash-case.d.ts.map +1 -0
- package/{util → dist/util}/dot-case.d.ts +1 -0
- package/dist/util/dot-case.d.ts.map +1 -0
- package/{util → dist/util}/glob-match.d.ts +1 -0
- package/dist/util/glob-match.d.ts.map +1 -0
- package/dist/util/index.cjs +1 -0
- package/{util → dist/util}/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +72 -0
- package/{util → dist/util}/module-type.d.ts +1 -0
- package/dist/util/module-type.d.ts.map +1 -0
- package/{util → dist/util}/pascal-case.d.ts +1 -0
- package/dist/util/pascal-case.d.ts.map +1 -0
- package/{util → dist/util}/to-hash.d.ts +1 -0
- package/dist/util/to-hash.d.ts.map +1 -0
- package/dist/vanilla-file-BEqMIe-6.js +4 -0
- package/{vanilla-file-1kOqbCIM.js → dist/vanilla-file-Z3VsOa_U.cjs} +2 -5
- package/dist/viewport-clamp-CHOyzt37.cjs +1 -0
- package/dist/viewport-clamp-CRtzRvJ3.js +7 -0
- package/package.json +67 -64
- package/README.md +0 -535
- package/astro-component-5hrNTCJ5.js +0 -4
- package/astro-component-Dj3enX6K.cjs +0 -4
- package/bin/index.cjs +0 -4
- package/bin/index.d.ts +0 -2
- package/bin/index.js +0 -3
- package/bin/main.cjs +0 -783
- package/bin/main.js +0 -782
- package/bin/templates.d.ts +0 -14
- package/class-name-generator-BcbeZdcV.cjs +0 -88
- package/class-name-generator-DJ27JHW_.js +0 -89
- package/compiler/get-files.cjs +0 -25
- package/compiler/get-files.js +0 -25
- package/compiler/get-function-range.cjs +0 -22
- package/compiler/get-function-range.js +0 -22
- package/compiler/helpers.cjs +0 -34
- package/compiler/helpers.js +0 -33
- package/compiler/salty-compiler.cjs +0 -845
- package/compiler/salty-compiler.js +0 -827
- package/config/index.cjs +0 -20
- package/config/index.js +0 -20
- package/css/index.cjs +0 -12
- package/css/index.js +0 -12
- package/css/keyframes.cjs +0 -49
- package/css/keyframes.js +0 -49
- package/css/media.cjs +0 -93
- package/css/media.js +0 -93
- package/css/merge.cjs +0 -20
- package/css/merge.js +0 -20
- package/css/token.cjs +0 -4
- package/css/token.js +0 -4
- package/define-templates-CVhhgPnd.js +0 -60
- package/define-templates-Deq1aCbN.cjs +0 -59
- package/factories/index.cjs +0 -177
- package/factories/index.js +0 -177
- package/generators/index.cjs +0 -58
- package/generators/index.js +0 -59
- package/glob-match-C28iYp1A.js +0 -74
- package/glob-match-CT1uFlp-.cjs +0 -73
- package/helpers/index.cjs +0 -53
- package/helpers/index.js +0 -53
- package/index-ByR0nfaf.cjs +0 -4
- package/index-DKz1QXqs.js +0 -4
- package/instances/classname-instance.cjs +0 -31
- package/instances/classname-instance.js +0 -31
- package/parse-styles-BlUpavVg.js +0 -521
- package/parse-styles-DWT4tDyS.cjs +0 -520
- package/parsers/index.cjs +0 -147
- package/parsers/index.js +0 -148
- package/pascal-case-By_l58S-.cjs +0 -7
- package/pascal-case-F3Usi5Wf.js +0 -8
- package/runtime/index.cjs +0 -24
- package/runtime/index.js +0 -24
- package/salty.config-DogY_sSQ.cjs +0 -4
- package/salty.config-GV37Q-D2.js +0 -4
- package/server/index.cjs +0 -4
- package/server/index.d.ts +0 -1
- package/server/index.js +0 -4
- package/should-restart-CQsyHls3.cjs +0 -17
- package/should-restart-CXIO0jxY.js +0 -18
- package/styled-file-BzmB9_Ez.cjs +0 -12
- package/styled-file-CPd_rTW2.cjs +0 -11
- package/to-hash-DSoCPs8D.js +0 -33
- package/to-hash-DT2ImSPA.cjs +0 -32
- package/types/index.cjs +0 -1
- package/types/index.js +0 -1
- package/util/index.cjs +0 -18
- package/util/index.js +0 -18
- package/vanilla-file-r0fp2q_m.cjs +0 -18
- package/viewport-clamp-CEmzmcSj.cjs +0 -10
- package/viewport-clamp-K553uXu3.js +0 -11
- /package/{.saltyrc.schema.json → dist/.saltyrc.schema.json} +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { dashCase as e } from "./util/index.js";
|
|
2
|
+
import { t } from "./viewport-clamp-CRtzRvJ3.js";
|
|
3
|
+
//#region src/parsers/parse-modifiers.ts
|
|
4
|
+
var n = (e) => (t) => {
|
|
5
|
+
if (typeof t != "string" || !e) return;
|
|
6
|
+
let n = t, r = [];
|
|
7
|
+
return Object.values(e).forEach((e) => {
|
|
8
|
+
let { pattern: t, transform: i } = e;
|
|
9
|
+
n = n.replace(t, (e) => {
|
|
10
|
+
let { value: t, css: n } = i(e);
|
|
11
|
+
return n && r.push(n), t;
|
|
12
|
+
});
|
|
13
|
+
}), {
|
|
14
|
+
transformed: n,
|
|
15
|
+
additionalCss: r
|
|
16
|
+
};
|
|
17
|
+
}, r = (t) => (n) => {
|
|
18
|
+
if (typeof n == "string" && /\{[^{}]+\}/g.test(n)) return { transformed: n.replace(/\{([^{}]+)\}/g, (...n) => {
|
|
19
|
+
let r = e(n[1].trim().replaceAll(".", "-"));
|
|
20
|
+
return t && !t.includes(r) && console.warn(`Token ${r} might not exist`), r.startsWith("-") ? `-${r}` : `var(--${r})`;
|
|
21
|
+
}) };
|
|
22
|
+
}, i = r(), a = [
|
|
23
|
+
"top",
|
|
24
|
+
"right",
|
|
25
|
+
"bottom",
|
|
26
|
+
"left",
|
|
27
|
+
"min-width",
|
|
28
|
+
/.*width.*/,
|
|
29
|
+
/^[^line]*height.*/,
|
|
30
|
+
/padding.*/,
|
|
31
|
+
/margin.*/,
|
|
32
|
+
/border.*/,
|
|
33
|
+
/inset.*/,
|
|
34
|
+
/.*radius.*/,
|
|
35
|
+
/.*spacing.*/,
|
|
36
|
+
/.*gap.*/,
|
|
37
|
+
/.*indent.*/,
|
|
38
|
+
/.*offset.*/,
|
|
39
|
+
/.*size.*/,
|
|
40
|
+
/.*thickness.*/,
|
|
41
|
+
/.*font-size.*/
|
|
42
|
+
], o = (e, n, r) => {
|
|
43
|
+
if (a.some((t) => typeof t == "string" ? t === e : t.test(e))) {
|
|
44
|
+
let e = r?.defaultUnit || "px";
|
|
45
|
+
if (e.startsWith("viewport-clamp:")) try {
|
|
46
|
+
let r = e.split(":")[1];
|
|
47
|
+
return t({ screenSize: parseInt(r) })(Number(n));
|
|
48
|
+
} catch (t) {
|
|
49
|
+
throw console.error(t), Error(`Invalid viewport-clamp value: ${e}`);
|
|
50
|
+
}
|
|
51
|
+
return `${n}${e}`;
|
|
52
|
+
}
|
|
53
|
+
return `${n}`;
|
|
54
|
+
}, s = [
|
|
55
|
+
"Webkit",
|
|
56
|
+
"Moz",
|
|
57
|
+
"ms",
|
|
58
|
+
"O"
|
|
59
|
+
], c = (e) => s.some((t) => {
|
|
60
|
+
if (!e.startsWith(t)) return !1;
|
|
61
|
+
let n = e.charAt(t.length);
|
|
62
|
+
return n >= "A" && n <= "Z";
|
|
63
|
+
}), l = (t) => t.startsWith("-") ? t : c(t) ? `-${e(t)}` : e(t), u = (e, t) => {
|
|
64
|
+
if (e === !0) throw Error(`[salty-css] ${t}`);
|
|
65
|
+
e === "warn" && console.warn(`[salty-css] ${t}`);
|
|
66
|
+
}, d = /^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/, f = /\$\{[^}]+\}/, p = /^@(media|supports|container|layer)\s*$/, m = /^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/, h = (e) => {
|
|
67
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
68
|
+
let t = Object.keys(e);
|
|
69
|
+
return t.includes("base") || t.includes("variants");
|
|
70
|
+
}, g = (e) => {
|
|
71
|
+
if (typeof e == "string") {
|
|
72
|
+
let [t, n] = e.split("@", 2), r = t.split(".").filter(Boolean);
|
|
73
|
+
if (!r.length) return;
|
|
74
|
+
let i = {};
|
|
75
|
+
if (n) for (let e of n.split("&")) {
|
|
76
|
+
if (!e) continue;
|
|
77
|
+
let t = e.indexOf("=");
|
|
78
|
+
if (t === -1) i[e.trim()] = !0;
|
|
79
|
+
else {
|
|
80
|
+
let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
|
|
81
|
+
if (!n) continue;
|
|
82
|
+
r === "true" ? i[n] = !0 : r === "false" ? i[n] = !1 : i[n] = r;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
path: r,
|
|
87
|
+
variants: i
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
91
|
+
let t = e, n = t.name;
|
|
92
|
+
if (typeof n != "string") return;
|
|
93
|
+
let r = n.split(".").filter(Boolean);
|
|
94
|
+
if (!r.length) return;
|
|
95
|
+
let i = {};
|
|
96
|
+
for (let [e, n] of Object.entries(t)) e !== "name" && (typeof n == "string" || typeof n == "boolean") && (i[e] = n);
|
|
97
|
+
return {
|
|
98
|
+
path: r,
|
|
99
|
+
variants: i
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}, _ = (e) => {
|
|
103
|
+
if (e !== void 0) return typeof e == "boolean" ? String(e) : e;
|
|
104
|
+
}, v = (e, t) => {
|
|
105
|
+
let n = [{
|
|
106
|
+
node: e,
|
|
107
|
+
isRich: h(e)
|
|
108
|
+
}], r = e;
|
|
109
|
+
for (let e of t) {
|
|
110
|
+
if (typeof r != "object" || !r) return;
|
|
111
|
+
let t = r[e];
|
|
112
|
+
if (t === void 0) return;
|
|
113
|
+
n.push({
|
|
114
|
+
node: t,
|
|
115
|
+
isRich: h(t)
|
|
116
|
+
}), r = t;
|
|
117
|
+
}
|
|
118
|
+
return n;
|
|
119
|
+
}, y = (e, t) => {
|
|
120
|
+
let n = v(e, t);
|
|
121
|
+
return n ? n.some((e) => e.isRich) : !1;
|
|
122
|
+
}, b = (e, t) => {
|
|
123
|
+
for (let [n, r] of Object.entries(e)) if (n !== "css" && t[n] !== _(r)) return !1;
|
|
124
|
+
return !0;
|
|
125
|
+
}, x = (e, t) => {
|
|
126
|
+
let n = !1;
|
|
127
|
+
for (let [r, i] of Object.entries(e)) if (r !== "css" && (n = !0, t[r] === _(i))) return !0;
|
|
128
|
+
return !n;
|
|
129
|
+
}, S = (e, t, n, r) => {
|
|
130
|
+
let i = v(e, t);
|
|
131
|
+
if (!i) return;
|
|
132
|
+
let a = i.map((e) => e.isRich ? e.node : e.node && typeof e.node == "object" && !Array.isArray(e.node) ? Object.keys(e.node).every((t) => e.node[t] && typeof e.node[t] == "object" && !h(e.node[t])) ? {} : { base: e.node } : {}), o = /* @__PURE__ */ new Set();
|
|
133
|
+
for (let e of a) if (e.variants) for (let t of Object.keys(e.variants)) o.add(t);
|
|
134
|
+
for (let e of a) if (e.defaultVariants) for (let t of Object.keys(e.defaultVariants)) o.add(t);
|
|
135
|
+
let s = {};
|
|
136
|
+
for (let e of o) {
|
|
137
|
+
if (e in n) {
|
|
138
|
+
s[e] = _(n[e]);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
for (let t = a.length - 1; t >= 0; t--) {
|
|
142
|
+
let n = a[t].defaultVariants?.[e];
|
|
143
|
+
if (n !== void 0) {
|
|
144
|
+
s[e] = _(n);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (let [e, i] of Object.entries(n)) {
|
|
150
|
+
if (!o.has(e)) {
|
|
151
|
+
console.warn(`Template "${r}" path "${t.join(".")}" has no variant axis "${e}"; ignored.`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
let n = _(i), s = !1;
|
|
155
|
+
for (let t of a) if (t.variants?.[e] && n !== void 0 && n in t.variants[e]) {
|
|
156
|
+
s = !0;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
!s && n !== void 0 && a.some((t) => t.variants && e in t.variants) && console.warn(`Template "${r}" axis "${e}" has no value "${n}" on path "${t.join(".")}"; ignored.`);
|
|
160
|
+
}
|
|
161
|
+
let c = {};
|
|
162
|
+
for (let e of a) e.base && Object.assign(c, e.base);
|
|
163
|
+
for (let e of Object.keys(s)) {
|
|
164
|
+
let t = s[e];
|
|
165
|
+
if (t !== void 0) for (let n = a.length - 1; n >= 0; n--) {
|
|
166
|
+
let r = a[n].variants?.[e]?.[t];
|
|
167
|
+
if (r) {
|
|
168
|
+
Object.assign(c, r);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (let e of a) {
|
|
174
|
+
if (e.compoundVariants) for (let t of e.compoundVariants) b(t, s) && t.css && Object.assign(c, t.css);
|
|
175
|
+
if (e.anyOfVariants) for (let t of e.anyOfVariants) x(t, s) && t.css && Object.assign(c, t.css);
|
|
176
|
+
}
|
|
177
|
+
return c;
|
|
178
|
+
}, C = async (e, t = "", i, a = !1) => {
|
|
179
|
+
if (!e) throw Error("No styles provided to parseStyles function!");
|
|
180
|
+
let s = /* @__PURE__ */ new Set(), c = Object.entries(e), h = i?.strict, _ = async ([e, n]) => {
|
|
181
|
+
let r = e.trim().replace(/^\?+/g, ""), c = l(r), v = (e, t = ";") => `${c}:${e}${t}`, b = {
|
|
182
|
+
scope: t,
|
|
183
|
+
config: i
|
|
184
|
+
};
|
|
185
|
+
if (typeof n == "function") try {
|
|
186
|
+
return await _([e, n(b)]);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
u(h, `Function value for "${r}" threw: ${e?.message ?? e}`);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (n instanceof Promise) return _([e, await n]);
|
|
192
|
+
if (i?.templates && i.templatePaths?.[r]) try {
|
|
193
|
+
let [e, t] = i.templatePaths[r].split(";;"), a = await import(
|
|
194
|
+
/* webpackIgnore: true */
|
|
195
|
+
/* @vite-ignore */
|
|
196
|
+
t
|
|
197
|
+
), o = t.includes("salty.config"), s = o ? a[e].templates : a[e], c = o ? s[r] : s.params[r];
|
|
198
|
+
if (s && typeof c == "function") {
|
|
199
|
+
let [e] = await C(await c(n), "");
|
|
200
|
+
return e;
|
|
201
|
+
}
|
|
202
|
+
} catch (e) {
|
|
203
|
+
console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`, e);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (i?.templates && i.templates[r]) {
|
|
207
|
+
if (a) return;
|
|
208
|
+
let e = i.templates[r], t = g(n);
|
|
209
|
+
if (t) {
|
|
210
|
+
let { path: n, variants: i } = t;
|
|
211
|
+
if (Object.keys(i).length > 0 || y(e, n)) {
|
|
212
|
+
let t = S(e, n, i, r);
|
|
213
|
+
if (t) {
|
|
214
|
+
let [e] = await C(t, "");
|
|
215
|
+
return e;
|
|
216
|
+
}
|
|
217
|
+
console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let a = n.reduce((e, t) => e?.[t], e);
|
|
221
|
+
if (a) {
|
|
222
|
+
let [e] = await C(a, "");
|
|
223
|
+
return e;
|
|
224
|
+
}
|
|
225
|
+
console.warn(`Template "${r}" with path of "${n.join(".")}" was not found in config!`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
console.warn(`Template "${r}" received an unsupported call-site value.`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (!(r === "compoundVariants" || r === "anyOfVariants") && Array.isArray(n)) return n.length === 0 ? void 0 : _([e, n.join(", ")]);
|
|
232
|
+
if (typeof n == "object") {
|
|
233
|
+
if (!n) return;
|
|
234
|
+
if (n.isColor || n.isDefineFont) return v(n.toString());
|
|
235
|
+
if (r === "defaultVariants") return;
|
|
236
|
+
if (r === "variants") {
|
|
237
|
+
let e = Object.entries(n);
|
|
238
|
+
for (let [n, r] of e) {
|
|
239
|
+
if (!r) continue;
|
|
240
|
+
let e = Object.entries(r);
|
|
241
|
+
for (let [r, a] of e) a && (await C(a, `${t}.${n}-${r}`, i)).forEach((e) => s.add(e));
|
|
242
|
+
}
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (r === "compoundVariants") {
|
|
246
|
+
for (let e of n) {
|
|
247
|
+
let { css: n, ...r } = e;
|
|
248
|
+
(await C(n, Object.entries(r).reduce((e, [t, n]) => `${e}.${t}-${n}`, t), i)).forEach((e) => s.add(e));
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (r === "anyOfVariants") {
|
|
253
|
+
for (let e of n) {
|
|
254
|
+
let { css: n, ...r } = e;
|
|
255
|
+
(await C(n, `${t}:where(${Object.entries(r).map(([e, t]) => `.${e}-${t}`).join(", ")})`, i)).forEach((e) => s.add(e));
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (r === "global") {
|
|
260
|
+
(await C(n, "", i)).forEach((e) => s.add(e));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (r.startsWith("@")) {
|
|
264
|
+
p.test(r) && u(h, `At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);
|
|
265
|
+
let e = m.test(r) ? "" : t, a = `${i?.mediaQueries?.[r] || r} { ${await w(n, e, i)} }`;
|
|
266
|
+
s.add(a);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (Object.keys(n).length === 0) return;
|
|
270
|
+
d.test(r) && u(h, `Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);
|
|
271
|
+
let e = D(t, r);
|
|
272
|
+
(await C(n, e, i)).forEach((e) => s.add(e));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (r.startsWith("$")) {
|
|
276
|
+
u(h, `Property key "${r}" looks like a SCSS variable — Salty does not support those.`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (r.includes(":")) {
|
|
280
|
+
u(h, `Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (n == null) {
|
|
284
|
+
u(h, `Property "${r}" has a ${n === void 0 ? "undefined" : "null"} value — skipping.`);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (typeof n == "boolean") {
|
|
288
|
+
u(h, `Property "${r}" has a boolean value (${n}) — skipping.`);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (n !== "") {
|
|
292
|
+
if (typeof n == "number") {
|
|
293
|
+
if (!Number.isFinite(n)) {
|
|
294
|
+
u(h, `Property "${r}" has a non-finite numeric value (${n}) — skipping.`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
return v(o(c, n, i));
|
|
298
|
+
}
|
|
299
|
+
if (typeof n != "string") if (n && typeof n == "object" && "toString" in n) n = n.toString();
|
|
300
|
+
else {
|
|
301
|
+
u(h, `Property "${r}" has an unsupported value type (${typeof n}) — skipping.`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
return typeof n == "string" && f.test(n) && u(h, `Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`), v(n);
|
|
305
|
+
}
|
|
306
|
+
}, v = c.map(_), { modifiers: b } = i || {}, x = [r(), n(b)], T = (await Promise.all(v).then((e) => Promise.all(e.map((e) => x.reduce(async (e, t) => {
|
|
307
|
+
let n = await e;
|
|
308
|
+
if (!n) return n;
|
|
309
|
+
let r = await t(n);
|
|
310
|
+
if (!r) return n;
|
|
311
|
+
let { transformed: i, additionalCss: a } = r, o = "";
|
|
312
|
+
if (a) for (let e of a) o += await w(e, "");
|
|
313
|
+
return `${o}${i}`;
|
|
314
|
+
}, Promise.resolve(e)))))).filter((e) => e !== void 0).join("\n ");
|
|
315
|
+
if (!T.trim()) return Array.from(s);
|
|
316
|
+
let E = t ? `${t} {\n\t${T}\n}` : T;
|
|
317
|
+
return s.has(E) ? Array.from(s) : [E, ...s];
|
|
318
|
+
}, w = async (e, t, n, r = !1) => (await C(e, t, n, r)).join("\n"), T = (e) => {
|
|
319
|
+
let t = [], n = 0, r = "";
|
|
320
|
+
for (let i of e) if (i === "(" || i === "[" ? n++ : (i === ")" || i === "]") && (n = Math.max(0, n - 1)), i === "," && n === 0) {
|
|
321
|
+
let e = r.trim();
|
|
322
|
+
e && t.push(e), r = "";
|
|
323
|
+
} else r += i;
|
|
324
|
+
let i = r.trim();
|
|
325
|
+
return i && t.push(i), t;
|
|
326
|
+
}, E = (e, t) => t.includes("&") ? t.replaceAll("&", e) : t.startsWith(":") ? `${e}${t}` : `${e} ${t}`, D = (e, t) => {
|
|
327
|
+
if (!e) return t;
|
|
328
|
+
let n = T(e), r = T(t);
|
|
329
|
+
if (!r.length) return e;
|
|
330
|
+
if (n.length <= 1 && r.length <= 1) return E(n[0] ?? e, r[0]);
|
|
331
|
+
let i = [];
|
|
332
|
+
for (let e of n) for (let t of r) i.push(E(e, t));
|
|
333
|
+
return i.join(", ");
|
|
334
|
+
};
|
|
335
|
+
//#endregion
|
|
336
|
+
export { u as a, n as c, g as i, C as n, r as o, h as r, i as s, w as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-2rwbF9j_.cjs");var n=new Set([`base`,`variants`,`defaultVariants`,`compoundVariants`,`anyOfVariants`]),r=(e,t)=>n.has(e)?!1:!!t&&typeof t==`object`&&!Array.isArray(t),i=async(n,a=[])=>{if(!n)return``;let o=[];if(t.r(n)){let s=n,c=a.map(t=>e.dashCase(String(t))).join(`-`);if(s.base){let n=`t_`+e.toHash(c,4),r=await t.t(s.base,`.${c}, .${n}`);o.push(r)}if(s.variants){for(let[n,r]of Object.entries(s.variants))if(!(!r||typeof r!=`object`))for(let[i,a]of Object.entries(r)){if(!a||typeof a!=`object`)continue;let r=`${c}-${e.dashCase(n)}-${e.dashCase(i)}`,s=await t.t(a,`.${r}, .${`tv_`+e.toHash(r,4)}`);o.push(s)}}for(let[e,t]of Object.entries(s)){if(!r(e,t))continue;let n=await i(t,[...a,e.trim()]);o.push(n)}return o.join(`
|
|
2
|
+
`)}let s={};for(let[e,t]of Object.entries(n))if(typeof t!=`function`)if(t&&typeof t==`object`){let n=e.trim(),r=await i(t,[...a,n]);o.push(r)}else s[e]=t;if(Object.keys(s).length){let n=a.map(t=>e.dashCase(String(t))).join(`-`),r=await t.t(s,`.${n}, .${`t_`+e.toHash(n,4)}`);o.push(r)}return o.join(`
|
|
3
|
+
`)},a=e=>Object.keys(e),o=e=>e?Object.entries(e).reduce((e,[t,n])=>(typeof n==`function`?e[t]=`any`:typeof n==`object`&&(e[t]=s(n).map(e=>`"${e}"`).join(` | `)),e),{}):{},s=(e,n=``,i=new Set)=>e?t.r(e)?(n&&i.add(n),Object.entries(e).forEach(([e,t])=>{r(e,t)&&s(t,n?`${n}.${e}`:e,i)}),[...i]):(Object.entries(e).forEach(([e,t])=>{let r=n?`${n}.${e}`:e;return t&&typeof t==`object`?s(t,r,i):i.add(n)}),[...i]):[],c=e=>{let t={};if(!e)return t;for(let[n,r]of Object.entries(e))!r||typeof r!=`object`||typeof r==`function`||u(r,[],t[n]||(t[n]={}),{});return t},l=(e,n)=>{let r={};for(let[t,n]of Object.entries(e))r[t]={...n};if(t.r(n)&&n.variants)for(let[e,t]of Object.entries(n.variants)){r[e]=r[e]||{};for(let n of Object.keys(t))r[e][n]=!0}return r},u=(e,n,i,a)=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let o=l(a,e),s=n.join(`.`);if(n.length&&(t.r(e)||Object.keys(o).length)){let e={};for(let[t,n]of Object.entries(o)){let r=Object.keys(n);e[t]=r.length===1&&r[0]===`true`?`boolean`:r.map(e=>`"${e}"`).join(` | `)}Object.keys(e).length&&(i[s]=e)}if(t.r(e)){for(let[t,a]of Object.entries(e))r(t,a)&&u(a,[...n,t.trim()],i,o);return}for(let[t,r]of Object.entries(e))!r||typeof r!=`object`||Array.isArray(r)||u(r,[...n,t.trim()],i,o)};exports.getTemplateKeys=a,exports.getTemplateTokens=s,exports.getTemplateTypes=o,exports.getTemplateVariantMaps=c,exports.parseAndJoinStyles=t.t,exports.parseStyles=t.n,exports.parseTemplates=i,exports.parseValueModifiers=t.c,exports.parseValueTokens=t.o,exports.parseVariableTokens=t.s,exports.reportParserIssue=t.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { dashCase as e, toHash as t } from "../util/index.js";
|
|
2
|
+
import { a as n, c as r, n as i, o as a, r as o, s, t as c } from "../parse-styles-Bz0otiZ-.js";
|
|
3
|
+
//#region src/parsers/parse-templates.ts
|
|
4
|
+
var l = new Set([
|
|
5
|
+
"base",
|
|
6
|
+
"variants",
|
|
7
|
+
"defaultVariants",
|
|
8
|
+
"compoundVariants",
|
|
9
|
+
"anyOfVariants"
|
|
10
|
+
]), u = (e, t) => l.has(e) ? !1 : !!t && typeof t == "object" && !Array.isArray(t), d = async (n, r = []) => {
|
|
11
|
+
if (!n) return "";
|
|
12
|
+
let i = [];
|
|
13
|
+
if (o(n)) {
|
|
14
|
+
let a = n, o = r.map((t) => e(String(t))).join("-");
|
|
15
|
+
if (a.base) {
|
|
16
|
+
let e = "t_" + t(o, 4), n = await c(a.base, `.${o}, .${e}`);
|
|
17
|
+
i.push(n);
|
|
18
|
+
}
|
|
19
|
+
if (a.variants) {
|
|
20
|
+
for (let [n, r] of Object.entries(a.variants)) if (!(!r || typeof r != "object")) for (let [a, s] of Object.entries(r)) {
|
|
21
|
+
if (!s || typeof s != "object") continue;
|
|
22
|
+
let r = `${o}-${e(n)}-${e(a)}`, l = await c(s, `.${r}, .${"tv_" + t(r, 4)}`);
|
|
23
|
+
i.push(l);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (let [e, t] of Object.entries(a)) {
|
|
27
|
+
if (!u(e, t)) continue;
|
|
28
|
+
let n = await d(t, [...r, e.trim()]);
|
|
29
|
+
i.push(n);
|
|
30
|
+
}
|
|
31
|
+
return i.join("\n");
|
|
32
|
+
}
|
|
33
|
+
let a = {};
|
|
34
|
+
for (let [e, t] of Object.entries(n)) if (typeof t != "function") if (t && typeof t == "object") {
|
|
35
|
+
let n = e.trim(), a = await d(t, [...r, n]);
|
|
36
|
+
i.push(a);
|
|
37
|
+
} else a[e] = t;
|
|
38
|
+
if (Object.keys(a).length) {
|
|
39
|
+
let n = r.map((t) => e(String(t))).join("-"), o = await c(a, `.${n}, .${"t_" + t(n, 4)}`);
|
|
40
|
+
i.push(o);
|
|
41
|
+
}
|
|
42
|
+
return i.join("\n");
|
|
43
|
+
}, f = (e) => Object.keys(e), p = (e) => e ? Object.entries(e).reduce((e, [t, n]) => (typeof n == "function" ? e[t] = "any" : typeof n == "object" && (e[t] = m(n).map((e) => `"${e}"`).join(" | ")), e), {}) : {}, m = (e, t = "", n = /* @__PURE__ */ new Set()) => e ? o(e) ? (t && n.add(t), Object.entries(e).forEach(([e, r]) => {
|
|
44
|
+
u(e, r) && m(r, t ? `${t}.${e}` : e, n);
|
|
45
|
+
}), [...n]) : (Object.entries(e).forEach(([e, r]) => {
|
|
46
|
+
let i = t ? `${t}.${e}` : e;
|
|
47
|
+
return r && typeof r == "object" ? m(r, i, n) : n.add(t);
|
|
48
|
+
}), [...n]) : [], h = (e) => {
|
|
49
|
+
let t = {};
|
|
50
|
+
if (!e) return t;
|
|
51
|
+
for (let [n, r] of Object.entries(e)) !r || typeof r != "object" || typeof r == "function" || _(r, [], t[n] || (t[n] = {}), {});
|
|
52
|
+
return t;
|
|
53
|
+
}, g = (e, t) => {
|
|
54
|
+
let n = {};
|
|
55
|
+
for (let [t, r] of Object.entries(e)) n[t] = { ...r };
|
|
56
|
+
if (o(t) && t.variants) for (let [e, r] of Object.entries(t.variants)) {
|
|
57
|
+
n[e] = n[e] || {};
|
|
58
|
+
for (let t of Object.keys(r)) n[e][t] = !0;
|
|
59
|
+
}
|
|
60
|
+
return n;
|
|
61
|
+
}, _ = (e, t, n, r) => {
|
|
62
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
63
|
+
let i = g(r, e), a = t.join(".");
|
|
64
|
+
if (t.length && (o(e) || Object.keys(i).length)) {
|
|
65
|
+
let e = {};
|
|
66
|
+
for (let [t, n] of Object.entries(i)) {
|
|
67
|
+
let r = Object.keys(n);
|
|
68
|
+
e[t] = r.length === 1 && r[0] === "true" ? "boolean" : r.map((e) => `"${e}"`).join(" | ");
|
|
69
|
+
}
|
|
70
|
+
Object.keys(e).length && (n[a] = e);
|
|
71
|
+
}
|
|
72
|
+
if (o(e)) {
|
|
73
|
+
for (let [r, a] of Object.entries(e)) u(r, a) && _(a, [...t, r.trim()], n, i);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (let [r, a] of Object.entries(e)) !a || typeof a != "object" || Array.isArray(a) || _(a, [...t, r.trim()], n, i);
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { f as getTemplateKeys, m as getTemplateTokens, p as getTemplateTypes, h as getTemplateVariantMaps, c as parseAndJoinStyles, i as parseStyles, d as parseTemplates, r as parseValueModifiers, a as parseValueTokens, s as parseVariableTokens, n as reportParserIssue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-modifiers.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,mBAAmB,GAC7B,YAAY,YAAY,KAAG,0BAiB3B,CAAC"}
|
|
@@ -11,3 +11,4 @@ import { CachedConfig, SaltyConfig } from '../types/config-types';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const parseStyles: <T extends object>(styles?: T, currentScope?: string, config?: Partial<SaltyConfig & CachedConfig> | CachedConfig | undefined, omitTemplates?: boolean) => Promise<string[]>;
|
|
13
13
|
export declare const parseAndJoinStyles: <T extends object>(styles: T, currentClass: string, config?: Partial<SaltyConfig & CachedConfig> | undefined, omitTemplates?: boolean) => Promise<string>;
|
|
14
|
+
//# sourceMappingURL=parse-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-styles.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWlE;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,SAAS,MAAM,EAChD,SAAS,CAAC,EACV,qBAAiB,EACjB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,YAAY,GAAG,SAAS,EACvE,uBAAqB,KACpB,OAAO,CAAC,MAAM,EAAE,CAoPlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,SAAS,MAAM,EACvD,QAAQ,CAAC,EACT,cAAc,MAAM,EACpB,SAAS,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,EACxD,uBAAqB,KACpB,OAAO,CAAC,MAAM,CAGhB,CAAC"}
|
|
@@ -12,3 +12,4 @@ export declare const getTemplateTokens: <T extends object>(templates: T, parent?
|
|
|
12
12
|
* valid call-site value.
|
|
13
13
|
*/
|
|
14
14
|
export declare const getTemplateVariantMaps: (templates: Record<string, any>) => Record<string, Record<string, Record<string, string>>>;
|
|
15
|
+
//# sourceMappingURL=parse-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-templates.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-templates.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,EAAE,OAAM,WAAW,EAAO,KAAG,OAAO,CAAC,MAAM,CAsDvG,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,WAAW,CAAC,KAAG,MAAM,EAEtE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,EAAE,WAAW,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CActF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,WAAW,CAAC,EAAE,eAAW,EAAE,4BAAkC,KAAG,MAAM,EAqBzH,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAS5H,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { SyncronousStyleValueModifierFunction } from './parser-types';
|
|
2
2
|
export declare const parseValueTokens: (tokenNames?: string[]) => SyncronousStyleValueModifierFunction;
|
|
3
3
|
export declare const parseVariableTokens: SyncronousStyleValueModifierFunction;
|
|
4
|
+
//# sourceMappingURL=parse-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-tokens.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-tokens.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,gBAAgB,GAC1B,aAAa,MAAM,EAAE,KAAG,oCAYxB,CAAC;AAEJ,eAAO,MAAM,mBAAmB,sCAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-regexes.d.ts","sourceRoot":"","sources":["../../src/parsers/parser-regexes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QACuJ,CAAC;AACpL,eAAO,MAAM,4BAA4B,QAAgB,CAAC;AAC1D,eAAO,MAAM,eAAe,QAA2C,CAAC;AACxE,eAAO,MAAM,oBAAoB,QAA4C,CAAC"}
|
|
@@ -6,3 +6,4 @@ type StyleValueModifierFunctionReturnValue = undefined | ValueParserReturnValue;
|
|
|
6
6
|
export type SyncronousStyleValueModifierFunction = (current: unknown) => StyleValueModifierFunctionReturnValue;
|
|
7
7
|
export type StyleValueModifierFunction = (current: string) => Promise<StyleValueModifierFunctionReturnValue> | StyleValueModifierFunctionReturnValue;
|
|
8
8
|
export {};
|
|
9
|
+
//# sourceMappingURL=parser-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-types.d.ts","sourceRoot":"","sources":["../../src/parsers/parser-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,KAAK,qCAAqC,GAAG,SAAS,GAAG,sBAAsB,CAAC;AAEhF,MAAM,MAAM,oCAAoC,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,qCAAqC,CAAC;AAE/G,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,qCAAqC,CAAC,GAAG,qCAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-name-check.d.ts","sourceRoot":"","sources":["../../src/parsers/property-name-check.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,MAI/C,CAAC"}
|
|
@@ -19,3 +19,4 @@ export declare const pathHasRichNode: (root: any, path: string[]) => boolean;
|
|
|
19
19
|
* Returns `undefined` if the path doesn't resolve. Emits console.warn for unknown axes / values.
|
|
20
20
|
*/
|
|
21
21
|
export declare const resolveRichTemplate: (root: any, path: string[], callSiteVariants: Record<string, string | boolean>, templateName: string) => Record<string, any> | undefined;
|
|
22
|
+
//# sourceMappingURL=resolve-template-variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-template-variants.d.ts","sourceRoot":"","sources":["../../src/parsers/resolve-template-variants.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,gBAK1D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,gBAAgB,GAAG,SAsCzE,CAAC;AA0BF,eAAO,MAAM,eAAe,GAAI,MAAM,GAAG,EAAE,MAAM,MAAM,EAAE,KAAG,OAI3D,CAAC;AAoBF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,GAAG,EAAE,MAAM,MAAM,EAAE,EAAE,kBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,cAAc,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAsG/J,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.d.ts","sourceRoot":"","sources":["../../src/parsers/strict.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,UAAU,EAAE,SAAS,MAAM,KAAG,IAGvE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-check.d.ts","sourceRoot":"","sources":["../../src/parsers/unit-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAyBxC;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,GAAG,MAAM,EAAE,SAAS,WAAW,KAAG,MAuBnF,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-2rwbF9j_.cjs");var n=n=>{let r=t=>e.toHash(t),i=async(e,r)=>(await t.n(e,r,n)).join(`
|
|
2
|
+
`);return{className:r,css:i,resolve:async(e,t)=>{let n=r(e);return{className:n,css:await i(e,t||`.${n}`)}},getDynamicStylesCss:i}};exports.defineRuntime=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,KAAK,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM;wBACf,UAAU;kBAEV,UAAU,UAAU,MAAM;sBAKtB,UAAU,UAAU,MAAM;;;;IAUvD,mIAAmI;kCAf1G,UAAU,UAAU,MAAM;CAkBtD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toHash as e } from "../util/index.js";
|
|
2
|
+
import { n as t } from "../parse-styles-Bz0otiZ-.js";
|
|
3
|
+
//#region src/runtime/index.ts
|
|
4
|
+
var n = (n) => {
|
|
5
|
+
let r = (t) => e(t), i = async (e, r) => (await t(e, r, n)).join("\n");
|
|
6
|
+
return {
|
|
7
|
+
className: r,
|
|
8
|
+
css: i,
|
|
9
|
+
resolve: async (e, t) => {
|
|
10
|
+
let n = r(e);
|
|
11
|
+
return {
|
|
12
|
+
className: n,
|
|
13
|
+
css: await i(e, t || `.${n}`)
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
getDynamicStylesCss: i
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as defineRuntime };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const e=require("./chunk-CMqjfN_6.cjs"),t=require("./compiler/helpers.cjs"),n=require("./util/index.cjs"),r=require("./factories/index.cjs"),i=require("./parse-styles-2rwbF9j_.cjs"),a=require("./css/merge.cjs");require("./css/index.cjs");const o=require("./compiler/get-files.cjs"),s=require("./parsers/index.cjs");let c=require("fs"),l=require("esbuild");l=e.t(l,1);let u=require("path"),d=require("winston"),f=require("fs/promises"),p=require("child_process"),m=require("module");var h=(0,d.createLogger)({level:`debug`,format:d.format.combine(d.format.colorize(),d.format.cli()),transports:[new d.transports.Console({})]}),g=e=>{h.error(e)},_=/^(?:[a-z][a-z0-9+.-]*:)?\/\//i,v=e=>typeof e==`string`?{url:e}:e,y=e=>e.startsWith(`.`)||e.startsWith(`/`)?e:`./${e}`,b=e=>e.split(`\\`).join(`/`),x=(e,t)=>(0,m.createRequire)(t).resolve(e),S=(e,t)=>{let n=(0,u.dirname)(t);(0,c.existsSync)(n)||(0,c.mkdirSync)(n,{recursive:!0}),(0,c.copyFileSync)(e,t)},C=(e,{media:t,supports:n})=>{let r=`@import url('${e}')`;return n&&(r+=` supports(${n})`),t&&(r+=` ${t}`),`${r};`},w=(e,t,r,i={})=>{let a=v(e),{url:o}=a,s=i.resolveModule??x,c=i.copyAsset??S;if(_.test(o)||o.startsWith(`/`))return{rule:C(o,a)};if(o.startsWith(`./`)||o.startsWith(`../`)){let e=(0,u.resolve)((0,u.dirname)(t),o);return{rule:C(y(b((0,u.relative)((0,u.join)(r,`css`),e))),a)}}let l=s(o.startsWith(`~`)?o.slice(1):o,t),d=`${n.toHash(l,6)}-${(0,u.basename)(l)}`;return c(l,(0,u.join)(r,`imports`,d)),{rule:C(`../imports/${d}`,a)}},T=async e=>{let t=await o.getPackageJson(e);if(t)return t.type},E,D=async e=>{if(E)return E;let t=await T(e);return t===`module`?E=`esm`:(t===`commonjs`||{}.url.endsWith(`.cjs`))&&(E=`cjs`),E||`esm`};function O(e){return e?typeof e==`string`?e.replace(/[^\d\w]/g,`.`):O(String(e)):``}var k={"*, *::before, *::after":{boxSizing:`border-box`},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:`100%`,WebkitFontSmoothing:`antialiased`},"img, picture, video, canvas, svg":{display:`block`,maxWidth:`100%`},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:`break-word`},p:{textWrap:`pretty`},"h1, h2, h3, h4, h5, h6":{textWrap:`balance`},a:{color:`currentColor`},button:{lineHeight:`1em`,color:`currentColor`},"input, optgroup, select, textarea":{fontFamily:`inherit`,fontSize:`100%`,lineHeight:`1.15em`}},A=class{projectRootDir;options;importFile=e=>import(`${e}?t=${Date.now()}`);cache={rcFile:null,destDir:null,externalModules:[]};constructor(e,t={}){if(this.projectRootDir=e,this.options=t,typeof process>`u`)throw Error(`SaltyServer can only be used in a Node.js environment.`)}get isProduction(){if(this.options.mode)return this.options.mode===`production`;try{return process.env.NODE_ENV!==`development`}catch{return!1}}readRCFile=async(e=this.projectRootDir)=>{if(this.cache.rcFile)return this.cache.rcFile;if(e===`/`)throw Error(`Could not find .saltyrc.json file`);let t=await(0,f.readFile)((0,u.join)(e,`.saltyrc.json`),`utf-8`).then(JSON.parse).catch(()=>void 0);return t?(this.cache.rcFile=t,t):this.readRCFile((0,u.join)(e,`..`))};getRCProjectConfig=async e=>{let t=await this.readRCFile(e);return t.projects?.find(t=>e.endsWith(t.dir||``))||t.projects?.find(e=>e.dir===t.defaultProject)};getPathFilter=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir);return{include:e?.include,exclude:e?.exclude}};isAllowedSaltyFile=(e,r)=>t.isSaltyFile(e)?n.isPathAllowed(n.normalizePath((0,u.relative)(this.projectRootDir,e)),r):!1;getExternalModules=e=>{if(this.cache.externalModules.length>0)return this.cache.externalModules;let t=(0,c.readFileSync)(e,`utf8`).match(/externalModules:\s?\[(.*)\]/);if(!t)return[];let n=t[1].split(`,`).map(e=>e.replace(/['"`]/g,``).trim());return this.cache.externalModules=n,n};getDestDir=async()=>{if(this.cache.destDir)return this.cache.destDir;let e=await this.getRCProjectConfig(this.projectRootDir),t=(0,u.join)(this.projectRootDir,e?.saltygenDir||`saltygen`);return this.cache.destDir=t,t};generateConfig=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir),t=await this.getDestDir(),n=(0,u.join)(this.projectRootDir,e?.configDir||``,`salty.config.ts`),r=(0,u.join)(t,`salty.config.js`),i=await D(this.projectRootDir),a=this.getExternalModules(n);await l.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:i,external:a});let{config:o}=await this.importFile(r);return{config:o,path:r}};addConfigCache=e=>{try{let t=(0,c.readFileSync)((0,u.join)(this.projectRootDir,`saltygen/cache/config-cache.json`),`utf8`);return t?`globalThis.saltyConfig = ${t};\n\n${e}`:`globalThis.saltyConfig = {};\n\n${e}`}catch{return e}};getConfigCache=async()=>{let e=(0,c.readFileSync)((0,u.join)(await this.getDestDir(),`cache/config-cache.json`),`utf8`);if(!e)throw Error(`Could not find config cache file`);return JSON.parse(e)};getConfig=async()=>{let e=await this.getConfigCache(),t=(0,u.join)(await this.getDestDir(),`salty.config.js`),{config:n}=await this.importFile(t);return a.mergeObjects(n,e)};generateCss=async(e=!0)=>{try{let r=Date.now();this.isProduction?h.info(`Generating CSS in production mode! 🔥`):h.info(`Generating CSS in development mode! 🚀`);let i=[],a=[],o=await this.getDestDir(),s=(0,u.join)(o,`index.css`);e&&((0,c.existsSync)(o)&&(0,p.execSync)(`rm -rf `+o),(0,c.mkdirSync)(o,{recursive:!0}),(0,c.mkdirSync)((0,u.join)(o,`css`)),(0,c.mkdirSync)((0,u.join)(o,`types`)),(0,c.mkdirSync)((0,u.join)(o,`js`)),(0,c.mkdirSync)((0,u.join)(o,`cache`)),(0,c.mkdirSync)((0,u.join)(o,`imports`)));let l=new Set,d=new Set,f=await this.getPathFilter(),{exclude:m}=f,g=this.projectRootDir;async function _(e){let r=[`node_modules`,`saltygen`],i=(0,c.statSync)(e);if(i.isDirectory()){if(r.some(t=>e.includes(t)))return;if(m?.length){let t=n.normalizePath((0,u.relative)(g,e));if(t&&!n.isPathAllowed(t,{exclude:m}))return}let t=(0,c.readdirSync)(e);await Promise.all(t.map(t=>_((0,u.join)(e,t))))}else if(i.isFile()&&t.isSaltyFile(e)&&n.isPathAllowed(n.normalizePath((0,u.relative)(g,e)),f)){l.add(e);let t=(0,c.readFileSync)(e,`utf8`);/define[\w\d]+\(/.test(t)&&d.add(e)}}await _(this.projectRootDir),await this.generateConfigStyles(d);let v={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async e=>{let{contents:n}=await this.compileSaltyFile(e,o);for(let[r,i]of Object.entries(n)){let n=await t.resolveExportValue(i,1);n.isKeyframes?v.keyframes.push({value:n,src:e,name:r}):n.isClassName?v.classNames.push({...i,src:e,name:r}):n.generator&&v.components.push({...i,src:e,name:r})}}));let y=await this.getConfig();for(let e of v.keyframes){let{value:t}=e,n=`a_${t.animationName}.css`,r=(0,u.join)(o,`css/${n}`);i.push(n),(0,c.writeFileSync)(r,t.css)}let b={};for(let e of v.components){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y});a[r.priority]||(a[r.priority]=[]);let i=await r.css;i&&(a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}for(let e of v.classNames){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y}),i=await r.css;i&&(a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}y.importStrategy===`component`&&Object.entries(b).forEach(([e,t])=>{let r=t.map(e=>`@import url('./${e}');`).join(`
|
|
2
|
+
`),i=n.toHash(e,6);(0,c.writeFileSync)((0,u.join)(o,`css/f_${n.dashCase((0,u.parse)(e).name)}-${i}.css`),r||`/* Empty file */`)});let x=i.map(e=>`@import url('./css/${e}');`).join(`
|
|
3
|
+
`),S=`/*!
|
|
4
|
+
* Generated with Salty CSS (https://salty-css.dev)
|
|
5
|
+
* Do not edit this file directly
|
|
6
|
+
*/
|
|
7
|
+
@layer imports, reset, global, templates, fonts, l0, l1, l2, l3, l4, l5, l6, l7, l8;\n\n${[`_imports.css`,`_variables.css`,`_reset.css`,`_global.css`,`_templates.css`,`_fonts.css`].filter(e=>{try{return(0,c.readFileSync)((0,u.join)(o,`css`,e),`utf8`).length>0}catch{return!1}}).map(e=>`@import url('./css/${e}')${e===`_imports.css`?` layer(imports)`:``};`).join(`
|
|
8
|
+
`)}\n${x}`;if(y.importStrategy!==`component`){let e=a.reduce((e,t,r)=>{let i=t.reduce((e,t)=>{let r=(0,u.join)(o,`css`,t),i=(0,c.readFileSync)(r,`utf8`),a=/.*-([^-]+)-\d+.css/.exec(t)?.at(1)||n.toHash(r,6);return e.includes(a)?e:`${e}\n/*start:${a}-${t}*/\n${i}\n/*end:${a}*/\n`},``),a=`l_${r}.css`;return(0,c.writeFileSync)((0,u.join)(o,`css`,a),`@layer l${r} { ${i}\n }`),`${e}\n@import url('./css/${a}');`},``);S+=e}(0,c.writeFileSync)(s,S);let C=Date.now()-r,w=C<200?`🔥`:C<500?`🚀`:C<1e3?`🎉`:C<2e3?`🚗`:C<5e3?`🤔`:`🥴`;h.info(`Generated CSS in ${C}ms! ${w}`)}catch(e){console.error(e)}};generateConfigStyles=async e=>{let t=await this.getDestDir(),o={mediaQueries:[],globalStyles:[],variables:[],templates:[],imports:[],fonts:[]};await Promise.all([...e].map(async e=>{let{contents:n,outputFilePath:r}=await this.compileSaltyFile(e,t);Object.entries(n).forEach(([t,n])=>{n.isMedia?o.mediaQueries.push([t,n]):n.isGlobalDefine?o.globalStyles.push(n):n.isDefineVariables?o.variables.push(n):n.isDefineTemplates?o.templates.push(n._setPath(`${t};;${r}`)):n.isDefineImport?o.imports.push(n._setPath(e)):n.isDefineFont&&o.fonts.push(n)})}));let{config:l,path:d}=await this.generateConfig(),f={...l},{mediaQueries:p}=o;f.mediaQueries=Object.fromEntries(p.map(([e,t])=>[`@${e}`,t]));let m=p.map(([e])=>`'@${e}'`).join(` | `),g=new Set,_=async(e,t=[])=>{if(!e)return[];let r=Object.entries(e).map(async([e,r])=>{let a=async r=>{if(!r)return;if(r instanceof Promise)return await a(await r);if(typeof r==`function`)return await a(await r());if(typeof r==`object`)return await _(r,[...t,e]);let o=O(e),s=n.dashCase(e),c=[...t,o].join(`.`);g.add(`"${c}"`);let l=[...t.map(n.dashCase),s].join(`-`),u=i.s(r);return u?`--${l}: ${u.transformed};`:`--${l}: ${r};`};return await a(r)});return(await Promise.all(r)).flat()},v=async e=>{if(!e)return[];let t=Object.entries(e).map(async([e,t])=>{let n=await _(t);return e===`base`?n.join(``):f.mediaQueries[e]?`${f.mediaQueries[e]} { ${n.join(``)} }`:`${e} { ${n.join(``)} }`});return(await Promise.all(t)).flat()},y=async e=>{if(!e)return[];let t=Object.entries(e).map(async([e,t])=>{let n=Object.entries(t).map(async([t,n])=>{let r=await _(n,[e]);return`${`.${e}-${t}, [data-${e}="${t}"]`} { ${r.join(``)} }`});return(await Promise.all(n)).flat()});return(await Promise.all(t)).flat()},b=(e={})=>({...e,responsive:void 0,conditional:void 0}),x=e=>o.variables.map(t=>e===`static`?b(t._current):t._current[e]),S=a.mergeObjects(b(l.variables),x(`static`)),C=await _(S),T=await v(a.mergeObjects(l.variables?.responsive,x(`responsive`))),E=await y(a.mergeObjects(l.variables?.conditional,x(`conditional`)));(0,c.writeFileSync)((0,u.join)(t,`css/_variables.css`),`:root { ${C.join(``)} ${T.join(``)} } ${E.join(``)}`),f.staticVariables=S,(0,c.writeFileSync)((0,u.join)(t,`css/_global.css`),`@layer global { ${await i.t(a.mergeObjects(l.global,o.globalStyles),``)} }`);let D=(0,u.join)(t,`css/_reset.css`);(0,c.writeFileSync)(D,`@layer reset { ${await i.t(l.reset===`none`?{}:typeof l.reset==`object`?l.reset:k,``)} }`);let A=(0,u.join)(t,`css/_templates.css`),j=a.mergeObjects(l.templates,o.templates),M=await s.parseTemplates(j),N=s.getTemplateTypes(j),P=s.getTemplateVariantMaps(j);(0,c.writeFileSync)(A,`@layer templates { ${M} }`),f.templates=j;let F=(0,u.join)(t,`css/_imports.css`),I=[];for(let e of o.imports){let n=e._path;if(n)for(let r of e._current)try{let{rule:e}=w(r,n,t);I.push(e)}catch(e){let t=typeof r==`string`?r:r.url;h.error(`Failed to resolve defineImport(${JSON.stringify(t)}) from ${n}: ${e.message}`)}}(0,c.writeFileSync)(F,I.join(`
|
|
9
|
+
`));let L=l.templates?[r.defineTemplates(l.templates)._setPath(`config;;${d}`)]:[],R=a.mergeFactories(o.templates,L);f.templatePaths=Object.fromEntries(Object.entries(R).map(([e,t])=>[e,t._path]));let z=(0,u.join)(t,`css/_fonts.css`);if(o.fonts.length===0)(0,c.writeFileSync)(z,``);else{let e=[],t=[];for(let n of o.fonts){let{imports:r,body:i}=n._toCss();e.push(...r),t.push(i)}(0,c.writeFileSync)(z,`${e.length?`${e.join(`
|
|
10
|
+
`)}\n\n`:``}@layer fonts { ${t.join(` `)} }`)}let B=(0,u.join)(t,`types/css-tokens.d.ts`),V=[...g].join(`|`),H=e=>e.split(/[.\-_]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``),U=Object.entries(P),W=U.some(([,e])=>Object.keys(e).length>0)?`type TemplateVariantTokens = {
|
|
11
|
+
${U.filter(([,e])=>Object.keys(e).length>0).map(([e,t])=>`${e}: {\n ${Object.entries(t).map(([e,t])=>`'${e}': { ${Object.entries(t).map(([e,t])=>`${e}?: ${t}`).join(`; `)} }`).join(`;
|
|
12
|
+
`)}\n }`).join(`;
|
|
13
|
+
`)}
|
|
14
|
+
}`:`type TemplateVariantTokens = Record<string, Record<string, Record<string, never>>>;`,G=U.flatMap(([e,t])=>Object.keys(t).map(t=>`type ${H(e)}${H(t)}Variants = TemplateVariantTokens['${e}']['${t}'];`)).join(`
|
|
15
|
+
`);(0,c.writeFileSync)(B,`
|
|
16
|
+
// Variable types
|
|
17
|
+
type VariableTokens = ${V||`''`};
|
|
18
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
19
|
+
|
|
20
|
+
// Template types
|
|
21
|
+
type TemplateTokens = {
|
|
22
|
+
${Object.entries(N).map(([e,t])=>!t||t===`any`?`${e}?: ${t||`any`}`:`${e}?: ${t} | \`\${${t}}@\${string}\``).join(`
|
|
23
|
+
`)}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Template variant types (per docs/template-variants-spec.md §7)
|
|
27
|
+
${W}
|
|
28
|
+
${G}
|
|
29
|
+
|
|
30
|
+
// Media query types
|
|
31
|
+
type MediaQueryKeys = ${m||`''`};
|
|
32
|
+
`),(0,c.writeFileSync)((0,u.join)(t,`cache/config-cache.json`),JSON.stringify(f,null,2))};compileSaltyFile=async(e,t)=>{let r=n.toHash(e),i=(0,u.join)(t,`./temp`);(0,c.existsSync)(i)||(0,c.mkdirSync)(i);let a=(0,u.parse)(e),o=(0,c.readFileSync)(e,`utf8`);o=this.replaceStyledTag(o),o=this.addConfigCache(o);let s=(0,u.join)(t,`js`,`${r}-${n.toHash(o)}.js`),d=await this.getRCProjectConfig(this.projectRootDir),f=(0,u.join)(this.projectRootDir,d?.configDir||``,`salty.config.ts`),p=this.getExternalModules(f),m=await D(this.projectRootDir);return await l.build({stdin:{contents:o,sourcefile:a.base,resolveDir:a.dir,loader:`tsx`},minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:m,target:[`node20`],keepNames:!0,external:p,packages:`external`,plugins:[{name:`test`,setup:e=>{e.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},e=>{let t=(0,c.readFileSync)(e.path,`utf8`);return{contents:this.replaceStyledTag(t),loader:`ts`}})}}]}),{contents:await this.importFile(s),outputFilePath:s}};getFramework=async()=>(await this.getRCProjectConfig(this.projectRootDir))?.framework;generateFile=async e=>{try{let r=await this.getDestDir(),i=await this.getPathFilter();if(this.isAllowedSaltyFile(e,i)){let i=[],a=await this.getConfig(),{contents:o}=await this.compileSaltyFile(e,r);for(let[e,n]of Object.entries(o)){let o=await t.resolveExportValue(n,1);if(o.isKeyframes&&o.css){(0,c.writeFileSync)((0,u.join)(r,`css/${`a_${o.animationName}.css`}`),await o.css);continue}if(o.isClassName){let t=o.generator._withBuildContext({callerName:e,isProduction:this.isProduction,config:a}),n=await t.css;if(!n)continue;i[t.priority]||(i[t.priority]=[]),i[t.priority].push(t.cssFileName),(0,c.writeFileSync)((0,u.join)(r,`css/${t.cssFileName}`),n);continue}if(!o.generator)continue;let s=o.generator._withBuildContext({callerName:e,isProduction:this.isProduction,config:a}),l=await s.css;l&&((0,c.writeFileSync)((0,u.join)(r,`css/${s.cssFileName}`),l),i[s.priority]||(i[s.priority]=[]),i[s.priority].push(s.cssFileName))}if(a.importStrategy!==`component`)i.forEach((e,t)=>{let i=(0,u.join)(r,`css`,`l_${t}.css`),a=(0,c.readFileSync)(i,`utf8`);e.forEach(e=>{let t=(0,u.join)(r,`css`,e),i=/.*-([^-]+)-\d+.css/.exec(e)?.at(1)||n.toHash(t,6);if(!a.includes(i)){let n=`/*start:${i}-${e}*/\n${(0,c.readFileSync)(t,`utf8`)}\n/*end:${i}*/\n`;a=`${a.replace(/\}$/,``)}\n${n}\n}`}}),(0,c.writeFileSync)(i,a)});else{let t=i.flat().map(e=>`@import url('./${e}');`).join(`
|
|
33
|
+
`),a=n.toHash(e,6);(0,c.writeFileSync)((0,u.join)(r,`css/f_${n.dashCase((0,u.parse)(e).name)}-${a}.css`),t||`/* Empty file */`)}}}catch(e){console.error(e)}};replaceStyledTag=e=>e.replace(/styled\(([^"'`{,]+),/g,(n,r)=>{if(/^['"`]/.test(r))return n;let i=RegExp(`import[^;]*${r}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return n;let a=i.exec(e);if(a){let e=a.at(1);if(t.saltyFileExtensions.some(t=>e?.includes(t)))return n}return`styled('div',`})};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}});
|