@salty-css/core 0.0.1-alpha.143 → 0.0.1-alpha.144
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/{index-ZxtEz_YW.js → index-C_uFtnr7.js} +104 -104
- package/index-Cil3mKhl.cjs +30 -0
- package/package.json +1 -1
- package/index-Btco4x8K.cjs +0 -30
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-Cil3mKhl.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_uFtnr7.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-templates-DD4hQEpv.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-templates-DD4hQEpv.cjs");const e=require("../index-Cil3mKhl.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
@@ -5,7 +5,7 @@ import "path";
|
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
7
|
import "../parse-templates-CgZo0YA1.js";
|
8
|
-
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-
|
8
|
+
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-C_uFtnr7.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
@@ -84,77 +84,77 @@ const wt = {
|
|
84
84
|
externalModules: []
|
85
85
|
}, st = (t) => {
|
86
86
|
if (A.externalModules.length > 0) return A.externalModules;
|
87
|
-
const e = o(t, "salty.config.ts"),
|
88
|
-
if (!
|
89
|
-
const p =
|
87
|
+
const e = o(t, "salty.config.ts"), a = _(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
+
if (!a) return [];
|
89
|
+
const p = a[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
90
|
return A.externalModules = p, p;
|
91
91
|
}, H = (t) => o(t, "./saltygen"), nt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...nt, ...t].join("|")})\\.`), L = (t, e = []) => xt(e).test(t), Ct = async (t) => {
|
92
|
-
const e = H(t), r = o(t, "salty.config.ts"),
|
92
|
+
const e = H(t), r = o(t, "salty.config.ts"), a = o(e, "salty.config.js"), p = await tt(t), s = st(t);
|
93
93
|
await Y.build({
|
94
94
|
entryPoints: [r],
|
95
95
|
minify: !0,
|
96
96
|
treeShaking: !0,
|
97
97
|
bundle: !0,
|
98
|
-
outfile:
|
98
|
+
outfile: a,
|
99
99
|
format: p,
|
100
100
|
external: s
|
101
101
|
});
|
102
|
-
const
|
103
|
-
return
|
102
|
+
const g = Date.now(), { config: m } = await import(`${a}?t=${g}`);
|
103
|
+
return m;
|
104
104
|
}, Ft = async (t) => {
|
105
|
-
const e = await Ct(t), r = /* @__PURE__ */ new Set(),
|
105
|
+
const e = await Ct(t), r = /* @__PURE__ */ new Set(), a = (l, d = []) => l ? Object.entries(l).flatMap(([b, u]) => {
|
106
106
|
if (!u) return;
|
107
|
-
if (typeof u == "object") return
|
108
|
-
const M = et(b), v = W(b),
|
109
|
-
r.add(`"${
|
110
|
-
const
|
111
|
-
return `--${
|
107
|
+
if (typeof u == "object") return a(u, [...d, b]);
|
108
|
+
const M = et(b), v = W(b), P = [...d, M].join(".");
|
109
|
+
r.add(`"${P}"`);
|
110
|
+
const N = [...d.map(W), v].join("-"), { result: E } = yt(u);
|
111
|
+
return `--${N}: ${E};`;
|
112
112
|
}) : [], p = (l) => l ? Object.entries(l).flatMap(([d, b]) => {
|
113
|
-
const u =
|
113
|
+
const u = a(b);
|
114
114
|
return d === "base" ? u.join("") : `${d} { ${u.join("")} }`;
|
115
115
|
}) : [], s = (l) => l ? Object.entries(l).flatMap(([d, b]) => Object.entries(b).flatMap(([u, M]) => {
|
116
|
-
const v =
|
117
|
-
return `${
|
118
|
-
})) : [],
|
119
|
-
w(
|
116
|
+
const v = a(M, [d]), P = `.${d}-${u}, [data-${d}="${u}"]`, N = v.join("");
|
117
|
+
return `${P} { ${N} }`;
|
118
|
+
})) : [], g = a(e.variables), m = p(e.responsiveVariables), j = s(e.conditionalVariables), n = H(t), c = o(n, "css/_variables.css"), f = `:root { ${g.join("")} ${m.join("")} } ${j.join("")}`;
|
119
|
+
w(c, f);
|
120
120
|
const S = o(n, "css/_global.css"), h = U(e.global, "");
|
121
121
|
w(S, `@layer global { ${h} }`);
|
122
|
-
const x = o(n, "css/_reset.css"),
|
123
|
-
w(x, `@layer reset { ${
|
124
|
-
const i = o(n, "css/_templates.css"), $ = gt(e.templates),
|
122
|
+
const x = o(n, "css/_reset.css"), y = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : wt, T = U(y, "");
|
123
|
+
w(x, `@layer reset { ${T} }`);
|
124
|
+
const i = o(n, "css/_templates.css"), $ = gt(e.templates), k = mt(e.templates);
|
125
125
|
w(i, $);
|
126
|
-
const
|
126
|
+
const F = o(n, "types/css-tokens.d.ts"), D = `
|
127
127
|
// Variable types
|
128
128
|
type VariableTokens = ${[...r].join("|")};
|
129
129
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
130
|
|
131
131
|
// Template types
|
132
132
|
type TemplateTokens = {
|
133
|
-
${Object.entries(
|
133
|
+
${Object.entries(k).map(([l, d]) => `${l}?: ${d}`).join(`
|
134
134
|
`)}
|
135
135
|
}
|
136
136
|
`;
|
137
|
-
w(
|
137
|
+
w(F, D);
|
138
138
|
}, X = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, r) => {
|
139
139
|
if (/^['"`]/.test(r)) return e;
|
140
140
|
const p = new RegExp(`import[^;]*${r}[,\\s{][^;]*from\\s?([^{};]+);`);
|
141
141
|
if (!p.test(t)) return e;
|
142
|
-
const
|
143
|
-
if (
|
144
|
-
const
|
145
|
-
if (nt.some((n) =>
|
142
|
+
const g = p.exec(t);
|
143
|
+
if (g) {
|
144
|
+
const m = g.at(1);
|
145
|
+
if (nt.some((n) => m == null ? void 0 : m.includes(n))) return e;
|
146
146
|
}
|
147
147
|
return "styled('div',";
|
148
148
|
}), Z = async (t, e, r) => {
|
149
|
-
const
|
149
|
+
const a = J(e), p = o(r, "./temp");
|
150
150
|
K(p) || O(p);
|
151
151
|
const s = B(e);
|
152
|
-
let
|
153
|
-
|
154
|
-
const
|
152
|
+
let g = _(e, "utf8");
|
153
|
+
g = X(g);
|
154
|
+
const m = o(r, "js", a + ".js"), j = st(t), n = await tt(t);
|
155
155
|
await Y.build({
|
156
156
|
stdin: {
|
157
|
-
contents:
|
157
|
+
contents: g,
|
158
158
|
sourcefile: s.base,
|
159
159
|
resolveDir: s.dir,
|
160
160
|
loader: "tsx"
|
@@ -162,11 +162,11 @@ const wt = {
|
|
162
162
|
minify: !1,
|
163
163
|
treeShaking: !0,
|
164
164
|
bundle: !0,
|
165
|
-
outfile:
|
165
|
+
outfile: m,
|
166
166
|
format: n,
|
167
167
|
target: ["node20"],
|
168
168
|
keepNames: !0,
|
169
|
-
external:
|
169
|
+
external: j,
|
170
170
|
packages: "external",
|
171
171
|
plugins: [
|
172
172
|
{
|
@@ -180,10 +180,10 @@ const wt = {
|
|
180
180
|
}
|
181
181
|
]
|
182
182
|
});
|
183
|
-
const
|
184
|
-
return await import(`${
|
183
|
+
const c = Date.now();
|
184
|
+
return await import(`${m}?t=${c}`);
|
185
185
|
}, G = async (t) => {
|
186
|
-
const e = H(t), r = o(e, "salty.config.js"),
|
186
|
+
const e = H(t), r = o(e, "salty.config.js"), a = Date.now(), { config: p } = await import(`${r}?t=${a}`);
|
187
187
|
return p;
|
188
188
|
}, ot = () => {
|
189
189
|
try {
|
@@ -195,42 +195,42 @@ const wt = {
|
|
195
195
|
try {
|
196
196
|
const r = Date.now();
|
197
197
|
e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
|
198
|
-
const
|
198
|
+
const a = [], p = [], s = H(t), g = o(s, "index.css");
|
199
199
|
(() => {
|
200
200
|
K(s) && lt("rm -rf " + s), O(s), O(o(s, "css")), O(o(s, "types"));
|
201
201
|
})(), await Ft(t);
|
202
|
-
const
|
202
|
+
const j = await G(t);
|
203
203
|
async function n(i, $) {
|
204
|
-
const
|
205
|
-
if (
|
204
|
+
const k = ["node_modules", "saltygen"], F = pt(i);
|
205
|
+
if (F.isDirectory()) {
|
206
206
|
const V = ft(i);
|
207
|
-
if (
|
207
|
+
if (k.some((l) => i.includes(l))) return;
|
208
208
|
await Promise.all(V.map((l) => n(o(i, l), o($, l))));
|
209
|
-
} else if (
|
209
|
+
} else if (F.isFile() && L(i)) {
|
210
210
|
const D = await Z(t, i, s), l = [];
|
211
|
-
Object.entries(D).forEach(([
|
212
|
-
if (
|
213
|
-
const q = `a_${
|
214
|
-
|
211
|
+
Object.entries(D).forEach(([P, N]) => {
|
212
|
+
if (N.isKeyframes && N.css) {
|
213
|
+
const q = `a_${N.animationName}.css`, ct = `css/${q}`, it = o(s, ct);
|
214
|
+
a.push(q), w(it, N.css);
|
215
215
|
return;
|
216
216
|
}
|
217
|
-
if (!
|
218
|
-
const E =
|
219
|
-
name:
|
220
|
-
config:
|
217
|
+
if (!N.generator) return;
|
218
|
+
const E = N.generator._withBuildContext({
|
219
|
+
name: P,
|
220
|
+
config: j,
|
221
221
|
prod: e
|
222
222
|
});
|
223
223
|
p[E.priority] || (p[E.priority] = []), p[E.priority].push(E.cssFileName), l.push(E.cssFileName);
|
224
224
|
const rt = `css/${E.cssFileName}`, at = o(s, rt);
|
225
225
|
w(at, E.css);
|
226
226
|
});
|
227
|
-
const d = l.map((
|
227
|
+
const d = l.map((P) => `@import url('./${P}');`).join(`
|
228
228
|
`), b = J(i, 6), u = B(i), M = W(u.name), v = o(s, `css/f_${M}-${b}.css`);
|
229
229
|
w(v, d);
|
230
230
|
}
|
231
231
|
}
|
232
232
|
await n(t, s);
|
233
|
-
const
|
233
|
+
const c = a.map((i) => `@import url('./css/${i}');`).join(`
|
234
234
|
`);
|
235
235
|
let x = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
236
236
|
|
@@ -242,61 +242,61 @@ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((i) =
|
|
242
242
|
}
|
243
243
|
}).map((i) => `@import url('./css/${i}');`).join(`
|
244
244
|
`)}
|
245
|
-
${
|
246
|
-
if (
|
247
|
-
const i = p.reduce(($,
|
248
|
-
const V =
|
249
|
-
const M = o(s, "css", u), v = _(M, "utf8"),
|
245
|
+
${c}`;
|
246
|
+
if (j.importStrategy !== "component") {
|
247
|
+
const i = p.reduce(($, k, F) => {
|
248
|
+
const V = k.reduce((b, u) => {
|
249
|
+
const M = o(s, "css", u), v = _(M, "utf8"), P = J(M, 6);
|
250
250
|
return `${b}
|
251
|
-
/*start:${
|
251
|
+
/*start:${P}*/
|
252
252
|
${v}
|
253
|
-
/*end:${
|
253
|
+
/*end:${P}*/
|
254
254
|
`;
|
255
|
-
}, ""), D = `l_${
|
255
|
+
}, ""), D = `l_${F}.css`, l = o(s, "css", D), d = `@layer l${F} { ${V}
|
256
256
|
}`;
|
257
257
|
return w(l, d), `${$}
|
258
258
|
@import url('./css/${D}');`;
|
259
259
|
}, "");
|
260
260
|
x += i;
|
261
261
|
}
|
262
|
-
w(
|
263
|
-
const
|
264
|
-
z.info(`Generated CSS in ${
|
262
|
+
w(g, x);
|
263
|
+
const y = Date.now() - r, T = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
|
264
|
+
z.info(`Generated CSS in ${y}ms! ${T}`);
|
265
265
|
} catch (r) {
|
266
266
|
console.error(r);
|
267
267
|
}
|
268
268
|
}, Vt = async (t, e) => {
|
269
269
|
try {
|
270
|
-
const r = o(t, "./saltygen"),
|
270
|
+
const r = o(t, "./saltygen"), a = o(r, "index.css");
|
271
271
|
if (L(e)) {
|
272
|
-
const s = [],
|
273
|
-
Object.entries(
|
274
|
-
if (
|
275
|
-
const C = `css/${`a_${
|
276
|
-
w(
|
272
|
+
const s = [], g = await G(t), m = await Z(t, e, r);
|
273
|
+
Object.entries(m).forEach(([n, c]) => {
|
274
|
+
if (c.isKeyframes && c.css) {
|
275
|
+
const C = `css/${`a_${c.animationName}.css`}`, y = o(r, C);
|
276
|
+
w(y, c.css);
|
277
277
|
return;
|
278
278
|
}
|
279
|
-
if (!
|
280
|
-
const f =
|
279
|
+
if (!c.generator) return;
|
280
|
+
const f = c.generator._withBuildContext({
|
281
281
|
name: n,
|
282
|
-
config:
|
282
|
+
config: g
|
283
283
|
}), S = `css/${f.cssFileName}`, h = o(r, S);
|
284
284
|
w(h, f.css), s[f.priority] || (s[f.priority] = []), s[f.priority].push(f.cssFileName);
|
285
285
|
});
|
286
|
-
const
|
286
|
+
const j = _(a, "utf8").split(`
|
287
287
|
`);
|
288
|
-
|
289
|
-
const f = `l_${
|
288
|
+
g.importStrategy !== "component" && s.forEach((n, c) => {
|
289
|
+
const f = `l_${c}.css`, S = o(r, "css", f);
|
290
290
|
let h = _(S, "utf8");
|
291
291
|
n.forEach((x) => {
|
292
|
-
const C = o(r, "css", x),
|
293
|
-
if (
|
294
|
-
const i = _(C, "utf8"), $ = J(C, 6),
|
292
|
+
const C = o(r, "css", x), y = J(C, 6);
|
293
|
+
if (!h.includes(y)) {
|
294
|
+
const i = _(C, "utf8"), $ = J(C, 6), k = `/*start:${$}*/
|
295
295
|
${i}
|
296
296
|
/*end:${$}*/
|
297
297
|
`;
|
298
298
|
h = `${h.replace(/\}$/, "")}
|
299
|
-
${
|
299
|
+
${k}
|
300
300
|
}`;
|
301
301
|
}
|
302
302
|
}), w(S, h);
|
@@ -307,44 +307,44 @@ ${P}
|
|
307
307
|
}
|
308
308
|
}, vt = async (t, e, r = ot()) => {
|
309
309
|
try {
|
310
|
-
const
|
310
|
+
const a = o(t, "./saltygen");
|
311
311
|
if (L(e)) {
|
312
312
|
const s = _(e, "utf8");
|
313
|
-
s.replace(/^(?!export\s)const\s.*/gm, (
|
314
|
-
const
|
313
|
+
s.replace(/^(?!export\s)const\s.*/gm, (c) => `export ${c}`) !== s && await ut(e, s);
|
314
|
+
const m = await G(t), j = await Z(t, e, a);
|
315
315
|
let n = s;
|
316
|
-
if (Object.entries(
|
316
|
+
if (Object.entries(j).forEach(([c, f]) => {
|
317
317
|
var b;
|
318
318
|
if (f.isKeyframes || !f.generator) return;
|
319
319
|
const S = f.generator._withBuildContext({
|
320
|
-
name:
|
321
|
-
config:
|
320
|
+
name: c,
|
321
|
+
config: m,
|
322
322
|
prod: r
|
323
|
-
}), h = new RegExp(`\\s${
|
323
|
+
}), h = new RegExp(`\\s${c}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
324
324
|
if (!h) return console.error("Could not find the original declaration");
|
325
|
-
const x = (b = h.at(1)) == null ? void 0 : b.trim(), C = new RegExp(`\\s${
|
325
|
+
const x = (b = h.at(1)) == null ? void 0 : b.trim(), C = new RegExp(`\\s${c}[=\\s]+styled\\(`, "g").exec(n);
|
326
326
|
if (!C) return console.error("Could not find the original declaration");
|
327
|
-
const { index:
|
328
|
-
let
|
329
|
-
const i = setTimeout(() =>
|
330
|
-
let $ = 0,
|
331
|
-
for (; !
|
332
|
-
const u = n[
|
333
|
-
u === "(" &&
|
327
|
+
const { index: y } = C;
|
328
|
+
let T = !1;
|
329
|
+
const i = setTimeout(() => T = !0, 5e3);
|
330
|
+
let $ = 0, k = !1, F = 0;
|
331
|
+
for (; !k && !T; ) {
|
332
|
+
const u = n[y + $];
|
333
|
+
u === "(" && F++, u === ")" && F--, F === 0 && u === ")" && (k = !0), $ > n.length && (T = !0), $++;
|
334
334
|
}
|
335
|
-
if (!
|
335
|
+
if (!T) clearTimeout(i);
|
336
336
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
337
|
-
const V =
|
338
|
-
n = n.replace(D, d), l === n && console.error("Minimize file failed to change content", { name:
|
339
|
-
}),
|
340
|
-
const
|
341
|
-
n = `import '../../saltygen/css/${`f_${W(f.name)}-${
|
337
|
+
const V = y + $, D = n.slice(y, V), l = n, d = ` ${c} = styled(${x}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
338
|
+
n = n.replace(D, d), l === n && console.error("Minimize file failed to change content", { name: c, tagName: x });
|
339
|
+
}), m.importStrategy === "component") {
|
340
|
+
const c = J(e, 6), f = B(e);
|
341
|
+
n = `import '../../saltygen/css/${`f_${W(f.name)}-${c}.css`}';
|
342
342
|
${n}`;
|
343
343
|
}
|
344
344
|
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
345
345
|
}
|
346
|
-
} catch (
|
347
|
-
console.error("Error in minimizeFile:",
|
346
|
+
} catch (a) {
|
347
|
+
console.error("Error in minimizeFile:", a);
|
348
348
|
}
|
349
349
|
};
|
350
350
|
export {
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";const ae=require("esbuild"),le=require("child_process"),N=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),H=require("winston");var W=typeof document<"u"?document.currentScript:null;function de(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 U=de(ae),X=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:X(o.join(e,".."))},pe=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},fe=async e=>{const t=await pe(e);if(t)return t.type};let V;const Y=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:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-Cil3mKhl.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},z=H.createLogger({level:"debug",format:H.format.combine(H.format.colorize(),H.format.cli()),transports:[new H.transports.Console({})]}),ue=e=>{z.error(e)};function Q(e){return e?typeof e!="string"?Q(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 ye={"*, *::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"}},L={externalModules:[]},ee=e=>{if(L.externalModules.length>0)return L.externalModules;const t=o.join(e,"salty.config.ts"),c=i.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!c)return[];const p=c[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return L.externalModules=p,p},J=e=>o.join(e,"./saltygen"),A=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...A,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ge=async e=>{const t=J(e),s=o.join(e,"salty.config.ts"),c=o.join(t,"salty.config.js"),p=await Y(e),n=ee(e);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:c,format:p,external:n});const g=Date.now(),{config:m}=await import(`${c}?t=${g}`);return m},se=async e=>{const t=await ge(e),s=new Set,c=(d,u=[])=>d?Object.entries(d).flatMap(([j,y])=>{if(!y)return;if(typeof y=="object")return c(y,[...u,j]);const M=Q(j),O=N.dashCase(j),P=[...u,M].join(".");s.add(`"${P}"`);const T=[...u.map(N.dashCase),O].join("-"),{result:E}=v.parseValueTokens(y);return`--${T}: ${E};`}):[],p=d=>d?Object.entries(d).flatMap(([u,j])=>{const y=c(j);return u==="base"?y.join(""):`${u} { ${y.join("")} }`}):[],n=d=>d?Object.entries(d).flatMap(([u,j])=>Object.entries(j).flatMap(([y,M])=>{const O=c(M,[u]),P=`.${u}-${y}, [data-${u}="${y}"]`,T=O.join("");return`${P} { ${T} }`})):[],g=c(t.variables),m=p(t.responsiveVariables),x=n(t.conditionalVariables),r=J(e),a=o.join(r,"css/_variables.css"),f=`:root { ${g.join("")} ${m.join("")} } ${x.join("")}`;i.writeFileSync(a,f);const F=o.join(r,"css/_global.css"),S=v.parseStyles(t.global,"");i.writeFileSync(F,`@layer global { ${S} }`);const b=o.join(r,"css/_reset.css"),h=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ye,D=v.parseStyles(h,"");i.writeFileSync(b,`@layer reset { ${D} }`);const l=o.join(r,"css/_templates.css"),$=v.parseTemplates(t.templates),k=v.getTemplateTypes(t.templates);i.writeFileSync(l,$);const C=o.join(r,"types/css-tokens.d.ts"),_=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...s].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(k).map(([d,u])=>`${d}?: ${u}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;i.writeFileSync(C,_)},Z=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const p=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!p.test(e))return t;const g=p.exec(e);if(g){const m=g.at(1);if(A.some(r=>m==null?void 0:m.includes(r)))return t}return"styled('div',"}),q=async(e,t,s)=>{const c=N.toHash(t),p=o.join(s,"./temp");i.existsSync(p)||i.mkdirSync(p);const n=o.parse(t);let g=i.readFileSync(t,"utf8");g=Z(g);const m=o.join(s,"js",c+".js"),x=ee(e),r=await Y(e);await U.build({stdin:{contents:g,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:r,target:["node20"],keepNames:!0,external:x,packages:"external",plugins:[{name:"test",setup:F=>{F.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},S=>{const b=i.readFileSync(S.path,"utf8");return{contents:Z(b),loader:"ts"}})}}]});const a=Date.now();return await import(`${m}?t=${a}`)},B=async e=>{const t=J(e),s=o.join(t,"salty.config.js"),c=Date.now(),{config:p}=await import(`${s}?t=${c}`);return p},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const s=Date.now();t?z.info("Generating CSS in production mode! 🔥"):z.info("Generating CSS in development mode! 🚀");const c=[],p=[],n=J(e),g=o.join(n,"index.css");(()=>{i.existsSync(n)&&le.execSync("rm -rf "+n),i.mkdirSync(n),i.mkdirSync(o.join(n,"css")),i.mkdirSync(o.join(n,"types"))})(),await se(e);const x=await B(e);async function r(l,$){const k=["node_modules","saltygen"],C=i.statSync(l);if(C.isDirectory()){const R=i.readdirSync(l);if(k.some(d=>l.includes(d)))return;await Promise.all(R.map(d=>r(o.join(l,d),o.join($,d))))}else if(C.isFile()&&I(l)){const _=await q(e,l,n),d=[];Object.entries(_).forEach(([P,T])=>{if(T.isKeyframes&&T.css){const K=`a_${T.animationName}.css`,ie=`css/${K}`,ce=o.join(n,ie);c.push(K),i.writeFileSync(ce,T.css);return}if(!T.generator)return;const E=T.generator._withBuildContext({name:P,config:x,prod:t});p[E.priority]||(p[E.priority]=[]),p[E.priority].push(E.cssFileName),d.push(E.cssFileName);const oe=`css/${E.cssFileName}`,re=o.join(n,oe);i.writeFileSync(re,E.css)});const u=d.map(P=>`@import url('./${P}');`).join(`
|
12
|
+
`),j=N.toHash(l,6),y=o.parse(l),M=N.dashCase(y.name),O=o.join(n,`css/f_${M}-${j}.css`);i.writeFileSync(O,u)}}await r(e,n);const a=c.map(l=>`@import url('./css/${l}');`).join(`
|
13
|
+
`);let b=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(l=>{try{return i.readFileSync(o.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
16
|
+
`)}
|
17
|
+
${a}`;if(x.importStrategy!=="component"){const l=p.reduce(($,k,C)=>{const R=k.reduce((j,y)=>{const M=o.join(n,"css",y),O=i.readFileSync(M,"utf8"),P=N.toHash(M,6);return`${j}
|
18
|
+
/*start:${P}*/
|
19
|
+
${O}
|
20
|
+
/*end:${P}*/
|
21
|
+
`},""),_=`l_${C}.css`,d=o.join(n,"css",_),u=`@layer l${C} { ${R}
|
22
|
+
}`;return i.writeFileSync(d,u),`${$}
|
23
|
+
@import url('./css/${_}');`},"");b+=l}i.writeFileSync(g,b);const h=Date.now()-s,D=h<200?"🔥":h<500?"🚀":h<1e3?"🎉":h<2e3?"🚗":h<5e3?"🤔":"🥴";z.info(`Generated CSS in ${h}ms! ${D}`)}catch(s){console.error(s)}},he=async(e,t)=>{try{const s=o.join(e,"./saltygen"),c=o.join(s,"index.css");if(I(t)){const n=[],g=await B(e),m=await q(e,t,s);Object.entries(m).forEach(([r,a])=>{if(a.isKeyframes&&a.css){const w=`css/${`a_${a.animationName}.css`}`,h=o.join(s,w);i.writeFileSync(h,a.css);return}if(!a.generator)return;const f=a.generator._withBuildContext({name:r,config:g}),F=`css/${f.cssFileName}`,S=o.join(s,F);i.writeFileSync(S,f.css),n[f.priority]||(n[f.priority]=[]),n[f.priority].push(f.cssFileName)});const x=i.readFileSync(c,"utf8").split(`
|
24
|
+
`);g.importStrategy!=="component"&&n.forEach((r,a)=>{const f=`l_${a}.css`,F=o.join(s,"css",f);let S=i.readFileSync(F,"utf8");r.forEach(b=>{const w=o.join(s,"css",b),h=N.toHash(w,6);if(!S.includes(h)){const l=i.readFileSync(w,"utf8"),$=N.toHash(w,6),k=`/*start:${$}*/
|
25
|
+
${l}
|
26
|
+
/*end:${$}*/
|
27
|
+
`;S=`${S.replace(/\}$/,"")}
|
28
|
+
${k}
|
29
|
+
}`}}),i.writeFileSync(F,S)})}}catch(s){console.error(s)}},Se=async(e,t,s=ne())=>{try{const c=o.join(e,"./saltygen");if(I(t)){const n=i.readFileSync(t,"utf8");n.replace(/^(?!export\s)const\s.*/gm,a=>`export ${a}`)!==n&&await G.writeFile(t,n);const m=await B(e),x=await q(e,t,c);let r=n;if(Object.entries(x).forEach(([a,f])=>{var j;if(f.isKeyframes||!f.generator)return;const F=f.generator._withBuildContext({name:a,config:m,prod:s}),S=new RegExp(`\\s${a}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(n);if(!S)return console.error("Could not find the original declaration");const b=(j=S.at(1))==null?void 0:j.trim(),w=new RegExp(`\\s${a}[=\\s]+styled\\(`,"g").exec(r);if(!w)return console.error("Could not find the original declaration");const{index:h}=w;let D=!1;const l=setTimeout(()=>D=!0,5e3);let $=0,k=!1,C=0;for(;!k&&!D;){const y=r[h+$];y==="("&&C++,y===")"&&C--,C===0&&y===")"&&(k=!0),$>r.length&&(D=!0),$++}if(!D)clearTimeout(l);else throw new Error("Failed to find the end of the styled call and timed out");const R=h+$,_=r.slice(h,R),d=r,u=` ${a} = styled(${b}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(_,u),d===r&&console.error("Minimize file failed to change content",{name:a,tagName:b})}),m.importStrategy==="component"){const a=N.toHash(t,6),f=o.parse(t);r=`import '../../saltygen/css/${`f_${N.dashCase(f.name)}-${a}.css`}';
|
30
|
+
${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=se;exports.generateCss=me;exports.generateFile=he;exports.isSaltyFile=I;exports.logError=ue;exports.logger=z;exports.minimizeFile=Se;exports.saltyFileExtensions=A;exports.saltyFileRegExp=te;
|
package/package.json
CHANGED
package/index-Btco4x8K.cjs
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
"use strict";const ae=require("esbuild"),le=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),H=require("winston");var W=typeof document<"u"?document.currentScript:null;function pe(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 U=pe(ae),X=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:X(o.join(e,".."))},de=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},fe=async e=>{const t=await de(e);if(t)return t.type};let V;const Y=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:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-Btco4x8K.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},z=H.createLogger({level:"debug",format:H.format.combine(H.format.colorize(),H.format.cli()),transports:[new H.transports.Console({})]}),ue=e=>{z.error(e)};function Q(e){return e?typeof e!="string"?Q(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 ye={"*, *::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"}},L={externalModules:[]},ee=e=>{if(L.externalModules.length>0)return L.externalModules;const t=o.join(e,"salty.config.ts"),c=i.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!c)return[];const d=c[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return L.externalModules=d,d},J=e=>o.join(e,"./saltygen"),A=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...A,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ge=async e=>{const t=J(e),s=o.join(e,"salty.config.ts"),c=o.join(t,"salty.config.js"),d=await Y(e),n=ee(e);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:c,format:d,external:n});const m=Date.now(),{config:h}=await import(`${c}?t=${m}`);return h},se=async e=>{const t=await ge(e),s=new Set,c=(p,u=[])=>p?Object.entries(p).flatMap(([j,y])=>{if(!y)return;if(typeof y=="object")return c(y,[...u,j]);const M=Q(j),O=D.dashCase(j),T=[...u,M].join(".");s.add(`"${T}"`);const N=[...u.map(D.dashCase),O].join("-"),{result:E}=v.parseValueTokens(y);return`--${N}: ${E};`}):[],d=p=>p?Object.entries(p).flatMap(([u,j])=>{const y=c(j);return u==="base"?y.join(""):`${u} { ${y.join("")} }`}):[],n=p=>p?Object.entries(p).flatMap(([u,j])=>Object.entries(j).flatMap(([y,M])=>{const O=c(M,[u]),T=`.${u}-${y}, [data-${u}="${y}"]`,N=O.join("");return`${T} { ${N} }`})):[],m=c(t.variables),h=d(t.responsiveVariables),k=n(t.conditionalVariables),r=J(e),a=o.join(r,"css/_variables.css"),f=`:root { ${m.join("")} ${h.join("")} } ${k.join("")}`;i.writeFileSync(a,f);const F=o.join(r,"css/_global.css"),S=v.parseStyles(t.global,"");i.writeFileSync(F,`@layer global { ${S} }`);const b=o.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ye,C=v.parseStyles(g,"");i.writeFileSync(b,`@layer reset { ${C} }`);const l=o.join(r,"css/_templates.css"),$=v.parseTemplates(t.templates),P=v.getTemplateTypes(t.templates);i.writeFileSync(l,$);const x=o.join(r,"types/css-tokens.d.ts"),_=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...s].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(P).map(([p,u])=>`${p}?: ${u}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;i.writeFileSync(x,_)},Z=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const d=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!d.test(e))return t;const m=d.exec(e);if(m){const h=m.at(1);if(A.some(r=>h==null?void 0:h.includes(r)))return t}return"styled('div',"}),q=async(e,t,s)=>{const c=D.toHash(t),d=o.join(s,"./temp");i.existsSync(d)||i.mkdirSync(d);const n=o.parse(t);let m=i.readFileSync(t,"utf8");m=Z(m);const h=o.join(s,"js",c+".js"),k=ee(e),r=await Y(e);await U.build({stdin:{contents:m,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:r,target:["node20"],keepNames:!0,external:k,packages:"external",plugins:[{name:"test",setup:F=>{F.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},S=>{const b=i.readFileSync(S.path,"utf8");return{contents:Z(b),loader:"ts"}})}}]});const a=Date.now();return await import(`${h}?t=${a}`)},B=async e=>{const t=J(e),s=o.join(t,"salty.config.js"),c=Date.now(),{config:d}=await import(`${s}?t=${c}`);return d},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const s=Date.now();t?z.info("Generating CSS in production mode! 🔥"):z.info("Generating CSS in development mode! 🚀");const c=[],d=[],n=J(e),m=o.join(n,"index.css");(()=>{i.existsSync(n)&&le.execSync("rm -rf "+n),i.mkdirSync(n),i.mkdirSync(o.join(n,"css")),i.mkdirSync(o.join(n,"types"))})(),await se(e);const k=await B(e);async function r(l,$){const P=["node_modules","saltygen"],x=i.statSync(l);if(x.isDirectory()){const R=i.readdirSync(l);if(P.some(p=>l.includes(p)))return;await Promise.all(R.map(p=>r(o.join(l,p),o.join($,p))))}else if(x.isFile()&&I(l)){const _=await q(e,l,n),p=[];Object.entries(_).forEach(([T,N])=>{if(N.isKeyframes&&N.css){const K=`a_${N.animationName}.css`,ie=`css/${K}`,ce=o.join(n,ie);c.push(K),i.writeFileSync(ce,N.css);return}if(!N.generator)return;const E=N.generator._withBuildContext({name:T,config:k,prod:t});d[E.priority]||(d[E.priority]=[]),d[E.priority].push(E.cssFileName),p.push(E.cssFileName);const oe=`css/${E.cssFileName}`,re=o.join(n,oe);i.writeFileSync(re,E.css)});const u=p.map(T=>`@import url('./${T}');`).join(`
|
12
|
-
`),j=D.toHash(l,6),y=o.parse(l),M=D.dashCase(y.name),O=o.join(n,`css/f_${M}-${j}.css`);i.writeFileSync(O,u)}}await r(e,n);const a=c.map(l=>`@import url('./css/${l}');`).join(`
|
13
|
-
`);let b=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(l=>{try{return i.readFileSync(o.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
16
|
-
`)}
|
17
|
-
${a}`;if(k.importStrategy!=="component"){const l=d.reduce(($,P,x)=>{const R=P.reduce((j,y)=>{const M=o.join(n,"css",y),O=i.readFileSync(M,"utf8"),T=D.toHash(M,6);return`${j}
|
18
|
-
/*start:${T}*/
|
19
|
-
${O}
|
20
|
-
/*end:${T}*/
|
21
|
-
`},""),_=`l_${x}.css`,p=o.join(n,"css",_),u=`@layer l${x} { ${R}
|
22
|
-
}`;return i.writeFileSync(p,u),`${$}
|
23
|
-
@import url('./css/${_}');`},"");b+=l}i.writeFileSync(m,b);const g=Date.now()-s,C=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";z.info(`Generated CSS in ${g}ms! ${C}`)}catch(s){console.error(s)}},he=async(e,t)=>{try{const s=o.join(e,"./saltygen"),c=o.join(s,"index.css");if(I(t)){const n=[],m=await B(e),h=await q(e,t,s);Object.entries(h).forEach(([r,a])=>{if(a.isKeyframes&&a.css){const w=`css/${`a_${a.animationName}.css`}`,g=o.join(s,w);i.writeFileSync(g,a.css);return}if(!a.generator)return;const f=a.generator._withBuildContext({name:r,config:m}),F=`css/${f.cssFileName}`,S=o.join(s,F);i.writeFileSync(S,f.css),n[f.priority]||(n[f.priority]=[]),n[f.priority].push(f.cssFileName)});const k=i.readFileSync(c,"utf8").split(`
|
24
|
-
`);m.importStrategy!=="component"&&n.forEach((r,a)=>{const f=`l_${a}.css`,F=o.join(s,"css",f);let S=i.readFileSync(F,"utf8");r.forEach(b=>{const w=o.join(s,"css",b),g=D.toHash(w,6),C=S.includes(g);if(console.log({layer:a,filepath:w,filepathHash:g,found:C}),!C){const l=i.readFileSync(w,"utf8"),$=D.toHash(w,6),P=`/*start:${$}*/
|
25
|
-
${l}
|
26
|
-
/*end:${$}*/
|
27
|
-
`;S=`${S.replace(/\}$/,"")}
|
28
|
-
${P}
|
29
|
-
}`}}),i.writeFileSync(F,S)})}}catch(s){console.error(s)}},Se=async(e,t,s=ne())=>{try{const c=o.join(e,"./saltygen");if(I(t)){const n=i.readFileSync(t,"utf8");n.replace(/^(?!export\s)const\s.*/gm,a=>`export ${a}`)!==n&&await G.writeFile(t,n);const h=await B(e),k=await q(e,t,c);let r=n;if(Object.entries(k).forEach(([a,f])=>{var j;if(f.isKeyframes||!f.generator)return;const F=f.generator._withBuildContext({name:a,config:h,prod:s}),S=new RegExp(`\\s${a}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(n);if(!S)return console.error("Could not find the original declaration");const b=(j=S.at(1))==null?void 0:j.trim(),w=new RegExp(`\\s${a}[=\\s]+styled\\(`,"g").exec(r);if(!w)return console.error("Could not find the original declaration");const{index:g}=w;let C=!1;const l=setTimeout(()=>C=!0,5e3);let $=0,P=!1,x=0;for(;!P&&!C;){const y=r[g+$];y==="("&&x++,y===")"&&x--,x===0&&y===")"&&(P=!0),$>r.length&&(C=!0),$++}if(!C)clearTimeout(l);else throw new Error("Failed to find the end of the styled call and timed out");const R=g+$,_=r.slice(g,R),p=r,u=` ${a} = styled(${b}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(_,u),p===r&&console.error("Minimize file failed to change content",{name:a,tagName:b})}),h.importStrategy==="component"){const a=D.toHash(t,6),f=o.parse(t);r=`import '../../saltygen/css/${`f_${D.dashCase(f.name)}-${a}.css`}';
|
30
|
-
${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=se;exports.generateCss=me;exports.generateFile=he;exports.isSaltyFile=I;exports.logError=ue;exports.logger=z;exports.minimizeFile=Se;exports.saltyFileExtensions=A;exports.saltyFileRegExp=te;
|