@salty-css/core 0.0.1-alpha.264 → 0.0.1-alpha.265

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-CR38wcdG.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-Bc7HlBnq.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-DV-sarjD.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-B6uSbFR6.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-rfFRH3oi.js";
6
+ import { l as e, a as h, g as K, i as dt, b as ft } from "../index-CqTDidoK.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-ChzCgWxJ.js";
10
+ import { c as yt } from "../should-restart-BE-pvAhK.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-DzCW5jpn.cjs");require("../parsers/index.cjs");const e=require("../index-CR38wcdG.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
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-DZYIEhB4.cjs");require("../parsers/index.cjs");const e=require("../index-DV-sarjD.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
package/compiler/index.js CHANGED
@@ -4,9 +4,9 @@ import "../dash-case-DBThphLm.js";
4
4
  import "path";
5
5
  import "fs";
6
6
  import "fs/promises";
7
- import "../parse-styles-C9p1lg4R.js";
7
+ import "../parse-styles-Cq_H5JGg.js";
8
8
  import "../parsers/index.js";
9
- import { e as F, d as y, g as x, b as S, i as c, m as f, s as C, c as E } from "../index-rfFRH3oi.js";
9
+ import { e as F, d as y, g as x, b as S, i as c, m as f, s as C, c as E } from "../index-CqTDidoK.js";
10
10
  import "../css/merge.js";
11
11
  import "../define-templates-4A2yHcMF.js";
12
12
  export {
package/css/keyframes.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-DzCW5jpn.cjs"),w=require("../dash-case-BJEkFEGQ.cjs"),C=async({animationName:l,params:u,appendInitialStyles:y,...t})=>{const n=l||w.toHash(t),r=async(s={})=>{const{duration:e="500ms",easing:o="ease-in-out",delay:i="0s",iterationCount:S="1",direction:p="normal",fillMode:g="forwards",playState:b="running"}={...u,...s},a=`${n} ${e} ${o} ${i} ${S} ${p} ${g} ${b}`;if(!y)return a;const c=t.from||t["0%"];if(!c)return a;const j=await m.parseAndJoinStyles(c,"");return`${a};${j}`},$=Object.entries(t).map(async([s,e])=>{if(!e)return"";const o=await m.parseAndJoinStyles(e,"");return`${typeof s=="number"?`${s}%`:s}{${o}}`}),d=(await Promise.all($)).join(""),f=`@keyframes ${n} {${d}}`;return Object.assign(r,{toString:r,isKeyframes:!0,animationName:n,css:f,keyframes:t}),r};exports.keyframes=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-DZYIEhB4.cjs"),w=require("../dash-case-BJEkFEGQ.cjs"),C=async({animationName:l,params:u,appendInitialStyles:y,...t})=>{const n=l||w.toHash(t),r=async(s={})=>{const{duration:e="500ms",easing:o="ease-in-out",delay:i="0s",iterationCount:S="1",direction:p="normal",fillMode:g="forwards",playState:b="running"}={...u,...s},a=`${n} ${e} ${o} ${i} ${S} ${p} ${g} ${b}`;if(!y)return a;const c=t.from||t["0%"];if(!c)return a;const j=await m.parseAndJoinStyles(c,"");return`${a};${j}`},$=Object.entries(t).map(async([s,e])=>{if(!e)return"";const o=await m.parseAndJoinStyles(e,"");return`${typeof s=="number"?`${s}%`:s}{${o}}`}),d=(await Promise.all($)).join(""),f=`@keyframes ${n} {${d}}`;return Object.assign(r,{toString:r,isKeyframes:!0,animationName:n,css:f,keyframes:t}),r};exports.keyframes=C;
package/css/keyframes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as m } from "../parse-styles-C9p1lg4R.js";
1
+ import { p as m } from "../parse-styles-Cq_H5JGg.js";
2
2
  import { t as j } from "../dash-case-DBThphLm.js";
