@salty-css/core 0.0.1-alpha.146 → 0.0.1-alpha.148

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.
@@ -34,6 +34,10 @@
34
34
  "configDir": {
35
35
  "type": "string",
36
36
  "description": "Dir3ectorywhere the project configuration file is located, relative to the project root."
37
+ },
38
+ "saltygenDir": {
39
+ "type": "string",
40
+ "description": "Directory where the salty css files will be generated to, relative to the project root."
37
41
  }
38
42
  },
39
43
  "required": ["dir", "framework"]
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-78hyHQwZ.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-CLCze-Xg.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-CY22bSGq.js";
6
+ import { l as t, a as h, g as te } from "../index-ChBlB_DP.js";
7
7
  import { p as le } from "../pascal-case-BQpR5PdN.js";
8
8
  import { exec as de } from "child_process";
9
9
  import fe from "ora";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DD4hQEpv.cjs");const e=require("../index-78hyHQwZ.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DD4hQEpv.cjs");const e=require("../index-CLCze-Xg.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
package/compiler/index.js CHANGED
@@ -5,7 +5,7 @@ import "path";
5
5
  import "fs";
6
6
  import "fs/promises";
7
7
  import "../parse-templates-CgZo0YA1.js";
8
- import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-CY22bSGq.js";
8
+ import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-ChBlB_DP.js";
9
9
  export {
10
10
  p as compileSaltyFile,
11
11
  n as generateConfigStyles,
@@ -0,0 +1,29 @@
1
+ "use strict";const de=require("esbuild"),fe=require("child_process"),N=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),i=require("fs"),B=require("fs/promises"),J=require("./parse-templates-DD4hQEpv.cjs"),H=require("winston");var L=typeof document<"u"?document.currentScript:null;function ue(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const X=ue(de),Y=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return i.existsSync(t)?t:Y(r.join(e,".."))},pe=async e=>{const t=Y(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ye=async e=>{const t=await pe(e);if(t)return t.type};let V;const Q=async e=>{if(V)return V;const t=await ye(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:L&&L.tagName.toUpperCase()==="SCRIPT"&&L.src||new URL("index-CLCze-Xg.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},I=H.createLogger({level:"debug",format:H.format.combine(H.format.colorize(),H.format.cli()),transports:[new H.transports.Console({})]}),ge=e=>{I.error(e)};function ee(e){return e?typeof e!="string"?ee(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 me={"*, *::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"}},_={externalModules:[],rcFile:void 0,destDir:void 0},te=e=>{if(_.externalModules.length>0)return _.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(a=>a.replace(/['"`]/g,"").trim());return _.externalModules=c,c},z=async e=>{if(_.destDir)return _.destDir;const t=await Z(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return _.destDir=s,s},K=["salty","css","styles","styled"],se=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),W=(e,t=[])=>se(t).test(e),ne=async e=>{if(_.rcFile)return _.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(_.rcFile=s,s):ne(r.join(e,".."))},Z=async e=>{var c,a;const t=await ne(e),s=(c=t.projects)==null?void 0:c.find(o=>e.endsWith(o.dir||""));return s||((a=t.projects)==null?void 0:a.find(o=>o.dir===t.defaultProject))},he=async e=>{const t=await Z(e),s=await z(e),c=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),a=r.join(s,"salty.config.js"),o=await Q(e),w=te(c);await X.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:a,format:o,external:w});const y=Date.now(),{config:l}=await import(`${a}?t=${y}`);return l},oe=async e=>{const t=await he(e),s=new Set,c=(f,g=[])=>f?Object.entries(f).flatMap(([S,p])=>{if(!p)return;if(typeof p=="object")return c(p,[...g,S]);const R=ee(S),v=N.dashCase(S),D=[...g,R].join(".");s.add(`"${D}"`);const j=[...g.map(N.dashCase),v].join("-"),{result:T}=J.parseValueTokens(p);return`--${j}: ${T};`}):[],a=f=>f?Object.entries(f).flatMap(([g,S])=>{const p=c(S);return g==="base"?p.join(""):`${g} { ${p.join("")} }`}):[],o=f=>f?Object.entries(f).flatMap(([g,S])=>Object.entries(S).flatMap(([p,R])=>{const v=c(R,[g]),D=`.${g}-${p}, [data-${g}="${p}"]`,j=v.join("");return`${D} { ${j} }`})):[],w=c(t.variables),y=a(t.responsiveVariables),l=o(t.conditionalVariables),n=await z(e),u=r.join(n,"css/_variables.css"),m=`:root { ${w.join("")} ${y.join("")} } ${l.join("")}`;i.writeFileSync(u,m);const $=r.join(n,"css/_global.css"),b=J.parseStyles(t.global,"");i.writeFileSync($,`@layer global { ${b} }`);const F=r.join(n,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:me,C=J.parseStyles(h,"");i.writeFileSync(F,`@layer reset { ${C} }`);const d=r.join(n,"css/_templates.css"),x=J.parseTemplates(t.templates),E=J.getTemplateTypes(t.templates);i.writeFileSync(d,x);const k=r.join(n,"types/css-tokens.d.ts"),P=`
2
+ // Variable types
3
+ type VariableTokens = ${[...s].join("|")};
4
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
5
+
6
+ // Template types
7
+ type TemplateTokens = {
8
+ ${Object.entries(E).map(([f,g])=>`${f}?: ${g}`).join(`
9
+ `)}
10
+ }
11
+ `;i.writeFileSync(k,P)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const a=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!a.test(e))return t;const w=a.exec(e);if(w){const y=w.at(1);if(K.some(n=>y==null?void 0:y.includes(n)))return t}return"styled('div',"}),q=async(e,t,s)=>{const c=N.toHash(t),a=r.join(s,"./temp");i.existsSync(a)||i.mkdirSync(a);const o=r.parse(t);let w=i.readFileSync(t,"utf8");w=U(w);const y=r.join(s,"js",c+".js"),l=await Z(e),n=r.join(e,(l==null?void 0:l.configDir)||"","salty.config.ts"),u=te(n),m=await Q(e);await X.build({stdin:{contents:w,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:m,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:F=>{F.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},M=>{const h=i.readFileSync(M.path,"utf8");return{contents:U(h),loader:"ts"}})}}]});const $=Date.now();return await import(`${y}?t=${$}`)},A=async e=>{const t=await z(e),s=r.join(t,"salty.config.js"),c=Date.now(),{config:a}=await import(`${s}?t=${c}`);return a},re=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Se=async(e,t=re())=>{try{const s=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const c=[],a=[],o=await z(e),w=r.join(o,"index.css");(()=>{i.existsSync(o)&&fe.execSync("rm -rf "+o),i.mkdirSync(o,{recursive:!0}),i.mkdirSync(r.join(o,"css")),i.mkdirSync(r.join(o,"types"))})(),await oe(e);const l=await A(e);async function n(d,x){const E=["node_modules","saltygen"],k=i.statSync(d);if(k.isDirectory()){const O=i.readdirSync(d);if(E.some(f=>d.includes(f)))return;await Promise.all(O.map(f=>n(r.join(d,f),r.join(x,f))))}else if(k.isFile()&&W(d)){const P=await q(e,d,o),f=[];Object.entries(P).forEach(([D,j])=>{if(j.isKeyframes&&j.css){const G=`a_${j.animationName}.css`,ae=`css/${G}`,le=r.join(o,ae);c.push(G),i.writeFileSync(le,j.css);return}if(!j.generator)return;const T=j.generator._withBuildContext({name:D,config:l,prod:t});a[T.priority]||(a[T.priority]=[]),a[T.priority].push(T.cssFileName),f.push(T.cssFileName);const ie=`css/${T.cssFileName}`,ce=r.join(o,ie);i.writeFileSync(ce,T.css)});const g=f.map(D=>`@import url('./${D}');`).join(`
12
+ `),S=N.toHash(d,6),p=r.parse(d),R=N.dashCase(p.name),v=r.join(o,`css/f_${R}-${S}.css`);i.writeFileSync(v,g)}}await n(e,o);const u=c.map(d=>`@import url('./css/${d}');`).join(`
13
+ `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
14
+
15
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(d=>{try{return i.readFileSync(r.join(o,"css",d),"utf8").length>0}catch{return!1}}).map(d=>`@import url('./css/${d}');`).join(`
16
+ `)}
17
+ ${u}`;if(l.importStrategy!=="component"){const d=a.reduce((x,E,k)=>{const O=E.reduce((S,p)=>{var j;const R=r.join(o,"css",p),v=i.readFileSync(R,"utf8"),D=((j=/.*-([^-]+)-\d+.css/.exec(p))==null?void 0:j.at(1))||N.toHash(R,6);return S.includes(D)?S:`${S}
18
+ /*start:${D}*/
19
+ ${v}
20
+ /*end:${D}*/
21
+ `},""),P=`l_${k}.css`,f=r.join(o,"css",P),g=`@layer l${k} { ${O}
22
+ }`;return i.writeFileSync(f,g),`${x}
23
+ @import url('./css/${P}');`},"");F+=d}i.writeFileSync(w,F);const h=Date.now()-s,C=h<200?"🔥":h<500?"🚀":h<1e3?"🎉":h<2e3?"🚗":h<5e3?"🤔":"🥴";I.info(`Generated CSS in ${h}ms! ${C}`)}catch(s){console.error(s)}},we=async(e,t)=>{try{const s=await z(e);if(W(t)){const a=[],o=await A(e),w=await q(e,t,s);Object.entries(w).forEach(([y,l])=>{if(l.isKeyframes&&l.css){const b=`css/${`a_${l.animationName}.css`}`,F=r.join(s,b);i.writeFileSync(F,l.css);return}if(!l.generator)return;const n=l.generator._withBuildContext({name:y,config:o}),u=`css/${n.cssFileName}`,m=r.join(s,u);i.writeFileSync(m,n.css),a[n.priority]||(a[n.priority]=[]),a[n.priority].push(n.cssFileName)}),o.importStrategy!=="component"&&a.forEach((y,l)=>{const n=`l_${l}.css`,u=r.join(s,"css",n);let m=i.readFileSync(u,"utf8");y.forEach($=>{var h;const b=r.join(s,"css",$),F=((h=/.*-([^-]+)-\d+.css/.exec($))==null?void 0:h.at(1))||N.toHash(b,6);if(!m.includes(F)){const C=i.readFileSync(b,"utf8"),d=`/*start:${F}*/
24
+ ${C}
25
+ /*end:${F}*/
26
+ `;m=`${m.replace(/\}$/,"")}
27
+ ${d}
28
+ }`}}),i.writeFileSync(u,m)})}}catch(s){console.error(s)}},Fe=async(e,t,s=re())=>{try{const c=await z(e);if(W(t)){const o=i.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==o&&await B.writeFile(t,o);const y=await A(e),l=await q(e,t,c);let n=o;if(Object.entries(l).forEach(([u,m])=>{var S;if(m.isKeyframes||!m.generator)return;const $=m.generator._withBuildContext({name:u,config:y,prod:s}),b=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!b)return console.error("Could not find the original declaration");const F=(S=b.at(1))==null?void 0:S.trim(),M=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(n);if(!M)return console.error("Could not find the original declaration");const{index:h}=M;let C=!1;const d=setTimeout(()=>C=!0,5e3);let x=0,E=!1,k=0;for(;!E&&!C;){const p=n[h+x];p==="("&&k++,p===")"&&k--,k===0&&p===")"&&(E=!0),x>n.length&&(C=!0),x++}if(!C)clearTimeout(d);else throw new Error("Failed to find the end of the styled call and timed out");const O=h+x,P=n.slice(h,O),f=n,g=` ${u} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;n=n.replace(P,g),f===n&&console.error("Minimize file failed to change content",{name:u,tagName:F})}),y.importStrategy==="component"){const u=N.toHash(t,6),m=r.parse(t);n=`import '../../saltygen/css/${`f_${N.dashCase(m.name)}-${u}.css`}';
29
+ ${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=oe;exports.generateCss=Se;exports.generateFile=we;exports.isSaltyFile=W;exports.logError=ge;exports.logger=I;exports.minimizeFile=Fe;exports.saltyFileExtensions=K;exports.saltyFileRegExp=se;
@@ -0,0 +1,376 @@
1
+ import * as Q from "esbuild";
2
+ import { execSync as pt } from "child_process";
3
+ import { t as z, d as H } from "./dash-case-DBThphLm.js";
4
+ import { join as r, parse as K } from "path";
5
+ import { existsSync as L, writeFileSync as S, mkdirSync as W, readFileSync as M, statSync as ut, readdirSync as gt } from "fs";
6
+ import { readFile as tt, writeFile as mt } from "fs/promises";
7
+ import { p as X, a as yt, b as ht, c as $t } from "./parse-templates-CgZo0YA1.js";
8
+ import { createLogger as bt, format as B, transports as wt } from "winston";
9
+ const et = (t) => {
10
+ if (!t || t === "/") throw new Error("Could not find package.json file");
11
+ const e = r(t, "package.json");
12
+ return L(e) ? e : et(r(t, ".."));
13
+ }, St = async (t) => {
14
+ const e = et(t);
15
+ return await tt(e, "utf-8").then(JSON.parse).catch(() => {
16
+ });
17
+ }, Ct = async (t) => {
18
+ const e = await St(t);
19
+ if (e)
20
+ return e.type;
21
+ };
22
+ let J;
23
+ const st = async (t) => {
24
+ if (J) return J;
25
+ const e = await Ct(t);
26
+ return e === "module" ? J = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (J = "cjs"), J || "esm";
27
+ }, I = bt({
28
+ level: "debug",
29
+ format: B.combine(B.colorize(), B.cli()),
30
+ transports: [new wt.Console({})]
31
+ }), Vt = (t) => {
32
+ I.error(t);
33
+ };
34
+ function nt(t) {
35
+ return t ? typeof t != "string" ? nt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
36
+ }
37
+ const Ft = {
38
+ /** Set box model to border-box */
39
+ "*, *::before, *::after": {
40
+ boxSizing: "border-box"
41
+ },
42
+ /** Remove default margin and padding */
43
+ "*": {
44
+ margin: 0
45
+ },
46
+ /** Remove adjust font properties */
47
+ html: {
48
+ lineHeight: 1.15,
49
+ textSizeAdjust: "100%",
50
+ WebkitFontSmoothing: "antialiased"
51
+ },
52
+ /** Make media elements responsive */
53
+ "img, picture, video, canvas, svg": {
54
+ display: "block",
55
+ maxWidth: "100%"
56
+ },
57
+ /** Avoid overflow of text */
58
+ "p, h1, h2, h3, h4, h5, h6": {
59
+ overflowWrap: "break-word"
60
+ },
61
+ /** Improve text wrapping */
62
+ p: {
63
+ textWrap: "pretty"
64
+ },
65
+ "h1, h2, h3, h4, h5, h6": {
66
+ textWrap: "balance"
67
+ },
68
+ /** Improve link color */
69
+ a: {
70
+ color: "currentColor"
71
+ },
72
+ /** Improve button line height */
73
+ button: {
74
+ lineHeight: "1em",
75
+ color: "currentColor"
76
+ },
77
+ /** Improve form elements */
78
+ "input, optgroup, select, textarea": {
79
+ fontFamily: "inherit",
80
+ fontSize: "100%",
81
+ lineHeight: "1.15em"
82
+ }
83
+ }, T = {
84
+ externalModules: [],
85
+ rcFile: void 0,
86
+ destDir: void 0
87
+ }, ot = (t) => {
88
+ if (T.externalModules.length > 0) return T.externalModules;
89
+ const s = M(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
90
+ if (!s) return [];
91
+ const i = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
92
+ return T.externalModules = i, i;
93
+ }, O = async (t) => {
94
+ if (T.destDir) return T.destDir;
95
+ const e = await A(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
96
+ return T.destDir = s, s;
97
+ }, rt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...rt, ...t].join("|")})\\.`), Z = (t, e = []) => xt(e).test(t), at = async (t) => {
98
+ if (T.rcFile) return T.rcFile;
99
+ if (t === "/") throw new Error("Could not find .saltyrc.json file");
100
+ const e = r(t, ".saltyrc.json"), s = await tt(e, "utf-8").then(JSON.parse).catch(() => {
101
+ });
102
+ return s ? (T.rcFile = s, s) : at(r(t, ".."));
103
+ }, A = async (t) => {
104
+ var i, a;
105
+ const e = await at(t), s = (i = e.projects) == null ? void 0 : i.find((o) => t.endsWith(o.dir || ""));
106
+ return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
107
+ }, jt = async (t) => {
108
+ const e = await A(t), s = await O(t), i = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await st(t), $ = ot(i);
109
+ await Q.build({
110
+ entryPoints: [i],
111
+ minify: !0,
112
+ treeShaking: !0,
113
+ bundle: !0,
114
+ outfile: a,
115
+ format: o,
116
+ external: $
117
+ });
118
+ const u = Date.now(), { config: c } = await import(`${a}?t=${u}`);
119
+ return c;
120
+ }, kt = async (t) => {
121
+ const e = await jt(t), s = /* @__PURE__ */ new Set(), i = (f, g = []) => f ? Object.entries(f).flatMap(([h, p]) => {
122
+ if (!p) return;
123
+ if (typeof p == "object") return i(p, [...g, h]);
124
+ const _ = nt(h), v = H(h), D = [...g, _].join(".");
125
+ s.add(`"${D}"`);
126
+ const w = [...g.map(H), v].join("-"), { result: N } = $t(p);
127
+ return `--${w}: ${N};`;
128
+ }) : [], a = (f) => f ? Object.entries(f).flatMap(([g, h]) => {
129
+ const p = i(h);
130
+ return g === "base" ? p.join("") : `${g} { ${p.join("")} }`;
131
+ }) : [], o = (f) => f ? Object.entries(f).flatMap(([g, h]) => Object.entries(h).flatMap(([p, _]) => {
132
+ const v = i(_, [g]), D = `.${g}-${p}, [data-${g}="${p}"]`, w = v.join("");
133
+ return `${D} { ${w} }`;
134
+ })) : [], $ = i(e.variables), u = a(e.responsiveVariables), c = o(e.conditionalVariables), n = await O(t), d = r(n, "css/_variables.css"), m = `:root { ${$.join("")} ${u.join("")} } ${c.join("")}`;
135
+ S(d, m);
136
+ const C = r(n, "css/_global.css"), F = X(e.global, "");
137
+ S(C, `@layer global { ${F} }`);
138
+ const b = r(n, "css/_reset.css"), y = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : Ft, x = X(y, "");
139
+ S(b, `@layer reset { ${x} }`);
140
+ const l = r(n, "css/_templates.css"), j = yt(e.templates), E = ht(e.templates);
141
+ S(l, j);
142
+ const k = r(n, "types/css-tokens.d.ts"), P = `
143
+ // Variable types
144
+ type VariableTokens = ${[...s].join("|")};
145
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
146
+
147
+ // Template types
148
+ type TemplateTokens = {
149
+ ${Object.entries(E).map(([f, g]) => `${f}?: ${g}`).join(`
150
+ `)}
151
+ }
152
+ `;
153
+ S(k, P);
154
+ }, Y = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
155
+ if (/^['"`]/.test(s)) return e;
156
+ const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
157
+ if (!a.test(t)) return e;
158
+ const $ = a.exec(t);
159
+ if ($) {
160
+ const u = $.at(1);
161
+ if (rt.some((n) => u == null ? void 0 : u.includes(n))) return e;
162
+ }
163
+ return "styled('div',";
164
+ }), G = async (t, e, s) => {
165
+ const i = z(e), a = r(s, "./temp");
166
+ L(a) || W(a);
167
+ const o = K(e);
168
+ let $ = M(e, "utf8");
169
+ $ = Y($);
170
+ const u = r(s, "js", i + ".js"), c = await A(t), n = r(t, (c == null ? void 0 : c.configDir) || "", "salty.config.ts"), d = ot(n), m = await st(t);
171
+ await Q.build({
172
+ stdin: {
173
+ contents: $,
174
+ sourcefile: o.base,
175
+ resolveDir: o.dir,
176
+ loader: "tsx"
177
+ },
178
+ minify: !1,
179
+ treeShaking: !0,
180
+ bundle: !0,
181
+ outfile: u,
182
+ format: m,
183
+ target: ["node20"],
184
+ keepNames: !0,
185
+ external: d,
186
+ packages: "external",
187
+ plugins: [
188
+ {
189
+ name: "test",
190
+ setup: (b) => {
191
+ b.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (V) => {
192
+ const y = M(V.path, "utf8");
193
+ return { contents: Y(y), loader: "ts" };
194
+ });
195
+ }
196
+ }
197
+ ]
198
+ });
199
+ const C = Date.now();
200
+ return await import(`${u}?t=${C}`);
201
+ }, q = async (t) => {
202
+ const e = await O(t), s = r(e, "salty.config.js"), i = Date.now(), { config: a } = await import(`${s}?t=${i}`);
203
+ return a;
204
+ }, it = () => {
205
+ try {
206
+ return process.env.NODE_ENV === "production";
207
+ } catch {
208
+ return !1;
209
+ }
210
+ }, Rt = async (t, e = it()) => {
211
+ try {
212
+ const s = Date.now();
213
+ e ? I.info("Generating CSS in production mode! 🔥") : I.info("Generating CSS in development mode! 🚀");
214
+ const i = [], a = [], o = await O(t), $ = r(o, "index.css");
215
+ (() => {
216
+ L(o) && pt("rm -rf " + o), W(o, { recursive: !0 }), W(r(o, "css")), W(r(o, "types"));
217
+ })(), await kt(t);
218
+ const c = await q(t);
219
+ async function n(l, j) {
220
+ const E = ["node_modules", "saltygen"], k = ut(l);
221
+ if (k.isDirectory()) {
222
+ const R = gt(l);
223
+ if (E.some((f) => l.includes(f))) return;
224
+ await Promise.all(R.map((f) => n(r(l, f), r(j, f))));
225
+ } else if (k.isFile() && Z(l)) {
226
+ const P = await G(t, l, o), f = [];
227
+ Object.entries(P).forEach(([D, w]) => {
228
+ if (w.isKeyframes && w.css) {
229
+ const U = `a_${w.animationName}.css`, ft = `css/${U}`, dt = r(o, ft);
230
+ i.push(U), S(dt, w.css);
231
+ return;
232
+ }
233
+ if (!w.generator) return;
234
+ const N = w.generator._withBuildContext({
235
+ name: D,
236
+ config: c,
237
+ prod: e
238
+ });
239
+ a[N.priority] || (a[N.priority] = []), a[N.priority].push(N.cssFileName), f.push(N.cssFileName);
240
+ const ct = `css/${N.cssFileName}`, lt = r(o, ct);
241
+ S(lt, N.css);
242
+ });
243
+ const g = f.map((D) => `@import url('./${D}');`).join(`
244
+ `), h = z(l, 6), p = K(l), _ = H(p.name), v = r(o, `css/f_${_}-${h}.css`);
245
+ S(v, g);
246
+ }
247
+ }
248
+ await n(t, o);
249
+ const d = i.map((l) => `@import url('./css/${l}');`).join(`
250
+ `);
251
+ let b = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
252
+
253
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
254
+ try {
255
+ return M(r(o, "css", l), "utf8").length > 0;
256
+ } catch {
257
+ return !1;
258
+ }
259
+ }).map((l) => `@import url('./css/${l}');`).join(`
260
+ `)}
261
+ ${d}`;
262
+ if (c.importStrategy !== "component") {
263
+ const l = a.reduce((j, E, k) => {
264
+ const R = E.reduce((h, p) => {
265
+ var w;
266
+ const _ = r(o, "css", p), v = M(_, "utf8"), D = ((w = /.*-([^-]+)-\d+.css/.exec(p)) == null ? void 0 : w.at(1)) || z(_, 6);
267
+ return h.includes(D) ? h : `${h}
268
+ /*start:${D}*/
269
+ ${v}
270
+ /*end:${D}*/
271
+ `;
272
+ }, ""), P = `l_${k}.css`, f = r(o, "css", P), g = `@layer l${k} { ${R}
273
+ }`;
274
+ return S(f, g), `${j}
275
+ @import url('./css/${P}');`;
276
+ }, "");
277
+ b += l;
278
+ }
279
+ S($, b);
280
+ const y = Date.now() - s, x = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
281
+ I.info(`Generated CSS in ${y}ms! ${x}`);
282
+ } catch (s) {
283
+ console.error(s);
284
+ }
285
+ }, vt = async (t, e) => {
286
+ try {
287
+ const s = await O(t);
288
+ if (Z(e)) {
289
+ const a = [], o = await q(t), $ = await G(t, e, s);
290
+ Object.entries($).forEach(([u, c]) => {
291
+ if (c.isKeyframes && c.css) {
292
+ const F = `css/${`a_${c.animationName}.css`}`, b = r(s, F);
293
+ S(b, c.css);
294
+ return;
295
+ }
296
+ if (!c.generator) return;
297
+ const n = c.generator._withBuildContext({
298
+ name: u,
299
+ config: o
300
+ }), d = `css/${n.cssFileName}`, m = r(s, d);
301
+ S(m, n.css), a[n.priority] || (a[n.priority] = []), a[n.priority].push(n.cssFileName);
302
+ }), o.importStrategy !== "component" && a.forEach((u, c) => {
303
+ const n = `l_${c}.css`, d = r(s, "css", n);
304
+ let m = M(d, "utf8");
305
+ u.forEach((C) => {
306
+ var y;
307
+ const F = r(s, "css", C), b = ((y = /.*-([^-]+)-\d+.css/.exec(C)) == null ? void 0 : y.at(1)) || z(F, 6);
308
+ if (!m.includes(b)) {
309
+ const x = M(F, "utf8"), l = `/*start:${b}*/
310
+ ${x}
311
+ /*end:${b}*/
312
+ `;
313
+ m = `${m.replace(/\}$/, "")}
314
+ ${l}
315
+ }`;
316
+ }
317
+ }), S(d, m);
318
+ });
319
+ }
320
+ } catch (s) {
321
+ console.error(s);
322
+ }
323
+ }, Jt = async (t, e, s = it()) => {
324
+ try {
325
+ const i = await O(t);
326
+ if (Z(e)) {
327
+ const o = M(e, "utf8");
328
+ o.replace(/^(?!export\s)const\s.*/gm, (d) => `export ${d}`) !== o && await mt(e, o);
329
+ const u = await q(t), c = await G(t, e, i);
330
+ let n = o;
331
+ if (Object.entries(c).forEach(([d, m]) => {
332
+ var h;
333
+ if (m.isKeyframes || !m.generator) return;
334
+ const C = m.generator._withBuildContext({
335
+ name: d,
336
+ config: u,
337
+ prod: s
338
+ }), F = new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
339
+ if (!F) return console.error("Could not find the original declaration");
340
+ const b = (h = F.at(1)) == null ? void 0 : h.trim(), V = new RegExp(`\\s${d}[=\\s]+styled\\(`, "g").exec(n);
341
+ if (!V) return console.error("Could not find the original declaration");
342
+ const { index: y } = V;
343
+ let x = !1;
344
+ const l = setTimeout(() => x = !0, 5e3);
345
+ let j = 0, E = !1, k = 0;
346
+ for (; !E && !x; ) {
347
+ const p = n[y + j];
348
+ p === "(" && k++, p === ")" && k--, k === 0 && p === ")" && (E = !0), j > n.length && (x = !0), j++;
349
+ }
350
+ if (!x) clearTimeout(l);
351
+ else throw new Error("Failed to find the end of the styled call and timed out");
352
+ const R = y + j, P = n.slice(y, R), f = n, g = ` ${d} = styled(${b}, "${C.classNames}", ${JSON.stringify(C.props)});`;
353
+ n = n.replace(P, g), f === n && console.error("Minimize file failed to change content", { name: d, tagName: b });
354
+ }), u.importStrategy === "component") {
355
+ const d = z(e, 6), m = K(e);
356
+ n = `import '../../saltygen/css/${`f_${H(m.name)}-${d}.css`}';
357
+ ${n}`;
358
+ }
359
+ return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
360
+ }
361
+ } catch (i) {
362
+ console.error("Error in minimizeFile:", i);
363
+ }
364
+ };
365
+ export {
366
+ Vt as a,
367
+ xt as b,
368
+ kt as c,
369
+ G as d,
370
+ vt as e,
371
+ Rt as g,
372
+ Z as i,
373
+ I as l,
374
+ Jt as m,
375
+ rt as s
376
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.146",
3
+ "version": "0.0.1-alpha.148",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -5,5 +5,6 @@ export interface RCFile {
5
5
  framework?: string;
6
6
  components?: string;
7
7
  configDir?: string;
8
+ saltygenDir?: string;
8
9
  }[];
9
10
  }
@@ -1,29 +0,0 @@
1
- "use strict";const de=require("esbuild"),fe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),B=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var q=typeof document<"u"?document.currentScript:null;function ue(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const U=ue(de),X=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:X(o.join(e,".."))},pe=async e=>{const t=X(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ye=async e=>{const t=await pe(e);if(t)return t.type};let V;const Y=async e=>{if(V)return V;const t=await ye(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-78hyHQwZ.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),ge=e=>{J.error(e)};function Q(e){return e?typeof e!="string"?Q(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 me={"*, *::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"}},L={externalModules:[]},ee=e=>{if(L.externalModules.length>0)return L.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(a=>a.replace(/['"`]/g,"").trim());return L.externalModules=c,c},H=e=>o.join(e,"./saltygen"),K=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),se=async e=>{if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=o.join(e,".saltyrc.json"),s=await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s||se(o.join(e,".."))},ne=async e=>{var c,a;const t=await se(e),s=(c=t.projects)==null?void 0:c.find(r=>e.endsWith(r.dir||""));return s||((a=t.projects)==null?void 0:a.find(r=>r.dir===t.defaultProject))},he=async e=>{const t=await ne(e),s=H(e),c=o.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),a=o.join(s,"salty.config.js"),r=await Y(e),j=ee(c);await U.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:a,format:r,external:j});const y=Date.now(),{config:l}=await import(`${a}?t=${y}`);return l},oe=async e=>{const t=await he(e),s=new Set,c=(f,g=[])=>f?Object.entries(f).flatMap(([S,p])=>{if(!p)return;if(typeof p=="object")return c(p,[...g,S]);const E=Q(S),O=D.dashCase(S),P=[...g,E].join(".");s.add(`"${P}"`);const w=[...g.map(D.dashCase),O].join("-"),{result:N}=v.parseValueTokens(p);return`--${w}: ${N};`}):[],a=f=>f?Object.entries(f).flatMap(([g,S])=>{const p=c(S);return g==="base"?p.join(""):`${g} { ${p.join("")} }`}):[],r=f=>f?Object.entries(f).flatMap(([g,S])=>Object.entries(S).flatMap(([p,E])=>{const O=c(E,[g]),P=`.${g}-${p}, [data-${g}="${p}"]`,w=O.join("");return`${P} { ${w} }`})):[],j=c(t.variables),y=a(t.responsiveVariables),l=r(t.conditionalVariables),n=H(e),u=o.join(n,"css/_variables.css"),m=`:root { ${j.join("")} ${y.join("")} } ${l.join("")}`;i.writeFileSync(u,m);const F=o.join(n,"css/_global.css"),b=v.parseStyles(t.global,"");i.writeFileSync(F,`@layer global { ${b} }`);const $=o.join(n,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:me,C=v.parseStyles(h,"");i.writeFileSync($,`@layer reset { ${C} }`);const d=o.join(n,"css/_templates.css"),x=v.parseTemplates(t.templates),_=v.getTemplateTypes(t.templates);i.writeFileSync(d,x);const k=o.join(n,"types/css-tokens.d.ts"),T=`
2
- // Variable types
3
- type VariableTokens = ${[...s].join("|")};
4
- type PropertyValueToken = \`{\${VariableTokens}}\`;
5
-
6
- // Template types
7
- type TemplateTokens = {
8
- ${Object.entries(_).map(([f,g])=>`${f}?: ${g}`).join(`
9
- `)}
10
- }
11
- `;i.writeFileSync(k,T)},G=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const a=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!a.test(e))return t;const j=a.exec(e);if(j){const y=j.at(1);if(K.some(n=>y==null?void 0:y.includes(n)))return t}return"styled('div',"}),W=async(e,t,s)=>{const c=D.toHash(t),a=o.join(s,"./temp");i.existsSync(a)||i.mkdirSync(a);const r=o.parse(t);let j=i.readFileSync(t,"utf8");j=G(j);const y=o.join(s,"js",c+".js"),l=await ne(e),n=o.join(e,(l==null?void 0:l.configDir)||"","salty.config.ts"),u=ee(n),m=await Y(e);await U.build({stdin:{contents:j,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:m,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:$=>{$.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},R=>{const h=i.readFileSync(R.path,"utf8");return{contents:G(h),loader:"ts"}})}}]});const F=Date.now();return await import(`${y}?t=${F}`)},Z=async e=>{const t=H(e),s=o.join(t,"salty.config.js"),c=Date.now(),{config:a}=await import(`${s}?t=${c}`);return a},re=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Se=async(e,t=re())=>{try{const s=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const c=[],a=[],r=H(e),j=o.join(r,"index.css");(()=>{i.existsSync(r)&&fe.execSync("rm -rf "+r),i.mkdirSync(r),i.mkdirSync(o.join(r,"css")),i.mkdirSync(o.join(r,"types"))})(),await oe(e);const l=await Z(e);async function n(d,x){const _=["node_modules","saltygen"],k=i.statSync(d);if(k.isDirectory()){const M=i.readdirSync(d);if(_.some(f=>d.includes(f)))return;await Promise.all(M.map(f=>n(o.join(d,f),o.join(x,f))))}else if(k.isFile()&&I(d)){const T=await W(e,d,r),f=[];Object.entries(T).forEach(([P,w])=>{if(w.isKeyframes&&w.css){const A=`a_${w.animationName}.css`,ae=`css/${A}`,le=o.join(r,ae);c.push(A),i.writeFileSync(le,w.css);return}if(!w.generator)return;const N=w.generator._withBuildContext({name:P,config:l,prod:t});a[N.priority]||(a[N.priority]=[]),a[N.priority].push(N.cssFileName),f.push(N.cssFileName);const ie=`css/${N.cssFileName}`,ce=o.join(r,ie);i.writeFileSync(ce,N.css)});const g=f.map(P=>`@import url('./${P}');`).join(`
12
- `),S=D.toHash(d,6),p=o.parse(d),E=D.dashCase(p.name),O=o.join(r,`css/f_${E}-${S}.css`);i.writeFileSync(O,g)}}await n(e,r);const u=c.map(d=>`@import url('./css/${d}');`).join(`
13
- `);let $=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
14
-
15
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(d=>{try{return i.readFileSync(o.join(r,"css",d),"utf8").length>0}catch{return!1}}).map(d=>`@import url('./css/${d}');`).join(`
16
- `)}
17
- ${u}`;if(l.importStrategy!=="component"){const d=a.reduce((x,_,k)=>{const M=_.reduce((S,p)=>{var w;const E=o.join(r,"css",p),O=i.readFileSync(E,"utf8"),P=((w=/.*-([^-]+)-\d+.css/.exec(p))==null?void 0:w.at(1))||D.toHash(E,6);return S.includes(P)?S:`${S}
18
- /*start:${P}*/
19
- ${O}
20
- /*end:${P}*/
21
- `},""),T=`l_${k}.css`,f=o.join(r,"css",T),g=`@layer l${k} { ${M}
22
- }`;return i.writeFileSync(f,g),`${x}
23
- @import url('./css/${T}');`},"");$+=d}i.writeFileSync(j,$);const h=Date.now()-s,C=h<200?"🔥":h<500?"🚀":h<1e3?"🎉":h<2e3?"🚗":h<5e3?"🤔":"🥴";J.info(`Generated CSS in ${h}ms! ${C}`)}catch(s){console.error(s)}},je=async(e,t)=>{try{const s=o.join(e,"./saltygen");if(I(t)){const a=[],r=await Z(e),j=await W(e,t,s);Object.entries(j).forEach(([y,l])=>{if(l.isKeyframes&&l.css){const b=`css/${`a_${l.animationName}.css`}`,$=o.join(s,b);i.writeFileSync($,l.css);return}if(!l.generator)return;const n=l.generator._withBuildContext({name:y,config:r}),u=`css/${n.cssFileName}`,m=o.join(s,u);i.writeFileSync(m,n.css),a[n.priority]||(a[n.priority]=[]),a[n.priority].push(n.cssFileName)}),r.importStrategy!=="component"&&a.forEach((y,l)=>{const n=`l_${l}.css`,u=o.join(s,"css",n);let m=i.readFileSync(u,"utf8");y.forEach(F=>{var h;const b=o.join(s,"css",F),$=((h=/.*-([^-]+)-\d+.css/.exec(F))==null?void 0:h.at(1))||D.toHash(b,6);if(!m.includes($)){const C=i.readFileSync(b,"utf8"),d=`/*start:${$}*/
24
- ${C}
25
- /*end:${$}*/
26
- `;m=`${m.replace(/\}$/,"")}
27
- ${d}
28
- }`}}),i.writeFileSync(u,m)})}}catch(s){console.error(s)}},$e=async(e,t,s=re())=>{try{const c=o.join(e,"./saltygen");if(I(t)){const r=i.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==r&&await B.writeFile(t,r);const y=await Z(e),l=await W(e,t,c);let n=r;if(Object.entries(l).forEach(([u,m])=>{var S;if(m.isKeyframes||!m.generator)return;const F=m.generator._withBuildContext({name:u,config:y,prod:s}),b=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!b)return console.error("Could not find the original declaration");const $=(S=b.at(1))==null?void 0:S.trim(),R=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(n);if(!R)return console.error("Could not find the original declaration");const{index:h}=R;let C=!1;const d=setTimeout(()=>C=!0,5e3);let x=0,_=!1,k=0;for(;!_&&!C;){const p=n[h+x];p==="("&&k++,p===")"&&k--,k===0&&p===")"&&(_=!0),x>n.length&&(C=!0),x++}if(!C)clearTimeout(d);else throw new Error("Failed to find the end of the styled call and timed out");const M=h+x,T=n.slice(h,M),f=n,g=` ${u} = styled(${$}, "${F.classNames}", ${JSON.stringify(F.props)});`;n=n.replace(T,g),f===n&&console.error("Minimize file failed to change content",{name:u,tagName:$})}),y.importStrategy==="component"){const u=D.toHash(t,6),m=o.parse(t);n=`import '../../saltygen/css/${`f_${D.dashCase(m.name)}-${u}.css`}';
29
- ${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=W;exports.generateConfigStyles=oe;exports.generateCss=Se;exports.generateFile=je;exports.isSaltyFile=I;exports.logError=ge;exports.logger=J;exports.minimizeFile=$e;exports.saltyFileExtensions=K;exports.saltyFileRegExp=te;
package/index-CY22bSGq.js DELETED
@@ -1,369 +0,0 @@
1
- import * as Y from "esbuild";
2
- import { execSync as dt } from "child_process";
3
- import { t as J, d as W } from "./dash-case-DBThphLm.js";
4
- import { join as r, parse as K } from "path";
5
- import { existsSync as L, writeFileSync as S, mkdirSync as O, readFileSync as _, statSync as ut, readdirSync as gt } from "fs";
6
- import { readFile as Q, writeFile as mt } from "fs/promises";
7
- import { p as U, a as yt, b as ht, c as $t } from "./parse-templates-CgZo0YA1.js";
8
- import { createLogger as bt, format as H, transports as wt } from "winston";
9
- const tt = (t) => {
10
- if (!t || t === "/") throw new Error("Could not find package.json file");
11
- const e = r(t, "package.json");
12
- return L(e) ? e : tt(r(t, ".."));
13
- }, St = async (t) => {
14
- const e = tt(t);
15
- return await Q(e, "utf-8").then(JSON.parse).catch(() => {
16
- });
17
- }, Ct = async (t) => {
18
- const e = await St(t);
19
- if (e)
20
- return e.type;
21
- };
22
- let v;
23
- const et = async (t) => {
24
- if (v) return v;
25
- const e = await Ct(t);
26
- return e === "module" ? v = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (v = "cjs"), v || "esm";
27
- }, z = bt({
28
- level: "debug",
29
- format: H.combine(H.colorize(), H.cli()),
30
- transports: [new wt.Console({})]
31
- }), Vt = (t) => {
32
- z.error(t);
33
- };
34
- function st(t) {
35
- return t ? typeof t != "string" ? st(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
36
- }
37
- const xt = {
38
- /** Set box model to border-box */
39
- "*, *::before, *::after": {
40
- boxSizing: "border-box"
41
- },
42
- /** Remove default margin and padding */
43
- "*": {
44
- margin: 0
45
- },
46
- /** Remove adjust font properties */
47
- html: {
48
- lineHeight: 1.15,
49
- textSizeAdjust: "100%",
50
- WebkitFontSmoothing: "antialiased"
51
- },
52
- /** Make media elements responsive */
53
- "img, picture, video, canvas, svg": {
54
- display: "block",
55
- maxWidth: "100%"
56
- },
57
- /** Avoid overflow of text */
58
- "p, h1, h2, h3, h4, h5, h6": {
59
- overflowWrap: "break-word"
60
- },
61
- /** Improve text wrapping */
62
- p: {
63
- textWrap: "pretty"
64
- },
65
- "h1, h2, h3, h4, h5, h6": {
66
- textWrap: "balance"
67
- },
68
- /** Improve link color */
69
- a: {
70
- color: "currentColor"
71
- },
72
- /** Improve button line height */
73
- button: {
74
- lineHeight: "1em",
75
- color: "currentColor"
76
- },
77
- /** Improve form elements */
78
- "input, optgroup, select, textarea": {
79
- fontFamily: "inherit",
80
- fontSize: "100%",
81
- lineHeight: "1.15em"
82
- }
83
- }, B = {
84
- externalModules: []
85
- }, nt = (t) => {
86
- if (B.externalModules.length > 0) return B.externalModules;
87
- const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
88
- if (!s) return [];
89
- const c = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
90
- return B.externalModules = c, c;
91
- }, I = (t) => r(t, "./saltygen"), ot = ["salty", "css", "styles", "styled"], Ft = (t = []) => new RegExp(`\\.(${[...ot, ...t].join("|")})\\.`), Z = (t, e = []) => Ft(e).test(t), rt = async (t) => {
92
- if (t === "/") throw new Error("Could not find .saltyrc.json file");
93
- const e = r(t, ".saltyrc.json"), s = await Q(e, "utf-8").then(JSON.parse).catch(() => {
94
- });
95
- return s || rt(r(t, ".."));
96
- }, at = async (t) => {
97
- var c, a;
98
- const e = await rt(t), s = (c = e.projects) == null ? void 0 : c.find((o) => t.endsWith(o.dir || ""));
99
- return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
100
- }, jt = async (t) => {
101
- const e = await at(t), s = I(t), c = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await et(t), $ = nt(c);
102
- await Y.build({
103
- entryPoints: [c],
104
- minify: !0,
105
- treeShaking: !0,
106
- bundle: !0,
107
- outfile: a,
108
- format: o,
109
- external: $
110
- });
111
- const u = Date.now(), { config: i } = await import(`${a}?t=${u}`);
112
- return i;
113
- }, kt = async (t) => {
114
- const e = await jt(t), s = /* @__PURE__ */ new Set(), c = (f, g = []) => f ? Object.entries(f).flatMap(([h, d]) => {
115
- if (!d) return;
116
- if (typeof d == "object") return c(d, [...g, h]);
117
- const E = st(h), R = W(h), P = [...g, E].join(".");
118
- s.add(`"${P}"`);
119
- const w = [...g.map(W), R].join("-"), { result: T } = $t(d);
120
- return `--${w}: ${T};`;
121
- }) : [], a = (f) => f ? Object.entries(f).flatMap(([g, h]) => {
122
- const d = c(h);
123
- return g === "base" ? d.join("") : `${g} { ${d.join("")} }`;
124
- }) : [], o = (f) => f ? Object.entries(f).flatMap(([g, h]) => Object.entries(h).flatMap(([d, E]) => {
125
- const R = c(E, [g]), P = `.${g}-${d}, [data-${g}="${d}"]`, w = R.join("");
126
- return `${P} { ${w} }`;
127
- })) : [], $ = c(e.variables), u = a(e.responsiveVariables), i = o(e.conditionalVariables), n = I(t), p = r(n, "css/_variables.css"), m = `:root { ${$.join("")} ${u.join("")} } ${i.join("")}`;
128
- S(p, m);
129
- const C = r(n, "css/_global.css"), x = U(e.global, "");
130
- S(C, `@layer global { ${x} }`);
131
- const b = r(n, "css/_reset.css"), y = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : xt, F = U(y, "");
132
- S(b, `@layer reset { ${F} }`);
133
- const l = r(n, "css/_templates.css"), j = yt(e.templates), D = ht(e.templates);
134
- S(l, j);
135
- const k = r(n, "types/css-tokens.d.ts"), N = `
136
- // Variable types
137
- type VariableTokens = ${[...s].join("|")};
138
- type PropertyValueToken = \`{\${VariableTokens}}\`;
139
-
140
- // Template types
141
- type TemplateTokens = {
142
- ${Object.entries(D).map(([f, g]) => `${f}?: ${g}`).join(`
143
- `)}
144
- }
145
- `;
146
- S(k, N);
147
- }, X = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
148
- if (/^['"`]/.test(s)) return e;
149
- const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
150
- if (!a.test(t)) return e;
151
- const $ = a.exec(t);
152
- if ($) {
153
- const u = $.at(1);
154
- if (ot.some((n) => u == null ? void 0 : u.includes(n))) return e;
155
- }
156
- return "styled('div',";
157
- }), A = async (t, e, s) => {
158
- const c = J(e), a = r(s, "./temp");
159
- L(a) || O(a);
160
- const o = K(e);
161
- let $ = _(e, "utf8");
162
- $ = X($);
163
- const u = r(s, "js", c + ".js"), i = await at(t), n = r(t, (i == null ? void 0 : i.configDir) || "", "salty.config.ts"), p = nt(n), m = await et(t);
164
- await Y.build({
165
- stdin: {
166
- contents: $,
167
- sourcefile: o.base,
168
- resolveDir: o.dir,
169
- loader: "tsx"
170
- },
171
- minify: !1,
172
- treeShaking: !0,
173
- bundle: !0,
174
- outfile: u,
175
- format: m,
176
- target: ["node20"],
177
- keepNames: !0,
178
- external: p,
179
- packages: "external",
180
- plugins: [
181
- {
182
- name: "test",
183
- setup: (b) => {
184
- b.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (M) => {
185
- const y = _(M.path, "utf8");
186
- return { contents: X(y), loader: "ts" };
187
- });
188
- }
189
- }
190
- ]
191
- });
192
- const C = Date.now();
193
- return await import(`${u}?t=${C}`);
194
- }, G = async (t) => {
195
- const e = I(t), s = r(e, "salty.config.js"), c = Date.now(), { config: a } = await import(`${s}?t=${c}`);
196
- return a;
197
- }, ct = () => {
198
- try {
199
- return process.env.NODE_ENV === "production";
200
- } catch {
201
- return !1;
202
- }
203
- }, Rt = async (t, e = ct()) => {
204
- try {
205
- const s = Date.now();
206
- e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
207
- const c = [], a = [], o = I(t), $ = r(o, "index.css");
208
- (() => {
209
- L(o) && dt("rm -rf " + o), O(o), O(r(o, "css")), O(r(o, "types"));
210
- })(), await kt(t);
211
- const i = await G(t);
212
- async function n(l, j) {
213
- const D = ["node_modules", "saltygen"], k = ut(l);
214
- if (k.isDirectory()) {
215
- const V = gt(l);
216
- if (D.some((f) => l.includes(f))) return;
217
- await Promise.all(V.map((f) => n(r(l, f), r(j, f))));
218
- } else if (k.isFile() && Z(l)) {
219
- const N = await A(t, l, o), f = [];
220
- Object.entries(N).forEach(([P, w]) => {
221
- if (w.isKeyframes && w.css) {
222
- const q = `a_${w.animationName}.css`, ft = `css/${q}`, pt = r(o, ft);
223
- c.push(q), S(pt, w.css);
224
- return;
225
- }
226
- if (!w.generator) return;
227
- const T = w.generator._withBuildContext({
228
- name: P,
229
- config: i,
230
- prod: e
231
- });
232
- a[T.priority] || (a[T.priority] = []), a[T.priority].push(T.cssFileName), f.push(T.cssFileName);
233
- const it = `css/${T.cssFileName}`, lt = r(o, it);
234
- S(lt, T.css);
235
- });
236
- const g = f.map((P) => `@import url('./${P}');`).join(`
237
- `), h = J(l, 6), d = K(l), E = W(d.name), R = r(o, `css/f_${E}-${h}.css`);
238
- S(R, g);
239
- }
240
- }
241
- await n(t, o);
242
- const p = c.map((l) => `@import url('./css/${l}');`).join(`
243
- `);
244
- let b = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
245
-
246
- ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
247
- try {
248
- return _(r(o, "css", l), "utf8").length > 0;
249
- } catch {
250
- return !1;
251
- }
252
- }).map((l) => `@import url('./css/${l}');`).join(`
253
- `)}
254
- ${p}`;
255
- if (i.importStrategy !== "component") {
256
- const l = a.reduce((j, D, k) => {
257
- const V = D.reduce((h, d) => {
258
- var w;
259
- const E = r(o, "css", d), R = _(E, "utf8"), P = ((w = /.*-([^-]+)-\d+.css/.exec(d)) == null ? void 0 : w.at(1)) || J(E, 6);
260
- return h.includes(P) ? h : `${h}
261
- /*start:${P}*/
262
- ${R}
263
- /*end:${P}*/
264
- `;
265
- }, ""), N = `l_${k}.css`, f = r(o, "css", N), g = `@layer l${k} { ${V}
266
- }`;
267
- return S(f, g), `${j}
268
- @import url('./css/${N}');`;
269
- }, "");
270
- b += l;
271
- }
272
- S($, b);
273
- const y = Date.now() - s, F = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
274
- z.info(`Generated CSS in ${y}ms! ${F}`);
275
- } catch (s) {
276
- console.error(s);
277
- }
278
- }, vt = async (t, e) => {
279
- try {
280
- const s = r(t, "./saltygen");
281
- if (Z(e)) {
282
- const a = [], o = await G(t), $ = await A(t, e, s);
283
- Object.entries($).forEach(([u, i]) => {
284
- if (i.isKeyframes && i.css) {
285
- const x = `css/${`a_${i.animationName}.css`}`, b = r(s, x);
286
- S(b, i.css);
287
- return;
288
- }
289
- if (!i.generator) return;
290
- const n = i.generator._withBuildContext({
291
- name: u,
292
- config: o
293
- }), p = `css/${n.cssFileName}`, m = r(s, p);
294
- S(m, n.css), a[n.priority] || (a[n.priority] = []), a[n.priority].push(n.cssFileName);
295
- }), o.importStrategy !== "component" && a.forEach((u, i) => {
296
- const n = `l_${i}.css`, p = r(s, "css", n);
297
- let m = _(p, "utf8");
298
- u.forEach((C) => {
299
- var y;
300
- const x = r(s, "css", C), b = ((y = /.*-([^-]+)-\d+.css/.exec(C)) == null ? void 0 : y.at(1)) || J(x, 6);
301
- if (!m.includes(b)) {
302
- const F = _(x, "utf8"), l = `/*start:${b}*/
303
- ${F}
304
- /*end:${b}*/
305
- `;
306
- m = `${m.replace(/\}$/, "")}
307
- ${l}
308
- }`;
309
- }
310
- }), S(p, m);
311
- });
312
- }
313
- } catch (s) {
314
- console.error(s);
315
- }
316
- }, Jt = async (t, e, s = ct()) => {
317
- try {
318
- const c = r(t, "./saltygen");
319
- if (Z(e)) {
320
- const o = _(e, "utf8");
321
- o.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== o && await mt(e, o);
322
- const u = await G(t), i = await A(t, e, c);
323
- let n = o;
324
- if (Object.entries(i).forEach(([p, m]) => {
325
- var h;
326
- if (m.isKeyframes || !m.generator) return;
327
- const C = m.generator._withBuildContext({
328
- name: p,
329
- config: u,
330
- prod: s
331
- }), x = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
332
- if (!x) return console.error("Could not find the original declaration");
333
- const b = (h = x.at(1)) == null ? void 0 : h.trim(), M = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
334
- if (!M) return console.error("Could not find the original declaration");
335
- const { index: y } = M;
336
- let F = !1;
337
- const l = setTimeout(() => F = !0, 5e3);
338
- let j = 0, D = !1, k = 0;
339
- for (; !D && !F; ) {
340
- const d = n[y + j];
341
- d === "(" && k++, d === ")" && k--, k === 0 && d === ")" && (D = !0), j > n.length && (F = !0), j++;
342
- }
343
- if (!F) clearTimeout(l);
344
- else throw new Error("Failed to find the end of the styled call and timed out");
345
- const V = y + j, N = n.slice(y, V), f = n, g = ` ${p} = styled(${b}, "${C.classNames}", ${JSON.stringify(C.props)});`;
346
- n = n.replace(N, g), f === n && console.error("Minimize file failed to change content", { name: p, tagName: b });
347
- }), u.importStrategy === "component") {
348
- const p = J(e, 6), m = K(e);
349
- n = `import '../../saltygen/css/${`f_${W(m.name)}-${p}.css`}';
350
- ${n}`;
351
- }
352
- return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
353
- }
354
- } catch (c) {
355
- console.error("Error in minimizeFile:", c);
356
- }
357
- };
358
- export {
359
- Vt as a,
360
- Ft as b,
361
- kt as c,
362
- A as d,
363
- vt as e,
364
- Rt as g,
365
- Z as i,
366
- z as l,
367
- Jt as m,
368
- ot as s
369
- };