@salty-css/core 0.0.1-alpha.132 → 0.0.1-alpha.133

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-Bl6Ocgz0.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-BfaeXpVd.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
package/bin/main.js CHANGED
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
3
3
  import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
4
4
  import { join as i, relative as z, parse as re, format as ee } from "path";
5
5
  import { render as ce } from "ejs";
6
- import { l as t, a as h, g as te } from "../index-BKhQ2XRr.js";
6
+ import { l as t, a as h, g as te } from "../index-D3LMeqt-.js";
7
7
  import { p as le } from "../pascal-case-BQpR5PdN.js";
8
8
  import { exec as de } from "child_process";
9
9
  import fe from "ora";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DdYSw-iq.cjs");const e=require("../index-Bl6Ocgz0.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DdYSw-iq.cjs");const e=require("../index-BfaeXpVd.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
package/compiler/index.js CHANGED
@@ -5,7 +5,7 @@ import "path";
5
5
  import "fs";
6
6
  import "fs/promises";
7
7
  import "../parse-templates-DnLWJ7Hc.js";
8
- import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-BKhQ2XRr.js";
8
+ import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-D3LMeqt-.js";
9
9
  export {
10
10
  p as compileSaltyFile,
11
11
  n as generateConfigStyles,
@@ -0,0 +1,21 @@
1
+ "use strict";const ce=require("esbuild"),ae=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),R=require("./parse-templates-DdYSw-iq.cjs"),z=require("winston");var I=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const G=le(ce),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:L(s.join(e,".."))},pe=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let M;const U=async e=>{if(M)return M;const t=await ue(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-BfaeXpVd.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{J.error(e)};function X(e){return e?typeof e!="string"?X(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const fe={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},Y=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const l=o[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return A.externalModules=l,l},q=e=>s.join(e,"./saltygen"),Q=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...Q,...e].join("|")})\\.`),W=(e,t=[])=>ee(t).test(e),ge=async e=>{const t=q(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),l=await U(e),r=Y(e);await G.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:l,external:r});const h=Date.now(),{config:S}=await import(`${o}?t=${h}`);return S},te=async e=>{const t=await ge(e),n=new Set,o=(p,d=[])=>p?Object.entries(p).flatMap(([b,f])=>{if(!f)return;if(typeof f=="object")return o(f,[...d,b]);const V=X(b),v=D.dashCase(b),T=[...d,V].join(".");n.add(`"${T}"`);const C=[...d.map(D.dashCase),v].join("-"),{result:k}=R.parseValueTokens(f);return`--${C}: ${k};`}):[],l=p=>p?Object.entries(p).flatMap(([d,b])=>{const f=o(b);return d==="base"?f.join(""):`${d} { ${f.join("")} }`}):[],r=p=>p?Object.entries(p).flatMap(([d,b])=>Object.entries(b).flatMap(([f,V])=>{const v=o(V,[d]),T=`.${d}-${f}, [data-${d}="${f}"]`,C=v.join("");return`${T} { ${C} }`})):[],h=o(t.variables),S=l(t.responsiveVariables),w=r(t.conditionalVariables),i=q(e),u=s.join(i,"css/_variables.css"),j=`:root { ${h.join("")} ${S.join("")} } ${w.join("")}`;c.writeFileSync(u,j);const $=s.join(i,"css/_global.css"),y=R.parseStyles(t.global,"");c.writeFileSync($,`@layer global { ${y} }`);const F=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,x=R.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${x} }`);const a=s.join(i,"css/_templates.css"),m=R.parseTemplates(t.templates),_=R.getTemplateTypes(t.templates);c.writeFileSync(a,m);const P=s.join(i,"types/css-tokens.d.ts"),E=`
2
+ // Variable types
3
+ type VariableTokens = ${[...n].join("|")};
4
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
5
+
6
+ // Template types
7
+ type TemplateTokens = {
8
+ ${Object.entries(_).map(([p,d])=>`${p}?: ${d}`).join(`
9
+ `)}
10
+ }
11
+ `;c.writeFileSync(P,E)},H=async(e,t,n)=>{const o=D.toHash(t),l=s.join(n,"./temp");c.existsSync(l)||c.mkdirSync(l);const r=s.parse(t);let h=c.readFileSync(t,"utf8");h=h.replace(/styled\([^"'`{,]+,/g,"styled('div',");const S=s.join(n,"js",o+".js"),w=Y(e),i=await U(e);await G.build({stdin:{contents:h,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:i,target:["node20"],keepNames:!0,external:w,packages:"external"});const u=Date.now();return await import(`${S}?t=${u}`)},B=async e=>{const t=q(e),n=s.join(t,"salty.config.js"),o=Date.now(),{config:l}=await import(`${n}?t=${o}`);return l},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ye=async(e,t=se())=>{try{const n=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const o=[],l=[],r=q(e),h=s.join(r,"index.css");(()=>{c.existsSync(r)&&ae.execSync("rm -rf "+r),c.mkdirSync(r),c.mkdirSync(s.join(r,"css")),c.mkdirSync(s.join(r,"types"))})(),await te(e);const w=await B(e);async function i(a,m){const _=["node_modules","saltygen"],P=c.statSync(a);if(P.isDirectory()){const O=c.readdirSync(a);if(_.some(p=>a.includes(p)))return;await Promise.all(O.map(p=>i(s.join(a,p),s.join(m,p))))}else if(P.isFile()&&W(a)){const E=await H(e,a,r),p=[];Object.entries(E).forEach(([T,C])=>{if(C.isKeyframes&&C.css){const K=`a_${C.animationName}.css`,re=`css/${K}`,ie=s.join(r,re);o.push(K),c.writeFileSync(ie,C.css);return}if(!C.generator)return;const k=C.generator._withBuildContext({name:T,config:w,prod:t});l[k.priority]||(l[k.priority]=[]),l[k.priority].push(k.cssFileName),p.push(k.cssFileName);const ne=`css/${k.cssFileName}`,oe=s.join(r,ne);c.writeFileSync(oe,k.css)});const d=p.map(T=>`@import url('./${T}');`).join(`
12
+ `),b=D.toHash(a,6),f=s.parse(a),V=D.dashCase(f.name),v=s.join(r,`css/f_${V}-${b}.css`);c.writeFileSync(v,d)}}await i(e,r);const u=o.map(a=>`@import url('./css/${a}');`).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(a=>{try{return c.readFileSync(s.join(r,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
16
+ `)}
17
+ ${u}`;if(w.importStrategy!=="component"){const a=l.flat().map(m=>`@import url('./css/${m}');`).join(`
18
+ `);F+=a}c.writeFileSync(h,F);const g=Date.now()-n,x=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";J.info(`Generated CSS in ${g}ms! ${x}`)}catch(n){console.error(n)}},me=async(e,t)=>{try{const n=[],o=s.join(e,"./saltygen"),l=s.join(o,"index.css");if(W(t)){const h=await B(e),S=await H(e,t,o);Object.entries(S).forEach(([$,y])=>{if(y.isKeyframes&&y.css){const a=`css/${`a_${y.animationName}.css`}`,m=s.join(o,a);c.writeFileSync(m,y.css);return}if(!y.generator)return;const F=y.generator._withBuildContext({name:$,config:h}),N=`css/${F.cssFileName}`,g=s.join(o,N);n.push(F.cssFileName),c.writeFileSync(g,F.css)});const w=c.readFileSync(l,"utf8").split(`
19
+ `),i=n.map($=>`@import url('../saltygen/css/${$}');`),j=[...new Set([...w,...i])].join(`
20
+ `);c.writeFileSync(l,j)}}catch(n){console.error(n)}},he=async(e,t,n=se())=>{try{const o=s.join(e,"./saltygen");if(W(t)){const r=c.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==r&&await Z.writeFile(t,r);const S=await B(e),w=await H(e,t,o);let i=r;if(Object.entries(w).forEach(([u,j])=>{var b;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:u,config:S,prod:n}),y=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!y)return console.error("Could not find the original declaration");const F=(b=y.at(1))==null?void 0:b.trim(),N=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(i);if(!N)return console.error("Could not find the original declaration");const{index:g}=N;let x=!1;const a=setTimeout(()=>x=!0,5e3);let m=0,_=!1,P=0;for(;!_&&!x;){const f=i[g+m];f==="("&&P++,f===")"&&P--,P===0&&f===")"&&(_=!0),m>i.length&&(x=!0),m++}if(!x)clearTimeout(a);else throw new Error("Failed to find the end of the styled call and timed out");const O=g+m,E=i.slice(g,O),p=i,d=` ${u} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;i=i.replace(E,d),p===i&&console.error("Minimize file failed to change content",{name:u,tagName:F})}),S.importStrategy==="component"){const u=D.toHash(t,6),j=s.parse(t);i=`import '../../saltygen/css/${`f_${D.dashCase(j.name)}-${u}.css`}';
21
+ ${i}`}return i=i.replace("{ styled }","{ styledClient as styled }"),i=i.replace("@salty-css/react/styled","@salty-css/react/styled-client"),i}}catch(o){console.error("Error in minimizeFile:",o)}};exports.compileSaltyFile=H;exports.generateConfigStyles=te;exports.generateCss=ye;exports.generateFile=me;exports.isSaltyFile=W;exports.logError=de;exports.logger=J;exports.minimizeFile=he;exports.saltyFileExtensions=Q;exports.saltyFileRegExp=ee;
@@ -4,7 +4,7 @@ import { t as H, d as R } from "./dash-case-DBThphLm.js";
4
4
  import { join as o, parse as I } from "path";
