@salty-css/core 0.0.1-alpha.250 → 0.0.1-alpha.252
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 +2 -2
- 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 +22 -22
- package/{index-CelIwoBr.cjs → index-Bh0Rdc9S.cjs} +2 -2
- package/{index-B_V_O1Qg.js → index-D_yT1YG2.js} +1 -1
- package/package.json +1 -1
- package/parse-styles-BBLk1gXe.js +137 -0
- package/parse-styles-bvJ5u1by.cjs +5 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-DJb3U4c8.cjs → should-restart-Crlwi2VJ.cjs} +1 -1
- package/{should-restart-eXCtNI8U.js → should-restart-tiWPsnY8.js} +1 -1
- package/parse-styles-CXclnoUS.cjs +0 -5
- package/parse-styles-DZ-LjC9e.js +0 -134
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-
|
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-Bh0Rdc9S.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-Crlwi2VJ.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,x=>{if(x)return P(x);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(),x=y.join(" ");await X(`npm install ${x}`),P.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"))},P=async(i,a)=>{const{default:f}=await C[i],d=ne.render(f,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,f=process.cwd();return n.join(f,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:f=i,cssFile:d,skipInstall:p}=this.opts();if(!f)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(f),q=await Promise.all([P("salty.config.ts"),P("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"),g=await s.readFile(h,"utf-8").catch(()=>{});if(g===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(g),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!==g&&(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 re } 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 ce, format as te } from "path";
|
5
5
|
import { render as le } from "ejs";
|
6
|
-
import { l as t, a as h, g as K, i as de, b as fe } from "../index-
|
6
|
+
import { l as t, a as h, g as K, i as de, b as fe } from "../index-D_yT1YG2.js";
|
7
7
|
import { p as pe } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as ue } from "child_process";
|
9
9
|
import ge from "ora";
|
10
|
-
import { c as ye } from "../should-restart-
|
10
|
+
import { c as ye } from "../should-restart-tiWPsnY8.js";
|
11
11
|
const ne = (g) => new Promise((P, x) => {
|
12
12
|
ue(g, ($) => {
|
13
13
|
if ($) return x($);
|
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-bvJ5u1by.cjs");const e=require("../index-Bh0Rdc9S.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,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 { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-
|
7
|
+
import "../parse-styles-BBLk1gXe.js";
|
8
|
+
import { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-D_yT1YG2.js";
|
9
9
|
import "../css/merge.js";
|
10
10
|
import "../define-templates-4A2yHcMF.js";
|
11
11
|
export {
|
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-bvJ5u1by.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-BBLk1gXe.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
|
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-bvJ5u1by.cjs"),o=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 o.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_${o.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,n={...s,variants:t,compoundVariants:e};return S.parseAndJoinStyles(n,`.${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,n])=>(t.includes(i)&&e.push("t_"+o.toHash(o.dashCase(`${i}-${n}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}class x extends y{constructor(s){super(s),this._params=s}}class v 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:n={},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=o.dashCase(u);u&&p.add(g)})}return{element:s,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:n,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=x;exports.StyledGenerator=v;
|
package/generators/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import { p as
|
5
|
-
import { t as
|
1
|
+
var C = Object.defineProperty;
|
2
|
+
var x = (a, t, s) => t in a ? C(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
|
3
|
+
var m = (a, t, s) => x(a, typeof t != "symbol" ? t + "" : t, s);
|
4
|
+
import { p as S } from "../parse-styles-BBLk1gXe.js";
|
5
|
+
import { t as f, d as h } from "../dash-case-DBThphLm.js";
|
6
6
|
class y {
|
7
7
|
constructor(t) {
|
8
|
-
|
8
|
+
m(this, "buildContext", {});
|
9
9
|
this.params = t;
|
10
10
|
}
|
11
11
|
get priority() {
|
@@ -16,7 +16,7 @@ class y {
|
|
16
16
|
}
|
17
17
|
get hash() {
|
18
18
|
const { base: t, variants: s, compoundVariants: e } = this.params;
|
19
|
-
return
|
19
|
+
return f({ base: t, variants: s, compoundVariants: e });
|
20
20
|
}
|
21
21
|
get cssClassName() {
|
22
22
|
return this.hash;
|
@@ -27,27 +27,27 @@ class y {
|
|
27
27
|
}
|
28
28
|
get cssFileName() {
|
29
29
|
const { callerName: t } = this.buildContext;
|
30
|
-
return t ? `cl_${
|
30
|
+
return t ? `cl_${h(t)}-${this.hash}.css` : `${this.hash}.css`;
|
31
31
|
}
|
32
32
|
get css() {
|
33
33
|
const { base: t = {}, variants: s = {}, compoundVariants: e = [] } = this.params, { config: i } = this.buildContext, n = { ...t, variants: s, compoundVariants: e };
|
34
|
-
return
|
34
|
+
return S(n, `.${this.cssClassName}`, i, this.isRoot);
|
35
35
|
}
|
36
36
|
getTemplateClasses(t = this.buildContext.config) {
|
37
37
|
if (!(t != null && t.templates) || !this.params.base || this.priority > 0) return [];
|
38
38
|
const s = Object.keys(t.templates);
|
39
|
-
return Object.entries(this.params.base).reduce((e, [i, n]) => (s.includes(i) && e.push("t_" +
|
39
|
+
return Object.entries(this.params.base).reduce((e, [i, n]) => (s.includes(i) && e.push("t_" + f(h(`${i}-${n}`), 4)), e), []);
|
40
40
|
}
|
41
41
|
_withBuildContext(t) {
|
42
42
|
return this.buildContext = t, this;
|
43
43
|
}
|
44
44
|
}
|
45
|
-
class
|
45
|
+
class j extends y {
|
46
46
|
constructor(t) {
|
47
47
|
super(t), this._params = t;
|
48
48
|
}
|
49
49
|
}
|
50
|
-
class
|
50
|
+
class E extends y {
|
51
51
|
constructor(t, s) {
|
52
52
|
super(s), this.tagName = t, this._params = s;
|
53
53
|
}
|
@@ -56,24 +56,24 @@ class j extends y {
|
|
56
56
|
return this.params.priority ? this.params.priority : typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
57
57
|
}
|
58
58
|
get clientProps() {
|
59
|
-
const { element: t, variants: s = {}, compoundVariants: e = [], defaultVariants: i = {}, defaultProps: n = {}, passProps:
|
59
|
+
const { element: t, variants: s = {}, compoundVariants: e = [], defaultVariants: i = {}, defaultProps: n = {}, passProps: p } = this.params, { callerName: b, isProduction: g } = this.buildContext, c = /* @__PURE__ */ new Set([]), d = (r) => {
|
60
60
|
const o = i[r];
|
61
61
|
o !== void 0 ? c.add(`${r}=${String(o)}`) : c.add(r);
|
62
62
|
};
|
63
|
-
Object.keys(s).forEach(
|
64
|
-
const
|
63
|
+
Object.keys(s).forEach(d), e.map((r) => Object.keys(r).forEach(d));
|
64
|
+
const l = /* @__PURE__ */ new Set([]);
|
65
65
|
if (this.params.base) {
|
66
|
-
const r = JSON.stringify(this.params.base).match(/\{props\.([
|
66
|
+
const r = JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);
|
67
67
|
r && r.forEach((o) => {
|
68
|
-
const
|
69
|
-
|
68
|
+
const u = o.replace(/\{(?:-)?props\.([^}]+)\}/gi, "$1"), N = h(u);
|
69
|
+
u && l.add(N);
|
70
70
|
});
|
71
71
|
}
|
72
72
|
return {
|
73
73
|
element: t,
|
74
74
|
variantKeys: [...c],
|
75
|
-
propValueKeys: [...
|
76
|
-
passProps:
|
75
|
+
propValueKeys: [...l],
|
76
|
+
passProps: p,
|
77
77
|
defaultProps: n,
|
78
78
|
attr: {
|
79
79
|
"data-component-name": g ? void 0 : b
|
@@ -82,6 +82,6 @@ class j extends y {
|
|
82
82
|
}
|
83
83
|
}
|
84
84
|
export {
|
85
|
-
|
86
|
-
|
85
|
+
j as ClassNameGenerator,
|
86
|
+
E as StyledGenerator
|
87
87
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";const Te=require("esbuild"),Oe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),c=require("path"),l=require("fs"),we=require("fs/promises"),Z=require("./parse-styles-
|
2
|
-
`)},ve=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=be(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},be=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?be(o,a,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:$e(c.join(e,".."))},Re=async e=>{const t=$e(e);return await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Me=async e=>{const t=await Re(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Me(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-
|
1
|
+
"use strict";const Te=require("esbuild"),Oe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),c=require("path"),l=require("fs"),we=require("fs/promises"),Z=require("./parse-styles-bvJ5u1by.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),Ee=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Ve(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 Se=Ve(Te),je=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,a]of Object.entries(e))if(typeof a!="function")if(a&&typeof a=="object"){const i=o.trim(),d=await je(a,[...t,i]);s.push(d)}else n[o]=a;if(Object.keys(n).length){const o=t.map(D.dashCase).join("-"),a="t_"+D.toHash(o,4),i=await Z.parseAndJoinStyles(n,`.${o}, .${a}`);s.push(i)}return s.join(`
|
2
|
+
`)},ve=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=be(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},be=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?be(o,a,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:$e(c.join(e,".."))},Re=async e=>{const t=$e(e);return await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Me=async e=>{const t=await Re(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Me(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-Bh0Rdc9S.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({})]}),Je=e=>{B.error(e)};function Ce(e){return e?typeof e!="string"?Ce(String(e)):e.replace(/[^\d\w]/g,"."):""}const ze={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},qe=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),a=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function i(d){if(ce.isVariableDeclaration(d)&&d.name.getText()===t){const S=d.getStart(),m=d.getEnd();clearTimeout(o),s([S,m])}d.forEachChild(i)}i(a)}),E={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(E.externalModules.length>0)return E.externalModules;const s=l.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return E.externalModules=n,n},z=async e=>{if(E.destDir)return E.destDir;const t=await fe(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},le=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),ee=(e,t=[])=>Ne(t).test(e),xe=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):xe(c.join(e,".."))},fe=async e=>{var n,o;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},He=async e=>{const t=await fe(e),s=await z(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),a=await Fe(e),i=Pe(n);await Se.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const d=Date.now(),{config:S}=await import(`${o}?t=${d}`);return{config:S,path:o}},ke=async(e,t)=>{var me,ye;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:$,outputFilePath:K}=await U(e,w,s);Object.entries($).forEach(([_,P])=>{P.isMedia?n.mediaQueries.push([_,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${_};;${K}`))})}));const{config:o,path:a}=await He(e),i={...o},{mediaQueries:d}=n;i.mediaQueries=Object.fromEntries(d.map(([w,$])=>[`@${w}`,$]));const S=d.map(([w])=>`'@${w}'`).join(" | "),m=new Set,r=async(w,$=[])=>{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 r(T,[...$,P]);const oe=Ce(P),ie=D.dashCase(P),ae=[...$,oe].join(".");m.add(`"${ae}"`);const Y=[...$.map(D.dashCase),ie].join("-"),ge=Z.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 $=Object.entries(w).map(async([_,P])=>{const M=await r(P);return _==="base"?M.join(""):i.mediaQueries[_]?`${i.mediaQueries[_]} { ${M.join("")} }`:`${_} { ${M.join("")} }`});return(await Promise.all($)).flat()},y=async w=>{if(!w)return[];const $=Object.entries(w).map(async([_,P])=>{const M=Object.entries(P).map(async([T,oe])=>{const ie=await r(oe,[_]),ae=`.${_}-${T}, [data-${_}="${T}"]`,Y=ie.join("");return`${ae} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all($)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map($=>w==="static"?h($._current):$._current[w]),F=J.mergeObjects(h(o.variables),p("static")),x=await r(F),k=J.mergeObjects((me=o.variables)==null?void 0:me.responsive,p("responsive")),V=await g(k),q=J.mergeObjects((ye=o.variables)==null?void 0:ye.conditional,p("conditional")),A=await y(q),de=c.join(s,"css/_variables.css"),v=`:root { ${x.join("")} ${V.join("")} } ${A.join("")}`;l.writeFileSync(de,v),i.staticVariables=F;const te=c.join(s,"css/_global.css"),u=J.mergeObjects(o.global,n.globalStyles),j=await Z.parseAndJoinStyles(u,"");l.writeFileSync(te,`@layer global { ${j} }`);const b=c.join(s,"css/_reset.css"),C=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ze,N=await Z.parseAndJoinStyles(C,"");l.writeFileSync(b,`@layer reset { ${N} }`);const O=c.join(s,"css/_templates.css"),R=J.mergeObjects(o.templates,n.templates),W=await je(R),I=ve(R);l.writeFileSync(O,`@layer templates { ${W} }`),i.templates=R;const X=o.templates?[Ee.defineTemplates(o.templates)._setPath(`config;;${a}`)]:[],se=J.mergeFactories(n.templates,X);i.templatePaths=Object.fromEntries(Object.entries(se).map(([w,$])=>[w,$._path]));const G=c.join(s,"types/css-tokens.d.ts"),De=`
|
3
3
|
// Variable types
|
4
4
|
type VariableTokens = ${[...m].join("|")};
|
5
5
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -4,7 +4,7 @@ import { d as K, t as J } from "./dash-case-DBThphLm.js";
|
|
4
4
|
import { join as r, parse as tt } from "path";
|
5
5
|
import { existsSync as ut, writeFileSync as j, mkdirSync as H, readFileSync as _, statSync as Et, readdirSync as Ot } from "fs";
|
6
6
|
import { readFile as Ct } from "fs/promises";
|
7
|
-
import { p as ft, a as Mt } from "./parse-styles-
|
7
|
+
import { p as ft, a as Mt } from "./parse-styles-BBLk1gXe.js";
|
8
8
|
import { createLogger as Rt, format as rt, transports as Jt } from "winston";
|
9
9
|
import { mergeObjects as I, mergeFactories as zt } from "./css/merge.js";
|
10
10
|
import { d as Wt } from "./define-templates-4A2yHcMF.js";
|
package/package.json
CHANGED
@@ -0,0 +1,137 @@
|
|
1
|
+
import { d as S } from "./dash-case-DBThphLm.js";
|
2
|
+
const M = (o) => (e) => {
|
3
|
+
if (typeof e != "string" || !o) return;
|
4
|
+
let t = e;
|
5
|
+
const p = [];
|
6
|
+
return Object.values(o).forEach((n) => {
|
7
|
+
const { pattern: h, transform: w } = n;
|
8
|
+
t = t.replace(h, (C) => {
|
9
|
+
const { value: O, css: E } = w(C);
|
10
|
+
return E && p.push(E), O;
|
11
|
+
});
|
12
|
+
}), { transformed: t, additionalCss: p };
|
13
|
+
}, z = (o) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...n) => {
|
14
|
+
const h = S(n[1].replaceAll(".", "-"));
|
15
|
+
return h.startsWith("-") ? `-${h}` : `var(--${h})`;
|
16
|
+
}) }, B = z(), Q = [
|
17
|
+
"top",
|
18
|
+
"right",
|
19
|
+
"bottom",
|
20
|
+
"left",
|
21
|
+
"min-width",
|
22
|
+
/.*width.*/,
|
23
|
+
/^[^line]*height.*/,
|
24
|
+
// Exclude line-height
|
25
|
+
/padding.*/,
|
26
|
+
/margin.*/,
|
27
|
+
/border.*/,
|
28
|
+
/inset.*/,
|
29
|
+
/.*radius.*/,
|
30
|
+
/.*spacing.*/,
|
31
|
+
/.*gap.*/,
|
32
|
+
/.*indent.*/,
|
33
|
+
/.*offset.*/,
|
34
|
+
/.*size.*/,
|
35
|
+
/.*thickness.*/,
|
36
|
+
/.*font-size.*/
|
37
|
+
], _ = (o, e, t) => {
|
38
|
+
if (Q.some((n) => typeof n == "string" ? n === o : n.test(o))) {
|
39
|
+
const n = (t == null ? void 0 : t.defaultUnit) || "px";
|
40
|
+
return `${e}${n}`;
|
41
|
+
}
|
42
|
+
return `${e}`;
|
43
|
+
}, k = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : k.some((e) => o.startsWith(e)) ? `-${S(o)}` : S(o), y = async (o, e = "", t, p = !1) => {
|
44
|
+
if (!o) throw new Error("No styles provided to parseStyles function!");
|
45
|
+
const n = /* @__PURE__ */ new Set(), h = Object.entries(o), w = async ([u, s]) => {
|
46
|
+
var j;
|
47
|
+
const r = u.trim(), b = q(r), l = (a, d = ";") => `${b}:${a}${d}`, P = { scope: e, config: t };
|
48
|
+
if (typeof s == "function") return w([u, s(P)]);
|
49
|
+
if (s instanceof Promise) return w([u, await s]);
|
50
|
+
if (t != null && t.templates && t.templatePaths[r])
|
51
|
+
try {
|
52
|
+
const [a, d] = t.templatePaths[r].split(";;"), i = await import(d), c = d.includes("salty.config"), f = c ? i[a].templates : i[a], $ = c ? f[r] : f.params[r];
|
53
|
+
if (f && typeof $ == "function") {
|
54
|
+
const x = await $(s), [m] = await y(x, "");
|
55
|
+
return m;
|
56
|
+
}
|
57
|
+
} catch (a) {
|
58
|
+
console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`, a);
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
if (t != null && t.templates && t.templates[r]) {
|
62
|
+
if (p) return;
|
63
|
+
const d = s.split(".").reduce((i, c) => i[c], t.templates[r]);
|
64
|
+
if (d) {
|
65
|
+
const [i] = await y(d, "");
|
66
|
+
return i;
|
67
|
+
}
|
68
|
+
console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
if (typeof s == "object") {
|
72
|
+
if (!s) return;
|
73
|
+
if (s.isColor) return l(s.toString());
|
74
|
+
if (r === "defaultVariants") return;
|
75
|
+
if (r === "variants") {
|
76
|
+
const i = Object.entries(s);
|
77
|
+
for (const [c, f] of i) {
|
78
|
+
if (!f) continue;
|
79
|
+
const $ = Object.entries(f);
|
80
|
+
for (const [x, m] of $) {
|
81
|
+
if (!m) continue;
|
82
|
+
const A = `${e}.${c}-${x}`;
|
83
|
+
(await y(m, A, t)).forEach((U) => n.add(U));
|
84
|
+
}
|
85
|
+
}
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
if (r === "compoundVariants") {
|
89
|
+
for (const i of s) {
|
90
|
+
const { css: c, ...f } = i, $ = Object.entries(f).reduce((m, [A, V]) => `${m}.${A}-${V}`, e);
|
91
|
+
(await y(c, $, t)).forEach((m) => n.add(m));
|
92
|
+
}
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
if (r.startsWith("@")) {
|
96
|
+
const i = ((j = t == null ? void 0 : t.mediaQueries) == null ? void 0 : j[r]) || r, c = await N(s, e, t), f = `${i} { ${c} }`;
|
97
|
+
n.add(f);
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
const a = u.includes("&") ? r.replaceAll("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
|
101
|
+
(await y(s, a, t)).forEach((i) => n.add(i));
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
if (typeof s == "number") {
|
105
|
+
const a = _(b, s, t);
|
106
|
+
return l(a);
|
107
|
+
}
|
108
|
+
if (typeof s != "string")
|
109
|
+
if ("toString" in s) s = s.toString();
|
110
|
+
else throw new Error(`Invalid value type for property ${b}`);
|
111
|
+
return l(s);
|
112
|
+
}, C = h.map(w), { modifiers: O } = t || {}, E = [z(), M(O)], W = (await Promise.all(C).then((u) => Promise.all(
|
113
|
+
u.map((s) => E.reduce(async (r, b) => {
|
114
|
+
const l = await r;
|
115
|
+
if (!l) return l;
|
116
|
+
const P = await b(l);
|
117
|
+
if (!P) return l;
|
118
|
+
const { transformed: j, additionalCss: a } = P;
|
119
|
+
let d = "";
|
120
|
+
if (a)
|
121
|
+
for (const i of a)
|
122
|
+
d += await N(i, "");
|
123
|
+
return `${d}${j}`;
|
124
|
+
}, Promise.resolve(s)))
|
125
|
+
))).filter((u) => u !== void 0).join(`
|
126
|
+
`);
|
127
|
+
if (!W.trim()) return Array.from(n);
|
128
|
+
const T = e ? `${e} {
|
129
|
+
${W}
|
130
|
+
}` : W;
|
131
|
+
return n.has(T) ? Array.from(n) : [T, ...n];
|
132
|
+
}, N = async (o, e, t, p = !1) => (await y(o, e, t, p)).join(`
|
133
|
+
`);
|
134
|
+
export {
|
135
|
+
B as a,
|
136
|
+
N as p
|
137
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),k=o=>e=>{if(typeof e!="string"||!o)return;let t=e;const u=[];return Object.values(o).forEach(n=>{const{pattern:h,transform:w}=n;t=t.replace(h,x=>{const{value:A,css:E}=w(x);return E&&u.push(E),A})}),{transformed:t,additionalCss:u}},z=o=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>{const h=T.dashCase(n[1].replaceAll(".","-"));return h.startsWith("-")?`-${h}`:`var(--${h})`})},q=z(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(o,e,t)=>{if(J.some(n=>typeof n=="string"?n===o:n.test(o))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=o=>o.startsWith("-")?o:Q.some(e=>o.startsWith(e))?`-${T.dashCase(o)}`:T.dashCase(o),y=async(o,e="",t,u=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const n=new Set,h=Object.entries(o),w=async([p,s])=>{var C;const r=p.trim(),b=_(r),l=(i,d=";")=>`${b}:${i}${d}`,P={scope:e,config:t};if(typeof s=="function")return w([p,s(P)]);if(s instanceof Promise)return w([p,await s]);if(t!=null&&t.templates&&t.templatePaths[r])try{const[i,d]=t.templatePaths[r].split(";;"),a=await import(d),c=d.includes("salty.config"),f=c?a[i].templates:a[i],$=c?f[r]:f.params[r];if(f&&typeof $=="function"){const j=await $(s),[m]=await y(j,"");return m}}catch(i){console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`,i);return}if(t!=null&&t.templates&&t.templates[r]){if(u)return;const d=s.split(".").reduce((a,c)=>a[c],t.templates[r]);if(d){const[a]=await y(d,"");return a}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 l(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const a=Object.entries(s);for(const[c,f]of a){if(!f)continue;const $=Object.entries(f);for(const[j,m]of $){if(!m)continue;const S=`${e}.${c}-${j}`;(await y(m,S,t)).forEach(U=>n.add(U))}}return}if(r==="compoundVariants"){for(const a of s){const{css:c,...f}=a,$=Object.entries(f).reduce((m,[S,N])=>`${m}.${S}-${N}`,e);(await y(c,$,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const a=((C=t==null?void 0:t.mediaQueries)==null?void 0:C[r])||r,c=await V(s,e,t),f=`${a} { ${c} }`;n.add(f);return}const i=p.includes("&")?r.replaceAll("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await y(s,i,t)).forEach(a=>n.add(a));return}if(typeof s=="number"){const i=M(b,s,t);return l(i)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${b}`);return l(s)},x=h.map(w),{modifiers:A}=t||{},E=[z(),k(A)],O=(await Promise.all(x).then(p=>Promise.all(p.map(s=>E.reduce(async(r,b)=>{const l=await r;if(!l)return l;const P=await b(l);if(!P)return l;const{transformed:C,additionalCss:i}=P;let d="";if(i)for(const a of i)d+=await V(a,"");return`${d}${C}`},Promise.resolve(s)))))).filter(p=>p!==void 0).join(`
|
2
|
+
`);if(!O.trim())return Array.from(n);const W=e?`${e} {
|
3
|
+
${O}
|
4
|
+
}`:O;return n.has(W)?Array.from(n):[W,...n]},V=async(o,e,t,u=!1)=>(await y(o,e,t,u)).join(`
|
5
|
+
`);exports.parseAndJoinStyles=V;exports.parseVariableTokens=q;
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-Crlwi2VJ.cjs");exports.checkShouldRestart=e.checkShouldRestart;
|
package/server/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const s=require("fs/promises"),r=require("./index-
|
1
|
+
"use strict";const s=require("fs/promises"),r=require("./index-Bh0Rdc9S.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-
|
2
|
+
import { i as e } from "./index-D_yT1YG2.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,5 +0,0 @@
|
|
1
|
-
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),k=a=>e=>{if(typeof e!="string"||!a)return;let t=e;const u=[];return Object.values(a).forEach(n=>{const{pattern:b,transform:y}=n;t=t.replace(b,x=>{const{value:O,css:E}=y(x);return E&&u.push(E),O})}),{transformed:t,additionalCss:u}},z=a=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)},q=z(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(a,e,t)=>{if(J.some(n=>typeof n=="string"?n===a:n.test(a))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=a=>a.startsWith("-")?a:Q.some(e=>a.startsWith(e))?`-${V.dashCase(a)}`:V.dashCase(a),$=async(a,e="",t,u=!1)=>{if(!a)throw new Error("No styles provided to parseStyles function!");const n=new Set,b=Object.entries(a),y=async([p,s])=>{var C;const r=p.trim(),w=_(r),l=(i,d=";")=>`${w}:${i}${d}`,P={scope:e,config:t};if(typeof s=="function")return y([p,s(P)]);if(s instanceof Promise)return y([p,await s]);if(t!=null&&t.templates&&t.templatePaths[r])try{const[i,d]=t.templatePaths[r].split(";;"),o=await import(d),c=d.includes("salty.config"),f=c?o[i].templates:o[i],h=c?f[r]:f.params[r];if(f&&typeof h=="function"){const j=await h(s),[m]=await $(j,"");return m}}catch(i){console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`,i);return}if(t!=null&&t.templates&&t.templates[r]){if(u)return;const d=s.split(".").reduce((o,c)=>o[c],t.templates[r]);if(d){const[o]=await $(d,"");return o}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 l(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const o=Object.entries(s);for(const[c,f]of o){if(!f)continue;const h=Object.entries(f);for(const[j,m]of h){if(!m)continue;const T=`${e}.${c}-${j}`;(await $(m,T,t)).forEach(U=>n.add(U))}}return}if(r==="compoundVariants"){for(const o of s){const{css:c,...f}=o,h=Object.entries(f).reduce((m,[T,N])=>`${m}.${T}-${N}`,e);(await $(c,h,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const o=((C=t==null?void 0:t.mediaQueries)==null?void 0:C[r])||r,c=await A(s,e,t),f=`${o} { ${c} }`;n.add(f);return}const i=p.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await $(s,i,t)).forEach(o=>n.add(o));return}if(typeof s=="number"){const i=M(w,s,t);return l(i)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${w}`);return l(s)},x=b.map(y),{modifiers:O}=t||{},E=[z(),k(O)],S=(await Promise.all(x).then(p=>Promise.all(p.map(s=>E.reduce(async(r,w)=>{const l=await r;if(!l)return l;const P=await w(l);if(!P)return l;const{transformed:C,additionalCss:i}=P;let d="";if(i)for(const o of i)d+=await A(o,"");return`${d}${C}`},Promise.resolve(s)))))).filter(p=>p!==void 0).join(`
|
2
|
-
`);if(!S.trim())return Array.from(n);const W=e?`${e} {
|
3
|
-
${S}
|
4
|
-
}`:S;return n.has(W)?Array.from(n):[W,...n]},A=async(a,e,t,u=!1)=>(await $(a,e,t,u)).join(`
|
5
|
-
`);exports.parseAndJoinStyles=A;exports.parseVariableTokens=q;
|
package/parse-styles-DZ-LjC9e.js
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
import { d as V } from "./dash-case-DBThphLm.js";
|
2
|
-
const M = (o) => (e) => {
|
3
|
-
if (typeof e != "string" || !o) return;
|
4
|
-
let t = e;
|
5
|
-
const p = [];
|
6
|
-
return Object.values(o).forEach((n) => {
|
7
|
-
const { pattern: b, transform: y } = n;
|
8
|
-
t = t.replace(b, (C) => {
|
9
|
-
const { value: O, css: E } = y(C);
|
10
|
-
return E && p.push(E), O;
|
11
|
-
});
|
12
|
-
}), { transformed: t, additionalCss: p };
|
13
|
-
}, z = (o) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) }, B = z(), Q = [
|
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
|
-
], _ = (o, e, t) => {
|
35
|
-
if (Q.some((n) => typeof n == "string" ? n === o : n.test(o))) {
|
36
|
-
const n = (t == null ? void 0 : t.defaultUnit) || "px";
|
37
|
-
return `${e}${n}`;
|
38
|
-
}
|
39
|
-
return `${e}`;
|
40
|
-
}, k = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : k.some((e) => o.startsWith(e)) ? `-${V(o)}` : V(o), $ = async (o, e = "", t, p = !1) => {
|
41
|
-
if (!o) throw new Error("No styles provided to parseStyles function!");
|
42
|
-
const n = /* @__PURE__ */ new Set(), b = Object.entries(o), y = async ([u, s]) => {
|
43
|
-
var j;
|
44
|
-
const r = u.trim(), w = q(r), l = (i, d = ";") => `${w}:${i}${d}`, P = { scope: e, config: t };
|
45
|
-
if (typeof s == "function") return y([u, s(P)]);
|
46
|
-
if (s instanceof Promise) return y([u, await s]);
|
47
|
-
if (t != null && t.templates && t.templatePaths[r])
|
48
|
-
try {
|
49
|
-
const [i, d] = t.templatePaths[r].split(";;"), a = await import(d), c = d.includes("salty.config"), f = c ? a[i].templates : a[i], h = c ? f[r] : f.params[r];
|
50
|
-
if (f && typeof h == "function") {
|
51
|
-
const x = await h(s), [m] = await $(x, "");
|
52
|
-
return m;
|
53
|
-
}
|
54
|
-
} catch (i) {
|
55
|
-
console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`, i);
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
if (t != null && t.templates && t.templates[r]) {
|
59
|
-
if (p) return;
|
60
|
-
const d = s.split(".").reduce((a, c) => a[c], t.templates[r]);
|
61
|
-
if (d) {
|
62
|
-
const [a] = await $(d, "");
|
63
|
-
return a;
|
64
|
-
}
|
65
|
-
console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
if (typeof s == "object") {
|
69
|
-
if (!s) return;
|
70
|
-
if (s.isColor) return l(s.toString());
|
71
|
-
if (r === "defaultVariants") return;
|
72
|
-
if (r === "variants") {
|
73
|
-
const a = Object.entries(s);
|
74
|
-
for (const [c, f] of a) {
|
75
|
-
if (!f) continue;
|
76
|
-
const h = Object.entries(f);
|
77
|
-
for (const [x, m] of h) {
|
78
|
-
if (!m) continue;
|
79
|
-
const T = `${e}.${c}-${x}`;
|
80
|
-
(await $(m, T, t)).forEach((U) => n.add(U));
|
81
|
-
}
|
82
|
-
}
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
if (r === "compoundVariants") {
|
86
|
-
for (const a of s) {
|
87
|
-
const { css: c, ...f } = a, h = Object.entries(f).reduce((m, [T, A]) => `${m}.${T}-${A}`, e);
|
88
|
-
(await $(c, h, t)).forEach((m) => n.add(m));
|
89
|
-
}
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
if (r.startsWith("@")) {
|
93
|
-
const a = ((j = t == null ? void 0 : t.mediaQueries) == null ? void 0 : j[r]) || r, c = await N(s, e, t), f = `${a} { ${c} }`;
|
94
|
-
n.add(f);
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
const i = u.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
|
98
|
-
(await $(s, i, t)).forEach((a) => n.add(a));
|
99
|
-
return;
|
100
|
-
}
|
101
|
-
if (typeof s == "number") {
|
102
|
-
const i = _(w, s, t);
|
103
|
-
return l(i);
|
104
|
-
}
|
105
|
-
if (typeof s != "string")
|
106
|
-
if ("toString" in s) s = s.toString();
|
107
|
-
else throw new Error(`Invalid value type for property ${w}`);
|
108
|
-
return l(s);
|
109
|
-
}, C = b.map(y), { modifiers: O } = t || {}, E = [z(), M(O)], S = (await Promise.all(C).then((u) => Promise.all(
|
110
|
-
u.map((s) => E.reduce(async (r, w) => {
|
111
|
-
const l = await r;
|
112
|
-
if (!l) return l;
|
113
|
-
const P = await w(l);
|
114
|
-
if (!P) return l;
|
115
|
-
const { transformed: j, additionalCss: i } = P;
|
116
|
-
let d = "";
|
117
|
-
if (i)
|
118
|
-
for (const a of i)
|
119
|
-
d += await N(a, "");
|
120
|
-
return `${d}${j}`;
|
121
|
-
}, Promise.resolve(s)))
|
122
|
-
))).filter((u) => u !== void 0).join(`
|
123
|
-
`);
|
124
|
-
if (!S.trim()) return Array.from(n);
|
125
|
-
const W = e ? `${e} {
|
126
|
-
${S}
|
127
|
-
}` : S;
|
128
|
-
return n.has(W) ? Array.from(n) : [W, ...n];
|
129
|
-
}, N = async (o, e, t, p = !1) => (await $(o, e, t, p)).join(`
|
130
|
-
`);
|
131
|
-
export {
|
132
|
-
B as a,
|
133
|
-
N as p
|
134
|
-
};
|