@salty-css/core 0.0.1-alpha.147 → 0.0.1-alpha.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.d.ts +23 -1
- package/compiler/index.js +12 -10
- package/config/define-config.d.ts +1 -1
- package/config/index.d.ts +1 -1
- package/css/index.cjs +1 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +121 -2
- package/css/keyframes.d.ts +22 -0
- package/css/media.d.ts +87 -0
- package/css/merge.d.ts +6 -0
- package/css/token.d.ts +1 -0
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-variables.d.ts +15 -0
- package/factories/index.cjs +1 -0
- package/factories/index.d.ts +2 -0
- package/factories/index.js +27 -0
- package/generator/index.cjs +1 -1
- package/generator/index.js +7 -6
- package/generator/parse-modifiers.d.ts +1 -1
- package/generator/parse-styles.d.ts +1 -1
- package/index-BixulVRN.js +397 -0
- package/index-C6uCnypW.cjs +29 -0
- package/merge-BVm9us1A.js +4 -0
- package/merge-DxGoJDHv.cjs +1 -0
- package/package.json +1 -1
- package/parse-styles-3zK35muR.cjs +7 -0
- package/parse-styles-DrLhKtqW.js +75 -0
- package/parse-templates-BKvQLGeN.cjs +2 -0
- package/parse-templates-BdcpkXBG.js +27 -0
- package/server/index.cjs +1 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +11 -0
- package/server/should-restart.d.ts +1 -0
- package/templates/salty-reset.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/index-CLCze-Xg.cjs +0 -29
- package/index-ChBlB_DP.js +0 -376
- package/parse-templates-CgZo0YA1.js +0 -97
- package/parse-templates-DD4hQEpv.cjs +0 -8
- /package/{config → types}/config-types.d.ts +0 -0
package/index-CLCze-Xg.cjs
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";const de=require("esbuild"),fe=require("child_process"),N=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),i=require("fs"),B=require("fs/promises"),J=require("./parse-templates-DD4hQEpv.cjs"),H=require("winston");var L=typeof document<"u"?document.currentScript:null;function ue(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const X=ue(de),Y=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return i.existsSync(t)?t:Y(r.join(e,".."))},pe=async e=>{const t=Y(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ye=async e=>{const t=await pe(e);if(t)return t.type};let V;const Q=async e=>{if(V)return V;const t=await ye(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:L&&L.tagName.toUpperCase()==="SCRIPT"&&L.src||new URL("index-CLCze-Xg.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},I=H.createLogger({level:"debug",format:H.format.combine(H.format.colorize(),H.format.cli()),transports:[new H.transports.Console({})]}),ge=e=>{I.error(e)};function ee(e){return e?typeof e!="string"?ee(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const me={"*, *::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"}},_={externalModules:[],rcFile:void 0,destDir:void 0},te=e=>{if(_.externalModules.length>0)return _.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(a=>a.replace(/['"`]/g,"").trim());return _.externalModules=c,c},z=async e=>{if(_.destDir)return _.destDir;const t=await Z(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return _.destDir=s,s},K=["salty","css","styles","styled"],se=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),W=(e,t=[])=>se(t).test(e),ne=async e=>{if(_.rcFile)return _.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(_.rcFile=s,s):ne(r.join(e,".."))},Z=async e=>{var c,a;const t=await ne(e),s=(c=t.projects)==null?void 0:c.find(o=>e.endsWith(o.dir||""));return s||((a=t.projects)==null?void 0:a.find(o=>o.dir===t.defaultProject))},he=async e=>{const t=await Z(e),s=await z(e),c=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),a=r.join(s,"salty.config.js"),o=await Q(e),w=te(c);await X.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:a,format:o,external:w});const y=Date.now(),{config:l}=await import(`${a}?t=${y}`);return l},oe=async e=>{const t=await he(e),s=new Set,c=(f,g=[])=>f?Object.entries(f).flatMap(([S,p])=>{if(!p)return;if(typeof p=="object")return c(p,[...g,S]);const R=ee(S),v=N.dashCase(S),D=[...g,R].join(".");s.add(`"${D}"`);const j=[...g.map(N.dashCase),v].join("-"),{result:T}=J.parseValueTokens(p);return`--${j}: ${T};`}):[],a=f=>f?Object.entries(f).flatMap(([g,S])=>{const p=c(S);return g==="base"?p.join(""):`${g} { ${p.join("")} }`}):[],o=f=>f?Object.entries(f).flatMap(([g,S])=>Object.entries(S).flatMap(([p,R])=>{const v=c(R,[g]),D=`.${g}-${p}, [data-${g}="${p}"]`,j=v.join("");return`${D} { ${j} }`})):[],w=c(t.variables),y=a(t.responsiveVariables),l=o(t.conditionalVariables),n=await z(e),u=r.join(n,"css/_variables.css"),m=`:root { ${w.join("")} ${y.join("")} } ${l.join("")}`;i.writeFileSync(u,m);const $=r.join(n,"css/_global.css"),b=J.parseStyles(t.global,"");i.writeFileSync($,`@layer global { ${b} }`);const F=r.join(n,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:me,C=J.parseStyles(h,"");i.writeFileSync(F,`@layer reset { ${C} }`);const d=r.join(n,"css/_templates.css"),x=J.parseTemplates(t.templates),E=J.getTemplateTypes(t.templates);i.writeFileSync(d,x);const k=r.join(n,"types/css-tokens.d.ts"),P=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...s].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(E).map(([f,g])=>`${f}?: ${g}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;i.writeFileSync(k,P)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const a=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!a.test(e))return t;const w=a.exec(e);if(w){const y=w.at(1);if(K.some(n=>y==null?void 0:y.includes(n)))return t}return"styled('div',"}),q=async(e,t,s)=>{const c=N.toHash(t),a=r.join(s,"./temp");i.existsSync(a)||i.mkdirSync(a);const o=r.parse(t);let w=i.readFileSync(t,"utf8");w=U(w);const y=r.join(s,"js",c+".js"),l=await Z(e),n=r.join(e,(l==null?void 0:l.configDir)||"","salty.config.ts"),u=te(n),m=await Q(e);await X.build({stdin:{contents:w,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:m,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:F=>{F.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},M=>{const h=i.readFileSync(M.path,"utf8");return{contents:U(h),loader:"ts"}})}}]});const $=Date.now();return await import(`${y}?t=${$}`)},A=async e=>{const t=await z(e),s=r.join(t,"salty.config.js"),c=Date.now(),{config:a}=await import(`${s}?t=${c}`);return a},re=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Se=async(e,t=re())=>{try{const s=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const c=[],a=[],o=await z(e),w=r.join(o,"index.css");(()=>{i.existsSync(o)&&fe.execSync("rm -rf "+o),i.mkdirSync(o,{recursive:!0}),i.mkdirSync(r.join(o,"css")),i.mkdirSync(r.join(o,"types"))})(),await oe(e);const l=await A(e);async function n(d,x){const E=["node_modules","saltygen"],k=i.statSync(d);if(k.isDirectory()){const O=i.readdirSync(d);if(E.some(f=>d.includes(f)))return;await Promise.all(O.map(f=>n(r.join(d,f),r.join(x,f))))}else if(k.isFile()&&W(d)){const P=await q(e,d,o),f=[];Object.entries(P).forEach(([D,j])=>{if(j.isKeyframes&&j.css){const G=`a_${j.animationName}.css`,ae=`css/${G}`,le=r.join(o,ae);c.push(G),i.writeFileSync(le,j.css);return}if(!j.generator)return;const T=j.generator._withBuildContext({name:D,config:l,prod:t});a[T.priority]||(a[T.priority]=[]),a[T.priority].push(T.cssFileName),f.push(T.cssFileName);const ie=`css/${T.cssFileName}`,ce=r.join(o,ie);i.writeFileSync(ce,T.css)});const g=f.map(D=>`@import url('./${D}');`).join(`
|
12
|
-
`),S=N.toHash(d,6),p=r.parse(d),R=N.dashCase(p.name),v=r.join(o,`css/f_${R}-${S}.css`);i.writeFileSync(v,g)}}await n(e,o);const u=c.map(d=>`@import url('./css/${d}');`).join(`
|
13
|
-
`);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(d=>{try{return i.readFileSync(r.join(o,"css",d),"utf8").length>0}catch{return!1}}).map(d=>`@import url('./css/${d}');`).join(`
|
16
|
-
`)}
|
17
|
-
${u}`;if(l.importStrategy!=="component"){const d=a.reduce((x,E,k)=>{const O=E.reduce((S,p)=>{var j;const R=r.join(o,"css",p),v=i.readFileSync(R,"utf8"),D=((j=/.*-([^-]+)-\d+.css/.exec(p))==null?void 0:j.at(1))||N.toHash(R,6);return S.includes(D)?S:`${S}
|
18
|
-
/*start:${D}*/
|
19
|
-
${v}
|
20
|
-
/*end:${D}*/
|
21
|
-
`},""),P=`l_${k}.css`,f=r.join(o,"css",P),g=`@layer l${k} { ${O}
|
22
|
-
}`;return i.writeFileSync(f,g),`${x}
|
23
|
-
@import url('./css/${P}');`},"");F+=d}i.writeFileSync(w,F);const h=Date.now()-s,C=h<200?"🔥":h<500?"🚀":h<1e3?"🎉":h<2e3?"🚗":h<5e3?"🤔":"🥴";I.info(`Generated CSS in ${h}ms! ${C}`)}catch(s){console.error(s)}},we=async(e,t)=>{try{const s=await z(e);if(W(t)){const a=[],o=await A(e),w=await q(e,t,s);Object.entries(w).forEach(([y,l])=>{if(l.isKeyframes&&l.css){const b=`css/${`a_${l.animationName}.css`}`,F=r.join(s,b);i.writeFileSync(F,l.css);return}if(!l.generator)return;const n=l.generator._withBuildContext({name:y,config:o}),u=`css/${n.cssFileName}`,m=r.join(s,u);i.writeFileSync(m,n.css),a[n.priority]||(a[n.priority]=[]),a[n.priority].push(n.cssFileName)}),o.importStrategy!=="component"&&a.forEach((y,l)=>{const n=`l_${l}.css`,u=r.join(s,"css",n);let m=i.readFileSync(u,"utf8");y.forEach($=>{var h;const b=r.join(s,"css",$),F=((h=/.*-([^-]+)-\d+.css/.exec($))==null?void 0:h.at(1))||N.toHash(b,6);if(!m.includes(F)){const C=i.readFileSync(b,"utf8"),d=`/*start:${F}*/
|
24
|
-
${C}
|
25
|
-
/*end:${F}*/
|
26
|
-
`;m=`${m.replace(/\}$/,"")}
|
27
|
-
${d}
|
28
|
-
}`}}),i.writeFileSync(u,m)})}}catch(s){console.error(s)}},Fe=async(e,t,s=re())=>{try{const c=await z(e);if(W(t)){const o=i.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==o&&await B.writeFile(t,o);const y=await A(e),l=await q(e,t,c);let n=o;if(Object.entries(l).forEach(([u,m])=>{var S;if(m.isKeyframes||!m.generator)return;const $=m.generator._withBuildContext({name:u,config:y,prod:s}),b=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!b)return console.error("Could not find the original declaration");const F=(S=b.at(1))==null?void 0:S.trim(),M=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(n);if(!M)return console.error("Could not find the original declaration");const{index:h}=M;let C=!1;const d=setTimeout(()=>C=!0,5e3);let x=0,E=!1,k=0;for(;!E&&!C;){const p=n[h+x];p==="("&&k++,p===")"&&k--,k===0&&p===")"&&(E=!0),x>n.length&&(C=!0),x++}if(!C)clearTimeout(d);else throw new Error("Failed to find the end of the styled call and timed out");const O=h+x,P=n.slice(h,O),f=n,g=` ${u} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;n=n.replace(P,g),f===n&&console.error("Minimize file failed to change content",{name:u,tagName:F})}),y.importStrategy==="component"){const u=N.toHash(t,6),m=r.parse(t);n=`import '../../saltygen/css/${`f_${N.dashCase(m.name)}-${u}.css`}';
|
29
|
-
${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=oe;exports.generateCss=Se;exports.generateFile=we;exports.isSaltyFile=W;exports.logError=ge;exports.logger=I;exports.minimizeFile=Fe;exports.saltyFileExtensions=K;exports.saltyFileRegExp=se;
|
package/index-ChBlB_DP.js
DELETED
@@ -1,376 +0,0 @@
|
|
1
|
-
import * as Q from "esbuild";
|
2
|
-
import { execSync as pt } from "child_process";
|
3
|
-
import { t as z, d as H } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as r, parse as K } from "path";
|
5
|
-
import { existsSync as L, writeFileSync as S, mkdirSync as W, readFileSync as M, statSync as ut, readdirSync as gt } from "fs";
|
6
|
-
import { readFile as tt, writeFile as mt } from "fs/promises";
|
7
|
-
import { p as X, a as yt, b as ht, c as $t } from "./parse-templates-CgZo0YA1.js";
|
8
|
-
import { createLogger as bt, format as B, transports as wt } from "winston";
|
9
|
-
const et = (t) => {
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
-
const e = r(t, "package.json");
|
12
|
-
return L(e) ? e : et(r(t, ".."));
|
13
|
-
}, St = async (t) => {
|
14
|
-
const e = et(t);
|
15
|
-
return await tt(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, Ct = async (t) => {
|
18
|
-
const e = await St(t);
|
19
|
-
if (e)
|
20
|
-
return e.type;
|
21
|
-
};
|
22
|
-
let J;
|
23
|
-
const st = async (t) => {
|
24
|
-
if (J) return J;
|
25
|
-
const e = await Ct(t);
|
26
|
-
return e === "module" ? J = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (J = "cjs"), J || "esm";
|
27
|
-
}, I = bt({
|
28
|
-
level: "debug",
|
29
|
-
format: B.combine(B.colorize(), B.cli()),
|
30
|
-
transports: [new wt.Console({})]
|
31
|
-
}), Vt = (t) => {
|
32
|
-
I.error(t);
|
33
|
-
};
|
34
|
-
function nt(t) {
|
35
|
-
return t ? typeof t != "string" ? nt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
-
}
|
37
|
-
const Ft = {
|
38
|
-
/** Set box model to border-box */
|
39
|
-
"*, *::before, *::after": {
|
40
|
-
boxSizing: "border-box"
|
41
|
-
},
|
42
|
-
/** Remove default margin and padding */
|
43
|
-
"*": {
|
44
|
-
margin: 0
|
45
|
-
},
|
46
|
-
/** Remove adjust font properties */
|
47
|
-
html: {
|
48
|
-
lineHeight: 1.15,
|
49
|
-
textSizeAdjust: "100%",
|
50
|
-
WebkitFontSmoothing: "antialiased"
|
51
|
-
},
|
52
|
-
/** Make media elements responsive */
|
53
|
-
"img, picture, video, canvas, svg": {
|
54
|
-
display: "block",
|
55
|
-
maxWidth: "100%"
|
56
|
-
},
|
57
|
-
/** Avoid overflow of text */
|
58
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
59
|
-
overflowWrap: "break-word"
|
60
|
-
},
|
61
|
-
/** Improve text wrapping */
|
62
|
-
p: {
|
63
|
-
textWrap: "pretty"
|
64
|
-
},
|
65
|
-
"h1, h2, h3, h4, h5, h6": {
|
66
|
-
textWrap: "balance"
|
67
|
-
},
|
68
|
-
/** Improve link color */
|
69
|
-
a: {
|
70
|
-
color: "currentColor"
|
71
|
-
},
|
72
|
-
/** Improve button line height */
|
73
|
-
button: {
|
74
|
-
lineHeight: "1em",
|
75
|
-
color: "currentColor"
|
76
|
-
},
|
77
|
-
/** Improve form elements */
|
78
|
-
"input, optgroup, select, textarea": {
|
79
|
-
fontFamily: "inherit",
|
80
|
-
fontSize: "100%",
|
81
|
-
lineHeight: "1.15em"
|
82
|
-
}
|
83
|
-
}, T = {
|
84
|
-
externalModules: [],
|
85
|
-
rcFile: void 0,
|
86
|
-
destDir: void 0
|
87
|
-
}, ot = (t) => {
|
88
|
-
if (T.externalModules.length > 0) return T.externalModules;
|
89
|
-
const s = M(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
90
|
-
if (!s) return [];
|
91
|
-
const i = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
|
92
|
-
return T.externalModules = i, i;
|
93
|
-
}, O = async (t) => {
|
94
|
-
if (T.destDir) return T.destDir;
|
95
|
-
const e = await A(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
96
|
-
return T.destDir = s, s;
|
97
|
-
}, rt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...rt, ...t].join("|")})\\.`), Z = (t, e = []) => xt(e).test(t), at = async (t) => {
|
98
|
-
if (T.rcFile) return T.rcFile;
|
99
|
-
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
100
|
-
const e = r(t, ".saltyrc.json"), s = await tt(e, "utf-8").then(JSON.parse).catch(() => {
|
101
|
-
});
|
102
|
-
return s ? (T.rcFile = s, s) : at(r(t, ".."));
|
103
|
-
}, A = async (t) => {
|
104
|
-
var i, a;
|
105
|
-
const e = await at(t), s = (i = e.projects) == null ? void 0 : i.find((o) => t.endsWith(o.dir || ""));
|
106
|
-
return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
|
107
|
-
}, jt = async (t) => {
|
108
|
-
const e = await A(t), s = await O(t), i = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await st(t), $ = ot(i);
|
109
|
-
await Q.build({
|
110
|
-
entryPoints: [i],
|
111
|
-
minify: !0,
|
112
|
-
treeShaking: !0,
|
113
|
-
bundle: !0,
|
114
|
-
outfile: a,
|
115
|
-
format: o,
|
116
|
-
external: $
|
117
|
-
});
|
118
|
-
const u = Date.now(), { config: c } = await import(`${a}?t=${u}`);
|
119
|
-
return c;
|
120
|
-
}, kt = async (t) => {
|
121
|
-
const e = await jt(t), s = /* @__PURE__ */ new Set(), i = (f, g = []) => f ? Object.entries(f).flatMap(([h, p]) => {
|
122
|
-
if (!p) return;
|
123
|
-
if (typeof p == "object") return i(p, [...g, h]);
|
124
|
-
const _ = nt(h), v = H(h), D = [...g, _].join(".");
|
125
|
-
s.add(`"${D}"`);
|
126
|
-
const w = [...g.map(H), v].join("-"), { result: N } = $t(p);
|
127
|
-
return `--${w}: ${N};`;
|
128
|
-
}) : [], a = (f) => f ? Object.entries(f).flatMap(([g, h]) => {
|
129
|
-
const p = i(h);
|
130
|
-
return g === "base" ? p.join("") : `${g} { ${p.join("")} }`;
|
131
|
-
}) : [], o = (f) => f ? Object.entries(f).flatMap(([g, h]) => Object.entries(h).flatMap(([p, _]) => {
|
132
|
-
const v = i(_, [g]), D = `.${g}-${p}, [data-${g}="${p}"]`, w = v.join("");
|
133
|
-
return `${D} { ${w} }`;
|
134
|
-
})) : [], $ = i(e.variables), u = a(e.responsiveVariables), c = o(e.conditionalVariables), n = await O(t), d = r(n, "css/_variables.css"), m = `:root { ${$.join("")} ${u.join("")} } ${c.join("")}`;
|
135
|
-
S(d, m);
|
136
|
-
const C = r(n, "css/_global.css"), F = X(e.global, "");
|
137
|
-
S(C, `@layer global { ${F} }`);
|
138
|
-
const b = r(n, "css/_reset.css"), y = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : Ft, x = X(y, "");
|
139
|
-
S(b, `@layer reset { ${x} }`);
|
140
|
-
const l = r(n, "css/_templates.css"), j = yt(e.templates), E = ht(e.templates);
|
141
|
-
S(l, j);
|
142
|
-
const k = r(n, "types/css-tokens.d.ts"), P = `
|
143
|
-
// Variable types
|
144
|
-
type VariableTokens = ${[...s].join("|")};
|
145
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
146
|
-
|
147
|
-
// Template types
|
148
|
-
type TemplateTokens = {
|
149
|
-
${Object.entries(E).map(([f, g]) => `${f}?: ${g}`).join(`
|
150
|
-
`)}
|
151
|
-
}
|
152
|
-
`;
|
153
|
-
S(k, P);
|
154
|
-
}, Y = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
155
|
-
if (/^['"`]/.test(s)) return e;
|
156
|
-
const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
157
|
-
if (!a.test(t)) return e;
|
158
|
-
const $ = a.exec(t);
|
159
|
-
if ($) {
|
160
|
-
const u = $.at(1);
|
161
|
-
if (rt.some((n) => u == null ? void 0 : u.includes(n))) return e;
|
162
|
-
}
|
163
|
-
return "styled('div',";
|
164
|
-
}), G = async (t, e, s) => {
|
165
|
-
const i = z(e), a = r(s, "./temp");
|
166
|
-
L(a) || W(a);
|
167
|
-
const o = K(e);
|
168
|
-
let $ = M(e, "utf8");
|
169
|
-
$ = Y($);
|
170
|
-
const u = r(s, "js", i + ".js"), c = await A(t), n = r(t, (c == null ? void 0 : c.configDir) || "", "salty.config.ts"), d = ot(n), m = await st(t);
|
171
|
-
await Q.build({
|
172
|
-
stdin: {
|
173
|
-
contents: $,
|
174
|
-
sourcefile: o.base,
|
175
|
-
resolveDir: o.dir,
|
176
|
-
loader: "tsx"
|
177
|
-
},
|
178
|
-
minify: !1,
|
179
|
-
treeShaking: !0,
|
180
|
-
bundle: !0,
|
181
|
-
outfile: u,
|
182
|
-
format: m,
|
183
|
-
target: ["node20"],
|
184
|
-
keepNames: !0,
|
185
|
-
external: d,
|
186
|
-
packages: "external",
|
187
|
-
plugins: [
|
188
|
-
{
|
189
|
-
name: "test",
|
190
|
-
setup: (b) => {
|
191
|
-
b.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (V) => {
|
192
|
-
const y = M(V.path, "utf8");
|
193
|
-
return { contents: Y(y), loader: "ts" };
|
194
|
-
});
|
195
|
-
}
|
196
|
-
}
|
197
|
-
]
|
198
|
-
});
|
199
|
-
const C = Date.now();
|
200
|
-
return await import(`${u}?t=${C}`);
|
201
|
-
}, q = async (t) => {
|
202
|
-
const e = await O(t), s = r(e, "salty.config.js"), i = Date.now(), { config: a } = await import(`${s}?t=${i}`);
|
203
|
-
return a;
|
204
|
-
}, it = () => {
|
205
|
-
try {
|
206
|
-
return process.env.NODE_ENV === "production";
|
207
|
-
} catch {
|
208
|
-
return !1;
|
209
|
-
}
|
210
|
-
}, Rt = async (t, e = it()) => {
|
211
|
-
try {
|
212
|
-
const s = Date.now();
|
213
|
-
e ? I.info("Generating CSS in production mode! 🔥") : I.info("Generating CSS in development mode! 🚀");
|
214
|
-
const i = [], a = [], o = await O(t), $ = r(o, "index.css");
|
215
|
-
(() => {
|
216
|
-
L(o) && pt("rm -rf " + o), W(o, { recursive: !0 }), W(r(o, "css")), W(r(o, "types"));
|
217
|
-
})(), await kt(t);
|
218
|
-
const c = await q(t);
|
219
|
-
async function n(l, j) {
|
220
|
-
const E = ["node_modules", "saltygen"], k = ut(l);
|
221
|
-
if (k.isDirectory()) {
|
222
|
-
const R = gt(l);
|
223
|
-
if (E.some((f) => l.includes(f))) return;
|
224
|
-
await Promise.all(R.map((f) => n(r(l, f), r(j, f))));
|
225
|
-
} else if (k.isFile() && Z(l)) {
|
226
|
-
const P = await G(t, l, o), f = [];
|
227
|
-
Object.entries(P).forEach(([D, w]) => {
|
228
|
-
if (w.isKeyframes && w.css) {
|
229
|
-
const U = `a_${w.animationName}.css`, ft = `css/${U}`, dt = r(o, ft);
|
230
|
-
i.push(U), S(dt, w.css);
|
231
|
-
return;
|
232
|
-
}
|
233
|
-
if (!w.generator) return;
|
234
|
-
const N = w.generator._withBuildContext({
|
235
|
-
name: D,
|
236
|
-
config: c,
|
237
|
-
prod: e
|
238
|
-
});
|
239
|
-
a[N.priority] || (a[N.priority] = []), a[N.priority].push(N.cssFileName), f.push(N.cssFileName);
|
240
|
-
const ct = `css/${N.cssFileName}`, lt = r(o, ct);
|
241
|
-
S(lt, N.css);
|
242
|
-
});
|
243
|
-
const g = f.map((D) => `@import url('./${D}');`).join(`
|
244
|
-
`), h = z(l, 6), p = K(l), _ = H(p.name), v = r(o, `css/f_${_}-${h}.css`);
|
245
|
-
S(v, g);
|
246
|
-
}
|
247
|
-
}
|
248
|
-
await n(t, o);
|
249
|
-
const d = i.map((l) => `@import url('./css/${l}');`).join(`
|
250
|
-
`);
|
251
|
-
let b = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
252
|
-
|
253
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
254
|
-
try {
|
255
|
-
return M(r(o, "css", l), "utf8").length > 0;
|
256
|
-
} catch {
|
257
|
-
return !1;
|
258
|
-
}
|
259
|
-
}).map((l) => `@import url('./css/${l}');`).join(`
|
260
|
-
`)}
|
261
|
-
${d}`;
|
262
|
-
if (c.importStrategy !== "component") {
|
263
|
-
const l = a.reduce((j, E, k) => {
|
264
|
-
const R = E.reduce((h, p) => {
|
265
|
-
var w;
|
266
|
-
const _ = r(o, "css", p), v = M(_, "utf8"), D = ((w = /.*-([^-]+)-\d+.css/.exec(p)) == null ? void 0 : w.at(1)) || z(_, 6);
|
267
|
-
return h.includes(D) ? h : `${h}
|
268
|
-
/*start:${D}*/
|
269
|
-
${v}
|
270
|
-
/*end:${D}*/
|
271
|
-
`;
|
272
|
-
}, ""), P = `l_${k}.css`, f = r(o, "css", P), g = `@layer l${k} { ${R}
|
273
|
-
}`;
|
274
|
-
return S(f, g), `${j}
|
275
|
-
@import url('./css/${P}');`;
|
276
|
-
}, "");
|
277
|
-
b += l;
|
278
|
-
}
|
279
|
-
S($, b);
|
280
|
-
const y = Date.now() - s, x = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
|
281
|
-
I.info(`Generated CSS in ${y}ms! ${x}`);
|
282
|
-
} catch (s) {
|
283
|
-
console.error(s);
|
284
|
-
}
|
285
|
-
}, vt = async (t, e) => {
|
286
|
-
try {
|
287
|
-
const s = await O(t);
|
288
|
-
if (Z(e)) {
|
289
|
-
const a = [], o = await q(t), $ = await G(t, e, s);
|
290
|
-
Object.entries($).forEach(([u, c]) => {
|
291
|
-
if (c.isKeyframes && c.css) {
|
292
|
-
const F = `css/${`a_${c.animationName}.css`}`, b = r(s, F);
|
293
|
-
S(b, c.css);
|
294
|
-
return;
|
295
|
-
}
|
296
|
-
if (!c.generator) return;
|
297
|
-
const n = c.generator._withBuildContext({
|
298
|
-
name: u,
|
299
|
-
config: o
|
300
|
-
}), d = `css/${n.cssFileName}`, m = r(s, d);
|
301
|
-
S(m, n.css), a[n.priority] || (a[n.priority] = []), a[n.priority].push(n.cssFileName);
|
302
|
-
}), o.importStrategy !== "component" && a.forEach((u, c) => {
|
303
|
-
const n = `l_${c}.css`, d = r(s, "css", n);
|
304
|
-
let m = M(d, "utf8");
|
305
|
-
u.forEach((C) => {
|
306
|
-
var y;
|
307
|
-
const F = r(s, "css", C), b = ((y = /.*-([^-]+)-\d+.css/.exec(C)) == null ? void 0 : y.at(1)) || z(F, 6);
|
308
|
-
if (!m.includes(b)) {
|
309
|
-
const x = M(F, "utf8"), l = `/*start:${b}*/
|
310
|
-
${x}
|
311
|
-
/*end:${b}*/
|
312
|
-
`;
|
313
|
-
m = `${m.replace(/\}$/, "")}
|
314
|
-
${l}
|
315
|
-
}`;
|
316
|
-
}
|
317
|
-
}), S(d, m);
|
318
|
-
});
|
319
|
-
}
|
320
|
-
} catch (s) {
|
321
|
-
console.error(s);
|
322
|
-
}
|
323
|
-
}, Jt = async (t, e, s = it()) => {
|
324
|
-
try {
|
325
|
-
const i = await O(t);
|
326
|
-
if (Z(e)) {
|
327
|
-
const o = M(e, "utf8");
|
328
|
-
o.replace(/^(?!export\s)const\s.*/gm, (d) => `export ${d}`) !== o && await mt(e, o);
|
329
|
-
const u = await q(t), c = await G(t, e, i);
|
330
|
-
let n = o;
|
331
|
-
if (Object.entries(c).forEach(([d, m]) => {
|
332
|
-
var h;
|
333
|
-
if (m.isKeyframes || !m.generator) return;
|
334
|
-
const C = m.generator._withBuildContext({
|
335
|
-
name: d,
|
336
|
-
config: u,
|
337
|
-
prod: s
|
338
|
-
}), F = new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
|
339
|
-
if (!F) return console.error("Could not find the original declaration");
|
340
|
-
const b = (h = F.at(1)) == null ? void 0 : h.trim(), V = new RegExp(`\\s${d}[=\\s]+styled\\(`, "g").exec(n);
|
341
|
-
if (!V) return console.error("Could not find the original declaration");
|
342
|
-
const { index: y } = V;
|
343
|
-
let x = !1;
|
344
|
-
const l = setTimeout(() => x = !0, 5e3);
|
345
|
-
let j = 0, E = !1, k = 0;
|
346
|
-
for (; !E && !x; ) {
|
347
|
-
const p = n[y + j];
|
348
|
-
p === "(" && k++, p === ")" && k--, k === 0 && p === ")" && (E = !0), j > n.length && (x = !0), j++;
|
349
|
-
}
|
350
|
-
if (!x) clearTimeout(l);
|
351
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
352
|
-
const R = y + j, P = n.slice(y, R), f = n, g = ` ${d} = styled(${b}, "${C.classNames}", ${JSON.stringify(C.props)});`;
|
353
|
-
n = n.replace(P, g), f === n && console.error("Minimize file failed to change content", { name: d, tagName: b });
|
354
|
-
}), u.importStrategy === "component") {
|
355
|
-
const d = z(e, 6), m = K(e);
|
356
|
-
n = `import '../../saltygen/css/${`f_${H(m.name)}-${d}.css`}';
|
357
|
-
${n}`;
|
358
|
-
}
|
359
|
-
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
360
|
-
}
|
361
|
-
} catch (i) {
|
362
|
-
console.error("Error in minimizeFile:", i);
|
363
|
-
}
|
364
|
-
};
|
365
|
-
export {
|
366
|
-
Vt as a,
|
367
|
-
xt as b,
|
368
|
-
kt as c,
|
369
|
-
G as d,
|
370
|
-
vt as e,
|
371
|
-
Rt as g,
|
372
|
-
Z as i,
|
373
|
-
I as l,
|
374
|
-
Jt as m,
|
375
|
-
rt as s
|
376
|
-
};
|
@@ -1,97 +0,0 @@
|
|
1
|
-
import { d as l } from "./dash-case-DBThphLm.js";
|
2
|
-
const W = (t, s) => {
|
3
|
-
if (typeof t != "string") return { result: t };
|
4
|
-
if (!s) return { result: t };
|
5
|
-
const r = [];
|
6
|
-
return Object.values(s).forEach((n) => {
|
7
|
-
const { pattern: o, transform: p } = n;
|
8
|
-
t = t.replace(o, (i) => {
|
9
|
-
const { value: d, css: e } = p(i);
|
10
|
-
return e && r.push(e), d;
|
11
|
-
});
|
12
|
-
}), { result: t, additionalCss: r };
|
13
|
-
}, N = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${l(n[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, s, r) => {
|
14
|
-
if (!t) return "";
|
15
|
-
const n = [], o = Object.entries(t).reduce((i, [d, e]) => {
|
16
|
-
const c = d.trim();
|
17
|
-
if (typeof e == "function" && (e = e()), typeof e == "object") {
|
18
|
-
if (!e) return i;
|
19
|
-
if (c === "variants")
|
20
|
-
return Object.entries(e).forEach(([f, u]) => {
|
21
|
-
u && Object.entries(u).forEach(([y, j]) => {
|
22
|
-
if (!j) return;
|
23
|
-
const b = `${s}.${f}-${y}`, m = a(j, b, r);
|
24
|
-
n.push(m);
|
25
|
-
});
|
26
|
-
}), i;
|
27
|
-
if (c === "defaultVariants")
|
28
|
-
return i;
|
29
|
-
if (c === "compoundVariants")
|
30
|
-
return e.forEach((f) => {
|
31
|
-
const { css: u, ...y } = f, j = Object.entries(y).reduce((m, [k, w]) => `${m}.${k}-${w}`, s), b = a(u, j, r);
|
32
|
-
n.push(b);
|
33
|
-
}), i;
|
34
|
-
if (c.startsWith("@")) {
|
35
|
-
const f = a(e, s, r), u = `${c} {
|
36
|
-
${f.replace(`
|
37
|
-
`, `
|
38
|
-
`)}
|
39
|
-
}`;
|
40
|
-
return n.push(u), i;
|
41
|
-
}
|
42
|
-
const $ = d.includes("&") ? c.replace("&", s) : c.startsWith(":") ? `${s}${c}` : `${s} ${c}`, h = a(e, $, r);
|
43
|
-
return n.push(h), i;
|
44
|
-
}
|
45
|
-
if (r != null && r.templates && r.templates[c]) {
|
46
|
-
const h = e.split(".").reduce((f, u) => f[u], r.templates[c]);
|
47
|
-
if (h) {
|
48
|
-
const f = a(h, "");
|
49
|
-
return `${i}${f}`;
|
50
|
-
}
|
51
|
-
return console.warn(`Template "${c}" with path of "${e}" was not found in config!`), i;
|
52
|
-
}
|
53
|
-
const S = c.startsWith("-") ? c : l(c), O = ($, h = ";") => i = `${i}${$}${h}`, T = ($) => O(`${S}:${$}`);
|
54
|
-
if (typeof e == "number") return T(e);
|
55
|
-
if (typeof e != "string")
|
56
|
-
if ("toString" in e) e = e.toString();
|
57
|
-
else return i;
|
58
|
-
const { modifiers: V } = r || {}, g = function* () {
|
59
|
-
yield N(e), yield W(e, V);
|
60
|
-
}();
|
61
|
-
for (const { result: $, additionalCss: h = [] } of g)
|
62
|
-
e = $, h.forEach((f) => {
|
63
|
-
const u = a(f, "");
|
64
|
-
O(u, "");
|
65
|
-
});
|
66
|
-
return T(e);
|
67
|
-
}, "");
|
68
|
-
return o ? s ? [`${s} { ${o} }`, ...n].join(`
|
69
|
-
`) : o : n.join(`
|
70
|
-
`);
|
71
|
-
}, P = (t, s = []) => {
|
72
|
-
if (!t) return "";
|
73
|
-
const r = [], n = {};
|
74
|
-
if (Object.entries(t).forEach(([o, p]) => {
|
75
|
-
if (typeof p == "object") {
|
76
|
-
if (!p) return;
|
77
|
-
const i = o.trim(), d = P(p, [...s, i]);
|
78
|
-
r.push(d);
|
79
|
-
} else
|
80
|
-
n[o] = p;
|
81
|
-
}), Object.keys(n).length) {
|
82
|
-
const o = s.map(l).join("-"), p = a(n, `.${o}`);
|
83
|
-
r.push(p);
|
84
|
-
}
|
85
|
-
return r.join(`
|
86
|
-
`);
|
87
|
-
}, x = (t) => Object.keys(t), A = (t) => Object.entries(t).reduce((s, [r, n]) => (typeof n == "object" && (s[r] = E(n).map((o) => `"${o}"`).join(" | ")), s), {}), E = (t, s = "", r = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
88
|
-
const p = s ? `${s}.${n}` : n;
|
89
|
-
return typeof o == "object" ? E(o, p, r) : r.add(s);
|
90
|
-
}), [...r]) : [];
|
91
|
-
export {
|
92
|
-
P as a,
|
93
|
-
A as b,
|
94
|
-
N as c,
|
95
|
-
x as g,
|
96
|
-
a as p
|
97
|
-
};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";const b=require("./dash-case-BJEkFEGQ.cjs"),K=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,i=>{const{value:d,css:r}=p(i);return r&&e.push(r),d})}),{result:t,additionalCss:e}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${b.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},h=(t,s,e)=>{if(!t)return"";const n=[],o=Object.entries(t).reduce((i,[d,r])=>{const c=d.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(c==="variants")return Object.entries(r).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,y])=>{if(!y)return;const j=`${s}.${f}-${l}`,m=h(y,j,e);n.push(m)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(f=>{const{css:u,...l}=f,y=Object.entries(l).reduce((m,[W,q])=>`${m}.${W}-${q}`,s),j=h(u,y,e);n.push(j)}),i;if(c.startsWith("@")){const f=h(r,s,e),u=`${c} {
|
2
|
-
${f.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return n.push(u),i}const a=d.includes("&")?c.replace("&",s):c.startsWith(":")?`${s}${c}`:`${s} ${c}`,$=h(r,a,e);return n.push($),i}if(e!=null&&e.templates&&e.templates[c]){const $=r.split(".").reduce((f,u)=>f[u],e.templates[c]);if($){const f=h($,"");return`${i}${f}`}return console.warn(`Template "${c}" with path of "${r}" was not found in config!`),i}const g=c.startsWith("-")?c:b.dashCase(c),T=(a,$=";")=>i=`${i}${a}${$}`,O=a=>T(`${g}:${a}`);if(typeof r=="number")return O(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:k}=e||{},w=function*(){yield S(r),yield K(r,k)}();for(const{result:a,additionalCss:$=[]}of w)r=a,$.forEach(f=>{const u=h(f,"");T(u,"")});return O(r)},"");return o?s?[`${s} { ${o} }`,...n].join(`
|
6
|
-
`):o:n.join(`
|
7
|
-
`)},E=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const i=o.trim(),d=E(p,[...s,i]);e.push(d)}else n[o]=p}),Object.keys(n).length){const o=s.map(b.dashCase).join("-"),p=h(n,`.${o}`);e.push(p)}return e.join(`
|
8
|
-
`)},N=t=>Object.keys(t),P=t=>Object.entries(t).reduce((s,[e,n])=>(typeof n=="object"&&(s[e]=V(n).map(o=>`"${o}"`).join(" | ")),s),{}),V=(t,s="",e=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const p=s?`${s}.${n}`:n;return typeof o=="object"?V(o,p,e):e.add(s)}),[...e]):[];exports.getTemplateKeys=N;exports.getTemplateTypes=P;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=S;
|
File without changes
|