@salty-css/core 0.0.1-alpha.232 → 0.0.1-alpha.234

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"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-q4N-TRZZ.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-CNiSFD9q.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,x=>{if(x)return P(x);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(),x=y.join(" ");await X(`npm install ${x}`),P.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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:f}=await C[i],d=ne.render(f,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,f=process.cwd();return n.join(f,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:f=i,cssFile:d,skipInstall:p}=this.opts();if(!f)return e.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 c=process.cwd(),r=H(f),q=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),g=await s.readFile(h,"utf-8").catch(()=>{});if(g===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(g),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==g&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-AIl-HgpW.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-lhNr1-w7.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,x=>{if(x)return P(x);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(),x=y.join(" ");await X(`npm install ${x}`),P.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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:f}=await C[i],d=ne.render(f,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,f=process.cwd();return n.join(f,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:f=i,cssFile:d,skipInstall:p}=this.opts();if(!f)return e.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 c=process.cwd(),r=H(f),q=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),g=await s.readFile(h,"utf-8").catch(()=>{});if(g===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(g),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==g&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
package/bin/main.js CHANGED
@@ -3,11 +3,11 @@ import { existsSync as Q, watch as re } from "fs";
3
3
  import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
4
4
  import { join as a, relative as z, parse as ce, format as te } from "path";
5
5
  import { render as le } from "ejs";
6
- import { l as t, a as h, g as K, i as de, b as fe } from "../index-B_l52ZKf.js";
6
+ import { l as t, a as h, g as K, i as de, b as fe } from "../index-D6UVbPah.js";
7
7
  import { p as pe } from "../pascal-case-BQpR5PdN.js";
8
8
  import { exec as ue } from "child_process";
9
9
  import ge from "ora";
