@salty-css/core 0.0.1-alpha.298 → 0.0.1-alpha.299

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"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-DojP6pQJ.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-B-ov9sPO.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,v)=>{se.exec(y,x=>{if(x)return v(x);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),v=oe(`Installing packages: ${C}`).start(),x=y.join(" ");await X(`npm install ${x}`),v.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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"))},v=async(i,a)=>{const{default:g}=await C[i],d=ne.render(g,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,g=process.cwd();return n.join(g,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:g=i,cssFile:d,skipInstall:p}=this.opts();if(!g)return e.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 c=process.cwd(),r=H(g),q=await Promise.all([v("salty.config.ts"),v("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),f=await s.readFile(h,"utf-8").catch(()=>{});if(f===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(f),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==f&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-ol1Q_xul.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-DAhvRrtu.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,v)=>{se.exec(y,x=>{if(x)return v(x);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),v=oe(`Installing packages: ${C}`).start(),x=y.join(" ");await X(`npm install ${x}`),v.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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"))},v=async(i,a)=>{const{default:g}=await C[i],d=ne.render(g,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,g=process.cwd();return n.join(g,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:g=i,cssFile:d,skipInstall:p}=this.opts();if(!g)return e.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 c=process.cwd(),r=H(g),q=await Promise.all([v("salty.config.ts"),v("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),f=await s.readFile(h,"utf-8").catch(()=>{});if(f===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(f),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==f&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
package/bin/main.js CHANGED
@@ -3,11 +3,11 @@ import { existsSync as Q, watch as rt } from "fs";
3
3
  import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
4
4
  import { join as a, relative as z, parse as ct, format as et } from "path";
5
5
  import { render as lt } from "ejs";
6
- import { l as e, a as h, g as K, i as dt, b as ft } from "../index-Bsj-9mQh.js";
6
+ import { l as e, a as h, g as K, i as dt, b as ft } from "../index-CituHO0U.js";
7
7
  import { p as pt } from "../pascal-case-BQpR5PdN.js";
8
8
  import { exec as gt } from "child_process";
9
9
  import ut from "ora";
10
- import { c as yt } from "../should-restart-Dvo5_WYL.js";
10
+ import { c as yt } from "../should-restart-C6VJ-qaY.js";
11
11
  const st = (u) => new Promise((v, k) => {
12
12
  gt(u, ($) => {
13
13
  if ($) return k($);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-B1E0JeC7.cjs");require("../parsers/index.cjs");const e=require("../index-DojP6pQJ.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");require("../helpers-CC5pFyba.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-B1E0JeC7.cjs");require("../parsers/index.cjs");const e=require("../index-ol1Q_xul.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");require("../helpers-CC5pFyba.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
@@ -6,7 +6,7 @@ import "fs";
6
6
  import "fs/promises";
7
7
  import "../parse-styles-y_-drahL.js";
8
8
  import "../parsers/index.js";
9
- import { e as y, d as x, g as S, b as c, i as f, m as C, s as E, c as b } from "../index-Bsj-9mQh.js";
9
+ import { e as y, d as x, g as S, b as c, i as f, m as C, s as E, c as b } from "../index-CituHO0U.js";
10
10
  import "../css/merge.js";
11
11
  import "../define-templates-4A2yHcMF.js";
12
12
  import "../helpers-nHqH4L9L.js";
@@ -197,7 +197,7 @@ const Lt = {
197
197
  o.templatePaths = Object.fromEntries(Object.entries(nt).map(([y, F]) => [y, F._path]));
198
198
  const L = i(s, "types/css-tokens.d.ts"), kt = `
199
199
  // Variable types
200
- type VariableTokens = ${[...S].join("|")};
200
+ type VariableTokens = ${[...S].join("|") || "''"};
201
201
  type PropertyValueToken = \`{\${VariableTokens}}\`;
202
202
 
203
203
  // Template types
@@ -1,6 +1,6 @@
1
- "use strict";const Oe=require("esbuild"),Ee=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),je=require("fs/promises"),ce=require("./parse-styles-B1E0JeC7.cjs"),we=require("./parsers/index.cjs"),B=require("winston"),q=require("./css/merge.cjs"),Ve=require("./define-templates-Cunsb_Tr.cjs"),re=require("typescript"),Z=require("./helpers-CC5pFyba.cjs");var le=typeof document<"u"?document.currentScript:null;function Re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const be=Re(Oe),Fe=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:Fe(i.join(e,".."))},Me=async e=>{const t=Fe(e);return await je.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Je=async e=>{const t=await Me(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await Je(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:le&&le.tagName.toUpperCase()==="SCRIPT"&&le.src||new URL("index-DojP6pQJ.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},U=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),qe=e=>{U.error(e)};function Ce(e){return e?typeof e!="string"?Ce(String(e)):e.replace(/[^\d\w]/g,"."):""}const ze={"*, *::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"}},He=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=re.createSourceFile("temp.ts",e,re.ScriptTarget.Latest,!0);function o(m){if(re.isVariableDeclaration(m)&&m.name.getText()===t){const w=m.getStart(),F=m.getEnd();clearTimeout(r),s([w,F])}m.forEachChild(o)}o(l)}),E={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(E.externalModules.length>0)return E.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return E.externalModules=n,n},z=async e=>{if(E.destDir)return E.destDir;const t=await ue(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},fe=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...fe,...e].join("|")})\\.`),ee=(e,t=[])=>Ne(t).test(e),xe=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await je.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):xe(i.join(e,".."))},ue=async e=>{var n,r;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(l=>e.endsWith(l.dir||""));return s||((r=t.projects)==null?void 0:r.find(l=>l.dir===t.defaultProject))},We=async e=>{const t=await ue(e),s=await z(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await $e(e),o=Pe(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const m=Date.now(),{config:w}=await import(`${r}?t=${m}`);return{config:w,path:r}},ke=async(e,t)=>{var ye,ge;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async h=>{const{contents:C,outputFilePath:L}=await A(e,h,s);Object.entries(C).forEach(([v,P])=>{P.isMedia?n.mediaQueries.push([v,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${v};;${L}`))})}));const{config:r,path:l}=await We(e),o={...r},{mediaQueries:m}=n;o.mediaQueries=Object.fromEntries(m.map(([h,C])=>[`@${h}`,C]));const w=m.map(([h])=>`'@${h}'`).join(" | "),F=new Set,a=async(h,C=[])=>{if(!h)return[];const L=Object.entries(h).map(async([P,J])=>{const Q=async D=>{if(!D)return;if(D instanceof Promise)return await Q(await D);if(typeof D=="function")return await Q(await D());if(typeof D=="object")return await a(D,[...C,P]);const oe=Ce(P),ie=_.dashCase(P),ae=[...C,oe].join(".");F.add(`"${ae}"`);const Y=[...C.map(_.dashCase),ie].join("-"),he=ce.parseVariableTokens(D);return he?`--${Y}: ${he.transformed};`:`--${Y}: ${D};`};return await Q(J)});return(await Promise.all(L)).flat()},p=async h=>{if(!h)return[];const C=Object.entries(h).map(async([v,P])=>{const J=await a(P);return v==="base"?J.join(""):o.mediaQueries[v]?`${o.mediaQueries[v]} { ${J.join("")} }`:`${v} { ${J.join("")} }`});return(await Promise.all(C)).flat()},d=async h=>{if(!h)return[];const C=Object.entries(h).map(async([v,P])=>{const J=Object.entries(P).map(async([D,oe])=>{const ie=await a(oe,[v]),ae=`.${v}-${D}, [data-${v}="${D}"]`,Y=ie.join("");return`${ae} { ${Y} }`});return(await Promise.all(J)).flat()});return(await Promise.all(C)).flat()},y=h=>({...h,responsive:void 0,conditional:void 0}),g=h=>n.variables.map(C=>h==="static"?y(C._current):C._current[h]),b=q.mergeObjects(y(r.variables),g("static")),k=await a(b),N=q.mergeObjects((ye=r.variables)==null?void 0:ye.responsive,g("responsive")),T=await p(N),V=q.mergeObjects((ge=r.variables)==null?void 0:ge.conditional,g("conditional")),H=await d(V),de=i.join(s,"css/_variables.css"),R=`:root { ${k.join("")} ${T.join("")} } ${H.join("")}`;c.writeFileSync(de,R),o.staticVariables=b;const te=i.join(s,"css/_global.css"),f=q.mergeObjects(r.global,n.globalStyles),S=await ce.parseAndJoinStyles(f,"");c.writeFileSync(te,`@layer global { ${S} }`);const $=i.join(s,"css/_reset.css"),j=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:ze,x=await ce.parseAndJoinStyles(j,"");c.writeFileSync($,`@layer reset { ${x} }`);const O=i.join(s,"css/_templates.css"),M=q.mergeObjects(r.templates,n.templates),I=await we.parseTemplates(M),G=we.getTemplateTypes(M);c.writeFileSync(O,`@layer templates { ${I} }`),o.templates=M;const X=r.templates?[Ve.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],se=q.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(se).map(([h,C])=>[h,C._path]));const K=i.join(s,"types/css-tokens.d.ts"),ve=`
1
+ "use strict";const Oe=require("esbuild"),Ee=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),je=require("fs/promises"),ce=require("./parse-styles-B1E0JeC7.cjs"),we=require("./parsers/index.cjs"),B=require("winston"),q=require("./css/merge.cjs"),Ve=require("./define-templates-Cunsb_Tr.cjs"),re=require("typescript"),Z=require("./helpers-CC5pFyba.cjs");var le=typeof document<"u"?document.currentScript:null;function Re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const be=Re(Oe),Fe=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:Fe(i.join(e,".."))},Me=async e=>{const t=Fe(e);return await je.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Je=async e=>{const t=await Me(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await Je(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:le&&le.tagName.toUpperCase()==="SCRIPT"&&le.src||new URL("index-ol1Q_xul.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},U=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),qe=e=>{U.error(e)};function Ce(e){return e?typeof e!="string"?Ce(String(e)):e.replace(/[^\d\w]/g,"."):""}const ze={"*, *::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"}},He=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=re.createSourceFile("temp.ts",e,re.ScriptTarget.Latest,!0);function o(m){if(re.isVariableDeclaration(m)&&m.name.getText()===t){const w=m.getStart(),F=m.getEnd();clearTimeout(r),s([w,F])}m.forEachChild(o)}o(l)}),E={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(E.externalModules.length>0)return E.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return E.externalModules=n,n},z=async e=>{if(E.destDir)return E.destDir;const t=await ue(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},fe=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...fe,...e].join("|")})\\.`),ee=(e,t=[])=>Ne(t).test(e),xe=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await je.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):xe(i.join(e,".."))},ue=async e=>{var n,r;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(l=>e.endsWith(l.dir||""));return s||((r=t.projects)==null?void 0:r.find(l=>l.dir===t.defaultProject))},We=async e=>{const t=await ue(e),s=await z(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await $e(e),o=Pe(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const m=Date.now(),{config:w}=await import(`${r}?t=${m}`);return{config:w,path:r}},ke=async(e,t)=>{var ye,ge;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async h=>{const{contents:C,outputFilePath:L}=await A(e,h,s);Object.entries(C).forEach(([v,P])=>{P.isMedia?n.mediaQueries.push([v,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${v};;${L}`))})}));const{config:r,path:l}=await We(e),o={...r},{mediaQueries:m}=n;o.mediaQueries=Object.fromEntries(m.map(([h,C])=>[`@${h}`,C]));const w=m.map(([h])=>`'@${h}'`).join(" | "),F=new Set,a=async(h,C=[])=>{if(!h)return[];const L=Object.entries(h).map(async([P,J])=>{const Q=async D=>{if(!D)return;if(D instanceof Promise)return await Q(await D);if(typeof D=="function")return await Q(await D());if(typeof D=="object")return await a(D,[...C,P]);const oe=Ce(P),ie=_.dashCase(P),ae=[...C,oe].join(".");F.add(`"${ae}"`);const Y=[...C.map(_.dashCase),ie].join("-"),he=ce.parseVariableTokens(D);return he?`--${Y}: ${he.transformed};`:`--${Y}: ${D};`};return await Q(J)});return(await Promise.all(L)).flat()},p=async h=>{if(!h)return[];const C=Object.entries(h).map(async([v,P])=>{const J=await a(P);return v==="base"?J.join(""):o.mediaQueries[v]?`${o.mediaQueries[v]} { ${J.join("")} }`:`${v} { ${J.join("")} }`});return(await Promise.all(C)).flat()},d=async h=>{if(!h)return[];const C=Object.entries(h).map(async([v,P])=>{const J=Object.entries(P).map(async([D,oe])=>{const ie=await a(oe,[v]),ae=`.${v}-${D}, [data-${v}="${D}"]`,Y=ie.join("");return`${ae} { ${Y} }`});return(await Promise.all(J)).flat()});return(await Promise.all(C)).flat()},y=h=>({...h,responsive:void 0,conditional:void 0}),g=h=>n.variables.map(C=>h==="static"?y(C._current):C._current[h]),b=q.mergeObjects(y(r.variables),g("static")),k=await a(b),N=q.mergeObjects((ye=r.variables)==null?void 0:ye.responsive,g("responsive")),T=await p(N),V=q.mergeObjects((ge=r.variables)==null?void 0:ge.conditional,g("conditional")),H=await d(V),de=i.join(s,"css/_variables.css"),R=`:root { ${k.join("")} ${T.join("")} } ${H.join("")}`;c.writeFileSync(de,R),o.staticVariables=b;const te=i.join(s,"css/_global.css"),f=q.mergeObjects(r.global,n.globalStyles),S=await ce.parseAndJoinStyles(f,"");c.writeFileSync(te,`@layer global { ${S} }`);const $=i.join(s,"css/_reset.css"),j=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:ze,x=await ce.parseAndJoinStyles(j,"");c.writeFileSync($,`@layer reset { ${x} }`);const O=i.join(s,"css/_templates.css"),M=q.mergeObjects(r.templates,n.templates),I=await we.parseTemplates(M),G=we.getTemplateTypes(M);c.writeFileSync(O,`@layer templates { ${I} }`),o.templates=M;const X=r.templates?[Ve.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],se=q.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(se).map(([h,C])=>[h,C._path]));const K=i.join(s,"types/css-tokens.d.ts"),ve=`
2
2
  // Variable types
3
- type VariableTokens = ${[...F].join("|")};
3
+ type VariableTokens = ${[...F].join("|")||"''"};
4
4
  type PropertyValueToken = \`{\${VariableTokens}}\`;
5
5
 
6
6
  // Template types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.298",
3
+ "version": "0.0.1-alpha.299",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/server/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-B-ov9sPO.cjs");exports.checkShouldRestart=e.checkShouldRestart;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-DAhvRrtu.cjs");exports.checkShouldRestart=e.checkShouldRestart;
package/server/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as o } from "../should-restart-Dvo5_WYL.js";
1
+ import { c as o } from "../should-restart-C6VJ-qaY.js";
2
2
  export {
3
3
  o as checkShouldRestart
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { readFile as r } from "fs/promises";
2
- import { i as e } from "./index-Bsj-9mQh.js";
2
+ import { i as e } from "./index-CituHO0U.js";
3
3
  const f = async (t) => {
4
4
  if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
5
5
  if (t.includes("salty.config")) return !0;
@@ -1 +1 @@
1
- "use strict";const s=require("fs/promises"),r=require("./index-DojP6pQJ.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;
1
+ "use strict";const s=require("fs/promises"),r=require("./index-ol1Q_xul.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;