@salty-css/core 0.0.1-alpha.191 → 0.0.1-alpha.193
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/helpers/color.d.ts +10 -0
- package/helpers/index.cjs +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1141 -0
- package/{index-ptxZPIoq.cjs → index-BDBZd026.cjs} +2 -2
- package/{index-BiZBc7HK.js → index-xtFx15Ka.js} +1 -1
- package/package.json +7 -1
- package/parse-styles-DMutm9wZ.cjs +7 -0
- package/{parse-styles-DrLhKtqW.js → parse-styles-DsUKNoSv.js} +25 -24
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/parse-styles-3zK35muR.cjs +0 -7
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";const he=require("esbuild"),Se=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),a=require("fs"),ee=require("fs/promises"),L=require("./parse-styles-
|
2
|
-
`)},we=e=>e?Object.entries(e).reduce((t,[s,o])=>(typeof o=="object"&&(t[s]=ce(o).map(c=>`"${c}"`).join(" | ")),t),{}):{},ce=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([o,c])=>{const r=t?`${t}.${o}`:o;return typeof c=="object"?ce(c,r,s):s.add(t)}),[...s]):[],ae=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return a.existsSync(t)?t:ae(i.join(e,".."))},Fe=async e=>{const t=ae(e);return await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},be=async e=>{const t=await Fe(e);if(t)return t.type};let V;const le=async e=>{if(V)return V;const t=await be(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:Y&&Y.tagName.toUpperCase()==="SCRIPT"&&Y.src||new URL("index-
|
1
|
+
"use strict";const he=require("esbuild"),Se=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),a=require("fs"),ee=require("fs/promises"),L=require("./parse-styles-DMutm9wZ.cjs"),I=require("winston"),J=require("./css/merge.cjs");var Y=typeof document<"u"?document.currentScript:null;function je(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ie=je(he),re=(e,t=[])=>{if(!e)return"";const s=[],o={};if(Object.entries(e).forEach(([c,r])=>{if(typeof r=="object"){if(!r)return;const f=c.trim(),m=re(r,[...t,f]);s.push(m)}else o[c]=r}),Object.keys(o).length){const c=t.map(P.dashCase).join("-"),r=L.parseStyles(o,`.${c}`);s.push(r)}return s.join(`
|
2
|
+
`)},we=e=>e?Object.entries(e).reduce((t,[s,o])=>(typeof o=="object"&&(t[s]=ce(o).map(c=>`"${c}"`).join(" | ")),t),{}):{},ce=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([o,c])=>{const r=t?`${t}.${o}`:o;return typeof c=="object"?ce(c,r,s):s.add(t)}),[...s]):[],ae=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return a.existsSync(t)?t:ae(i.join(e,".."))},Fe=async e=>{const t=ae(e);return await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},be=async e=>{const t=await Fe(e);if(t)return t.type};let V;const le=async e=>{if(V)return V;const t=await be(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:Y&&Y.tagName.toUpperCase()==="SCRIPT"&&Y.src||new URL("index-BDBZd026.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},W=I.createLogger({level:"debug",format:I.format.combine(I.format.colorize(),I.format.cli()),transports:[new I.transports.Console({})]}),$e=e=>{W.error(e)};function fe(e){return e?typeof e!="string"?fe(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 Ce={"*, *::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"}},T={externalModules:[],rcFile:void 0,destDir:void 0},de=e=>{if(T.externalModules.length>0)return T.externalModules;const s=a.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const o=s[1].split(",").map(c=>c.replace(/['"`]/g,"").trim());return T.externalModules=o,o},M=async e=>{if(T.destDir)return T.destDir;const t=await se(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return T.destDir=s,s},te=["salty","css","styles","styled"],ue=(e=[])=>new RegExp(`\\.(${[...te,...e].join("|")})\\.`),K=(e,t=[])=>ue(t).test(e),pe=async e=>{if(T.rcFile)return T.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(T.rcFile=s,s):pe(i.join(e,".."))},se=async e=>{var o,c;const t=await pe(e),s=(o=t.projects)==null?void 0:o.find(r=>e.endsWith(r.dir||""));return s||((c=t.projects)==null?void 0:c.find(r=>r.dir===t.defaultProject))},xe=async e=>{const t=await se(e),s=await M(e),o=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),c=i.join(s,"salty.config.js"),r=await le(e),f=de(o);await ie.build({entryPoints:[o],minify:!0,treeShaking:!0,bundle:!0,outfile:c,format:r,external:f});const m=Date.now(),{config:u}=await import(`${c}?t=${m}`);return u},ye=async(e,t)=>{var q,G;const s=await xe(e),o={...s},c=new Set,r=(F,b=[])=>F?Object.entries(F).flatMap(([O,_])=>{if(!_)return;if(typeof _=="object")return r(_,[...b,O]);const A=fe(O),U=P.dashCase(O),Q=[...b,A].join(".");c.add(`"${Q}"`);const X=[...b.map(P.dashCase),U].join("-"),{result:ge}=L.parseValueTokens(_);return`--${X}: ${ge};`}):[],f=F=>F?Object.entries(F).flatMap(([b,O])=>{const _=r(O);return b==="base"?_.join(""):`${b} { ${_.join("")} }`}):[],m=F=>F?Object.entries(F).flatMap(([b,O])=>Object.entries(O).flatMap(([_,A])=>{const U=r(A,[b]),Q=`.${b}-${_}, [data-${b}="${_}"]`,X=U.join("");return`${Q} { ${X} }`})):[],u=F=>({...F,responsive:void 0,conditional:void 0}),n=F=>t.variables.map(b=>F==="static"?u(b._current):b._current[F]),h=r(J.mergeStyles(u(s.variables),n("static"))),p=f(J.mergeStyles((q=s.variables)==null?void 0:q.responsive,n("responsive"))),y=m(J.mergeStyles((G=s.variables)==null?void 0:G.conditional,n("conditional"))),w=await M(e),x=i.join(w,"css/_variables.css"),E=`:root { ${h.join("")} ${p.join("")} } ${y.join("")}`;a.writeFileSync(x,E);const D=i.join(w,"css/_global.css"),k=J.mergeStyles(s.global,t.globalStyles),R=L.parseStyles(k,"");a.writeFileSync(D,`@layer global { ${R} }`);const N=i.join(w,"css/_reset.css"),l=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:Ce,S=L.parseStyles(l,"");a.writeFileSync(N,`@layer reset { ${S} }`);const $=i.join(w,"css/_templates.css"),d=J.mergeStyles(s.templates,t.templates),C=re(d),j=we(d);a.writeFileSync($,C),o.templates=d;const g=i.join(w,"types/css-tokens.d.ts"),H=`
|
3
3
|
// Variable types
|
4
4
|
type VariableTokens = ${[...c].join("|")};
|
5
5
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -4,7 +4,7 @@ import { d as W, t as I } from "./dash-case-DBThphLm.js";
|
|
4
4
|
import { join as i, parse as A } from "path";
|
5
5
|
import { existsSync as et, writeFileSync as F, mkdirSync as J, readFileSync as E, statSync as wt, readdirSync as St } from "fs";
|
6
6
|
import { readFile as at, writeFile as Ct } from "fs/promises";
|
7
|
-
import { p as tt, a as Ft } from "./parse-styles-
|
7
|
+
import { p as tt, a as Ft } from "./parse-styles-DsUKNoSv.js";
|
8
8
|
import { createLogger as jt, format as Y, transports as xt } from "winston";
|
9
9
|
import { mergeStyles as z } from "./css/merge.js";
|
10
10
|
const lt = (t, e = []) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/core",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.193",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -28,7 +28,9 @@
|
|
28
28
|
"name": "core"
|
29
29
|
},
|
30
30
|
"peerDependencies": {
|
31
|
+
"color": ">=5.x",
|
31
32
|
"commander": ">=12.x",
|
33
|
+
"csstype": "^3.1.x",
|
32
34
|
"ejs": ">=3.x",
|
33
35
|
"esbuild": ">=0.21.x",
|
34
36
|
"ora": ">=8.x",
|
@@ -79,6 +81,10 @@
|
|
79
81
|
"./util": {
|
80
82
|
"import": "./util/index.js",
|
81
83
|
"require": "./util/index.cjs"
|
84
|
+
},
|
85
|
+
"./helpers": {
|
86
|
+
"import": "./helpers/index.js",
|
87
|
+
"require": "./helpers/index.cjs"
|
82
88
|
}
|
83
89
|
},
|
84
90
|
"bin": {
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),q=(r,o)=>{if(typeof r!="string")return{result:r};if(!o)return{result:r};const e=[];return Object.values(o).forEach(p=>{const{pattern:h,transform:j}=p;r=r.replace(h,n=>{const{value:a,css:t}=j(n);return t&&e.push(t),a})}),{result:r,additionalCss:e}},E=r=>typeof r!="string"?{result:r}:/\{[^{}]+\}/g.test(r)?{result:r.replace(/\{([^{}]+)\}/g,(...p)=>`var(--${V.dashCase(p[1].replaceAll(".","-"))})`)}:{result:r},$=(r,o,e)=>{if(!r)return"";const p=[],h=Object.entries(r).reduce((n,[a,t])=>{const s=a.trim(),O=s.startsWith("-")?s:V.dashCase(s),S=(u,c=";")=>n=`${n}${u}${c}`,y=u=>S(`${O}:${u}`);if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return n;if(t.isColor)return y(t.toString()),n;if(s==="variants")return Object.entries(t).forEach(([i,f])=>{f&&Object.entries(f).forEach(([m,d])=>{if(!d)return;const b=`${o}.${i}-${m}`,l=$(d,b,e);p.push(l)})}),n;if(s==="defaultVariants")return n;if(s==="compoundVariants")return t.forEach(i=>{const{css:f,...m}=i,d=Object.entries(m).reduce((l,[w,W])=>`${l}.${w}-${W}`,o),b=$(f,d,e);p.push(b)}),n;if(s.startsWith("@")){const i=$(t,o,e),f=`${s} {
|
2
|
+
${i.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return p.push(f),n}const u=a.includes("&")?s.replace("&",o):s.startsWith(":")?`${o}${s}`:`${o} ${s}`,c=$(t,u,e);return p.push(c),n}if(e!=null&&e.templates&&e.templates[s]){const c=t.split(".").reduce((i,f)=>i[f],e.templates[s]);if(c){const i=$(c,"");return`${n}${i}`}return console.warn(`Template "${s}" with path of "${t}" was not found in config!`),n}if(typeof t=="number")return y(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return n;const{modifiers:T}=e||{},k=function*(){yield E(t),yield q(t,T)}();for(const{result:u,additionalCss:c=[]}of k)t=u,c.forEach(i=>{const f=$(i,"");S(f,"")});return y(t)},"");return h?o?[`${o} { ${h} }`,...p].join(`
|
6
|
+
`):h:p.join(`
|
7
|
+
`)};exports.parseStyles=$;exports.parseValueTokens=E;
|
@@ -1,35 +1,37 @@
|
|
1
|
-
import { d as
|
1
|
+
import { d as E } from "./dash-case-DBThphLm.js";
|
2
2
|
const W = (r, o) => {
|
3
3
|
if (typeof r != "string") return { result: r };
|
4
4
|
if (!o) return { result: r };
|
5
5
|
const e = [];
|
6
6
|
return Object.values(o).forEach((p) => {
|
7
|
-
const { pattern: $, transform:
|
7
|
+
const { pattern: $, transform: l } = p;
|
8
8
|
r = r.replace($, (n) => {
|
9
|
-
const { value:
|
10
|
-
return t && e.push(t),
|
9
|
+
const { value: d, css: t } = l(n);
|
10
|
+
return t && e.push(t), d;
|
11
11
|
});
|
12
12
|
}), { result: r, additionalCss: e };
|
13
|
-
}, P = (r) => typeof r != "string" ? { result: r } : /\{[^{}]+\}/g.test(r) ? { result: r.replace(/\{([^{}]+)\}/g, (...p) => `var(--${
|
13
|
+
}, P = (r) => typeof r != "string" ? { result: r } : /\{[^{}]+\}/g.test(r) ? { result: r.replace(/\{([^{}]+)\}/g, (...p) => `var(--${E(p[1].replaceAll(".", "-"))})`) } : { result: r }, h = (r, o, e) => {
|
14
14
|
if (!r) return "";
|
15
|
-
const p = [], $ = Object.entries(r).reduce((n, [
|
16
|
-
const s =
|
15
|
+
const p = [], $ = Object.entries(r).reduce((n, [d, t]) => {
|
16
|
+
const s = d.trim(), O = s.startsWith("-") ? s : E(s), S = (u, c = ";") => n = `${n}${u}${c}`, m = (u) => S(`${O}:${u}`);
|
17
17
|
if (typeof t == "function" && (t = t()), typeof t == "object") {
|
18
18
|
if (!t) return n;
|
19
|
+
if (t.isColor)
|
20
|
+
return m(t.toString()), n;
|
19
21
|
if (s === "variants")
|
20
22
|
return Object.entries(t).forEach(([i, f]) => {
|
21
|
-
f && Object.entries(f).forEach(([
|
22
|
-
if (!
|
23
|
-
const
|
24
|
-
p.push(
|
23
|
+
f && Object.entries(f).forEach(([y, a]) => {
|
24
|
+
if (!a) return;
|
25
|
+
const b = `${o}.${i}-${y}`, j = h(a, b, e);
|
26
|
+
p.push(j);
|
25
27
|
});
|
26
28
|
}), n;
|
27
29
|
if (s === "defaultVariants")
|
28
30
|
return n;
|
29
31
|
if (s === "compoundVariants")
|
30
32
|
return t.forEach((i) => {
|
31
|
-
const { css: f, ...
|
32
|
-
p.push(
|
33
|
+
const { css: f, ...y } = i, a = Object.entries(y).reduce((j, [k, w]) => `${j}.${k}-${w}`, o), b = h(f, a, e);
|
34
|
+
p.push(b);
|
33
35
|
}), n;
|
34
36
|
if (s.startsWith("@")) {
|
35
37
|
const i = h(t, o, e), f = `${s} {
|
@@ -39,31 +41,30 @@ const W = (r, o) => {
|
|
39
41
|
}`;
|
40
42
|
return p.push(f), n;
|
41
43
|
}
|
42
|
-
const
|
43
|
-
return p.push(
|
44
|
+
const u = d.includes("&") ? s.replace("&", o) : s.startsWith(":") ? `${o}${s}` : `${o} ${s}`, c = h(t, u, e);
|
45
|
+
return p.push(c), n;
|
44
46
|
}
|
45
47
|
if (e != null && e.templates && e.templates[s]) {
|
46
|
-
const
|
47
|
-
if (
|
48
|
-
const i = h(
|
48
|
+
const c = t.split(".").reduce((i, f) => i[f], e.templates[s]);
|
49
|
+
if (c) {
|
50
|
+
const i = h(c, "");
|
49
51
|
return `${n}${i}`;
|
50
52
|
}
|
51
53
|
return console.warn(`Template "${s}" with path of "${t}" was not found in config!`), n;
|
52
54
|
}
|
53
|
-
|
54
|
-
if (typeof t == "number") return E(t);
|
55
|
+
if (typeof t == "number") return m(t);
|
55
56
|
if (typeof t != "string")
|
56
57
|
if ("toString" in t) t = t.toString();
|
57
58
|
else return n;
|
58
59
|
const { modifiers: V } = e || {}, T = function* () {
|
59
60
|
yield P(t), yield W(t, V);
|
60
61
|
}();
|
61
|
-
for (const { result:
|
62
|
-
t =
|
62
|
+
for (const { result: u, additionalCss: c = [] } of T)
|
63
|
+
t = u, c.forEach((i) => {
|
63
64
|
const f = h(i, "");
|
64
|
-
|
65
|
+
S(f, "");
|
65
66
|
});
|
66
|
-
return
|
67
|
+
return m(t);
|
67
68
|
}, "");
|
68
69
|
return $ ? o ? [`${o} { ${$} }`, ...p].join(`
|
69
70
|
`) : $ : p.join(`
|
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-BDBZd026.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-xtFx15Ka.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,7 +0,0 @@
|
|
1
|
-
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),q=(r,o)=>{if(typeof r!="string")return{result:r};if(!o)return{result:r};const e=[];return Object.values(o).forEach(p=>{const{pattern:h,transform:b}=p;r=r.replace(h,n=>{const{value:a,css:t}=b(n);return t&&e.push(t),a})}),{result:r,additionalCss:e}},E=r=>typeof r!="string"?{result:r}:/\{[^{}]+\}/g.test(r)?{result:r.replace(/\{([^{}]+)\}/g,(...p)=>`var(--${V.dashCase(p[1].replaceAll(".","-"))})`)}:{result:r},$=(r,o,e)=>{if(!r)return"";const p=[],h=Object.entries(r).reduce((n,[a,t])=>{const s=a.trim();if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return n;if(s==="variants")return Object.entries(t).forEach(([i,f])=>{f&&Object.entries(f).forEach(([y,d])=>{if(!d)return;const l=`${o}.${i}-${y}`,m=$(d,l,e);p.push(m)})}),n;if(s==="defaultVariants")return n;if(s==="compoundVariants")return t.forEach(i=>{const{css:f,...y}=i,d=Object.entries(y).reduce((m,[w,W])=>`${m}.${w}-${W}`,o),l=$(f,d,e);p.push(l)}),n;if(s.startsWith("@")){const i=$(t,o,e),f=`${s} {
|
2
|
-
${i.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return p.push(f),n}const u=a.includes("&")?s.replace("&",o):s.startsWith(":")?`${o}${s}`:`${o} ${s}`,c=$(t,u,e);return p.push(c),n}if(e!=null&&e.templates&&e.templates[s]){const c=t.split(".").reduce((i,f)=>i[f],e.templates[s]);if(c){const i=$(c,"");return`${n}${i}`}return console.warn(`Template "${s}" with path of "${t}" was not found in config!`),n}const O=s.startsWith("-")?s:V.dashCase(s),j=(u,c=";")=>n=`${n}${u}${c}`,S=u=>j(`${O}:${u}`);if(typeof t=="number")return S(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return n;const{modifiers:T}=e||{},k=function*(){yield E(t),yield q(t,T)}();for(const{result:u,additionalCss:c=[]}of k)t=u,c.forEach(i=>{const f=$(i,"");j(f,"")});return S(t)},"");return h?o?[`${o} { ${h} }`,...p].join(`
|
6
|
-
`):h:p.join(`
|
7
|
-
`)};exports.parseStyles=$;exports.parseValueTokens=E;
|