@salty-css/core 0.0.1-alpha.136 → 0.0.1-alpha.138

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-BC_57RHS.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-DabuYZHM.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-CjY7a4U6.js";
6
+ import { l as t, a as h, g as te } from "../index-B2e2OpmJ.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-BC_57RHS.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-DabuYZHM.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-CjY7a4U6.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-B2e2OpmJ.js";
9
9
  export {
10
10
  p as compileSaltyFile,
11
11
  n as generateConfigStyles,
@@ -142,7 +142,7 @@ const St = {
142
142
  let m = v(e, "utf8");
143
143
  m = m.replace(/styled\(([^"'`{,]+),/g, (y, d) => {
144
144
  if (/^['"`]/.test(d)) return y;
145
- const D = new RegExp(`import\\s?\\{[^{}]*${d}[^{}]*\\}\\s?from\\s?([^{};]+);`);
145
+ const D = new RegExp(`import[^;]*${d}[,\\s{][^;]*from\\s?([^{};]+);`);
146
146
  if (!D.test(m)) return y;
147
147
  const x = D.exec(m);
148
148
  if (x) {
@@ -1,4 +1,4 @@
1
- "use strict";const ce=require("esbuild"),ae=require("child_process"),R=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const G=le(ce),U=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:U(s.join(e,".."))},ue=async e=>{const t=U(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},pe=async e=>{const t=await ue(e);if(t)return t.type};let O;const X=async e=>{if(O)return O;const t=await pe(e);return t==="module"?O="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:H&&H.tagName.toUpperCase()==="SCRIPT"&&H.src||new URL("index-BC_57RHS.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},I=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{I.error(e)};function Y(e){return e?typeof e!="string"?Y(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,o)=>(o>0?".":"")+t.toLowerCase()):""}const fe={"*, *::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"}},A={externalModules:[]},Q=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),r=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!r)return[];const u=r[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return A.externalModules=u,u},J=e=>s.join(e,"./saltygen"),B=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...B,...e].join("|")})\\.`),q=(e,t=[])=>ee(t).test(e),ye=async e=>{const t=J(e),o=s.join(e,"salty.config.ts"),r=s.join(t,"salty.config.js"),u=await X(e),n=Q(e);await G.build({entryPoints:[o],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:u,external:n});const m=Date.now(),{config:b}=await import(`${r}?t=${m}`);return b},te=async e=>{const t=await ye(e),o=new Set,r=(l,p=[])=>l?Object.entries(l).flatMap(([j,d])=>{if(!d)return;if(typeof d=="object")return r(d,[...p,j]);const E=Y(j),V=R.dashCase(j),M=[...p,E].join(".");o.add(`"${M}"`);const P=[...p.map(R.dashCase),V].join("-"),{result:N}=v.parseValueTokens(d);return`--${P}: ${N};`}):[],u=l=>l?Object.entries(l).flatMap(([p,j])=>{const d=r(j);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],n=l=>l?Object.entries(l).flatMap(([p,j])=>Object.entries(j).flatMap(([d,E])=>{const V=r(E,[p]),M=`.${p}-${d}, [data-${p}="${d}"]`,P=V.join("");return`${M} { ${P} }`})):[],m=r(t.variables),b=u(t.responsiveVariables),x=n(t.conditionalVariables),i=J(e),f=s.join(i,"css/_variables.css"),$=`:root { ${m.join("")} ${b.join("")} } ${x.join("")}`;c.writeFileSync(f,$);const h=s.join(i,"css/_global.css"),y=v.parseStyles(t.global,"");c.writeFileSync(h,`@layer global { ${y} }`);const F=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,w=v.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${w} }`);const a=s.join(i,"css/_templates.css"),S=v.parseTemplates(t.templates),k=v.getTemplateTypes(t.templates);c.writeFileSync(a,S);const C=s.join(i,"types/css-tokens.d.ts"),D=`
1
+ "use strict";const ce=require("esbuild"),ae=require("child_process"),R=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const G=le(ce),U=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:U(s.join(e,".."))},ue=async e=>{const t=U(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},pe=async e=>{const t=await ue(e);if(t)return t.type};let O;const X=async e=>{if(O)return O;const t=await pe(e);return t==="module"?O="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:H&&H.tagName.toUpperCase()==="SCRIPT"&&H.src||new URL("index-DabuYZHM.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},I=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{I.error(e)};function Y(e){return e?typeof e!="string"?Y(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,o)=>(o>0?".":"")+t.toLowerCase()):""}const fe={"*, *::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"}},A={externalModules:[]},Q=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),r=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!r)return[];const u=r[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return A.externalModules=u,u},J=e=>s.join(e,"./saltygen"),B=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...B,...e].join("|")})\\.`),q=(e,t=[])=>ee(t).test(e),ye=async e=>{const t=J(e),o=s.join(e,"salty.config.ts"),r=s.join(t,"salty.config.js"),u=await X(e),n=Q(e);await G.build({entryPoints:[o],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:u,external:n});const m=Date.now(),{config:b}=await import(`${r}?t=${m}`);return b},te=async e=>{const t=await ye(e),o=new Set,r=(l,p=[])=>l?Object.entries(l).flatMap(([j,d])=>{if(!d)return;if(typeof d=="object")return r(d,[...p,j]);const E=Y(j),V=R.dashCase(j),M=[...p,E].join(".");o.add(`"${M}"`);const P=[...p.map(R.dashCase),V].join("-"),{result:N}=v.parseValueTokens(d);return`--${P}: ${N};`}):[],u=l=>l?Object.entries(l).flatMap(([p,j])=>{const d=r(j);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],n=l=>l?Object.entries(l).flatMap(([p,j])=>Object.entries(j).flatMap(([d,E])=>{const V=r(E,[p]),M=`.${p}-${d}, [data-${p}="${d}"]`,P=V.join("");return`${M} { ${P} }`})):[],m=r(t.variables),b=u(t.responsiveVariables),x=n(t.conditionalVariables),i=J(e),f=s.join(i,"css/_variables.css"),$=`:root { ${m.join("")} ${b.join("")} } ${x.join("")}`;c.writeFileSync(f,$);const h=s.join(i,"css/_global.css"),y=v.parseStyles(t.global,"");c.writeFileSync(h,`@layer global { ${y} }`);const F=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,w=v.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${w} }`);const a=s.join(i,"css/_templates.css"),S=v.parseTemplates(t.templates),k=v.getTemplateTypes(t.templates);c.writeFileSync(a,S);const C=s.join(i,"types/css-tokens.d.ts"),D=`
2
2
  // Variable types
3
3
  type VariableTokens = ${[...o].join("|")};
4
4
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -8,7 +8,7 @@
8
8
  ${Object.entries(k).map(([l,p])=>`${l}?: ${p}`).join(`
9
9
  `)}
10
10
  }
