@salty-css/core 0.0.1-alpha.209 → 0.0.1-alpha.210

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-C5koRP2C.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-B9PS8nEw.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-DXHGOCFn.js";
6
+ import { l as t, a as h, g as te } from "../index-BzhU5E_2.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-GZrbHhPa.cjs");const e=require("../index-C5koRP2C.cjs");require("../css/merge.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-B4adoYza.cjs");const e=require("../index-B9PS8nEw.cjs");require("../css/merge.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--rFRnpgg.js";
8
- import { d as n, c as g, g as F, e as y, i as x, m as S, s as c, b as f } from "../index-DXHGOCFn.js";
7
+ import "../parse-styles-Bi-5cRYF.js";
8
+ import { d as n, c as g, g as F, e as y, i as x, m as S, s as c, b as f } from "../index-BzhU5E_2.js";
9
9
  import "../css/merge.js";
10
10
  export {
11
11
  n as compileSaltyFile,
package/css/keyframes.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-GZrbHhPa.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-B4adoYza.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--rFRnpgg.js";
1
+ import { p as m } from "../parse-styles-Bi-5cRYF.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-GZrbHhPa.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-B4adoYza.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--rFRnpgg.js";
4
+ import { p as x } from "../parse-styles-Bi-5cRYF.js";
5
5
  import { t as m, d as f } from "../dash-case-DBThphLm.js";
6
6
  class y {
7
7
  constructor(t) {
@@ -1,5 +1,5 @@
1
- "use strict";const Ce=require("esbuild"),xe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-GZrbHhPa.cjs"),B=require("winston"),M=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function Ne(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=Ne(Ce),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[r,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const a=r.trim(),y=await ye(o,[...t,a]);s.push(y)}else n[r]=o;if(Object.keys(n).length){const r=t.map(D.dashCase).join("-"),o="t_"+D.toHash(r,4),a=await X.parseAndJoinStyles(n,`.${r}, .${o}`);s.push(a)}return s.join(`
2
- `)},Pe=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(r=>`"${r}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,r])=>{const o=t?`${t}.${n}`:n;return typeof r=="object"?me(r,o,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:ge(i.join(e,".."))},ke=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await ke(e);if(t)return t.type};let H;const he=async e=>{if(H)return H;const t=await De(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-C5koRP2C.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),_e=e=>{G.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 Oe={"*, *::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(r=>r.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await re(e),s=i.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("|")})\\.`),Y=(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=i.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(i.join(e,".."))},re=async e=>{var n,r;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(o=>e.endsWith(o.dir||""));return s||((r=t.projects)==null?void 0:r.find(o=>o.dir===t.defaultProject))},Ee=async e=>{const t=await re(e),s=await v(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),o=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:o,external:a});const y=Date.now(),{config:F}=await import(`${r}?t=${y}`);return F},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await K(e,m,s);Object.entries(b).forEach(([k,O])=>{O.isMedia?n.mediaQueries.push([k,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(R))})}));const r=await Ee(e),o={...r},a=new Set,y=(m,b=[])=>m?Object.entries(m).flatMap(([R,k])=>{if(!k)return;if(typeof k=="object")return y(k,[...b,R]);const O=Se(R),te=D.dashCase(R),se=[...b,O].join(".");a.add(`"${se}"`);const U=[...b.map(D.dashCase),te].join("-"),ue=X.parseVariableTokens(k);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${k};`}):[],F=m=>m?Object.entries(m).flatMap(([b,R])=>{const k=y(R);return b==="base"?k.join(""):`${b} { ${k.join("")} }`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([k,O])=>{const te=y(O,[b]),se=`.${b}-${k}, [data-${b}="${k}"]`,U=te.join("");return`${se} { ${U} }`})):[],d=m=>({...m,responsive:void 0,conditional:void 0}),g=m=>n.variables.map(b=>m==="static"?d(b._current):b._current[m]),p=M.mergeObjects(d(r.variables),g("static")),j=y(p),h=M.mergeObjects((le=r.variables)==null?void 0:le.responsive,g("responsive")),C=F(h),N=M.mergeObjects((fe=r.variables)==null?void 0:fe.conditional,g("conditional")),P=l(N),J=i.join(s,"css/_variables.css"),E=`:root { ${j.join("")} ${C.join("")} } ${P.join("")}`;c.writeFileSync(J,E),o.staticVariables=p;const q=i.join(s,"css/_global.css"),_=M.mergeObjects(r.global,n.globalStyles),I=await X.parseAndJoinStyles(_,"");c.writeFileSync(q,`@layer global { ${I} }`);const f=i.join(s,"css/_reset.css"),w=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Oe,u=await X.parseAndJoinStyles(w,"");c.writeFileSync(f,`@layer reset { ${u} }`);const $=i.join(s,"css/_templates.css"),x=M.mergeObjects(r.templates,n.templates),T=await ye(x),W=Pe(x);c.writeFileSync($,`@layer templates { ${T} }`),o.templates=x;const A=M.mergeFactories(n.templates);o.templatePaths=Object.fromEntries(Object.entries(A).map(([m,b])=>[m,b._path]));const{mediaQueries:z}=n;o.mediaQueries=Object.fromEntries(z.map(([m,b])=>[`@${m}`,b]));const L=z.map(([m])=>`'@${m}'`).join(" | "),ee=i.join(s,"types/css-tokens.d.ts"),Z=`
1
+ "use strict";const Ce=require("esbuild"),xe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-B4adoYza.cjs"),B=require("winston"),M=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function Ne(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=Ne(Ce),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[r,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const a=r.trim(),y=await ye(o,[...t,a]);s.push(y)}else n[r]=o;if(Object.keys(n).length){const r=t.map(D.dashCase).join("-"),o="t_"+D.toHash(r,4),a=await X.parseAndJoinStyles(n,`.${r}, .${o}`);s.push(a)}return s.join(`
2
+ `)},Pe=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(r=>`"${r}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,r])=>{const o=t?`${t}.${n}`:n;return typeof r=="object"?me(r,o,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:ge(i.join(e,".."))},ke=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await ke(e);if(t)return t.type};let H;const he=async e=>{if(H)return H;const t=await De(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-B9PS8nEw.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),_e=e=>{G.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 Oe={"*, *::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(r=>r.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await re(e),s=i.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("|")})\\.`),Y=(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=i.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(i.join(e,".."))},re=async e=>{var n,r;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(o=>e.endsWith(o.dir||""));return s||((r=t.projects)==null?void 0:r.find(o=>o.dir===t.defaultProject))},Ee=async e=>{const t=await re(e),s=await v(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),o=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:o,external:a});const y=Date.now(),{config:F}=await import(`${r}?t=${y}`);return F},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await K(e,m,s);Object.entries(b).forEach(([N,O])=>{O.isMedia?n.mediaQueries.push([N,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${N};;${R}`))})}));const r=await Ee(e),o={...r},a=new Set,y=(m,b=[])=>m?Object.entries(m).flatMap(([R,N])=>{if(!N)return;if(typeof N=="object")return y(N,[...b,R]);const O=Se(R),te=D.dashCase(R),se=[...b,O].join(".");a.add(`"${se}"`);const U=[...b.map(D.dashCase),te].join("-"),ue=X.parseVariableTokens(N);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${N};`}):[],F=m=>m?Object.entries(m).flatMap(([b,R])=>{const N=y(R);return b==="base"?N.join(""):`${b} { ${N.join("")} }`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([N,O])=>{const te=y(O,[b]),se=`.${b}-${N}, [data-${b}="${N}"]`,U=te.join("");return`${se} { ${U} }`})):[],d=m=>({...m,responsive:void 0,conditional:void 0}),g=m=>n.variables.map(b=>m==="static"?d(b._current):b._current[m]),p=M.mergeObjects(d(r.variables),g("static")),j=y(p),h=M.mergeObjects((le=r.variables)==null?void 0:le.responsive,g("responsive")),C=F(h),P=M.mergeObjects((fe=r.variables)==null?void 0:fe.conditional,g("conditional")),k=l(P),J=i.join(s,"css/_variables.css"),E=`:root { ${j.join("")} ${C.join("")} } ${k.join("")}`;c.writeFileSync(J,E),o.staticVariables=p;const q=i.join(s,"css/_global.css"),_=M.mergeObjects(r.global,n.globalStyles),I=await X.parseAndJoinStyles(_,"");c.writeFileSync(q,`@layer global { ${I} }`);const f=i.join(s,"css/_reset.css"),w=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Oe,u=await X.parseAndJoinStyles(w,"");c.writeFileSync(f,`@layer reset { ${u} }`);const $=i.join(s,"css/_templates.css"),x=M.mergeObjects(r.templates,n.templates),T=await ye(x),W=Pe(x);c.writeFileSync($,`@layer templates { ${T} }`),o.templates=x;const A=M.mergeFactories(n.templates);o.templatePaths=Object.fromEntries(Object.entries(A).map(([m,b])=>[m,b._path]));const{mediaQueries:z}=n;o.mediaQueries=Object.fromEntries(z.map(([m,b])=>[`@${m}`,b]));const L=z.map(([m])=>`'@${m}'`).join(" | "),ee=i.join(s,"types/css-tokens.d.ts"),Z=`
3
3
  // Variable types
4
4
  type VariableTokens = ${[...a].join("|")};
5
5
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -16,7 +16,7 @@
16
16
 
17
17
  ${e}`:`globalThis.saltyConfig = {};
18
18
 
19
- ${e}`}catch{return e}},K=async(e,t,s)=>{const n=D.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const o=i.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Te(a,e);const y=i.join(s,"js",n+".js"),F=await re(e),l=i.join(e,(F==null?void 0:F.configDir)||"","salty.config.ts"),d=je(l),g=await he(e);await pe.build({stdin:{contents:a,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const N=c.readFileSync(C.path,"utf8");return{contents:de(N),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${y}?t=${p}`),outputFilePath:y}},Re=async e=>{const t=await v(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Re(e),s=await v(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:o}=await import(`${n}?t=${r}`);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?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const r=[],o=[],a=await v(e),y=i.join(a,"index.css");s&&(()=>{c.existsSync(a)&&xe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(i.join(a,"css")),c.mkdirSync(i.join(a,"types")),c.mkdirSync(i.join(a,"js")),c.mkdirSync(i.join(a,"cache"))})();const l=new Set,d=new Set;async function g(f){const S=["node_modules","saltygen"],w=c.statSync(f);if(w.isDirectory()){const u=c.readdirSync(f);if(S.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>g(i.join(f,x))))}else if(w.isFile()&&Y(f)){l.add(f);const $=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test($)&&d.add(f)}}await g(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:S}=await K(e,f,a);Object.entries(S).forEach(([w,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:w}):u.isClassName?p.classNames.push({...u,src:f,name:w}):u.generator&&p.components.push({...u,src:f,name:w})})}));const j=await ae(e);for(const f of p.keyframes){const{value:S}=f,w=`a_${S.animationName}.css`,u=`css/${w}`,$=i.join(a,u);r.push(w),c.writeFileSync($,S.css)}const h={};for(const f of p.components){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j});o[u.priority]||(o[u.priority]=[]);const $=await u.css;if(!$)continue;o[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}for(const f of p.classNames){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j}),$=await u.css;if(!$)continue;o[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}j.importStrategy==="component"&&Object.entries(h).forEach(([f,S])=>{const w=S.map(W=>`@import url('./${W}');`).join(`
19
+ ${e}`}catch{return e}},K=async(e,t,s)=>{const n=D.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const o=i.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Te(a,e);const y=i.join(s,"js",n+".js"),F=await re(e),l=i.join(e,(F==null?void 0:F.configDir)||"","salty.config.ts"),d=je(l),g=await he(e);await pe.build({stdin:{contents:a,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const P=c.readFileSync(C.path,"utf8");return{contents:de(P),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${y}?t=${p}`),outputFilePath:y}},Re=async e=>{const t=await v(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Re(e),s=await v(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:o}=await import(`${n}?t=${r}`);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?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const r=[],o=[],a=await v(e),y=i.join(a,"index.css");s&&(()=>{c.existsSync(a)&&xe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(i.join(a,"css")),c.mkdirSync(i.join(a,"types")),c.mkdirSync(i.join(a,"js")),c.mkdirSync(i.join(a,"cache"))})();const l=new Set,d=new Set;async function g(f){const S=["node_modules","saltygen"],w=c.statSync(f);if(w.isDirectory()){const u=c.readdirSync(f);if(S.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>g(i.join(f,x))))}else if(w.isFile()&&Y(f)){l.add(f);const $=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test($)&&d.add(f)}}await g(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:S}=await K(e,f,a);Object.entries(S).forEach(([w,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:w}):u.isClassName?p.classNames.push({...u,src:f,name:w}):u.generator&&p.components.push({...u,src:f,name:w})})}));const j=await ae(e);for(const f of p.keyframes){const{value:S}=f,w=`a_${S.animationName}.css`,u=`css/${w}`,$=i.join(a,u);r.push(w),c.writeFileSync($,S.css)}const h={};for(const f of p.components){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j});o[u.priority]||(o[u.priority]=[]);const $=await u.css;if(!$)continue;o[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}for(const f of p.classNames){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j}),$=await u.css;if(!$)continue;o[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}j.importStrategy==="component"&&Object.entries(h).forEach(([f,S])=>{const w=S.map(W=>`@import url('./${W}');`).join(`
20
20
  `),u=D.toHash(f,6),$=i.parse(f),x=D.dashCase($.name),T=i.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(T,w||"/* Empty file */")});const C=r.map(f=>`@import url('./css/${f}');`).join(`
21
21
  `);let E=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
22
 
@@ -28,11 +28,11 @@ ${ee}
28
28
  /*end:${Q}*/
29
29
  `},""),x=`l_${u}.css`,T=i.join(a,"css",x),W=`@layer l${u} { ${$}
30
30
  }`;return c.writeFileSync(T,W),`${S}
31
- @import url('./css/${x}');`},"");E+=f}c.writeFileSync(y,E);const _=Date.now()-n,I=_<200?"🔥":_<500?"🚀":_<1e3?"🎉":_<2e3?"🚗":_<5e3?"🤔":"🥴";G.info(`Generated CSS in ${_}ms! ${I}`)}catch(n){console.error(n)}},Me=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=[],a=await ae(e),{contents:y}=await K(e,t,n);for(const[F,l]of Object.entries(y)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,N=i.join(n,C);c.writeFileSync(N,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),C=await h.css;if(!C)continue;o[0].push(h.cssFileName);const N=`css/${h.cssFileName}`,P=i.join(n,N);c.writeFileSync(P,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),g=await d.css;if(!g)continue;const p=`css/${d.cssFileName}`,j=i.join(n,p);c.writeFileSync(j,g),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")o.forEach((F,l)=>{const d=`l_${l}.css`,g=i.join(n,"css",d);let p=c.readFileSync(g,"utf8");F.forEach(j=>{var P;const h=i.join(n,"css",j),C=((P=/.*-([^-]+)-\d+.css/.exec(j))==null?void 0:P.at(1))||D.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),E=`/*start:${C}-${j}*/
31
+ @import url('./css/${x}');`},"");E+=f}c.writeFileSync(y,E);const _=Date.now()-n,I=_<200?"🔥":_<500?"🚀":_<1e3?"🎉":_<2e3?"🚗":_<5e3?"🤔":"🥴";G.info(`Generated CSS in ${_}ms! ${I}`)}catch(n){console.error(n)}},Me=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=[],a=await ae(e),{contents:y}=await K(e,t,n);for(const[F,l]of Object.entries(y)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,P=i.join(n,C);c.writeFileSync(P,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),C=await h.css;if(!C)continue;o[0].push(h.cssFileName);const P=`css/${h.cssFileName}`,k=i.join(n,P);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),g=await d.css;if(!g)continue;const p=`css/${d.cssFileName}`,j=i.join(n,p);c.writeFileSync(j,g),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")o.forEach((F,l)=>{const d=`l_${l}.css`,g=i.join(n,"css",d);let p=c.readFileSync(g,"utf8");F.forEach(j=>{var k;const h=i.join(n,"css",j),C=((k=/.*-([^-]+)-\d+.css/.exec(j))==null?void 0:k.at(1))||D.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),E=`/*start:${C}-${j}*/
32
32
  ${J}
33
33
  /*end:${C}*/
34
34
  `;p=`${p.replace(/\}$/,"")}
