@salty-css/core 0.0.1-alpha.187 → 0.0.1-alpha.188
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 +1 -1
- package/config/index.cjs +1 -1
- package/config/index.js +7 -10
- package/factories/define-variables.d.ts +9 -12
- package/factories/index.cjs +1 -1
- package/factories/index.js +11 -14
- package/index-C-3Ey2EZ.js +433 -0
- package/index-D8nwtA-j.cjs +30 -0
- package/package.json +1 -1
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/types/config-types.d.ts +12 -13
- package/index-BmsXxgnE.cjs +0 -30
- package/index-DKkgPK-r.js +0 -433
package/bin/main.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-D8nwtA-j.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
|
|
3
3
|
import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
|
4
4
|
import { join as i, relative as z, parse as re, format as ee } from "path";
|
5
5
|
import { render as ce } from "ejs";
|
6
|
-
import { l as t, a as h, g as te } from "../index-
|
6
|
+
import { l as t, a as h, g as te } from "../index-C-3Ey2EZ.js";
|
7
7
|
import { p as le } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as de } from "child_process";
|
9
9
|
import fe from "ora";
|
package/compiler/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-3zK35muR.cjs");require("../parse-templates-VIvmVb52.cjs");const e=require("../index-
|
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-3zK35muR.cjs");require("../parse-templates-VIvmVb52.cjs");const e=require("../index-D8nwtA-j.cjs");require("../merge-DxGoJDHv.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
@@ -6,7 +6,7 @@ import "fs";
|
|
6
6
|
import "fs/promises";
|
7
7
|
import "../parse-styles-DrLhKtqW.js";
|
8
8
|
import "../parse-templates-DRKlN-pP.js";
|
9
|
-
import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-
|
9
|
+
import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-C-3Ey2EZ.js";
|
10
10
|
import "../merge-BVm9us1A.js";
|
11
11
|
export {
|
12
12
|
g as compileSaltyFile,
|
package/config/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../factories/index.cjs"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../factories/index.cjs"),t=a=>a;exports.GlobalStylesFactory=e.GlobalStylesFactory;exports.TemplatesFactory=e.TemplatesFactory;exports.VariablesFactory=e.VariablesFactory;exports.defineGlobalStyles=e.defineGlobalStyles;exports.defineTemplates=e.defineTemplates;exports.defineVariables=e.defineVariables;exports.defineConfig=t;
|
package/config/index.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
import { GlobalStylesFactory as
|
1
|
+
import { GlobalStylesFactory as o, TemplatesFactory as r, VariablesFactory as i, defineGlobalStyles as n, defineTemplates as s, defineVariables as f } from "../factories/index.js";
|
2
2
|
const a = (e) => e;
|
3
3
|
export {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
r as defineConditionalVariables,
|
4
|
+
o as GlobalStylesFactory,
|
5
|
+
r as TemplatesFactory,
|
6
|
+
i as VariablesFactory,
|
8
7
|
a as defineConfig,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
b as defineTemplates,
|
13
|
-
c as defineVariables
|
8
|
+
n as defineGlobalStyles,
|
9
|
+
s as defineTemplates,
|
10
|
+
f as defineVariables
|
14
11
|
};
|
@@ -1,15 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
export interface VariablesFactoryParams {
|
3
|
-
variables?: CssVariables;
|
4
|
-
responsiveVariables?: CssResponsiveVariables;
|
5
|
-
conditionalVariables?: CssConditionalVariables;
|
6
|
-
}
|
1
|
+
import { SaltyVariables } from '../types/config-types';
|
7
2
|
export declare class VariablesFactory {
|
8
|
-
_current:
|
9
|
-
constructor(_current:
|
3
|
+
_current: SaltyVariables;
|
4
|
+
constructor(_current: SaltyVariables);
|
10
5
|
get isDefineVariables(): boolean;
|
11
6
|
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
/**
|
8
|
+
* Base level variables that can be used in all styles as they are applied globally to :root.
|
9
|
+
@param responsive Variables that are defined for different media queries.
|
10
|
+
@param conditional Variables that are defined for different parent selectors (classes or data attributes).
|
11
|
+
*/
|
12
|
+
export declare const defineVariables: (variables: SaltyVariables) => VariablesFactory;
|
package/factories/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(t){this._current=t}get isGlobalDefine(){return!0}}const l=e=>new r(e);class s{constructor(t){this._current=t}get isDefineVariables(){return!0}}const n=e=>new s(e);class a{constructor(t){this._current=t}get isDefineTemplates(){return!0}}const o=e=>new a(e);exports.GlobalStylesFactory=r;exports.TemplatesFactory=a;exports.VariablesFactory=s;exports.defineGlobalStyles=l;exports.defineTemplates=o;exports.defineVariables=n;
|
package/factories/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class r {
|
2
2
|
constructor(t) {
|
3
3
|
this._current = t;
|
4
4
|
}
|
@@ -6,8 +6,8 @@ class n {
|
|
6
6
|
return !0;
|
7
7
|
}
|
8
8
|
}
|
9
|
-
const a = (e) => new
|
10
|
-
class
|
9
|
+
const a = (e) => new r(e);
|
10
|
+
class s {
|
11
11
|
constructor(t) {
|
12
12
|
this._current = t;
|
13
13
|
}
|
@@ -15,8 +15,8 @@ class r {
|
|
15
15
|
return !0;
|
16
16
|
}
|
17
17
|
}
|
18
|
-
const
|
19
|
-
class
|
18
|
+
const c = (e) => new s(e);
|
19
|
+
class n {
|
20
20
|
constructor(t) {
|
21
21
|
this._current = t;
|
22
22
|
}
|
@@ -24,15 +24,12 @@ class s {
|
|
24
24
|
return !0;
|
25
25
|
}
|
26
26
|
}
|
27
|
-
const
|
27
|
+
const l = (e) => new n(e);
|
28
28
|
export {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
l as defineConditionalVariables,
|
29
|
+
r as GlobalStylesFactory,
|
30
|
+
n as TemplatesFactory,
|
31
|
+
s as VariablesFactory,
|
33
32
|
a as defineGlobalStyles,
|
34
|
-
|
35
|
-
c as
|
36
|
-
u as defineTemplates,
|
37
|
-
i as defineVariables
|
33
|
+
l as defineTemplates,
|
34
|
+
c as defineVariables
|
38
35
|
};
|
@@ -0,0 +1,433 @@
|
|
1
|
+
import * as ct from "esbuild";
|
2
|
+
import { execSync as yt } from "child_process";
|
3
|
+
import { t as z, d as G } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as o, parse as A } from "path";
|
5
|
+
import { existsSync as tt, writeFileSync as x, mkdirSync as J, readFileSync as _, statSync as $t, readdirSync as bt } from "fs";
|
6
|
+
import { readFile as it, writeFile as wt } from "fs/promises";
|
7
|
+
import { p as at, a as St } from "./parse-styles-DrLhKtqW.js";
|
8
|
+
import { p as Ct, a as Ft } from "./parse-templates-DRKlN-pP.js";
|
9
|
+
import { createLogger as xt, format as Y, transports as jt } from "winston";
|
10
|
+
import { m as R } from "./merge-BVm9us1A.js";
|
11
|
+
const lt = (t) => {
|
12
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
13
|
+
const e = o(t, "package.json");
|
14
|
+
return tt(e) ? e : lt(o(t, ".."));
|
15
|
+
}, Nt = async (t) => {
|
16
|
+
const e = lt(t);
|
17
|
+
return await it(e, "utf-8").then(JSON.parse).catch(() => {
|
18
|
+
});
|
19
|
+
}, kt = async (t) => {
|
20
|
+
const e = await Nt(t);
|
21
|
+
if (e)
|
22
|
+
return e.type;
|
23
|
+
};
|
24
|
+
let v;
|
25
|
+
const ft = async (t) => {
|
26
|
+
if (v) return v;
|
27
|
+
const e = await kt(t);
|
28
|
+
return e === "module" ? v = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (v = "cjs"), v || "esm";
|
29
|
+
}, Z = xt({
|
30
|
+
level: "debug",
|
31
|
+
format: Y.combine(Y.colorize(), Y.cli()),
|
32
|
+
transports: [new jt.Console({})]
|
33
|
+
}), Bt = (t) => {
|
34
|
+
Z.error(t);
|
35
|
+
};
|
36
|
+
function pt(t) {
|
37
|
+
return t ? typeof t != "string" ? pt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
38
|
+
}
|
39
|
+
const Dt = {
|
40
|
+
/** Set box model to border-box */
|
41
|
+
"*, *::before, *::after": {
|
42
|
+
boxSizing: "border-box"
|
43
|
+
},
|
44
|
+
/** Remove default margin and padding */
|
45
|
+
"*": {
|
46
|
+
margin: 0
|
47
|
+
},
|
48
|
+
/** Remove adjust font properties */
|
49
|
+
html: {
|
50
|
+
lineHeight: 1.15,
|
51
|
+
textSizeAdjust: "100%",
|
52
|
+
WebkitFontSmoothing: "antialiased"
|
53
|
+
},
|
54
|
+
/** Make media elements responsive */
|
55
|
+
"img, picture, video, canvas, svg": {
|
56
|
+
display: "block",
|
57
|
+
maxWidth: "100%"
|
58
|
+
},
|
59
|
+
/** Avoid overflow of text */
|
60
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
61
|
+
overflowWrap: "break-word"
|
62
|
+
},
|
63
|
+
/** Improve text wrapping */
|
64
|
+
p: {
|
65
|
+
textWrap: "pretty"
|
66
|
+
},
|
67
|
+
"h1, h2, h3, h4, h5, h6": {
|
68
|
+
textWrap: "balance"
|
69
|
+
},
|
70
|
+
/** Improve link color */
|
71
|
+
a: {
|
72
|
+
color: "currentColor"
|
73
|
+
},
|
74
|
+
/** Improve button line height */
|
75
|
+
button: {
|
76
|
+
lineHeight: "1em",
|
77
|
+
color: "currentColor"
|
78
|
+
},
|
79
|
+
/** Improve form elements */
|
80
|
+
"input, optgroup, select, textarea": {
|
81
|
+
fontFamily: "inherit",
|
82
|
+
fontSize: "100%",
|
83
|
+
lineHeight: "1.15em"
|
84
|
+
}
|
85
|
+
}, T = {
|
86
|
+
externalModules: [],
|
87
|
+
rcFile: void 0,
|
88
|
+
destDir: void 0
|
89
|
+
}, dt = (t) => {
|
90
|
+
if (T.externalModules.length > 0) return T.externalModules;
|
91
|
+
const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
92
|
+
if (!s) return [];
|
93
|
+
const l = s[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
94
|
+
return T.externalModules = l, l;
|
95
|
+
}, V = async (t) => {
|
96
|
+
if (T.destDir) return T.destDir;
|
97
|
+
const e = await st(t), s = o(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
98
|
+
return T.destDir = s, s;
|
99
|
+
}, ut = ["salty", "css", "styles", "styled"], Pt = (t = []) => new RegExp(`\\.(${[...ut, ...t].join("|")})\\.`), et = (t, e = []) => Pt(e).test(t), mt = async (t) => {
|
100
|
+
if (T.rcFile) return T.rcFile;
|
101
|
+
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
102
|
+
const e = o(t, ".saltyrc.json"), s = await it(e, "utf-8").then(JSON.parse).catch(() => {
|
103
|
+
});
|
104
|
+
return s ? (T.rcFile = s, s) : mt(o(t, ".."));
|
105
|
+
}, st = async (t) => {
|
106
|
+
var l, i;
|
107
|
+
const e = await mt(t), s = (l = e.projects) == null ? void 0 : l.find((r) => t.endsWith(r.dir || ""));
|
108
|
+
return s || ((i = e.projects) == null ? void 0 : i.find((r) => r.dir === e.defaultProject));
|
109
|
+
}, Tt = async (t) => {
|
110
|
+
const e = await st(t), s = await V(t), l = o(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), i = o(s, "salty.config.js"), r = await ft(t), c = dt(l);
|
111
|
+
await ct.build({
|
112
|
+
entryPoints: [l],
|
113
|
+
minify: !0,
|
114
|
+
treeShaking: !0,
|
115
|
+
bundle: !0,
|
116
|
+
outfile: i,
|
117
|
+
format: r,
|
118
|
+
external: c
|
119
|
+
});
|
120
|
+
const h = Date.now(), { config: d } = await import(`${i}?t=${h}`);
|
121
|
+
return d;
|
122
|
+
}, _t = async (t, e) => {
|
123
|
+
var B, L;
|
124
|
+
const s = await Tt(t), l = { ...s }, i = /* @__PURE__ */ new Set(), r = (S, C = []) => S ? Object.entries(S).flatMap(([M, P]) => {
|
125
|
+
if (!P) return;
|
126
|
+
if (typeof P == "object") return r(P, [...C, M]);
|
127
|
+
const Q = pt(M), q = G(M), U = [...C, Q].join(".");
|
128
|
+
i.add(`"${U}"`);
|
129
|
+
const X = [...C.map(G), q].join("-"), { result: ht } = St(P);
|
130
|
+
return `--${X}: ${ht};`;
|
131
|
+
}) : [], c = (S) => S ? Object.entries(S).flatMap(([C, M]) => {
|
132
|
+
const P = r(M);
|
133
|
+
return C === "base" ? P.join("") : `${C} { ${P.join("")} }`;
|
134
|
+
}) : [], h = (S) => S ? Object.entries(S).flatMap(([C, M]) => Object.entries(M).flatMap(([P, Q]) => {
|
135
|
+
const q = r(Q, [C]), U = `.${C}-${P}, [data-${C}="${P}"]`, X = q.join("");
|
136
|
+
return `${U} { ${X} }`;
|
137
|
+
})) : [], d = (S) => ({ ...S, responsive: void 0, conditional: void 0 }), n = (S) => e.variables.map((C) => S === "static" ? d(C._current) : C._current[S]), g = r(R(d(s.variables), n("static"))), m = c(R((B = s.variables) == null ? void 0 : B.responsive, n("responsive"))), u = h(R((L = s.variables) == null ? void 0 : L.conditional, n("conditional"))), b = await V(t), j = o(b, "css/_variables.css"), E = `:root { ${g.join("")} ${m.join("")} } ${u.join("")}`;
|
138
|
+
x(j, E);
|
139
|
+
const D = o(b, "css/_global.css"), k = R(s.global, e.globalStyles), O = at(k, "");
|
140
|
+
x(D, `@layer global { ${O} }`);
|
141
|
+
const N = o(b, "css/_reset.css"), a = s.reset === "none" ? {} : typeof s.reset == "object" ? s.reset : Dt, F = at(a, "");
|
142
|
+
x(N, `@layer reset { ${F} }`);
|
143
|
+
const w = o(b, "css/_templates.css"), y = R(s.templates, e.templates), p = Ct(y), $ = Ft(y);
|
144
|
+
x(w, p), l.templates = y;
|
145
|
+
const f = o(b, "types/css-tokens.d.ts"), I = `
|
146
|
+
// Variable types
|
147
|
+
type VariableTokens = ${[...i].join("|")};
|
148
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
149
|
+
|
150
|
+
// Template types
|
151
|
+
type TemplateTokens = {
|
152
|
+
${Object.entries($).map(([S, C]) => `${S}?: ${C}`).join(`
|
153
|
+
`)}
|
154
|
+
}
|
155
|
+
`;
|
156
|
+
x(f, I);
|
157
|
+
const K = o(b, "cache/config-cache.json");
|
158
|
+
x(K, JSON.stringify(l, null, 2));
|
159
|
+
}, rt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
160
|
+
if (/^['"`]/.test(s)) return e;
|
161
|
+
const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
162
|
+
if (!i.test(t)) return e;
|
163
|
+
const c = i.exec(t);
|
164
|
+
if (c) {
|
165
|
+
const h = c.at(1);
|
166
|
+
if (ut.some((n) => h == null ? void 0 : h.includes(n))) return e;
|
167
|
+
}
|
168
|
+
return "styled('div',";
|
169
|
+
}), nt = async (t, e, s) => {
|
170
|
+
const l = z(e), i = o(s, "./temp");
|
171
|
+
tt(i) || J(i);
|
172
|
+
const r = A(e);
|
173
|
+
let c = _(e, "utf8");
|
174
|
+
c = rt(c);
|
175
|
+
const h = o(s, "js", l + ".js"), d = await st(t), n = o(t, (d == null ? void 0 : d.configDir) || "", "salty.config.ts"), g = dt(n), m = await ft(t);
|
176
|
+
await ct.build({
|
177
|
+
stdin: {
|
178
|
+
contents: c,
|
179
|
+
sourcefile: r.base,
|
180
|
+
resolveDir: r.dir,
|
181
|
+
loader: "tsx"
|
182
|
+
},
|
183
|
+
minify: !1,
|
184
|
+
treeShaking: !0,
|
185
|
+
bundle: !0,
|
186
|
+
outfile: h,
|
187
|
+
format: m,
|
188
|
+
target: ["node20"],
|
189
|
+
keepNames: !0,
|
190
|
+
external: g,
|
191
|
+
packages: "external",
|
192
|
+
plugins: [
|
193
|
+
{
|
194
|
+
name: "test",
|
195
|
+
setup: (j) => {
|
196
|
+
j.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (E) => {
|
197
|
+
const D = _(E.path, "utf8");
|
198
|
+
return { contents: rt(D), loader: "ts" };
|
199
|
+
});
|
200
|
+
}
|
201
|
+
}
|
202
|
+
]
|
203
|
+
});
|
204
|
+
const u = Date.now();
|
205
|
+
return await import(`${h}?t=${u}`);
|
206
|
+
}, Et = async (t) => {
|
207
|
+
const e = await V(t), s = o(e, "cache/config-cache.json"), l = _(s, "utf8");
|
208
|
+
if (!l) throw new Error("Could not find config cache file");
|
209
|
+
return JSON.parse(l);
|
210
|
+
}, ot = async (t) => {
|
211
|
+
const e = await Et(t), s = await V(t), l = o(s, "salty.config.js"), i = Date.now(), { config: r } = await import(`${l}?t=${i}`);
|
212
|
+
return R(r, e);
|
213
|
+
}, gt = () => {
|
214
|
+
try {
|
215
|
+
return process.env.NODE_ENV === "production";
|
216
|
+
} catch {
|
217
|
+
return !1;
|
218
|
+
}
|
219
|
+
}, Gt = async (t, e = gt(), s = !0) => {
|
220
|
+
try {
|
221
|
+
const l = Date.now();
|
222
|
+
e ? Z.info("Generating CSS in production mode! 🔥") : Z.info("Generating CSS in development mode! 🚀");
|
223
|
+
const i = [], r = [], c = await V(t), h = o(c, "index.css");
|
224
|
+
s && (() => {
|
225
|
+
tt(c) && yt("rm -rf " + c), J(c, { recursive: !0 }), J(o(c, "css")), J(o(c, "types")), J(o(c, "js")), J(o(c, "cache"));
|
226
|
+
})();
|
227
|
+
const n = {
|
228
|
+
keyframes: [],
|
229
|
+
mediaQueries: [],
|
230
|
+
globalStyles: [],
|
231
|
+
variables: [],
|
232
|
+
templates: [],
|
233
|
+
components: [],
|
234
|
+
classNames: []
|
235
|
+
};
|
236
|
+
async function g(a) {
|
237
|
+
const F = ["node_modules", "saltygen"], w = $t(a);
|
238
|
+
if (w.isDirectory()) {
|
239
|
+
const y = bt(a);
|
240
|
+
if (F.some(($) => a.includes($))) return;
|
241
|
+
await Promise.all(y.map(($) => g(o(a, $))));
|
242
|
+
} else if (w.isFile() && et(a)) {
|
243
|
+
const p = await nt(t, a, c);
|
244
|
+
Object.entries(p).forEach(([$, f]) => {
|
245
|
+
f.isKeyframes ? n.keyframes.push({
|
246
|
+
value: f,
|
247
|
+
src: a,
|
248
|
+
name: $
|
249
|
+
}) : f.isMedia ? n.mediaQueries.push(f) : f.isGlobalDefine ? n.globalStyles.push(f) : f.isDefineVariables ? n.variables.push(f) : f.isDefineTemplates ? n.templates.push(f) : f.isClassName ? n.classNames.push({
|
250
|
+
value: f.factory,
|
251
|
+
src: a,
|
252
|
+
name: $
|
253
|
+
}) : f.generator && n.components.push({
|
254
|
+
value: f.generator,
|
255
|
+
src: a,
|
256
|
+
name: $
|
257
|
+
});
|
258
|
+
});
|
259
|
+
}
|
260
|
+
}
|
261
|
+
await g(t), await _t(t, n);
|
262
|
+
const m = await ot(t);
|
263
|
+
for (const a of n.keyframes) {
|
264
|
+
const { value: F } = a, w = `a_${F.animationName}.css`, y = `css/${w}`, p = o(c, y);
|
265
|
+
i.push(w), x(p, F.css);
|
266
|
+
}
|
267
|
+
const u = {};
|
268
|
+
for (const a of n.components) {
|
269
|
+
const { value: F, name: w, src: y } = a, p = F._withBuildContext({
|
270
|
+
name: w,
|
271
|
+
config: m,
|
272
|
+
prod: e
|
273
|
+
});
|
274
|
+
r[p.priority] || (r[p.priority] = []), r[p.priority].push(p.cssFileName);
|
275
|
+
const $ = `css/${p.cssFileName}`, f = o(c, $);
|
276
|
+
x(f, p.css), m.importStrategy === "component" && (u[y] ? u[y].push(p.cssFileName) : u[y] = [p.cssFileName]);
|
277
|
+
}
|
278
|
+
for (const a of n.classNames) {
|
279
|
+
const { value: F, src: w, name: y } = a, p = F._withBuildContext({
|
280
|
+
name: y,
|
281
|
+
prod: e
|
282
|
+
});
|
283
|
+
r[0].push(p.cssFileName);
|
284
|
+
const $ = `css/${p.cssFileName}`, f = o(c, $);
|
285
|
+
x(f, p.css), m.importStrategy === "component" && (u[w] ? u[w].push(p.cssFileName) : u[w] = [p.cssFileName]);
|
286
|
+
}
|
287
|
+
m.importStrategy === "component" && Object.entries(u).forEach(([a, F]) => {
|
288
|
+
const w = F.map((H) => `@import url('./${H}');`).join(`
|
289
|
+
`), y = z(a, 6), p = A(a), $ = G(p.name), f = o(c, `css/f_${$}-${y}.css`);
|
290
|
+
x(f, w);
|
291
|
+
});
|
292
|
+
const b = i.map((a) => `@import url('./css/${a}');`).join(`
|
293
|
+
`);
|
294
|
+
let k = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
295
|
+
|
296
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((a) => {
|
297
|
+
try {
|
298
|
+
return _(o(c, "css", a), "utf8").length > 0;
|
299
|
+
} catch {
|
300
|
+
return !1;
|
301
|
+
}
|
302
|
+
}).map((a) => `@import url('./css/${a}');`).join(`
|
303
|
+
`)}
|
304
|
+
${b}`;
|
305
|
+
if (m.importStrategy !== "component") {
|
306
|
+
const a = r.reduce((F, w, y) => {
|
307
|
+
const p = w.reduce((I, K) => {
|
308
|
+
var C;
|
309
|
+
const B = o(c, "css", K), L = _(B, "utf8"), S = ((C = /.*-([^-]+)-\d+.css/.exec(K)) == null ? void 0 : C.at(1)) || z(B, 6);
|
310
|
+
return I.includes(S) ? I : `${I}
|
311
|
+
/*start:${S}*/
|
312
|
+
${L}
|
313
|
+
/*end:${S}*/
|
314
|
+
`;
|
315
|
+
}, ""), $ = `l_${y}.css`, f = o(c, "css", $), H = `@layer l${y} { ${p}
|
316
|
+
}`;
|
317
|
+
return x(f, H), `${F}
|
318
|
+
@import url('./css/${$}');`;
|
319
|
+
}, "");
|
320
|
+
k += a;
|
321
|
+
}
|
322
|
+
x(h, k);
|
323
|
+
const N = Date.now() - l, W = N < 200 ? "🔥" : N < 500 ? "🚀" : N < 1e3 ? "🎉" : N < 2e3 ? "🚗" : N < 5e3 ? "🤔" : "🥴";
|
324
|
+
Z.info(`Generated CSS in ${N}ms! ${W}`);
|
325
|
+
} catch (l) {
|
326
|
+
console.error(l);
|
327
|
+
}
|
328
|
+
}, Ht = async (t, e) => {
|
329
|
+
try {
|
330
|
+
const s = await V(t);
|
331
|
+
if (et(e)) {
|
332
|
+
const i = [], r = await ot(t), c = await nt(t, e, s);
|
333
|
+
if (Object.entries(c).forEach(([h, d]) => {
|
334
|
+
if (d.isKeyframes && d.css) {
|
335
|
+
const b = `css/${`a_${d.animationName}.css`}`, j = o(s, b);
|
336
|
+
x(j, d.css);
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
if (d.isClassName) {
|
340
|
+
const u = d.factory._withBuildContext({
|
341
|
+
name: h
|
342
|
+
});
|
343
|
+
i[0].push(u.cssFileName);
|
344
|
+
const b = `css/${u.cssFileName}`, j = o(s, b);
|
345
|
+
x(j, u.css);
|
346
|
+
}
|
347
|
+
if (!d.generator) return;
|
348
|
+
const n = d.generator._withBuildContext({
|
349
|
+
name: h,
|
350
|
+
config: r
|
351
|
+
}), g = `css/${n.cssFileName}`, m = o(s, g);
|
352
|
+
x(m, n.css), i[n.priority] || (i[n.priority] = []), i[n.priority].push(n.cssFileName);
|
353
|
+
}), r.importStrategy !== "component")
|
354
|
+
i.forEach((h, d) => {
|
355
|
+
const n = `l_${d}.css`, g = o(s, "css", n);
|
356
|
+
let m = _(g, "utf8");
|
357
|
+
h.forEach((u) => {
|
358
|
+
var D;
|
359
|
+
const b = o(s, "css", u), j = ((D = /.*-([^-]+)-\d+.css/.exec(u)) == null ? void 0 : D.at(1)) || z(b, 6);
|
360
|
+
if (!m.includes(j)) {
|
361
|
+
const k = _(b, "utf8"), O = `/*start:${j}*/
|
362
|
+
${k}
|
363
|
+
/*end:${j}*/
|
364
|
+
`;
|
365
|
+
m = `${m.replace(/\}$/, "")}
|
366
|
+
${O}
|
367
|
+
}`;
|
368
|
+
}
|
369
|
+
}), x(g, m);
|
370
|
+
});
|
371
|
+
else {
|
372
|
+
const h = i.flat().map((u) => `@import url('./${u}');`).join(`
|
373
|
+
`), d = z(e, 6), n = A(e), g = G(n.name), m = o(s, `css/f_${g}-${d}.css`);
|
374
|
+
x(m, h);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
} catch (s) {
|
378
|
+
console.error(s);
|
379
|
+
}
|
380
|
+
}, Kt = async (t, e, s = gt()) => {
|
381
|
+
try {
|
382
|
+
const l = await V(t);
|
383
|
+
if (et(e)) {
|
384
|
+
const r = _(e, "utf8");
|
385
|
+
r.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== r && await wt(e, r);
|
386
|
+
const h = await ot(t), d = await nt(t, e, l);
|
387
|
+
let n = r;
|
388
|
+
if (Object.entries(d).forEach(([g, m]) => {
|
389
|
+
var $;
|
390
|
+
if (m.isKeyframes || !m.generator) return;
|
391
|
+
const u = m.generator._withBuildContext({
|
392
|
+
name: g,
|
393
|
+
config: h,
|
394
|
+
prod: s
|
395
|
+
}), b = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(r);
|
396
|
+
if (!b) return console.error("Could not find the original declaration");
|
397
|
+
const j = ($ = b.at(1)) == null ? void 0 : $.trim(), E = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(n);
|
398
|
+
if (!E) return console.error("Could not find the original declaration");
|
399
|
+
const { index: D } = E;
|
400
|
+
let k = !1;
|
401
|
+
const O = setTimeout(() => k = !0, 5e3);
|
402
|
+
let N = 0, W = !1, a = 0;
|
403
|
+
for (; !W && !k; ) {
|
404
|
+
const f = n[D + N];
|
405
|
+
f === "(" && a++, f === ")" && a--, a === 0 && f === ")" && (W = !0), N > n.length && (k = !0), N++;
|
406
|
+
}
|
407
|
+
if (!k) clearTimeout(O);
|
408
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
409
|
+
const F = D + N, w = n.slice(D, F), y = n, p = ` ${g} = styled(${j}, "${u.classNames}", ${JSON.stringify(u.props)});`;
|
410
|
+
n = n.replace(w, p), y === n && console.error("Minimize file failed to change content", { name: g, tagName: j });
|
411
|
+
}), h.importStrategy === "component") {
|
412
|
+
const g = z(e, 6), m = A(e);
|
413
|
+
n = `import '../../saltygen/css/${`f_${G(m.name)}-${g}.css`}';
|
414
|
+
${n}`;
|
415
|
+
}
|
416
|
+
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
417
|
+
}
|
418
|
+
} catch (l) {
|
419
|
+
console.error("Error in minimizeFile:", l);
|
420
|
+
}
|
421
|
+
};
|
422
|
+
export {
|
423
|
+
Bt as a,
|
424
|
+
Pt as b,
|
425
|
+
_t as c,
|
426
|
+
nt as d,
|
427
|
+
Ht as e,
|
428
|
+
Gt as g,
|
429
|
+
et as i,
|
430
|
+
Z as l,
|
431
|
+
Kt as m,
|
432
|
+
ut as s
|
433
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";const ge=require("esbuild"),he=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),ee=require("fs/promises"),X=require("./parse-styles-3zK35muR.cjs"),oe=require("./parse-templates-VIvmVb52.cjs"),q=require("winston"),v=require("./merge-DxGoJDHv.cjs");var Y=typeof document<"u"?document.currentScript:null;function Se(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const re=Se(ge),ce=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:ce(o.join(e,".."))},we=async e=>{const t=ce(e);return await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Fe=async e=>{const t=await we(e);if(t)return t.type};let V;const ae=async e=>{if(V)return V;const t=await Fe(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-D8nwtA-j.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},I=q.createLogger({level:"debug",format:q.format.combine(q.format.colorize(),q.format.cli()),transports:[new q.transports.Console({})]}),je=e=>{I.error(e)};function le(e){return e?typeof e!="string"?le(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 be={"*, *::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},fe=e=>{if(T.externalModules.length>0)return T.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(f=>f.replace(/['"`]/g,"").trim());return T.externalModules=c,c},O=async e=>{if(T.destDir)return T.destDir;const t=await se(e),s=o.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return T.destDir=s,s},te=["salty","css","styles","styled"],de=(e=[])=>new RegExp(`\\.(${[...te,...e].join("|")})\\.`),L=(e,t=[])=>de(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=o.join(e,".saltyrc.json"),s=await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(T.rcFile=s,s):pe(o.join(e,".."))},se=async e=>{var c,f;const t=await pe(e),s=(c=t.projects)==null?void 0:c.find(a=>e.endsWith(a.dir||""));return s||((f=t.projects)==null?void 0:f.find(a=>a.dir===t.defaultProject))},$e=async e=>{const t=await se(e),s=await O(e),c=o.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),f=o.join(s,"salty.config.js"),a=await ae(e),l=fe(c);await re.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:f,format:a,external:l});const h=Date.now(),{config:u}=await import(`${f}?t=${h}`);return u},ue=async(e,t)=>{var H,G;const s=await $e(e),c={...s},f=new Set,a=(b,$=[])=>b?Object.entries(b).flatMap(([M,_])=>{if(!_)return;if(typeof _=="object")return a(_,[...$,M]);const Z=le(M),A=P.dashCase(M),U=[...$,Z].join(".");f.add(`"${U}"`);const Q=[...$.map(P.dashCase),A].join("-"),{result:me}=X.parseValueTokens(_);return`--${Q}: ${me};`}):[],l=b=>b?Object.entries(b).flatMap(([$,M])=>{const _=a(M);return $==="base"?_.join(""):`${$} { ${_.join("")} }`}):[],h=b=>b?Object.entries(b).flatMap(([$,M])=>Object.entries(M).flatMap(([_,Z])=>{const A=a(Z,[$]),U=`.${$}-${_}, [data-${$}="${_}"]`,Q=A.join("");return`${U} { ${Q} }`})):[],u=b=>({...b,responsive:void 0,conditional:void 0}),n=b=>t.variables.map($=>b==="static"?u($._current):$._current[b]),g=a(v.mergeStyles(u(s.variables),n("static"))),m=l(v.mergeStyles((H=s.variables)==null?void 0:H.responsive,n("responsive"))),y=h(v.mergeStyles((G=s.variables)==null?void 0:G.conditional,n("conditional"))),F=await O(e),x=o.join(F,"css/_variables.css"),E=`:root { ${g.join("")} ${m.join("")} } ${y.join("")}`;i.writeFileSync(x,E);const D=o.join(F,"css/_global.css"),N=v.mergeStyles(s.global,t.globalStyles),R=X.parseStyles(N,"");i.writeFileSync(D,`@layer global { ${R} }`);const k=o.join(F,"css/_reset.css"),r=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:be,C=X.parseStyles(r,"");i.writeFileSync(k,`@layer reset { ${C} }`);const j=o.join(F,"css/_templates.css"),S=v.mergeStyles(s.templates,t.templates),p=oe.parseTemplates(S),w=oe.getTemplateTypes(S);i.writeFileSync(j,p),c.templates=S;const d=o.join(F,"types/css-tokens.d.ts"),z=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...f].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(w).map(([b,$])=>`${b}?: ${$}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;i.writeFileSync(d,z);const B=o.join(F,"cache/config-cache.json");i.writeFileSync(B,JSON.stringify(c,null,2))},ie=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const f=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!f.test(e))return t;const l=f.exec(e);if(l){const h=l.at(1);if(te.some(n=>h==null?void 0:h.includes(n)))return t}return"styled('div',"}),K=async(e,t,s)=>{const c=P.toHash(t),f=o.join(s,"./temp");i.existsSync(f)||i.mkdirSync(f);const a=o.parse(t);let l=i.readFileSync(t,"utf8");l=ie(l);const h=o.join(s,"js",c+".js"),u=await se(e),n=o.join(e,(u==null?void 0:u.configDir)||"","salty.config.ts"),g=fe(n),m=await ae(e);await re.build({stdin:{contents:l,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:m,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:x=>{x.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},E=>{const D=i.readFileSync(E.path,"utf8");return{contents:ie(D),loader:"ts"}})}}]});const y=Date.now();return await import(`${h}?t=${y}`)},Ce=async e=>{const t=await O(e),s=o.join(t,"cache/config-cache.json"),c=i.readFileSync(s,"utf8");if(!c)throw new Error("Could not find config cache file");return JSON.parse(c)},ne=async e=>{const t=await Ce(e),s=await O(e),c=o.join(s,"salty.config.js"),f=Date.now(),{config:a}=await import(`${c}?t=${f}`);return v.mergeStyles(a,t)},ye=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ye(),s=!0)=>{try{const c=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const f=[],a=[],l=await O(e),h=o.join(l,"index.css");s&&(()=>{i.existsSync(l)&&he.execSync("rm -rf "+l),i.mkdirSync(l,{recursive:!0}),i.mkdirSync(o.join(l,"css")),i.mkdirSync(o.join(l,"types")),i.mkdirSync(o.join(l,"js")),i.mkdirSync(o.join(l,"cache"))})();const n={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function g(r){const C=["node_modules","saltygen"],j=i.statSync(r);if(j.isDirectory()){const S=i.readdirSync(r);if(C.some(w=>r.includes(w)))return;await Promise.all(S.map(w=>g(o.join(r,w))))}else if(j.isFile()&&L(r)){const p=await K(e,r,l);Object.entries(p).forEach(([w,d])=>{d.isKeyframes?n.keyframes.push({value:d,src:r,name:w}):d.isMedia?n.mediaQueries.push(d):d.isGlobalDefine?n.globalStyles.push(d):d.isDefineVariables?n.variables.push(d):d.isDefineTemplates?n.templates.push(d):d.isClassName?n.classNames.push({value:d.factory,src:r,name:w}):d.generator&&n.components.push({value:d.generator,src:r,name:w})})}}await g(e),await ue(e,n);const m=await ne(e);for(const r of n.keyframes){const{value:C}=r,j=`a_${C.animationName}.css`,S=`css/${j}`,p=o.join(l,S);f.push(j),i.writeFileSync(p,C.css)}const y={};for(const r of n.components){const{value:C,name:j,src:S}=r,p=C._withBuildContext({name:j,config:m,prod:t});a[p.priority]||(a[p.priority]=[]),a[p.priority].push(p.cssFileName);const w=`css/${p.cssFileName}`,d=o.join(l,w);i.writeFileSync(d,p.css),m.importStrategy==="component"&&(y[S]?y[S].push(p.cssFileName):y[S]=[p.cssFileName])}for(const r of n.classNames){const{value:C,src:j,name:S}=r,p=C._withBuildContext({name:S,prod:t});a[0].push(p.cssFileName);const w=`css/${p.cssFileName}`,d=o.join(l,w);i.writeFileSync(d,p.css),m.importStrategy==="component"&&(y[j]?y[j].push(p.cssFileName):y[j]=[p.cssFileName])}m.importStrategy==="component"&&Object.entries(y).forEach(([r,C])=>{const j=C.map(W=>`@import url('./${W}');`).join(`
|
12
|
+
`),S=P.toHash(r,6),p=o.parse(r),w=P.dashCase(p.name),d=o.join(l,`css/f_${w}-${S}.css`);i.writeFileSync(d,j)});const F=f.map(r=>`@import url('./css/${r}');`).join(`
|
13
|
+
`);let N=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(r=>{try{return i.readFileSync(o.join(l,"css",r),"utf8").length>0}catch{return!1}}).map(r=>`@import url('./css/${r}');`).join(`
|
16
|
+
`)}
|
17
|
+
${F}`;if(m.importStrategy!=="component"){const r=a.reduce((C,j,S)=>{const p=j.reduce((z,B)=>{var $;const H=o.join(l,"css",B),G=i.readFileSync(H,"utf8"),b=(($=/.*-([^-]+)-\d+.css/.exec(B))==null?void 0:$.at(1))||P.toHash(H,6);return z.includes(b)?z:`${z}
|
18
|
+
/*start:${b}*/
|
19
|
+
${G}
|
20
|
+
/*end:${b}*/
|
21
|
+
`},""),w=`l_${S}.css`,d=o.join(l,"css",w),W=`@layer l${S} { ${p}
|
22
|
+
}`;return i.writeFileSync(d,W),`${C}
|
23
|
+
@import url('./css/${w}');`},"");N+=r}i.writeFileSync(h,N);const k=Date.now()-c,J=k<200?"🔥":k<500?"🚀":k<1e3?"🎉":k<2e3?"🚗":k<5e3?"🤔":"🥴";I.info(`Generated CSS in ${k}ms! ${J}`)}catch(c){console.error(c)}},ke=async(e,t)=>{try{const s=await O(e);if(L(t)){const f=[],a=await ne(e),l=await K(e,t,s);if(Object.entries(l).forEach(([h,u])=>{if(u.isKeyframes&&u.css){const F=`css/${`a_${u.animationName}.css`}`,x=o.join(s,F);i.writeFileSync(x,u.css);return}if(u.isClassName){const y=u.factory._withBuildContext({name:h});f[0].push(y.cssFileName);const F=`css/${y.cssFileName}`,x=o.join(s,F);i.writeFileSync(x,y.css)}if(!u.generator)return;const n=u.generator._withBuildContext({name:h,config:a}),g=`css/${n.cssFileName}`,m=o.join(s,g);i.writeFileSync(m,n.css),f[n.priority]||(f[n.priority]=[]),f[n.priority].push(n.cssFileName)}),a.importStrategy!=="component")f.forEach((h,u)=>{const n=`l_${u}.css`,g=o.join(s,"css",n);let m=i.readFileSync(g,"utf8");h.forEach(y=>{var D;const F=o.join(s,"css",y),x=((D=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:D.at(1))||P.toHash(F,6);if(!m.includes(x)){const N=i.readFileSync(F,"utf8"),R=`/*start:${x}*/
|
24
|
+
${N}
|
25
|
+
/*end:${x}*/
|
26
|
+
`;m=`${m.replace(/\}$/,"")}
|
27
|
+
${R}
|
28
|
+
}`}}),i.writeFileSync(g,m)});else{const h=f.flat().map(y=>`@import url('./${y}');`).join(`
|
29
|
+
`),u=P.toHash(t,6),n=o.parse(t),g=P.dashCase(n.name),m=o.join(s,`css/f_${g}-${u}.css`);i.writeFileSync(m,h)}}}catch(s){console.error(s)}},Ne=async(e,t,s=ye())=>{try{const c=await O(e);if(L(t)){const a=i.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==a&&await ee.writeFile(t,a);const h=await ne(e),u=await K(e,t,c);let n=a;if(Object.entries(u).forEach(([g,m])=>{var w;if(m.isKeyframes||!m.generator)return;const y=m.generator._withBuildContext({name:g,config:h,prod:s}),F=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!F)return console.error("Could not find the original declaration");const x=(w=F.at(1))==null?void 0:w.trim(),E=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(n);if(!E)return console.error("Could not find the original declaration");const{index:D}=E;let N=!1;const R=setTimeout(()=>N=!0,5e3);let k=0,J=!1,r=0;for(;!J&&!N;){const d=n[D+k];d==="("&&r++,d===")"&&r--,r===0&&d===")"&&(J=!0),k>n.length&&(N=!0),k++}if(!N)clearTimeout(R);else throw new Error("Failed to find the end of the styled call and timed out");const C=D+k,j=n.slice(D,C),S=n,p=` ${g} = styled(${x}, "${y.classNames}", ${JSON.stringify(y.props)});`;n=n.replace(j,p),S===n&&console.error("Minimize file failed to change content",{name:g,tagName:x})}),h.importStrategy==="component"){const g=P.toHash(t,6),m=o.parse(t);n=`import '../../saltygen/css/${`f_${P.dashCase(m.name)}-${g}.css`}';
|
30
|
+
${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=K;exports.generateConfigStyles=ue;exports.generateCss=xe;exports.generateFile=ke;exports.isSaltyFile=L;exports.logError=je;exports.logger=I;exports.minimizeFile=Ne;exports.saltyFileExtensions=te;exports.saltyFileRegExp=de;
|
package/package.json
CHANGED
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-D8nwtA-j.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-C-3Ey2EZ.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|
package/types/config-types.d.ts
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
import { CssProperties, CssStyles } from '../types';
|
2
2
|
import { OrString } from '../types/util-types';
|
3
3
|
export type GlobalStyles = Record<string, CssProperties>;
|
4
|
-
export type
|
4
|
+
export type CssVariableTokensObject = Record<string, unknown>;
|
5
5
|
export interface CssResponsiveVariables {
|
6
|
-
[key: string]:
|
6
|
+
[key: string]: CssVariableTokensObject;
|
7
7
|
}
|
8
8
|
export interface CssConditionalVariables {
|
9
9
|
[key: PropertyKey]: {
|
10
|
-
[key: PropertyKey]:
|
10
|
+
[key: PropertyKey]: CssVariableTokensObject;
|
11
11
|
};
|
12
12
|
}
|
13
|
+
export interface SaltyVariables {
|
14
|
+
responsive?: CssResponsiveVariables;
|
15
|
+
conditional?: CssConditionalVariables;
|
16
|
+
[key: string]: undefined | string | number | CssVariableTokensObject;
|
17
|
+
}
|
13
18
|
type CssTemplate = CssStyles | {
|
14
19
|
[key: PropertyKey]: CssTemplate;
|
15
20
|
};
|
@@ -34,17 +39,11 @@ export interface SaltyConfig {
|
|
34
39
|
*/
|
35
40
|
importStrategy?: 'root' | 'component';
|
36
41
|
/**
|
37
|
-
* Base variables that can be used in all styles as they are applied globally to :root.
|
38
|
-
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Variables that are defined for different media queries.
|
42
|
-
*/
|
43
|
-
responsiveVariables?: CssResponsiveVariables;
|
44
|
-
/**
|
45
|
-
* Variables that are defined for different parent selectors (classes or data attributes).
|
42
|
+
* Base level variables that can be used in all styles as they are applied globally to :root.
|
43
|
+
@param responsive Variables that are defined for different media queries.
|
44
|
+
@param conditional Variables that are defined for different parent selectors (classes or data attributes).
|
46
45
|
*/
|
47
|
-
|
46
|
+
variables?: SaltyVariables;
|
48
47
|
/**
|
49
48
|
* The global styles that are imported in the root of the project.
|
50
49
|
*/
|
package/index-BmsXxgnE.cjs
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
"use strict";const ue=require("esbuild"),ye=require("child_process"),T=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),Q=require("fs/promises"),A=require("./parse-styles-3zK35muR.cjs"),te=require("./parse-templates-VIvmVb52.cjs"),I=require("winston"),z=require("./merge-DxGoJDHv.cjs");var U=typeof document<"u"?document.currentScript:null;function me(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ne=me(ue),oe=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:oe(o.join(e,".."))},ge=async e=>{const t=oe(e);return await Q.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},he=async e=>{const t=await ge(e);if(t)return t.type};let J;const ie=async e=>{if(J)return J;const t=await he(e);return t==="module"?J="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index-BmsXxgnE.cjs",document.baseURI).href).endsWith(".cjs"))&&(J="cjs"),J||"esm"},W=I.createLogger({level:"debug",format:I.format.combine(I.format.colorize(),I.format.cli()),transports:[new I.transports.Console({})]}),Se=e=>{W.error(e)};function re(e){return e?typeof e!="string"?re(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 we={"*, *::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"}},E={externalModules:[],rcFile:void 0,destDir:void 0},ce=e=>{if(E.externalModules.length>0)return E.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(f=>f.replace(/['"`]/g,"").trim());return E.externalModules=c,c},O=async e=>{if(E.destDir)return E.destDir;const t=await Y(e),s=o.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},X=["salty","css","styles","styled"],ae=(e=[])=>new RegExp(`\\.(${[...X,...e].join("|")})\\.`),B=(e,t=[])=>ae(t).test(e),le=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=o.join(e,".saltyrc.json"),s=await Q.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):le(o.join(e,".."))},Y=async e=>{var c,f;const t=await le(e),s=(c=t.projects)==null?void 0:c.find(a=>e.endsWith(a.dir||""));return s||((f=t.projects)==null?void 0:f.find(a=>a.dir===t.defaultProject))},Fe=async e=>{const t=await Y(e),s=await O(e),c=o.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),f=o.join(s,"salty.config.js"),a=await ie(e),d=ce(c);await ne.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:f,format:a,external:d});const h=Date.now(),{config:p}=await import(`${f}?t=${h}`);return p},fe=async(e,t)=>{const s=await Fe(e),c={...s},f=new Set,a=(x,b=[])=>x?Object.entries(x).flatMap(([_,N])=>{if(!N)return;if(typeof N=="object")return a(N,[...b,_]);const v=re(_),L=T.dashCase(_),K=[...b,v].join(".");f.add(`"${K}"`);const Z=[...b.map(T.dashCase),L].join("-"),{result:pe}=A.parseValueTokens(N);return`--${Z}: ${pe};`}):[],d=x=>x?Object.entries(x).flatMap(([b,_])=>{const N=a(_);return b==="base"?N.join(""):`${b} { ${N.join("")} }`}):[],h=x=>x?Object.entries(x).flatMap(([b,_])=>Object.entries(_).flatMap(([N,v])=>{const L=a(v,[b]),K=`.${b}-${N}, [data-${b}="${N}"]`,Z=L.join("");return`${K} { ${Z} }`})):[],p=x=>t.variables.map(b=>b._current[x]),n=a(z.mergeStyles(s.variables,p("variables"))),g=d(z.mergeStyles(s.responsiveVariables,p("responsiveVariables"))),m=h(z.mergeStyles(s.conditionalVariables,p("conditionalVariables"))),l=await O(e),C=o.join(l,"css/_variables.css"),$=`:root { ${n.join("")} ${g.join("")} } ${m.join("")}`;i.writeFileSync(C,$);const M=o.join(l,"css/_global.css"),P=z.mergeStyles(s.global,t.globalStyles),k=A.parseStyles(P,"");i.writeFileSync(M,`@layer global { ${k} }`);const V=o.join(l,"css/_reset.css"),R=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:we,r=A.parseStyles(R,"");i.writeFileSync(V,`@layer reset { ${r} }`);const j=o.join(l,"css/_templates.css"),S=z.mergeStyles(s.templates,t.templates),F=te.parseTemplates(S),u=te.getTemplateTypes(S);i.writeFileSync(j,F),c.templates=S;const w=o.join(l,"types/css-tokens.d.ts"),H=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...f].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(u).map(([x,b])=>`${x}?: ${b}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;i.writeFileSync(w,H);const q=o.join(l,"cache/config-cache.json");i.writeFileSync(q,JSON.stringify(c,null,2))},se=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const f=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!f.test(e))return t;const d=f.exec(e);if(d){const h=d.at(1);if(X.some(n=>h==null?void 0:h.includes(n)))return t}return"styled('div',"}),G=async(e,t,s)=>{const c=T.toHash(t),f=o.join(s,"./temp");i.existsSync(f)||i.mkdirSync(f);const a=o.parse(t);let d=i.readFileSync(t,"utf8");d=se(d);const h=o.join(s,"js",c+".js"),p=await Y(e),n=o.join(e,(p==null?void 0:p.configDir)||"","salty.config.ts"),g=ce(n),m=await ie(e);await ne.build({stdin:{contents:d,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:m,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:$=>{$.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},M=>{const P=i.readFileSync(M.path,"utf8");return{contents:se(P),loader:"ts"}})}}]});const l=Date.now();return await import(`${h}?t=${l}`)},je=async e=>{const t=await O(e),s=o.join(t,"cache/config-cache.json"),c=i.readFileSync(s,"utf8");if(!c)throw new Error("Could not find config cache file");return JSON.parse(c)},ee=async e=>{const t=await je(e),s=await O(e),c=o.join(s,"salty.config.js"),f=Date.now(),{config:a}=await import(`${c}?t=${f}`);return z.mergeStyles(a,t)},de=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},be=async(e,t=de(),s=!0)=>{try{const c=Date.now();t?W.info("Generating CSS in production mode! 🔥"):W.info("Generating CSS in development mode! 🚀");const f=[],a=[],d=await O(e),h=o.join(d,"index.css");s&&(()=>{i.existsSync(d)&&ye.execSync("rm -rf "+d),i.mkdirSync(d,{recursive:!0}),i.mkdirSync(o.join(d,"css")),i.mkdirSync(o.join(d,"types")),i.mkdirSync(o.join(d,"js")),i.mkdirSync(o.join(d,"cache"))})();const n={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function g(r){const j=["node_modules","saltygen"],S=i.statSync(r);if(S.isDirectory()){const F=i.readdirSync(r);if(j.some(w=>r.includes(w)))return;await Promise.all(F.map(w=>g(o.join(r,w))))}else if(S.isFile()&&B(r)){const u=await G(e,r,d);Object.entries(u).forEach(([w,y])=>{y.isKeyframes?n.keyframes.push({value:y,src:r,name:w}):y.isMedia?n.mediaQueries.push(y):y.isGlobalDefine?n.globalStyles.push(y):y.isDefineVariables?n.variables.push(y):y.isDefineTemplates?n.templates.push(y):y.isClassName?n.classNames.push({value:y.factory,src:r,name:w}):y.generator&&n.components.push({value:y.generator,src:r,name:w})})}}await g(e),await fe(e,n);const m=await ee(e);for(const r of n.keyframes){const{value:j}=r,S=`a_${j.animationName}.css`,F=`css/${S}`,u=o.join(d,F);f.push(S),i.writeFileSync(u,j.css)}const l={};for(const r of n.components){const{value:j,name:S,src:F}=r,u=j._withBuildContext({name:S,config:m,prod:t});a[u.priority]||(a[u.priority]=[]),a[u.priority].push(u.cssFileName);const w=`css/${u.cssFileName}`,y=o.join(d,w);i.writeFileSync(y,u.css),m.importStrategy==="component"&&(l[F]?l[F].push(u.cssFileName):l[F]=[u.cssFileName])}for(const r of n.classNames){const{value:j,src:S,name:F}=r,u=j._withBuildContext({name:F,prod:t});a[0].push(u.cssFileName);const w=`css/${u.cssFileName}`,y=o.join(d,w);i.writeFileSync(y,u.css),m.importStrategy==="component"&&(l[S]?l[S].push(u.cssFileName):l[S]=[u.cssFileName])}m.importStrategy==="component"&&Object.entries(l).forEach(([r,j])=>{const S=j.map(H=>`@import url('./${H}');`).join(`
|
12
|
-
`),F=T.toHash(r,6),u=o.parse(r),w=T.dashCase(u.name),y=o.join(d,`css/f_${w}-${F}.css`);i.writeFileSync(y,S)});const C=f.map(r=>`@import url('./css/${r}');`).join(`
|
13
|
-
`);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(r=>{try{return i.readFileSync(o.join(d,"css",r),"utf8").length>0}catch{return!1}}).map(r=>`@import url('./css/${r}');`).join(`
|
16
|
-
`)}
|
17
|
-
${C}`;if(m.importStrategy!=="component"){const r=a.reduce((j,S,F)=>{const u=S.reduce((q,x)=>{var v;const b=o.join(d,"css",x),_=i.readFileSync(b,"utf8"),N=((v=/.*-([^-]+)-\d+.css/.exec(x))==null?void 0:v.at(1))||T.toHash(b,6);return q.includes(N)?q:`${q}
|
18
|
-
/*start:${N}*/
|
19
|
-
${_}
|
20
|
-
/*end:${N}*/
|
21
|
-
`},""),w=`l_${F}.css`,y=o.join(d,"css",w),H=`@layer l${F} { ${u}
|
22
|
-
}`;return i.writeFileSync(y,H),`${j}
|
23
|
-
@import url('./css/${w}');`},"");k+=r}i.writeFileSync(h,k);const D=Date.now()-c,R=D<200?"🔥":D<500?"🚀":D<1e3?"🎉":D<2e3?"🚗":D<5e3?"🤔":"🥴";W.info(`Generated CSS in ${D}ms! ${R}`)}catch(c){console.error(c)}},$e=async(e,t)=>{try{const s=await O(e);if(B(t)){const f=[],a=await ee(e),d=await G(e,t,s);if(Object.entries(d).forEach(([h,p])=>{if(p.isKeyframes&&p.css){const C=`css/${`a_${p.animationName}.css`}`,$=o.join(s,C);i.writeFileSync($,p.css);return}if(p.isClassName){console.log("found className value",p);const l=p.factory._withBuildContext({name:h});f[0].push(l.cssFileName);const C=`css/${l.cssFileName}`,$=o.join(s,C);i.writeFileSync($,l.css),console.log($,l.css)}if(!p.generator)return;const n=p.generator._withBuildContext({name:h,config:a}),g=`css/${n.cssFileName}`,m=o.join(s,g);i.writeFileSync(m,n.css),f[n.priority]||(f[n.priority]=[]),f[n.priority].push(n.cssFileName)}),console.log(f),a.importStrategy!=="component")f.forEach((h,p)=>{const n=`l_${p}.css`,g=o.join(s,"css",n);let m=i.readFileSync(g,"utf8");h.forEach(l=>{var P;const C=o.join(s,"css",l),$=((P=/.*-([^-]+)-\d+.css/.exec(l))==null?void 0:P.at(1))||T.toHash(C,6);if(!m.includes($)){const k=i.readFileSync(C,"utf8"),V=`/*start:${$}*/
|
24
|
-
${k}
|
25
|
-
/*end:${$}*/
|
26
|
-
`;m=`${m.replace(/\}$/,"")}
|
27
|
-
${V}
|
28
|
-
}`}}),i.writeFileSync(g,m)});else{const h=f.flat().map(l=>`@import url('./${l}');`).join(`
|
29
|
-
`),p=T.toHash(t,6),n=o.parse(t),g=T.dashCase(n.name),m=o.join(s,`css/f_${g}-${p}.css`);i.writeFileSync(m,h)}}}catch(s){console.error(s)}},Ce=async(e,t,s=de())=>{try{const c=await O(e);if(B(t)){const a=i.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==a&&await Q.writeFile(t,a);const h=await ee(e),p=await G(e,t,c);let n=a;if(Object.entries(p).forEach(([g,m])=>{var w;if(m.isKeyframes||!m.generator)return;const l=m.generator._withBuildContext({name:g,config:h,prod:s}),C=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!C)return console.error("Could not find the original declaration");const $=(w=C.at(1))==null?void 0:w.trim(),M=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(n);if(!M)return console.error("Could not find the original declaration");const{index:P}=M;let k=!1;const V=setTimeout(()=>k=!0,5e3);let D=0,R=!1,r=0;for(;!R&&!k;){const y=n[P+D];y==="("&&r++,y===")"&&r--,r===0&&y===")"&&(R=!0),D>n.length&&(k=!0),D++}if(!k)clearTimeout(V);else throw new Error("Failed to find the end of the styled call and timed out");const j=P+D,S=n.slice(P,j),F=n,u=` ${g} = styled(${$}, "${l.classNames}", ${JSON.stringify(l.props)});`;n=n.replace(S,u),F===n&&console.error("Minimize file failed to change content",{name:g,tagName:$})}),h.importStrategy==="component"){const g=T.toHash(t,6),m=o.parse(t);n=`import '../../saltygen/css/${`f_${T.dashCase(m.name)}-${g}.css`}';
|
30
|
-
${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=G;exports.generateConfigStyles=fe;exports.generateCss=be;exports.generateFile=$e;exports.isSaltyFile=B;exports.logError=Se;exports.logger=W;exports.minimizeFile=Ce;exports.saltyFileExtensions=X;exports.saltyFileRegExp=ae;
|
package/index-DKkgPK-r.js
DELETED
@@ -1,433 +0,0 @@
|
|
1
|
-
import * as oe from "esbuild";
|
2
|
-
import { execSync as me } from "child_process";
|
3
|
-
import { t as I, d as H } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as o, parse as L } from "path";
|
5
|
-
import { existsSync as U, writeFileSync as C, mkdirSync as z, readFileSync as _, statSync as ge, readdirSync as ye } from "fs";
|
6
|
-
import { readFile as ae, writeFile as he } from "fs/promises";
|
7
|
-
import { p as se, a as $e } from "./parse-styles-DrLhKtqW.js";
|
8
|
-
import { p as be, a as we } from "./parse-templates-DRKlN-pP.js";
|
9
|
-
import { createLogger as Se, format as q, transports as Ce } from "winston";
|
10
|
-
import { m as W } from "./merge-BVm9us1A.js";
|
11
|
-
const re = (e) => {
|
12
|
-
if (!e || e === "/") throw new Error("Could not find package.json file");
|
13
|
-
const t = o(e, "package.json");
|
14
|
-
return U(t) ? t : re(o(e, ".."));
|
15
|
-
}, Fe = async (e) => {
|
16
|
-
const t = re(e);
|
17
|
-
return await ae(t, "utf-8").then(JSON.parse).catch(() => {
|
18
|
-
});
|
19
|
-
}, xe = async (e) => {
|
20
|
-
const t = await Fe(e);
|
21
|
-
if (t)
|
22
|
-
return t.type;
|
23
|
-
};
|
24
|
-
let v;
|
25
|
-
const ce = async (e) => {
|
26
|
-
if (v) return v;
|
27
|
-
const t = await xe(e);
|
28
|
-
return t === "module" ? v = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (v = "cjs"), v || "esm";
|
29
|
-
}, K = Se({
|
30
|
-
level: "debug",
|
31
|
-
format: q.combine(q.colorize(), q.cli()),
|
32
|
-
transports: [new Ce.Console({})]
|
33
|
-
}), ze = (e) => {
|
34
|
-
K.error(e);
|
35
|
-
};
|
36
|
-
function ie(e) {
|
37
|
-
return e ? typeof e != "string" ? ie(String(e)) : e.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "." : "") + t.toLowerCase()) : "";
|
38
|
-
}
|
39
|
-
const je = {
|
40
|
-
/** Set box model to border-box */
|
41
|
-
"*, *::before, *::after": {
|
42
|
-
boxSizing: "border-box"
|
43
|
-
},
|
44
|
-
/** Remove default margin and padding */
|
45
|
-
"*": {
|
46
|
-
margin: 0
|
47
|
-
},
|
48
|
-
/** Remove adjust font properties */
|
49
|
-
html: {
|
50
|
-
lineHeight: 1.15,
|
51
|
-
textSizeAdjust: "100%",
|
52
|
-
WebkitFontSmoothing: "antialiased"
|
53
|
-
},
|
54
|
-
/** Make media elements responsive */
|
55
|
-
"img, picture, video, canvas, svg": {
|
56
|
-
display: "block",
|
57
|
-
maxWidth: "100%"
|
58
|
-
},
|
59
|
-
/** Avoid overflow of text */
|
60
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
61
|
-
overflowWrap: "break-word"
|
62
|
-
},
|
63
|
-
/** Improve text wrapping */
|
64
|
-
p: {
|
65
|
-
textWrap: "pretty"
|
66
|
-
},
|
67
|
-
"h1, h2, h3, h4, h5, h6": {
|
68
|
-
textWrap: "balance"
|
69
|
-
},
|
70
|
-
/** Improve link color */
|
71
|
-
a: {
|
72
|
-
color: "currentColor"
|
73
|
-
},
|
74
|
-
/** Improve button line height */
|
75
|
-
button: {
|
76
|
-
lineHeight: "1em",
|
77
|
-
color: "currentColor"
|
78
|
-
},
|
79
|
-
/** Improve form elements */
|
80
|
-
"input, optgroup, select, textarea": {
|
81
|
-
fontFamily: "inherit",
|
82
|
-
fontSize: "100%",
|
83
|
-
lineHeight: "1.15em"
|
84
|
-
}
|
85
|
-
}, E = {
|
86
|
-
externalModules: [],
|
87
|
-
rcFile: void 0,
|
88
|
-
destDir: void 0
|
89
|
-
}, le = (e) => {
|
90
|
-
if (E.externalModules.length > 0) return E.externalModules;
|
91
|
-
const s = _(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
92
|
-
if (!s) return [];
|
93
|
-
const f = s[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
94
|
-
return E.externalModules = f, f;
|
95
|
-
}, M = async (e) => {
|
96
|
-
if (E.destDir) return E.destDir;
|
97
|
-
const t = await Y(e), s = o(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
|
98
|
-
return E.destDir = s, s;
|
99
|
-
}, fe = ["salty", "css", "styles", "styled"], Ne = (e = []) => new RegExp(`\\.(${[...fe, ...e].join("|")})\\.`), X = (e, t = []) => Ne(t).test(e), pe = async (e) => {
|
100
|
-
if (E.rcFile) return E.rcFile;
|
101
|
-
if (e === "/") throw new Error("Could not find .saltyrc.json file");
|
102
|
-
const t = o(e, ".saltyrc.json"), s = await ae(t, "utf-8").then(JSON.parse).catch(() => {
|
103
|
-
});
|
104
|
-
return s ? (E.rcFile = s, s) : pe(o(e, ".."));
|
105
|
-
}, Y = async (e) => {
|
106
|
-
var f, i;
|
107
|
-
const t = await pe(e), s = (f = t.projects) == null ? void 0 : f.find((r) => e.endsWith(r.dir || ""));
|
108
|
-
return s || ((i = t.projects) == null ? void 0 : i.find((r) => r.dir === t.defaultProject));
|
109
|
-
}, ke = async (e) => {
|
110
|
-
const t = await Y(e), s = await M(e), f = o(e, (t == null ? void 0 : t.configDir) || "", "salty.config.ts"), i = o(s, "salty.config.js"), r = await ce(e), l = le(f);
|
111
|
-
await oe.build({
|
112
|
-
entryPoints: [f],
|
113
|
-
minify: !0,
|
114
|
-
treeShaking: !0,
|
115
|
-
bundle: !0,
|
116
|
-
outfile: i,
|
117
|
-
format: r,
|
118
|
-
external: l
|
119
|
-
});
|
120
|
-
const y = Date.now(), { config: p } = await import(`${i}?t=${y}`);
|
121
|
-
return p;
|
122
|
-
}, De = async (e, t) => {
|
123
|
-
const s = await ke(e), f = { ...s }, i = /* @__PURE__ */ new Set(), r = (j, S = []) => j ? Object.entries(j).flatMap(([T, N]) => {
|
124
|
-
if (!N) return;
|
125
|
-
if (typeof N == "object") return r(N, [...S, T]);
|
126
|
-
const R = ie(T), Z = H(T), A = [...S, R].join(".");
|
127
|
-
i.add(`"${A}"`);
|
128
|
-
const Q = [...S.map(H), Z].join("-"), { result: ue } = $e(N);
|
129
|
-
return `--${Q}: ${ue};`;
|
130
|
-
}) : [], l = (j) => j ? Object.entries(j).flatMap(([S, T]) => {
|
131
|
-
const N = r(T);
|
132
|
-
return S === "base" ? N.join("") : `${S} { ${N.join("")} }`;
|
133
|
-
}) : [], y = (j) => j ? Object.entries(j).flatMap(([S, T]) => Object.entries(T).flatMap(([N, R]) => {
|
134
|
-
const Z = r(R, [S]), A = `.${S}-${N}, [data-${S}="${N}"]`, Q = Z.join("");
|
135
|
-
return `${A} { ${Q} }`;
|
136
|
-
})) : [], p = (j) => t.variables.map((S) => S._current[j]), n = r(W(s.variables, p("variables"))), g = l(W(s.responsiveVariables, p("responsiveVariables"))), m = y(W(s.conditionalVariables, p("conditionalVariables"))), c = await M(e), x = o(c, "css/_variables.css"), F = `:root { ${n.join("")} ${g.join("")} } ${m.join("")}`;
|
137
|
-
C(x, F);
|
138
|
-
const V = o(c, "css/_global.css"), P = W(s.global, t.globalStyles), k = se(P, "");
|
139
|
-
C(V, `@layer global { ${k} }`);
|
140
|
-
const O = o(c, "css/_reset.css"), J = s.reset === "none" ? {} : typeof s.reset == "object" ? s.reset : je, a = se(J, "");
|
141
|
-
C(O, `@layer reset { ${a} }`);
|
142
|
-
const w = o(c, "css/_templates.css"), h = W(s.templates, t.templates), b = be(h), d = we(h);
|
143
|
-
C(w, b), f.templates = h;
|
144
|
-
const $ = o(c, "types/css-tokens.d.ts"), B = `
|
145
|
-
// Variable types
|
146
|
-
type VariableTokens = ${[...i].join("|")};
|
147
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
148
|
-
|
149
|
-
// Template types
|
150
|
-
type TemplateTokens = {
|
151
|
-
${Object.entries(d).map(([j, S]) => `${j}?: ${S}`).join(`
|
152
|
-
`)}
|
153
|
-
}
|
154
|
-
`;
|
155
|
-
C($, B);
|
156
|
-
const G = o(c, "cache/config-cache.json");
|
157
|
-
C(G, JSON.stringify(f, null, 2));
|
158
|
-
}, ne = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
|
159
|
-
if (/^['"`]/.test(s)) return t;
|
160
|
-
const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
161
|
-
if (!i.test(e)) return t;
|
162
|
-
const l = i.exec(e);
|
163
|
-
if (l) {
|
164
|
-
const y = l.at(1);
|
165
|
-
if (fe.some((n) => y == null ? void 0 : y.includes(n))) return t;
|
166
|
-
}
|
167
|
-
return "styled('div',";
|
168
|
-
}), ee = async (e, t, s) => {
|
169
|
-
const f = I(t), i = o(s, "./temp");
|
170
|
-
U(i) || z(i);
|
171
|
-
const r = L(t);
|
172
|
-
let l = _(t, "utf8");
|
173
|
-
l = ne(l);
|
174
|
-
const y = o(s, "js", f + ".js"), p = await Y(e), n = o(e, (p == null ? void 0 : p.configDir) || "", "salty.config.ts"), g = le(n), m = await ce(e);
|
175
|
-
await oe.build({
|
176
|
-
stdin: {
|
177
|
-
contents: l,
|
178
|
-
sourcefile: r.base,
|
179
|
-
resolveDir: r.dir,
|
180
|
-
loader: "tsx"
|
181
|
-
},
|
182
|
-
minify: !1,
|
183
|
-
treeShaking: !0,
|
184
|
-
bundle: !0,
|
185
|
-
outfile: y,
|
186
|
-
format: m,
|
187
|
-
target: ["node20"],
|
188
|
-
keepNames: !0,
|
189
|
-
external: g,
|
190
|
-
packages: "external",
|
191
|
-
plugins: [
|
192
|
-
{
|
193
|
-
name: "test",
|
194
|
-
setup: (F) => {
|
195
|
-
F.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (V) => {
|
196
|
-
const P = _(V.path, "utf8");
|
197
|
-
return { contents: ne(P), loader: "ts" };
|
198
|
-
});
|
199
|
-
}
|
200
|
-
}
|
201
|
-
]
|
202
|
-
});
|
203
|
-
const c = Date.now();
|
204
|
-
return await import(`${y}?t=${c}`);
|
205
|
-
}, Pe = async (e) => {
|
206
|
-
const t = await M(e), s = o(t, "cache/config-cache.json"), f = _(s, "utf8");
|
207
|
-
if (!f) throw new Error("Could not find config cache file");
|
208
|
-
return JSON.parse(f);
|
209
|
-
}, te = async (e) => {
|
210
|
-
const t = await Pe(e), s = await M(e), f = o(s, "salty.config.js"), i = Date.now(), { config: r } = await import(`${f}?t=${i}`);
|
211
|
-
return W(r, t);
|
212
|
-
}, de = () => {
|
213
|
-
try {
|
214
|
-
return process.env.NODE_ENV === "production";
|
215
|
-
} catch {
|
216
|
-
return !1;
|
217
|
-
}
|
218
|
-
}, We = async (e, t = de(), s = !0) => {
|
219
|
-
try {
|
220
|
-
const f = Date.now();
|
221
|
-
t ? K.info("Generating CSS in production mode! 🔥") : K.info("Generating CSS in development mode! 🚀");
|
222
|
-
const i = [], r = [], l = await M(e), y = o(l, "index.css");
|
223
|
-
s && (() => {
|
224
|
-
U(l) && me("rm -rf " + l), z(l, { recursive: !0 }), z(o(l, "css")), z(o(l, "types")), z(o(l, "js")), z(o(l, "cache"));
|
225
|
-
})();
|
226
|
-
const n = {
|
227
|
-
keyframes: [],
|
228
|
-
mediaQueries: [],
|
229
|
-
globalStyles: [],
|
230
|
-
variables: [],
|
231
|
-
templates: [],
|
232
|
-
components: [],
|
233
|
-
classNames: []
|
234
|
-
};
|
235
|
-
async function g(a) {
|
236
|
-
const w = ["node_modules", "saltygen"], h = ge(a);
|
237
|
-
if (h.isDirectory()) {
|
238
|
-
const b = ye(a);
|
239
|
-
if (w.some(($) => a.includes($))) return;
|
240
|
-
await Promise.all(b.map(($) => g(o(a, $))));
|
241
|
-
} else if (h.isFile() && X(a)) {
|
242
|
-
const d = await ee(e, a, l);
|
243
|
-
Object.entries(d).forEach(([$, u]) => {
|
244
|
-
u.isKeyframes ? n.keyframes.push({
|
245
|
-
value: u,
|
246
|
-
src: a,
|
247
|
-
name: $
|
248
|
-
}) : u.isMedia ? n.mediaQueries.push(u) : u.isGlobalDefine ? n.globalStyles.push(u) : u.isDefineVariables ? n.variables.push(u) : u.isDefineTemplates ? n.templates.push(u) : u.isClassName ? n.classNames.push({
|
249
|
-
value: u.factory,
|
250
|
-
src: a,
|
251
|
-
name: $
|
252
|
-
}) : u.generator && n.components.push({
|
253
|
-
value: u.generator,
|
254
|
-
src: a,
|
255
|
-
name: $
|
256
|
-
});
|
257
|
-
});
|
258
|
-
}
|
259
|
-
}
|
260
|
-
await g(e), await De(e, n);
|
261
|
-
const m = await te(e);
|
262
|
-
for (const a of n.keyframes) {
|
263
|
-
const { value: w } = a, h = `a_${w.animationName}.css`, b = `css/${h}`, d = o(l, b);
|
264
|
-
i.push(h), C(d, w.css);
|
265
|
-
}
|
266
|
-
const c = {};
|
267
|
-
for (const a of n.components) {
|
268
|
-
const { value: w, name: h, src: b } = a, d = w._withBuildContext({
|
269
|
-
name: h,
|
270
|
-
config: m,
|
271
|
-
prod: t
|
272
|
-
});
|
273
|
-
r[d.priority] || (r[d.priority] = []), r[d.priority].push(d.cssFileName);
|
274
|
-
const $ = `css/${d.cssFileName}`, u = o(l, $);
|
275
|
-
C(u, d.css), m.importStrategy === "component" && (c[b] ? c[b].push(d.cssFileName) : c[b] = [d.cssFileName]);
|
276
|
-
}
|
277
|
-
for (const a of n.classNames) {
|
278
|
-
const { value: w, src: h, name: b } = a, d = w._withBuildContext({
|
279
|
-
name: b,
|
280
|
-
prod: t
|
281
|
-
});
|
282
|
-
r[0].push(d.cssFileName);
|
283
|
-
const $ = `css/${d.cssFileName}`, u = o(l, $);
|
284
|
-
C(u, d.css), m.importStrategy === "component" && (c[h] ? c[h].push(d.cssFileName) : c[h] = [d.cssFileName]);
|
285
|
-
}
|
286
|
-
m.importStrategy === "component" && Object.entries(c).forEach(([a, w]) => {
|
287
|
-
const h = w.map((B) => `@import url('./${B}');`).join(`
|
288
|
-
`), b = I(a, 6), d = L(a), $ = H(d.name), u = o(l, `css/f_${$}-${b}.css`);
|
289
|
-
C(u, h);
|
290
|
-
});
|
291
|
-
const x = i.map((a) => `@import url('./css/${a}');`).join(`
|
292
|
-
`);
|
293
|
-
let k = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
294
|
-
|
295
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((a) => {
|
296
|
-
try {
|
297
|
-
return _(o(l, "css", a), "utf8").length > 0;
|
298
|
-
} catch {
|
299
|
-
return !1;
|
300
|
-
}
|
301
|
-
}).map((a) => `@import url('./css/${a}');`).join(`
|
302
|
-
`)}
|
303
|
-
${x}`;
|
304
|
-
if (m.importStrategy !== "component") {
|
305
|
-
const a = r.reduce((w, h, b) => {
|
306
|
-
const d = h.reduce((G, j) => {
|
307
|
-
var R;
|
308
|
-
const S = o(l, "css", j), T = _(S, "utf8"), N = ((R = /.*-([^-]+)-\d+.css/.exec(j)) == null ? void 0 : R.at(1)) || I(S, 6);
|
309
|
-
return G.includes(N) ? G : `${G}
|
310
|
-
/*start:${N}*/
|
311
|
-
${T}
|
312
|
-
/*end:${N}*/
|
313
|
-
`;
|
314
|
-
}, ""), $ = `l_${b}.css`, u = o(l, "css", $), B = `@layer l${b} { ${d}
|
315
|
-
}`;
|
316
|
-
return C(u, B), `${w}
|
317
|
-
@import url('./css/${$}');`;
|
318
|
-
}, "");
|
319
|
-
k += a;
|
320
|
-
}
|
321
|
-
C(y, k);
|
322
|
-
const D = Date.now() - f, J = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
|
323
|
-
K.info(`Generated CSS in ${D}ms! ${J}`);
|
324
|
-
} catch (f) {
|
325
|
-
console.error(f);
|
326
|
-
}
|
327
|
-
}, Ie = async (e, t) => {
|
328
|
-
try {
|
329
|
-
const s = await M(e);
|
330
|
-
if (X(t)) {
|
331
|
-
const i = [], r = await te(e), l = await ee(e, t, s);
|
332
|
-
if (Object.entries(l).forEach(([y, p]) => {
|
333
|
-
if (p.isKeyframes && p.css) {
|
334
|
-
const x = `css/${`a_${p.animationName}.css`}`, F = o(s, x);
|
335
|
-
C(F, p.css);
|
336
|
-
return;
|
337
|
-
}
|
338
|
-
if (p.isClassName) {
|
339
|
-
console.log("found className value", p);
|
340
|
-
const c = p.factory._withBuildContext({
|
341
|
-
name: y
|
342
|
-
});
|
343
|
-
i[0].push(c.cssFileName);
|
344
|
-
const x = `css/${c.cssFileName}`, F = o(s, x);
|
345
|
-
C(F, c.css), console.log(F, c.css);
|
346
|
-
}
|
347
|
-
if (!p.generator) return;
|
348
|
-
const n = p.generator._withBuildContext({
|
349
|
-
name: y,
|
350
|
-
config: r
|
351
|
-
}), g = `css/${n.cssFileName}`, m = o(s, g);
|
352
|
-
C(m, n.css), i[n.priority] || (i[n.priority] = []), i[n.priority].push(n.cssFileName);
|
353
|
-
}), console.log(i), r.importStrategy !== "component")
|
354
|
-
i.forEach((y, p) => {
|
355
|
-
const n = `l_${p}.css`, g = o(s, "css", n);
|
356
|
-
let m = _(g, "utf8");
|
357
|
-
y.forEach((c) => {
|
358
|
-
var P;
|
359
|
-
const x = o(s, "css", c), F = ((P = /.*-([^-]+)-\d+.css/.exec(c)) == null ? void 0 : P.at(1)) || I(x, 6);
|
360
|
-
if (!m.includes(F)) {
|
361
|
-
const k = _(x, "utf8"), O = `/*start:${F}*/
|
362
|
-
${k}
|
363
|
-
/*end:${F}*/
|
364
|
-
`;
|
365
|
-
m = `${m.replace(/\}$/, "")}
|
366
|
-
${O}
|
367
|
-
}`;
|
368
|
-
}
|
369
|
-
}), C(g, m);
|
370
|
-
});
|
371
|
-
else {
|
372
|
-
const y = i.flat().map((c) => `@import url('./${c}');`).join(`
|
373
|
-
`), p = I(t, 6), n = L(t), g = H(n.name), m = o(s, `css/f_${g}-${p}.css`);
|
374
|
-
C(m, y);
|
375
|
-
}
|
376
|
-
}
|
377
|
-
} catch (s) {
|
378
|
-
console.error(s);
|
379
|
-
}
|
380
|
-
}, Be = async (e, t, s = de()) => {
|
381
|
-
try {
|
382
|
-
const f = await M(e);
|
383
|
-
if (X(t)) {
|
384
|
-
const r = _(t, "utf8");
|
385
|
-
r.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== r && await he(t, r);
|
386
|
-
const y = await te(e), p = await ee(e, t, f);
|
387
|
-
let n = r;
|
388
|
-
if (Object.entries(p).forEach(([g, m]) => {
|
389
|
-
var $;
|
390
|
-
if (m.isKeyframes || !m.generator) return;
|
391
|
-
const c = m.generator._withBuildContext({
|
392
|
-
name: g,
|
393
|
-
config: y,
|
394
|
-
prod: s
|
395
|
-
}), x = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(r);
|
396
|
-
if (!x) return console.error("Could not find the original declaration");
|
397
|
-
const F = ($ = x.at(1)) == null ? void 0 : $.trim(), V = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(n);
|
398
|
-
if (!V) return console.error("Could not find the original declaration");
|
399
|
-
const { index: P } = V;
|
400
|
-
let k = !1;
|
401
|
-
const O = setTimeout(() => k = !0, 5e3);
|
402
|
-
let D = 0, J = !1, a = 0;
|
403
|
-
for (; !J && !k; ) {
|
404
|
-
const u = n[P + D];
|
405
|
-
u === "(" && a++, u === ")" && a--, a === 0 && u === ")" && (J = !0), D > n.length && (k = !0), D++;
|
406
|
-
}
|
407
|
-
if (!k) clearTimeout(O);
|
408
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
409
|
-
const w = P + D, h = n.slice(P, w), b = n, d = ` ${g} = styled(${F}, "${c.classNames}", ${JSON.stringify(c.props)});`;
|
410
|
-
n = n.replace(h, d), b === n && console.error("Minimize file failed to change content", { name: g, tagName: F });
|
411
|
-
}), y.importStrategy === "component") {
|
412
|
-
const g = I(t, 6), m = L(t);
|
413
|
-
n = `import '../../saltygen/css/${`f_${H(m.name)}-${g}.css`}';
|
414
|
-
${n}`;
|
415
|
-
}
|
416
|
-
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
417
|
-
}
|
418
|
-
} catch (f) {
|
419
|
-
console.error("Error in minimizeFile:", f);
|
420
|
-
}
|
421
|
-
};
|
422
|
-
export {
|
423
|
-
ze as a,
|
424
|
-
Ne as b,
|
425
|
-
De as c,
|
426
|
-
ee as d,
|
427
|
-
Ie as e,
|
428
|
-
We as g,
|
429
|
-
X as i,
|
430
|
-
K as l,
|
431
|
-
Be as m,
|
432
|
-
fe as s
|
433
|
-
};
|