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

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-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+`
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-B6M9WK93.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-BzhU5E_2.js";
6
+ import { l as t, a as h, g as te } from "../index-B_bv7TCc.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-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;
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-B6M9WK93.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,16 +4,17 @@ import "../dash-case-DBThphLm.js";
4
4
  import "path";
5
5
  import "fs";
6
6
  import "fs/promises";
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";
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-B_bv7TCc.js";
9
9
  import "../css/merge.js";
10
+ import "../define-templates-4A2yHcMF.js";
10
11
  export {
11
- n as compileSaltyFile,
12
- g as generateConfigStyles,
13
- F as generateCss,
14
- y as generateFile,
15
- x as isSaltyFile,
16
- S as minimizeFile,
17
- c as saltyFileExtensions,
18
- f as saltyFileRegExp
12
+ g as compileSaltyFile,
13
+ F as generateConfigStyles,
14
+ y as generateCss,
15
+ x as generateFile,
16
+ S as isSaltyFile,
17
+ c as minimizeFile,
18
+ f as saltyFileExtensions,
19
+ C as saltyFileRegExp
19
20
  };
package/config/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../parsers/index.cjs"),t=a=>a;exports.GlobalStylesFactory=e.GlobalStylesFactory;exports.TemplateFactory=e.TemplateFactory;exports.TemplatesFactory=e.TemplatesFactory;exports.VariablesFactory=e.VariablesFactory;exports.defineGlobalStyles=e.defineGlobalStyles;exports.defineMediaQuery=e.defineMediaQuery;exports.defineTemplates=e.defineTemplates;exports.defineVariables=e.defineVariables;exports.defineConfig=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../parsers/index.cjs"),a=require("../define-templates-Cunsb_Tr.cjs"),l=t=>t;exports.GlobalStylesFactory=e.GlobalStylesFactory;exports.VariablesFactory=e.VariablesFactory;exports.defineGlobalStyles=e.defineGlobalStyles;exports.defineMediaQuery=e.defineMediaQuery;exports.defineVariables=e.defineVariables;exports.TemplateFactory=a.TemplateFactory;exports.TemplatesFactory=a.TemplatesFactory;exports.defineTemplates=a.defineTemplates;exports.defineConfig=l;
package/config/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { GlobalStylesFactory as l, TemplateFactory as o, TemplatesFactory as i, VariablesFactory as n, defineGlobalStyles as f, defineMediaQuery as s, defineTemplates as y, defineVariables as d } from "../parsers/index.js";
1
+ import { GlobalStylesFactory as o, VariablesFactory as l, defineGlobalStyles as s, defineMediaQuery as i, defineVariables as f } from "../parsers/index.js";
2
+ import { T as d, a as y, d as p } from "../define-templates-4A2yHcMF.js";
2
3
  const a = (e) => e;
3
4
  export {
4
- l as GlobalStylesFactory,
5
- o as TemplateFactory,
6
- i as TemplatesFactory,
7
- n as VariablesFactory,
5
+ o as GlobalStylesFactory,
6
+ d as TemplateFactory,
7
+ y as TemplatesFactory,
8
+ l as VariablesFactory,
8
9
  a as defineConfig,
9
- f as defineGlobalStyles,
10
- s as defineMediaQuery,
11
- y as defineTemplates,
12
- d as defineVariables
10
+ s as defineGlobalStyles,
11
+ i as defineMediaQuery,
12
+ p as defineTemplates,
13
+ f as defineVariables
13
14
  };
package/css/keyframes.cjs CHANGED
@@ -1 +1 @@
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;
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;
package/css/keyframes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as m } from "../parse-styles-Bi-5cRYF.js";
1
+ import { p as m } from "../parse-styles-Cc_Ir3PV.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 = {}) => {
@@ -0,0 +1,52 @@
1
+ var n = Object.defineProperty;
2
+ var h = (e, t, r) => t in e ? n(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var s = (e, t, r) => h(e, typeof t != "symbol" ? t + "" : t, r);
4
+ class i {
5
+ constructor(t) {
6
+ s(this, "_path");
7
+ this.params = t;
8
+ }
9
+ get _current() {
10
+ return this.params.template;
11
+ }
12
+ get isDefineTemplate() {
13
+ return !0;
14
+ }
15
+ _setPath(t) {
16
+ return this._path = t, this;
17
+ }
18
+ }
19
+ class p {
20
+ constructor(t) {
21
+ s(this, "_path");
22
+ s(this, "templates", []);
23
+ this.params = t, Object.entries(t).forEach(([r, a]) => {
24
+ this.templates.push(
25
+ new i({
26
+ name: r,
27
+ template: a
28
+ })
29
+ );
30
+ });
31
+ }
32
+ get _current() {
33
+ return this.params;
34
+ }
35
+ get _children() {
36
+ return Object.fromEntries(
37
+ this.templates.map((t) => [t.params.name, t])
38
+ );
39
+ }
40
+ get isDefineTemplates() {
41
+ return !0;
42
+ }
43
+ _setPath(t) {
44
+ return this._path = t, this.templates.forEach((r) => r._setPath(t)), this;
45
+ }
46
+ }
47
+ const m = (e) => new p(e);
48
+ export {
49
+ i as T,
50
+ p as a,
51
+ m as d
52
+ };
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var p=(e,t,r)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var s=(e,t,r)=>p(e,typeof t!="symbol"?t+"":t,r);class a{constructor(t){s(this,"_path");this.params=t}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(t){return this._path=t,this}}class n{constructor(t){s(this,"_path");s(this,"templates",[]);this.params=t,Object.entries(t).forEach(([r,h])=>{this.templates.push(new a({name:r,template:h}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(t=>[t.params.name,t]))}get isDefineTemplates(){return!0}_setPath(t){return this._path=t,this.templates.forEach(r=>r._setPath(t)),this}}const c=e=>new n(e);exports.TemplateFactory=a;exports.TemplatesFactory=n;exports.defineTemplates=c;
@@ -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-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
+ "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,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-Bi-5cRYF.js";
4
+ import { p as x } from "../parse-styles-Cc_Ir3PV.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"),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[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const a=o.trim(),S=await ye(i,[...t,a]);s.push(S)}else n[o]=i;if(Object.keys(n).length){const o=t.map(_.dashCase).join("-"),i="t_"+_.toHash(o,4),a=await Y.parseAndJoinStyles(n,`.${o}, .${i}`);s.push(a)}return s.join(`
2
+ `)},_e=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?me(o,i,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 c.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-B6M9WK93.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(o=>o.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await ae(e),s=r.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=r.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(r.join(e,".."))},ae=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Re=async e=>{const t=await ae(e),s=await v(e),n=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=r.join(s,"salty.config.js"),i=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:a});const S=Date.now(),{config:j}=await import(`${o}?t=${S}`);return{config:j,path:o}},$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 L(e,m,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:o,path:i}=await Re(e),a={...o},S=new Set,j=(m,b=[])=>m?Object.entries(m).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=m=>m?Object.entries(m).flatMap(([b,R])=>{const P=j(R);return b==="base"?P.join(""):`${b} { ${P.join("")} }`}):[],d=m=>m?Object.entries(m).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=m=>({...m,responsive:void 0,conditional:void 0}),p=m=>n.variables.map(b=>m==="static"?w(b._current):b._current[m]),g=M.mergeObjects(w(o.variables),p("static")),h=j(g),C=M.mergeObjects((le=o.variables)==null?void 0:le.responsive,p("responsive")),N=l(C),k=M.mergeObjects((fe=o.variables)==null?void 0:fe.conditional,p("conditional")),J=d(k),T=r.join(s,"css/_variables.css"),H=`:root { ${h.join("")} ${N.join("")} } ${J.join("")}`;c.writeFileSync(T,H),a.staticVariables=g;const D=r.join(s,"css/_global.css"),q=M.mergeObjects(o.global,n.globalStyles),f=await Y.parseAndJoinStyles(q,"");c.writeFileSync(D,`@layer global { ${f} }`);const y=r.join(s,"css/_reset.css"),u=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ee,F=await Y.parseAndJoinStyles(u,"");c.writeFileSync(y,`@layer reset { ${F} }`);const x=r.join(s,"css/_templates.css"),E=M.mergeObjects(o.templates,n.templates),I=await ye(E),W=_e(E);c.writeFileSync(x,`@layer templates { ${I} }`),a.templates=E;const A=o.templates?[Ne.defineTemplates(o.templates)._setPath(`config;;${i}`)]:[],Q=M.mergeFactories(n.templates,A);a.templatePaths=Object.fromEntries(Object.entries(Q).map(([m,b])=>[m,b._path]));const{mediaQueries:Z}=n;a.mediaQueries=Object.fromEntries(Z.map(([m,b])=>[`@${m}`,b]));const B=Z.map(([m])=>`'@${m}'`).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(([m,b])=>`${m}?: ${b}`).join(`
10
+ `)}
11
+ }
12
+
13
+ // Media query types
14
+ type MediaQueryKeys = ${B||"''"};
15
+ `;c.writeFileSync(U,Fe);const Ce=r.join(s,"cache/config-cache.json");c.writeFileSync(Ce,JSON.stringify(a,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const a=o.exec(e);if(a){const S=a.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(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),o=r.join(s,"./temp");c.existsSync(o)||c.mkdirSync(o);const i=r.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Ve(a,e);const S=r.join(s,"js",n+".js"),j=await ae(e),l=r.join(e,(j==null?void 0:j.configDir)||"","salty.config.ts"),d=je(l),w=await he(e);await pe.build({stdin:{contents:a,sourcefile:i.base,resolveDir:i.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: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(`${S}?t=${p}`),outputFilePath:S}},Me=async e=>{const t=await v(e),s=r.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},re=async e=>{const t=await Me(e),s=await v(e),n=r.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return M.mergeObjects(i,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 o=[],i=[],a=await v(e),S=r.join(a,"index.css");s&&(()=>{c.existsSync(a)&&Pe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(r.join(a,"css")),c.mkdirSync(r.join(a,"types")),c.mkdirSync(r.join(a,"js")),c.mkdirSync(r.join(a,"cache"))})();const l=new Set,d=new Set;async function w(f){const y=["node_modules","saltygen"],$=c.statSync(f);if($.isDirectory()){const u=c.readdirSync(f);if(y.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>w(r.join(f,x))))}else if($.isFile()&&ee(f)){l.add(f);const F=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&d.add(f)}}await w(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:y}=await L(e,f,a);Object.entries(y).forEach(([$,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:$}):u.isClassName?p.classNames.push({...u,src:f,name:$}):u.generator&&p.components.push({...u,src:f,name:$})})}));const g=await re(e);for(const f of p.keyframes){const{value:y}=f,$=`a_${y.animationName}.css`,u=`css/${$}`,F=r.join(a,u);o.push($),c.writeFileSync(F,y.css)}const h={};for(const f of p.components){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g});i[u.priority]||(i[u.priority]=[]);const F=await u.css;if(!F)continue;i[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}for(const f of p.classNames){const{src:y,name:$}=f;h[y]||(h[y]=[]);const u=f.generator._withBuildContext({callerName:$,isProduction:t,config:g}),F=await u.css;if(!F)continue;i[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,E=r.join(a,x);c.writeFileSync(E,F),g.importStrategy==="component"&&h[y].push(u.cssFileName)}g.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const $=y.map(I=>`@import url('./${I}');`).join(`
20
+ `),u=_.toHash(f,6),F=r.parse(f),x=_.dashCase(F.name),E=r.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(E,$||"/* Empty file */")});const C=o.map(f=>`@import url('./css/${f}');`).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(f=>{try{return c.readFileSync(r.join(a,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
24
+ `)}
25
+ ${C}`;if(g.importStrategy!=="component"){const f=i.reduce((y,$,u)=>{const F=$.reduce((W,A)=>{var U;const Q=r.join(a,"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_${u}.css`,E=r.join(a,"css",x),I=`@layer l${u} { ${F}
30
+ }`;return c.writeFileSync(E,I),`${y}
31
+ @import url('./css/${x}');`},"");T+=f}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 i=[],a=await re(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=r.join(n,C);c.writeFileSync(N,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),C=await h.css;if(!C)continue;i[0].push(h.cssFileName);const N=`css/${h.cssFileName}`,k=r.join(n,N);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:j,isProduction:s,config:a}),w=await d.css;if(!w)continue;const p=`css/${d.cssFileName}`,g=r.join(n,p);c.writeFileSync(g,w),i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")i.forEach((j,l)=>{const d=`l_${l}.css`,w=r.join(n,"css",d);let p=c.readFileSync(w,"utf8");j.forEach(g=>{var k;const h=r.join(n,"css",g),C=((k=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:k.at(1))||_.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),T=`/*start:${C}-${g}*/
32
+ ${J}
33
+ /*end:${C}*/
34
+ `;p=`${p.replace(/\}$/,"")}
35
+ ${T}
36
+ }`}}),c.writeFileSync(w,p)});else{const j=i.flat().map(g=>`@import url('./${g}');`).join(`
37
+ `),l=_.toHash(t,6),d=r.parse(t),w=_.dashCase(d.name),p=r.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 i=c.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==i&&await oe.writeFile(t,i);const S=await re(e),{contents:j}=await L(e,t,n);let l=i;if(Object.entries(j).forEach(([d,w])=>{var u;if(w.isKeyframes||!w.generator)return;const p=w.generator._withBuildContext({callerName:d,isProduction:s,config:S}),g=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!g)return console.error("Could not find the original declaration");const h=(u=g.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 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,f=l.slice(N,q),y=l,$=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,$),y===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),S.importStrategy==="component"){const d=_.toHash(t,6),w=r.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;