35
35
  ${E}
36
36
  }`}}),c.writeFileSync(g,p)});else{const F=o.flat().map(j=>`@import url('./${j}');`).join(`
37
- `),l=D.toHash(t,6),d=i.parse(t),g=D.dashCase(d.name),p=i.join(n,`css/f_${g}-${l}.css`);c.writeFileSync(p,F||"/* Empty file */")}}}catch(n){console.error(n)}},ve=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=c.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==o&&await oe.writeFile(t,o);const y=await ae(e),{contents:F}=await K(e,t,n);let l=o;if(Object.entries(F).forEach(([d,g])=>{var u;if(g.isKeyframes||!g.generator)return;const p=g.generator._withBuildContext({callerName:d,isProduction:s,config:y}),j=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!j)return console.error("Could not find the original declaration");const h=(u=j.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:N}=C;let P=!1;const J=setTimeout(()=>P=!0,5e3);let E=0,q=!1,_=0;for(;!q&&!P;){const $=l[N+E];$==="("&&_++,$===")"&&_--,_===0&&$===")"&&(q=!0),E>l.length&&(P=!0),E++}if(!P)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const I=N+E,f=l.slice(N,I),S=l,w=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,w),S===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),y.importStrategy==="component"){const d=D.toHash(t,6),g=i.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(g.name)}-${d}.css`}';
37
+ `),l=D.toHash(t,6),d=i.parse(t),g=D.dashCase(d.name),p=i.join(n,`css/f_${g}-${l}.css`);c.writeFileSync(p,F||"/* Empty file */")}}}catch(n){console.error(n)}},ve=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=c.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==o&&await oe.writeFile(t,o);const y=await ae(e),{contents:F}=await K(e,t,n);let l=o;if(Object.entries(F).forEach(([d,g])=>{var u;if(g.isKeyframes||!g.generator)return;const p=g.generator._withBuildContext({callerName:d,isProduction:s,config:y}),j=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!j)return console.error("Could not find the original declaration");const h=(u=j.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:P}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let E=0,q=!1,_=0;for(;!q&&!k;){const $=l[P+E];$==="("&&_++,$===")"&&_--,_===0&&$===")"&&(q=!0),E>l.length&&(k=!0),E++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const I=P+E,f=l.slice(P,I),S=l,w=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,w),S===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),y.importStrategy==="component"){const d=D.toHash(t,6),g=i.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(g.name)}-${d}.css`}';
38
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=K;exports.generateConfigStyles=$e;exports.generateCss=Ve;exports.generateFile=Me;exports.isSaltyFile=Y;exports.logError=_e;exports.logger=G;exports.minimizeFile=ve;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;
@@ -4,7 +4,7 @@ import { d as G, t as v } from "./dash-case-DBThphLm.js";
4
4
  import { join as r, parse as Y } from "path";