11
- `;c.writeFileSync(C,D)},W=async(e,t,o)=>{const r=R.toHash(t),u=s.join(o,"./temp");c.existsSync(u)||c.mkdirSync(u);const n=s.parse(t);let m=c.readFileSync(t,"utf8");m=m.replace(/styled\(([^"'`{,]+),/g,(h,y)=>{if(/^['"`]/.test(y))return h;const T=new RegExp(`import\\s?\\{[^{}]*${y}[^{}]*\\}\\s?from\\s?([^{};]+);`);if(!T.test(m))return h;const w=T.exec(m);if(w){const a=w.at(1);if(B.some(k=>a==null?void 0:a.includes(k)))return h}return"styled('div',"});const b=s.join(o,"js",r+".js"),x=Q(e),i=await X(e);await G.build({stdin:{contents:m,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:b,format:i,target:["node20"],keepNames:!0,external:x,packages:"external"});const f=Date.now();return await import(`${b}?t=${f}`)},K=async e=>{const t=J(e),o=s.join(t,"salty.config.js"),r=Date.now(),{config:u}=await import(`${o}?t=${r}`);return u},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ge=async(e,t=se())=>{try{const o=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const r=[],u=[],n=J(e),m=s.join(n,"index.css");(()=>{c.existsSync(n)&&ae.execSync("rm -rf "+n),c.mkdirSync(n),c.mkdirSync(s.join(n,"css")),c.mkdirSync(s.join(n,"types"))})(),await te(e);const x=await K(e);async function i(a,S){const k=["node_modules","saltygen"],C=c.statSync(a);if(C.isDirectory()){const _=c.readdirSync(a);if(k.some(l=>a.includes(l)))return;await Promise.all(_.map(l=>i(s.join(a,l),s.join(S,l))))}else if(C.isFile()&&q(a)){const D=await W(e,a,n),l=[];Object.entries(D).forEach(([M,P])=>{if(P.isKeyframes&&P.css){const L=`a_${P.animationName}.css`,re=`css/${L}`,ie=s.join(n,re);r.push(L),c.writeFileSync(ie,P.css);return}if(!P.generator)return;const N=P.generator._withBuildContext({name:M,config:x,prod:t});u[N.priority]||(u[N.priority]=[]),u[N.priority].push(N.cssFileName),l.push(N.cssFileName);const ne=`css/${N.cssFileName}`,oe=s.join(n,ne);c.writeFileSync(oe,N.css)});const p=l.map(M=>`@import url('./${M}');`).join(`
11
+ `;c.writeFileSync(C,D)},W=async(e,t,o)=>{const r=R.toHash(t),u=s.join(o,"./temp");c.existsSync(u)||c.mkdirSync(u);const n=s.parse(t);let m=c.readFileSync(t,"utf8");m=m.replace(/styled\(([^"'`{,]+),/g,(h,y)=>{if(/^['"`]/.test(y))return h;const T=new RegExp(`import[^;]*${y}[,\\s{][^;]*from\\s?([^{};]+);`);if(!T.test(m))return h;const w=T.exec(m);if(w){const a=w.at(1);if(B.some(k=>a==null?void 0:a.includes(k)))return h}return"styled('div',"});const b=s.join(o,"js",r+".js"),x=Q(e),i=await X(e);await G.build({stdin:{contents:m,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:b,format:i,target:["node20"],keepNames:!0,external:x,packages:"external"});const f=Date.now();return await import(`${b}?t=${f}`)},K=async e=>{const t=J(e),o=s.join(t,"salty.config.js"),r=Date.now(),{config:u}=await import(`${o}?t=${r}`);return u},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ge=async(e,t=se())=>{try{const o=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const r=[],u=[],n=J(e),m=s.join(n,"index.css");(()=>{c.existsSync(n)&&ae.execSync("rm -rf "+n),c.mkdirSync(n),c.mkdirSync(s.join(n,"css")),c.mkdirSync(s.join(n,"types"))})(),await te(e);const x=await K(e);async function i(a,S){const k=["node_modules","saltygen"],C=c.statSync(a);if(C.isDirectory()){const _=c.readdirSync(a);if(k.some(l=>a.includes(l)))return;await Promise.all(_.map(l=>i(s.join(a,l),s.join(S,l))))}else if(C.isFile()&&q(a)){const D=await W(e,a,n),l=[];Object.entries(D).forEach(([M,P])=>{if(P.isKeyframes&&P.css){const L=`a_${P.animationName}.css`,re=`css/${L}`,ie=s.join(n,re);r.push(L),c.writeFileSync(ie,P.css);return}if(!P.generator)return;const N=P.generator._withBuildContext({name:M,config:x,prod:t});u[N.priority]||(u[N.priority]=[]),u[N.priority].push(N.cssFileName),l.push(N.cssFileName);const ne=`css/${N.cssFileName}`,oe=s.join(n,ne);c.writeFileSync(oe,N.css)});const p=l.map(M=>`@import url('./${M}');`).join(`
12
12
  `),j=R.toHash(a,6),d=s.parse(a),E=R.dashCase(d.name),V=s.join(n,`css/f_${E}-${j}.css`);c.writeFileSync(V,p)}}await i(e,n);const f=r.map(a=>`@import url('./css/${a}');`).join(`
13
13
  `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.136",
3
+ "version": "0.0.1-alpha.138",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/types/index.d.ts CHANGED
@@ -33,12 +33,12 @@ type VariantOptions = {
33
33
  export type CompoundVariant = {
34
34
  [key: PropertyKey]: string | boolean | undefined;
35
35
  } | {
36
- css: CssStyles;
36
+ css: CSSinJS;
37
37
  };
38
38
  type Variants = {
39
39
  variants?: VariantOptions & {
40
40
  [key: PropertyKey]: {
41
- [key: string]: Styles;
41
+ [key: PropertyKey]: CSSinJS;
42
42
  };
43
43
  };
44
44
  defaultVariants?: {
@@ -66,8 +66,9 @@ export type ValueProps = {
66
66
  };
67
67
  export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : object;
68
68
  type StylePropertyValue = Record<never, never> & unknown;
69
+ type CSSinJS = CssProperties | StylePropertyValue | PropertyValueToken | TemplateTokens | CssPseudos;
69
70
  export type CssStyles = {
70
- [key in OrString]?: CssProperties | StylePropertyValue | PropertyValueToken | TemplateTokens | CssStyles;
71
+ [key in OrString]?: CSSinJS;
71
72
  };
72
73
  export type Styles = CssStyles & Variants;
73
74
  export interface GeneratorOptions {
@@ -81,7 +82,7 @@ interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens {
81
82
  }
82
83
  type Pseudos = CSS.Pseudos | `&${CSS.Pseudos}`;
83
84
  type CssPseudos = {
84
- [P in Pseudos]?: Base;
85
+ [P in Pseudos]?: CssStyles;
85
86
  };
86
87
  export interface StyledParams extends GeneratorOptions, Variants {
87
88
  base?: Base;