@salty-css/core 0.0.1-alpha.258 → 0.0.1-alpha.259
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 +11 -10
- 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-Cpvtq5h9.js +517 -0
- package/index-DV-sarjD.cjs +41 -0
- package/package.json +1 -1
- package/{parse-styles-DzvIRlln.js → parse-styles-CKmL8EwD.js} +43 -40
- package/parse-styles-DZYIEhB4.cjs +5 -0
- package/parsers/index.cjs +2 -1
- package/parsers/index.js +31 -10
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-DuV6TZaJ.cjs → should-restart-B6uSbFR6.cjs} +1 -1
- package/{should-restart-D12YL-ao.js → should-restart-M_v7QUN8.js} +1 -1
- package/index-C6aWAT5E.js +0 -534
- package/index-hRLfXvS_.cjs +0 -42
- package/parse-styles-BV4RZMzC.cjs +0 -5
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-DV-sarjD.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-B6uSbFR6.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,v)=>{se.exec(y,x=>{if(x)return v(x);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),v=oe(`Installing packages: ${C}`).start(),x=y.join(" ");await X(`npm install ${x}`),v.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},v=async(i,a)=>{const{default:g}=await C[i],d=ne.render(g,a);return{fileName:i,content:d}},x=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},H=i=>{const a=i==="."?"":i,g=process.cwd();return n.join(g,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:g=i,cssFile:d,skipInstall:p}=this.opts();if(!g)return e.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const c=process.cwd(),r=H(g),q=await Promise.all([v("salty.config.ts"),v("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),f=await s.readFile(h,"utf-8").catch(()=>{});if(f===void 0){e.logger.info("Creating file: "+h);const u=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,u),await S(h)}else{const t=JSON.parse(f),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==f&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,11 +3,11 @@ import { existsSync as Q, watch as rt } from "fs";
|
|
3
3
|
import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
|
4
4
|
import { join as a, relative as z, parse as ct, format as et } from "path";
|
5
5
|
import { render as lt } from "ejs";
|
6
|
-
import { l as e, a as h, g as K, i as dt, b as ft } from "../index-
|
6
|
+
import { l as e, a as h, g as K, i as dt, b as ft } from "../index-Cpvtq5h9.js";
|
7
7
|
import { p as pt } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as gt } from "child_process";
|
9
9
|
import ut from "ora";
|
10
|
-
import { c as yt } from "../should-restart-
|
10
|
+
import { c as yt } from "../should-restart-M_v7QUN8.js";
|
11
11
|
const st = (u) => new Promise((v, k) => {
|
12
12
|
gt(u, ($) => {
|
13
13
|
if ($) return k($);
|
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-DZYIEhB4.cjs");require("../parsers/index.cjs");const e=require("../index-DV-sarjD.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -4,17 +4,18 @@ import "../dash-case-DBThphLm.js";
|
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-styles-
|
8
|
-
import
|
7
|
+
import "../parse-styles-CKmL8EwD.js";
|
8
|
+
import "../parsers/index.js";
|
9
|
+
import { e as F, d as y, g as x, b as S, i as c, m as f, s as C, c as E } from "../index-Cpvtq5h9.js";
|
9
10
|
import "../css/merge.js";
|
10
11
|
import "../define-templates-4A2yHcMF.js";
|
11
12
|
export {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
F as compileSaltyFile,
|
14
|
+
y as generateConfigStyles,
|
15
|
+
x as generateCss,
|
16
|
+
S as generateFile,
|
17
|
+
c as isSaltyFile,
|
18
|
+
f as minimizeFile,
|
19
|
+
C as saltyFileExtensions,
|
20
|
+
E as saltyFileRegExp
|
20
21
|
};
|
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-DZYIEhB4.cjs"),w=require("../dash-case-BJEkFEGQ.cjs"),C=async({animationName:l,params:u,appendInitialStyles:y,...t})=>{const n=l||w.toHash(t),r=async(s={})=>{const{duration:e="500ms",easing:o="ease-in-out",delay:i="0s",iterationCount:S="1",direction:p="normal",fillMode:g="forwards",playState:b="running"}={...u,...s},a=`${n} ${e} ${o} ${i} ${S} ${p} ${g} ${b}`;if(!y)return a;const c=t.from||t["0%"];if(!c)return a;const j=await m.parseAndJoinStyles(c,"");return`${a};${j}`},$=Object.entries(t).map(async([s,e])=>{if(!e)return"";const o=await m.parseAndJoinStyles(e,"");return`${typeof s=="number"?`${s}%`:s}{${o}}`}),d=(await Promise.all($)).join(""),f=`@keyframes ${n} {${d}}`;return Object.assign(r,{toString:r,isKeyframes:!0,animationName:n,css:f,keyframes:t}),r};exports.keyframes=C;
|
package/css/keyframes.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { p as m } from "../parse-styles-
|
1
|
+
import { p as m } from "../parse-styles-CKmL8EwD.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 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-
|
1
|
+
"use strict";var C=Object.defineProperty;var N=(a,s,t)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var m=(a,s,t)=>N(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../parse-styles-DZYIEhB4.cjs"),n=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(s){m(this,"buildContext",{});this.params=s}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){const{base:s,variants:t,compoundVariants:e}=this.params;return n.toHash({base:s,variants:t,compoundVariants:e})}get cssClassName(){return this.hash}get classNames(){const s=new Set([this.cssClassName]),{className:t}=this.params;return typeof t=="string"&&s.add(t),typeof t=="object"&&t.forEach(e=>s.add(e)),this.getTemplateClasses().forEach(e=>s.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>s.add(e)),[...s].join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${n.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,o={...s,variants:t,compoundVariants:e};return S.parseAndJoinStyles(o,`.${this.cssClassName}`,i,this.isRoot)}getTemplateClasses(s=this.buildContext.config){if(!(s!=null&&s.templates)||!this.params.base||this.priority>0)return[];const t=Object.keys(s.templates);return Object.entries(this.params.base).reduce((e,[i,o])=>(t.includes(i)&&e.push("t_"+n.toHash(n.dashCase(`${i}-${o}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}class v extends y{constructor(s){super(s),this._params=s}}class x extends y{constructor(s,t){super(t),this.tagName=s,this._params=t}get priority(){var s;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((s=this.tagName.generator)==null?void 0:s.priority)||0)+1:0}get clientProps(){const{element:s,variants:t={},compoundVariants:e=[],defaultVariants:i={},defaultProps:o={},passProps:d}=this.params,{callerName:f,isProduction:b}=this.buildContext,h=new Set([]),l=r=>{const c=i[r];c!==void 0?h.add(`${r}=${String(c)}`):h.add(r)};Object.keys(t).forEach(l),e.map(r=>Object.keys(r).forEach(l));const p=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);r&&r.forEach(c=>{const u=c.replace(/\{(?:-)?props\.([^}]+)\}/gi,"$1"),g=n.dashCase(u);u&&p.add(g)})}return{element:s,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:o,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=v;exports.StyledGenerator=x;
|
package/generators/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
var C = Object.defineProperty;
|
2
2
|
var x = (a, t, s) => t in a ? C(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
|
3
3
|
var u = (a, t, s) => x(a, typeof t != "symbol" ? t + "" : t, s);
|
4
|
-
import { p as v } from "../parse-styles-
|
4
|
+
import { p as v } from "../parse-styles-CKmL8EwD.js";
|
5
5
|
import { t as f, d as h } from "../dash-case-DBThphLm.js";
|
6
6
|
class y {
|
7
7
|
constructor(t) {
|
@@ -0,0 +1,517 @@
|
|
1
|
+
import * as St from "esbuild";
|
2
|
+
import { execSync as Tt } from "child_process";
|
3
|
+
import { t as I, d as A } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as i, parse as tt } from "path";
|
5
|
+
import { existsSync as ft, mkdirSync as G, statSync as _t, readdirSync as Vt, readFileSync as T, writeFileSync as F } from "fs";
|
6
|
+
import { readFile as Ct } from "fs/promises";
|
7
|
+
import { p as $t, a as Et } from "./parse-styles-CKmL8EwD.js";
|
8
|
+
import { parseTemplates as Ot, getTemplateTypes as Mt } from "./parsers/index.js";
|
9
|
+
import { createLogger as Rt, transports as Jt, format as rt } from "winston";
|
10
|
+
import { mergeObjects as H, mergeFactories as zt } from "./css/merge.js";
|
11
|
+
import { d as Wt } from "./define-templates-4A2yHcMF.js";
|
12
|
+
import lt from "typescript";
|
13
|
+
const Ft = (t) => {
|
14
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
15
|
+
const e = i(t, "package.json");
|
16
|
+
return ft(e) ? e : Ft(i(t, ".."));
|
17
|
+
}, Gt = async (t) => {
|
18
|
+
const e = Ft(t);
|
19
|
+
return await Ct(e, "utf-8").then(JSON.parse).catch(() => {
|
20
|
+
});
|
21
|
+
}, Ht = async (t) => {
|
22
|
+
const e = await Gt(t);
|
23
|
+
if (e)
|
24
|
+
return e.type;
|
25
|
+
};
|
26
|
+
let W;
|
27
|
+
const Pt = async (t) => {
|
28
|
+
if (W) return W;
|
29
|
+
const e = await Ht(t);
|
30
|
+
return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
|
31
|
+
}, Z = Rt({
|
32
|
+
level: "debug",
|
33
|
+
format: rt.combine(rt.colorize(), rt.cli()),
|
34
|
+
transports: [new Jt.Console({})]
|
35
|
+
}), ce = (t) => {
|
36
|
+
Z.error(t);
|
37
|
+
};
|
38
|
+
function jt(t) {
|
39
|
+
return t ? typeof t != "string" ? jt(String(t)) : t.replace(/[^\d\w]/g, ".") : "";
|
40
|
+
}
|
41
|
+
const It = {
|
42
|
+
/** Set box model to border-box */
|
43
|
+
"*, *::before, *::after": {
|
44
|
+
boxSizing: "border-box"
|
45
|
+
},
|
46
|
+
/** Remove default margin and padding */
|
47
|
+
"*": {
|
48
|
+
margin: 0
|
49
|
+
},
|
50
|
+
/** Remove adjust font properties */
|
51
|
+
html: {
|
52
|
+
lineHeight: 1.15,
|
53
|
+
textSizeAdjust: "100%",
|
54
|
+
WebkitFontSmoothing: "antialiased"
|
55
|
+
},
|
56
|
+
/** Make media elements responsive */
|
57
|
+
"img, picture, video, canvas, svg": {
|
58
|
+
display: "block",
|
59
|
+
maxWidth: "100%"
|
60
|
+
},
|
61
|
+
/** Avoid overflow of text */
|
62
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
63
|
+
overflowWrap: "break-word"
|
64
|
+
},
|
65
|
+
/** Improve text wrapping */
|
66
|
+
p: {
|
67
|
+
textWrap: "pretty"
|
68
|
+
},
|
69
|
+
"h1, h2, h3, h4, h5, h6": {
|
70
|
+
textWrap: "balance"
|
71
|
+
},
|
72
|
+
/** Improve link color */
|
73
|
+
a: {
|
74
|
+
color: "currentColor"
|
75
|
+
},
|
76
|
+
/** Improve button line height */
|
77
|
+
button: {
|
78
|
+
lineHeight: "1em",
|
79
|
+
color: "currentColor"
|
80
|
+
},
|
81
|
+
/** Improve form elements */
|
82
|
+
"input, optgroup, select, textarea": {
|
83
|
+
fontFamily: "inherit",
|
84
|
+
fontSize: "100%",
|
85
|
+
lineHeight: "1.15em"
|
86
|
+
}
|
87
|
+
}, Kt = (t, e) => new Promise((s, n) => {
|
88
|
+
const c = setTimeout(() => {
|
89
|
+
n(new Error("Timeout"));
|
90
|
+
}, 100), r = lt.createSourceFile("temp.ts", t, lt.ScriptTarget.Latest, !0);
|
91
|
+
function o(d) {
|
92
|
+
if (lt.isVariableDeclaration(d) && d.name.getText() === e) {
|
93
|
+
const w = d.getStart(), p = d.getEnd();
|
94
|
+
clearTimeout(c), s([w, p]);
|
95
|
+
}
|
96
|
+
d.forEachChild(o);
|
97
|
+
}
|
98
|
+
o(r);
|
99
|
+
}), V = {
|
100
|
+
externalModules: [],
|
101
|
+
rcFile: void 0,
|
102
|
+
destDir: void 0
|
103
|
+
}, Nt = (t) => {
|
104
|
+
if (V.externalModules.length > 0) return V.externalModules;
|
105
|
+
const s = T(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
106
|
+
if (!s) return [];
|
107
|
+
const n = s[1].split(",").map((c) => c.replace(/['"`]/g, "").trim());
|
108
|
+
return V.externalModules = n, n;
|
109
|
+
}, J = async (t) => {
|
110
|
+
if (V.destDir) return V.destDir;
|
111
|
+
const e = await pt(t), s = i(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
112
|
+
return V.destDir = s, s;
|
113
|
+
}, xt = ["salty", "css", "styles", "styled"], Qt = (t = []) => new RegExp(`\\.(${[...xt, ...t].join("|")})\\.`), mt = (t, e = []) => Qt(e).test(t), Dt = async (t) => {
|
114
|
+
if (V.rcFile) return V.rcFile;
|
115
|
+
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
116
|
+
const e = i(t, ".saltyrc.json"), s = await Ct(e, "utf-8").then(JSON.parse).catch(() => {
|
117
|
+
});
|
118
|
+
return s ? (V.rcFile = s, s) : Dt(i(t, ".."));
|
119
|
+
}, pt = async (t) => {
|
120
|
+
var n, c;
|
121
|
+
const e = await Dt(t), s = (n = e.projects) == null ? void 0 : n.find((r) => t.endsWith(r.dir || ""));
|
122
|
+
return s || ((c = e.projects) == null ? void 0 : c.find((r) => r.dir === e.defaultProject));
|
123
|
+
}, Bt = async (t) => {
|
124
|
+
const e = await pt(t), s = await J(t), n = i(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), c = i(s, "salty.config.js"), r = await Pt(t), o = Nt(n);
|
125
|
+
await St.build({
|
126
|
+
entryPoints: [n],
|
127
|
+
minify: !0,
|
128
|
+
treeShaking: !0,
|
129
|
+
bundle: !0,
|
130
|
+
outfile: c,
|
131
|
+
format: r,
|
132
|
+
external: o
|
133
|
+
});
|
134
|
+
const d = Date.now(), { config: w } = await import(`${c}?t=${d}`);
|
135
|
+
return { config: w, path: c };
|
136
|
+
}, Lt = async (t, e) => {
|
137
|
+
var gt, ht;
|
138
|
+
const s = await J(t), n = {
|
139
|
+
mediaQueries: [],
|
140
|
+
globalStyles: [],
|
141
|
+
variables: [],
|
142
|
+
templates: []
|
143
|
+
};
|
144
|
+
await Promise.all(
|
145
|
+
[...e].map(async (h) => {
|
146
|
+
const { contents: S, outputFilePath: L } = await et(t, h, s);
|
147
|
+
Object.entries(S).forEach(([k, j]) => {
|
148
|
+
j.isMedia ? n.mediaQueries.push([k, j]) : j.isGlobalDefine ? n.globalStyles.push(j) : j.isDefineVariables ? n.variables.push(j) : j.isDefineTemplates && n.templates.push(j._setPath(`${k};;${L}`));
|
149
|
+
});
|
150
|
+
})
|
151
|
+
);
|
152
|
+
const { config: c, path: r } = await Bt(t), o = { ...c }, { mediaQueries: d } = n;
|
153
|
+
o.mediaQueries = Object.fromEntries(d.map(([h, S]) => [`@${h}`, S]));
|
154
|
+
const w = d.map(([h]) => `'@${h}'`).join(" | "), p = /* @__PURE__ */ new Set(), a = async (h, S = []) => {
|
155
|
+
if (!h) return [];
|
156
|
+
const L = Object.entries(h).map(async ([j, R]) => {
|
157
|
+
const q = async (v) => {
|
158
|
+
if (!v) return;
|
159
|
+
if (v instanceof Promise) return await q(await v);
|
160
|
+
if (typeof v == "function") return await q(await v());
|
161
|
+
if (typeof v == "object") return await a(v, [...S, j]);
|
162
|
+
const at = jt(j), it = A(j), ct = [...S, at].join(".");
|
163
|
+
p.add(`"${ct}"`);
|
164
|
+
const Y = [...S.map(A), it].join("-"), wt = Et(v);
|
165
|
+
return wt ? `--${Y}: ${wt.transformed};` : `--${Y}: ${v};`;
|
166
|
+
};
|
167
|
+
return await q(R);
|
168
|
+
});
|
169
|
+
return (await Promise.all(L)).flat();
|
170
|
+
}, y = async (h) => {
|
171
|
+
if (!h) return [];
|
172
|
+
const S = Object.entries(h).map(async ([k, j]) => {
|
173
|
+
const R = await a(j);
|
174
|
+
return k === "base" ? R.join("") : o.mediaQueries[k] ? `${o.mediaQueries[k]} { ${R.join("")} }` : `${k} { ${R.join("")} }`;
|
175
|
+
});
|
176
|
+
return (await Promise.all(S)).flat();
|
177
|
+
}, u = async (h) => {
|
178
|
+
if (!h) return [];
|
179
|
+
const S = Object.entries(h).map(async ([k, j]) => {
|
180
|
+
const R = Object.entries(j).map(async ([v, at]) => {
|
181
|
+
const it = await a(at, [k]), ct = `.${k}-${v}, [data-${k}="${v}"]`, Y = it.join("");
|
182
|
+
return `${ct} { ${Y} }`;
|
183
|
+
});
|
184
|
+
return (await Promise.all(R)).flat();
|
185
|
+
});
|
186
|
+
return (await Promise.all(S)).flat();
|
187
|
+
}, g = (h) => ({ ...h, responsive: void 0, conditional: void 0 }), m = (h) => n.variables.map((S) => h === "static" ? g(S._current) : S._current[h]), C = H(g(c.variables), m("static")), x = await a(C), D = H((gt = c.variables) == null ? void 0 : gt.responsive, m("responsive")), E = await y(D), z = H((ht = c.variables) == null ? void 0 : ht.conditional, m("conditional")), U = await u(z), yt = i(s, "css/_variables.css"), O = `:root { ${x.join("")} ${E.join("")} } ${U.join("")}`;
|
188
|
+
F(yt, O), o.staticVariables = C;
|
189
|
+
const st = i(s, "css/_global.css"), f = H(c.global, n.globalStyles), $ = await $t(f, "");
|
190
|
+
F(st, `@layer global { ${$} }`);
|
191
|
+
const b = i(s, "css/_reset.css"), P = c.reset === "none" ? {} : typeof c.reset == "object" ? c.reset : It, N = await $t(P, "");
|
192
|
+
F(b, `@layer reset { ${N} }`);
|
193
|
+
const _ = i(s, "css/_templates.css"), M = H(c.templates, n.templates), K = await Ot(M), Q = Mt(M);
|
194
|
+
F(_, `@layer templates { ${K} }`), o.templates = M;
|
195
|
+
const X = c.templates ? [Wt(c.templates)._setPath(`config;;${r}`)] : [], nt = zt(n.templates, X);
|
196
|
+
o.templatePaths = Object.fromEntries(Object.entries(nt).map(([h, S]) => [h, S._path]));
|
197
|
+
const B = i(s, "types/css-tokens.d.ts"), kt = `
|
198
|
+
// Variable types
|
199
|
+
type VariableTokens = ${[...p].join("|")};
|
200
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
201
|
+
|
202
|
+
// Template types
|
203
|
+
type TemplateTokens = {
|
204
|
+
${Object.entries(Q).map(([h, S]) => `${h}?: ${S}`).join(`
|
205
|
+
`)}
|
206
|
+
}
|
207
|
+
|
208
|
+
// Media query types
|
209
|
+
type MediaQueryKeys = ${w || "''"};
|
210
|
+
`;
|
211
|
+
F(B, kt);
|
212
|
+
const vt = i(s, "cache/config-cache.json");
|
213
|
+
F(vt, JSON.stringify(o, null, 2));
|
214
|
+
}, bt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
215
|
+
if (/^['"`]/.test(s)) return e;
|
216
|
+
const c = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
217
|
+
if (!c.test(t)) return e;
|
218
|
+
const o = c.exec(t);
|
219
|
+
if (o) {
|
220
|
+
const d = o.at(1);
|
221
|
+
if (xt.some((p) => d == null ? void 0 : d.includes(p))) return e;
|
222
|
+
}
|
223
|
+
return "styled('div',";
|
224
|
+
}), qt = (t, e) => {
|
225
|
+
try {
|
226
|
+
const s = T(i(e, "saltygen/cache/config-cache.json"), "utf8");
|
227
|
+
return s ? `globalThis.saltyConfig = ${s};
|
228
|
+
|
229
|
+
${t}` : `globalThis.saltyConfig = {};
|
230
|
+
|
231
|
+
${t}`;
|
232
|
+
} catch {
|
233
|
+
return t;
|
234
|
+
}
|
235
|
+
}, et = async (t, e, s) => {
|
236
|
+
const n = I(e), c = i(s, "./temp");
|
237
|
+
ft(c) || G(c);
|
238
|
+
const r = tt(e);
|
239
|
+
let o = T(e, "utf8");
|
240
|
+
o = bt(o), o = qt(o, t);
|
241
|
+
const d = i(s, "js", n + ".js"), w = await pt(t), p = i(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), a = Nt(p), y = await Pt(t);
|
242
|
+
await St.build({
|
243
|
+
stdin: {
|
244
|
+
contents: o,
|
245
|
+
sourcefile: r.base,
|
246
|
+
resolveDir: r.dir,
|
247
|
+
loader: "tsx"
|
248
|
+
},
|
249
|
+
minify: !1,
|
250
|
+
treeShaking: !0,
|
251
|
+
bundle: !0,
|
252
|
+
outfile: d,
|
253
|
+
format: y,
|
254
|
+
target: ["node20"],
|
255
|
+
keepNames: !0,
|
256
|
+
external: a,
|
257
|
+
packages: "external",
|
258
|
+
plugins: [
|
259
|
+
{
|
260
|
+
name: "test",
|
261
|
+
setup: (m) => {
|
262
|
+
m.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (C) => {
|
263
|
+
const x = T(C.path, "utf8");
|
264
|
+
return { contents: bt(x), loader: "ts" };
|
265
|
+
});
|
266
|
+
}
|
267
|
+
}
|
268
|
+
]
|
269
|
+
});
|
270
|
+
const u = Date.now();
|
271
|
+
return { contents: await import(`${d}?t=${u}`), outputFilePath: d };
|
272
|
+
}, At = async (t) => {
|
273
|
+
const e = await J(t), s = i(e, "cache/config-cache.json"), n = T(s, "utf8");
|
274
|
+
if (!n) throw new Error("Could not find config cache file");
|
275
|
+
return JSON.parse(n);
|
276
|
+
}, ut = async (t) => {
|
277
|
+
const e = await At(t), s = await J(t), n = i(s, "salty.config.js"), c = Date.now(), { config: r } = await import(`${n}?t=${c}`);
|
278
|
+
return H(r, e);
|
279
|
+
}, dt = () => {
|
280
|
+
try {
|
281
|
+
return process.env.NODE_ENV === "production";
|
282
|
+
} catch {
|
283
|
+
return !1;
|
284
|
+
}
|
285
|
+
}, re = async (t, e = dt(), s = !0) => {
|
286
|
+
try {
|
287
|
+
const n = Date.now();
|
288
|
+
e ? Z.info("Generating CSS in production mode! 🔥") : Z.info("Generating CSS in development mode! 🚀");
|
289
|
+
const c = [], r = [], o = await J(t), d = i(o, "index.css");
|
290
|
+
s && (() => {
|
291
|
+
ft(o) && Tt("rm -rf " + o), G(o, { recursive: !0 }), G(i(o, "css")), G(i(o, "types")), G(i(o, "js")), G(i(o, "cache"));
|
292
|
+
})();
|
293
|
+
const p = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
294
|
+
async function y(f) {
|
295
|
+
const $ = ["node_modules", "saltygen"], b = _t(f);
|
296
|
+
if (b.isDirectory()) {
|
297
|
+
const l = Vt(f);
|
298
|
+
if ($.some((N) => f.includes(N))) return;
|
299
|
+
await Promise.all(l.map((N) => y(i(f, N))));
|
300
|
+
} else if (b.isFile() && mt(f)) {
|
301
|
+
p.add(f);
|
302
|
+
const P = T(f, "utf8");
|
303
|
+
/define[\w\d]+\(/.test(P) && a.add(f);
|
304
|
+
}
|
305
|
+
}
|
306
|
+
await y(t), await Lt(t, a);
|
307
|
+
const u = {
|
308
|
+
keyframes: [],
|
309
|
+
components: [],
|
310
|
+
classNames: []
|
311
|
+
};
|
312
|
+
await Promise.all(
|
313
|
+
[...p].map(async (f) => {
|
314
|
+
const { contents: $ } = await et(t, f, o);
|
315
|
+
for (let [b, l] of Object.entries($))
|
316
|
+
l instanceof Promise && (l = await l), l.isKeyframes ? u.keyframes.push({
|
317
|
+
value: l,
|
318
|
+
src: f,
|
319
|
+
name: b
|
320
|
+
}) : l.isClassName ? u.classNames.push({
|
321
|
+
...l,
|
322
|
+
src: f,
|
323
|
+
name: b
|
324
|
+
}) : l.generator && u.components.push({
|
325
|
+
...l,
|
326
|
+
src: f,
|
327
|
+
name: b
|
328
|
+
});
|
329
|
+
})
|
330
|
+
);
|
331
|
+
const g = await ut(t);
|
332
|
+
for (const f of u.keyframes) {
|
333
|
+
const { value: $ } = f, b = `a_${$.animationName}.css`, l = `css/${b}`, P = i(o, l);
|
334
|
+
c.push(b), F(P, $.css);
|
335
|
+
}
|
336
|
+
const m = {};
|
337
|
+
for (const f of u.components) {
|
338
|
+
const { src: $, name: b } = f;
|
339
|
+
m[$] || (m[$] = []);
|
340
|
+
const l = f.generator._withBuildContext({
|
341
|
+
callerName: b,
|
342
|
+
isProduction: e,
|
343
|
+
config: g
|
344
|
+
});
|
345
|
+
r[l.priority] || (r[l.priority] = []);
|
346
|
+
const P = await l.css;
|
347
|
+
if (!P) continue;
|
348
|
+
r[l.priority].push(l.cssFileName);
|
349
|
+
const N = `css/${l.cssFileName}`, _ = i(o, N);
|
350
|
+
F(_, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
351
|
+
}
|
352
|
+
for (const f of u.classNames) {
|
353
|
+
const { src: $, name: b } = f;
|
354
|
+
m[$] || (m[$] = []);
|
355
|
+
const l = f.generator._withBuildContext({
|
356
|
+
callerName: b,
|
357
|
+
isProduction: e,
|
358
|
+
config: g
|
359
|
+
}), P = await l.css;
|
360
|
+
if (!P) continue;
|
361
|
+
r[l.priority] || (r[l.priority] = []), r[l.priority].push(l.cssFileName);
|
362
|
+
const N = `css/${l.cssFileName}`, _ = i(o, N);
|
363
|
+
F(_, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
364
|
+
}
|
365
|
+
g.importStrategy === "component" && Object.entries(m).forEach(([f, $]) => {
|
366
|
+
const b = $.map((M) => `@import url('./${M}');`).join(`
|
367
|
+
`), l = I(f, 6), P = tt(f), N = A(P.name), _ = i(o, `css/f_${N}-${l}.css`);
|
368
|
+
F(_, b || "/* Empty file */");
|
369
|
+
});
|
370
|
+
const C = c.map((f) => `@import url('./css/${f}');`).join(`
|
371
|
+
`);
|
372
|
+
let U = `/*!
|
373
|
+
* Generated with Salty CSS (https://salty-css.dev)
|
374
|
+
* Do not edit this file directly
|
375
|
+
*/
|
376
|
+
@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
377
|
+
|
378
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
|
379
|
+
try {
|
380
|
+
return T(i(o, "css", f), "utf8").length > 0;
|
381
|
+
} catch {
|
382
|
+
return !1;
|
383
|
+
}
|
384
|
+
}).map((f) => `@import url('./css/${f}');`).join(
|
385
|
+
`
|
386
|
+
`
|
387
|
+
)}
|
388
|
+
${C}`;
|
389
|
+
if (g.importStrategy !== "component") {
|
390
|
+
const f = r.reduce(($, b, l) => {
|
391
|
+
const P = b.reduce((K, Q) => {
|
392
|
+
var ot;
|
393
|
+
const X = i(o, "css", Q), nt = T(X, "utf8"), B = ((ot = /.*-([^-]+)-\d+.css/.exec(Q)) == null ? void 0 : ot.at(1)) || I(X, 6);
|
394
|
+
return K.includes(B) ? K : `${K}
|
395
|
+
/*start:${B}-${Q}*/
|
396
|
+
${nt}
|
397
|
+
/*end:${B}*/
|
398
|
+
`;
|
399
|
+
}, ""), N = `l_${l}.css`, _ = i(o, "css", N), M = `@layer l${l} { ${P}
|
400
|
+
}`;
|
401
|
+
return F(_, M), `${$}
|
402
|
+
@import url('./css/${N}');`;
|
403
|
+
}, "");
|
404
|
+
U += f;
|
405
|
+
}
|
406
|
+
F(d, U);
|
407
|
+
const O = Date.now() - n, st = O < 200 ? "🔥" : O < 500 ? "🚀" : O < 1e3 ? "🎉" : O < 2e3 ? "🚗" : O < 5e3 ? "🤔" : "🥴";
|
408
|
+
Z.info(`Generated CSS in ${O}ms! ${st}`);
|
409
|
+
} catch (n) {
|
410
|
+
console.error(n);
|
411
|
+
}
|
412
|
+
}, le = async (t, e, s = dt()) => {
|
413
|
+
try {
|
414
|
+
const n = await J(t);
|
415
|
+
if (mt(e)) {
|
416
|
+
const r = [], o = await ut(t), { contents: d } = await et(t, e, n);
|
417
|
+
for (const [w, p] of Object.entries(d)) {
|
418
|
+
if (p.isKeyframes && p.css) {
|
419
|
+
const C = `css/${`a_${p.animationName}.css`}`, x = i(n, C);
|
420
|
+
F(x, await p.css);
|
421
|
+
continue;
|
422
|
+
}
|
423
|
+
if (p.isClassName) {
|
424
|
+
const m = p.generator._withBuildContext({
|
425
|
+
callerName: w,
|
426
|
+
isProduction: s,
|
427
|
+
config: o
|
428
|
+
}), C = await m.css;
|
429
|
+
if (!C) continue;
|
430
|
+
r[m.priority] || (r[m.priority] = []), r[m.priority].push(m.cssFileName);
|
431
|
+
const x = `css/${m.cssFileName}`, D = i(n, x);
|
432
|
+
F(D, C);
|
433
|
+
continue;
|
434
|
+
}
|
435
|
+
if (!p.generator) continue;
|
436
|
+
const a = p.generator._withBuildContext({
|
437
|
+
callerName: w,
|
438
|
+
isProduction: s,
|
439
|
+
config: o
|
440
|
+
}), y = await a.css;
|
441
|
+
if (!y) continue;
|
442
|
+
const u = `css/${a.cssFileName}`, g = i(n, u);
|
443
|
+
F(g, y), r[a.priority] || (r[a.priority] = []), r[a.priority].push(a.cssFileName);
|
444
|
+
}
|
445
|
+
if (o.importStrategy !== "component")
|
446
|
+
r.forEach((w, p) => {
|
447
|
+
const a = `l_${p}.css`, y = i(n, "css", a);
|
448
|
+
let u = T(y, "utf8");
|
449
|
+
w.forEach((g) => {
|
450
|
+
var D;
|
451
|
+
const m = i(n, "css", g), C = ((D = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : D.at(1)) || I(m, 6);
|
452
|
+
if (!u.includes(C)) {
|
453
|
+
const E = T(m, "utf8"), z = `/*start:${C}-${g}*/
|
454
|
+
${E}
|
455
|
+
/*end:${C}*/
|
456
|
+
`;
|
457
|
+
u = `${u.replace(/\}$/, "")}
|
458
|
+
${z}
|
459
|
+
}`;
|
460
|
+
}
|
461
|
+
}), F(y, u);
|
462
|
+
});
|
463
|
+
else {
|
464
|
+
const w = r.flat().map((g) => `@import url('./${g}');`).join(`
|
465
|
+
`), p = I(e, 6), a = tt(e), y = A(a.name), u = i(n, `css/f_${y}-${p}.css`);
|
466
|
+
F(u, w || "/* Empty file */");
|
467
|
+
}
|
468
|
+
}
|
469
|
+
} catch (n) {
|
470
|
+
console.error(n);
|
471
|
+
}
|
472
|
+
}, fe = async (t, e, s = dt()) => {
|
473
|
+
var n, c;
|
474
|
+
try {
|
475
|
+
const r = await J(t);
|
476
|
+
if (mt(e)) {
|
477
|
+
const d = T(e, "utf8"), w = await ut(t), { contents: p } = await et(t, e, r);
|
478
|
+
let a = d;
|
479
|
+
for (const [y, u] of Object.entries(p)) {
|
480
|
+
if (u.isKeyframes || !u.generator) continue;
|
481
|
+
const g = u.generator._withBuildContext({
|
482
|
+
callerName: y,
|
483
|
+
isProduction: s,
|
484
|
+
config: w
|
485
|
+
}), [m, C] = await Kt(a, y), x = a.slice(m, C);
|
486
|
+
if (u.isClassName) {
|
487
|
+
const D = a, E = ` ${y} = className("${g.classNames}")`;
|
488
|
+
a = a.replace(x, E), D === a && console.error("Minimize file failed to change content", { name: y });
|
489
|
+
}
|
490
|
+
if (x.includes("styled")) {
|
491
|
+
const D = (c = (n = /styled\(([^,]+),/.exec(x)) == null ? void 0 : n.at(1)) == null ? void 0 : c.trim(), E = a, z = ` ${y} = styled(${D}, "${g.classNames}", ${JSON.stringify(g.clientProps)})`;
|
492
|
+
a = a.replace(x, z), E === a && console.error("Minimize file failed to change content", { name: y, tagName: D });
|
493
|
+
}
|
494
|
+
}
|
495
|
+
if (w.importStrategy === "component") {
|
496
|
+
const y = I(e, 6), u = tt(e);
|
497
|
+
a = `import '../../saltygen/css/${`f_${A(u.name)}-${y}.css`}';
|
498
|
+
${a}`;
|
499
|
+
}
|
500
|
+
return a = a.replace("@salty-css/react/class-name", "@salty-css/react/class-name-client"), a = a.replace("{ styled }", "{ styledClient as styled }"), a = a.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), a;
|
501
|
+
}
|
502
|
+
} catch (r) {
|
503
|
+
console.error("Error in minimizeFile:", r);
|
504
|
+
}
|
505
|
+
};
|
506
|
+
export {
|
507
|
+
ce as a,
|
508
|
+
le as b,
|
509
|
+
Qt as c,
|
510
|
+
Lt as d,
|
511
|
+
et as e,
|
512
|
+
re as g,
|
513
|
+
mt as i,
|
514
|
+
Z as l,
|
515
|
+
fe as m,
|
516
|
+
xt as s
|
517
|
+
};
|