@salty-css/core 0.0.1-alpha.197 → 0.0.1-alpha.198
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 +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +1 -1
- package/{index-DZmq1drj.js → index-DuY0wgQt.js} +1 -1
- package/{index-UDCa37Mh.cjs → index-DyTXfJI6.cjs} +2 -2
- package/package.json +1 -1
- package/parse-styles-Blfh9nVa.js +106 -0
- package/parse-styles-Dhe9azay.cjs +7 -0
- package/parsers/unit-check.d.ts +7 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/types/config-types.d.ts +4 -0
- package/parse-styles-DMutm9wZ.cjs +0 -7
- package/parse-styles-DsUKNoSv.js +0 -76
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-
|
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-DyTXfJI6.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-
|
6
|
+
import { l as t, a as h, g as te } from "../index-DuY0wgQt.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";
|
package/compiler/index.cjs
CHANGED
@@ -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-
|
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-Dhe9azay.cjs");const e=require("../index-DyTXfJI6.cjs");require("../css/merge.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,8 +4,8 @@ import "../dash-case-DBThphLm.js";
|
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-styles-
|
8
|
-
import { d as n, c as g, g as F, e as y, i as x, m as S, s as c, b as f } from "../index-
|
7
|
+
import "../parse-styles-Blfh9nVa.js";
|
8
|
+
import { d as n, c as g, g as F, e as y, i as x, m as S, s as c, b as f } from "../index-DuY0wgQt.js";
|
9
9
|
import "../css/merge.js";
|
10
10
|
export {
|
11
11
|
n as compileSaltyFile,
|
package/css/keyframes.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../parse-styles-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../parse-styles-Dhe9azay.cjs"),j=require("../dash-case-BJEkFEGQ.cjs"),C=({animationName:m,params:l,appendInitialStyles:f,...t})=>{const r=m||j.toHash(t),o=(s={})=>{const{duration:e="500ms",easing:n="ease-in-out",delay:a="0s",iterationCount:i="1",direction:S="normal",fillMode:g="forwards",playState:p="running"}={...l,...s},c=`${r} ${e} ${n} ${a} ${i} ${S} ${g} ${p}`;if(!f)return c;const u=t.from||t["0%"];if(!u)return c;const b=$.parseStyles(u,"");return`${c};${b}`},y=Object.entries(t).reduce((s,[e,n])=>{if(!n)return s;const a=$.parseStyles(n,""),i=typeof e=="number"?`${e}%`:e;return`${s}${i}{${a}}`},""),d=`@keyframes ${r} {${y}}`;return Object.assign(o,{toString:o,isKeyframes:!0,animationName:r,css:d,keyframes:t}),o};exports.keyframes=C;
|
package/css/keyframes.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { p as c } from "../parse-styles-
|
1
|
+
import { p as c } from "../parse-styles-Blfh9nVa.js";
|
2
2
|
import { t as j } from "../dash-case-DBThphLm.js";
|
3
3
|
const O = ({ animationName: u, params: f, appendInitialStyles: p, ...t }) => {
|
4
4
|
const o = u || j(t), e = (r = {}) => {
|
package/generators/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var b=Object.defineProperty;var N=(e,s,t)=>s in e?b(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t;var u=(e,s,t)=>N(e,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../parse-styles-
|
1
|
+
"use strict";var b=Object.defineProperty;var N=(e,s,t)=>s in e?b(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t;var u=(e,s,t)=>N(e,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../parse-styles-Dhe9azay.cjs"),m=require("../dash-case-BJEkFEGQ.cjs");class f{constructor(s){u(this,"buildContext",{});this.params=s}get hash(){return m.toHash(this.params.base||this.params)}get cssClassName(){return this.hash}get classNames(){const s=[this.hash],{className:t}=this.params;return typeof t=="string"&&s.push(t),typeof t=="object"&&s.push(...t),s.join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${m.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:n=[]}=this.params,{config:i}=this.buildContext,o={...s,variants:t,compoundVariants:n};return C.parseStyles(o,`.${this.cssClassName}`,i)}_withBuildContext(s){return this.buildContext=s,this}}class S extends f{constructor(s){super(s),this._params=s}}class v extends f{constructor(s,t){super(t),this.tagName=s,this._params=t}get priority(){var s;return 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:n=[],defaultVariants:i={},defaultProps:o={},passProps:h}=this.params,{callerName:y,isProduction:g}=this.buildContext,c=new Set([]),l=a=>{const r=i[a];r!==void 0?c.add(`${a}=${String(r)}`):c.add(a)};Object.keys(t).forEach(l),n.map(a=>Object.keys(a).forEach(l));const d=new Set([]);if(this.params.base){const a=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);a&&a.forEach(r=>{const p=r.replace(/\{props\.([\w\d]+)\}/gi,"$1");p&&d.add(p)})}return{element:s,variantKeys:[...c],propValueKeys:[...d],passProps:h,defaultProps:o,attr:{"data-component-name":g?void 0:y}}}}exports.ClassNameGenerator=S;exports.StyledGenerator=v;
|
package/generators/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
var y = Object.defineProperty;
|
2
2
|
var b = (e, s, t) => s in e ? y(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
|
3
3
|
var u = (e, s, t) => b(e, typeof s != "symbol" ? s + "" : s, t);
|
4
|
-
import { p as N } from "../parse-styles-
|
4
|
+
import { p as N } from "../parse-styles-Blfh9nVa.js";
|
5
5
|
import { t as C, d as x } from "../dash-case-DBThphLm.js";
|
6
6
|
class m {
|
7
7
|
constructor(s) {
|
@@ -4,7 +4,7 @@ import { d as v, t as I } from "./dash-case-DBThphLm.js";
|
|
4
4
|
import { join as a, parse as q } from "path";
|
5
5
|
import { existsSync as at, writeFileSync as j, mkdirSync as z, readFileSync as P, statSync as jt, readdirSync as xt } from "fs";
|
6
6
|
import { readFile as dt, writeFile as Nt } from "fs/promises";
|
7
|
-
import { p as rt, a as kt } from "./parse-styles-
|
7
|
+
import { p as rt, a as kt } from "./parse-styles-Blfh9nVa.js";
|
8
8
|
import { createLogger as Pt, format as ot, transports as Dt } from "winston";
|
9
9
|
import { mergeStyles as W } from "./css/merge.js";
|
10
10
|
const ut = (t, e = []) => {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";const be=require("esbuild"),Fe=require("child_process"),k=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),A=require("./parse-styles-
|
2
|
-
`)},Ce=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=de(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},de=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?de(o,r,s):s.add(t)}),[...s]):[],ue=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:ue(i.join(e,".."))},xe=async e=>{const t=ue(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ne=async e=>{const t=await xe(e);if(t)return t.type};let J;const pe=async e=>{if(J)return J;const t=await Ne(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-
|
1
|
+
"use strict";const be=require("esbuild"),Fe=require("child_process"),k=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),A=require("./parse-styles-Dhe9azay.cjs"),G=require("winston"),z=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function $e(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 le=$e(be),fe=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,r])=>{if(typeof r=="object"){if(!r)return;const f=o.trim(),u=fe(r,[...t,f]);s.push(u)}else n[o]=r}),Object.keys(n).length){const o=t.map(k.dashCase).join("-"),r=A.parseStyles(n,`.${o}`);s.push(r)}return s.join(`
|
2
|
+
`)},Ce=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=de(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},de=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?de(o,r,s):s.add(t)}),[...s]):[],ue=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:ue(i.join(e,".."))},xe=async e=>{const t=ue(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ne=async e=>{const t=await xe(e);if(t)return t.type};let J;const pe=async e=>{if(J)return J;const t=await Ne(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-DyTXfJI6.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},L=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]}),ke=e=>{L.error(e)};function ye(e){return e?typeof e!="string"?ye(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 Pe={"*, *::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"}},O={externalModules:[],rcFile:void 0,destDir:void 0},ge=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(o=>o.replace(/['"`]/g,"").trim());return O.externalModules=n,n},R=async e=>{if(O.destDir)return O.destDir;const t=await re(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},ie=["salty","css","styles","styled"],me=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),U=(e,t=[])=>me(t).test(e),he=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 oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):he(i.join(e,".."))},re=async e=>{var n,o;const t=await he(e),s=(n=t.projects)==null?void 0:n.find(r=>e.endsWith(r.dir||""));return s||((o=t.projects)==null?void 0:o.find(r=>r.dir===t.defaultProject))},De=async e=>{const t=await re(e),s=await R(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=i.join(s,"salty.config.js"),r=await pe(e),f=ge(n);await le.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:f});const u=Date.now(),{config:y}=await import(`${o}?t=${u}`);return y},Se=async(e,t)=>{var M,B;const s=await R(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async $=>{const C=await K(e,$,s);Object.values(C).forEach(x=>{x.isMedia?n.mediaQueries.push(x):x.isGlobalDefine?n.globalStyles.push(x):x.isDefineVariables?n.variables.push(x):x.isDefineTemplates&&n.templates.push(x)})}));const o=await De(e),r={...o},f=new Set,u=($,C=[])=>$?Object.entries($).flatMap(([x,_])=>{if(!_)return;if(typeof _=="object")return u(_,[...C,x]);const Y=ye(x),ee=k.dashCase(x),te=[...C,Y].join(".");f.add(`"${te}"`);const se=[...C.map(k.dashCase),ee].join("-"),{result:we}=A.parseValueTokens(_);return`--${se}: ${we};`}):[],y=$=>$?Object.entries($).flatMap(([C,x])=>{const _=u(x);return C==="base"?_.join(""):`${C} { ${_.join("")} }`}):[],d=$=>$?Object.entries($).flatMap(([C,x])=>Object.entries(x).flatMap(([_,Y])=>{const ee=u(Y,[C]),te=`.${C}-${_}, [data-${C}="${_}"]`,se=ee.join("");return`${te} { ${se} }`})):[],g=$=>({...$,responsive:void 0,conditional:void 0}),m=$=>n.variables.map(C=>$==="static"?g(C._current):C._current[$]),p=z.mergeStyles(g(o.variables),m("static")),w=u(p),h=z.mergeStyles((M=o.variables)==null?void 0:M.responsive,m("responsive")),T=y(h),P=z.mergeStyles((B=o.variables)==null?void 0:B.conditional,m("conditional")),D=d(P),V=i.join(s,"css/_variables.css"),E=`:root { ${w.join("")} ${T.join("")} } ${D.join("")}`;c.writeFileSync(V,E),r.staticVariables=p;const H=i.join(s,"css/_global.css"),N=z.mergeStyles(o.global,n.globalStyles),v=A.parseStyles(N,"");c.writeFileSync(H,`@layer global { ${v} }`);const a=i.join(s,"css/_reset.css"),j=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Pe,l=A.parseStyles(j,"");c.writeFileSync(a,`@layer reset { ${l} }`);const b=i.join(s,"css/_templates.css"),F=z.mergeStyles(o.templates,n.templates),q=fe(F),I=Ce(F);c.writeFileSync(b,q),r.templates=F;const W=i.join(s,"types/css-tokens.d.ts"),Z=`
|
3
3
|
// Variable types
|
4
4
|
type VariableTokens = ${[...f].join("|")};
|
5
5
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
package/package.json
CHANGED
@@ -0,0 +1,106 @@
|
|
1
|
+
import { d as E } from "./dash-case-DBThphLm.js";
|
2
|
+
const k = (s, e) => {
|
3
|
+
if (typeof s != "string") return { result: s };
|
4
|
+
if (!e) return { result: s };
|
5
|
+
const r = [];
|
6
|
+
return Object.values(e).forEach((p) => {
|
7
|
+
const { pattern: i, transform: j } = p;
|
8
|
+
s = s.replace(i, (o) => {
|
9
|
+
const { value: $, css: t } = j(o);
|
10
|
+
return t && r.push(t), $;
|
11
|
+
});
|
12
|
+
}), { result: s, additionalCss: r };
|
13
|
+
}, x = (s) => typeof s != "string" ? { result: s } : /\{[^{}]+\}/g.test(s) ? { result: s.replace(/\{([^{}]+)\}/g, (...p) => `var(--${E(p[1].replaceAll(".", "-"))})`) } : { result: s }, U = [
|
14
|
+
"top",
|
15
|
+
"right",
|
16
|
+
"bottom",
|
17
|
+
"left",
|
18
|
+
"min-width",
|
19
|
+
/.*width.*/,
|
20
|
+
/^[^line]*height.*/,
|
21
|
+
// Exclude line-height
|
22
|
+
/padding.*/,
|
23
|
+
/margin.*/,
|
24
|
+
/border.*/,
|
25
|
+
/inset.*/,
|
26
|
+
/.*radius.*/,
|
27
|
+
/.*spacing.*/,
|
28
|
+
/.*gap.*/,
|
29
|
+
/.*indent.*/,
|
30
|
+
/.*offset.*/,
|
31
|
+
/.*size.*/,
|
32
|
+
/.*thickness.*/,
|
33
|
+
/.*font-size.*/
|
34
|
+
], W = (s, e, r) => {
|
35
|
+
if (U.some((i) => typeof i == "string" ? i === s : i.test(s))) {
|
36
|
+
const i = (r == null ? void 0 : r.defaultUnit) || "px";
|
37
|
+
return `${e}${i}`;
|
38
|
+
}
|
39
|
+
return `${e}`;
|
40
|
+
}, h = (s, e, r) => {
|
41
|
+
if (!s) return "";
|
42
|
+
const p = [], i = Object.entries(s).reduce((o, [$, t]) => {
|
43
|
+
const n = $.trim(), w = n.startsWith("-") ? n : E(n), S = (u, d = ";") => o = `${o}${u}${d}`, m = (u) => S(`${w}:${u}`);
|
44
|
+
if (typeof t == "function" && (t = t()), typeof t == "object") {
|
45
|
+
if (!t) return o;
|
46
|
+
if (t.isColor)
|
47
|
+
return m(t.toString()), o;
|
48
|
+
if (n === "variants")
|
49
|
+
return Object.entries(t).forEach(([f, c]) => {
|
50
|
+
c && Object.entries(c).forEach(([b, a]) => {
|
51
|
+
if (!a) return;
|
52
|
+
const y = `${e}.${f}-${b}`, l = h(a, y, r);
|
53
|
+
p.push(l);
|
54
|
+
});
|
55
|
+
}), o;
|
56
|
+
if (n === "defaultVariants")
|
57
|
+
return o;
|
58
|
+
if (n === "compoundVariants")
|
59
|
+
return t.forEach((f) => {
|
60
|
+
const { css: c, ...b } = f, a = Object.entries(b).reduce((l, [V, T]) => `${l}.${V}-${T}`, e), y = h(c, a, r);
|
61
|
+
p.push(y);
|
62
|
+
}), o;
|
63
|
+
if (n.startsWith("@")) {
|
64
|
+
const f = h(t, e, r), c = `${n} {
|
65
|
+
${f.replace(`
|
66
|
+
`, `
|
67
|
+
`)}
|
68
|
+
}`;
|
69
|
+
return p.push(c), o;
|
70
|
+
}
|
71
|
+
const u = $.includes("&") ? n.replace("&", e) : n.startsWith(":") ? `${e}${n}` : `${e} ${n}`, d = h(t, u, r);
|
72
|
+
return p.push(d), o;
|
73
|
+
}
|
74
|
+
if (r != null && r.templates && r.templates[n]) {
|
75
|
+
const d = t.split(".").reduce((f, c) => f[c], r.templates[n]);
|
76
|
+
if (d) {
|
77
|
+
const f = h(d, "");
|
78
|
+
return `${o}${f}`;
|
79
|
+
}
|
80
|
+
return console.warn(`Template "${n}" with path of "${t}" was not found in config!`), o;
|
81
|
+
}
|
82
|
+
if (typeof t == "number") {
|
83
|
+
const u = W(w, t, r);
|
84
|
+
return m(u);
|
85
|
+
}
|
86
|
+
if (typeof t != "string")
|
87
|
+
if ("toString" in t) t = t.toString();
|
88
|
+
else return o;
|
89
|
+
const { modifiers: O } = r || {}, P = function* () {
|
90
|
+
yield x(t), yield k(t, O);
|
91
|
+
}();
|
92
|
+
for (const { result: u, additionalCss: d = [] } of P)
|
93
|
+
t = u, d.forEach((f) => {
|
94
|
+
const c = h(f, "");
|
95
|
+
S(c, "");
|
96
|
+
});
|
97
|
+
return m(t);
|
98
|
+
}, "");
|
99
|
+
return i ? e ? [`${e} { ${i} }`, ...p].join(`
|
100
|
+
`) : i : p.join(`
|
101
|
+
`);
|
102
|
+
};
|
103
|
+
export {
|
104
|
+
x as a,
|
105
|
+
h as p
|
106
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),U=(s,e)=>{if(typeof s!="string")return{result:s};if(!e)return{result:s};const r=[];return Object.values(e).forEach(p=>{const{pattern:i,transform:j}=p;s=s.replace(i,o=>{const{value:$,css:t}=j(o);return t&&r.push(t),$})}),{result:s,additionalCss:r}},E=s=>typeof s!="string"?{result:s}:/\{[^{}]+\}/g.test(s)?{result:s.replace(/\{([^{}]+)\}/g,(...p)=>`var(--${V.dashCase(p[1].replaceAll(".","-"))})`)}:{result:s},W=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],g=(s,e,r)=>{if(W.some(i=>typeof i=="string"?i===s:i.test(s))){const i=(r==null?void 0:r.defaultUnit)||"px";return`${e}${i}`}return`${e}`},d=(s,e,r)=>{if(!s)return"";const p=[],i=Object.entries(s).reduce((o,[$,t])=>{const n=$.trim(),S=n.startsWith("-")?n:V.dashCase(n),w=(f,h=";")=>o=`${o}${f}${h}`,m=f=>w(`${S}:${f}`);if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return o;if(t.isColor)return m(t.toString()),o;if(n==="variants")return Object.entries(t).forEach(([u,c])=>{c&&Object.entries(c).forEach(([b,a])=>{if(!a)return;const l=`${e}.${u}-${b}`,y=d(a,l,r);p.push(y)})}),o;if(n==="defaultVariants")return o;if(n==="compoundVariants")return t.forEach(u=>{const{css:c,...b}=u,a=Object.entries(b).reduce((y,[T,k])=>`${y}.${T}-${k}`,e),l=d(c,a,r);p.push(l)}),o;if(n.startsWith("@")){const u=d(t,e,r),c=`${n} {
|
2
|
+
${u.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return p.push(c),o}const f=$.includes("&")?n.replace("&",e):n.startsWith(":")?`${e}${n}`:`${e} ${n}`,h=d(t,f,r);return p.push(h),o}if(r!=null&&r.templates&&r.templates[n]){const h=t.split(".").reduce((u,c)=>u[c],r.templates[n]);if(h){const u=d(h,"");return`${o}${u}`}return console.warn(`Template "${n}" with path of "${t}" was not found in config!`),o}if(typeof t=="number"){const f=g(S,t,r);return m(f)}if(typeof t!="string")if("toString"in t)t=t.toString();else return o;const{modifiers:O}=r||{},P=function*(){yield E(t),yield U(t,O)}();for(const{result:f,additionalCss:h=[]}of P)t=f,h.forEach(u=>{const c=d(u,"");w(c,"")});return m(t)},"");return i?e?[`${e} { ${i} }`,...p].join(`
|
6
|
+
`):i:p.join(`
|
7
|
+
`)};exports.parseStyles=d;exports.parseValueTokens=E;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { SaltyConfig } from '../config';
|
2
|
+
/**
|
3
|
+
* Add unit to a number value based on property name
|
4
|
+
* @param key - The property name
|
5
|
+
* @param value - The value to add unit to
|
6
|
+
*/
|
7
|
+
export declare const addUnit: (key: string, value: string | number, config?: SaltyConfig) => string;
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-DyTXfJI6.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)};exports.checkShouldRestart=i;
|
package/server/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "../index-
|
2
|
+
import { i as e } from "../index-DuY0wgQt.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;
|
package/types/config-types.d.ts
CHANGED
@@ -64,6 +64,10 @@ export interface SaltyConfig {
|
|
64
64
|
* Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
|
65
65
|
*/
|
66
66
|
externalModules?: ('react' | 'react-dom' | OrString)[];
|
67
|
+
/**
|
68
|
+
* default unit for px based properties when providing a number value. Default is 'px'.
|
69
|
+
*/
|
70
|
+
defaultUnit?: 'px' | 'rem' | 'em' | 'vh' | 'vw' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'ex' | 'fr' | 'percent' | OrString;
|
67
71
|
}
|
68
72
|
export interface CachedConfig {
|
69
73
|
templates: CssTemplates;
|
@@ -1,7 +0,0 @@
|
|
1
|
-
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),q=(r,o)=>{if(typeof r!="string")return{result:r};if(!o)return{result:r};const e=[];return Object.values(o).forEach(p=>{const{pattern:h,transform:j}=p;r=r.replace(h,n=>{const{value:a,css:t}=j(n);return t&&e.push(t),a})}),{result:r,additionalCss:e}},E=r=>typeof r!="string"?{result:r}:/\{[^{}]+\}/g.test(r)?{result:r.replace(/\{([^{}]+)\}/g,(...p)=>`var(--${V.dashCase(p[1].replaceAll(".","-"))})`)}:{result:r},$=(r,o,e)=>{if(!r)return"";const p=[],h=Object.entries(r).reduce((n,[a,t])=>{const s=a.trim(),O=s.startsWith("-")?s:V.dashCase(s),S=(u,c=";")=>n=`${n}${u}${c}`,y=u=>S(`${O}:${u}`);if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return n;if(t.isColor)return y(t.toString()),n;if(s==="variants")return Object.entries(t).forEach(([i,f])=>{f&&Object.entries(f).forEach(([m,d])=>{if(!d)return;const b=`${o}.${i}-${m}`,l=$(d,b,e);p.push(l)})}),n;if(s==="defaultVariants")return n;if(s==="compoundVariants")return t.forEach(i=>{const{css:f,...m}=i,d=Object.entries(m).reduce((l,[w,W])=>`${l}.${w}-${W}`,o),b=$(f,d,e);p.push(b)}),n;if(s.startsWith("@")){const i=$(t,o,e),f=`${s} {
|
2
|
-
${i.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return p.push(f),n}const u=a.includes("&")?s.replace("&",o):s.startsWith(":")?`${o}${s}`:`${o} ${s}`,c=$(t,u,e);return p.push(c),n}if(e!=null&&e.templates&&e.templates[s]){const c=t.split(".").reduce((i,f)=>i[f],e.templates[s]);if(c){const i=$(c,"");return`${n}${i}`}return console.warn(`Template "${s}" with path of "${t}" was not found in config!`),n}if(typeof t=="number")return y(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return n;const{modifiers:T}=e||{},k=function*(){yield E(t),yield q(t,T)}();for(const{result:u,additionalCss:c=[]}of k)t=u,c.forEach(i=>{const f=$(i,"");S(f,"")});return y(t)},"");return h?o?[`${o} { ${h} }`,...p].join(`
|
6
|
-
`):h:p.join(`
|
7
|
-
`)};exports.parseStyles=$;exports.parseValueTokens=E;
|
package/parse-styles-DsUKNoSv.js
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
import { d as E } from "./dash-case-DBThphLm.js";
|
2
|
-
const W = (r, o) => {
|
3
|
-
if (typeof r != "string") return { result: r };
|
4
|
-
if (!o) return { result: r };
|
5
|
-
const e = [];
|
6
|
-
return Object.values(o).forEach((p) => {
|
7
|
-
const { pattern: $, transform: l } = p;
|
8
|
-
r = r.replace($, (n) => {
|
9
|
-
const { value: d, css: t } = l(n);
|
10
|
-
return t && e.push(t), d;
|
11
|
-
});
|
12
|
-
}), { result: r, additionalCss: e };
|
13
|
-
}, P = (r) => typeof r != "string" ? { result: r } : /\{[^{}]+\}/g.test(r) ? { result: r.replace(/\{([^{}]+)\}/g, (...p) => `var(--${E(p[1].replaceAll(".", "-"))})`) } : { result: r }, h = (r, o, e) => {
|
14
|
-
if (!r) return "";
|
15
|
-
const p = [], $ = Object.entries(r).reduce((n, [d, t]) => {
|
16
|
-
const s = d.trim(), O = s.startsWith("-") ? s : E(s), S = (u, c = ";") => n = `${n}${u}${c}`, m = (u) => S(`${O}:${u}`);
|
17
|
-
if (typeof t == "function" && (t = t()), typeof t == "object") {
|
18
|
-
if (!t) return n;
|
19
|
-
if (t.isColor)
|
20
|
-
return m(t.toString()), n;
|
21
|
-
if (s === "variants")
|
22
|
-
return Object.entries(t).forEach(([i, f]) => {
|
23
|
-
f && Object.entries(f).forEach(([y, a]) => {
|
24
|
-
if (!a) return;
|
25
|
-
const b = `${o}.${i}-${y}`, j = h(a, b, e);
|
26
|
-
p.push(j);
|
27
|
-
});
|
28
|
-
}), n;
|
29
|
-
if (s === "defaultVariants")
|
30
|
-
return n;
|
31
|
-
if (s === "compoundVariants")
|
32
|
-
return t.forEach((i) => {
|
33
|
-
const { css: f, ...y } = i, a = Object.entries(y).reduce((j, [k, w]) => `${j}.${k}-${w}`, o), b = h(f, a, e);
|
34
|
-
p.push(b);
|
35
|
-
}), n;
|
36
|
-
if (s.startsWith("@")) {
|
37
|
-
const i = h(t, o, e), f = `${s} {
|
38
|
-
${i.replace(`
|
39
|
-
`, `
|
40
|
-
`)}
|
41
|
-
}`;
|
42
|
-
return p.push(f), n;
|
43
|
-
}
|
44
|
-
const u = d.includes("&") ? s.replace("&", o) : s.startsWith(":") ? `${o}${s}` : `${o} ${s}`, c = h(t, u, e);
|
45
|
-
return p.push(c), n;
|
46
|
-
}
|
47
|
-
if (e != null && e.templates && e.templates[s]) {
|
48
|
-
const c = t.split(".").reduce((i, f) => i[f], e.templates[s]);
|
49
|
-
if (c) {
|
50
|
-
const i = h(c, "");
|
51
|
-
return `${n}${i}`;
|
52
|
-
}
|
53
|
-
return console.warn(`Template "${s}" with path of "${t}" was not found in config!`), n;
|
54
|
-
}
|
55
|
-
if (typeof t == "number") return m(t);
|
56
|
-
if (typeof t != "string")
|
57
|
-
if ("toString" in t) t = t.toString();
|
58
|
-
else return n;
|
59
|
-
const { modifiers: V } = e || {}, T = function* () {
|
60
|
-
yield P(t), yield W(t, V);
|
61
|
-
}();
|
62
|
-
for (const { result: u, additionalCss: c = [] } of T)
|
63
|
-
t = u, c.forEach((i) => {
|
64
|
-
const f = h(i, "");
|
65
|
-
S(f, "");
|
66
|
-
});
|
67
|
-
return m(t);
|
68
|
-
}, "");
|
69
|
-
return $ ? o ? [`${o} { ${$} }`, ...p].join(`
|
70
|
-
`) : $ : p.join(`
|
71
|
-
`);
|
72
|
-
};
|
73
|
-
export {
|
74
|
-
P as a,
|
75
|
-
h as p
|
76
|
-
};
|