10
- import { c as ye } from "../should-restart-mA0gAeEm.js";
10
+ import { c as ye } from "../should-restart-0ZMFyli-.js";
11
11
  const ne = (g) => new Promise((P, x) => {
12
12
  ue(g, ($) => {
13
13
  if ($) return x($);
@@ -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-styles-3N79AOBO.cjs");const e=require("../index-q4N-TRZZ.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.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-styles-3N79AOBO.cjs");const e=require("../index-AIl-HgpW.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.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-styles-Bo7fQ_SV.js";
8
- import { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-B_l52ZKf.js";
8
+ import { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-D6UVbPah.js";
9
9
  import "../css/merge.js";
10
10
  import "../define-templates-4A2yHcMF.js";
11
11
  export {
@@ -0,0 +1,38 @@
1
+ "use strict";const _e=require("esbuild"),Te=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),c=require("fs"),he=require("fs/promises"),ee=require("./parse-styles-3N79AOBO.cjs"),G=require("winston"),M=require("./css/merge.cjs"),Oe=require("./define-templates-Cunsb_Tr.cjs"),ae=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Ee(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 we=Ee(_e),Se=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(),d=await Se(i,[...t,a]);s.push(d)}else n[o]=i;if(Object.keys(n).length){const o=t.map(D.dashCase).join("-"),i="t_"+D.toHash(o,4),a=await ee.parseAndJoinStyles(n,`.${o}, .${i}`);s.push(a)}return s.join(`
2
+ `)},ve=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=je(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},je=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?je(o,i,s):s.add(t)}),[...s]):[],be=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:be(r.join(e,".."))},Ve=async e=>{const t=be(e);return await he.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Re=async e=>{const t=await Ve(e);if(t)return t.type};let q;const $e=async e=>{if(q)return q;const t=await Re(e);return t==="module"?q="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-AIl-HgpW.cjs",document.baseURI).href).endsWith(".cjs"))&&(q="cjs"),q||"esm"},K=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]}),Me=e=>{K.error(e)};function Fe(e){return e?typeof e!="string"?Fe(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 Je={"*, *::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"}},ze=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),i=ae.createSourceFile("temp.ts",e,ae.ScriptTarget.Latest,!0);function a(d){if(ae.isVariableDeclaration(d)&&d.name.getText()===t){const g=d.getStart(),m=d.getEnd();clearTimeout(o),s([g,m])}d.forEachChild(a)}a(i)}),E={externalModules:[],rcFile:void 0,destDir:void 0},Ce=e=>{if(E.externalModules.length>0)return E.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 E.externalModules=n,n},J=async e=>{if(E.destDir)return E.destDir;const t=await le(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},ce=["salty","css","styles","styled"],Pe=(e=[])=>new RegExp(`\\.(${[...ce,...e].join("|")})\\.`),te=(e,t=[])=>Pe(t).test(e),Ne=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await he.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):Ne(r.join(e,".."))},le=async e=>{var n,o;const t=await Ne(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))},qe=async e=>{const t=await le(e),s=await J(e),n=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=r.join(s,"salty.config.js"),i=await $e(e),a=Ce(n);await we.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:a});const d=Date.now(),{config:g}=await import(`${o}?t=${d}`);return{config:g,path:o}},ke=async(e,t)=>{var de,me;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:$,outputFilePath:A}=await B(e,S,s);Object.entries($).forEach(([O,P])=>{P.isMedia?n.mediaQueries.push([O,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${O};;${A}`))})}));const{config:o,path:i}=await qe(e),a={...o},d=new Set,g=async(S,$=[])=>{if(!S)return[];const A=Object.entries(S).map(async([P,z])=>{const X=async _=>{if(!_)return;if(_ instanceof Promise)return await X(await _);if(typeof _=="function")return await X(await _());if(typeof _=="object")return await g(_,[...$,P]);const ne=Fe(P),oe=D.dashCase(P),ie=[...$,ne].join(".");d.add(`"${ie}"`);const Y=[...$.map(D.dashCase),oe].join("-"),ye=ee.parseVariableTokens(_);return ye?`--${Y}: ${ye.transformed};`:`--${Y}: ${_};`};return await X(z)});return(await Promise.all(A)).flat()},m=async S=>{if(!S)return[];const $=Object.entries(S).map(async([O,P])=>{const z=await g(P);return O==="base"?z.join(""):`${O} { ${z.join("")} }`});return(await Promise.all($)).flat()},l=async S=>{if(!S)return[];const $=Object.entries(S).map(async([O,P])=>{const z=Object.entries(P).map(async([_,ne])=>{const oe=await g(ne,[O]),ie=`.${O}-${_}, [data-${O}="${_}"]`,Y=oe.join("");return`${ie} { ${Y} }`});return(await Promise.all(z)).flat()});return(await Promise.all($)).flat()},h=S=>({...S,responsive:void 0,conditional:void 0}),p=S=>n.variables.map($=>S==="static"?h($._current):$._current[S]),w=M.mergeObjects(h(o.variables),p("static")),y=await g(w),F=M.mergeObjects((de=o.variables)==null?void 0:de.responsive,p("responsive")),k=await m(F),x=M.mergeObjects((me=o.variables)==null?void 0:me.conditional,p("conditional")),v=await l(x),V=r.join(s,"css/_variables.css"),pe=`:root { ${y.join("")} ${k.join("")} } ${v.join("")}`;c.writeFileSync(V,pe),a.staticVariables=w;const R=r.join(s,"css/_global.css"),se=M.mergeObjects(o.global,n.globalStyles),u=await ee.parseAndJoinStyles(se,"");c.writeFileSync(R,`@layer global { ${u} }`);const j=r.join(s,"css/_reset.css"),f=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Je,C=await ee.parseAndJoinStyles(f,"");c.writeFileSync(j,`@layer reset { ${C} }`);const N=r.join(s,"css/_templates.css"),T=M.mergeObjects(o.templates,n.templates),H=await Se(T),W=ve(T);c.writeFileSync(N,`@layer templates { ${H} }`),a.templates=T;const I=o.templates?[Oe.defineTemplates(o.templates)._setPath(`config;;${i}`)]:[],Q=M.mergeFactories(n.templates,I);a.templatePaths=Object.fromEntries(Object.entries(Q).map(([S,$])=>[S,$._path]));const{mediaQueries:Z}=n;a.mediaQueries=Object.fromEntries(Z.map(([S,$])=>[`@${S}`,$]));const L=Z.map(([S])=>`'@${S}'`).join(" | "),U=r.join(s,"types/css-tokens.d.ts"),xe=`
3
+ // Variable types
4
+ type VariableTokens = ${[...d].join("|")};
5
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
6
+
7
+ // Template types
8
+ type TemplateTokens = {
9
+ ${Object.entries(W).map(([S,$])=>`${S}?: ${$}`).join(`
10
+ `)}
11
+ }
12
+
13
+ // Media query types
14
+ type MediaQueryKeys = ${L||"''"};
15
+ `;c.writeFileSync(U,xe);const De=r.join(s,"cache/config-cache.json");c.writeFileSync(De,JSON.stringify(a,null,2))},ge=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 d=a.at(1);if(ce.some(m=>d==null?void 0:d.includes(m)))return t}return"styled('div',"}),He=(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}},B=async(e,t,s)=>{const n=D.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=ge(a),a=He(a,e);const d=r.join(s,"js",n+".js"),g=await le(e),m=r.join(e,(g==null?void 0:g.configDir)||"","salty.config.ts"),l=Ce(m),h=await $e(e);await we.build({stdin:{contents:a,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:h,target:["node20"],keepNames:!0,external:l,packages:"external",plugins:[{name:"test",setup:y=>{y.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},F=>{const k=c.readFileSync(F.path,"utf8");return{contents:ge(k),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${d}?t=${p}`),outputFilePath:d}},We=async e=>{const t=await J(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)},fe=async e=>{const t=await We(e),s=await J(e),n=r.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return M.mergeObjects(i,t)},ue=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ie=async(e,t=ue(),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 J(e),d=r.join(a,"index.css");s&&(()=>{c.existsSync(a)&&Te.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 m=new Set,l=new Set;async function h(u){const j=["node_modules","saltygen"],b=c.statSync(u);if(b.isDirectory()){const f=c.readdirSync(u);if(j.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>h(r.join(u,N))))}else if(b.isFile()&&te(u)){m.add(u);const C=c.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&l.add(u)}}await h(e),await ke(e,l);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...m].map(async u=>{const{contents:j}=await B(e,u,a);for(let[b,f]of Object.entries(j))f instanceof Promise&&(f=await f),f.isKeyframes?p.keyframes.push({value:f,src:u,name:b}):f.isClassName?p.classNames.push({...f,src:u,name:b}):f.generator&&p.components.push({...f,src:u,name:b})}));const w=await fe(e);for(const u of p.keyframes){const{value:j}=u,b=`a_${j.animationName}.css`,f=`css/${b}`,C=r.join(a,f);o.push(b),c.writeFileSync(C,j.css)}const y={};for(const u of p.components){const{src:j,name:b}=u;y[j]||(y[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:w});i[f.priority]||(i[f.priority]=[]);const C=await f.css;if(!C)continue;i[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,T=r.join(a,N);c.writeFileSync(T,C),w.importStrategy==="component"&&y[j].push(f.cssFileName)}for(const u of p.classNames){const{src:j,name:b}=u;y[j]||(y[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:w}),C=await f.css;if(!C)continue;i[f.priority]||(i[f.priority]=[]),i[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,T=r.join(a,N);c.writeFileSync(T,C),w.importStrategy==="component"&&y[j].push(f.cssFileName)}w.importStrategy==="component"&&Object.entries(y).forEach(([u,j])=>{const b=j.map(H=>`@import url('./${H}');`).join(`
20
+ `),f=D.toHash(u,6),C=r.parse(u),N=D.dashCase(C.name),T=r.join(a,`css/f_${N}-${f}.css`);c.writeFileSync(T,b||"/* Empty file */")});const F=o.map(u=>`@import url('./css/${u}');`).join(`
21
+ `);let V=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
+
23
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(u=>{try{return c.readFileSync(r.join(a,"css",u),"utf8").length>0}catch{return!1}}).map(u=>`@import url('./css/${u}');`).join(`
24
+ `)}
25
+ ${F}`;if(w.importStrategy!=="component"){const u=i.reduce((j,b,f)=>{const C=b.reduce((W,I)=>{var U;const Q=r.join(a,"css",I),Z=c.readFileSync(Q,"utf8"),L=((U=/.*-([^-]+)-\d+.css/.exec(I))==null?void 0:U.at(1))||D.toHash(Q,6);return W.includes(L)?W:`${W}
26
+ /*start:${L}-${I}*/
27
+ ${Z}
28
+ /*end:${L}*/
29
+ `},""),N=`l_${f}.css`,T=r.join(a,"css",N),H=`@layer l${f} { ${C}
30
+ }`;return c.writeFileSync(T,H),`${j}
31
+ @import url('./css/${N}');`},"");V+=u}c.writeFileSync(d,V);const R=Date.now()-n,se=R<200?"🔥":R<500?"🚀":R<1e3?"🎉":R<2e3?"🚗":R<5e3?"🤔":"🥴";K.info(`Generated CSS in ${R}ms! ${se}`)}catch(n){console.error(n)}},Le=async(e,t,s=ue())=>{try{const n=await J(e);if(te(t)){const i=[],a=await fe(e),{contents:d}=await B(e,t,n);for(const[g,m]of Object.entries(d)){if(m.isKeyframes&&m.css){const F=`css/${`a_${m.animationName}.css`}`,k=r.join(n,F);c.writeFileSync(k,await m.css);return}if(m.isClassName){const y=m.generator._withBuildContext({callerName:g,isProduction:s,config:a}),F=await y.css;if(!F)continue;i[y.priority]||(i[y.priority]=[]),i[y.priority].push(y.cssFileName);const k=`css/${y.cssFileName}`,x=r.join(n,k);c.writeFileSync(x,F)}if(!m.generator)return;const l=m.generator._withBuildContext({callerName:g,isProduction:s,config:a}),h=await l.css;if(!h)continue;const p=`css/${l.cssFileName}`,w=r.join(n,p);c.writeFileSync(w,h),i[l.priority]||(i[l.priority]=[]),i[l.priority].push(l.cssFileName)}if(a.importStrategy!=="component")i.forEach((g,m)=>{const l=`l_${m}.css`,h=r.join(n,"css",l);let p=c.readFileSync(h,"utf8");g.forEach(w=>{var x;const y=r.join(n,"css",w),F=((x=/.*-([^-]+)-\d+.css/.exec(w))==null?void 0:x.at(1))||D.toHash(y,6);if(!p.includes(F)){const v=c.readFileSync(y,"utf8"),V=`/*start:${F}-${w}*/
32
+ ${v}
33
+ /*end:${F}*/
34
+ `;p=`${p.replace(/\}$/,"")}
35
+ ${V}
36
+ }`}}),c.writeFileSync(h,p)});else{const g=i.flat().map(w=>`@import url('./${w}');`).join(`
37
+ `),m=D.toHash(t,6),l=r.parse(t),h=D.dashCase(l.name),p=r.join(n,`css/f_${h}-${m}.css`);c.writeFileSync(p,g||"/* Empty file */")}}}catch(n){console.error(n)}},Ae=async(e,t,s=ue())=>{var n,o;try{const i=await J(e);if(te(t)){const d=c.readFileSync(t,"utf8"),g=await fe(e),{contents:m}=await B(e,t,i);let l=d;for(const[h,p]of Object.entries(m)){if(p.isKeyframes||!p.generator)continue;const w=p.generator._withBuildContext({callerName:h,isProduction:s,config:g}),[y,F]=await ze(l,h),k=l.slice(y,F);if(p.isClassName){const x=l,v=` ${h} = className("${w.classNames}")`;l=l.replace(k,v),x===l&&console.error("Minimize file failed to change content",{name:h})}if(k.includes("styled")){const x=(o=(n=/styled\(([^,]+),/.exec(k))==null?void 0:n.at(1))==null?void 0:o.trim(),v=l,V=` ${h} = styled(${x}, "${w.classNames}", ${JSON.stringify(w.clientProps)})`;l=l.replace(k,V),v===l&&console.error("Minimize file failed to change content",{name:h,tagName:x})}}if(g.importStrategy==="component"){const h=D.toHash(t,6),p=r.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(p.name)}-${h}.css`}';
38
+ ${l}`}return l=l.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(i){console.error("Error in minimizeFile:",i)}};exports.compileSaltyFile=B;exports.generateConfigStyles=ke;exports.generateCss=Ie;exports.generateFile=Le;exports.isSaltyFile=te;exports.logError=Me;exports.logger=K;exports.minimizeFile=Ae;exports.saltyFileExtensions=ce;exports.saltyFileRegExp=Pe;
@@ -1,61 +1,61 @@
1
- import * as gt from "esbuild";
2
- import { execSync as Dt } from "child_process";
3
- import { d as H, t as R } from "./dash-case-DBThphLm.js";
4
- import { join as c, parse as X } from "path";
5
- import { existsSync as it, writeFileSync as C, mkdirSync as W, readFileSync as _, statSync as kt, readdirSync as Tt } from "fs";
6
- import { readFile as ht } from "fs/promises";
7
- import { p as at, a as _t } from "./parse-styles-Bo7fQ_SV.js";
8
- import { createLogger as vt, format as nt, transports as Et } from "winston";
9
- import { mergeObjects as G, mergeFactories as Vt } from "./css/merge.js";
10
- import { d as Ot } from "./define-templates-4A2yHcMF.js";
11
- import ot from "typescript";
12
- const $t = async (t, e = []) => {
1
+ import * as bt from "esbuild";
2
+ import { execSync as Vt } from "child_process";
3
+ import { d as I, t as R } from "./dash-case-DBThphLm.js";
4
+ import { join as c, parse as et } from "path";
5
+ import { existsSync as ft, writeFileSync as C, mkdirSync as G, readFileSync as _, statSync as Et, readdirSync as vt } from "fs";
6
+ import { readFile as St } from "fs/promises";
7
+ import { p as lt, a as Ot } from "./parse-styles-Bo7fQ_SV.js";
8
+ import { createLogger as Mt, format as ct, transports as Rt } from "winston";
9
+ import { mergeObjects as H, mergeFactories as Jt } from "./css/merge.js";
10
+ import { d as zt } from "./define-templates-4A2yHcMF.js";
11
+ import rt from "typescript";
12
+ const Ct = async (t, e = []) => {
13
13
  if (!t) return "";
14
14
  const s = [], n = {};
15
15
  for (const [o, a] of Object.entries(t))
16
16
  if (typeof a != "function") if (a && typeof a == "object") {
17
- const i = o.trim(), p = await $t(a, [...e, i]);
17
+ const i = o.trim(), p = await Ct(a, [...e, i]);
18
18
  s.push(p);
19
19
  } else
20
20
  n[o] = a;
21
21
  if (Object.keys(n).length) {
22
- const o = e.map(H).join("-"), a = "t_" + R(o, 4), i = await at(n, `.${o}, .${a}`);
22
+ const o = e.map(I).join("-"), a = "t_" + R(o, 4), i = await lt(n, `.${o}, .${a}`);
23
23
  s.push(i);
24
24
  }
25
25
  return s.join(`