3
3
  const v = async ({ animationName: $, params: f, appendInitialStyles: l, ...t }) => {
4
4
  const r = $ || j(t), o = async (n = {}) => {
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var N=(a,s,t)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var m=(a,s,t)=>N(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../parse-styles-DzCW5jpn.cjs"),n=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(s){m(this,"buildContext",{});this.params=s}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){const{base:s,variants:t,compoundVariants:e}=this.params;return n.toHash({base:s,variants:t,compoundVariants:e})}get cssClassName(){return this.hash}get classNames(){const s=new Set([this.cssClassName]),{className:t}=this.params;return typeof t=="string"&&s.add(t),typeof t=="object"&&t.forEach(e=>s.add(e)),this.getTemplateClasses().forEach(e=>s.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>s.add(e)),[...s].join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${n.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,o={...s,variants:t,compoundVariants:e};return S.parseAndJoinStyles(o,`.${this.cssClassName}`,i,this.isRoot)}getTemplateClasses(s=this.buildContext.config){if(!(s!=null&&s.templates)||!this.params.base||this.priority>0)return[];const t=Object.keys(s.templates);return Object.entries(this.params.base).reduce((e,[i,o])=>(t.includes(i)&&e.push("t_"+n.toHash(n.dashCase(`${i}-${o}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}class v extends y{constructor(s){super(s),this._params=s}}class x extends y{constructor(s,t){super(t),this.tagName=s,this._params=t}get priority(){var s;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((s=this.tagName.generator)==null?void 0:s.priority)||0)+1:0}get clientProps(){const{element:s,variants:t={},compoundVariants:e=[],defaultVariants:i={},defaultProps:o={},passProps:d}=this.params,{callerName:f,isProduction:b}=this.buildContext,h=new Set([]),l=r=>{const c=i[r];c!==void 0?h.add(`${r}=${String(c)}`):h.add(r)};Object.keys(t).forEach(l),e.map(r=>Object.keys(r).forEach(l));const p=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);r&&r.forEach(c=>{const u=c.replace(/\{(?:-)?props\.([^}]+)\}/gi,"$1"),g=n.dashCase(u);u&&p.add(g)})}return{element:s,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:o,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=v;exports.StyledGenerator=x;
1
+ "use strict";var C=Object.defineProperty;var N=(a,s,t)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var m=(a,s,t)=>N(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../parse-styles-DZYIEhB4.cjs"),n=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(s){m(this,"buildContext",{});this.params=s}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){const{base:s,variants:t,compoundVariants:e}=this.params;return n.toHash({base:s,variants:t,compoundVariants:e})}get cssClassName(){return this.hash}get classNames(){const s=new Set([this.cssClassName]),{className:t}=this.params;return typeof t=="string"&&s.add(t),typeof t=="object"&&t.forEach(e=>s.add(e)),this.getTemplateClasses().forEach(e=>s.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>s.add(e)),[...s].join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${n.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,o={...s,variants:t,compoundVariants:e};return S.parseAndJoinStyles(o,`.${this.cssClassName}`,i,this.isRoot)}getTemplateClasses(s=this.buildContext.config){if(!(s!=null&&s.templates)||!this.params.base||this.priority>0)return[];const t=Object.keys(s.templates);return Object.entries(this.params.base).reduce((e,[i,o])=>(t.includes(i)&&e.push("t_"+n.toHash(n.dashCase(`${i}-${o}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}class v extends y{constructor(s){super(s),this._params=s}}class x extends y{constructor(s,t){super(t),this.tagName=s,this._params=t}get priority(){var s;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((s=this.tagName.generator)==null?void 0:s.priority)||0)+1:0}get clientProps(){const{element:s,variants:t={},compoundVariants:e=[],defaultVariants:i={},defaultProps:o={},passProps:d}=this.params,{callerName:f,isProduction:b}=this.buildContext,h=new Set([]),l=r=>{const c=i[r];c!==void 0?h.add(`${r}=${String(c)}`):h.add(r)};Object.keys(t).forEach(l),e.map(r=>Object.keys(r).forEach(l));const p=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);r&&r.forEach(c=>{const u=c.replace(/\{(?:-)?props\.([^}]+)\}/gi,"$1"),g=n.dashCase(u);u&&p.add(g)})}return{element:s,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:o,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=v;exports.StyledGenerator=x;
@@ -1,7 +1,7 @@
1
1
  var C = Object.defineProperty;
2
2
  var x = (a, t, s) => t in a ? C(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
3
3
  var u = (a, t, s) => x(a, typeof t != "symbol" ? t + "" : t, s);
4
- import { p as v } from "../parse-styles-C9p1lg4R.js";
4
+ import { p as v } from "../parse-styles-Cq_H5JGg.js";
5
5
  import { t as f, d as h } from "../dash-case-DBThphLm.js";
6
6
  class y {
7
7
  constructor(t) {
@@ -4,7 +4,7 @@ import { t as I, d as A } from "./dash-case-DBThphLm.js";
4
4
  import { join as i, parse as tt } from "path";
5
5
  import { existsSync as ft, mkdirSync as G, statSync as _t, readdirSync as Vt, readFileSync as T, writeFileSync as F } from "fs";
6
6
  import { readFile as Ct } from "fs/promises";
7
- import { p as $t, a as Et } from "./parse-styles-C9p1lg4R.js";
7
+ import { p as $t, a as Et } from "./parse-styles-Cq_H5JGg.js";
8
8
  import { parseTemplates as Ot, getTemplateTypes as Mt } from "./parsers/index.js";
9
9
  import { createLogger as Rt, transports as Jt, format as rt } from "winston";
10
10
  import { mergeObjects as H, mergeFactories as zt } from "./css/merge.js";
@@ -1,4 +1,4 @@
1
- "use strict";const Te=require("esbuild"),_e=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ae=require("./parse-styles-DzCW5jpn.cjs"),he=require("./parsers/index.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),ve=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Oe(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=Oe(Te),je=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:je(i.join(e,".."))},Ee=async e=>{const t=je(e);return await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ve=async e=>{const t=await Ee(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Ve(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-CR38wcdG.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Re=e=>{B.error(e)};function $e(e){return e?typeof e!="string"?$e(String(e)):e.replace(/[^\d\w]/g,"."):""}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"}},Je=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function o(y){if(ce.isVariableDeclaration(y)&&y.name.getText()===t){const S=y.getStart(),m=y.getEnd();clearTimeout(r),s([S,m])}y.forEachChild(o)}o(l)}),O={externalModules:[],rcFile:void 0,destDir:void 0},Ce=e=>{if(O.externalModules.length>0)return O.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 O.externalModules=n,n},q=async e=>{if(O.destDir)return O.destDir;const t=await fe(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},le=["salty","css","styles","styled"],Pe=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),Z=(e,t=[])=>Pe(t).test(e),Ne=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):Ne(i.join(e,".."))},fe=async e=>{var n,r;const t=await Ne(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))},qe=async e=>{const t=await fe(e),s=await q(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await Fe(e),o=Ce(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const y=Date.now(),{config:S}=await import(`${r}?t=${y}`);return{config:S,path:r}},xe=async(e,t)=>{var de,ye;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:F,outputFilePath:K}=await U(e,w,s);Object.entries(F).forEach(([D,P])=>{P.isMedia?n.mediaQueries.push([D,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${D};;${K}`))})}));const{config:r,path:l}=await qe(e),o={...r},{mediaQueries:y}=n;o.mediaQueries=Object.fromEntries(y.map(([w,F])=>[`@${w}`,F]));const S=y.map(([w])=>`'@${w}'`).join(" | "),m=new Set,a=async(w,F=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await a(T,[...F,P]);const ne=$e(P),oe=_.dashCase(P),ie=[...F,ne].join(".");m.add(`"${ie}"`);const Y=[...F.map(_.dashCase),oe].join("-"),ge=ae.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=await a(P);return D==="base"?M.join(""):o.mediaQueries[D]?`${o.mediaQueries[D]} { ${M.join("")} }`:`${D} { ${M.join("")} }`});return(await Promise.all(F)).flat()},d=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=Object.entries(P).map(async([T,ne])=>{const oe=await a(ne,[D]),ie=`.${D}-${T}, [data-${D}="${T}"]`,Y=oe.join("");return`${ie} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all(F)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map(F=>w==="static"?h(F._current):F._current[w]),$=J.mergeObjects(h(r.variables),p("static")),x=await a($),k=J.mergeObjects((de=r.variables)==null?void 0:de.responsive,p("responsive")),E=await g(k),z=J.mergeObjects((ye=r.variables)==null?void 0:ye.conditional,p("conditional")),A=await d(z),me=i.join(s,"css/_variables.css"),V=`:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;c.writeFileSync(me,V),o.staticVariables=$;const ee=i.join(s,"css/_global.css"),u=J.mergeObjects(r.global,n.globalStyles),b=await ae.parseAndJoinStyles(u,"");c.writeFileSync(ee,`@layer global { ${b} }`);const j=i.join(s,"css/_reset.css"),C=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Me,N=await ae.parseAndJoinStyles(C,"");c.writeFileSync(j,`@layer reset { ${N} }`);const v=i.join(s,"css/_templates.css"),R=J.mergeObjects(r.templates,n.templates),W=await he.parseTemplates(R),I=he.getTemplateTypes(R);c.writeFileSync(v,`@layer templates { ${W} }`),o.templates=R;const X=r.templates?[ve.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],te=J.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(te).map(([w,F])=>[w,F._path]));const G=i.join(s,"types/css-tokens.d.ts"),ke=`
1
+ "use strict";const Te=require("esbuild"),_e=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ae=require("./parse-styles-DZYIEhB4.cjs"),he=require("./parsers/index.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),ve=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Oe(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=Oe(Te),je=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:je(i.join(e,".."))},Ee=async e=>{const t=je(e);return await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ve=async e=>{const t=await Ee(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Ve(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-DV-sarjD.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Re=e=>{B.error(e)};function $e(e){return e?typeof e!="string"?$e(String(e)):e.replace(/[^\d\w]/g,"."):""}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"}},Je=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function o(y){if(ce.isVariableDeclaration(y)&&y.name.getText()===t){const S=y.getStart(),m=y.getEnd();clearTimeout(r),s([S,m])}y.forEachChild(o)}o(l)}),O={externalModules:[],rcFile:void 0,destDir:void 0},Ce=e=>{if(O.externalModules.length>0)return O.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 O.externalModules=n,n},q=async e=>{if(O.destDir)return O.destDir;const t=await fe(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},le=["salty","css","styles","styled"],Pe=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),Z=(e,t=[])=>Pe(t).test(e),Ne=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):Ne(i.join(e,".."))},fe=async e=>{var n,r;const t=await Ne(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))},qe=async e=>{const t=await fe(e),s=await q(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await Fe(e),o=Ce(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const y=Date.now(),{config:S}=await import(`${r}?t=${y}`);return{config:S,path:r}},xe=async(e,t)=>{var de,ye;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:F,outputFilePath:K}=await U(e,w,s);Object.entries(F).forEach(([D,P])=>{P.isMedia?n.mediaQueries.push([D,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${D};;${K}`))})}));const{config:r,path:l}=await qe(e),o={...r},{mediaQueries:y}=n;o.mediaQueries=Object.fromEntries(y.map(([w,F])=>[`@${w}`,F]));const S=y.map(([w])=>`'@${w}'`).join(" | "),m=new Set,a=async(w,F=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await a(T,[...F,P]);const ne=$e(P),oe=_.dashCase(P),ie=[...F,ne].join(".");m.add(`"${ie}"`);const Y=[...F.map(_.dashCase),oe].join("-"),ge=ae.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=await a(P);return D==="base"?M.join(""):o.mediaQueries[D]?`${o.mediaQueries[D]} { ${M.join("")} }`:`${D} { ${M.join("")} }`});return(await Promise.all(F)).flat()},d=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=Object.entries(P).map(async([T,ne])=>{const oe=await a(ne,[D]),ie=`.${D}-${T}, [data-${D}="${T}"]`,Y=oe.join("");return`${ie} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all(F)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map(F=>w==="static"?h(F._current):F._current[w]),$=J.mergeObjects(h(r.variables),p("static")),x=await a($),k=J.mergeObjects((de=r.variables)==null?void 0:de.responsive,p("responsive")),E=await g(k),z=J.mergeObjects((ye=r.variables)==null?void 0:ye.conditional,p("conditional")),A=await d(z),me=i.join(s,"css/_variables.css"),V=`:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;c.writeFileSync(me,V),o.staticVariables=$;const ee=i.join(s,"css/_global.css"),u=J.mergeObjects(r.global,n.globalStyles),b=await ae.parseAndJoinStyles(u,"");c.writeFileSync(ee,`@layer global { ${b} }`);const j=i.join(s,"css/_reset.css"),C=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Me,N=await ae.parseAndJoinStyles(C,"");c.writeFileSync(j,`@layer reset { ${N} }`);const v=i.join(s,"css/_templates.css"),R=J.mergeObjects(r.templates,n.templates),W=await he.parseTemplates(R),I=he.getTemplateTypes(R);c.writeFileSync(v,`@layer templates { ${W} }`),o.templates=R;const X=r.templates?[ve.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],te=J.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(te).map(([w,F])=>[w,F._path]));const G=i.join(s,"types/css-tokens.d.ts"),ke=`
2
2
  // Variable types
3
3
  type VariableTokens = ${[...m].join("|")};
4
4
  type PropertyValueToken = \`{\${VariableTokens}}\`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.264",
3
+ "version": "0.0.1-alpha.265",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -0,0 +1,153 @@
1
+ import { d as O } from "./dash-case-DBThphLm.js";
2
+ import { d as N } from "./viewport-clamp-BOc-8Oph.js";
3
+ const U = (o) => (s) => {
4
+ if (typeof s != "string" || !o) return;
5
+ let t = s;
6
+ const m = [];
7
+ return Object.values(o).forEach((e) => {
8
+ const { pattern: p, transform: f } = e;
9
+ t = t.replace(p, (E) => {
10
+ const { value: x, css: v } = f(E);
11
+ return v && m.push(v), x;
12
+ });
13
+ }), { transformed: t, additionalCss: m };
14
+ }, A = (o) => (s) => typeof s != "string" || !/\{[^{}]+\}/g.test(s) ? void 0 : { transformed: s.replace(/\{([^{}]+)\}/g, (...e) => {
15
+ const p = O(e[1].replaceAll(".", "-"));
16
+ return o && !o.includes(p) && console.warn(`Token ${p} might not exist`), p.startsWith("-") ? `-${p}` : `var(--${p})`;
17
+ }) }, D = A(), M = [
18
+ "top",
19
+ "right",
20
+ "bottom",
21
+ "left",
22
+ "min-width",
23
+ /.*width.*/,
24
+ /^[^line]*height.*/,
25
+ // Exclude line-height
26
+ /padding.*/,
27
+ /margin.*/,
28
+ /border.*/,
29
+ /inset.*/,
30
+ /.*radius.*/,
31
+ /.*spacing.*/,
32
+ /.*gap.*/,
33
+ /.*indent.*/,
34
+ /.*offset.*/,
35
+ /.*size.*/,
36
+ /.*thickness.*/,
37
+ /.*font-size.*/
38
+ ], Q = (o, s, t) => {
39
+ if (M.some((e) => typeof e == "string" ? e === o : e.test(o))) {
40
+ const e = (t == null ? void 0 : t.defaultUnit) || "px";
41
+ if (e.startsWith("viewport-clamp:"))
42
+ try {
43
+ const f = e.split(":")[1];
44
+ return N({
45
+ screenSize: parseInt(f)
46
+ })(Number(s));
47
+ } catch (f) {
48
+ throw console.error(f), new Error(`Invalid viewport-clamp value: ${e}`);
49
+ }
50
+ return `${s}${e}`;
51
+ }
52
+ return `${s}`;
53
+ }, _ = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : _.some((s) => o.startsWith(s)) ? `-${O(o)}` : O(o), y = async (o, s = "", t, m = !1) => {
54
+ if (!o) throw new Error("No styles provided to parseStyles function!");
55
+ const e = /* @__PURE__ */ new Set(), p = Object.entries(o), f = async ([u, r]) => {
56
+ var P;
57
+ const n = u.trim().replace(/^\?+/g, ""), b = q(n), h = (a, c = ";") => `${b}:${a}${c}`, C = { scope: s, config: t };
58
+ if (typeof r == "function") return f([u, r(C)]);
59
+ if (r instanceof Promise) return f([u, await r]);
60
+ if (t != null && t.templates && t.templatePaths[n])
61
+ try {
62
+ const [a, c] = t.templatePaths[n].split(";;"), i = await import(
63
+ /* webpackIgnore: true */
64
+ c
65
+ ), d = c.includes("salty.config"), l = d ? i[a].templates : i[a], $ = d ? l[n] : l.params[n];
66
+ if (l && typeof $ == "function") {
67
+ const j = await $(r), [w] = await y(j, "");
68
+ return w;
69
+ }
70
+ } catch (a) {
71
+ console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`, a);
72
+ return;
73
+ }
74
+ if (t != null && t.templates && t.templates[n]) {
75
+ if (m) return;
76
+ const c = r.split(".").reduce((i, d) => i[d], t.templates[n]);
77
+ if (c) {
78
+ const [i] = await y(c, "");
79
+ return i;
80
+ }
81
+ console.warn(`Template "${n}" with path of "${r}" was not found in config!`);
82
+ return;
83
+ }
84
+ if (typeof r == "object") {
85
+ if (!r) return;
86
+ if (r.isColor) return h(r.toString());
87
+ if (n === "defaultVariants") return;
88
+ if (n === "variants") {
89
+ const i = Object.entries(r);
90
+ for (const [d, l] of i) {
91
+ if (!l) continue;
92
+ const $ = Object.entries(l);
93
+ for (const [j, w] of $) {
94
+ if (!w) continue;
95
+ const W = `${s}.${d}-${j}`;
96
+ (await y(w, W, t)).forEach((I) => e.add(I));
97
+ }
98
+ }
99
+ return;
100
+ }
101
+ if (n === "compoundVariants") {
102
+ for (const i of r) {
103
+ const { css: d, ...l } = i, $ = Object.entries(l).reduce((w, [W, V]) => `${w}.${W}-${V}`, s);
104
+ (await y(d, $, t)).forEach((w) => e.add(w));
105
+ }
106
+ return;
107
+ }
108
+ if (n.startsWith("@")) {
109
+ const i = ((P = t == null ? void 0 : t.mediaQueries) == null ? void 0 : P[n]) || n, d = await z(r, s, t), l = `${i} { ${d} }`;
110
+ e.add(l);
111
+ return;
112
+ }
113
+ const a = u.includes("&") ? n.replaceAll("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
114
+ (await y(r, a, t)).forEach((i) => e.add(i));
115
+ return;
116
+ }
117
+ if (typeof r == "number") {
118
+ const a = Q(b, r, t);
119
+ return h(a);
120
+ }
121
+ if (typeof r != "string")
122
+ if ("toString" in r) r = r.toString();
123
+ else throw new Error(`Invalid value type for property ${b}`);
124
+ return h(r);
125
+ }, E = p.map(f), { modifiers: x } = t || {}, v = [A(), U(x)], S = (await Promise.all(E).then((u) => Promise.all(
126
+ u.map((r) => v.reduce(async (n, b) => {
127
+ const h = await n;
128
+ if (!h) return h;
129
+ const C = await b(h);
130
+ if (!C) return h;
131
+ const { transformed: P, additionalCss: a } = C;
132
+ let c = "";
133
+ if (a)
134
+ for (const i of a)
135
+ c += await z(i, "");
136
+ return `${c}${P}`;
137
+ }, Promise.resolve(r)))
138
+ ))).filter((u) => u !== void 0).join(`
139
+ `);
140
+ if (!S.trim()) return Array.from(e);
141
+ const T = s ? `${s} {
142
+ ${S}
143
+ }` : S;
144
+ return e.has(T) ? Array.from(e) : [T, ...e];
145
+ }, z = async (o, s, t, m = !1) => (await y(o, s, t, m)).join(`
146
+ `);
147
+ export {
148
+ D as a,
149
+ U as b,
150
+ y as c,
151
+ A as d,
152
+ z as p
153
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";const x=require("./dash-case-BJEkFEGQ.cjs"),M=require("./viewport-clamp-kY8JqYzm.cjs"),q=o=>s=>{if(typeof s!="string"||!o)return;let t=s;const u=[];return Object.values(o).forEach(e=>{const{pattern:p,transform:f}=e;t=t.replace(p,C=>{const{value:V,css:v}=f(C);return v&&u.push(v),V})}),{transformed:t,additionalCss:u}},A=o=>s=>typeof s!="string"||!/\{[^{}]+\}/g.test(s)?void 0:{transformed:s.replace(/\{([^{}]+)\}/g,(...e)=>{const p=x.dashCase(e[1].replaceAll(".","-"));return o&&!o.includes(p)&&console.warn(`Token ${p} might not exist`),p.startsWith("-")?`-${p}`:`var(--${p})`})},N=A(),U=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],k=(o,s,t)=>{if(U.some(e=>typeof e=="string"?e===o:e.test(o))){const e=(t==null?void 0:t.defaultUnit)||"px";if(e.startsWith("viewport-clamp:"))try{const f=e.split(":")[1];return M.defineViewportClamp({screenSize:parseInt(f)})(Number(s))}catch(f){throw console.error(f),new Error(`Invalid viewport-clamp value: ${e}`)}return`${s}${e}`}return`${s}`},J=["Webkit","Moz","ms","O"],Q=o=>o.startsWith("-")?o:J.some(s=>o.startsWith(s))?`-${x.dashCase(o)}`:x.dashCase(o),$=async(o,s="",t,u=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const e=new Set,p=Object.entries(o),f=async([m,r])=>{var P;const n=m.trim().replace(/^\?+/g,""),b=Q(n),h=(a,c=";")=>`${b}:${a}${c}`,E={scope:s,config:t};if(typeof r=="function")return f([m,r(E)]);if(r instanceof Promise)return f([m,await r]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[a,c]=t.templatePaths[n].split(";;"),i=await import(c),l=c.includes("salty.config"),d=l?i[a].templates:i[a],y=l?d[n]:d.params[n];if(d&&typeof y=="function"){const S=await y(r),[w]=await $(S,"");return w}}catch(a){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,a);return}if(t!=null&&t.templates&&t.templates[n]){if(u)return;const c=r.split(".").reduce((i,l)=>i[l],t.templates[n]);if(c){const[i]=await $(c,"");return i}console.warn(`Template "${n}" with path of "${r}" was not found in config!`);return}if(typeof r=="object"){if(!r)return;if(r.isColor)return h(r.toString());if(n==="defaultVariants")return;if(n==="variants"){const i=Object.entries(r);for(const[l,d]of i){if(!d)continue;const y=Object.entries(d);for(const[S,w]of y){if(!w)continue;const T=`${s}.${l}-${S}`;(await $(w,T,t)).forEach(I=>e.add(I))}}return}if(n==="compoundVariants"){for(const i of r){const{css:l,...d}=i,y=Object.entries(d).reduce((w,[T,z])=>`${w}.${T}-${z}`,s);(await $(l,y,t)).forEach(w=>e.add(w))}return}if(n.startsWith("@")){const i=((P=t==null?void 0:t.mediaQueries)==null?void 0:P[n])||n,l=await W(r,s,t),d=`${i} { ${l} }`;e.add(d);return}const a=m.includes("&")?n.replaceAll("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`;(await $(r,a,t)).forEach(i=>e.add(i));return}if(typeof r=="number"){const a=k(b,r,t);return h(a)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${b}`);return h(r)},C=p.map(f),{modifiers:V}=t||{},v=[A(),q(V)],j=(await Promise.all(C).then(m=>Promise.all(m.map(r=>v.reduce(async(n,b)=>{const h=await n;if(!h)return h;const E=await b(h);if(!E)return h;const{transformed:P,additionalCss:a}=E;let c="";if(a)for(const i of a)c+=await W(i,"");return`${c}${P}`},Promise.resolve(r)))))).filter(m=>m!==void 0).join(`
2
+ `);if(!j.trim())return Array.from(e);const O=s?`${s} {
3
+ ${j}
4
+ }`:j;return e.has(O)?Array.from(e):[O,...e]},W=async(o,s,t,u=!1)=>(await $(o,s,t,u)).join(`
5
+ `);exports.parseAndJoinStyles=W;exports.parseStyles=$;exports.parseValueModifiers=q;exports.parseValueTokens=A;exports.parseVariableTokens=N;
package/parsers/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-DzCW5jpn.cjs"),c=require("../dash-case-BJEkFEGQ.cjs"),p=async(e,s=[])=>{if(!e)return"";const t=[],r={};for(const[n,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const i=n.trim(),u=await p(o,[...s,i]);t.push(u)}else r[n]=o;if(Object.keys(r).length){const n=s.map(c.dashCase).join("-"),o="t_"+c.toHash(n,4),i=await a.parseAndJoinStyles(r,`.${n}, .${o}`);t.push(i)}return t.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-DZYIEhB4.cjs"),c=require("../dash-case-BJEkFEGQ.cjs"),p=async(e,s=[])=>{if(!e)return"";const t=[],r={};for(const[n,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const i=n.trim(),u=await p(o,[...s,i]);t.push(u)}else r[n]=o;if(Object.keys(r).length){const n=s.map(c.dashCase).join("-"),o="t_"+c.toHash(n,4),i=await a.parseAndJoinStyles(r,`.${n}, .${o}`);t.push(i)}return t.join(`
2
2
  `)},y=e=>Object.keys(e),f=e=>e?Object.entries(e).reduce((s,[t,r])=>(typeof r=="function"?s[t]="any":typeof r=="object"&&(s[t]=l(r).map(n=>`"${n}"`).join(" | ")),s),{}):{},l=(e,s="",t=new Set)=>e?(Object.entries(e).forEach(([r,n])=>{const o=s?`${s}.${r}`:r;return typeof n=="object"?l(n,o,t):t.add(s)}),[...t]):[];exports.parseAndJoinStyles=a.parseAndJoinStyles;exports.parseStyles=a.parseStyles;exports.parseValueModifiers=a.parseValueModifiers;exports.parseValueTokens=a.parseValueTokens;exports.parseVariableTokens=a.parseVariableTokens;exports.getTemplateKeys=y;exports.getTemplateTokens=l;exports.getTemplateTypes=f;exports.parseTemplates=p;
package/parsers/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { p as f } from "../parse-styles-C9p1lg4R.js";
2
- import { c as T, b as O, d as $, a as g } from "../parse-styles-C9p1lg4R.js";
1
+ import { p as f } from "../parse-styles-Cq_H5JGg.js";
2
+ import { c as T, b as O, d as $, a as g } from "../parse-styles-Cq_H5JGg.js";
3
3
  import { d as p, t as u } from "../dash-case-DBThphLm.js";
4
4
  const l = async (e, s = []) => {
5
5
  if (!e) return "";
package/server/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-Bc7HlBnq.cjs");exports.checkShouldRestart=e.checkShouldRestart;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-B6uSbFR6.cjs");exports.checkShouldRestart=e.checkShouldRestart;
package/server/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as o } from "../should-restart-ChzCgWxJ.js";
1
+ import { c as o } from "../should-restart-BE-pvAhK.js";
2
2
  export {
3
3
  o as checkShouldRestart
4
4
  };
@@ -1 +1 @@
1
- "use strict";const s=require("fs/promises"),r=require("./index-CR38wcdG.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-DV-sarjD.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,5 +1,5 @@
1
1
  import { readFile as r } from "fs/promises";
2
- import { i as e } from "./index-rfFRH3oi.js";
2
+ import { i as e } from "./index-CqTDidoK.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,146 +0,0 @@
1
- import { d as O } from "./dash-case-DBThphLm.js";
2
- import { d as N } from "./viewport-clamp-BOc-8Oph.js";
3
- const U = (n) => (r) => {
4
- if (typeof r != "string" || !n) return;
5
- let t = r;
6
- const p = [];
7
- return Object.values(n).forEach((e) => {
8
- const { pattern: c, transform: d } = e;
9
- t = t.replace(c, (b) => {
10
- const { value: P, css: v } = d(b);
11
- return v && p.push(v), P;
12
- });
13
- }), { transformed: t, additionalCss: p };
14
- }, S = (n) => (r) => typeof r != "string" || !/\{[^{}]+\}/g.test(r) ? void 0 : { transformed: r.replace(/\{([^{}]+)\}/g, (...e) => {
15
- const c = O(e[1].replaceAll(".", "-"));
16
- return n && !n.includes(c) && console.warn(`Token ${c} might not exist`), c.startsWith("-") ? `-${c}` : `var(--${c})`;
17
- }) }, D = S(), M = [
18
- "top",
19
- "right",
20
- "bottom",
21
- "left",
22
- "min-width",
23
- /.*width.*/,
24
- /^[^line]*height.*/,
25
- // Exclude line-height
26
- /padding.*/,
27
- /margin.*/,
28
- /border.*/,
29
- /inset.*/,
30
- /.*radius.*/,
31
- /.*spacing.*/,
32
- /.*gap.*/,
33
- /.*indent.*/,
34
- /.*offset.*/,
35
- /.*size.*/,
36
- /.*thickness.*/,
37
- /.*font-size.*/
38
- ], Q = (n, r, t) => {
39
- if (M.some((e) => typeof e == "string" ? e === n : e.test(n))) {
40
- const e = (t == null ? void 0 : t.defaultUnit) || "px";
41
- if (e.startsWith("viewport-clamp:"))
42
- try {
43
- const d = e.split(":")[1];
44
- return N({
45
- screenSize: parseInt(d)
46
- })(Number(r));
47
- } catch (d) {
48
- throw console.error(d), new Error(`Invalid viewport-clamp value: ${e}`);
49
- }
50
- return `${r}${e}`;
51
- }
52
- return `${r}`;
53
- }, _ = ["Webkit", "Moz", "ms", "O"], q = (n) => n.startsWith("-") ? n : _.some((r) => n.startsWith(r)) ? `-${O(n)}` : O(n), y = async (n, r = "", t, p = !1) => {
54
- if (!n) throw new Error("No styles provided to parseStyles function!");
55
- const e = /* @__PURE__ */ new Set(), c = Object.entries(n), d = async ([l, s]) => {
56
- var C;
57
- const o = l.trim().replace(/^\?+/g, ""), w = q(o), f = (a, m = ";") => `${w}:${a}${m}`, E = { scope: r, config: t };
58
- if (typeof s == "function") return d([l, s(E)]);
59
- if (s instanceof Promise) return d([l, await s]);
60
- if (t != null && t.templates && t.templatePaths[o])
61
- try {
62
- return;
63
- } catch (a) {
64
- console.error(`Error loading template "${o}" from path "${t.templatePaths[o]}"`, a);
65
- return;
66
- }
67
- if (t != null && t.templates && t.templates[o]) {
68
- if (p) return;
69
- const m = s.split(".").reduce((i, u) => i[u], t.templates[o]);
70
- if (m) {
71
- const [i] = await y(m, "");
72
- return i;
73
- }
74
- console.warn(`Template "${o}" with path of "${s}" was not found in config!`);
75
- return;
76
- }
77
- if (typeof s == "object") {
78
- if (!s) return;
79
- if (s.isColor) return f(s.toString());
80
- if (o === "defaultVariants") return;
81
- if (o === "variants") {
82
- const i = Object.entries(s);
83
- for (const [u, h] of i) {
84
- if (!h) continue;
85
- const x = Object.entries(h);
86
- for (const [V, $] of x) {
87
- if (!$) continue;
88
- const W = `${r}.${u}-${V}`;
89
- (await y($, W, t)).forEach((I) => e.add(I));
90
- }
91
- }
92
- return;
93
- }
94
- if (o === "compoundVariants") {
95
- for (const i of s) {
96
- const { css: u, ...h } = i, x = Object.entries(h).reduce(($, [W, z]) => `${$}.${W}-${z}`, r);
97
- (await y(u, x, t)).forEach(($) => e.add($));
98
- }
99
- return;
100
- }
101
- if (o.startsWith("@")) {
102
- const i = ((C = t == null ? void 0 : t.mediaQueries) == null ? void 0 : C[o]) || o, u = await A(s, r, t), h = `${i} { ${u} }`;
103
- e.add(h);
104
- return;
105
- }
106
- const a = l.includes("&") ? o.replaceAll("&", r) : o.startsWith(":") ? `${r}${o}` : `${r} ${o}`;
107
- (await y(s, a, t)).forEach((i) => e.add(i));
108
- return;
109
- }
110
- if (typeof s == "number") {
111
- const a = Q(w, s, t);
112
- return f(a);
113
- }
114
- if (typeof s != "string")
115
- if ("toString" in s) s = s.toString();
116
- else throw new Error(`Invalid value type for property ${w}`);
117
- return f(s);
118
- }, b = c.map(d), { modifiers: P } = t || {}, v = [S(), U(P)], j = (await Promise.all(b).then((l) => Promise.all(
119
- l.map((s) => v.reduce(async (o, w) => {
120
- const f = await o;
121
- if (!f) return f;
122
- const E = await w(f);
123
- if (!E) return f;
124
- const { transformed: C, additionalCss: a } = E;
125
- let m = "";
126
- if (a)
127
- for (const i of a)
128
- m += await A(i, "");
129
- return `${m}${C}`;
130
- }, Promise.resolve(s)))
131
- ))).filter((l) => l !== void 0).join(`
132
- `);
133
- if (!j.trim()) return Array.from(e);
134
- const T = r ? `${r} {
135
- ${j}
136
- }` : j;
137
- return e.has(T) ? Array.from(e) : [T, ...e];
138
- }, A = async (n, r, t, p = !1) => (await y(n, r, t, p)).join(`
139
- `);
140
- export {
141
- D as a,
142
- U as b,
143
- y as c,
144
- S as d,
145
- A as p
146
- };
@@ -1,5 +0,0 @@
1
- "use strict";const x=require("./dash-case-BJEkFEGQ.cjs"),M=require("./viewport-clamp-kY8JqYzm.cjs"),q=n=>r=>{if(typeof r!="string"||!n)return;let t=r;const d=[];return Object.values(n).forEach(e=>{const{pattern:c,transform:p}=e;t=t.replace(c,b=>{const{value:P,css:C}=p(b);return C&&d.push(C),P})}),{transformed:t,additionalCss:d}},W=n=>r=>typeof r!="string"||!/\{[^{}]+\}/g.test(r)?void 0:{transformed:r.replace(/\{([^{}]+)\}/g,(...e)=>{const c=x.dashCase(e[1].replaceAll(".","-"));return n&&!n.includes(c)&&console.warn(`Token ${c} might not exist`),c.startsWith("-")?`-${c}`:`var(--${c})`})},N=W(),U=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],k=(n,r,t)=>{if(U.some(e=>typeof e=="string"?e===n:e.test(n))){const e=(t==null?void 0:t.defaultUnit)||"px";if(e.startsWith("viewport-clamp:"))try{const p=e.split(":")[1];return M.defineViewportClamp({screenSize:parseInt(p)})(Number(r))}catch(p){throw console.error(p),new Error(`Invalid viewport-clamp value: ${e}`)}return`${r}${e}`}return`${r}`},J=["Webkit","Moz","ms","O"],Q=n=>n.startsWith("-")?n:J.some(r=>n.startsWith(r))?`-${x.dashCase(n)}`:x.dashCase(n),w=async(n,r="",t,d=!1)=>{if(!n)throw new Error("No styles provided to parseStyles function!");const e=new Set,c=Object.entries(n),p=async([l,s])=>{var E;const o=l.trim().replace(/^\?+/g,""),y=Q(o),f=(a,u=";")=>`${y}:${a}${u}`,v={scope:r,config:t};if(typeof s=="function")return p([l,s(v)]);if(s instanceof Promise)return p([l,await s]);if(t!=null&&t.templates&&t.templatePaths[o])try{return}catch(a){console.error(`Error loading template "${o}" from path "${t.templatePaths[o]}"`,a);return}if(t!=null&&t.templates&&t.templates[o]){if(d)return;const u=s.split(".").reduce((i,m)=>i[m],t.templates[o]);if(u){const[i]=await w(u,"");return i}console.warn(`Template "${o}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return f(s.toString());if(o==="defaultVariants")return;if(o==="variants"){const i=Object.entries(s);for(const[m,h]of i){if(!h)continue;const j=Object.entries(h);for(const[O,$]of j){if(!$)continue;const T=`${r}.${m}-${O}`;(await w($,T,t)).forEach(I=>e.add(I))}}return}if(o==="compoundVariants"){for(const i of s){const{css:m,...h}=i,j=Object.entries(h).reduce(($,[T,z])=>`${$}.${T}-${z}`,r);(await w(m,j,t)).forEach($=>e.add($))}return}if(o.startsWith("@")){const i=((E=t==null?void 0:t.mediaQueries)==null?void 0:E[o])||o,m=await S(s,r,t),h=`${i} { ${m} }`;e.add(h);return}const a=l.includes("&")?o.replaceAll("&",r):o.startsWith(":")?`${r}${o}`:`${r} ${o}`;(await w(s,a,t)).forEach(i=>e.add(i));return}if(typeof s=="number"){const a=k(y,s,t);return f(a)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${y}`);return f(s)},b=c.map(p),{modifiers:P}=t||{},C=[W(),q(P)],V=(await Promise.all(b).then(l=>Promise.all(l.map(s=>C.reduce(async(o,y)=>{const f=await o;if(!f)return f;const v=await y(f);if(!v)return f;const{transformed:E,additionalCss:a}=v;let u="";if(a)for(const i of a)u+=await S(i,"");return`${u}${E}`},Promise.resolve(s)))))).filter(l=>l!==void 0).join(`
2
- `);if(!V.trim())return Array.from(e);const A=r?`${r} {
3
- ${V}
4
- }`:V;return e.has(A)?Array.from(e):[A,...e]},S=async(n,r,t,d=!1)=>(await w(n,r,t,d)).join(`
5
- `);exports.parseAndJoinStyles=S;exports.parseStyles=w;exports.parseValueModifiers=q;exports.parseValueTokens=W;exports.parseVariableTokens=N;