@salty-css/core 0.0.1-alpha.217 → 0.0.1-alpha.219
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/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +1 -1
- package/index-CNuRN2e-.cjs +38 -0
- package/index-ClF7lS_W.js +502 -0
- package/package.json +1 -1
- package/parse-styles-3N79AOBO.cjs +5 -0
- package/parse-styles-Bo7fQ_SV.js +134 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/index-B6M9WK93.cjs +0 -38
- package/index-B_bv7TCc.js +0 -503
- package/parse-styles-C6OYNcYI.cjs +0 -5
- package/parse-styles-Cc_Ir3PV.js +0 -132
package/index-B6M9WK93.cjs
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";const xe=require("esbuild"),Pe=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),c=require("fs"),oe=require("fs/promises"),Y=require("./parse-styles-C6OYNcYI.cjs"),G=require("winston"),M=require("./css/merge.cjs"),Ne=require("./define-templates-Cunsb_Tr.cjs");var ne=typeof document<"u"?document.currentScript:null;function ke(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pe=ke(xe),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const a=o.trim(),S=await ye(i,[...t,a]);s.push(S)}else n[o]=i;if(Object.keys(n).length){const o=t.map(_.dashCase).join("-"),i="t_"+_.toHash(o,4),a=await Y.parseAndJoinStyles(n,`.${o}, .${i}`);s.push(a)}return s.join(`
|
2
|
-
`)},_e=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?me(o,i,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return c.existsSync(t)?t:ge(r.join(e,".."))},De=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await De(e);if(t)return t.type};let z;const he=async e=>{if(z)return z;const t=await Oe(e);return t==="module"?z="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-B6M9WK93.cjs",document.baseURI).href).endsWith(".cjs"))&&(z="cjs"),z||"esm"},K=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]}),Te=e=>{K.error(e)};function Se(e){return e?typeof e!="string"?Se(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 Ee={"*, *::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"}},V={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(V.externalModules.length>0)return V.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await ae(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),ee=(e,t=[])=>we(t).test(e),be=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(r.join(e,".."))},ae=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Re=async e=>{const t=await ae(e),s=await v(e),n=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=r.join(s,"salty.config.js"),i=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:a});const S=Date.now(),{config:j}=await import(`${o}?t=${S}`);return{config:j,path:o}},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await L(e,m,s);Object.entries(b).forEach(([P,O])=>{O.isMedia?n.mediaQueries.push([P,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${P};;${R}`))})}));const{config:o,path:i}=await Re(e),a={...o},S=new Set,j=(m,b=[])=>m?Object.entries(m).flatMap(([R,P])=>{if(!P)return;if(typeof P=="object")return j(P,[...b,R]);const O=Se(R),te=_.dashCase(R),se=[...b,O].join(".");S.add(`"${se}"`);const X=[...b.map(_.dashCase),te].join("-"),ue=Y.parseVariableTokens(P);return ue?`--${X}: ${ue.transformed};`:`--${X}: ${P};`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>{const P=j(R);return b==="base"?P.join(""):`${b} { ${P.join("")} }`}):[],d=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([P,O])=>{const te=j(O,[b]),se=`.${b}-${P}, [data-${b}="${P}"]`,X=te.join("");return`${se} { ${X} }`})):[],w=m=>({...m,responsive:void 0,conditional:void 0}),p=m=>n.variables.map(b=>m==="static"?w(b._current):b._current[m]),g=M.mergeObjects(w(o.variables),p("static")),h=j(g),C=M.mergeObjects((le=o.variables)==null?void 0:le.responsive,p("responsive")),N=l(C),k=M.mergeObjects((fe=o.variables)==null?void 0:fe.conditional,p("conditional")),J=d(k),T=r.join(s,"css/_variables.css"),H=`:root { ${h.join("")} ${N.join("")} } ${J.join("")}`;c.writeFileSync(T,H),a.staticVariables=g;const D=r.join(s,"css/_global.css"),q=M.mergeObjects(o.global,n.globalStyles),f=await Y.parseAndJoinStyles(q,"");c.writeFileSync(D,`@layer global { ${f} }`);const y=r.join(s,"css/_reset.css"),u=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ee,F=await Y.parseAndJoinStyles(u,"");c.writeFileSync(y,`@layer reset { ${F} }`);const x=r.join(s,"css/_templates.css"),E=M.mergeObjects(o.templates,n.templates),I=await ye(E),W=_e(E);c.writeFileSync(x,`@layer templates { ${I} }`),a.templates=E;const A=o.templates?[Ne.defineTemplates(o.templates)._setPath(`config;;${i}`)]:[],Q=M.mergeFactories(n.templates,A);a.templatePaths=Object.fromEntries(Object.entries(Q).map(([m,b])=>[m,b._path]));const{mediaQueries:Z}=n;a.mediaQueries=Object.fromEntries(Z.map(([m,b])=>[`@${m}`,b]));const B=Z.map(([m])=>`'@${m}'`).join(" | "),U=r.join(s,"types/css-tokens.d.ts"),Fe=`
|
3
|
-
// Variable types
|
4
|
-
type VariableTokens = ${[...S].join("|")};
|
5
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
6
|
-
|
7
|
-
// Template types
|
8
|
-
type TemplateTokens = {
|
9
|
-
${Object.entries(W).map(([m,b])=>`${m}?: ${b}`).join(`
|
10
|
-
`)}
|
11
|
-
}
|
12
|
-
|
13
|
-
// Media query types
|
14
|
-
type MediaQueryKeys = ${B||"''"};
|
15
|
-
`;c.writeFileSync(U,Fe);const Ce=r.join(s,"cache/config-cache.json");c.writeFileSync(Ce,JSON.stringify(a,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const a=o.exec(e);if(a){const S=a.at(1);if(ie.some(l=>S==null?void 0:S.includes(l)))return t}return"styled('div',"}),Ve=(e,t)=>{try{const s=c.readFileSync(r.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
16
|
-
|
17
|
-
${e}`:`globalThis.saltyConfig = {};
|
18
|
-
|
19
|
-
${e}`}catch{return e}},L=async(e,t,s)=>{const n=_.toHash(t),o=r.join(s,"./temp");c.existsSync(o)||c.mkdirSync(o);const i=r.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Ve(a,e);const S=r.join(s,"js",n+".js"),j=await ae(e),l=r.join(e,(j==null?void 0:j.configDir)||"","salty.config.ts"),d=je(l),w=await he(e);await pe.build({stdin:{contents:a,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:w,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const N=c.readFileSync(C.path,"utf8");return{contents:de(N),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${S}?t=${p}`),outputFilePath:S}},Me=async e=>{const t=await v(e),s=r.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},re=async e=>{const t=await Me(e),s=await v(e),n=r.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return M.mergeObjects(i,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ve=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?K.info("Generating CSS in production mode! 🔥"):K.info("Generating CSS in development mode! 🚀");const o=[],i=[],a=await v(e),S=r.join(a,"index.css");s&&(()=>{c.existsSync(a)&&Pe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(r.join(a,"css")),c.mkdirSync(r.join(a,"types")),c.mkdirSync(r.join(a,"js")),c.mkdirSync(r.join(a,"cache"))})();const l=new Set,d=new Set;async function w(f){const y=["node_modules","saltygen"],$=c.statSync(f);if($.isDirectory()){const u=c.readdirSync(f);if(y.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>w(r.join(f,x))))}else if($.isFile()&&ee(f)){l.add(f);const F=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&d.add(f)}}await w(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:y}=await L(e,f,a);Object.entries(y).forEach(([$,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:$}):u.isClassName?p.classNames.push({...u,src:f,name:$}):u.generator&&p.components.push({...u,src:f,name:$})})}));const g=await re(e);for(const f of p.keyframes){const{value:y}=f,$=`a_${y.animationName}.css`,u=`css/${$}`,F=r.join(a,u);o.push($),c.writeFileSync(F,y.css)}const h={};for(const f of p.components){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g});i[u.priority]||(i[u.priority]=[]);const F=await u.css;if(!F)continue;i[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}for(const f of p.classNames){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g}),F=await u.css;if(!F)continue;i[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}g.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const $=y.map(I=>`@import url('./${I}');`).join(`
|
20
|
-
`),u=_.toHash(f,6),F=r.parse(f),x=_.dashCase(F.name),E=r.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(E,$||"/* Empty file */")});const C=o.map(f=>`@import url('./css/${f}');`).join(`
|
21
|
-
`);let T=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
22
|
-
|
23
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return c.readFileSync(r.join(a,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
24
|
-
`)}
|
25
|
-
${C}`;if(g.importStrategy!=="component"){const f=i.reduce((y,$,u)=>{const F=$.reduce((W,A)=>{var U;const Q=r.join(a,"css",A),Z=c.readFileSync(Q,"utf8"),B=((U=/.*-([^-]+)-\d+.css/.exec(A))==null?void 0:U.at(1))||_.toHash(Q,6);return W.includes(B)?W:`${W}
|
26
|
-
/*start:${B}-${A}*/
|
27
|
-
${Z}
|
28
|
-
/*end:${B}*/
|
29
|
-
`},""),x=`l_${u}.css`,E=r.join(a,"css",x),I=`@layer l${u} { ${F}
|
30
|
-
}`;return c.writeFileSync(E,I),`${y}
|
31
|
-
@import url('./css/${x}');`},"");T+=f}c.writeFileSync(S,T);const D=Date.now()-n,q=D<200?"🔥":D<500?"🚀":D<1e3?"🎉":D<2e3?"🚗":D<5e3?"🤔":"🥴";K.info(`Generated CSS in ${D}ms! ${q}`)}catch(n){console.error(n)}},Je=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const i=[],a=await re(e),{contents:S}=await L(e,t,n);for(const[j,l]of Object.entries(S)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,N=r.join(n,C);c.writeFileSync(N,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),C=await h.css;if(!C)continue;i[0].push(h.cssFileName);const N=`css/${h.cssFileName}`,k=r.join(n,N);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),w=await d.css;if(!w)continue;const p=`css/${d.cssFileName}`,g=r.join(n,p);c.writeFileSync(g,w),i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")i.forEach((j,l)=>{const d=`l_${l}.css`,w=r.join(n,"css",d);let p=c.readFileSync(w,"utf8");j.forEach(g=>{var k;const h=r.join(n,"css",g),C=((k=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:k.at(1))||_.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),T=`/*start:${C}-${g}*/
|
32
|
-
${J}
|
33
|
-
/*end:${C}*/
|
34
|
-
`;p=`${p.replace(/\}$/,"")}
|
35
|
-
${T}
|
36
|
-
}`}}),c.writeFileSync(w,p)});else{const j=i.flat().map(g=>`@import url('./${g}');`).join(`
|
37
|
-
`),l=_.toHash(t,6),d=r.parse(t),w=_.dashCase(d.name),p=r.join(n,`css/f_${w}-${l}.css`);c.writeFileSync(p,j||"/* Empty file */")}}}catch(n){console.error(n)}},ze=async(e,t,s=ce())=>{try{const n=await v(e);if(ee(t)){const i=c.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==i&&await oe.writeFile(t,i);const S=await re(e),{contents:j}=await L(e,t,n);let l=i;if(Object.entries(j).forEach(([d,w])=>{var u;if(w.isKeyframes||!w.generator)return;const p=w.generator._withBuildContext({callerName:d,isProduction:s,config:S}),g=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!g)return console.error("Could not find the original declaration");const h=(u=g.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:N}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let T=0,H=!1,D=0;for(;!H&&!k;){const F=l[N+T];F==="("&&D++,F===")"&&D--,D===0&&F===")"&&(H=!0),T>l.length&&(k=!0),T++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const q=N+T,f=l.slice(N,q),y=l,$=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,$),y===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),S.importStrategy==="component"){const d=_.toHash(t,6),w=r.parse(t);l=`import '../../saltygen/css/${`f_${_.dashCase(w.name)}-${d}.css`}';
|
38
|
-
${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=L;exports.generateConfigStyles=$e;exports.generateCss=ve;exports.generateFile=Je;exports.isSaltyFile=ee;exports.logError=Te;exports.logger=K;exports.minimizeFile=ze;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;
|
package/index-B_bv7TCc.js
DELETED
@@ -1,503 +0,0 @@
|
|
1
|
-
import * as gt from "esbuild";
|
2
|
-
import { execSync as Pt } from "child_process";
|
3
|
-
import { d as B, t as v } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as r, parse as tt } from "path";
|
5
|
-
import { existsSync as it, writeFileSync as F, mkdirSync as W, readFileSync as O, statSync as kt, readdirSync as Dt } from "fs";
|
6
|
-
import { readFile as yt, writeFile as _t } from "fs/promises";
|
7
|
-
import { p as at, a as Tt } from "./parse-styles-Cc_Ir3PV.js";
|
8
|
-
import { createLogger as Et, format as ot, transports as Ot } from "winston";
|
9
|
-
import { mergeObjects as I, mergeFactories as Vt } from "./css/merge.js";
|
10
|
-
import { d as Mt } from "./define-templates-4A2yHcMF.js";
|
11
|
-
const ht = async (t, e = []) => {
|
12
|
-
if (!t) return "";
|
13
|
-
const s = [], n = {};
|
14
|
-
for (const [o, a] of Object.entries(t))
|
15
|
-
if (typeof a != "function") if (a && typeof a == "object") {
|
16
|
-
const i = o.trim(), h = await ht(a, [...e, i]);
|
17
|
-
s.push(h);
|
18
|
-
} else
|
19
|
-
n[o] = a;
|
20
|
-
if (Object.keys(n).length) {
|
21
|
-
const o = e.map(B).join("-"), a = "t_" + v(o, 4), i = await at(n, `.${o}, .${a}`);
|
22
|
-
s.push(i);
|
23
|
-
}
|
24
|
-
return s.join(`
|
25
|
-
`);
|
26
|
-
}, vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
27
|
-
const a = e ? `${e}.${n}` : n;
|
28
|
-
return typeof o == "object" ? $t(o, a, s) : s.add(e);
|
29
|
-
}), [...s]) : [], bt = (t) => {
|
30
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
31
|
-
const e = r(t, "package.json");
|
32
|
-
return it(e) ? e : bt(r(t, ".."));
|
33
|
-
}, Rt = async (t) => {
|
34
|
-
const e = bt(t);
|
35
|
-
return await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
36
|
-
});
|
37
|
-
}, Jt = async (t) => {
|
38
|
-
const e = await Rt(t);
|
39
|
-
if (e)
|
40
|
-
return e.type;
|
41
|
-
};
|
42
|
-
let z;
|
43
|
-
const wt = async (t) => {
|
44
|
-
if (z) return z;
|
45
|
-
const e = await Jt(t);
|
46
|
-
return e === "module" ? z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (z = "cjs"), z || "esm";
|
47
|
-
}, Y = Et({
|
48
|
-
level: "debug",
|
49
|
-
format: ot.combine(ot.colorize(), ot.cli()),
|
50
|
-
transports: [new Ot.Console({})]
|
51
|
-
}), ee = (t) => {
|
52
|
-
Y.error(t);
|
53
|
-
};
|
54
|
-
function St(t) {
|
55
|
-
return t ? typeof t != "string" ? St(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
56
|
-
}
|
57
|
-
const zt = {
|
58
|
-
/** Set box model to border-box */
|
59
|
-
"*, *::before, *::after": {
|
60
|
-
boxSizing: "border-box"
|
61
|
-
},
|
62
|
-
/** Remove default margin and padding */
|
63
|
-
"*": {
|
64
|
-
margin: 0
|
65
|
-
},
|
66
|
-
/** Remove adjust font properties */
|
67
|
-
html: {
|
68
|
-
lineHeight: 1.15,
|
69
|
-
textSizeAdjust: "100%",
|
70
|
-
WebkitFontSmoothing: "antialiased"
|
71
|
-
},
|
72
|
-
/** Make media elements responsive */
|
73
|
-
"img, picture, video, canvas, svg": {
|
74
|
-
display: "block",
|
75
|
-
maxWidth: "100%"
|
76
|
-
},
|
77
|
-
/** Avoid overflow of text */
|
78
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
79
|
-
overflowWrap: "break-word"
|
80
|
-
},
|
81
|
-
/** Improve text wrapping */
|
82
|
-
p: {
|
83
|
-
textWrap: "pretty"
|
84
|
-
},
|
85
|
-
"h1, h2, h3, h4, h5, h6": {
|
86
|
-
textWrap: "balance"
|
87
|
-
},
|
88
|
-
/** Improve link color */
|
89
|
-
a: {
|
90
|
-
color: "currentColor"
|
91
|
-
},
|
92
|
-
/** Improve button line height */
|
93
|
-
button: {
|
94
|
-
lineHeight: "1em",
|
95
|
-
color: "currentColor"
|
96
|
-
},
|
97
|
-
/** Improve form elements */
|
98
|
-
"input, optgroup, select, textarea": {
|
99
|
-
fontFamily: "inherit",
|
100
|
-
fontSize: "100%",
|
101
|
-
lineHeight: "1.15em"
|
102
|
-
}
|
103
|
-
}, M = {
|
104
|
-
externalModules: [],
|
105
|
-
rcFile: void 0,
|
106
|
-
destDir: void 0
|
107
|
-
}, Ct = (t) => {
|
108
|
-
if (M.externalModules.length > 0) return M.externalModules;
|
109
|
-
const s = O(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
110
|
-
if (!s) return [];
|
111
|
-
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
112
|
-
return M.externalModules = n, n;
|
113
|
-
}, R = async (t) => {
|
114
|
-
if (M.destDir) return M.destDir;
|
115
|
-
const e = await ct(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
116
|
-
return M.destDir = s, s;
|
117
|
-
}, jt = ["salty", "css", "styles", "styled"], Wt = (t = []) => new RegExp(`\\.(${[...jt, ...t].join("|")})\\.`), rt = (t, e = []) => Wt(e).test(t), Ft = async (t) => {
|
118
|
-
if (M.rcFile) return M.rcFile;
|
119
|
-
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
120
|
-
const e = r(t, ".saltyrc.json"), s = await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
121
|
-
});
|
122
|
-
return s ? (M.rcFile = s, s) : Ft(r(t, ".."));
|
123
|
-
}, ct = async (t) => {
|
124
|
-
var n, o;
|
125
|
-
const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
|
126
|
-
return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
|
127
|
-
}, It = async (t) => {
|
128
|
-
const e = await ct(t), s = await R(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = r(s, "salty.config.js"), a = await wt(t), i = Ct(n);
|
129
|
-
await gt.build({
|
130
|
-
entryPoints: [n],
|
131
|
-
minify: !0,
|
132
|
-
treeShaking: !0,
|
133
|
-
bundle: !0,
|
134
|
-
outfile: o,
|
135
|
-
format: a,
|
136
|
-
external: i
|
137
|
-
});
|
138
|
-
const h = Date.now(), { config: $ } = await import(`${o}?t=${h}`);
|
139
|
-
return { config: $, path: o };
|
140
|
-
}, Bt = async (t, e) => {
|
141
|
-
var pt, ut;
|
142
|
-
const s = await R(t), n = {
|
143
|
-
mediaQueries: [],
|
144
|
-
globalStyles: [],
|
145
|
-
variables: [],
|
146
|
-
templates: []
|
147
|
-
};
|
148
|
-
await Promise.all(
|
149
|
-
[...e].map(async (m) => {
|
150
|
-
const { contents: w, outputFilePath: V } = await et(t, m, s);
|
151
|
-
Object.entries(w).forEach(([N, _]) => {
|
152
|
-
_.isMedia ? n.mediaQueries.push([N, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${N};;${V}`));
|
153
|
-
});
|
154
|
-
})
|
155
|
-
);
|
156
|
-
const { config: o, path: a } = await It(t), i = { ...o }, h = /* @__PURE__ */ new Set(), $ = (m, w = []) => m ? Object.entries(m).flatMap(([V, N]) => {
|
157
|
-
if (!N) return;
|
158
|
-
if (typeof N == "object") return $(N, [...w, V]);
|
159
|
-
const _ = St(V), st = B(V), nt = [...w, _].join(".");
|
160
|
-
h.add(`"${nt}"`);
|
161
|
-
const X = [...w.map(B), st].join("-"), dt = Tt(N);
|
162
|
-
return dt ? `--${X}: ${dt.transformed};` : `--${X}: ${N};`;
|
163
|
-
}) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => {
|
164
|
-
const N = $(V);
|
165
|
-
return w === "base" ? N.join("") : `${w} { ${N.join("")} }`;
|
166
|
-
}) : [], p = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
|
167
|
-
const st = $(_, [w]), nt = `.${w}-${N}, [data-${w}="${N}"]`, X = st.join("");
|
168
|
-
return `${nt} { ${X} }`;
|
169
|
-
})) : [], b = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), u = (m) => n.variables.map((w) => m === "static" ? b(w._current) : w._current[m]), g = I(b(o.variables), u("static")), y = $(g), j = I((pt = o.variables) == null ? void 0 : pt.responsive, u("responsive")), P = c(j), k = I((ut = o.variables) == null ? void 0 : ut.conditional, u("conditional")), J = p(k), T = r(s, "css/_variables.css"), G = `:root { ${y.join("")} ${P.join("")} } ${J.join("")}`;
|
170
|
-
F(T, G), i.staticVariables = g;
|
171
|
-
const D = r(s, "css/_global.css"), H = I(o.global, n.globalStyles), l = await at(H, "");
|
172
|
-
F(D, `@layer global { ${l} }`);
|
173
|
-
const d = r(s, "css/_reset.css"), f = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : zt, C = await at(f, "");
|
174
|
-
F(d, `@layer reset { ${C} }`);
|
175
|
-
const x = r(s, "css/_templates.css"), E = I(o.templates, n.templates), K = await ht(E), A = vt(E);
|
176
|
-
F(x, `@layer templates { ${K} }`), i.templates = E;
|
177
|
-
const L = o.templates ? [Mt(o.templates)._setPath(`config;;${a}`)] : [], Z = Vt(n.templates, L);
|
178
|
-
i.templatePaths = Object.fromEntries(Object.entries(Z).map(([m, w]) => [m, w._path]));
|
179
|
-
const { mediaQueries: q } = n;
|
180
|
-
i.mediaQueries = Object.fromEntries(q.map(([m, w]) => [`@${m}`, w]));
|
181
|
-
const Q = q.map(([m]) => `'@${m}'`).join(" | "), U = r(s, "types/css-tokens.d.ts"), xt = `
|
182
|
-
// Variable types
|
183
|
-
type VariableTokens = ${[...h].join("|")};
|
184
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
185
|
-
|
186
|
-
// Template types
|
187
|
-
type TemplateTokens = {
|
188
|
-
${Object.entries(A).map(([m, w]) => `${m}?: ${w}`).join(`
|
189
|
-
`)}
|
190
|
-
}
|
191
|
-
|
192
|
-
// Media query types
|
193
|
-
type MediaQueryKeys = ${Q || "''"};
|
194
|
-
`;
|
195
|
-
F(U, xt);
|
196
|
-
const Nt = r(s, "cache/config-cache.json");
|
197
|
-
F(Nt, JSON.stringify(i, null, 2));
|
198
|
-
}, mt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
199
|
-
if (/^['"`]/.test(s)) return e;
|
200
|
-
const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
201
|
-
if (!o.test(t)) return e;
|
202
|
-
const i = o.exec(t);
|
203
|
-
if (i) {
|
204
|
-
const h = i.at(1);
|
205
|
-
if (jt.some((c) => h == null ? void 0 : h.includes(c))) return e;
|
206
|
-
}
|
207
|
-
return "styled('div',";
|
208
|
-
}), Gt = (t, e) => {
|
209
|
-
try {
|
210
|
-
const s = O(r(e, "saltygen/cache/config-cache.json"), "utf8");
|
211
|
-
return s ? `globalThis.saltyConfig = ${s};
|
212
|
-
|
213
|
-
${t}` : `globalThis.saltyConfig = {};
|
214
|
-
|
215
|
-
${t}`;
|
216
|
-
} catch {
|
217
|
-
return t;
|
218
|
-
}
|
219
|
-
}, et = async (t, e, s) => {
|
220
|
-
const n = v(e), o = r(s, "./temp");
|
221
|
-
it(o) || W(o);
|
222
|
-
const a = tt(e);
|
223
|
-
let i = O(e, "utf8");
|
224
|
-
i = mt(i), i = Gt(i, t);
|
225
|
-
const h = r(s, "js", n + ".js"), $ = await ct(t), c = r(t, ($ == null ? void 0 : $.configDir) || "", "salty.config.ts"), p = Ct(c), b = await wt(t);
|
226
|
-
await gt.build({
|
227
|
-
stdin: {
|
228
|
-
contents: i,
|
229
|
-
sourcefile: a.base,
|
230
|
-
resolveDir: a.dir,
|
231
|
-
loader: "tsx"
|
232
|
-
},
|
233
|
-
minify: !1,
|
234
|
-
treeShaking: !0,
|
235
|
-
bundle: !0,
|
236
|
-
outfile: h,
|
237
|
-
format: b,
|
238
|
-
target: ["node20"],
|
239
|
-
keepNames: !0,
|
240
|
-
external: p,
|
241
|
-
packages: "external",
|
242
|
-
plugins: [
|
243
|
-
{
|
244
|
-
name: "test",
|
245
|
-
setup: (y) => {
|
246
|
-
y.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
|
247
|
-
const P = O(j.path, "utf8");
|
248
|
-
return { contents: mt(P), loader: "ts" };
|
249
|
-
});
|
250
|
-
}
|
251
|
-
}
|
252
|
-
]
|
253
|
-
});
|
254
|
-
const u = Date.now();
|
255
|
-
return { contents: await import(`${h}?t=${u}`), outputFilePath: h };
|
256
|
-
}, Ht = async (t) => {
|
257
|
-
const e = await R(t), s = r(e, "cache/config-cache.json"), n = O(s, "utf8");
|
258
|
-
if (!n) throw new Error("Could not find config cache file");
|
259
|
-
return JSON.parse(n);
|
260
|
-
}, lt = async (t) => {
|
261
|
-
const e = await Ht(t), s = await R(t), n = r(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
|
262
|
-
return I(a, e);
|
263
|
-
}, ft = () => {
|
264
|
-
try {
|
265
|
-
return process.env.NODE_ENV === "production";
|
266
|
-
} catch {
|
267
|
-
return !1;
|
268
|
-
}
|
269
|
-
}, se = async (t, e = ft(), s = !0) => {
|
270
|
-
try {
|
271
|
-
const n = Date.now();
|
272
|
-
e ? Y.info("Generating CSS in production mode! 🔥") : Y.info("Generating CSS in development mode! 🚀");
|
273
|
-
const o = [], a = [], i = await R(t), h = r(i, "index.css");
|
274
|
-
s && (() => {
|
275
|
-
it(i) && Pt("rm -rf " + i), W(i, { recursive: !0 }), W(r(i, "css")), W(r(i, "types")), W(r(i, "js")), W(r(i, "cache"));
|
276
|
-
})();
|
277
|
-
const c = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
|
278
|
-
async function b(l) {
|
279
|
-
const d = ["node_modules", "saltygen"], S = kt(l);
|
280
|
-
if (S.isDirectory()) {
|
281
|
-
const f = Dt(l);
|
282
|
-
if (d.some((x) => l.includes(x))) return;
|
283
|
-
await Promise.all(f.map((x) => b(r(l, x))));
|
284
|
-
} else if (S.isFile() && rt(l)) {
|
285
|
-
c.add(l);
|
286
|
-
const C = O(l, "utf8");
|
287
|
-
/define[\w\d]+\(/.test(C) && p.add(l);
|
288
|
-
}
|
289
|
-
}
|
290
|
-
await b(t), await Bt(t, p);
|
291
|
-
const u = {
|
292
|
-
keyframes: [],
|
293
|
-
components: [],
|
294
|
-
classNames: []
|
295
|
-
};
|
296
|
-
await Promise.all(
|
297
|
-
[...c].map(async (l) => {
|
298
|
-
const { contents: d } = await et(t, l, i);
|
299
|
-
Object.entries(d).forEach(([S, f]) => {
|
300
|
-
f.isKeyframes ? u.keyframes.push({
|
301
|
-
value: f,
|
302
|
-
src: l,
|
303
|
-
name: S
|
304
|
-
}) : f.isClassName ? u.classNames.push({
|
305
|
-
...f,
|
306
|
-
src: l,
|
307
|
-
name: S
|
308
|
-
}) : f.generator && u.components.push({
|
309
|
-
...f,
|
310
|
-
src: l,
|
311
|
-
name: S
|
312
|
-
});
|
313
|
-
});
|
314
|
-
})
|
315
|
-
);
|
316
|
-
const g = await lt(t);
|
317
|
-
for (const l of u.keyframes) {
|
318
|
-
const { value: d } = l, S = `a_${d.animationName}.css`, f = `css/${S}`, C = r(i, f);
|
319
|
-
o.push(S), F(C, d.css);
|
320
|
-
}
|
321
|
-
const y = {};
|
322
|
-
for (const l of u.components) {
|
323
|
-
const { src: d, name: S } = l;
|
324
|
-
y[d] || (y[d] = []);
|
325
|
-
const f = l.generator._withBuildContext({
|
326
|
-
callerName: S,
|
327
|
-
isProduction: e,
|
328
|
-
config: g
|
329
|
-
});
|
330
|
-
a[f.priority] || (a[f.priority] = []);
|
331
|
-
const C = await f.css;
|
332
|
-
if (!C) continue;
|
333
|
-
a[f.priority].push(f.cssFileName);
|
334
|
-
const x = `css/${f.cssFileName}`, E = r(i, x);
|
335
|
-
F(E, C), g.importStrategy === "component" && y[d].push(f.cssFileName);
|
336
|
-
}
|
337
|
-
for (const l of u.classNames) {
|
338
|
-
const { src: d, name: S } = l;
|
339
|
-
y[d] || (y[d] = []);
|
340
|
-
const f = l.generator._withBuildContext({
|
341
|
-
callerName: S,
|
342
|
-
isProduction: e,
|
343
|
-
config: g
|
344
|
-
}), C = await f.css;
|
345
|
-
if (!C) continue;
|
346
|
-
a[0].push(f.cssFileName);
|
347
|
-
const x = `css/${f.cssFileName}`, E = r(i, x);
|
348
|
-
F(E, C), g.importStrategy === "component" && y[d].push(f.cssFileName);
|
349
|
-
}
|
350
|
-
g.importStrategy === "component" && Object.entries(y).forEach(([l, d]) => {
|
351
|
-
const S = d.map((K) => `@import url('./${K}');`).join(`
|
352
|
-
`), f = v(l, 6), C = tt(l), x = B(C.name), E = r(i, `css/f_${x}-${f}.css`);
|
353
|
-
F(E, S || "/* Empty file */");
|
354
|
-
});
|
355
|
-
const j = o.map((l) => `@import url('./css/${l}');`).join(`
|
356
|
-
`);
|
357
|
-
let T = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
358
|
-
|
359
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
360
|
-
try {
|
361
|
-
return O(r(i, "css", l), "utf8").length > 0;
|
362
|
-
} catch {
|
363
|
-
return !1;
|
364
|
-
}
|
365
|
-
}).map((l) => `@import url('./css/${l}');`).join(`
|
366
|
-
`)}
|
367
|
-
${j}`;
|
368
|
-
if (g.importStrategy !== "component") {
|
369
|
-
const l = a.reduce((d, S, f) => {
|
370
|
-
const C = S.reduce((A, L) => {
|
371
|
-
var U;
|
372
|
-
const Z = r(i, "css", L), q = O(Z, "utf8"), Q = ((U = /.*-([^-]+)-\d+.css/.exec(L)) == null ? void 0 : U.at(1)) || v(Z, 6);
|
373
|
-
return A.includes(Q) ? A : `${A}
|
374
|
-
/*start:${Q}-${L}*/
|
375
|
-
${q}
|
376
|
-
/*end:${Q}*/
|
377
|
-
`;
|
378
|
-
}, ""), x = `l_${f}.css`, E = r(i, "css", x), K = `@layer l${f} { ${C}
|
379
|
-
}`;
|
380
|
-
return F(E, K), `${d}
|
381
|
-
@import url('./css/${x}');`;
|
382
|
-
}, "");
|
383
|
-
T += l;
|
384
|
-
}
|
385
|
-
F(h, T);
|
386
|
-
const D = Date.now() - n, H = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
|
387
|
-
Y.info(`Generated CSS in ${D}ms! ${H}`);
|
388
|
-
} catch (n) {
|
389
|
-
console.error(n);
|
390
|
-
}
|
391
|
-
}, ne = async (t, e, s = ft()) => {
|
392
|
-
try {
|
393
|
-
const n = await R(t);
|
394
|
-
if (rt(e)) {
|
395
|
-
const a = [], i = await lt(t), { contents: h } = await et(t, e, n);
|
396
|
-
for (const [$, c] of Object.entries(h)) {
|
397
|
-
if (c.isKeyframes && c.css) {
|
398
|
-
const j = `css/${`a_${c.animationName}.css`}`, P = r(n, j);
|
399
|
-
F(P, await c.css);
|
400
|
-
return;
|
401
|
-
}
|
402
|
-
if (c.isClassName) {
|
403
|
-
const y = c.generator._withBuildContext({
|
404
|
-
callerName: $,
|
405
|
-
isProduction: s,
|
406
|
-
config: i
|
407
|
-
}), j = await y.css;
|
408
|
-
if (!j) continue;
|
409
|
-
a[0].push(y.cssFileName);
|
410
|
-
const P = `css/${y.cssFileName}`, k = r(n, P);
|
411
|
-
F(k, j);
|
412
|
-
}
|
413
|
-
if (!c.generator) return;
|
414
|
-
const p = c.generator._withBuildContext({
|
415
|
-
callerName: $,
|
416
|
-
isProduction: s,
|
417
|
-
config: i
|
418
|
-
}), b = await p.css;
|
419
|
-
if (!b) continue;
|
420
|
-
const u = `css/${p.cssFileName}`, g = r(n, u);
|
421
|
-
F(g, b), a[p.priority] || (a[p.priority] = []), a[p.priority].push(p.cssFileName);
|
422
|
-
}
|
423
|
-
if (i.importStrategy !== "component")
|
424
|
-
a.forEach(($, c) => {
|
425
|
-
const p = `l_${c}.css`, b = r(n, "css", p);
|
426
|
-
let u = O(b, "utf8");
|
427
|
-
$.forEach((g) => {
|
428
|
-
var k;
|
429
|
-
const y = r(n, "css", g), j = ((k = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : k.at(1)) || v(y, 6);
|
430
|
-
if (!u.includes(j)) {
|
431
|
-
const J = O(y, "utf8"), T = `/*start:${j}-${g}*/
|
432
|
-
${J}
|
433
|
-
/*end:${j}*/
|
434
|
-
`;
|
435
|
-
u = `${u.replace(/\}$/, "")}
|
436
|
-
${T}
|
437
|
-
}`;
|
438
|
-
}
|
439
|
-
}), F(b, u);
|
440
|
-
});
|
441
|
-
else {
|
442
|
-
const $ = a.flat().map((g) => `@import url('./${g}');`).join(`
|
443
|
-
`), c = v(e, 6), p = tt(e), b = B(p.name), u = r(n, `css/f_${b}-${c}.css`);
|
444
|
-
F(u, $ || "/* Empty file */");
|
445
|
-
}
|
446
|
-
}
|
447
|
-
} catch (n) {
|
448
|
-
console.error(n);
|
449
|
-
}
|
450
|
-
}, oe = async (t, e, s = ft()) => {
|
451
|
-
try {
|
452
|
-
const n = await R(t);
|
453
|
-
if (rt(e)) {
|
454
|
-
const a = O(e, "utf8");
|
455
|
-
a.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== a && await _t(e, a);
|
456
|
-
const h = await lt(t), { contents: $ } = await et(t, e, n);
|
457
|
-
let c = a;
|
458
|
-
if (Object.entries($).forEach(([p, b]) => {
|
459
|
-
var f;
|
460
|
-
if (b.isKeyframes || !b.generator) return;
|
461
|
-
const u = b.generator._withBuildContext({
|
462
|
-
callerName: p,
|
463
|
-
isProduction: s,
|
464
|
-
config: h
|
465
|
-
}), g = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
|
466
|
-
if (!g) return console.error("Could not find the original declaration");
|
467
|
-
const y = (f = g.at(1)) == null ? void 0 : f.trim(), j = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(c);
|
468
|
-
if (!j) return console.error("Could not find the original declaration");
|
469
|
-
const { index: P } = j;
|
470
|
-
let k = !1;
|
471
|
-
const J = setTimeout(() => k = !0, 5e3);
|
472
|
-
let T = 0, G = !1, D = 0;
|
473
|
-
for (; !G && !k; ) {
|
474
|
-
const C = c[P + T];
|
475
|
-
C === "(" && D++, C === ")" && D--, D === 0 && C === ")" && (G = !0), T > c.length && (k = !0), T++;
|
476
|
-
}
|
477
|
-
if (!k) clearTimeout(J);
|
478
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
479
|
-
const H = P + T, l = c.slice(P, H), d = c, S = ` ${p} = styled(${y}, "${u.classNames}", ${JSON.stringify(u.clientProps)});`;
|
480
|
-
c = c.replace(l, S), d === c && console.error("Minimize file failed to change content", { name: p, tagName: y });
|
481
|
-
}), h.importStrategy === "component") {
|
482
|
-
const p = v(e, 6), b = tt(e);
|
483
|
-
c = `import '../../saltygen/css/${`f_${B(b.name)}-${p}.css`}';
|
484
|
-
${c}`;
|
485
|
-
}
|
486
|
-
return c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
487
|
-
}
|
488
|
-
} catch (n) {
|
489
|
-
console.error("Error in minimizeFile:", n);
|
490
|
-
}
|
491
|
-
};
|
492
|
-
export {
|
493
|
-
ee as a,
|
494
|
-
Wt as b,
|
495
|
-
Bt as c,
|
496
|
-
et as d,
|
497
|
-
ne as e,
|
498
|
-
se as g,
|
499
|
-
rt as i,
|
500
|
-
Y as l,
|
501
|
-
oe as m,
|
502
|
-
jt as s
|
503
|
-
};
|
@@ -1,5 +0,0 @@
|
|
1
|
-
"use strict";const A=require("./dash-case-BJEkFEGQ.cjs"),U=a=>e=>{if(typeof e!="string"||!a)return;let t=e;const p=[];return Object.values(a).forEach(n=>{const{pattern:P,transform:E}=n;t=t.replace(P,C=>{const{value:j,css:x}=E(C);return x&&p.push(x),j})}),{transformed:t,additionalCss:p}},N=a=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${A.dashCase(n[1].replaceAll(".","-"))})`)},q=N(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(a,e,t)=>{if(J.some(n=>typeof n=="string"?n===a:n.test(a))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=a=>a.startsWith("-")?a:Q.some(e=>a.startsWith(e))?`-${A.dashCase(a)}`:A.dashCase(a),$=async(a,e="",t,p=!1)=>{if(!a)throw new Error("No styles provided to parseStyles function!");const n=new Set,E=Object.entries(a).map(async([m,s])=>{var w;const r=m.trim(),y=_(r),u=(i,d=";")=>`${y}:${i}${d}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templatePaths[r])try{const[i,d]=t.templatePaths[r].split(";;"),o=await import(d),c=d.includes("salty.config"),f=c?o[i].templates:o[i],h=c?f[r]:f.params[r];if(f&&typeof h=="function"){const b=await h(s),[l]=await $(b,"");return l}}catch(i){console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`,i);return}if(t!=null&&t.templates&&t.templates[r]){if(p)return;const d=s.split(".").reduce((o,c)=>o[c],t.templates[r]);if(d){const[o]=await $(d,"");return o}console.warn(`Template "${r}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return u(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const o=Object.entries(s);for(const[c,f]of o){if(!f)return;const h=Object.entries(f);for(const[b,l]of h){if(!l)return;const V=`${e}.${c}-${b}`;(await $(l,V,t)).forEach(z=>n.add(z))}}return}if(r==="compoundVariants"){for(const o of s){const{css:c,...f}=o,h=Object.entries(f).reduce((l,[V,k])=>`${l}.${V}-${k}`,e);(await $(c,h,t)).forEach(l=>n.add(l))}return}if(r.startsWith("@")){const o=((w=t==null?void 0:t.mediaQueries)==null?void 0:w[r])||r,c=await S(s,e,t),f=`${o} { ${c} }`;n.add(f);return}const i=m.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await $(s,i,t)).forEach(o=>n.add(o));return}if(typeof s=="number"){const i=M(y,s,t);return u(i)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${y}`);return u(s)}),{modifiers:C}=t||{},j=[N(),U(C)],O=(await Promise.all(E).then(m=>Promise.all(m.map(s=>j.reduce(async(r,y)=>{const u=await r;if(!u)return u;const T=await y(u);if(!T)return u;const{transformed:w,additionalCss:i}=T;let d="";if(i)for(const o of i)d+=await S(o,"");return`${d}${w}`},Promise.resolve(s)))))).filter(m=>m!==void 0).join(`
|
2
|
-
`);if(!O.trim())return Array.from(n);const W=e?`${e} {
|
3
|
-
${O}
|
4
|
-
}`:O;return n.has(W)?Array.from(n):[W,...n]},S=async(a,e,t,p=!1)=>(await $(a,e,t,p)).join(`
|
5
|
-
`);exports.parseAndJoinStyles=S;exports.parseVariableTokens=q;
|