5
5
  import { existsSync as it, writeFileSync as x, mkdirSync as I, readFileSync as T, statSync as Pt, readdirSync as kt } from "fs";
6
6
  import { readFile as yt, writeFile as Dt } from "fs/promises";
7
- import { p as at, a as _t } from "./parse-styles--rFRnpgg.js";
7
+ import { p as at, a as _t } from "./parse-styles-Bi-5cRYF.js";
8
8
  import { createLogger as Et, format as ot, transports as Tt } from "winston";
9
9
  import { mergeObjects as B, mergeFactories as Ot } from "./css/merge.js";
10
10
  const ht = async (t, e = []) => {
@@ -147,25 +147,25 @@ const Rt = {
147
147
  await Promise.all(
148
148
  [...e].map(async (m) => {
149
149
  const { contents: w, outputFilePath: V } = await tt(t, m, s);
150
- Object.entries(w).forEach(([k, _]) => {
151
- _.isMedia ? n.mediaQueries.push([k, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(V));
150
+ Object.entries(w).forEach(([N, _]) => {
151
+ _.isMedia ? n.mediaQueries.push([N, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${N};;${V}`));
152
152
  });
153
153
  })
154
154
  );
155
- const a = await zt(t), o = { ...a }, i = /* @__PURE__ */ new Set(), d = (m, w = []) => m ? Object.entries(m).flatMap(([V, k]) => {
156
- if (!k) return;
157
- if (typeof k == "object") return d(k, [...w, V]);
155
+ const a = await zt(t), o = { ...a }, i = /* @__PURE__ */ new Set(), d = (m, w = []) => m ? Object.entries(m).flatMap(([V, N]) => {
156
+ if (!N) return;
157
+ if (typeof N == "object") return d(N, [...w, V]);
158
158
  const _ = St(V), st = G(V), nt = [...w, _].join(".");
159
159
  i.add(`"${nt}"`);
160
- const U = [...w.map(G), st].join("-"), dt = _t(k);
161
- return dt ? `--${U}: ${dt.transformed};` : `--${U}: ${k};`;
160
+ const U = [...w.map(G), st].join("-"), dt = _t(N);
161
+ return dt ? `--${U}: ${dt.transformed};` : `--${U}: ${N};`;
162
162
  }) : [], C = (m) => m ? Object.entries(m).flatMap(([w, V]) => {
163
- const k = d(V);
164
- return w === "base" ? k.join("") : `${w} { ${k.join("")} }`;
165
- }) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([k, _]) => {
166
- const st = d(_, [w]), nt = `.${w}-${k}, [data-${w}="${k}"]`, U = st.join("");
163
+ const N = d(V);
164
+ return w === "base" ? N.join("") : `${w} { ${N.join("")} }`;
165
+ }) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
166
+ const st = d(_, [w]), nt = `.${w}-${N}, [data-${w}="${N}"]`, U = st.join("");
167
167
  return `${nt} { ${U} }`;
168
- })) : [], u = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), g = (m) => n.variables.map((w) => m === "static" ? u(w._current) : w._current[m]), p = B(u(a.variables), g("static")), $ = d(p), y = B((ut = a.variables) == null ? void 0 : ut.responsive, g("responsive")), j = C(y), N = B((pt = a.variables) == null ? void 0 : pt.conditional, g("conditional")), P = c(N), J = r(s, "css/_variables.css"), E = `:root { ${$.join("")} ${j.join("")} } ${P.join("")}`;
168
+ })) : [], u = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), g = (m) => n.variables.map((w) => m === "static" ? u(w._current) : w._current[m]), p = B(u(a.variables), g("static")), $ = d(p), y = B((ut = a.variables) == null ? void 0 : ut.responsive, g("responsive")), j = C(y), P = B((pt = a.variables) == null ? void 0 : pt.conditional, g("conditional")), k = c(P), J = r(s, "css/_variables.css"), E = `:root { ${$.join("")} ${j.join("")} } ${k.join("")}`;
169
169
  x(J, E), o.staticVariables = p;
170
170
  const H = r(s, "css/_global.css"), D = B(a.global, n.globalStyles), K = await at(D, "");
171
171
  x(H, `@layer global { ${K} }`);
@@ -243,8 +243,8 @@ ${t}`;
243
243
  name: "test",
244
244
  setup: (y) => {
245
245
  y.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
246
- const N = T(j.path, "utf8");
247
- return { contents: mt(N), loader: "ts" };
246
+ const P = T(j.path, "utf8");
247
+ return { contents: mt(P), loader: "ts" };
248
248
  });
249
249
  }
250
250
  }
@@ -394,8 +394,8 @@ ${et}
394
394
  const o = [], i = await lt(t), { contents: d } = await tt(t, e, n);
395
395
  for (const [C, c] of Object.entries(d)) {
396
396
  if (c.isKeyframes && c.css) {
397
- const j = `css/${`a_${c.animationName}.css`}`, N = r(n, j);
398
- x(N, await c.css);
397
+ const j = `css/${`a_${c.animationName}.css`}`, P = r(n, j);
398
+ x(P, await c.css);
399
399
  return;
400
400
  }
401
401
  if (c.isClassName) {
@@ -406,8 +406,8 @@ ${et}
406
406
  }), j = await y.css;
407
407
  if (!j) continue;
408
408
  o[0].push(y.cssFileName);
409
- const N = `css/${y.cssFileName}`, P = r(n, N);
410
- x(P, j);
409
+ const P = `css/${y.cssFileName}`, k = r(n, P);
410
+ x(k, j);
411
411
  }
412
412
  if (!c.generator) return;
413
413
  const u = c.generator._withBuildContext({
@@ -424,8 +424,8 @@ ${et}
424
424
  const u = `l_${c}.css`, g = r(n, "css", u);
425
425
  let p = T(g, "utf8");
426
426
  C.forEach(($) => {
427
- var P;
428
- const y = r(n, "css", $), j = ((P = /.*-([^-]+)-\d+.css/.exec($)) == null ? void 0 : P.at(1)) || v(y, 6);
427
+ var k;
428
+ const y = r(n, "css", $), j = ((k = /.*-([^-]+)-\d+.css/.exec($)) == null ? void 0 : k.at(1)) || v(y, 6);
429
429
  if (!p.includes(j)) {
430
430
  const J = T(y, "utf8"), E = `/*start:${j}-${$}*/
431
431
  ${J}
@@ -465,17 +465,17 @@ ${E}
465
465
  if (!$) return console.error("Could not find the original declaration");
466
466
  const y = (f = $.at(1)) == null ? void 0 : f.trim(), j = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(c);
467
467
  if (!j) return console.error("Could not find the original declaration");
468
- const { index: N } = j;
469
- let P = !1;
470
- const J = setTimeout(() => P = !0, 5e3);
468
+ const { index: P } = j;
469
+ let k = !1;
470
+ const J = setTimeout(() => k = !0, 5e3);
471
471
  let E = 0, H = !1, D = 0;
472
- for (; !H && !P; ) {
473
- const S = c[N + E];
474
- S === "(" && D++, S === ")" && D--, D === 0 && S === ")" && (H = !0), E > c.length && (P = !0), E++;
472
+ for (; !H && !k; ) {
473
+ const S = c[P + E];
474
+ S === "(" && D++, S === ")" && D--, D === 0 && S === ")" && (H = !0), E > c.length && (k = !0), E++;
475
475
  }
476
- if (!P) clearTimeout(J);
476
+ if (!k) clearTimeout(J);
477
477
  else throw new Error("Failed to find the end of the styled call and timed out");
478
- const K = N + E, l = c.slice(N, K), h = c, b = ` ${u} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;
478
+ const K = P + E, l = c.slice(P, K), h = c, b = ` ${u} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;
479
479
  c = c.replace(l, b), h === c && console.error("Minimize file failed to change content", { name: u, tagName: y });
480
480
  }), d.importStrategy === "component") {
481
481
  const u = v(e, 6), g = Y(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.209",
3
+ "version": "0.0.1-alpha.210",
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"),U=i=>e=>{if(typeof e!="string"||!i)return;let t=e;const f=[];return Object.values(i).forEach(n=>{const{pattern:b,transform:P}=n;t=t.replace(b,E=>{const{value:j,css:C}=P(E);return C&&f.push(C),j})}),{transformed:t,additionalCss:f}},S=i=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)},q=S(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(i,e,t)=>{if(J.some(n=>typeof n=="string"?n===i:n.test(i))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=i=>i.startsWith("-")?i:Q.some(e=>i.startsWith(e))?`-${V.dashCase(i)}`:V.dashCase(i),h=async(i,e="",t,f=!1)=>{if(!i)throw new Error("No styles provided to parseStyles function!");const n=new Set,P=Object.entries(i).map(async([l,s])=>{var y;const r=l.trim(),$=_(r),u=(o,c=";")=>`${$}:${o}${c}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templatePaths[r]){const[o,c]=t.templatePaths[r].split(";;"),d=(await import(c))[o];if(d&&typeof d.params[r]=="function"){const p=await d.params[r](s),[w]=await h(p,"");return w}}if(t!=null&&t.templates&&t.templates[r]){if(f)return;const c=s.split(".").reduce((a,d)=>a[d],t.templates[r]);if(c){const[a]=await h(c,"");return a}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 a=Object.entries(s);for(const[d,p]of a){if(!p)return;const w=Object.entries(p);for(const[k,m]of w){if(!m)return;const T=`${e}.${d}-${k}`;(await h(m,T,t)).forEach(z=>n.add(z))}}return}if(r==="compoundVariants"){for(const a of s){const{css:d,...p}=a,w=Object.entries(p).reduce((m,[T,N])=>`${m}.${T}-${N}`,e);(await h(d,w,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const a=((y=t==null?void 0:t.mediaQueries)==null?void 0:y[r])||r,d=await A(s,e,t),p=`${a} { ${d} }`;n.add(p);return}const o=l.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await h(s,o,t)).forEach(a=>n.add(a));return}if(typeof s=="number"){const o=M($,s,t);return u(o)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${$}`);return u(s)}),{modifiers:E}=t||{},j=[S(),U(E)],x=(await Promise.all(P).then(l=>Promise.all(l.map(s=>j.reduce(async(r,$)=>{const u=await r;if(!u)return u;const O=await $(u);if(!O)return u;const{transformed:y,additionalCss:o}=O;let c="";if(o)for(const a of o)c+=await A(a,"");return`${c}${y}`},Promise.resolve(s)))))).filter(l=>l!==void 0).join(`
2
+ `);if(!x.trim())return Array.from(n);const W=e?`${e} {
3
+ ${x}
4
+ }`:x;return n.has(W)?Array.from(n):[W,...n]},A=async(i,e,t,f=!1)=>(await h(i,e,t,f)).join(`
5
+ `);exports.parseAndJoinStyles=A;exports.parseVariableTokens=q;
@@ -2,14 +2,14 @@ import { d as V } from "./dash-case-DBThphLm.js";
2
2
  const U = (i) => (e) => {
3
3
  if (typeof e != "string" || !i) return;
4
4
  let t = e;
5
- const f = [];
5
+ const c = [];
6
6
  return Object.values(i).forEach((n) => {
7
- const { pattern: y, transform: b } = n;
8
- t = t.replace(y, (P) => {
9
- const { value: E, css: j } = b(P);
10
- return j && f.push(j), E;
7
+ const { pattern: b, transform: P } = n;
8
+ t = t.replace(b, (E) => {
9
+ const { value: j, css: x } = P(E);
10
+ return x && c.push(x), j;
11
11
  });
12
- }), { transformed: t, additionalCss: f };
12
+ }), { transformed: t, additionalCss: c };
13
13
  }, z = (i) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) }, J = z(), M = [
14
14
  "top",
15
15
  "right",
@@ -37,23 +37,23 @@ const U = (i) => (e) => {
37
37
  return `${e}${n}`;
38
38
  }
39
39
  return `${e}`;
40
- }, _ = ["Webkit", "Moz", "ms", "O"], q = (i) => i.startsWith("-") ? i : _.some((e) => i.startsWith(e)) ? `-${V(i)}` : V(i), h = async (i, e = "", t, f = !1) => {
40
+ }, _ = ["Webkit", "Moz", "ms", "O"], q = (i) => i.startsWith("-") ? i : _.some((e) => i.startsWith(e)) ? `-${V(i)}` : V(i), h = async (i, e = "", t, c = !1) => {
41
41
  if (!i) throw new Error("No styles provided to parseStyles function!");
42
- const n = /* @__PURE__ */ new Set(), b = Object.entries(i).map(async ([u, s]) => {
43
- var w;
44
- const r = u.trim(), $ = q(r), c = (a, d = ";") => `${$}:${a}${d}`;
42
+ const n = /* @__PURE__ */ new Set(), P = Object.entries(i).map(async ([m, s]) => {
43
+ var y;
44
+ const r = m.trim(), $ = q(r), p = (a, f = ";") => `${$}:${a}${f}`;
45
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
- const { default: a } = await import(t.templatePaths[r]);
47
- if (typeof a.params[r] == "function") {
48
- const d = await a.params[r](s), [o] = await h(d, "");
49
- return o;
46
+ const [a, f] = t.templatePaths[r].split(";;"), d = (await import(f))[a];
47
+ if (d && typeof d.params[r] == "function") {
48
+ const u = await d.params[r](s), [w] = await h(u, "");
49
+ return w;
50
50
  }
51
51
  }
52
52
  if (t != null && t.templates && t.templates[r]) {
53
- if (f) return;
54
- const d = s.split(".").reduce((o, p) => o[p], t.templates[r]);
55
- if (d) {
56
- const [o] = await h(d, "");
53
+ if (c) return;
54
+ const f = s.split(".").reduce((o, d) => o[d], t.templates[r]);
55
+ if (f) {
56
+ const [o] = await h(f, "");
57
57
  return o;
58
58
  }
59
59
  console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
@@ -61,16 +61,16 @@ const U = (i) => (e) => {
61
61
  }
62
62
  if (typeof s == "object") {
63
63
  if (!s) return;
64
- if (s.isColor) return c(s.toString());
64
+ if (s.isColor) return p(s.toString());
65
65
  if (r === "defaultVariants") return;
66
66
  if (r === "variants") {
67
67
  const o = Object.entries(s);
68
- for (const [p, m] of o) {
69
- if (!m) return;
70
- const C = Object.entries(m);
71
- for (const [A, l] of C) {
68
+ for (const [d, u] of o) {
69
+ if (!u) return;
70
+ const w = Object.entries(u);
71
+ for (const [A, l] of w) {
72
72
  if (!l) return;
73
- const T = `${e}.${p}-${A}`;
73
+ const T = `${e}.${d}-${A}`;
74
74
  (await h(l, T, t)).forEach((S) => n.add(S));
75
75
  }
76
76
  }
@@ -78,49 +78,49 @@ const U = (i) => (e) => {
78
78
  }
79
79
  if (r === "compoundVariants") {
80
80
  for (const o of s) {
81
- const { css: p, ...m } = o, C = Object.entries(m).reduce((l, [T, N]) => `${l}.${T}-${N}`, e);
82
- (await h(p, C, t)).forEach((l) => n.add(l));
81
+ const { css: d, ...u } = o, w = Object.entries(u).reduce((l, [T, N]) => `${l}.${T}-${N}`, e);
82
+ (await h(d, w, t)).forEach((l) => n.add(l));
83
83
  }
84
84
  return;
85
85
  }
86
86
  if (r.startsWith("@")) {
87
- const o = ((w = t == null ? void 0 : t.mediaQueries) == null ? void 0 : w[r]) || r, p = await k(s, e, t), m = `${o} { ${p} }`;
88
- n.add(m);
87
+ const o = ((y = t == null ? void 0 : t.mediaQueries) == null ? void 0 : y[r]) || r, d = await k(s, e, t), u = `${o} { ${d} }`;
88
+ n.add(u);
89
89
  return;
90
90
  }
91
- const a = u.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
91
+ const a = m.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
92
92
  (await h(s, a, t)).forEach((o) => n.add(o));
93
93
  return;
94
94
  }
95
95
  if (typeof s == "number") {
96
96
  const a = Q($, s, t);
97
- return c(a);
97
+ return p(a);
98
98
  }
99
99
  if (typeof s != "string")
100
100
  if ("toString" in s) s = s.toString();
101
101
  else throw new Error(`Invalid value type for property ${$}`);
102
- return c(s);
103
- }), { modifiers: P } = t || {}, E = [z(), U(P)], x = (await Promise.all(b).then((u) => Promise.all(
104
- u.map((s) => E.reduce(async (r, $) => {
105
- const c = await r;
106
- if (!c) return c;
107
- const O = await $(c);
108
- if (!O) return c;
109
- const { transformed: w, additionalCss: a } = O;
110
- let d = "";
102
+ return p(s);
103
+ }), { modifiers: E } = t || {}, j = [z(), U(E)], O = (await Promise.all(P).then((m) => Promise.all(
104
+ m.map((s) => j.reduce(async (r, $) => {
105
+ const p = await r;
106
+ if (!p) return p;
107
+ const C = await $(p);
108
+ if (!C) return p;
109
+ const { transformed: y, additionalCss: a } = C;
110
+ let f = "";
111
111
  if (a)
112
112
  for (const o of a)
113
- d += await k(o, "");
114
- return `${d}${w}`;
113
+ f += await k(o, "");
114
+ return `${f}${y}`;
115
115
  }, Promise.resolve(s)))
116
- ))).filter((u) => u !== void 0).join(`
116
+ ))).filter((m) => m !== void 0).join(`
117
117
  `);
118
- if (!x.trim()) return Array.from(n);
118
+ if (!O.trim()) return Array.from(n);
119
119
  const W = e ? `${e} {
120
- ${x}
121
- }` : x;
120
+ ${O}
121
+ }` : O;
122
122
  return n.has(W) ? Array.from(n) : [W, ...n];
123
- }, k = async (i, e, t, f = !1) => (await h(i, e, t, f)).join(`
123
+ }, k = async (i, e, t, c = !1) => (await h(i, e, t, c)).join(`
124
124
  `);
125
125
  export {
126
126
  J as a,
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-C5koRP2C.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-B9PS8nEw.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-DXHGOCFn.js";
2
+ import { i as e } from "../index-BzhU5E_2.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,5 +0,0 @@
1
- "use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),U=a=>e=>{if(typeof e!="string"||!a)return;let t=e;const f=[];return Object.values(a).forEach(n=>{const{pattern:y,transform:b}=n;t=t.replace(y,P=>{const{value:E,css:j}=b(P);return j&&f.push(j),E})}),{transformed:t,additionalCss:f}},S=a=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)},q=S(),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),h=async(a,e="",t,f=!1)=>{if(!a)throw new Error("No styles provided to parseStyles function!");const n=new Set,b=Object.entries(a).map(async([p,s])=>{var w;const r=p.trim(),$=_(r),c=(o,d=";")=>`${$}:${o}${d}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templatePaths[r]){const{default:o}=await import(t.templatePaths[r]);if(typeof o.params[r]=="function"){const d=await o.params[r](s),[i]=await h(d,"");return i}}if(t!=null&&t.templates&&t.templates[r]){if(f)return;const d=s.split(".").reduce((i,u)=>i[u],t.templates[r]);if(d){const[i]=await h(d,"");return i}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 c(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const i=Object.entries(s);for(const[u,l]of i){if(!l)return;const O=Object.entries(l);for(const[k,m]of O){if(!m)return;const T=`${e}.${u}-${k}`;(await h(m,T,t)).forEach(z=>n.add(z))}}return}if(r==="compoundVariants"){for(const i of s){const{css:u,...l}=i,O=Object.entries(l).reduce((m,[T,N])=>`${m}.${T}-${N}`,e);(await h(u,O,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const i=((w=t==null?void 0:t.mediaQueries)==null?void 0:w[r])||r,u=await A(s,e,t),l=`${i} { ${u} }`;n.add(l);return}const o=p.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await h(s,o,t)).forEach(i=>n.add(i));return}if(typeof s=="number"){const o=M($,s,t);return c(o)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${$}`);return c(s)}),{modifiers:P}=t||{},E=[S(),U(P)],C=(await Promise.all(b).then(p=>Promise.all(p.map(s=>E.reduce(async(r,$)=>{const c=await r;if(!c)return c;const x=await $(c);if(!x)return c;const{transformed:w,additionalCss:o}=x;let d="";if(o)for(const i of o)d+=await A(i,"");return`${d}${w}`},Promise.resolve(s)))))).filter(p=>p!==void 0).join(`
2
- `);if(!C.trim())return Array.from(n);const W=e?`${e} {
3
- ${C}
4
- }`:C;return n.has(W)?Array.from(n):[W,...n]},A=async(a,e,t,f=!1)=>(await h(a,e,t,f)).join(`
5
- `);exports.parseAndJoinStyles=A;exports.parseVariableTokens=q;