26
26
  `);
27
- }, Mt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = bt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, bt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
27
+ }, Wt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = jt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, jt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
28
28
  const a = e ? `${e}.${n}` : n;
29
- return typeof o == "object" ? bt(o, a, s) : s.add(e);
30
- }), [...s]) : [], wt = (t) => {
29
+ return typeof o == "object" ? jt(o, a, s) : s.add(e);
30
+ }), [...s]) : [], Ft = (t) => {
31
31
  if (!t || t === "/") throw new Error("Could not find package.json file");
32
32
  const e = c(t, "package.json");
33
- return it(e) ? e : wt(c(t, ".."));
34
- }, Rt = async (t) => {
35
- const e = wt(t);
36
- return await ht(e, "utf-8").then(JSON.parse).catch(() => {
33
+ return ft(e) ? e : Ft(c(t, ".."));
34
+ }, Gt = async (t) => {
35
+ const e = Ft(t);
36
+ return await St(e, "utf-8").then(JSON.parse).catch(() => {
37
37
  });
38
- }, Jt = async (t) => {
39
- const e = await Rt(t);
38
+ }, Ht = async (t) => {
39
+ const e = await Gt(t);
40
40
  if (e)
41
41
  return e.type;
42
42
  };
43
- let z;
44
- const St = async (t) => {
45
- if (z) return z;
46
- const e = await Jt(t);
47
- return e === "module" ? z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (z = "cjs"), z || "esm";
48
- }, U = vt({
43
+ let W;
44
+ const Pt = async (t) => {
45
+ if (W) return W;
46
+ const e = await Ht(t);
47
+ return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
48
+ }, tt = Mt({
49
49
  level: "debug",
50
- format: nt.combine(nt.colorize(), nt.cli()),
51
- transports: [new Et.Console({})]
52
- }), ne = (t) => {
53
- U.error(t);
50
+ format: ct.combine(ct.colorize(), ct.cli()),
51
+ transports: [new Rt.Console({})]
52
+ }), ce = (t) => {
53
+ tt.error(t);
54
54
  };
55
- function Ct(t) {
56
- return t ? typeof t != "string" ? Ct(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
55
+ function Nt(t) {
56
+ return t ? typeof t != "string" ? Nt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
57
57
  }
58
- const zt = {
58
+ const It = {
59
59
  /** Set box model to border-box */
60
60
  "*, *::before, *::after": {
61
61
  boxSizing: "border-box"
@@ -101,12 +101,12 @@ const zt = {
101
101
  fontSize: "100%",
102
102
  lineHeight: "1.15em"
103
103
  }
104
- }, Wt = (t, e) => new Promise((s, n) => {
104
+ }, Kt = (t, e) => new Promise((s, n) => {
105
105
  const o = setTimeout(() => {
106
106
  n(new Error("Timeout"));
107
- }, 100), a = ot.createSourceFile("temp.ts", t, ot.ScriptTarget.Latest, !0);
107
+ }, 100), a = rt.createSourceFile("temp.ts", t, rt.ScriptTarget.Latest, !0);
108
108
  function i(p) {
109
- if (ot.isVariableDeclaration(p) && p.name.getText() === e) {
109
+ if (rt.isVariableDeclaration(p) && p.name.getText() === e) {
110
110
  const y = p.getStart(), m = p.getEnd();
111
111
  clearTimeout(o), s([y, m]);
112
112
  }
@@ -117,7 +117,7 @@ const zt = {
117
117
  externalModules: [],
118
118
  rcFile: void 0,
119
119
  destDir: void 0
120
- }, jt = (t) => {
120
+ }, xt = (t) => {
121
121
  if (E.externalModules.length > 0) return E.externalModules;
122
122
  const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
123
123
  if (!s) return [];
@@ -125,21 +125,21 @@ const zt = {
125
125
  return E.externalModules = n, n;
126
126
  }, J = async (t) => {
127
127
  if (E.destDir) return E.destDir;
128
- const e = await rt(t), s = c(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
128
+ const e = await pt(t), s = c(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
129
129
  return E.destDir = s, s;
130
- }, Ft = ["salty", "css", "styles", "styled"], Gt = (t = []) => new RegExp(`\\.(${[...Ft, ...t].join("|")})\\.`), ct = (t, e = []) => Gt(e).test(t), Nt = async (t) => {
130
+ }, Dt = ["salty", "css", "styles", "styled"], Lt = (t = []) => new RegExp(`\\.(${[...Dt, ...t].join("|")})\\.`), ut = (t, e = []) => Lt(e).test(t), kt = async (t) => {
131
131
  if (E.rcFile) return E.rcFile;
132
132
  if (t === "/") throw new Error("Could not find .saltyrc.json file");
133
- const e = c(t, ".saltyrc.json"), s = await ht(e, "utf-8").then(JSON.parse).catch(() => {
133
+ const e = c(t, ".saltyrc.json"), s = await St(e, "utf-8").then(JSON.parse).catch(() => {
134
134
  });
135
- return s ? (E.rcFile = s, s) : Nt(c(t, ".."));
136
- }, rt = async (t) => {
135
+ return s ? (E.rcFile = s, s) : kt(c(t, ".."));
136
+ }, pt = async (t) => {
137
137
  var n, o;
138
- const e = await Nt(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
138
+ const e = await kt(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
139
139
  return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
140
- }, Ht = async (t) => {
141
- const e = await rt(t), s = await J(t), n = c(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = c(s, "salty.config.js"), a = await St(t), i = jt(n);
142
- await gt.build({
140
+ }, At = async (t) => {
141
+ const e = await pt(t), s = await J(t), n = c(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = c(s, "salty.config.js"), a = await Pt(t), i = xt(n);
142
+ await bt.build({
143
143
  entryPoints: [n],
144
144
  minify: !0,
145
145
  treeShaking: !0,
@@ -150,8 +150,8 @@ const zt = {
150
150
  });
151
151
  const p = Date.now(), { config: y } = await import(`${o}?t=${p}`);
152
152
  return { config: y, path: o };
153
- }, It = async (t, e) => {
154
- var pt, mt;
153
+ }, Bt = async (t, e) => {
154
+ var gt, ht;
155
155
  const s = await J(t), n = {
156
156
  mediaQueries: [],
157
157
  globalStyles: [],
@@ -159,66 +159,86 @@ const zt = {
159
159
  templates: []
160
160
  };
161
161
  await Promise.all(
162
- [...e].map(async ($) => {
163
- const { contents: w, outputFilePath: v } = await Y(t, $, s);
164
- Object.entries(w).forEach(([x, k]) => {
165
- k.isMedia ? n.mediaQueries.push([x, k]) : k.isGlobalDefine ? n.globalStyles.push(k) : k.isDefineVariables ? n.variables.push(k) : k.isDefineTemplates && n.templates.push(k._setPath(`${x};;${v}`));
162
+ [...e].map(async (w) => {
163
+ const { contents: S, outputFilePath: Q } = await st(t, w, s);
164
+ Object.entries(S).forEach(([V, P]) => {
165
+ P.isMedia ? n.mediaQueries.push([V, P]) : P.isGlobalDefine ? n.globalStyles.push(P) : P.isDefineVariables ? n.variables.push(P) : P.isDefineTemplates && n.templates.push(P._setPath(`${V};;${Q}`));
166
166
  });
167
167
  })
168
168
  );
169
- const { config: o, path: a } = await Ht(t), i = { ...o }, p = /* @__PURE__ */ new Set(), y = ($, w = []) => $ ? Object.entries($).flatMap(([v, x]) => {
170
- if (!x) return;
171
- if (typeof x == "object") return y(x, [...w, v]);
172
- const k = Ct(v), et = H(v), st = [...w, k].join(".");
173
- p.add(`"${st}"`);
174
- const q = [...w.map(H), et].join("-"), dt = _t(x);
175
- return dt ? `--${q}: ${dt.transformed};` : `--${q}: ${x};`;
176
- }) : [], m = ($) => $ ? Object.entries($).flatMap(([w, v]) => {
177
- const x = y(v);
178
- return w === "base" ? x.join("") : `${w} { ${x.join("")} }`;
179
- }) : [], r = ($) => $ ? Object.entries($).flatMap(([w, v]) => Object.entries(v).flatMap(([x, k]) => {
180
- const et = y(k, [w]), st = `.${w}-${x}, [data-${w}="${x}"]`, q = et.join("");
181
- return `${st} { ${q} }`;
182
- })) : [], g = ($) => ({ ...$, responsive: void 0, conditional: void 0 }), u = ($) => n.variables.map((w) => $ === "static" ? g(w._current) : w._current[$]), h = G(g(o.variables), u("static")), d = y(h), j = G((pt = o.variables) == null ? void 0 : pt.responsive, u("responsive")), P = m(j), D = G((mt = o.variables) == null ? void 0 : mt.conditional, u("conditional")), V = r(D), O = c(s, "css/_variables.css"), ut = `:root { ${d.join("")} ${P.join("")} } ${V.join("")}`;
183
- C(O, ut), i.staticVariables = h;
184
- const M = c(s, "css/_global.css"), tt = G(o.global, n.globalStyles), f = await at(tt, "");
169
+ const { config: o, path: a } = await At(t), i = { ...o }, p = /* @__PURE__ */ new Set(), y = async (w, S = []) => {
170
+ if (!w) return [];
171
+ const Q = Object.entries(w).map(async ([P, z]) => {
172
+ const X = async (k) => {
173
+ if (!k) return;
174
+ if (k instanceof Promise) return await X(await k);
175
+ if (typeof k == "function") return await X(await k());
176
+ if (typeof k == "object") return await y(k, [...S, P]);
177
+ const ot = Nt(P), at = I(P), it = [...S, ot].join(".");
178
+ p.add(`"${it}"`);
179
+ const Y = [...S.map(I), at].join("-"), wt = Ot(k);
180
+ return wt ? `--${Y}: ${wt.transformed};` : `--${Y}: ${k};`;
181
+ };
182
+ return await X(z);
183
+ });
184
+ return (await Promise.all(Q)).flat();
185
+ }, m = async (w) => {
186
+ if (!w) return [];
187
+ const S = Object.entries(w).map(async ([V, P]) => {
188
+ const z = await y(P);
189
+ return V === "base" ? z.join("") : `${V} { ${z.join("")} }`;
190
+ });
191
+ return (await Promise.all(S)).flat();
192
+ }, r = async (w) => {
193
+ if (!w) return [];
194
+ const S = Object.entries(w).map(async ([V, P]) => {
195
+ const z = Object.entries(P).map(async ([k, ot]) => {
196
+ const at = await y(ot, [V]), it = `.${V}-${k}, [data-${V}="${k}"]`, Y = at.join("");
197
+ return `${it} { ${Y} }`;
198
+ });
199
+ return (await Promise.all(z)).flat();
200
+ });
201
+ return (await Promise.all(S)).flat();
202
+ }, g = (w) => ({ ...w, responsive: void 0, conditional: void 0 }), u = (w) => n.variables.map((S) => w === "static" ? g(S._current) : S._current[w]), h = H(g(o.variables), u("static")), d = await y(h), j = H((gt = o.variables) == null ? void 0 : gt.responsive, u("responsive")), x = await m(j), D = H((ht = o.variables) == null ? void 0 : ht.conditional, u("conditional")), v = await r(D), O = c(s, "css/_variables.css"), yt = `:root { ${d.join("")} ${x.join("")} } ${v.join("")}`;
203
+ C(O, yt), i.staticVariables = h;
204
+ const M = c(s, "css/_global.css"), nt = H(o.global, n.globalStyles), f = await lt(nt, "");
185
205
  C(M, `@layer global { ${f} }`);
186
- const b = c(s, "css/_reset.css"), l = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : zt, F = await at(l, "");
187
- C(b, `@layer reset { ${F} }`);
188
- const N = c(s, "css/_templates.css"), T = G(o.templates, n.templates), I = await $t(T), K = Mt(T);
189
- C(N, `@layer templates { ${I} }`), i.templates = T;
190
- const L = o.templates ? [Ot(o.templates)._setPath(`config;;${a}`)] : [], B = Vt(n.templates, L);
191
- i.templatePaths = Object.fromEntries(Object.entries(B).map(([$, w]) => [$, w._path]));
192
- const { mediaQueries: Q } = n;
193
- i.mediaQueries = Object.fromEntries(Q.map(([$, w]) => [`@${$}`, w]));
194
- const A = Q.map(([$]) => `'@${$}'`).join(" | "), Z = c(s, "types/css-tokens.d.ts"), Pt = `
206
+ const $ = c(s, "css/_reset.css"), l = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : It, F = await lt(l, "");
207
+ C($, `@layer reset { ${F} }`);
208
+ const N = c(s, "css/_templates.css"), T = H(o.templates, n.templates), K = await Ct(T), L = Wt(T);
209
+ C(N, `@layer templates { ${K} }`), i.templates = T;
210
+ const A = o.templates ? [zt(o.templates)._setPath(`config;;${a}`)] : [], Z = Jt(n.templates, A);
211
+ i.templatePaths = Object.fromEntries(Object.entries(Z).map(([w, S]) => [w, S._path]));
212
+ const { mediaQueries: q } = n;
213
+ i.mediaQueries = Object.fromEntries(q.map(([w, S]) => [`@${w}`, S]));
214
+ const B = q.map(([w]) => `'@${w}'`).join(" | "), U = c(s, "types/css-tokens.d.ts"), Tt = `
195
215
  // Variable types
196
216
  type VariableTokens = ${[...p].join("|")};
197
217
  type PropertyValueToken = \`{\${VariableTokens}}\`;
198
218
 
199
219
  // Template types
200
220
  type TemplateTokens = {
201
- ${Object.entries(K).map(([$, w]) => `${$}?: ${w}`).join(`
221
+ ${Object.entries(L).map(([w, S]) => `${w}?: ${S}`).join(`
202
222
  `)}
