@salty-css/core 0.0.1-alpha.140 → 0.0.1-alpha.141

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-Bywmnn_7.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-FtLw6IR2.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-ChAB4YZW.js";
6
+ import { l as t, a as h, g as te } from "../index-C6kc7u48.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-Bywmnn_7.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-FtLw6IR2.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-ChAB4YZW.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-C6kc7u48.js";
9
9
  export {
10
10
  p as compileSaltyFile,
11
11
  n as generateConfigStyles,
@@ -180,7 +180,7 @@ const wt = {
180
180
  args: m
181
181
  });
182
182
  const b = V(m.path, "utf8");
183
- return { contents: X(b) };
183
+ return { contents: X(b), loader: "ts" };
184
184
  });
185
185
  }
186
186
  }
@@ -1,4 +1,4 @@
1
- "use strict";const ae=require("esbuild"),le=require("child_process"),R=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),c=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function de(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const U=de(ae),X=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return c.existsSync(t)?t:X(o.join(e,".."))},pe=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let O;const Y=async e=>{if(O)return O;const t=await ue(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-Bywmnn_7.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),fe=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 ge={"*, *::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 t=o.join(e,"salty.config.ts"),r=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!r)return[];const a=r[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return L.externalModules=a,a},q=e=>o.join(e,"./saltygen"),A=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...A,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ye=async e=>{const t=q(e),s=o.join(e,"salty.config.ts"),r=o.join(t,"salty.config.js"),a=await Y(e),n=ee(e);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:a,external:n});const f=Date.now(),{config:g}=await import(`${r}?t=${f}`);return g},se=async e=>{const t=await ye(e),s=new Set,r=(d,p=[])=>d?Object.entries(d).flatMap(([S,u])=>{if(!u)return;if(typeof u=="object")return r(u,[...p,S]);const E=Q(S),V=R.dashCase(S),M=[...p,E].join(".");s.add(`"${M}"`);const x=[...p.map(R.dashCase),V].join("-"),{result:N}=v.parseValueTokens(u);return`--${x}: ${N};`}):[],a=d=>d?Object.entries(d).flatMap(([p,S])=>{const u=r(S);return p==="base"?u.join(""):`${p} { ${u.join("")} }`}):[],n=d=>d?Object.entries(d).flatMap(([p,S])=>Object.entries(S).flatMap(([u,E])=>{const V=r(E,[p]),M=`.${p}-${u}, [data-${p}="${u}"]`,x=V.join("");return`${M} { ${x} }`})):[],f=r(t.variables),g=a(t.responsiveVariables),j=n(t.conditionalVariables),i=q(e),y=o.join(i,"css/_variables.css"),F=`:root { ${f.join("")} ${g.join("")} } ${j.join("")}`;c.writeFileSync(y,F);const w=o.join(i,"css/_global.css"),m=v.parseStyles(t.global,"");c.writeFileSync(w,`@layer global { ${m} }`);const b=o.join(i,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ge,k=v.parseStyles(h,"");c.writeFileSync(b,`@layer reset { ${k} }`);const l=o.join(i,"css/_templates.css"),$=v.parseTemplates(t.templates),D=v.getTemplateTypes(t.templates);c.writeFileSync(l,$);const C=o.join(i,"types/css-tokens.d.ts"),T=`
1
+ "use strict";const ae=require("esbuild"),le=require("child_process"),R=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),c=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function de(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const U=de(ae),X=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return c.existsSync(t)?t:X(o.join(e,".."))},pe=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let O;const Y=async e=>{if(O)return O;const t=await ue(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-FtLw6IR2.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),fe=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 ge={"*, *::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 t=o.join(e,"salty.config.ts"),r=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!r)return[];const a=r[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return L.externalModules=a,a},q=e=>o.join(e,"./saltygen"),A=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...A,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ye=async e=>{const t=q(e),s=o.join(e,"salty.config.ts"),r=o.join(t,"salty.config.js"),a=await Y(e),n=ee(e);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:a,external:n});const f=Date.now(),{config:g}=await import(`${r}?t=${f}`);return g},se=async e=>{const t=await ye(e),s=new Set,r=(d,p=[])=>d?Object.entries(d).flatMap(([S,u])=>{if(!u)return;if(typeof u=="object")return r(u,[...p,S]);const E=Q(S),V=R.dashCase(S),M=[...p,E].join(".");s.add(`"${M}"`);const x=[...p.map(R.dashCase),V].join("-"),{result:N}=v.parseValueTokens(u);return`--${x}: ${N};`}):[],a=d=>d?Object.entries(d).flatMap(([p,S])=>{const u=r(S);return p==="base"?u.join(""):`${p} { ${u.join("")} }`}):[],n=d=>d?Object.entries(d).flatMap(([p,S])=>Object.entries(S).flatMap(([u,E])=>{const V=r(E,[p]),M=`.${p}-${u}, [data-${p}="${u}"]`,x=V.join("");return`${M} { ${x} }`})):[],f=r(t.variables),g=a(t.responsiveVariables),j=n(t.conditionalVariables),i=q(e),y=o.join(i,"css/_variables.css"),F=`:root { ${f.join("")} ${g.join("")} } ${j.join("")}`;c.writeFileSync(y,F);const w=o.join(i,"css/_global.css"),m=v.parseStyles(t.global,"");c.writeFileSync(w,`@layer global { ${m} }`);const b=o.join(i,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ge,k=v.parseStyles(h,"");c.writeFileSync(b,`@layer reset { ${k} }`);const l=o.join(i,"css/_templates.css"),$=v.parseTemplates(t.templates),D=v.getTemplateTypes(t.templates);c.writeFileSync(l,$);const C=o.join(i,"types/css-tokens.d.ts"),T=`
2
2
  // Variable types
3
3
  type VariableTokens = ${[...s].join("|")};
4
4
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -8,7 +8,7 @@
8
8
  ${Object.entries(D).map(([d,p])=>`${d}?: ${p}`).join(`
9
9
  `)}
10
10
  }
11
- `;c.writeFileSync(C,T)},Z=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{const r=/^['"`]/.test(s);if(r&&console.log("String tag",s),r)return t;const a=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`),n=a.test(e);if(n||console.log("Not imported",s),!n)return t;const f=a.exec(e);if(f){const g=f.at(1),j=A.some(i=>g==null?void 0:g.includes(i));if(j&&console.log("Salty import for",s,`"${f.at(0)}"`),j)return t}return console.log("Replacing",s),"styled('div',"}),W=async(e,t,s)=>{console.log({sourceFilePath:t});const r=R.toHash(t),a=o.join(s,"./temp");c.existsSync(a)||c.mkdirSync(a);const n=o.parse(t);let f=c.readFileSync(t,"utf8");f=Z(f);const g=o.join(s,"js",r+".js"),j=ee(e),i=await Y(e);await U.build({stdin:{contents:f,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:g,format:i,target:["node20"],keepNames:!0,external:j,packages:"external",plugins:[{name:"test",setup:w=>{w.onLoad({filter:/.*.css.ts/},m=>{console.log("Loading",{sourceFilePath:t,args:m});const b=c.readFileSync(m.path,"utf8");return{contents:Z(b)}})}}]});const y=Date.now();return await import(`${g}?t=${y}`)},B=async e=>{const t=q(e),s=o.join(t,"salty.config.js"),r=Date.now(),{config:a}=await import(`${s}?t=${r}`);return a},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const s=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const r=[],a=[],n=q(e),f=o.join(n,"index.css");(()=>{c.existsSync(n)&&le.execSync("rm -rf "+n),c.mkdirSync(n),c.mkdirSync(o.join(n,"css")),c.mkdirSync(o.join(n,"types"))})(),await se(e);const j=await B(e);async function i(l,$){const D=["node_modules","saltygen"],C=c.statSync(l);if(C.isDirectory()){const _=c.readdirSync(l);if(D.some(d=>l.includes(d)))return;await Promise.all(_.map(d=>i(o.join(l,d),o.join($,d))))}else if(C.isFile()&&I(l)){const T=await W(e,l,n),d=[];Object.entries(T).forEach(([M,x])=>{if(x.isKeyframes&&x.css){const K=`a_${x.animationName}.css`,ie=`css/${K}`,ce=o.join(n,ie);r.push(K),c.writeFileSync(ce,x.css);return}if(!x.generator)return;const N=x.generator._withBuildContext({name:M,config:j,prod:t});a[N.priority]||(a[N.priority]=[]),a[N.priority].push(N.cssFileName),d.push(N.cssFileName);const oe=`css/${N.cssFileName}`,re=o.join(n,oe);c.writeFileSync(re,N.css)});const p=d.map(M=>`@import url('./${M}');`).join(`
11
+ `;c.writeFileSync(C,T)},Z=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{const r=/^['"`]/.test(s);if(r&&console.log("String tag",s),r)return t;const a=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`),n=a.test(e);if(n||console.log("Not imported",s),!n)return t;const f=a.exec(e);if(f){const g=f.at(1),j=A.some(i=>g==null?void 0:g.includes(i));if(j&&console.log("Salty import for",s,`"${f.at(0)}"`),j)return t}return console.log("Replacing",s),"styled('div',"}),W=async(e,t,s)=>{console.log({sourceFilePath:t});const r=R.toHash(t),a=o.join(s,"./temp");c.existsSync(a)||c.mkdirSync(a);const n=o.parse(t);let f=c.readFileSync(t,"utf8");f=Z(f);const g=o.join(s,"js",r+".js"),j=ee(e),i=await Y(e);await U.build({stdin:{contents:f,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:g,format:i,target:["node20"],keepNames:!0,external:j,packages:"external",plugins:[{name:"test",setup:w=>{w.onLoad({filter:/.*.css.ts/},m=>{console.log("Loading",{sourceFilePath:t,args:m});const b=c.readFileSync(m.path,"utf8");return{contents:Z(b),loader:"ts"}})}}]});const y=Date.now();return await import(`${g}?t=${y}`)},B=async e=>{const t=q(e),s=o.join(t,"salty.config.js"),r=Date.now(),{config:a}=await import(`${s}?t=${r}`);return a},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const s=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const r=[],a=[],n=q(e),f=o.join(n,"index.css");(()=>{c.existsSync(n)&&le.execSync("rm -rf "+n),c.mkdirSync(n),c.mkdirSync(o.join(n,"css")),c.mkdirSync(o.join(n,"types"))})(),await se(e);const j=await B(e);async function i(l,$){const D=["node_modules","saltygen"],C=c.statSync(l);if(C.isDirectory()){const _=c.readdirSync(l);if(D.some(d=>l.includes(d)))return;await Promise.all(_.map(d=>i(o.join(l,d),o.join($,d))))}else if(C.isFile()&&I(l)){const T=await W(e,l,n),d=[];Object.entries(T).forEach(([M,x])=>{if(x.isKeyframes&&x.css){const K=`a_${x.animationName}.css`,ie=`css/${K}`,ce=o.join(n,ie);r.push(K),c.writeFileSync(ce,x.css);return}if(!x.generator)return;const N=x.generator._withBuildContext({name:M,config:j,prod:t});a[N.priority]||(a[N.priority]=[]),a[N.priority].push(N.cssFileName),d.push(N.cssFileName);const oe=`css/${N.cssFileName}`,re=o.join(n,oe);c.writeFileSync(re,N.css)});const p=d.map(M=>`@import url('./${M}');`).join(`
12
12
  `),S=R.toHash(l,6),u=o.parse(l),E=R.dashCase(u.name),V=o.join(n,`css/f_${E}-${S}.css`);c.writeFileSync(V,p)}}await i(e,n);const y=r.map(l=>`@import url('./css/${l}');`).join(`
13
13
  `);let b=`@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.140",
3
+ "version": "0.0.1-alpha.141",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",