@salty-css/core 0.0.1-alpha.218 → 0.0.1-alpha.219

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