203
223
  }
204
224
 
205
225
  // Media query types
206
- type MediaQueryKeys = ${A || "''"};
226
+ type MediaQueryKeys = ${B || "''"};
207
227
  `;
208
- C(Z, Pt);
209
- const xt = c(s, "cache/config-cache.json");
210
- C(xt, JSON.stringify(i, null, 2));
211
- }, yt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
228
+ C(U, Tt);
229
+ const _t = c(s, "cache/config-cache.json");
230
+ C(_t, JSON.stringify(i, null, 2));
231
+ }, $t = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
212
232
  if (/^['"`]/.test(s)) return e;
213
233
  const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
214
234
  if (!o.test(t)) return e;
215
235
  const i = o.exec(t);
216
236
  if (i) {
217
237
  const p = i.at(1);
218
- if (Ft.some((m) => p == null ? void 0 : p.includes(m))) return e;
238
+ if (Dt.some((m) => p == null ? void 0 : p.includes(m))) return e;
219
239
  }
220
240
  return "styled('div',";
221
- }), Kt = (t, e) => {
241
+ }), Qt = (t, e) => {
222
242
  try {
223
243
  const s = _(c(e, "saltygen/cache/config-cache.json"), "utf8");
224
244
  return s ? `globalThis.saltyConfig = ${s};
@@ -229,14 +249,14 @@ ${t}`;
229
249
  } catch {
230
250
  return t;
231
251
  }
232
- }, Y = async (t, e, s) => {
252
+ }, st = async (t, e, s) => {
233
253
  const n = R(e), o = c(s, "./temp");
234
- it(o) || W(o);
235
- const a = X(e);
254
+ ft(o) || G(o);
255
+ const a = et(e);
236
256
  let i = _(e, "utf8");
237
- i = yt(i), i = Kt(i, t);
238
- const p = c(s, "js", n + ".js"), y = await rt(t), m = c(t, (y == null ? void 0 : y.configDir) || "", "salty.config.ts"), r = jt(m), g = await St(t);
239
- await gt.build({
257
+ i = $t(i), i = Qt(i, t);
258
+ const p = c(s, "js", n + ".js"), y = await pt(t), m = c(t, (y == null ? void 0 : y.configDir) || "", "salty.config.ts"), r = xt(m), g = await Pt(t);
259
+ await bt.build({
240
260
  stdin: {
241
261
  contents: i,
242
262
  sourcefile: a.base,
@@ -257,8 +277,8 @@ ${t}`;
257
277
  name: "test",
258
278
  setup: (d) => {
259
279
  d.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
260
- const P = _(j.path, "utf8");
261
- return { contents: yt(P), loader: "ts" };
280
+ const x = _(j.path, "utf8");
281
+ return { contents: $t(x), loader: "ts" };
262
282
  });
263
283
  }
264
284
  }
@@ -266,41 +286,41 @@ ${t}`;
266
286
  });
267
287
  const u = Date.now();
268
288
  return { contents: await import(`${p}?t=${u}`), outputFilePath: p };
269
- }, Lt = async (t) => {
289
+ }, Zt = async (t) => {
270
290
  const e = await J(t), s = c(e, "cache/config-cache.json"), n = _(s, "utf8");
271
291
  if (!n) throw new Error("Could not find config cache file");
272
292
  return JSON.parse(n);
273
- }, lt = async (t) => {
274
- const e = await Lt(t), s = await J(t), n = c(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
275
- return G(a, e);
276
- }, ft = () => {
293
+ }, mt = async (t) => {
294
+ const e = await Zt(t), s = await J(t), n = c(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
295
+ return H(a, e);
296
+ }, dt = () => {
277
297
  try {
278
298
  return process.env.NODE_ENV === "production";
279
299
  } catch {
280
300
  return !1;
281
301
  }
282
- }, oe = async (t, e = ft(), s = !0) => {
302
+ }, re = async (t, e = dt(), s = !0) => {
283
303
  try {
284
304
  const n = Date.now();
285
- e ? U.info("Generating CSS in production mode! 🔥") : U.info("Generating CSS in development mode! 🚀");
305
+ e ? tt.info("Generating CSS in production mode! 🔥") : tt.info("Generating CSS in development mode! 🚀");
286
306
  const o = [], a = [], i = await J(t), p = c(i, "index.css");
287
307
  s && (() => {
288
- it(i) && Dt("rm -rf " + i), W(i, { recursive: !0 }), W(c(i, "css")), W(c(i, "types")), W(c(i, "js")), W(c(i, "cache"));
308
+ ft(i) && Vt("rm -rf " + i), G(i, { recursive: !0 }), G(c(i, "css")), G(c(i, "types")), G(c(i, "js")), G(c(i, "cache"));
289
309
  })();
290
310
  const m = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
291
311
  async function g(f) {
292
- const b = ["node_modules", "saltygen"], S = kt(f);
293
- if (S.isDirectory()) {
294
- const l = Tt(f);
295
- if (b.some((N) => f.includes(N))) return;
312
+ const $ = ["node_modules", "saltygen"], b = Et(f);
313
+ if (b.isDirectory()) {
314
+ const l = vt(f);
315
+ if ($.some((N) => f.includes(N))) return;
296
316
  await Promise.all(l.map((N) => g(c(f, N))));
297
- } else if (S.isFile() && ct(f)) {
317
+ } else if (b.isFile() && ut(f)) {
298
318
  m.add(f);
299
319
  const F = _(f, "utf8");
300
320
  /define[\w\d]+\(/.test(F) && r.add(f);
301
321
  }
302
322
  }
303
- await g(t), await It(t, r);
323
+ await g(t), await Bt(t, r);
304
324
  const u = {
305
325
  keyframes: [],
306
326
  components: [],
@@ -308,34 +328,34 @@ ${t}`;
308
328
  };
309
329
  await Promise.all(
310
330
  [...m].map(async (f) => {
311
- const { contents: b } = await Y(t, f, i);
312
- for (let [S, l] of Object.entries(b))
331
+ const { contents: $ } = await st(t, f, i);
332
+ for (let [b, l] of Object.entries($))
313
333
  l instanceof Promise && (l = await l), l.isKeyframes ? u.keyframes.push({
314
334
  value: l,
315
335
  src: f,
316
- name: S
336
+ name: b
317
337
  }) : l.isClassName ? u.classNames.push({
318
338
  ...l,
319
339
  src: f,
320
- name: S
340
+ name: b
321
341
  }) : l.generator && u.components.push({
322
342
  ...l,
323
343
  src: f,
324
- name: S
344
+ name: b
325
345
  });
326
346
  })
327
347
  );
328
- const h = await lt(t);
348
+ const h = await mt(t);
329
349
  for (const f of u.keyframes) {
330
- const { value: b } = f, S = `a_${b.animationName}.css`, l = `css/${S}`, F = c(i, l);
331
- o.push(S), C(F, b.css);
350
+ const { value: $ } = f, b = `a_${$.animationName}.css`, l = `css/${b}`, F = c(i, l);
351
+ o.push(b), C(F, $.css);
332
352
  }
333
353
  const d = {};
334
354
  for (const f of u.components) {
335
- const { src: b, name: S } = f;
336
- d[b] || (d[b] = []);
355
+ const { src: $, name: b } = f;
356
+ d[$] || (d[$] = []);
337
357
  const l = f.generator._withBuildContext({
338
- callerName: S,
358
+ callerName: b,
339
359
  isProduction: e,
340
360
  config: h
341
361
  });
@@ -344,25 +364,25 @@ ${t}`;
344
364
  if (!F) continue;
345
365
  a[l.priority].push(l.cssFileName);
346
366
  const N = `css/${l.cssFileName}`, T = c(i, N);
347
- C(T, F), h.importStrategy === "component" && d[b].push(l.cssFileName);
367
+ C(T, F), h.importStrategy === "component" && d[$].push(l.cssFileName);
348
368
  }
349
369
  for (const f of u.classNames) {
350
- const { src: b, name: S } = f;
351
- d[b] || (d[b] = []);
370
+ const { src: $, name: b } = f;
371
+ d[$] || (d[$] = []);
352
372
  const l = f.generator._withBuildContext({
353
- callerName: S,
373
+ callerName: b,
354
374
  isProduction: e,
355
375
  config: h
356
376
  }), F = await l.css;
357
377
  if (!F) continue;
358
378
  a[l.priority] || (a[l.priority] = []), a[l.priority].push(l.cssFileName);
359
379
  const N = `css/${l.cssFileName}`, T = c(i, N);
360
- C(T, F), h.importStrategy === "component" && d[b].push(l.cssFileName);
380
+ C(T, F), h.importStrategy === "component" && d[$].push(l.cssFileName);
361
381
  }
362
- h.importStrategy === "component" && Object.entries(d).forEach(([f, b]) => {
363
- const S = b.map((I) => `@import url('./${I}');`).join(`
364
- `), l = R(f, 6), F = X(f), N = H(F.name), T = c(i, `css/f_${N}-${l}.css`);
365
- C(T, S || "/* Empty file */");
382
+ h.importStrategy === "component" && Object.entries(d).forEach(([f, $]) => {
383
+ const b = $.map((K) => `@import url('./${K}');`).join(`
384
+ `), l = R(f, 6), F = et(f), N = I(F.name), T = c(i, `css/f_${N}-${l}.css`);
385
+ C(T, b || "/* Empty file */");
366
386
  });
367
387
  const j = o.map((f) => `@import url('./css/${f}');`).join(`
368
388
  `);
@@ -378,37 +398,37 @@ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) =
378
398
  `)}
379
399
  ${j}`;
380
400
  if (h.importStrategy !== "component") {
381
- const f = a.reduce((b, S, l) => {
382
- const F = S.reduce((K, L) => {
383
- var Z;
384
- const B = c(i, "css", L), Q = _(B, "utf8"), A = ((Z = /.*-([^-]+)-\d+.css/.exec(L)) == null ? void 0 : Z.at(1)) || R(B, 6);
385
- return K.includes(A) ? K : `${K}
386
- /*start:${A}-${L}*/
387
- ${Q}
388
- /*end:${A}*/
401
+ const f = a.reduce(($, b, l) => {
402
+ const F = b.reduce((L, A) => {
403
+ var U;
404
+ const Z = c(i, "css", A), q = _(Z, "utf8"), B = ((U = /.*-([^-]+)-\d+.css/.exec(A)) == null ? void 0 : U.at(1)) || R(Z, 6);
405
+ return L.includes(B) ? L : `${L}
406
+ /*start:${B}-${A}*/
407
+ ${q}
408
+ /*end:${B}*/
389
409
  `;
390
- }, ""), N = `l_${l}.css`, T = c(i, "css", N), I = `@layer l${l} { ${F}
410
+ }, ""), N = `l_${l}.css`, T = c(i, "css", N), K = `@layer l${l} { ${F}
391
411
  }`;
392
- return C(T, I), `${b}
412
+ return C(T, K), `${$}
393
413
  @import url('./css/${N}');`;
394
414
  }, "");
395
415
  O += f;
396
416
  }
397
417
  C(p, O);
398
- const M = Date.now() - n, tt = M < 200 ? "🔥" : M < 500 ? "🚀" : M < 1e3 ? "🎉" : M < 2e3 ? "🚗" : M < 5e3 ? "🤔" : "🥴";
399
- U.info(`Generated CSS in ${M}ms! ${tt}`);
418
+ const M = Date.now() - n, nt = M < 200 ? "🔥" : M < 500 ? "🚀" : M < 1e3 ? "🎉" : M < 2e3 ? "🚗" : M < 5e3 ? "🤔" : "🥴";
419
+ tt.info(`Generated CSS in ${M}ms! ${nt}`);
400
420
  } catch (n) {
401
421
  console.error(n);
402
422
  }
403
- }, ae = async (t, e, s = ft()) => {
423
+ }, le = async (t, e, s = dt()) => {
404
424
  try {
405
425
  const n = await J(t);
406
- if (ct(e)) {
407
- const a = [], i = await lt(t), { contents: p } = await Y(t, e, n);
426
+ if (ut(e)) {
427
+ const a = [], i = await mt(t), { contents: p } = await st(t, e, n);
408
428
  for (const [y, m] of Object.entries(p)) {
409
429
  if (m.isKeyframes && m.css) {
410
- const j = `css/${`a_${m.animationName}.css`}`, P = c(n, j);
411
- C(P, await m.css);
430
+ const j = `css/${`a_${m.animationName}.css`}`, x = c(n, j);
431
+ C(x, await m.css);
412
432
  return;
413
433
  }
414
434
  if (m.isClassName) {
@@ -419,7 +439,7 @@ ${Q}
419
439
  }), j = await d.css;
420
440
  if (!j) continue;
421
441
  a[d.priority] || (a[d.priority] = []), a[d.priority].push(d.cssFileName);
422
- const P = `css/${d.cssFileName}`, D = c(n, P);
442
+ const x = `css/${d.cssFileName}`, D = c(n, x);
423
443
  C(D, j);
424
444
  }
425
445
  if (!m.generator) return;
@@ -440,8 +460,8 @@ ${Q}
440
460
  var D;
441
461
  const d = c(n, "css", h), j = ((D = /.*-([^-]+)-\d+.css/.exec(h)) == null ? void 0 : D.at(1)) || R(d, 6);
442
462
  if (!u.includes(j)) {
443
- const V = _(d, "utf8"), O = `/*start:${j}-${h}*/
444
- ${V}
463
+ const v = _(d, "utf8"), O = `/*start:${j}-${h}*/
464
+ ${v}
445
465
  /*end:${j}*/
446
466
  `;
447
467
  u = `${u.replace(/\}$/, "")}
@@ -452,19 +472,19 @@ ${O}
452
472
  });
453
473
  else {
454
474
  const y = a.flat().map((h) => `@import url('./${h}');`).join(`
455
- `), m = R(e, 6), r = X(e), g = H(r.name), u = c(n, `css/f_${g}-${m}.css`);
475
+ `), m = R(e, 6), r = et(e), g = I(r.name), u = c(n, `css/f_${g}-${m}.css`);
456
476
  C(u, y || "/* Empty file */");
457
477
  }
458
478
  }
459
479
  } catch (n) {
460
480
  console.error(n);
461
481
  }
462
- }, ie = async (t, e, s = ft()) => {
482
+ }, fe = async (t, e, s = dt()) => {
463
483
  var n, o;
464
484
  try {
465
485
  const a = await J(t);
466
- if (ct(e)) {
467
- const p = _(e, "utf8"), y = await lt(t), { contents: m } = await Y(t, e, a);
486
+ if (ut(e)) {
487
+ const p = _(e, "utf8"), y = await mt(t), { contents: m } = await st(t, e, a);
468
488
  let r = p;
469
489
  for (const [g, u] of Object.entries(m)) {
470
490
  if (u.isKeyframes || !u.generator) continue;
@@ -472,19 +492,19 @@ ${O}
472
492
  callerName: g,
473
493
  isProduction: s,
474
494
  config: y
475
- }), [d, j] = await Wt(r, g), P = r.slice(d, j);
495
+ }), [d, j] = await Kt(r, g), x = r.slice(d, j);
476
496
  if (u.isClassName) {
477
- const D = r, V = ` ${g} = className("${h.classNames}")`;
478
- r = r.replace(P, V), D === r && console.error("Minimize file failed to change content", { name: g });
497
+ const D = r, v = ` ${g} = className("${h.classNames}")`;
498
+ r = r.replace(x, v), D === r && console.error("Minimize file failed to change content", { name: g });
479
499
  }
480
- if (P.includes("styled")) {
481
- const D = (o = (n = /styled\(([^,]+),/.exec(P)) == null ? void 0 : n.at(1)) == null ? void 0 : o.trim(), V = r, O = ` ${g} = styled(${D}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;
482
- r = r.replace(P, O), V === r && console.error("Minimize file failed to change content", { name: g, tagName: D });
500
+ if (x.includes("styled")) {
501
+ const D = (o = (n = /styled\(([^,]+),/.exec(x)) == null ? void 0 : n.at(1)) == null ? void 0 : o.trim(), v = r, O = ` ${g} = styled(${D}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;
502
+ r = r.replace(x, O), v === r && console.error("Minimize file failed to change content", { name: g, tagName: D });
483
503
  }
484
504
  }
485
505
  if (y.importStrategy === "component") {
486
- const g = R(e, 6), u = X(e);
487
- r = `import '../../saltygen/css/${`f_${H(u.name)}-${g}.css`}';
506
+ const g = R(e, 6), u = et(e);
507
+ r = `import '../../saltygen/css/${`f_${I(u.name)}-${g}.css`}';
488
508
  ${r}`;
489
509
  }
490
510
  return r = r.replace("@salty-css/react/class-name", "@salty-css/react/class-name-client"), r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
@@ -494,14 +514,14 @@ ${r}`;
494
514
  }
495
515
  };
496
516
  export {
497
- ne as a,
498
- ae as b,
499
- Gt as c,
500
- It as d,
501
- Y as e,
502
- oe as g,
503
- ct as i,
504
- U as l,
505
- ie as m,
506
- Ft as s
517
+ ce as a,
518
+ le as b,
519
+ Lt as c,
520
+ Bt as d,
521
+ st as e,
522
+ re as g,
523
+ ut as i,
524
+ tt as l,
525
+ fe as m,
526
+ Dt as s
507
527
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.232",
3
+ "version": "0.0.1-alpha.234",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/server/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-CNiSFD9q.cjs");exports.checkShouldRestart=e.checkShouldRestart;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-lhNr1-w7.cjs");exports.checkShouldRestart=e.checkShouldRestart;
package/server/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as o } from "../should-restart-mA0gAeEm.js";
1
+ import { c as o } from "../should-restart-0ZMFyli-.js";
2
2
  export {
3
3
  o as checkShouldRestart
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { readFile as r } from "fs/promises";
2
- import { i as e } from "./index-B_l52ZKf.js";
2
+ import { i as e } from "./index-D6UVbPah.js";
3
3
  const c = 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 e=require("fs/promises"),r=require("./index-q4N-TRZZ.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 s=await e.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(s)};exports.checkShouldRestart=i;
1
+ "use strict";const e=require("fs/promises"),r=require("./index-AIl-HgpW.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 s=await e.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(s)};exports.checkShouldRestart=i;
@@ -1,38 +0,0 @@
1
- "use strict";const Pe=require("esbuild"),ke=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),c=require("path"),r=require("fs"),de=require("fs/promises"),U=require("./parse-styles-3N79AOBO.cjs"),L=require("winston"),R=require("./css/merge.cjs"),xe=require("./define-templates-Cunsb_Tr.cjs"),se=require("typescript");var ne=typeof document<"u"?document.currentScript:null;function De(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 me=De(Pe),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(),d=await ye(i,[...t,a]);s.push(d)}else n[o]=i;if(Object.keys(n).length){const o=t.map(D.dashCase).join("-"),i="t_"+D.toHash(o,4),a=await U.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]=ge(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},ge=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?ge(o,i,s):s.add(t)}),[...s]):[],he=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return r.existsSync(t)?t:he(c.join(e,".."))},Te=async e=>{const t=he(e);return await de.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await Te(e);if(t)return t.type};let z;const Se=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-q4N-TRZZ.cjs",document.baseURI).href).endsWith(".cjs"))&&(z="cjs"),z||"esm"},A=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]}),ve=e=>{A.error(e)};function je(e){return e?typeof e!="string"?je(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"}},Ve=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),i=se.createSourceFile("temp.ts",e,se.ScriptTarget.Latest,!0);function a(d){if(se.isVariableDeclaration(d)&&d.name.getText()===t){const g=d.getStart(),m=d.getEnd();clearTimeout(o),s([g,m])}d.forEachChild(a)}a(i)}),v={externalModules:[],rcFile:void 0,destDir:void 0},be=e=>{if(v.externalModules.length>0)return v.externalModules;const s=r.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},J=async e=>{if(v.destDir)return v.destDir;const t=await ie(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return v.destDir=s,s},oe=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...oe,...e].join("|")})\\.`),X=(e,t=[])=>we(t).test(e),$e=async e=>{if(v.rcFile)return v.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await de.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(v.rcFile=s,s):$e(c.join(e,".."))},ie=async e=>{var n,o;const t=await $e(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))},Me=async e=>{const t=await ie(e),s=await J(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),i=await Se(e),a=be(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:a});const d=Date.now(),{config:g}=await import(`${o}?t=${d}`);return{config:g,path:o}},Fe=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async j=>{const{contents:w,outputFilePath:O}=await G(e,j,s);Object.entries(w).forEach(([k,_])=>{_.isMedia?n.mediaQueries.push([k,_]):_.isGlobalDefine?n.globalStyles.push(_):_.isDefineVariables?n.variables.push(_):_.isDefineTemplates&&n.templates.push(_._setPath(`${k};;${O}`))})}));const{config:o,path:i}=await Me(e),a={...o},d=new Set,g=(j,w=[])=>j?Object.entries(j).flatMap(([O,k])=>{if(!k)return;if(typeof k=="object")return g(k,[...w,O]);const _=je(O),ee=D.dashCase(O),te=[...w,_].join(".");d.add(`"${te}"`);const Z=[...w.map(D.dashCase),ee].join("-"),ue=U.parseVariableTokens(k);return ue?`--${Z}: ${ue.transformed};`:`--${Z}: ${k};`}):[],m=j=>j?Object.entries(j).flatMap(([w,O])=>{const k=g(O);return w==="base"?k.join(""):`${w} { ${k.join("")} }`}):[],l=j=>j?Object.entries(j).flatMap(([w,O])=>Object.entries(O).flatMap(([k,_])=>{const ee=g(_,[w]),te=`.${w}-${k}, [data-${w}="${k}"]`,Z=ee.join("");return`${te} { ${Z} }`})):[],h=j=>({...j,responsive:void 0,conditional:void 0}),p=j=>n.variables.map(w=>j==="static"?h(w._current):w._current[j]),S=R.mergeObjects(h(o.variables),p("static")),y=g(S),F=R.mergeObjects((le=o.variables)==null?void 0:le.responsive,p("responsive")),P=m(F),x=R.mergeObjects((fe=o.variables)==null?void 0:fe.conditional,p("conditional")),E=l(x),V=c.join(s,"css/_variables.css"),re=`:root { ${y.join("")} ${P.join("")} } ${E.join("")}`;r.writeFileSync(V,re),a.staticVariables=S;const M=c.join(s,"css/_global.css"),Y=R.mergeObjects(o.global,n.globalStyles),u=await U.parseAndJoinStyles(Y,"");r.writeFileSync(M,`@layer global { ${u} }`);const b=c.join(s,"css/_reset.css"),f=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ee,C=await U.parseAndJoinStyles(f,"");r.writeFileSync(b,`@layer reset { ${C} }`);const N=c.join(s,"css/_templates.css"),T=R.mergeObjects(o.templates,n.templates),q=await ye(T),H=_e(T);r.writeFileSync(N,`@layer templates { ${q} }`),a.templates=T;const W=o.templates?[xe.defineTemplates(o.templates)._setPath(`config;;${i}`)]:[],K=R.mergeFactories(n.templates,W);a.templatePaths=Object.fromEntries(Object.entries(K).map(([j,w])=>[j,w._path]));const{mediaQueries:B}=n;a.mediaQueries=Object.fromEntries(B.map(([j,w])=>[`@${j}`,w]));const I=B.map(([j])=>`'@${j}'`).join(" | "),Q=c.join(s,"types/css-tokens.d.ts"),Ce=`
3
- // Variable types
4
- type VariableTokens = ${[...d].join("|")};
5
- type PropertyValueToken = \`{\${VariableTokens}}\`;
6
-
7
- // Template types
8
- type TemplateTokens = {
9
- ${Object.entries(H).map(([j,w])=>`${j}?: ${w}`).join(`
10
- `)}
11
- }
12
-
13
- // Media query types
14
- type MediaQueryKeys = ${I||"''"};
15
- `;r.writeFileSync(Q,Ce);const Ne=c.join(s,"cache/config-cache.json");r.writeFileSync(Ne,JSON.stringify(a,null,2))},pe=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 d=a.at(1);if(oe.some(m=>d==null?void 0:d.includes(m)))return t}return"styled('div',"}),Re=(e,t)=>{try{const s=r.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
16
-
17
- ${e}`:`globalThis.saltyConfig = {};
18
-
19
- ${e}`}catch{return e}},G=async(e,t,s)=>{const n=D.toHash(t),o=c.join(s,"./temp");r.existsSync(o)||r.mkdirSync(o);const i=c.parse(t);let a=r.readFileSync(t,"utf8");a=pe(a),a=Re(a,e);const d=c.join(s,"js",n+".js"),g=await ie(e),m=c.join(e,(g==null?void 0:g.configDir)||"","salty.config.ts"),l=be(m),h=await Se(e);await me.build({stdin:{contents:a,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:h,target:["node20"],keepNames:!0,external:l,packages:"external",plugins:[{name:"test",setup:y=>{y.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},F=>{const P=r.readFileSync(F.path,"utf8");return{contents:pe(P),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${d}?t=${p}`),outputFilePath:d}},Je=async e=>{const t=await J(e),s=c.join(t,"cache/config-cache.json"),n=r.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Je(e),s=await J(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return R.mergeObjects(i,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ze=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?A.info("Generating CSS in production mode! 🔥"):A.info("Generating CSS in development mode! 🚀");const o=[],i=[],a=await J(e),d=c.join(a,"index.css");s&&(()=>{r.existsSync(a)&&ke.execSync("rm -rf "+a),r.mkdirSync(a,{recursive:!0}),r.mkdirSync(c.join(a,"css")),r.mkdirSync(c.join(a,"types")),r.mkdirSync(c.join(a,"js")),r.mkdirSync(c.join(a,"cache"))})();const m=new Set,l=new Set;async function h(u){const b=["node_modules","saltygen"],$=r.statSync(u);if($.isDirectory()){const f=r.readdirSync(u);if(b.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>h(c.join(u,N))))}else if($.isFile()&&X(u)){m.add(u);const C=r.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&l.add(u)}}await h(e),await Fe(e,l);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...m].map(async u=>{const{contents:b}=await G(e,u,a);for(let[$,f]of Object.entries(b))f instanceof Promise&&(f=await f),f.isKeyframes?p.keyframes.push({value:f,src:u,name:$}):f.isClassName?p.classNames.push({...f,src:u,name:$}):f.generator&&p.components.push({...f,src:u,name:$})}));const S=await ae(e);for(const u of p.keyframes){const{value:b}=u,$=`a_${b.animationName}.css`,f=`css/${$}`,C=c.join(a,f);o.push($),r.writeFileSync(C,b.css)}const y={};for(const u of p.components){const{src:b,name:$}=u;y[b]||(y[b]=[]);const f=u.generator._withBuildContext({callerName:$,isProduction:t,config:S});i[f.priority]||(i[f.priority]=[]);const C=await f.css;if(!C)continue;i[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,T=c.join(a,N);r.writeFileSync(T,C),S.importStrategy==="component"&&y[b].push(f.cssFileName)}for(const u of p.classNames){const{src:b,name:$}=u;y[b]||(y[b]=[]);const f=u.generator._withBuildContext({callerName:$,isProduction:t,config:S}),C=await f.css;if(!C)continue;i[f.priority]||(i[f.priority]=[]),i[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,T=c.join(a,N);r.writeFileSync(T,C),S.importStrategy==="component"&&y[b].push(f.cssFileName)}S.importStrategy==="component"&&Object.entries(y).forEach(([u,b])=>{const $=b.map(q=>`@import url('./${q}');`).join(`
20
- `),f=D.toHash(u,6),C=c.parse(u),N=D.dashCase(C.name),T=c.join(a,`css/f_${N}-${f}.css`);r.writeFileSync(T,$||"/* Empty file */")});const F=o.map(u=>`@import url('./css/${u}');`).join(`
21
- `);let V=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
-
23
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(u=>{try{return r.readFileSync(c.join(a,"css",u),"utf8").length>0}catch{return!1}}).map(u=>`@import url('./css/${u}');`).join(`
24
- `)}
25
- ${F}`;if(S.importStrategy!=="component"){const u=i.reduce((b,$,f)=>{const C=$.reduce((H,W)=>{var Q;const K=c.join(a,"css",W),B=r.readFileSync(K,"utf8"),I=((Q=/.*-([^-]+)-\d+.css/.exec(W))==null?void 0:Q.at(1))||D.toHash(K,6);return H.includes(I)?H:`${H}
26
- /*start:${I}-${W}*/
27
- ${B}
28
- /*end:${I}*/
29
- `},""),N=`l_${f}.css`,T=c.join(a,"css",N),q=`@layer l${f} { ${C}
30
- }`;return r.writeFileSync(T,q),`${b}
31
- @import url('./css/${N}');`},"");V+=u}r.writeFileSync(d,V);const M=Date.now()-n,Y=M<200?"🔥":M<500?"🚀":M<1e3?"🎉":M<2e3?"🚗":M<5e3?"🤔":"🥴";A.info(`Generated CSS in ${M}ms! ${Y}`)}catch(n){console.error(n)}},qe=async(e,t,s=ce())=>{try{const n=await J(e);if(X(t)){const i=[],a=await ae(e),{contents:d}=await G(e,t,n);for(const[g,m]of Object.entries(d)){if(m.isKeyframes&&m.css){const F=`css/${`a_${m.animationName}.css`}`,P=c.join(n,F);r.writeFileSync(P,await m.css);return}if(m.isClassName){const y=m.generator._withBuildContext({callerName:g,isProduction:s,config:a}),F=await y.css;if(!F)continue;i[y.priority]||(i[y.priority]=[]),i[y.priority].push(y.cssFileName);const P=`css/${y.cssFileName}`,x=c.join(n,P);r.writeFileSync(x,F)}if(!m.generator)return;const l=m.generator._withBuildContext({callerName:g,isProduction:s,config:a}),h=await l.css;if(!h)continue;const p=`css/${l.cssFileName}`,S=c.join(n,p);r.writeFileSync(S,h),i[l.priority]||(i[l.priority]=[]),i[l.priority].push(l.cssFileName)}if(a.importStrategy!=="component")i.forEach((g,m)=>{const l=`l_${m}.css`,h=c.join(n,"css",l);let p=r.readFileSync(h,"utf8");g.forEach(S=>{var x;const y=c.join(n,"css",S),F=((x=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:x.at(1))||D.toHash(y,6);if(!p.includes(F)){const E=r.readFileSync(y,"utf8"),V=`/*start:${F}-${S}*/
32
- ${E}
33
- /*end:${F}*/
34
- `;p=`${p.replace(/\}$/,"")}
35
- ${V}
36
- }`}}),r.writeFileSync(h,p)});else{const g=i.flat().map(S=>`@import url('./${S}');`).join(`
37
- `),m=D.toHash(t,6),l=c.parse(t),h=D.dashCase(l.name),p=c.join(n,`css/f_${h}-${m}.css`);r.writeFileSync(p,g||"/* Empty file */")}}}catch(n){console.error(n)}},He=async(e,t,s=ce())=>{var n,o;try{const i=await J(e);if(X(t)){const d=r.readFileSync(t,"utf8"),g=await ae(e),{contents:m}=await G(e,t,i);let l=d;for(const[h,p]of Object.entries(m)){if(p.isKeyframes||!p.generator)continue;const S=p.generator._withBuildContext({callerName:h,isProduction:s,config:g}),[y,F]=await Ve(l,h),P=l.slice(y,F);if(p.isClassName){const x=l,E=` ${h} = className("${S.classNames}")`;l=l.replace(P,E),x===l&&console.error("Minimize file failed to change content",{name:h})}if(P.includes("styled")){const x=(o=(n=/styled\(([^,]+),/.exec(P))==null?void 0:n.at(1))==null?void 0:o.trim(),E=l,V=` ${h} = styled(${x}, "${S.classNames}", ${JSON.stringify(S.clientProps)})`;l=l.replace(P,V),E===l&&console.error("Minimize file failed to change content",{name:h,tagName:x})}}if(g.importStrategy==="component"){const h=D.toHash(t,6),p=c.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(p.name)}-${h}.css`}';
38
- ${l}`}return l=l.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(i){console.error("Error in minimizeFile:",i)}};exports.compileSaltyFile=G;exports.generateConfigStyles=Fe;exports.generateCss=ze;exports.generateFile=qe;exports.isSaltyFile=X;exports.logError=ve;exports.logger=A;exports.minimizeFile=He;exports.saltyFileExtensions=oe;exports.saltyFileRegExp=we;