@salty-css/core 0.0.1-alpha.276 → 0.0.1-alpha.278
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 +4 -4
- package/bin/main.js +125 -125
- 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 +13 -13
- package/{index-DV-sarjD.cjs → index-B5Z3hZJn.cjs} +11 -11
- package/{index-CqTDidoK.js → index-WkN_0Aq0.js} +46 -46
- package/package.json +1 -1
- package/parse-styles-Bdgw_4ME.cjs +5 -0
- package/parse-styles-Xjjg0H2Z.js +153 -0
- package/parsers/index.cjs +1 -1
- package/parsers/index.js +2 -2
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-BE-pvAhK.js → should-restart-BCGjmlNw.js} +1 -1
- package/{should-restart-B6uSbFR6.cjs → should-restart-CapzIWDV.cjs} +1 -1
- package/parse-styles-Cq_H5JGg.js +0 -153
- package/parse-styles-DZYIEhB4.cjs +0 -5
@@ -1,6 +1,6 @@
|
|
1
|
-
"use strict";const Te=require("esbuild"),_e=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ae=require("./parse-styles-
|
1
|
+
"use strict";const Te=require("esbuild"),_e=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ae=require("./parse-styles-Bdgw_4ME.cjs"),he=require("./parsers/index.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),Oe=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function ve(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 be=ve(Te),je=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:je(i.join(e,".."))},Ee=async e=>{const t=je(e);return await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ve=async e=>{const t=await Ee(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Ve(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-B5Z3hZJn.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Re=e=>{B.error(e)};function $e(e){return e?typeof e!="string"?$e(String(e)):e.replace(/[^\d\w]/g,"."):""}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"}},Je=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function o(y){if(ce.isVariableDeclaration(y)&&y.name.getText()===t){const S=y.getStart(),d=y.getEnd();clearTimeout(r),s([S,d])}y.forEachChild(o)}o(l)}),v={externalModules:[],rcFile:void 0,destDir:void 0},Ce=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(r=>r.replace(/['"`]/g,"").trim());return v.externalModules=n,n},q=async e=>{if(v.destDir)return v.destDir;const t=await fe(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return v.destDir=s,s},le=["salty","css","styles","styled"],Pe=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),Z=(e,t=[])=>Pe(t).test(e),Ne=async e=>{if(v.rcFile)return v.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(v.rcFile=s,s):Ne(i.join(e,".."))},fe=async e=>{var n,r;const t=await Ne(e),s=(n=t.projects)==null?void 0:n.find(l=>e.endsWith(l.dir||""));return s||((r=t.projects)==null?void 0:r.find(l=>l.dir===t.defaultProject))},qe=async e=>{const t=await fe(e),s=await q(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await Fe(e),o=Ce(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const y=Date.now(),{config:S}=await import(`${r}?t=${y}`);return{config:S,path:r}},xe=async(e,t)=>{var me,ye;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:F,outputFilePath:K}=await U(e,w,s);Object.entries(F).forEach(([D,P])=>{P.isMedia?n.mediaQueries.push([D,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${D};;${K}`))})}));const{config:r,path:l}=await qe(e),o={...r},{mediaQueries:y}=n;o.mediaQueries=Object.fromEntries(y.map(([w,F])=>[`@${w}`,F]));const S=y.map(([w])=>`'@${w}'`).join(" | "),d=new Set,a=async(w,F=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await a(T,[...F,P]);const ne=$e(P),oe=_.dashCase(P),ie=[...F,ne].join(".");d.add(`"${ie}"`);const Y=[...F.map(_.dashCase),oe].join("-"),ge=ae.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=await a(P);return D==="base"?M.join(""):o.mediaQueries[D]?`${o.mediaQueries[D]} { ${M.join("")} }`:`${D} { ${M.join("")} }`});return(await Promise.all(F)).flat()},m=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=Object.entries(P).map(async([T,ne])=>{const oe=await a(ne,[D]),ie=`.${D}-${T}, [data-${D}="${T}"]`,Y=oe.join("");return`${ie} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all(F)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map(F=>w==="static"?h(F._current):F._current[w]),$=J.mergeObjects(h(r.variables),p("static")),x=await a($),k=J.mergeObjects((me=r.variables)==null?void 0:me.responsive,p("responsive")),E=await g(k),z=J.mergeObjects((ye=r.variables)==null?void 0:ye.conditional,p("conditional")),A=await m(z),de=i.join(s,"css/_variables.css"),V=`:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;c.writeFileSync(de,V),o.staticVariables=$;const ee=i.join(s,"css/_global.css"),u=J.mergeObjects(r.global,n.globalStyles),b=await ae.parseAndJoinStyles(u,"");c.writeFileSync(ee,`@layer global { ${b} }`);const j=i.join(s,"css/_reset.css"),C=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Me,N=await ae.parseAndJoinStyles(C,"");c.writeFileSync(j,`@layer reset { ${N} }`);const O=i.join(s,"css/_templates.css"),R=J.mergeObjects(r.templates,n.templates),W=await he.parseTemplates(R),I=he.getTemplateTypes(R);c.writeFileSync(O,`@layer templates { ${W} }`),o.templates=R;const X=r.templates?[Oe.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],te=J.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(te).map(([w,F])=>[w,F._path]));const G=i.join(s,"types/css-tokens.d.ts"),ke=`
|
2
2
|
// Variable types
|
3
|
-
type VariableTokens = ${[...
|
3
|
+
type VariableTokens = ${[...d].join("|")};
|
4
4
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
5
|
|
6
6
|
// Template types
|
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
// Media query types
|
13
13
|
type MediaQueryKeys = ${S||"''"};
|
14
|
-
`;c.writeFileSync(G,ke);const De=i.join(s,"cache/config-cache.json");c.writeFileSync(De,JSON.stringify(o,null,2))},we=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const o=r.exec(e);if(o){const y=o.at(1);if(le.some(
|
14
|
+
`;c.writeFileSync(G,ke);const De=i.join(s,"cache/config-cache.json");c.writeFileSync(De,JSON.stringify(o,null,2))},we=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const o=r.exec(e);if(o){const y=o.at(1);if(le.some(d=>y==null?void 0:y.includes(d)))return t}return"styled('div',"}),ze=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
15
15
|
|
16
16
|
${e}`:`globalThis.saltyConfig = {};
|
17
17
|
|
18
|
-
${e}`}catch{return e}},U=async(e,t,s)=>{const n=_.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const l=i.parse(t);let o=c.readFileSync(t,"utf8");o=we(o),o=ze(o,e);const y=i.join(s,"js",n+".js"),S=await fe(e),
|
19
|
-
`),f=_.toHash(u,6),C=i.parse(u),N=_.dashCase(C.name),
|
18
|
+
${e}`}catch{return e}},U=async(e,t,s)=>{const n=_.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const l=i.parse(t);let o=c.readFileSync(t,"utf8");o=we(o),o=ze(o,e);const y=i.join(s,"js",n+".js"),S=await fe(e),d=i.join(e,(S==null?void 0:S.configDir)||"","salty.config.ts"),a=Ce(d),g=await Fe(e);await be.build({stdin:{contents:o,sourcefile:l.base,resolveDir:l.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:a,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},$=>{const x=c.readFileSync($.path,"utf8");return{contents:we(x),loader:"ts"}})}}]});const m=Date.now();return{contents:await import(`${y}?t=${m}`),outputFilePath:y}},He=async e=>{const t=await q(e),s=i.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)},ue=async e=>{const t=await He(e),s=await q(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:l}=await import(`${n}?t=${r}`);return J.mergeObjects(l,t)},pe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},We=async(e,t=pe(),s=!0)=>{try{const n=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const r=[],l=[],o=await q(e),y=i.join(o,"index.css");s&&(()=>{c.existsSync(o)&&_e.execSync("rm -rf "+o),c.mkdirSync(o,{recursive:!0}),c.mkdirSync(i.join(o,"css")),c.mkdirSync(i.join(o,"types")),c.mkdirSync(i.join(o,"js")),c.mkdirSync(i.join(o,"cache"))})();const d=new Set,a=new Set;async function g(u){const b=["node_modules","saltygen"],j=c.statSync(u);if(j.isDirectory()){const f=c.readdirSync(u);if(b.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>g(i.join(u,N))))}else if(j.isFile()&&Z(u)){d.add(u);const C=c.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&a.add(u)}}await g(e),await xe(e,a);const m={keyframes:[],components:[],classNames:[]};await Promise.all([...d].map(async u=>{const{contents:b}=await U(e,u,o);for(let[j,f]of Object.entries(b))f instanceof Promise&&(f=await f),f.isKeyframes?m.keyframes.push({value:f,src:u,name:j}):f.isClassName?m.classNames.push({...f,src:u,name:j}):f.generator&&m.components.push({...f,src:u,name:j})}));const h=await ue(e);for(const u of m.keyframes){const{value:b}=u,j=`a_${b.animationName}.css`,f=`css/${j}`,C=i.join(o,f);r.push(j),c.writeFileSync(C,b.css)}const p={};for(const u of m.components){const{src:b,name:j}=u;p[b]||(p[b]=[]);const f=u.generator._withBuildContext({callerName:j,isProduction:t,config:h});l[f.priority]||(l[f.priority]=[]);const C=await f.css;if(!C)continue;l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=i.join(o,N);c.writeFileSync(O,C),h.importStrategy==="component"&&p[b].push(f.cssFileName)}for(const u of m.classNames){const{src:b,name:j}=u;p[b]||(p[b]=[]);const f=u.generator._withBuildContext({callerName:j,isProduction:t,config:h}),C=await f.css;if(!C)continue;l[f.priority]||(l[f.priority]=[]),l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=i.join(o,N);c.writeFileSync(O,C),h.importStrategy==="component"&&p[b].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(p).forEach(([u,b])=>{const j=b.map(R=>`@import url('./${R}');`).join(`
|
19
|
+
`),f=_.toHash(u,6),C=i.parse(u),N=_.dashCase(C.name),O=i.join(o,`css/f_${N}-${f}.css`);c.writeFileSync(O,j||"/* Empty file */")});const $=r.map(u=>`@import url('./css/${u}');`).join(`
|
20
20
|
`);let A=`/*!
|
21
21
|
* Generated with Salty CSS (https://salty-css.dev)
|
22
22
|
* Do not edit this file directly
|
@@ -29,13 +29,13 @@ ${$}`;if(h.importStrategy!=="component"){const u=l.reduce((b,j,f)=>{const C=j.re
|
|
29
29
|
/*start:${G}-${I}*/
|
30
30
|
${te}
|
31
31
|
/*end:${G}*/
|
32
|
-
`},""),N=`l_${f}.css`,
|
33
|
-
}`;return c.writeFileSync(
|
34
|
-
@import url('./css/${N}');`},"");A+=u}c.writeFileSync(y,A);const V=Date.now()-n,ee=V<200?"🔥":V<500?"🚀":V<1e3?"🎉":V<2e3?"🚗":V<5e3?"🤔":"🥴";B.info(`Generated CSS in ${V}ms! ${ee}`)}catch(n){console.error(n)}},Ie=async(e,t,s=pe())=>{try{const n=await q(e);if(Z(t)){const l=[],o=await ue(e),{contents:y}=await U(e,t,n);for(const[S,
|
32
|
+
`},""),N=`l_${f}.css`,O=i.join(o,"css",N),R=`@layer l${f} { ${C}
|
33
|
+
}`;return c.writeFileSync(O,R),`${b}
|
34
|
+
@import url('./css/${N}');`},"");A+=u}c.writeFileSync(y,A);const V=Date.now()-n,ee=V<200?"🔥":V<500?"🚀":V<1e3?"🎉":V<2e3?"🚗":V<5e3?"🤔":"🥴";B.info(`Generated CSS in ${V}ms! ${ee}`)}catch(n){console.error(n)}},Ie=async(e,t,s=pe())=>{try{const n=await q(e);if(Z(t)){const l=[],o=await ue(e),{contents:y}=await U(e,t,n);for(const[S,d]of Object.entries(y)){if(d.isKeyframes&&d.css){const $=`css/${`a_${d.animationName}.css`}`,x=i.join(n,$);c.writeFileSync(x,await d.css);continue}if(d.isClassName){const p=d.generator._withBuildContext({callerName:S,isProduction:s,config:o}),$=await p.css;if(!$)continue;l[p.priority]||(l[p.priority]=[]),l[p.priority].push(p.cssFileName);const x=`css/${p.cssFileName}`,k=i.join(n,x);c.writeFileSync(k,$);continue}if(!d.generator)continue;const a=d.generator._withBuildContext({callerName:S,isProduction:s,config:o}),g=await a.css;if(!g)continue;const m=`css/${a.cssFileName}`,h=i.join(n,m);c.writeFileSync(h,g),l[a.priority]||(l[a.priority]=[]),l[a.priority].push(a.cssFileName)}if(o.importStrategy!=="component")l.forEach((S,d)=>{const a=`l_${d}.css`,g=i.join(n,"css",a);let m=c.readFileSync(g,"utf8");S.forEach(h=>{var k;const p=i.join(n,"css",h),$=((k=/.*-([^-]+)-\d+.css/.exec(h))==null?void 0:k.at(1))||_.toHash(p,6);if(!m.includes($)){const E=c.readFileSync(p,"utf8"),z=`/*start:${$}-${h}*/
|
35
35
|
${E}
|
36
36
|
/*end:${$}*/
|
37
|
-
`;
|
37
|
+
`;m=`${m.replace(/\}$/,"")}
|
38
38
|
${z}
|
39
|
-
}`}}),c.writeFileSync(g,
|
40
|
-
`),
|
39
|
+
}`}}),c.writeFileSync(g,m)});else{const S=l.flat().map(h=>`@import url('./${h}');`).join(`
|
40
|
+
`),d=_.toHash(t,6),a=i.parse(t),g=_.dashCase(a.name),m=i.join(n,`css/f_${g}-${d}.css`);c.writeFileSync(m,S||"/* Empty file */")}}}catch(n){console.error(n)}},Ge=async(e,t,s=pe())=>{var n,r;try{const l=await q(e);if(Z(t)){const y=c.readFileSync(t,"utf8"),S=await ue(e),{contents:d}=await U(e,t,l);let a=y;for(const[g,m]of Object.entries(d)){if(m.isKeyframes||!m.generator)continue;const h=m.generator._withBuildContext({callerName:g,isProduction:s,config:S}),[p,$]=await Je(a,g),x=a.slice(p,$);if(m.isClassName){const k=a,E=` ${g} = className("${h.classNames}")`;a=a.replace(x,E),k===a&&console.error("Minimize file failed to change content",{name:g})}if(x.includes("styled")){const k=(r=(n=/styled\(([^,]+),/.exec(x))==null?void 0:n.at(1))==null?void 0:r.trim(),E=a,z=` ${g} = styled(${k}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;a=a.replace(x,z),E===a&&console.error("Minimize file failed to change content",{name:g,tagName:k})}}if(S.importStrategy==="component"){const g=_.toHash(t,6),m=i.parse(t);a=`import '../../saltygen/css/${`f_${_.dashCase(m.name)}-${g}.css`}';
|
41
41
|
${a}`}return a=a.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),a=a.replace("{ styled }","{ styledClient as styled }"),a=a.replace("@salty-css/react/styled","@salty-css/react/styled-client"),a}}catch(l){console.error("Error in minimizeFile:",l)}};exports.compileSaltyFile=U;exports.generateConfigStyles=xe;exports.generateCss=We;exports.generateFile=Ie;exports.isSaltyFile=Z;exports.logError=Re;exports.logger=B;exports.minimizeFile=Ge;exports.saltyFileExtensions=le;exports.saltyFileRegExp=Pe;
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import * as St from "esbuild";
|
2
|
-
import { execSync as
|
2
|
+
import { execSync as _t } from "child_process";
|
3
3
|
import { t as I, d as A } from "./dash-case-DBThphLm.js";
|
4
4
|
import { join as i, parse as tt } from "path";
|
5
|
-
import { existsSync as ft,
|
5
|
+
import { existsSync as ft, writeFileSync as F, mkdirSync as G, readFileSync as _, statSync as Vt, readdirSync as vt } from "fs";
|
6
6
|
import { readFile as Ct } from "fs/promises";
|
7
|
-
import { p as $t, a as Et } from "./parse-styles-
|
7
|
+
import { p as $t, a as Et } from "./parse-styles-Xjjg0H2Z.js";
|
8
8
|
import { parseTemplates as Ot, getTemplateTypes as Mt } from "./parsers/index.js";
|
9
|
-
import { createLogger as Rt,
|
9
|
+
import { createLogger as Rt, format as rt, transports as Jt } from "winston";
|
10
10
|
import { mergeObjects as H, mergeFactories as zt } from "./css/merge.js";
|
11
11
|
import { d as Wt } from "./define-templates-4A2yHcMF.js";
|
12
12
|
import lt from "typescript";
|
@@ -96,26 +96,26 @@ const It = {
|
|
96
96
|
d.forEachChild(o);
|
97
97
|
}
|
98
98
|
o(r);
|
99
|
-
}),
|
99
|
+
}), v = {
|
100
100
|
externalModules: [],
|
101
101
|
rcFile: void 0,
|
102
102
|
destDir: void 0
|
103
103
|
}, Nt = (t) => {
|
104
|
-
if (
|
105
|
-
const s =
|
104
|
+
if (v.externalModules.length > 0) return v.externalModules;
|
105
|
+
const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
106
106
|
if (!s) return [];
|
107
107
|
const n = s[1].split(",").map((c) => c.replace(/['"`]/g, "").trim());
|
108
|
-
return
|
108
|
+
return v.externalModules = n, n;
|
109
109
|
}, J = async (t) => {
|
110
|
-
if (
|
110
|
+
if (v.destDir) return v.destDir;
|
111
111
|
const e = await pt(t), s = i(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
112
|
-
return
|
112
|
+
return v.destDir = s, s;
|
113
113
|
}, xt = ["salty", "css", "styles", "styled"], Qt = (t = []) => new RegExp(`\\.(${[...xt, ...t].join("|")})\\.`), mt = (t, e = []) => Qt(e).test(t), Dt = async (t) => {
|
114
|
-
if (
|
114
|
+
if (v.rcFile) return v.rcFile;
|
115
115
|
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
116
116
|
const e = i(t, ".saltyrc.json"), s = await Ct(e, "utf-8").then(JSON.parse).catch(() => {
|
117
117
|
});
|
118
|
-
return s ? (
|
118
|
+
return s ? (v.rcFile = s, s) : Dt(i(t, ".."));
|
119
119
|
}, pt = async (t) => {
|
120
120
|
var n, c;
|
121
121
|
const e = await Dt(t), s = (n = e.projects) == null ? void 0 : n.find((r) => t.endsWith(r.dir || ""));
|
@@ -154,15 +154,15 @@ const It = {
|
|
154
154
|
const w = d.map(([h]) => `'@${h}'`).join(" | "), p = /* @__PURE__ */ new Set(), a = async (h, S = []) => {
|
155
155
|
if (!h) return [];
|
156
156
|
const L = Object.entries(h).map(async ([j, R]) => {
|
157
|
-
const q = async (
|
158
|
-
if (!
|
159
|
-
if (
|
160
|
-
if (typeof
|
161
|
-
if (typeof
|
157
|
+
const q = async (T) => {
|
158
|
+
if (!T) return;
|
159
|
+
if (T instanceof Promise) return await q(await T);
|
160
|
+
if (typeof T == "function") return await q(await T());
|
161
|
+
if (typeof T == "object") return await a(T, [...S, j]);
|
162
162
|
const at = jt(j), it = A(j), ct = [...S, at].join(".");
|
163
163
|
p.add(`"${ct}"`);
|
164
|
-
const Y = [...S.map(A), it].join("-"), wt = Et(
|
165
|
-
return wt ? `--${Y}: ${wt.transformed};` : `--${Y}: ${
|
164
|
+
const Y = [...S.map(A), it].join("-"), wt = Et(T);
|
165
|
+
return wt ? `--${Y}: ${wt.transformed};` : `--${Y}: ${T};`;
|
166
166
|
};
|
167
167
|
return await q(R);
|
168
168
|
});
|
@@ -177,8 +177,8 @@ const It = {
|
|
177
177
|
}, u = async (h) => {
|
178
178
|
if (!h) return [];
|
179
179
|
const S = Object.entries(h).map(async ([k, j]) => {
|
180
|
-
const R = Object.entries(j).map(async ([
|
181
|
-
const it = await a(at, [k]), ct = `.${k}-${
|
180
|
+
const R = Object.entries(j).map(async ([T, at]) => {
|
181
|
+
const it = await a(at, [k]), ct = `.${k}-${T}, [data-${k}="${T}"]`, Y = it.join("");
|
182
182
|
return `${ct} { ${Y} }`;
|
183
183
|
});
|
184
184
|
return (await Promise.all(R)).flat();
|
@@ -190,8 +190,8 @@ const It = {
|
|
190
190
|
F(st, `@layer global { ${$} }`);
|
191
191
|
const b = i(s, "css/_reset.css"), P = c.reset === "none" ? {} : typeof c.reset == "object" ? c.reset : It, N = await $t(P, "");
|
192
192
|
F(b, `@layer reset { ${N} }`);
|
193
|
-
const
|
194
|
-
F(
|
193
|
+
const V = i(s, "css/_templates.css"), M = H(c.templates, n.templates), K = await Ot(M), Q = Mt(M);
|
194
|
+
F(V, `@layer templates { ${K} }`), o.templates = M;
|
195
195
|
const X = c.templates ? [Wt(c.templates)._setPath(`config;;${r}`)] : [], nt = zt(n.templates, X);
|
196
196
|
o.templatePaths = Object.fromEntries(Object.entries(nt).map(([h, S]) => [h, S._path]));
|
197
197
|
const B = i(s, "types/css-tokens.d.ts"), kt = `
|
@@ -209,8 +209,8 @@ const It = {
|
|
209
209
|
type MediaQueryKeys = ${w || "''"};
|
210
210
|
`;
|
211
211
|
F(B, kt);
|
212
|
-
const
|
213
|
-
F(
|
212
|
+
const Tt = i(s, "cache/config-cache.json");
|
213
|
+
F(Tt, JSON.stringify(o, null, 2));
|
214
214
|
}, bt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
215
215
|
if (/^['"`]/.test(s)) return e;
|
216
216
|
const c = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
@@ -223,7 +223,7 @@ const It = {
|
|
223
223
|
return "styled('div',";
|
224
224
|
}), qt = (t, e) => {
|
225
225
|
try {
|
226
|
-
const s =
|
226
|
+
const s = _(i(e, "saltygen/cache/config-cache.json"), "utf8");
|
227
227
|
return s ? `globalThis.saltyConfig = ${s};
|
228
228
|
|
229
229
|
${t}` : `globalThis.saltyConfig = {};
|
@@ -236,7 +236,7 @@ ${t}`;
|
|
236
236
|
const n = I(e), c = i(s, "./temp");
|
237
237
|
ft(c) || G(c);
|
238
238
|
const r = tt(e);
|
239
|
-
let o =
|
239
|
+
let o = _(e, "utf8");
|
240
240
|
o = bt(o), o = qt(o, t);
|
241
241
|
const d = i(s, "js", n + ".js"), w = await pt(t), p = i(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), a = Nt(p), y = await Pt(t);
|
242
242
|
await St.build({
|
@@ -260,7 +260,7 @@ ${t}`;
|
|
260
260
|
name: "test",
|
261
261
|
setup: (m) => {
|
262
262
|
m.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (C) => {
|
263
|
-
const x =
|
263
|
+
const x = _(C.path, "utf8");
|
264
264
|
return { contents: bt(x), loader: "ts" };
|
265
265
|
});
|
266
266
|
}
|
@@ -270,7 +270,7 @@ ${t}`;
|
|
270
270
|
const u = Date.now();
|
271
271
|
return { contents: await import(`${d}?t=${u}`), outputFilePath: d };
|
272
272
|
}, At = async (t) => {
|
273
|
-
const e = await J(t), s = i(e, "cache/config-cache.json"), n =
|
273
|
+
const e = await J(t), s = i(e, "cache/config-cache.json"), n = _(s, "utf8");
|
274
274
|
if (!n) throw new Error("Could not find config cache file");
|
275
275
|
return JSON.parse(n);
|
276
276
|
}, ut = async (t) => {
|
@@ -288,18 +288,18 @@ ${t}`;
|
|
288
288
|
e ? Z.info("Generating CSS in production mode! 🔥") : Z.info("Generating CSS in development mode! 🚀");
|
289
289
|
const c = [], r = [], o = await J(t), d = i(o, "index.css");
|
290
290
|
s && (() => {
|
291
|
-
ft(o) &&
|
291
|
+
ft(o) && _t("rm -rf " + o), G(o, { recursive: !0 }), G(i(o, "css")), G(i(o, "types")), G(i(o, "js")), G(i(o, "cache"));
|
292
292
|
})();
|
293
293
|
const p = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
294
294
|
async function y(f) {
|
295
|
-
const $ = ["node_modules", "saltygen"], b =
|
295
|
+
const $ = ["node_modules", "saltygen"], b = Vt(f);
|
296
296
|
if (b.isDirectory()) {
|
297
|
-
const l =
|
297
|
+
const l = vt(f);
|
298
298
|
if ($.some((N) => f.includes(N))) return;
|
299
299
|
await Promise.all(l.map((N) => y(i(f, N))));
|
300
300
|
} else if (b.isFile() && mt(f)) {
|
301
301
|
p.add(f);
|
302
|
-
const P =
|
302
|
+
const P = _(f, "utf8");
|
303
303
|
/define[\w\d]+\(/.test(P) && a.add(f);
|
304
304
|
}
|
305
305
|
}
|
@@ -346,8 +346,8 @@ ${t}`;
|
|
346
346
|
const P = await l.css;
|
347
347
|
if (!P) continue;
|
348
348
|
r[l.priority].push(l.cssFileName);
|
349
|
-
const N = `css/${l.cssFileName}`,
|
350
|
-
F(
|
349
|
+
const N = `css/${l.cssFileName}`, V = i(o, N);
|
350
|
+
F(V, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
351
351
|
}
|
352
352
|
for (const f of u.classNames) {
|
353
353
|
const { src: $, name: b } = f;
|
@@ -359,13 +359,13 @@ ${t}`;
|
|
359
359
|
}), P = await l.css;
|
360
360
|
if (!P) continue;
|
361
361
|
r[l.priority] || (r[l.priority] = []), r[l.priority].push(l.cssFileName);
|
362
|
-
const N = `css/${l.cssFileName}`,
|
363
|
-
F(
|
362
|
+
const N = `css/${l.cssFileName}`, V = i(o, N);
|
363
|
+
F(V, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
364
364
|
}
|
365
365
|
g.importStrategy === "component" && Object.entries(m).forEach(([f, $]) => {
|
366
366
|
const b = $.map((M) => `@import url('./${M}');`).join(`
|
367
|
-
`), l = I(f, 6), P = tt(f), N = A(P.name),
|
368
|
-
F(
|
367
|
+
`), l = I(f, 6), P = tt(f), N = A(P.name), V = i(o, `css/f_${N}-${l}.css`);
|
368
|
+
F(V, b || "/* Empty file */");
|
369
369
|
});
|
370
370
|
const C = c.map((f) => `@import url('./css/${f}');`).join(`
|
371
371
|
`);
|
@@ -377,7 +377,7 @@ ${t}`;
|
|
377
377
|
|
378
378
|
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
|
379
379
|
try {
|
380
|
-
return
|
380
|
+
return _(i(o, "css", f), "utf8").length > 0;
|
381
381
|
} catch {
|
382
382
|
return !1;
|
383
383
|
}
|
@@ -390,15 +390,15 @@ ${C}`;
|
|
390
390
|
const f = r.reduce(($, b, l) => {
|
391
391
|
const P = b.reduce((K, Q) => {
|
392
392
|
var ot;
|
393
|
-
const X = i(o, "css", Q), nt =
|
393
|
+
const X = i(o, "css", Q), nt = _(X, "utf8"), B = ((ot = /.*-([^-]+)-\d+.css/.exec(Q)) == null ? void 0 : ot.at(1)) || I(X, 6);
|
394
394
|
return K.includes(B) ? K : `${K}
|
395
395
|
/*start:${B}-${Q}*/
|
396
396
|
${nt}
|
397
397
|
/*end:${B}*/
|
398
398
|
`;
|
399
|
-
}, ""), N = `l_${l}.css`,
|
399
|
+
}, ""), N = `l_${l}.css`, V = i(o, "css", N), M = `@layer l${l} { ${P}
|
400
400
|
}`;
|
401
|
-
return F(
|
401
|
+
return F(V, M), `${$}
|
402
402
|
@import url('./css/${N}');`;
|
403
403
|
}, "");
|
404
404
|
U += f;
|
@@ -445,12 +445,12 @@ ${nt}
|
|
445
445
|
if (o.importStrategy !== "component")
|
446
446
|
r.forEach((w, p) => {
|
447
447
|
const a = `l_${p}.css`, y = i(n, "css", a);
|
448
|
-
let u =
|
448
|
+
let u = _(y, "utf8");
|
449
449
|
w.forEach((g) => {
|
450
450
|
var D;
|
451
451
|
const m = i(n, "css", g), C = ((D = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : D.at(1)) || I(m, 6);
|
452
452
|
if (!u.includes(C)) {
|
453
|
-
const E =
|
453
|
+
const E = _(m, "utf8"), z = `/*start:${C}-${g}*/
|
454
454
|
${E}
|
455
455
|
/*end:${C}*/
|
456
456
|
`;
|
@@ -474,7 +474,7 @@ ${z}
|
|
474
474
|
try {
|
475
475
|
const r = await J(t);
|
476
476
|
if (mt(e)) {
|
477
|
-
const d =
|
477
|
+
const d = _(e, "utf8"), w = await ut(t), { contents: p } = await et(t, e, r);
|
478
478
|
let a = d;
|
479
479
|
for (const [y, u] of Object.entries(p)) {
|
480
480
|
if (u.isKeyframes || !u.generator) continue;
|
package/package.json
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";const W=require("./dash-case-BJEkFEGQ.cjs"),N=require("./viewport-clamp-kY8JqYzm.cjs"),I=i=>e=>{if(typeof e!="string"||!i)return;let t=e;const u=[];return Object.values(i).forEach(r=>{const{pattern:d,transform:f}=r;t=t.replace(d,C=>{const{value:j,css:E}=f(C);return E&&u.push(E),j})}),{transformed:t,additionalCss:u}},O=i=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...r)=>{const d=W.dashCase(r[1].replaceAll(".","-"));return i&&!i.includes(d)&&console.warn(`Token ${d} might not exist`),d.startsWith("-")?`-${d}`:`var(--${d})`})},U=O(),k=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],J=(i,e,t)=>{if(k.some(r=>typeof r=="string"?r===i:r.test(i))){const r=(t==null?void 0:t.defaultUnit)||"px";if(r.startsWith("viewport-clamp:"))try{const f=r.split(":")[1];return N.defineViewportClamp({screenSize:parseInt(f)})(Number(e))}catch(f){throw console.error(f),new Error(`Invalid viewport-clamp value: ${r}`)}return`${e}${r}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=i=>i.startsWith("-")?i:Q.some(e=>i.startsWith(e))?`-${W.dashCase(i)}`:W.dashCase(i),$=async(i,e="",t,u=!1)=>{if(!i)throw new Error("No styles provided to parseStyles function!");const r=new Set,d=Object.entries(i),f=async([m,s])=>{var S;const n=m.trim().replace(/^\?+/g,""),b=_(n),h=(a,c=";")=>`${b}:${a}${c}`,P={scope:e,config:t};if(typeof s=="function")return f([m,s(P)]);if(s instanceof Promise)return f([m,await s]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[a,c]=t.templatePaths[n].split(";;"),o=await import(c),p=c.includes("salty.config"),l=p?o[a].templates:o[a],y=p?l[n]:l.params[n];if(l&&typeof y=="function"){const V=await y(s),[w]=await $(V,"");return w}}catch(a){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,a);return}if(t!=null&&t.templates&&t.templates[n]){if(u)return;const c=s.split(".").reduce((o,p)=>o[p],t.templates[n]);if(c){const[o]=await $(c,"");return o}console.warn(`Template "${n}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return h(s.toString());if(n==="defaultVariants")return;if(n==="variants"){const o=Object.entries(s);for(const[p,l]of o){if(!l)continue;const y=Object.entries(l);for(const[V,w]of y){if(!w)continue;const x=`${e}.${p}-${V}`;(await $(w,x,t)).forEach(M=>r.add(M))}}return}if(n==="compoundVariants"){for(const o of s){const{css:p,...l}=o,y=Object.entries(l).reduce((w,[x,q])=>`${w}.${x}-${q}`,e);(await $(p,y,t)).forEach(w=>r.add(w))}return}if(n.startsWith("@")){const o=((S=t==null?void 0:t.mediaQueries)==null?void 0:S[n])||n,p=await A(s,e,t),l=`${o} { ${p} }`;r.add(l);return}const a=m.includes("&")?n.replaceAll("&",e):n.startsWith(":")?`${e}${n}`:`${e} ${n}`;(await $(s,a,t)).forEach(o=>r.add(o));return}if(typeof s=="number"){const a=J(b,s,t);return h(a)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${b}`);return h(s)},C=d.map(f),{modifiers:j}=t||{},E=[O(),I(j)],T=(await Promise.all(C).then(m=>Promise.all(m.map(s=>E.reduce(async(n,b)=>{const h=await n;if(!h)return h;const P=await b(h);if(!P)return h;const{transformed:S,additionalCss:a}=P;let c="";if(a)for(const o of a)c+=await A(o,"");return`${c}${S}`},Promise.resolve(s)))))).filter(m=>m!==void 0).join(`
|
2
|
+
`);if(!T.trim())return Array.from(r);const z=e?`${e} {
|
3
|
+
${T}
|
4
|
+
}`:T;return r.has(z)?Array.from(r):[z,...r]},A=async(i,e,t,u=!1)=>(await $(i,e,t,u)).join(`
|
5
|
+
`);exports.parseAndJoinStyles=A;exports.parseStyles=$;exports.parseValueModifiers=I;exports.parseValueTokens=O;exports.parseVariableTokens=U;
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { d as T } from "./dash-case-DBThphLm.js";
|
2
|
+
import { d as U } from "./viewport-clamp-BOc-8Oph.js";
|
3
|
+
const M = (o) => (s) => {
|
4
|
+
if (typeof s != "string" || !o) return;
|
5
|
+
let t = s;
|
6
|
+
const u = [];
|
7
|
+
return Object.values(o).forEach((r) => {
|
8
|
+
const { pattern: d, transform: l } = r;
|
9
|
+
t = t.replace(d, (E) => {
|
10
|
+
const { value: S, css: C } = l(E);
|
11
|
+
return C && u.push(C), S;
|
12
|
+
});
|
13
|
+
}), { transformed: t, additionalCss: u };
|
14
|
+
}, I = (o) => (s) => typeof s != "string" || !/\{[^{}]+\}/g.test(s) ? void 0 : { transformed: s.replace(/\{([^{}]+)\}/g, (...r) => {
|
15
|
+
const d = T(r[1].replaceAll(".", "-"));
|
16
|
+
return o && !o.includes(d) && console.warn(`Token ${d} might not exist`), d.startsWith("-") ? `-${d}` : `var(--${d})`;
|
17
|
+
}) }, G = I(), Q = [
|
18
|
+
"top",
|
19
|
+
"right",
|
20
|
+
"bottom",
|
21
|
+
"left",
|
22
|
+
"min-width",
|
23
|
+
/.*width.*/,
|
24
|
+
/^[^line]*height.*/,
|
25
|
+
// Exclude line-height
|
26
|
+
/padding.*/,
|
27
|
+
/margin.*/,
|
28
|
+
/border.*/,
|
29
|
+
/inset.*/,
|
30
|
+
/.*radius.*/,
|
31
|
+
/.*spacing.*/,
|
32
|
+
/.*gap.*/,
|
33
|
+
/.*indent.*/,
|
34
|
+
/.*offset.*/,
|
35
|
+
/.*size.*/,
|
36
|
+
/.*thickness.*/,
|
37
|
+
/.*font-size.*/
|
38
|
+
], _ = (o, s, t) => {
|
39
|
+
if (Q.some((r) => typeof r == "string" ? r === o : r.test(o))) {
|
40
|
+
const r = (t == null ? void 0 : t.defaultUnit) || "px";
|
41
|
+
if (r.startsWith("viewport-clamp:"))
|
42
|
+
try {
|
43
|
+
const l = r.split(":")[1];
|
44
|
+
return U({
|
45
|
+
screenSize: parseInt(l)
|
46
|
+
})(Number(s));
|
47
|
+
} catch (l) {
|
48
|
+
throw console.error(l), new Error(`Invalid viewport-clamp value: ${r}`);
|
49
|
+
}
|
50
|
+
return `${s}${r}`;
|
51
|
+
}
|
52
|
+
return `${s}`;
|
53
|
+
}, q = ["Webkit", "Moz", "ms", "O"], F = (o) => o.startsWith("-") ? o : q.some((s) => o.startsWith(s)) ? `-${T(o)}` : T(o), y = async (o, s = "", t, u = !1) => {
|
54
|
+
if (!o) throw new Error("No styles provided to parseStyles function!");
|
55
|
+
const r = /* @__PURE__ */ new Set(), d = Object.entries(o), l = async ([m, e]) => {
|
56
|
+
var j;
|
57
|
+
const n = m.trim().replace(/^\?+/g, ""), b = F(n), h = (a, c = ";") => `${b}:${a}${c}`, P = { scope: s, config: t };
|
58
|
+
if (typeof e == "function") return l([m, e(P)]);
|
59
|
+
if (e instanceof Promise) return l([m, await e]);
|
60
|
+
if (t != null && t.templates && t.templatePaths[n])
|
61
|
+
try {
|
62
|
+
const [a, c] = t.templatePaths[n].split(";;"), i = await import(
|
63
|
+
/* webpackIgnore: true */
|
64
|
+
c
|
65
|
+
), p = c.includes("salty.config"), f = p ? i[a].templates : i[a], $ = p ? f[n] : f.params[n];
|
66
|
+
if (f && typeof $ == "function") {
|
67
|
+
const x = await $(e), [w] = await y(x, "");
|
68
|
+
return w;
|
69
|
+
}
|
70
|
+
} catch (a) {
|
71
|
+
console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`, a);
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
if (t != null && t.templates && t.templates[n]) {
|
75
|
+
if (u) return;
|
76
|
+
const c = e.split(".").reduce((i, p) => i[p], t.templates[n]);
|
77
|
+
if (c) {
|
78
|
+
const [i] = await y(c, "");
|
79
|
+
return i;
|
80
|
+
}
|
81
|
+
console.warn(`Template "${n}" with path of "${e}" was not found in config!`);
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
if (typeof e == "object") {
|
85
|
+
if (!e) return;
|
86
|
+
if (e.isColor) return h(e.toString());
|
87
|
+
if (n === "defaultVariants") return;
|
88
|
+
if (n === "variants") {
|
89
|
+
const i = Object.entries(e);
|
90
|
+
for (const [p, f] of i) {
|
91
|
+
if (!f) continue;
|
92
|
+
const $ = Object.entries(f);
|
93
|
+
for (const [x, w] of $) {
|
94
|
+
if (!w) continue;
|
95
|
+
const O = `${s}.${p}-${x}`;
|
96
|
+
(await y(w, O, t)).forEach((N) => r.add(N));
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
if (n === "compoundVariants") {
|
102
|
+
for (const i of e) {
|
103
|
+
const { css: p, ...f } = i, $ = Object.entries(f).reduce((w, [O, z]) => `${w}.${O}-${z}`, s);
|
104
|
+
(await y(p, $, t)).forEach((w) => r.add(w));
|
105
|
+
}
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
if (n.startsWith("@")) {
|
109
|
+
const i = ((j = t == null ? void 0 : t.mediaQueries) == null ? void 0 : j[n]) || n, p = await A(e, s, t), f = `${i} { ${p} }`;
|
110
|
+
r.add(f);
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
const a = m.includes("&") ? n.replaceAll("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
|
114
|
+
(await y(e, a, t)).forEach((i) => r.add(i));
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
if (typeof e == "number") {
|
118
|
+
const a = _(b, e, t);
|
119
|
+
return h(a);
|
120
|
+
}
|
121
|
+
if (typeof e != "string")
|
122
|
+
if ("toString" in e) e = e.toString();
|
123
|
+
else throw new Error(`Invalid value type for property ${b}`);
|
124
|
+
return h(e);
|
125
|
+
}, E = d.map(l), { modifiers: S } = t || {}, C = [I(), M(S)], W = (await Promise.all(E).then((m) => Promise.all(
|
126
|
+
m.map((e) => C.reduce(async (n, b) => {
|
127
|
+
const h = await n;
|
128
|
+
if (!h) return h;
|
129
|
+
const P = await b(h);
|
130
|
+
if (!P) return h;
|
131
|
+
const { transformed: j, additionalCss: a } = P;
|
132
|
+
let c = "";
|
133
|
+
if (a)
|
134
|
+
for (const i of a)
|
135
|
+
c += await A(i, "");
|
136
|
+
return `${c}${j}`;
|
137
|
+
}, Promise.resolve(e)))
|
138
|
+
))).filter((m) => m !== void 0).join(`
|
139
|
+
`);
|
140
|
+
if (!W.trim()) return Array.from(r);
|
141
|
+
const V = s ? `${s} {
|
142
|
+
${W}
|
143
|
+
}` : W;
|
144
|
+
return r.has(V) ? Array.from(r) : [V, ...r];
|
145
|
+
}, A = async (o, s, t, u = !1) => (await y(o, s, t, u)).join(`
|
146
|
+
`);
|
147
|
+
export {
|
148
|
+
G as a,
|
149
|
+
M as b,
|
150
|
+
y as c,
|
151
|
+
I as d,
|
152
|
+
A as p
|
153
|
+
};
|
package/parsers/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-Bdgw_4ME.cjs"),c=require("../dash-case-BJEkFEGQ.cjs"),p=async(e,s=[])=>{if(!e)return"";const t=[],r={};for(const[n,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const i=n.trim(),u=await p(o,[...s,i]);t.push(u)}else r[n]=o;if(Object.keys(r).length){const n=s.map(c.dashCase).join("-"),o="t_"+c.toHash(n,4),i=await a.parseAndJoinStyles(r,`.${n}, .${o}`);t.push(i)}return t.join(`
|
2
2
|
`)},y=e=>Object.keys(e),f=e=>e?Object.entries(e).reduce((s,[t,r])=>(typeof r=="function"?s[t]="any":typeof r=="object"&&(s[t]=l(r).map(n=>`"${n}"`).join(" | ")),s),{}):{},l=(e,s="",t=new Set)=>e?(Object.entries(e).forEach(([r,n])=>{const o=s?`${s}.${r}`:r;return typeof n=="object"?l(n,o,t):t.add(s)}),[...t]):[];exports.parseAndJoinStyles=a.parseAndJoinStyles;exports.parseStyles=a.parseStyles;exports.parseValueModifiers=a.parseValueModifiers;exports.parseValueTokens=a.parseValueTokens;exports.parseVariableTokens=a.parseVariableTokens;exports.getTemplateKeys=y;exports.getTemplateTokens=l;exports.getTemplateTypes=f;exports.parseTemplates=p;
|
package/parsers/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { p as f } from "../parse-styles-
|
2
|
-
import { c as T, b as O, d as $, a as g } from "../parse-styles-
|
1
|
+
import { p as f } from "../parse-styles-Xjjg0H2Z.js";
|
2
|
+
import { c as T, b as O, d as $, a as g } from "../parse-styles-Xjjg0H2Z.js";
|
3
3
|
import { d as p, t as u } from "../dash-case-DBThphLm.js";
|
4
4
|
const l = async (e, s = []) => {
|
5
5
|
if (!e) return "";
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-CapzIWDV.cjs");exports.checkShouldRestart=e.checkShouldRestart;
|
package/server/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "./index-
|
2
|
+
import { i as e } from "./index-WkN_0Aq0.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";const s=require("fs/promises"),r=require("./index-
|
1
|
+
"use strict";const s=require("fs/promises"),r=require("./index-B5Z3hZJn.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;
|