5
5
  import { existsSync as K, writeFileSync as $, mkdirSync as O, readFileSync as J, statSync as it, readdirSync as lt } from "fs";
6
6
  import { readFile as pt, writeFile as ft } from "fs/promises";
7
- import { p as U, a as dt, b as gt, c as ut } from "./parse-templates-DnLWJ7Hc.js";
7
+ import { p as U, a as dt, b as ut, c as gt } from "./parse-templates-DnLWJ7Hc.js";
8
8
  import { createLogger as mt, format as A, transports as yt } from "winston";
9
9
  const Y = (t) => {
10
10
  if (!t || t === "/") throw new Error("Could not find package.json file");
@@ -32,7 +32,7 @@ const Q = async (t) => {
32
32
  z.error(t);
33
33
  };
34
34
  function tt(t) {
35
- return t ? typeof t != "string" ? tt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, r) => (r > 0 ? "." : "") + e.toLowerCase()) : "";
35
+ return t ? typeof t != "string" ? tt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, a) => (a > 0 ? "." : "") + e.toLowerCase()) : "";
36
36
  }
37
37
  const $t = {
38
38
  /** Set box model to border-box */
@@ -65,9 +65,14 @@ const $t = {
65
65
  "h1, h2, h3, h4, h5, h6": {
66
66
  textWrap: "balance"
67
67
  },
68
+ /** Improve link color */
69
+ a: {
70
+ color: "currentColor"
71
+ },
68
72
  /** Improve button line height */
69
73
  button: {
70
- lineHeight: "1em"
74
+ lineHeight: "1em",
75
+ color: "currentColor"
71
76
  },
72
77
  /** Improve form elements */
73
78
  "input, optgroup, select, textarea": {
@@ -79,48 +84,48 @@ const $t = {
79
84
  externalModules: []
80
85
  }, et = (t) => {
81
86
  if (B.externalModules.length > 0) return B.externalModules;
82
- const e = o(t, "salty.config.ts"), a = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
83
- if (!a) return [];
84
- const i = a[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
87
+ const e = o(t, "salty.config.ts"), r = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
88
+ if (!r) return [];
89
+ const i = r[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
85
90
  return B.externalModules = i, i;
86
91
  }, W = (t) => o(t, "./saltygen"), wt = ["salty", "css", "styles", "styled"], St = (t = []) => new RegExp(`\\.(${[...wt, ...t].join("|")})\\.`), Z = (t, e = []) => St(e).test(t), Ft = async (t) => {
87
- const e = W(t), r = o(t, "salty.config.ts"), a = o(e, "salty.config.js"), i = await Q(t), s = et(t);
92
+ const e = W(t), a = o(t, "salty.config.ts"), r = o(e, "salty.config.js"), i = await Q(t), s = et(t);
88
93
  await X.build({
89
- entryPoints: [r],
94
+ entryPoints: [a],
90
95
  minify: !0,
91
96
  treeShaking: !0,
92
97
  bundle: !0,
93
- outfile: a,
98
+ outfile: r,
94
99
  format: i,
95
100
  external: s
96
101
  });
97
- const y = Date.now(), { config: h } = await import(`${a}?t=${y}`);
102
+ const y = Date.now(), { config: h } = await import(`${r}?t=${y}`);
98
103
  return h;
99
104
  }, xt = async (t) => {
100
- const e = await Ft(t), r = /* @__PURE__ */ new Set(), a = (l, f = []) => l ? Object.entries(l).flatMap(([b, d]) => {
105
+ const e = await Ft(t), a = /* @__PURE__ */ new Set(), r = (l, f = []) => l ? Object.entries(l).flatMap(([b, d]) => {
101
106
  if (!d) return;
102
- if (typeof d == "object") return a(d, [...f, b]);
107
+ if (typeof d == "object") return r(d, [...f, b]);
103
108
  const V = tt(b), v = R(b), D = [...f, V].join(".");
104
- r.add(`"${D}"`);
105
- const j = [...f.map(R), v].join("-"), { result: k } = ut(d);
106
- return `--${j}: ${k};`;
109
+ a.add(`"${D}"`);
110
+ const C = [...f.map(R), v].join("-"), { result: k } = gt(d);
111
+ return `--${C}: ${k};`;
107
112
  }) : [], i = (l) => l ? Object.entries(l).flatMap(([f, b]) => {
108
- const d = a(b);
113
+ const d = r(b);
109
114
  return f === "base" ? d.join("") : `${f} { ${d.join("")} }`;
110
115
  }) : [], s = (l) => l ? Object.entries(l).flatMap(([f, b]) => Object.entries(b).flatMap(([d, V]) => {
111
- const v = a(V, [f]), D = `.${f}-${d}, [data-${f}="${d}"]`, j = v.join("");
112
- return `${D} { ${j} }`;
113
- })) : [], y = a(e.variables), h = i(e.responsiveVariables), F = s(e.conditionalVariables), n = W(t), p = o(n, "css/_variables.css"), w = `:root { ${y.join("")} ${h.join("")} } ${F.join("")}`;
116
+ const v = r(V, [f]), D = `.${f}-${d}, [data-${f}="${d}"]`, C = v.join("");
117
+ return `${D} { ${C} }`;
118
+ })) : [], y = r(e.variables), h = i(e.responsiveVariables), F = s(e.conditionalVariables), n = W(t), p = o(n, "css/_variables.css"), w = `:root { ${y.join("")} ${h.join("")} } ${F.join("")}`;
114
119
  $(p, w);
115
- const x = o(n, "css/_global.css"), u = U(e.global, "");
116
- $(x, `@layer global { ${u} }`);
117
- const S = o(n, "css/_reset.css"), g = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : $t, C = U(g, "");
118
- $(S, `@layer reset { ${C} }`);
119
- const c = o(n, "css/_templates.css"), m = dt(e.templates), N = gt(e.templates);
120
+ const x = o(n, "css/_global.css"), g = U(e.global, "");
121
+ $(x, `@layer global { ${g} }`);
122
+ const S = o(n, "css/_reset.css"), u = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : $t, j = U(u, "");
123
+ $(S, `@layer reset { ${j} }`);
124
+ const c = o(n, "css/_templates.css"), m = dt(e.templates), N = ut(e.templates);
120
125
  $(c, m);
121
126
  const P = o(n, "types/css-tokens.d.ts"), M = `
122
127
  // Variable types
123
- type VariableTokens = ${[...r].join("|")};
128
+ type VariableTokens = ${[...a].join("|")};
124
129
  type PropertyValueToken = \`{\${VariableTokens}}\`;
125
130
 
126
131
  // Template types
@@ -130,13 +135,13 @@ const $t = {
130
135
  }
131
136
  `;
132
137
  $(P, M);
133
- }, G = async (t, e, r) => {
134
- const a = H(e), i = o(r, "./temp");
138
+ }, G = async (t, e, a) => {
139
+ const r = H(e), i = o(a, "./temp");
135
140
  K(i) || O(i);
136
141
  const s = I(e);
137
142
  let y = J(e, "utf8");
138
143
  y = y.replace(/styled\([^"'`{,]+,/g, "styled('div',");
139
- const h = o(r, "js", a + ".js"), F = et(t), n = await Q(t);
144
+ const h = o(a, "js", r + ".js"), F = et(t), n = await Q(t);
140
145
  await X.build({
141
146
  stdin: {
142
147
  contents: y,
@@ -157,7 +162,7 @@ const $t = {
157
162
  const p = Date.now();
158
163
  return await import(`${h}?t=${p}`);
159
164
  }, L = async (t) => {
160
- const e = W(t), r = o(e, "salty.config.js"), a = Date.now(), { config: i } = await import(`${r}?t=${a}`);
165
+ const e = W(t), a = o(e, "salty.config.js"), r = Date.now(), { config: i } = await import(`${a}?t=${r}`);
161
166
  return i;
162
167
  }, st = () => {
163
168
  try {
@@ -167,9 +172,9 @@ const $t = {
167
172
  }
168
173
  }, _t = async (t, e = st()) => {
169
174
  try {
170
- const r = Date.now();
175
+ const a = Date.now();
171
176
  e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
172
- const a = [], i = [], s = W(t), y = o(s, "index.css");
177
+ const r = [], i = [], s = W(t), y = o(s, "index.css");
173
178
  (() => {
174
179
  K(s) && ct("rm -rf " + s), O(s), O(o(s, "css")), O(o(s, "types"));
175
180
  })(), await xt(t);
@@ -182,14 +187,14 @@ const $t = {
182
187
  await Promise.all(E.map((l) => n(o(c, l), o(m, l))));
183
188
  } else if (P.isFile() && Z(c)) {
184
189
  const M = await G(t, c, s), l = [];
185
- Object.entries(M).forEach(([D, j]) => {
186
- if (j.isKeyframes && j.css) {
187
- const q = `a_${j.animationName}.css`, at = `css/${q}`, rt = o(s, at);
188
- a.push(q), $(rt, j.css);
190
+ Object.entries(M).forEach(([D, C]) => {
191
+ if (C.isKeyframes && C.css) {
192
+ const q = `a_${C.animationName}.css`, rt = `css/${q}`, at = o(s, rt);
193
+ r.push(q), $(at, C.css);
189
194
  return;
190
195
  }
191
- if (!j.generator) return;
192
- const k = j.generator._withBuildContext({
196
+ if (!C.generator) return;
197
+ const k = C.generator._withBuildContext({
193
198
  name: D,
194
199
  config: F,
195
200
  prod: e
@@ -204,7 +209,7 @@ const $t = {
204
209
  }
205
210
  }
206
211
  await n(t, s);
207
- const p = a.map((c) => `@import url('./css/${c}');`).join(`
212
+ const p = r.map((c) => `@import url('./css/${c}');`).join(`
208
213
  `);
209
214
  let S = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
210
215
 
@@ -223,44 +228,44 @@ ${p}`;
223
228
  S += c;
224
229
  }
225
230
  $(y, S);
226
- const g = Date.now() - r, C = g < 200 ? "🔥" : g < 500 ? "🚀" : g < 1e3 ? "🎉" : g < 2e3 ? "🚗" : g < 5e3 ? "🤔" : "🥴";
227
- z.info(`Generated CSS in ${g}ms! ${C}`);
228
- } catch (r) {
229
- console.error(r);
231
+ const u = Date.now() - a, j = u < 200 ? "🔥" : u < 500 ? "🚀" : u < 1e3 ? "🎉" : u < 2e3 ? "🚗" : u < 5e3 ? "🤔" : "🥴";
232
+ z.info(`Generated CSS in ${u}ms! ${j}`);
233
+ } catch (a) {
234
+ console.error(a);
230
235
  }
231
236
  }, Et = async (t, e) => {
232
237
  try {
233
- const r = [], a = o(t, "./saltygen"), i = o(a, "index.css");
238
+ const a = [], r = o(t, "./saltygen"), i = o(r, "index.css");
234
239
  if (Z(e)) {
235
- const y = await L(t), h = await G(t, e, a);
236
- Object.entries(h).forEach(([x, u]) => {
237
- if (u.isKeyframes && u.css) {
238
- const c = `css/${`a_${u.animationName}.css`}`, m = o(a, c);
239
- $(m, u.css);
240
+ const y = await L(t), h = await G(t, e, r);
241
+ Object.entries(h).forEach(([x, g]) => {
242
+ if (g.isKeyframes && g.css) {
243
+ const c = `css/${`a_${g.animationName}.css`}`, m = o(r, c);
244
+ $(m, g.css);
240
245
  return;
241
246
  }
242
- if (!u.generator) return;
243
- const S = u.generator._withBuildContext({
247
+ if (!g.generator) return;
248
+ const S = g.generator._withBuildContext({
244
249
  name: x,
245
250
  config: y
246
- }), T = `css/${S.cssFileName}`, g = o(a, T);
247
- r.push(S.cssFileName), $(g, S.css);
251
+ }), T = `css/${S.cssFileName}`, u = o(r, T);
252
+ a.push(S.cssFileName), $(u, S.css);
248
253
  });
249
254
  const F = J(i, "utf8").split(`
250
- `), n = r.map((x) => `@import url('../saltygen/css/${x}');`), w = [.../* @__PURE__ */ new Set([...F, ...n])].join(`
255
+ `), n = a.map((x) => `@import url('../saltygen/css/${x}');`), w = [.../* @__PURE__ */ new Set([...F, ...n])].join(`
251
256
  `);
252
257
  $(i, w);
253
258
  }
254
- } catch (r) {
255
- console.error(r);
259
+ } catch (a) {
260
+ console.error(a);
256
261
  }
257
- }, Vt = async (t, e, r = st()) => {
262
+ }, Vt = async (t, e, a = st()) => {
258
263
  try {
259
- const a = o(t, "./saltygen");
264
+ const r = o(t, "./saltygen");
260
265
  if (Z(e)) {
261
266
  const s = J(e, "utf8");
262
267
  s.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== s && await ft(e, s);
263
- const h = await L(t), F = await G(t, e, a);
268
+ const h = await L(t), F = await G(t, e, r);
264
269
  let n = s;
265
270
  if (Object.entries(F).forEach(([p, w]) => {
266
271
  var b;
@@ -268,22 +273,22 @@ ${p}`;
268
273
  const x = w.generator._withBuildContext({
269
274
  name: p,
270
275
  config: h,
271
- prod: r
272
- }), u = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
273
- if (!u) return console.error("Could not find the original declaration");
274
- const S = (b = u.at(1)) == null ? void 0 : b.trim(), T = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
276
+ prod: a
277
+ }), g = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
278
+ if (!g) return console.error("Could not find the original declaration");
279
+ const S = (b = g.at(1)) == null ? void 0 : b.trim(), T = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
275
280
  if (!T) return console.error("Could not find the original declaration");
276
- const { index: g } = T;
277
- let C = !1;
278
- const c = setTimeout(() => C = !0, 5e3);
281
+ const { index: u } = T;
282
+ let j = !1;
283
+ const c = setTimeout(() => j = !0, 5e3);
279
284
  let m = 0, N = !1, P = 0;
280
- for (; !N && !C; ) {
281
- const d = n[g + m];
282
- d === "(" && P++, d === ")" && P--, P === 0 && d === ")" && (N = !0), m > n.length && (C = !0), m++;
285
+ for (; !N && !j; ) {
286
+ const d = n[u + m];
287
+ d === "(" && P++, d === ")" && P--, P === 0 && d === ")" && (N = !0), m > n.length && (j = !0), m++;
283
288
  }
284
- if (!C) clearTimeout(c);
289
+ if (!j) clearTimeout(c);
285
290
  else throw new Error("Failed to find the end of the styled call and timed out");
286
- const E = g + m, M = n.slice(g, E), l = n, f = ` ${p} = styled(${S}, "${x.classNames}", ${JSON.stringify(x.props)});`;
291
+ const E = u + m, M = n.slice(u, E), l = n, f = ` ${p} = styled(${S}, "${x.classNames}", ${JSON.stringify(x.props)});`;
287
292
  n = n.replace(M, f), l === n && console.error("Minimize file failed to change content", { name: p, tagName: S });
288
293
  }), h.importStrategy === "component") {
289
294
  const p = H(e, 6), w = I(e);
@@ -292,8 +297,8 @@ ${n}`;
292
297
  }
293
298
  return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
294
299
  }
295
- } catch (a) {
296
- console.error("Error in minimizeFile:", a);
300
+ } catch (r) {
301
+ console.error("Error in minimizeFile:", r);
297
302
  }
298
303
  };
299
304
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.132",
3
+ "version": "0.0.1-alpha.133",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -1,21 +0,0 @@
1
- "use strict";const ce=require("esbuild"),ae=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),R=require("./parse-templates-DdYSw-iq.cjs"),z=require("winston");var I=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const G=le(ce),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:L(s.join(e,".."))},pe=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},de=async e=>{const t=await pe(e);if(t)return t.type};let M;const U=async e=>{if(M)return M;const t=await de(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-Bl6Ocgz0.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),ue=e=>{J.error(e)};function X(e){return e?typeof e!="string"?X(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const fe={"*, *::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"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},Y=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const l=o[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return A.externalModules=l,l},q=e=>s.join(e,"./saltygen"),Q=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...Q,...e].join("|")})\\.`),W=(e,t=[])=>ee(t).test(e),ge=async e=>{const t=q(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),l=await U(e),i=Y(e);await G.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:l,external:i});const h=Date.now(),{config:S}=await import(`${o}?t=${h}`);return S},te=async e=>{const t=await ge(e),n=new Set,o=(p,u=[])=>p?Object.entries(p).flatMap(([b,f])=>{if(!f)return;if(typeof f=="object")return o(f,[...u,b]);const V=X(b),v=D.dashCase(b),T=[...u,V].join(".");n.add(`"${T}"`);const C=[...u.map(D.dashCase),v].join("-"),{result:k}=R.parseValueTokens(f);return`--${C}: ${k};`}):[],l=p=>p?Object.entries(p).flatMap(([u,b])=>{const f=o(b);return u==="base"?f.join(""):`${u} { ${f.join("")} }`}):[],i=p=>p?Object.entries(p).flatMap(([u,b])=>Object.entries(b).flatMap(([f,V])=>{const v=o(V,[u]),T=`.${u}-${f}, [data-${u}="${f}"]`,C=v.join("");return`${T} { ${C} }`})):[],h=o(t.variables),S=l(t.responsiveVariables),w=i(t.conditionalVariables),r=q(e),d=s.join(r,"css/_variables.css"),j=`:root { ${h.join("")} ${S.join("")} } ${w.join("")}`;c.writeFileSync(d,j);const $=s.join(r,"css/_global.css"),y=R.parseStyles(t.global,"");c.writeFileSync($,`@layer global { ${y} }`);const F=s.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,x=R.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${x} }`);const a=s.join(r,"css/_templates.css"),m=R.parseTemplates(t.templates),_=R.getTemplateTypes(t.templates);c.writeFileSync(a,m);const P=s.join(r,"types/css-tokens.d.ts"),E=`
2
- // Variable types
3
- type VariableTokens = ${[...n].join("|")};
4
- type PropertyValueToken = \`{\${VariableTokens}}\`;
5
-
6
- // Template types
7
- type TemplateTokens = {
8
- ${Object.entries(_).map(([p,u])=>`${p}?: ${u}`).join(`
9
- `)}
10
- }
11
- `;c.writeFileSync(P,E)},H=async(e,t,n)=>{const o=D.toHash(t),l=s.join(n,"./temp");c.existsSync(l)||c.mkdirSync(l);const i=s.parse(t);let h=c.readFileSync(t,"utf8");h=h.replace(/styled\([^"'`{,]+,/g,"styled('div',");const S=s.join(n,"js",o+".js"),w=Y(e),r=await U(e);await G.build({stdin:{contents:h,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:r,target:["node20"],keepNames:!0,external:w,packages:"external"});const d=Date.now();return await import(`${S}?t=${d}`)},B=async e=>{const t=q(e),n=s.join(t,"salty.config.js"),o=Date.now(),{config:l}=await import(`${n}?t=${o}`);return l},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ye=async(e,t=se())=>{try{const n=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const o=[],l=[],i=q(e),h=s.join(i,"index.css");(()=>{c.existsSync(i)&&ae.execSync("rm -rf "+i),c.mkdirSync(i),c.mkdirSync(s.join(i,"css")),c.mkdirSync(s.join(i,"types"))})(),await te(e);const w=await B(e);async function r(a,m){const _=["node_modules","saltygen"],P=c.statSync(a);if(P.isDirectory()){const O=c.readdirSync(a);if(_.some(p=>a.includes(p)))return;await Promise.all(O.map(p=>r(s.join(a,p),s.join(m,p))))}else if(P.isFile()&&W(a)){const E=await H(e,a,i),p=[];Object.entries(E).forEach(([T,C])=>{if(C.isKeyframes&&C.css){const K=`a_${C.animationName}.css`,ie=`css/${K}`,re=s.join(i,ie);o.push(K),c.writeFileSync(re,C.css);return}if(!C.generator)return;const k=C.generator._withBuildContext({name:T,config:w,prod:t});l[k.priority]||(l[k.priority]=[]),l[k.priority].push(k.cssFileName),p.push(k.cssFileName);const ne=`css/${k.cssFileName}`,oe=s.join(i,ne);c.writeFileSync(oe,k.css)});const u=p.map(T=>`@import url('./${T}');`).join(`
12
- `),b=D.toHash(a,6),f=s.parse(a),V=D.dashCase(f.name),v=s.join(i,`css/f_${V}-${b}.css`);c.writeFileSync(v,u)}}await r(e,i);const d=o.map(a=>`@import url('./css/${a}');`).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(a=>{try{return c.readFileSync(s.join(i,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
16
- `)}
17
- ${d}`;if(w.importStrategy!=="component"){const a=l.flat().map(m=>`@import url('./css/${m}');`).join(`
18
- `);F+=a}c.writeFileSync(h,F);const g=Date.now()-n,x=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";J.info(`Generated CSS in ${g}ms! ${x}`)}catch(n){console.error(n)}},me=async(e,t)=>{try{const n=[],o=s.join(e,"./saltygen"),l=s.join(o,"index.css");if(W(t)){const h=await B(e),S=await H(e,t,o);Object.entries(S).forEach(([$,y])=>{if(y.isKeyframes&&y.css){const a=`css/${`a_${y.animationName}.css`}`,m=s.join(o,a);c.writeFileSync(m,y.css);return}if(!y.generator)return;const F=y.generator._withBuildContext({name:$,config:h}),N=`css/${F.cssFileName}`,g=s.join(o,N);n.push(F.cssFileName),c.writeFileSync(g,F.css)});const w=c.readFileSync(l,"utf8").split(`
19
- `),r=n.map($=>`@import url('../saltygen/css/${$}');`),j=[...new Set([...w,...r])].join(`
20
- `);c.writeFileSync(l,j)}}catch(n){console.error(n)}},he=async(e,t,n=se())=>{try{const o=s.join(e,"./saltygen");if(W(t)){const i=c.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==i&&await Z.writeFile(t,i);const S=await B(e),w=await H(e,t,o);let r=i;if(Object.entries(w).forEach(([d,j])=>{var b;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:d,config:S,prod:n}),y=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!y)return console.error("Could not find the original declaration");const F=(b=y.at(1))==null?void 0:b.trim(),N=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(r);if(!N)return console.error("Could not find the original declaration");const{index:g}=N;let x=!1;const a=setTimeout(()=>x=!0,5e3);let m=0,_=!1,P=0;for(;!_&&!x;){const f=r[g+m];f==="("&&P++,f===")"&&P--,P===0&&f===")"&&(_=!0),m>r.length&&(x=!0),m++}if(!x)clearTimeout(a);else throw new Error("Failed to find the end of the styled call and timed out");const O=g+m,E=r.slice(g,O),p=r,u=` ${d} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;r=r.replace(E,u),p===r&&console.error("Minimize file failed to change content",{name:d,tagName:F})}),S.importStrategy==="component"){const d=D.toHash(t,6),j=s.parse(t);r=`import '../../saltygen/css/${`f_${D.dashCase(j.name)}-${d}.css`}';
21
- ${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(o){console.error("Error in minimizeFile:",o)}};exports.compileSaltyFile=H;exports.generateConfigStyles=te;exports.generateCss=ye;exports.generateFile=me;exports.isSaltyFile=W;exports.logError=ue;exports.logger=J;exports.minimizeFile=he;exports.saltyFileExtensions=Q;exports.saltyFileRegExp=ee;