@salty-css/core 0.0.1-alpha.203 → 0.0.1-alpha.205
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-_k0TKi9f.cjs → index-BEJWepok.cjs} +2 -2
- package/{index-CuE3hjO7.js → index-BsRtXRDr.js} +55 -56
- package/package.json +1 -1
- package/parse-styles-B67L4oyf.cjs +3 -0
- package/parse-styles-DZbuVYRn.js +125 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/types/config-types.d.ts +1 -1
- package/parse-styles-CbYzTfwr.js +0 -118
- package/parse-styles-DhDStS4F.cjs +0 -3
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-BEJWepok.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-BsRtXRDr.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-B67L4oyf.cjs");const e=require("../index-BEJWepok.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-DZbuVYRn.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-BsRtXRDr.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 m=require("../parse-styles-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-B67L4oyf.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-
|
1
|
+
import { p as m } from "../parse-styles-DZbuVYRn.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 = {}) => {
|
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-B67L4oyf.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.parseAndJoinStyles(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([]),d=a=>{const r=i[a];r!==void 0?c.add(`${a}=${String(r)}`):c.add(a)};Object.keys(t).forEach(d),n.map(a=>Object.keys(a).forEach(d));const l=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&&l.add(p)})}return{element:s,variantKeys:[...c],propValueKeys:[...l],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-DZbuVYRn.js";
|
5
5
|
import { t as C, d as x } from "../dash-case-DBThphLm.js";
|
6
6
|
class m {
|
7
7
|
constructor(s) {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";const Ce=require("esbuild"),xe=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),a=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-
|
2
|
-
`)},ke=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ye(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},ye=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?ye(o,i,s):s.add(t)}),[...s]):[],me=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return a.existsSync(t)?t:me(r.join(e,".."))},Pe=async e=>{const t=me(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await Pe(e);if(t)return t.type};let J;const ge=async e=>{if(J)return J;const t=await De(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 Ce=require("esbuild"),xe=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),r=require("path"),a=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-B67L4oyf.cjs"),B=require("winston"),V=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function Ne(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 de=Ne(Ce),pe=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const f=o.trim(),d=await pe(i,[...t,f]);s.push(d)}else n[o]=i;if(Object.keys(n).length){const o=t.map(P.dashCase).join("-"),i=await X.parseAndJoinStyles(n,`.${o}`);s.push(i)}return s.join(`
|
2
|
+
`)},ke=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=ye(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},ye=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?ye(o,i,s):s.add(t)}),[...s]):[],me=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=r.join(e,"package.json");return a.existsSync(t)?t:me(r.join(e,".."))},Pe=async e=>{const t=me(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await Pe(e);if(t)return t.type};let J;const ge=async e=>{if(J)return J;const t=await De(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-BEJWepok.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),_e=e=>{G.error(e)};function he(e){return e?typeof e!="string"?he(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 Te={"*, *::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"}},R={externalModules:[],rcFile:void 0,destDir:void 0},Se=e=>{if(R.externalModules.length>0)return R.externalModules;const s=a.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return R.externalModules=n,n},M=async e=>{if(R.destDir)return R.destDir;const t=await re(e),s=r.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),Y=(e,t=[])=>we(t).test(e),je=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=r.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):je(r.join(e,".."))},re=async e=>{var n,o;const t=await je(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Ee=async e=>{const t=await re(e),s=await M(e),n=r.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=r.join(s,"salty.config.js"),i=await ge(e),f=Se(n);await de.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:f});const d=Date.now(),{config:y}=await import(`${o}?t=${d}`);return y},be=async(e,t)=>{var ce,le;const s=await M(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async h=>{const{contents:b,outputFilePath:O}=await K(e,h,s);Object.entries(b).forEach(([x,k])=>{k.isMedia?n.mediaQueries.push([x,k]):k.isGlobalDefine?n.globalStyles.push(k):k.isDefineVariables?n.variables.push(k):k.isDefineTemplates&&n.templates.push(k._setPath(O))})}));const o=await Ee(e),i={...o},f=new Set,d=(h,b=[])=>h?Object.entries(h).flatMap(([O,x])=>{if(!x)return;if(typeof x=="object")return d(x,[...b,O]);const k=he(O),te=P.dashCase(O),se=[...b,k].join(".");f.add(`"${se}"`);const U=[...b.map(P.dashCase),te].join("-"),fe=X.parseVariableTokens(x);return fe?`--${U}: ${fe.transformed};`:`--${U}: ${x};`}):[],y=h=>h?Object.entries(h).flatMap(([b,O])=>{const x=d(O);return b==="base"?x.join(""):`${b} { ${x.join("")} }`}):[],u=h=>h?Object.entries(h).flatMap(([b,O])=>Object.entries(O).flatMap(([x,k])=>{const te=d(k,[b]),se=`.${b}-${x}, [data-${b}="${x}"]`,U=te.join("");return`${se} { ${U} }`})):[],m=h=>({...h,responsive:void 0,conditional:void 0}),g=h=>n.variables.map(b=>h==="static"?m(b._current):b._current[h]),p=V.mergeStyles(m(o.variables),g("static")),F=d(p),S=V.mergeStyles((ce=o.variables)==null?void 0:ce.responsive,g("responsive")),T=y(S),D=V.mergeStyles((le=o.variables)==null?void 0:le.conditional,g("conditional")),_=u(D),v=r.join(s,"css/_variables.css"),E=`:root { ${F.join("")} ${T.join("")} } ${_.join("")}`;a.writeFileSync(v,E),i.staticVariables=p;const z=r.join(s,"css/_global.css"),N=V.mergeStyles(o.global,n.globalStyles),H=await X.parseAndJoinStyles(N,"");a.writeFileSync(z,`@layer global { ${H} }`);const c=r.join(s,"css/_reset.css"),j=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Te,l=await X.parseAndJoinStyles(j,"");a.writeFileSync(c,`@layer reset { ${l} }`);const $=r.join(s,"css/_templates.css"),C=V.mergeStyles(o.templates,n.templates),q=await pe(C),I=ke(C);a.writeFileSync($,q),i.templates=C;const W=V.mergeFactories(n.templates);i.templatePaths=Object.fromEntries(Object.entries(W).map(([h,b])=>[h,b._path||"nope"]));const{mediaQueries:A}=n;i.mediaQueries=Object.fromEntries(A.map(([h,b])=>[`@${h}`,b]));const L=A.map(([h])=>`'@${h}'`).join(" | "),ee=r.join(s,"types/css-tokens.d.ts"),Z=`
|
3
3
|
// Variable types
|
4
4
|
type VariableTokens = ${[...f].join("|")};
|
5
5
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -4,28 +4,27 @@ import { d as W, t as I } from "./dash-case-DBThphLm.js";
|
|
4
4
|
import { join as i, parse as Y } from "path";
|
5
5
|
import { existsSync as it, writeFileSync as j, mkdirSync as J, readFileSync as D, statSync as Pt, readdirSync as kt } from "fs";
|
6
6
|
import { readFile as gt, writeFile as Dt } from "fs/promises";
|
7
|
-
import { p as at, a as _t } from "./parse-styles-
|
7
|
+
import { p as at, a as _t } from "./parse-styles-DZbuVYRn.js";
|
8
8
|
import { createLogger as Tt, format as ot, transports as Et } from "winston";
|
9
9
|
import { mergeStyles as z, mergeFactories as Ot } from "./css/merge.js";
|
10
10
|
const yt = async (t, e = []) => {
|
11
11
|
if (!t) return "";
|
12
|
-
const s = [],
|
13
|
-
for (const [
|
14
|
-
if (typeof a
|
15
|
-
|
16
|
-
const l = n.trim(), u = await yt(a, [...e, l]);
|
12
|
+
const s = [], n = {};
|
13
|
+
for (const [o, a] of Object.entries(t))
|
14
|
+
if (typeof a != "function") if (a && typeof a == "object") {
|
15
|
+
const l = o.trim(), u = await yt(a, [...e, l]);
|
17
16
|
s.push(u);
|
18
17
|
} else
|
19
|
-
o
|
20
|
-
if (Object.keys(
|
21
|
-
const
|
18
|
+
n[o] = a;
|
19
|
+
if (Object.keys(n).length) {
|
20
|
+
const o = e.map(W).join("-"), a = await at(n, `.${o}`);
|
22
21
|
s.push(a);
|
23
22
|
}
|
24
23
|
return s.join(`
|
25
24
|
`);
|
26
|
-
}, Vt = (t) => t ? Object.entries(t).reduce((e, [s,
|
27
|
-
const a = e ? `${e}.${
|
28
|
-
return typeof
|
25
|
+
}, Vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = ht(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, ht = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
26
|
+
const a = e ? `${e}.${n}` : n;
|
27
|
+
return typeof o == "object" ? ht(o, a, s) : s.add(e);
|
29
28
|
}), [...s]) : [], bt = (t) => {
|
30
29
|
if (!t || t === "/") throw new Error("Could not find package.json file");
|
31
30
|
const e = i(t, "package.json");
|
@@ -108,8 +107,8 @@ const Rt = {
|
|
108
107
|
if (V.externalModules.length > 0) return V.externalModules;
|
109
108
|
const s = D(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
110
109
|
if (!s) return [];
|
111
|
-
const
|
112
|
-
return V.externalModules =
|
110
|
+
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
111
|
+
return V.externalModules = n, n;
|
113
112
|
}, M = async (t) => {
|
114
113
|
if (V.destDir) return V.destDir;
|
115
114
|
const e = await ct(t), s = i(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
@@ -121,25 +120,25 @@ const Rt = {
|
|
121
120
|
});
|
122
121
|
return s ? (V.rcFile = s, s) : Ft(i(t, ".."));
|
123
122
|
}, ct = async (t) => {
|
124
|
-
var
|
125
|
-
const e = await Ft(t), s = (
|
126
|
-
return s || ((
|
123
|
+
var n, o;
|
124
|
+
const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
|
125
|
+
return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
|
127
126
|
}, zt = async (t) => {
|
128
|
-
const e = await ct(t), s = await M(t),
|
127
|
+
const e = await ct(t), s = await M(t), n = i(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = i(s, "salty.config.js"), a = await $t(t), l = St(n);
|
129
128
|
await mt.build({
|
130
|
-
entryPoints: [
|
129
|
+
entryPoints: [n],
|
131
130
|
minify: !0,
|
132
131
|
treeShaking: !0,
|
133
132
|
bundle: !0,
|
134
|
-
outfile:
|
133
|
+
outfile: o,
|
135
134
|
format: a,
|
136
135
|
external: l
|
137
136
|
});
|
138
|
-
const u = Date.now(), { config: d } = await import(`${
|
137
|
+
const u = Date.now(), { config: d } = await import(`${o}?t=${u}`);
|
139
138
|
return d;
|
140
139
|
}, Wt = async (t, e) => {
|
141
140
|
var ft, ut;
|
142
|
-
const s = await M(t),
|
141
|
+
const s = await M(t), n = {
|
143
142
|
mediaQueries: [],
|
144
143
|
globalStyles: [],
|
145
144
|
variables: [],
|
@@ -149,11 +148,11 @@ const Rt = {
|
|
149
148
|
[...e].map(async (y) => {
|
150
149
|
const { contents: w, outputFilePath: O } = await tt(t, y, s);
|
151
150
|
Object.entries(w).forEach(([x, P]) => {
|
152
|
-
P.isMedia ?
|
151
|
+
P.isMedia ? n.mediaQueries.push([x, P]) : P.isGlobalDefine ? n.globalStyles.push(P) : P.isDefineVariables ? n.variables.push(P) : P.isDefineTemplates && n.templates.push(P._setPath(O));
|
153
152
|
});
|
154
153
|
})
|
155
154
|
);
|
156
|
-
const
|
155
|
+
const o = await zt(t), a = { ...o }, l = /* @__PURE__ */ new Set(), u = (y, w = []) => y ? Object.entries(y).flatMap(([O, x]) => {
|
157
156
|
if (!x) return;
|
158
157
|
if (typeof x == "object") return u(x, [...w, O]);
|
159
158
|
const P = wt(O), st = W(O), nt = [...w, P].join(".");
|
@@ -166,19 +165,19 @@ const Rt = {
|
|
166
165
|
}) : [], f = (y) => y ? Object.entries(y).flatMap(([w, O]) => Object.entries(O).flatMap(([x, P]) => {
|
167
166
|
const st = u(P, [w]), nt = `.${w}-${x}, [data-${w}="${x}"]`, U = st.join("");
|
168
167
|
return `${nt} { ${U} }`;
|
169
|
-
})) : [], m = (y) => ({ ...y, responsive: void 0, conditional: void 0 }), g = (y) =>
|
168
|
+
})) : [], m = (y) => ({ ...y, responsive: void 0, conditional: void 0 }), g = (y) => n.variables.map((w) => y === "static" ? m(w._current) : w._current[y]), p = z(m(o.variables), g("static")), S = u(p), h = z((ft = o.variables) == null ? void 0 : ft.responsive, g("responsive")), T = d(h), k = z((ut = o.variables) == null ? void 0 : ut.conditional, g("conditional")), _ = f(k), v = i(s, "css/_variables.css"), E = `:root { ${S.join("")} ${T.join("")} } ${_.join("")}`;
|
170
169
|
j(v, E), a.staticVariables = p;
|
171
|
-
const B = i(s, "css/_global.css"), N = z(
|
170
|
+
const B = i(s, "css/_global.css"), N = z(o.global, n.globalStyles), G = await at(N, "");
|
172
171
|
j(B, `@layer global { ${G} }`);
|
173
|
-
const r = i(s, "css/_reset.css"), $ =
|
172
|
+
const r = i(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Rt, c = await at($, "");
|
174
173
|
j(r, `@layer reset { ${c} }`);
|
175
|
-
const C = i(s, "css/_templates.css"), F = z(
|
174
|
+
const C = i(s, "css/_templates.css"), F = z(o.templates, n.templates), H = await yt(F), K = Vt(F);
|
176
175
|
j(C, H), a.templates = F;
|
177
|
-
const A = Ot(
|
176
|
+
const A = Ot(n.templates);
|
178
177
|
a.templatePaths = Object.fromEntries(
|
179
178
|
Object.entries(A).map(([y, w]) => [y, w._path || "nope"])
|
180
179
|
);
|
181
|
-
const { mediaQueries: L } =
|
180
|
+
const { mediaQueries: L } = n;
|
182
181
|
a.mediaQueries = Object.fromEntries(L.map(([y, w]) => [`@${y}`, w]));
|
183
182
|
const Q = L.map(([y]) => `'@${y}'`).join(" | "), et = i(s, "types/css-tokens.d.ts"), q = `
|
184
183
|
// Variable types
|
@@ -199,9 +198,9 @@ const Rt = {
|
|
199
198
|
j(xt, JSON.stringify(a, null, 2));
|
200
199
|
}, dt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
201
200
|
if (/^['"`]/.test(s)) return e;
|
202
|
-
const
|
203
|
-
if (!
|
204
|
-
const l =
|
201
|
+
const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
202
|
+
if (!o.test(t)) return e;
|
203
|
+
const l = o.exec(t);
|
205
204
|
if (l) {
|
206
205
|
const u = l.at(1);
|
207
206
|
if (Ct.some((f) => u == null ? void 0 : u.includes(f))) return e;
|
@@ -219,12 +218,12 @@ ${t}`;
|
|
219
218
|
return t;
|
220
219
|
}
|
221
220
|
}, tt = async (t, e, s) => {
|
222
|
-
const
|
223
|
-
it(
|
221
|
+
const n = I(e), o = i(s, "./temp");
|
222
|
+
it(o) || J(o);
|
224
223
|
const a = Y(e);
|
225
224
|
let l = D(e, "utf8");
|
226
225
|
l = dt(l), l = It(l, t);
|
227
|
-
const u = i(s, "js",
|
226
|
+
const u = i(s, "js", n + ".js"), d = await ct(t), f = i(t, (d == null ? void 0 : d.configDir) || "", "salty.config.ts"), m = St(f), g = await $t(t);
|
228
227
|
await mt.build({
|
229
228
|
stdin: {
|
230
229
|
contents: l,
|
@@ -256,11 +255,11 @@ ${t}`;
|
|
256
255
|
const p = Date.now();
|
257
256
|
return { contents: await import(`${u}?t=${p}`), outputFilePath: u };
|
258
257
|
}, Bt = async (t) => {
|
259
|
-
const e = await M(t), s = i(e, "cache/config-cache.json"),
|
260
|
-
if (!
|
261
|
-
return JSON.parse(
|
258
|
+
const e = await M(t), s = i(e, "cache/config-cache.json"), n = D(s, "utf8");
|
259
|
+
if (!n) throw new Error("Could not find config cache file");
|
260
|
+
return JSON.parse(n);
|
262
261
|
}, lt = async (t) => {
|
263
|
-
const e = await Bt(t), s = await M(t),
|
262
|
+
const e = await Bt(t), s = await M(t), n = i(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
|
264
263
|
return z(a, e);
|
265
264
|
}, jt = () => {
|
266
265
|
try {
|
@@ -270,9 +269,9 @@ ${t}`;
|
|
270
269
|
}
|
271
270
|
}, Xt = async (t, e = jt(), s = !0) => {
|
272
271
|
try {
|
273
|
-
const
|
272
|
+
const n = Date.now();
|
274
273
|
e ? X.info("Generating CSS in production mode! 🔥") : X.info("Generating CSS in development mode! 🚀");
|
275
|
-
const
|
274
|
+
const o = [], a = [], l = await M(t), u = i(l, "index.css");
|
276
275
|
s && (() => {
|
277
276
|
it(l) && Nt("rm -rf " + l), J(l, { recursive: !0 }), J(i(l, "css")), J(i(l, "types")), J(i(l, "js")), J(i(l, "cache"));
|
278
277
|
})();
|
@@ -318,7 +317,7 @@ ${t}`;
|
|
318
317
|
const S = await lt(t);
|
319
318
|
for (const r of p.keyframes) {
|
320
319
|
const { value: b } = r, $ = `a_${b.animationName}.css`, c = `css/${$}`, C = i(l, c);
|
321
|
-
|
320
|
+
o.push($), j(C, b.css);
|
322
321
|
}
|
323
322
|
const h = {};
|
324
323
|
for (const r of p.components) {
|
@@ -346,7 +345,7 @@ ${t}`;
|
|
346
345
|
`), c = I(r, 6), C = Y(r), F = W(C.name), H = i(l, `css/f_${F}-${c}.css`);
|
347
346
|
j(H, $);
|
348
347
|
});
|
349
|
-
const T =
|
348
|
+
const T = o.map((r) => `@import url('./css/${r}');`).join(`
|
350
349
|
`);
|
351
350
|
let E = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
352
351
|
|
@@ -377,16 +376,16 @@ ${et}
|
|
377
376
|
E += r;
|
378
377
|
}
|
379
378
|
j(u, E);
|
380
|
-
const N = Date.now() -
|
379
|
+
const N = Date.now() - n, G = N < 200 ? "🔥" : N < 500 ? "🚀" : N < 1e3 ? "🎉" : N < 2e3 ? "🚗" : N < 5e3 ? "🤔" : "🥴";
|
381
380
|
X.info(`Generated CSS in ${N}ms! ${G}`);
|
382
|
-
} catch (
|
383
|
-
console.error(
|
381
|
+
} catch (n) {
|
382
|
+
console.error(n);
|
384
383
|
}
|
385
384
|
}, Yt = async (t, e) => {
|
386
385
|
try {
|
387
386
|
const s = await M(t);
|
388
387
|
if (rt(e)) {
|
389
|
-
const
|
388
|
+
const o = [], a = await lt(t), { contents: l } = await tt(t, e, s);
|
390
389
|
for (const [u, d] of Object.entries(l)) {
|
391
390
|
if (d.isKeyframes && d.css) {
|
392
391
|
const S = `css/${`a_${d.animationName}.css`}`, h = i(s, S);
|
@@ -397,7 +396,7 @@ ${et}
|
|
397
396
|
const p = d.factory._withBuildContext({
|
398
397
|
name: u
|
399
398
|
});
|
400
|
-
|
399
|
+
o[0].push(p.cssFileName);
|
401
400
|
const S = `css/${p.cssFileName}`, h = i(s, S);
|
402
401
|
j(h, await p.css);
|
403
402
|
}
|
@@ -406,10 +405,10 @@ ${et}
|
|
406
405
|
name: u,
|
407
406
|
config: a
|
408
407
|
}), m = `css/${f.cssFileName}`, g = i(s, m);
|
409
|
-
j(g, await f.css),
|
408
|
+
j(g, await f.css), o[f.priority] || (o[f.priority] = []), o[f.priority].push(f.cssFileName);
|
410
409
|
}
|
411
410
|
if (a.importStrategy !== "component")
|
412
|
-
|
411
|
+
o.forEach((u, d) => {
|
413
412
|
const f = `l_${d}.css`, m = i(s, "css", f);
|
414
413
|
let g = D(m, "utf8");
|
415
414
|
u.forEach((p) => {
|
@@ -427,7 +426,7 @@ ${v}
|
|
427
426
|
}), j(m, g);
|
428
427
|
});
|
429
428
|
else {
|
430
|
-
const u =
|
429
|
+
const u = o.flat().map((p) => `@import url('./${p}');`).join(`
|
431
430
|
`), d = I(e, 6), f = Y(e), m = W(f.name), g = i(s, `css/f_${m}-${d}.css`);
|
432
431
|
j(g, u);
|
433
432
|
}
|
@@ -437,11 +436,11 @@ ${v}
|
|
437
436
|
}
|
438
437
|
}, te = async (t, e, s = jt()) => {
|
439
438
|
try {
|
440
|
-
const
|
439
|
+
const n = await M(t);
|
441
440
|
if (rt(e)) {
|
442
441
|
const a = D(e, "utf8");
|
443
442
|
a.replace(/^(?!export\s)const\s.*/gm, (m) => `export ${m}`) !== a && await Dt(e, a);
|
444
|
-
const u = await lt(t), { contents: d } = await tt(t, e,
|
443
|
+
const u = await lt(t), { contents: d } = await tt(t, e, n);
|
445
444
|
let f = a;
|
446
445
|
if (Object.entries(d).forEach(([m, g]) => {
|
447
446
|
var c;
|
@@ -473,8 +472,8 @@ ${f}`;
|
|
473
472
|
}
|
474
473
|
return f = f.replace("{ styled }", "{ styledClient as styled }"), f = f.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), f;
|
475
474
|
}
|
476
|
-
} catch (
|
477
|
-
console.error("Error in minimizeFile:",
|
475
|
+
} catch (n) {
|
476
|
+
console.error("Error in minimizeFile:", n);
|
478
477
|
}
|
479
478
|
};
|
480
479
|
export {
|
package/package.json
CHANGED
@@ -0,0 +1,3 @@
|
|
1
|
+
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),A=n=>e=>{if(typeof e!="string"||!n)return;let t=e;const a=[];return Object.values(n).forEach(d=>{const{pattern:w,transform:P}=d;t=t.replace(w,j=>{const{value:x,css:u}=P(j);return u&&a.push(u),x})}),{transformed:t,additionalCss:a}},N=n=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...d)=>`var(--${T.dashCase(d[1].replaceAll(".","-"))})`)},U=N(),q=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],J=(n,e,t)=>{if(q.some(d=>typeof d=="string"?d===n:d.test(n))){const d=(t==null?void 0:t.defaultUnit)||"px";return`${e}${d}`}return`${e}`},M=["Webkit","Moz","ms","O"],Q=n=>n.startsWith("-")?n:M.some(e=>n.startsWith(e))?`-${T.dashCase(n)}`:T.dashCase(n),h=async(n,e="",t)=>{if(!n)throw new Error("No styles provided to parseStyles function!");const a=new Set,w=Object.entries(n).map(async([y,s])=>{var b;const r=y.trim(),$=Q(r),f=(o,c=";")=>`${$}:${o}${c}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templatePaths[r]){const{default:o}=await import(t.templatePaths[r]);if(typeof o.params[r]=="function"){const c=await o.params[r](s),[i]=await h(c,"");return i}}if(t!=null&&t.templates&&t.templates[r]){const c=s.split(".").reduce((i,p)=>i[p],t.templates[r]);if(c){const[i]=await h(c,"");return i}console.warn(`Template "${r}" 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(r==="defaultVariants")return;if(r==="variants"){const i=Object.entries(s);for(const[p,l]of i){if(!l)return;const E=Object.entries(l);for(const[W,m]of E){if(!m)return;const O=`${e}.${p}-${W}`;(await h(m,O,t)).forEach(z=>a.add(z))}}return}if(r==="compoundVariants"){for(const i of s){const{css:p,...l}=i,E=Object.entries(l).reduce((m,[O,k])=>`${m}.${O}-${k}`,e);(await h(p,E,t)).forEach(m=>a.add(m))}return}if(r.startsWith("@")){const i=((b=t==null?void 0:t.mediaQueries)==null?void 0:b[r])||r,p=await V(s,e,t),l=`${i} { ${p} }`;a.add(l);return}const o=y.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await h(s,o,t)).forEach(i=>a.add(i));return}if(typeof s=="number"){const o=J($,s,t);return f(o)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${$}`);return f(s)}),{modifiers:P}=t||{},j=[N(),A(P)],u=(await Promise.all(w).then(y=>Promise.all(y.map(s=>j.reduce(async(r,$)=>{const f=await r;if(!f)return f;const C=await $(f);if(!C)return f;const{transformed:b,additionalCss:o}=C;let c="";if(o)for(const i of o)c+=await V(i,"");return`${c}${b}`},Promise.resolve(s)))))).join(`
|
2
|
+
`);if(!u.trim())return a;const S=e?`${e} { ${u} }`:u;return a.add(S),a},V=async(n,e,t)=>[...await h(n,e,t)].join(`
|
3
|
+
`);exports.parseAndJoinStyles=V;exports.parseVariableTokens=U;
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import { d as C } from "./dash-case-DBThphLm.js";
|
2
|
+
const U = (n) => (e) => {
|
3
|
+
if (typeof e != "string" || !n) return;
|
4
|
+
let t = e;
|
5
|
+
const i = [];
|
6
|
+
return Object.values(n).forEach((d) => {
|
7
|
+
const { pattern: w, transform: P } = d;
|
8
|
+
t = t.replace(w, (j) => {
|
9
|
+
const { value: T, css: u } = P(j);
|
10
|
+
return u && i.push(u), T;
|
11
|
+
});
|
12
|
+
}), { transformed: t, additionalCss: i };
|
13
|
+
}, k = (n) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...d) => `var(--${C(d[1].replaceAll(".", "-"))})`) }, F = k(), A = [
|
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
|
+
], M = (n, e, t) => {
|
35
|
+
if (A.some((d) => typeof d == "string" ? d === n : d.test(n))) {
|
36
|
+
const d = (t == null ? void 0 : t.defaultUnit) || "px";
|
37
|
+
return `${e}${d}`;
|
38
|
+
}
|
39
|
+
return `${e}`;
|
40
|
+
}, Q = ["Webkit", "Moz", "ms", "O"], _ = (n) => n.startsWith("-") ? n : Q.some((e) => n.startsWith(e)) ? `-${C(n)}` : C(n), h = async (n, e = "", t) => {
|
41
|
+
if (!n) throw new Error("No styles provided to parseStyles function!");
|
42
|
+
const i = /* @__PURE__ */ new Set(), w = Object.entries(n).map(async ([y, s]) => {
|
43
|
+
var b;
|
44
|
+
const r = y.trim(), $ = _(r), f = (a, c = ";") => `${$}:${a}${c}`;
|
45
|
+
if (typeof s == "function" && (s = s({ scope: e, config: t })), s instanceof Promise && (s = await s), t != null && t.templates && t.templatePaths[r]) {
|
46
|
+
const { default: a } = await import(t.templatePaths[r]);
|
47
|
+
if (typeof a.params[r] == "function") {
|
48
|
+
const c = await a.params[r](s), [o] = await h(c, "");
|
49
|
+
return o;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if (t != null && t.templates && t.templates[r]) {
|
53
|
+
const c = s.split(".").reduce((o, p) => o[p], t.templates[r]);
|
54
|
+
if (c) {
|
55
|
+
const [o] = await h(c, "");
|
56
|
+
return o;
|
57
|
+
}
|
58
|
+
console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
if (typeof s == "object") {
|
62
|
+
if (!s) return;
|
63
|
+
if (s.isColor) return f(s.toString());
|
64
|
+
if (r === "defaultVariants") return;
|
65
|
+
if (r === "variants") {
|
66
|
+
const o = Object.entries(s);
|
67
|
+
for (const [p, m] of o) {
|
68
|
+
if (!m) return;
|
69
|
+
const x = Object.entries(m);
|
70
|
+
for (const [V, l] of x) {
|
71
|
+
if (!l) return;
|
72
|
+
const O = `${e}.${p}-${V}`;
|
73
|
+
(await h(l, O, t)).forEach((S) => i.add(S));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
if (r === "compoundVariants") {
|
79
|
+
for (const o of s) {
|
80
|
+
const { css: p, ...m } = o, x = Object.entries(m).reduce((l, [O, W]) => `${l}.${O}-${W}`, e);
|
81
|
+
(await h(p, x, t)).forEach((l) => i.add(l));
|
82
|
+
}
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (r.startsWith("@")) {
|
86
|
+
const o = ((b = t == null ? void 0 : t.mediaQueries) == null ? void 0 : b[r]) || r, p = await N(s, e, t), m = `${o} { ${p} }`;
|
87
|
+
i.add(m);
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
const a = y.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
|
91
|
+
(await h(s, a, t)).forEach((o) => i.add(o));
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
if (typeof s == "number") {
|
95
|
+
const a = M($, s, t);
|
96
|
+
return f(a);
|
97
|
+
}
|
98
|
+
if (typeof s != "string")
|
99
|
+
if ("toString" in s) s = s.toString();
|
100
|
+
else throw new Error(`Invalid value type for property ${$}`);
|
101
|
+
return f(s);
|
102
|
+
}), { modifiers: P } = t || {}, j = [k(), U(P)], u = (await Promise.all(w).then((y) => Promise.all(
|
103
|
+
y.map((s) => j.reduce(async (r, $) => {
|
104
|
+
const f = await r;
|
105
|
+
if (!f) return f;
|
106
|
+
const E = await $(f);
|
107
|
+
if (!E) return f;
|
108
|
+
const { transformed: b, additionalCss: a } = E;
|
109
|
+
let c = "";
|
110
|
+
if (a)
|
111
|
+
for (const o of a)
|
112
|
+
c += await N(o, "");
|
113
|
+
return `${c}${b}`;
|
114
|
+
}, Promise.resolve(s)))
|
115
|
+
))).join(`
|
116
|
+
`);
|
117
|
+
if (!u.trim()) return i;
|
118
|
+
const z = e ? `${e} { ${u} }` : u;
|
119
|
+
return i.add(z), i;
|
120
|
+
}, N = async (n, e, t) => [...await h(n, e, t)].join(`
|
121
|
+
`);
|
122
|
+
export {
|
123
|
+
F as a,
|
124
|
+
N as p
|
125
|
+
};
|
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-BEJWepok.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-BsRtXRDr.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
@@ -22,7 +22,7 @@ export interface CssTemplateObject {
|
|
22
22
|
[key: PropertyKey]: CssTemplate;
|
23
23
|
}
|
24
24
|
export interface CssTemplateFunction {
|
25
|
-
(value:
|
25
|
+
(value: any): CssTemplate;
|
26
26
|
}
|
27
27
|
export interface CssTemplates {
|
28
28
|
[key: PropertyKey]: CssTemplateObject | CssTemplateFunction;
|
package/parse-styles-CbYzTfwr.js
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
import { d as C } from "./dash-case-DBThphLm.js";
|
2
|
-
const A = (r) => (e) => {
|
3
|
-
if (typeof e != "string" || !r) return;
|
4
|
-
let t = e;
|
5
|
-
const o = [];
|
6
|
-
return Object.values(r).forEach((a) => {
|
7
|
-
const { pattern: w, transform: j } = a;
|
8
|
-
t = t.replace(w, (P) => {
|
9
|
-
const { value: T, css: u } = j(P);
|
10
|
-
return u && o.push(u), T;
|
11
|
-
});
|
12
|
-
}), { transformed: t, additionalCss: o };
|
13
|
-
}, k = (r) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...a) => `var(--${C(a[1].replaceAll(".", "-"))})`) }, F = k(), M = [
|
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
|
-
], Q = (r, e, t) => {
|
35
|
-
if (M.some((a) => typeof a == "string" ? a === r : a.test(r))) {
|
36
|
-
const a = (t == null ? void 0 : t.defaultUnit) || "px";
|
37
|
-
return `${e}${a}`;
|
38
|
-
}
|
39
|
-
return `${e}`;
|
40
|
-
}, S = ["Webkit", "Moz", "ms", "O"], _ = (r) => r.startsWith("-") ? r : S.some((e) => r.startsWith(e)) ? `-${C(r)}` : C(r), $ = async (r, e = "", t) => {
|
41
|
-
if (!r) throw new Error("No styles provided to parseStyles function!");
|
42
|
-
const o = /* @__PURE__ */ new Set(), w = Object.entries(r).map(async ([y, s]) => {
|
43
|
-
var b;
|
44
|
-
const n = y.trim(), h = _(n), c = (d, f = ";") => `${h}:${d}${f}`;
|
45
|
-
if (typeof s == "function" && (s = s({ scope: e, config: t })), s instanceof Promise && (s = await s), t != null && t.templates && t.templates[n]) {
|
46
|
-
const f = s.split(".").reduce((i, p) => i[p], t.templates[n]);
|
47
|
-
if (f) {
|
48
|
-
const [i] = await $(f, "");
|
49
|
-
return i;
|
50
|
-
}
|
51
|
-
console.warn(`Template "${n}" with path of "${s}" was not found in config!`);
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
if (typeof s == "object") {
|
55
|
-
if (!s) return;
|
56
|
-
if (s.isColor) return c(s.toString());
|
57
|
-
if (n === "defaultVariants") return;
|
58
|
-
if (n === "variants") {
|
59
|
-
const i = Object.entries(s);
|
60
|
-
for (const [p, m] of i) {
|
61
|
-
if (!m) return;
|
62
|
-
const x = Object.entries(m);
|
63
|
-
for (const [V, l] of x) {
|
64
|
-
if (!l) return;
|
65
|
-
const O = `${e}.${p}-${V}`;
|
66
|
-
(await $(l, O, t)).forEach((U) => o.add(U));
|
67
|
-
}
|
68
|
-
}
|
69
|
-
return;
|
70
|
-
}
|
71
|
-
if (n === "compoundVariants") {
|
72
|
-
for (const i of s) {
|
73
|
-
const { css: p, ...m } = i, x = Object.entries(m).reduce((l, [O, W]) => `${l}.${O}-${W}`, e);
|
74
|
-
(await $(p, x, t)).forEach((l) => o.add(l));
|
75
|
-
}
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
if (n.startsWith("@")) {
|
79
|
-
const i = ((b = t == null ? void 0 : t.mediaQueries) == null ? void 0 : b[n]) || n, p = await N(s, e, t), m = `${i} { ${p} }`;
|
80
|
-
o.add(m);
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
const d = y.includes("&") ? n.replace("&", e) : n.startsWith(":") ? `${e}${n}` : `${e} ${n}`;
|
84
|
-
(await $(s, d, t)).forEach((i) => o.add(i));
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
if (typeof s == "number") {
|
88
|
-
const d = Q(h, s, t);
|
89
|
-
return c(d);
|
90
|
-
}
|
91
|
-
if (typeof s != "string")
|
92
|
-
if ("toString" in s) s = s.toString();
|
93
|
-
else throw new Error(`Invalid value type for property ${h}`);
|
94
|
-
return c(s);
|
95
|
-
}), { modifiers: j } = t || {}, P = [k(), A(j)], u = (await Promise.all(w).then((y) => Promise.all(
|
96
|
-
y.map((s) => P.reduce(async (n, h) => {
|
97
|
-
const c = await n;
|
98
|
-
if (!c) return c;
|
99
|
-
const E = await h(c);
|
100
|
-
if (!E) return c;
|
101
|
-
const { transformed: b, additionalCss: d } = E;
|
102
|
-
let f = "";
|
103
|
-
if (d)
|
104
|
-
for (const i of d)
|
105
|
-
f += await N(i, "");
|
106
|
-
return `${f}${b}`;
|
107
|
-
}, Promise.resolve(s)))
|
108
|
-
))).join(`
|
109
|
-
`);
|
110
|
-
if (!u.trim()) return o;
|
111
|
-
const z = e ? `${e} { ${u} }` : u;
|
112
|
-
return o.add(z), o;
|
113
|
-
}, N = async (r, e, t) => [...await $(r, e, t)].join(`
|
114
|
-
`);
|
115
|
-
export {
|
116
|
-
F as a,
|
117
|
-
N as p
|
118
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),S=r=>e=>{if(typeof e!="string"||!r)return;let t=e;const i=[];return Object.values(r).forEach(a=>{const{pattern:w,transform:j}=a;t=t.replace(w,C=>{const{value:x,css:p}=j(C);return p&&i.push(p),x})}),{transformed:t,additionalCss:i}},N=r=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...a)=>`var(--${T.dashCase(a[1].replaceAll(".","-"))})`)},U=N(),q=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],J=(r,e,t)=>{if(q.some(a=>typeof a=="string"?a===r:a.test(r))){const a=(t==null?void 0:t.defaultUnit)||"px";return`${e}${a}`}return`${e}`},M=["Webkit","Moz","ms","O"],Q=r=>r.startsWith("-")?r:M.some(e=>r.startsWith(e))?`-${T.dashCase(r)}`:T.dashCase(r),$=async(r,e="",t)=>{if(!r)throw new Error("No styles provided to parseStyles function!");const i=new Set,w=Object.entries(r).map(async([y,s])=>{var b;const n=y.trim(),h=Q(n),c=(d,f=";")=>`${h}:${d}${f}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templates[n]){const f=s.split(".").reduce((o,u)=>o[u],t.templates[n]);if(f){const[o]=await $(f,"");return o}console.warn(`Template "${n}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return c(s.toString());if(n==="defaultVariants")return;if(n==="variants"){const o=Object.entries(s);for(const[u,l]of o){if(!l)return;const E=Object.entries(l);for(const[W,m]of E){if(!m)return;const O=`${e}.${u}-${W}`;(await $(m,O,t)).forEach(A=>i.add(A))}}return}if(n==="compoundVariants"){for(const o of s){const{css:u,...l}=o,E=Object.entries(l).reduce((m,[O,k])=>`${m}.${O}-${k}`,e);(await $(u,E,t)).forEach(m=>i.add(m))}return}if(n.startsWith("@")){const o=((b=t==null?void 0:t.mediaQueries)==null?void 0:b[n])||n,u=await V(s,e,t),l=`${o} { ${u} }`;i.add(l);return}const d=y.includes("&")?n.replace("&",e):n.startsWith(":")?`${e}${n}`:`${e} ${n}`;(await $(s,d,t)).forEach(o=>i.add(o));return}if(typeof s=="number"){const d=J(h,s,t);return c(d)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${h}`);return c(s)}),{modifiers:j}=t||{},C=[N(),S(j)],p=(await Promise.all(w).then(y=>Promise.all(y.map(s=>C.reduce(async(n,h)=>{const c=await n;if(!c)return c;const P=await h(c);if(!P)return c;const{transformed:b,additionalCss:d}=P;let f="";if(d)for(const o of d)f+=await V(o,"");return`${f}${b}`},Promise.resolve(s)))))).join(`
|
2
|
-
`);if(!p.trim())return i;const z=e?`${e} { ${p} }`:p;return i.add(z),i},V=async(r,e,t)=>[...await $(r,e,t)].join(`
|
3
|
-
`);exports.parseAndJoinStyles=V;exports.parseVariableTokens=U;
|