@salty-css/core 0.0.1-alpha.85 → 0.0.1-alpha.86
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.d.ts +1 -1
- package/compiler/index.js +1 -1
- package/generator/index.cjs +1 -1
- package/generator/index.js +23 -19
- package/generator/style-generator.d.ts +5 -0
- package/index-BGaLvshf.js +232 -0
- package/index-BKoD9apd.cjs +11 -0
- package/package.json +1 -1
- package/index-CVMlMbWG.js +0 -230
- package/index-DXEpY0wo.cjs +0 -11
package/bin/main.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("commander"),L=require("fs"),s=require("fs/promises"),n=require("path"),ie=require("ejs"),t=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("commander"),L=require("fs"),s=require("fs/promises"),n=require("path"),ie=require("ejs"),t=require("../index-BKoD9apd.cjs"),se=require("../pascal-case-iWoaJWwT.cjs"),oe=require("child_process"),ae=require("ora");var W=typeof document<"u"?document.currentScript:null;const Y=g=>new Promise((h,C)=>{oe.exec(g,x=>{if(x)return C(x);h()})}),N=async(...g)=>{const h=g.map(F=>F.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),C=ae(`Installing packages: ${h}`).start(),x=g.join(" ");await Y(`npm install ${x}`),C.succeed(`Installed packages: ${h}`)},re=()=>L.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function P(g){try{if(!re())return;await Y(`./node_modules/.bin/prettier --write "${g}"`),t.logger.info(`Formatted ${g} with Prettier`)}catch(h){t.logger.error(`Error formatting ${g} with Prettier:`,h)}}async function ce(){const g=new ne.Command;g.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const h={"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"))},C=async(i,a)=>{const{default:c}=await h[i],f=ie.render(c,a);return{fileName:i,content:f}},x=async()=>{const i=n.join(process.cwd(),".saltyrc");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},F=n.join(process.cwd(),"package.json"),D=async(i=F)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Z=async(i,a=F)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},M=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("bin/main.cjs",document.baseURI).href);return D(i)},B=await(async()=>(await x()).defaultProject)(),k=await M(),I={core:`@salty-css/core@${k.version}`,react:`@salty-css/react@${k.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${k.version}`,vite:`@salty-css/vite@${k.version}`,next:`@salty-css/next@${k.version}`},R=i=>{const a=i==="."?"":i,c=process.cwd();return n.join(c,a)};g.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 D().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:c=i,cssFile:f,skipInstall:u}=this.opts();if(!c)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");u||await N(I.core,I.react);const p=process.cwd(),l=R(c),b=await Promise.all([C("salty.config.ts"),C("saltygen/index.css")]);await s.mkdir(l,{recursive:!0});const m=b.map(async({fileName:e,content:o})=>{const d=n.join(l,e);if(await s.readFile(d,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+d);return}const S=e.split("/").slice(0,-1).join("/");S&&await s.mkdir(n.join(l,S),{recursive:!0}),t.logger.info("Creating file: "+d),await s.writeFile(d,o),await P(d)});await Promise.all(m);const E=n.relative(p,l)||".",j=n.join(p,".saltyrc"),r=await s.readFile(j,"utf-8").catch(()=>{});if(r===void 0){t.logger.info("Creating file: "+j);const o=JSON.stringify({defaultProject:E,projects:[E]},null,2);await s.writeFile(j,o)}else{t.logger.info("Edit file: "+j);const e=JSON.parse(r),o=new Set((e==null?void 0:e.projects)||[]);o.add(E),e.projects=[...o];const d=JSON.stringify(e,null,2);await s.writeFile(j,d)}const w=n.join(p,".gitignore"),A=await s.readFile(w,"utf-8").catch(()=>{});A!==void 0&&(A.includes("saltygen")||(t.logger.info("Edit file: "+w),await s.writeFile(w,A+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,7 +3,7 @@ import { existsSync as G } from "fs";
|
|
3
3
|
import { mkdir as V, readFile as m, writeFile as h } from "fs/promises";
|
4
4
|
import { join as a, relative as z, parse as rt, format as et } from "path";
|
5
5
|
import { render as ct } from "ejs";
|
6
|
-
import { l as e, a as w, g as lt } from "../index-
|
6
|
+
import { l as e, a as w, g as lt } from "../index-BGaLvshf.js";
|
7
7
|
import { p as dt } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as pt } from "child_process";
|
9
9
|
import ft 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-DKzpenwY.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DVK3iZIl.cjs");const e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-DKzpenwY.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DVK3iZIl.cjs");const e=require("../index-BKoD9apd.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.d.ts
CHANGED
@@ -13,4 +13,4 @@ export declare const compileSaltyFile: (dirname: string, sourceFilePath: string,
|
|
13
13
|
}>;
|
14
14
|
export declare const generateCss: (dirname: string, prod?: boolean) => Promise<void>;
|
15
15
|
export declare const generateFile: (dirname: string, file: string) => Promise<void>;
|
16
|
-
export declare const minimizeFile: (dirname: string, file: string) => Promise<string | undefined>;
|
16
|
+
export declare const minimizeFile: (dirname: string, file: string, prod?: boolean) => Promise<string | undefined>;
|
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-DUUSaubj.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-BGaLvshf.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var m=Object.defineProperty;var l=(a,t,s)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var
|
1
|
+
"use strict";var m=Object.defineProperty;var l=(a,t,s)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var o=(a,t,s)=>l(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-DKzpenwY.cjs"),p=require("../parse-templates-DVK3iZIl.cjs");class g{constructor(t,s){o(this,"_isProd");o(this,"_callerName");o(this,"_context");this.tagName=t,this.params=s}get hash(){return u.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?p.getTemplateKeys(this._context.config.templates):[]}get css(){var e;const{base:t={},variants:s={},compoundVariants:i=[]}=this.params,r={...t,variants:s,compoundVariants:i};return p.parseStyles(r,`.${this.cssClassName}`,this.priority,(e=this._context)==null?void 0:e.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var n;const c=(n=this.params.defaultVariants)==null?void 0:n[e];return c!==void 0?`${e}=${String(c)}`:e}):void 0,i=new Set([]),r=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return r&&r.forEach((e,c,n)=>{const h=n.at(1);h&&i.add(h)}),{element:t,variantKeys:s,propValueKeys:[...i],attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:i,prod:r}=t;return this._isProd=r,this._callerName=s,this}}exports.StyleComponentGenerator=g;
|
package/generator/index.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
var
|
2
|
-
var m = (e, t, s) => t in e ?
|
3
|
-
var
|
1
|
+
var p = Object.defineProperty;
|
2
|
+
var m = (e, t, s) => t in e ? p(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
|
+
var n = (e, t, s) => m(e, typeof t != "symbol" ? t + "" : t, s);
|
4
4
|
import { t as l } from "../dash-case-DMQMcCO6.js";
|
5
5
|
import { g, p as u } from "../parse-templates-DUUSaubj.js";
|
6
|
-
class
|
6
|
+
class N {
|
7
7
|
constructor(t, s) {
|
8
|
-
|
9
|
-
|
8
|
+
n(this, "_isProd");
|
9
|
+
n(this, "_callerName");
|
10
|
+
n(this, "_context");
|
10
11
|
this.tagName = t, this.params = s;
|
11
12
|
}
|
12
13
|
get hash() {
|
@@ -32,30 +33,33 @@ class d {
|
|
32
33
|
}
|
33
34
|
get css() {
|
34
35
|
var a;
|
35
|
-
const { base: t = {}, variants: s = {}, compoundVariants:
|
36
|
-
return u(
|
36
|
+
const { base: t = {}, variants: s = {}, compoundVariants: i = [] } = this.params, r = { ...t, variants: s, compoundVariants: i };
|
37
|
+
return u(r, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
|
37
38
|
}
|
38
39
|
get props() {
|
39
40
|
const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
|
40
|
-
var
|
41
|
-
const
|
42
|
-
return
|
43
|
-
}) : void 0,
|
44
|
-
return
|
45
|
-
const
|
46
|
-
|
41
|
+
var o;
|
42
|
+
const c = (o = this.params.defaultVariants) == null ? void 0 : o[a];
|
43
|
+
return c !== void 0 ? `${a}=${String(c)}` : a;
|
44
|
+
}) : void 0, i = /* @__PURE__ */ new Set([]), r = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
|
45
|
+
return r && r.forEach((a, c, o) => {
|
46
|
+
const h = o.at(1);
|
47
|
+
h && i.add(h);
|
47
48
|
}), {
|
48
49
|
element: t,
|
49
50
|
variantKeys: s,
|
50
|
-
propValueKeys: [...
|
51
|
+
propValueKeys: [...i],
|
52
|
+
attr: {
|
53
|
+
"data-component-name": this._isProd ? void 0 : this._callerName
|
54
|
+
}
|
51
55
|
};
|
52
56
|
}
|
53
57
|
_withBuildContext(t) {
|
54
58
|
this._context = t;
|
55
|
-
const { name: s, config: r } = t;
|
56
|
-
return this._callerName = s, this;
|
59
|
+
const { name: s, config: i, prod: r } = t;
|
60
|
+
return this._isProd = r, this._callerName = s, this;
|
57
61
|
}
|
58
62
|
}
|
59
63
|
export {
|
60
|
-
|
64
|
+
N as StyleComponentGenerator
|
61
65
|
};
|
@@ -3,10 +3,14 @@ export interface GeneratorProps {
|
|
3
3
|
element?: string;
|
4
4
|
variantKeys?: string[];
|
5
5
|
propValueKeys?: string[];
|
6
|
+
attr: {
|
7
|
+
[key: string]: any;
|
8
|
+
};
|
6
9
|
}
|
7
10
|
export declare class StyleComponentGenerator {
|
8
11
|
tagName: Tag<any>;
|
9
12
|
params: StyledParams;
|
13
|
+
_isProd: boolean | undefined;
|
10
14
|
_callerName: string | undefined;
|
11
15
|
_context: {
|
12
16
|
name: string;
|
@@ -24,5 +28,6 @@ export declare class StyleComponentGenerator {
|
|
24
28
|
_withBuildContext(context: {
|
25
29
|
name: string;
|
26
30
|
config: any;
|
31
|
+
prod: boolean;
|
27
32
|
}): this;
|
28
33
|
}
|
@@ -0,0 +1,232 @@
|
|
1
|
+
import * as H from "esbuild";
|
2
|
+
import { execSync as Q } from "child_process";
|
3
|
+
import { t as B, d as W } from "./dash-case-DMQMcCO6.js";
|
4
|
+
import { join as o } from "path";
|
5
|
+
import { existsSync as K, writeFileSync as w, mkdirSync as V, statSync as tt, readdirSync as st, readFileSync as v } from "fs";
|
6
|
+
import { readFile as et, writeFile as nt } from "fs/promises";
|
7
|
+
import { p as ot, a as rt, b as ct } from "./parse-templates-DUUSaubj.js";
|
8
|
+
import { createLogger as at, format as J, transports as it } from "winston";
|
9
|
+
const L = (t) => {
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
+
const s = o(t, "package.json");
|
12
|
+
return K(s) ? s : L(o(t, ".."));
|
13
|
+
}, lt = async (t) => {
|
14
|
+
const s = L(t);
|
15
|
+
return await et(s, "utf-8").then(JSON.parse).catch(() => {
|
16
|
+
});
|
17
|
+
}, pt = async (t) => {
|
18
|
+
const s = await lt(t);
|
19
|
+
if (s)
|
20
|
+
return s.type;
|
21
|
+
};
|
22
|
+
let M;
|
23
|
+
const q = async (t) => {
|
24
|
+
if (M) return M;
|
25
|
+
const s = await pt(t);
|
26
|
+
return s === "module" ? M = "esm" : (s === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
27
|
+
}, R = at({
|
28
|
+
level: "debug",
|
29
|
+
format: J.combine(J.colorize(), J.cli()),
|
30
|
+
transports: [new it.Console({})]
|
31
|
+
}), Ct = (t) => {
|
32
|
+
R.error(t);
|
33
|
+
}, O = {
|
34
|
+
externalModules: []
|
35
|
+
}, A = (t) => {
|
36
|
+
if (O.externalModules.length > 0) return O.externalModules;
|
37
|
+
const s = o(t, "salty.config.ts"), e = v(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
38
|
+
if (!e) return [];
|
39
|
+
const n = e[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
40
|
+
return O.externalModules = n, n;
|
41
|
+
}, N = (t) => o(t, "./saltygen"), ft = ["salty", "css", "styles", "styled"], ut = (t = []) => new RegExp(`\\.(${[...ft, ...t].join("|")})\\.`), I = (t, s = []) => ut(s).test(t), gt = async (t) => {
|
42
|
+
const s = N(t), i = o(t, "salty.config.ts"), e = o(s, "salty.config.js"), n = await q(t), l = A(t);
|
43
|
+
await H.build({
|
44
|
+
entryPoints: [i],
|
45
|
+
minify: !0,
|
46
|
+
treeShaking: !0,
|
47
|
+
bundle: !0,
|
48
|
+
outfile: e,
|
49
|
+
format: n,
|
50
|
+
external: l
|
51
|
+
});
|
52
|
+
const S = Date.now(), { config: f } = await import(`${e}?t=${S}`);
|
53
|
+
return f;
|
54
|
+
}, dt = async (t) => {
|
55
|
+
const s = await gt(t), i = /* @__PURE__ */ new Set(), e = (u, a = []) => u ? Object.entries(u).flatMap(([m, p]) => {
|
56
|
+
if (!p) return;
|
57
|
+
if (typeof p == "object") return e(p, [...a, m]);
|
58
|
+
const P = [...a, m].join(".");
|
59
|
+
i.add(`"${P}"`);
|
60
|
+
const x = [...a.map(W), W(m)].join("-"), { result: y } = ct(p);
|
61
|
+
return `--${x}: ${y};`;
|
62
|
+
}) : [], n = (u) => u ? Object.entries(u).flatMap(([a, m]) => {
|
63
|
+
const p = e(m);
|
64
|
+
return a === "base" ? p.join("") : `${a} { ${p.join("")} }`;
|
65
|
+
}) : [], l = (u) => u ? Object.entries(u).flatMap(([a, m]) => Object.entries(m).flatMap(([p, P]) => {
|
66
|
+
const x = e(P, [a]), y = `.${a}-${p}, [data-${a}="${p}"]`, b = x.join("");
|
67
|
+
return `${y} { ${b} }`;
|
68
|
+
})) : [], S = e(s.variables), f = n(s.responsiveVariables), C = l(s.conditionalVariables), r = N(t), T = o(r, "css/variables.css"), g = `:root { ${S.join("")} ${f.join("")} } ${C.join("")}`;
|
69
|
+
w(T, g);
|
70
|
+
const h = o(r, "types/css-tokens.d.ts"), c = `type VariableTokens = ${[...i].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
71
|
+
w(h, c);
|
72
|
+
const d = o(r, "css/global.css"), k = ot(s.global, "");
|
73
|
+
w(d, k);
|
74
|
+
const $ = o(r, "css/templates.css"), j = rt(s.templates);
|
75
|
+
w($, j);
|
76
|
+
}, _ = async (t, s, i) => {
|
77
|
+
const e = B(s), n = o(i, "js", e + ".js"), l = await q(t), S = A(t);
|
78
|
+
await H.build({
|
79
|
+
entryPoints: [s],
|
80
|
+
minify: !0,
|
81
|
+
treeShaking: !0,
|
82
|
+
bundle: !0,
|
83
|
+
outfile: n,
|
84
|
+
format: l,
|
85
|
+
target: ["es2022"],
|
86
|
+
keepNames: !0,
|
87
|
+
external: S
|
88
|
+
});
|
89
|
+
const f = Date.now();
|
90
|
+
return await import(`${n}?t=${f}`);
|
91
|
+
}, z = async (t) => {
|
92
|
+
const s = N(t), i = o(s, "salty.config.js"), { config: e } = await import(i);
|
93
|
+
return e;
|
94
|
+
}, U = () => {
|
95
|
+
try {
|
96
|
+
return process.env.NODE_ENV === "production";
|
97
|
+
} catch {
|
98
|
+
return !1;
|
99
|
+
}
|
100
|
+
}, Ft = async (t, s = U()) => {
|
101
|
+
try {
|
102
|
+
s ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
|
103
|
+
const i = [], e = [], n = N(t), l = o(n, "index.css");
|
104
|
+
(() => {
|
105
|
+
K(n) && Q("rm -rf " + n), V(n), V(o(n, "css")), V(o(n, "types"));
|
106
|
+
})(), await dt(t);
|
107
|
+
const f = await z(t);
|
108
|
+
async function C(c, d) {
|
109
|
+
const k = ["node_modules", "saltygen"], $ = tt(c);
|
110
|
+
if ($.isDirectory()) {
|
111
|
+
const j = st(c);
|
112
|
+
if (k.some((a) => c.includes(a))) return;
|
113
|
+
await Promise.all(j.map((a) => C(o(c, a), o(d, a))));
|
114
|
+
} else if ($.isFile() && I(c)) {
|
115
|
+
const u = await _(t, c, n), a = [];
|
116
|
+
Object.entries(u).forEach(([x, y]) => {
|
117
|
+
if (y.isKeyframes && y.css) {
|
118
|
+
const G = `${y.animationName}.css`, Y = `css/${G}`, Z = o(n, Y);
|
119
|
+
i.push(G), w(Z, y.css);
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
if (!y.generator) return;
|
123
|
+
const b = y.generator._withBuildContext({
|
124
|
+
name: x,
|
125
|
+
config: f,
|
126
|
+
prod: s
|
127
|
+
}), D = `${b.hash}-${b.priority}.css`;
|
128
|
+
e[b.priority] || (e[b.priority] = []), e[b.priority].push(D), a.push(D);
|
129
|
+
const E = `css/${D}`, X = o(n, E);
|
130
|
+
w(X, b.css);
|
131
|
+
});
|
132
|
+
const m = a.map((x) => `@import url('./${x}');`).join(`
|
133
|
+
`), p = B(c, 6), P = o(n, `css/${p}.css`);
|
134
|
+
w(P, m);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
await C(t, n);
|
138
|
+
const r = i.map((c) => `@import url('./css/${c}');`).join(`
|
139
|
+
`);
|
140
|
+
let F = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
141
|
+
|
142
|
+
${["variables.css", "global.css", "templates.css"].filter((c) => {
|
143
|
+
try {
|
144
|
+
return v(o(n, "css", c), "utf8").length > 0;
|
145
|
+
} catch {
|
146
|
+
return !1;
|
147
|
+
}
|
148
|
+
}).map((c) => `@import url('./css/${c}');`).join(`
|
149
|
+
`)}
|
150
|
+
${r}`;
|
151
|
+
if (f.importStrategy !== "component") {
|
152
|
+
const c = e.flat().map((d) => `@import url('./css/${d}');`).join(`
|
153
|
+
`);
|
154
|
+
F += c;
|
155
|
+
}
|
156
|
+
w(l, F);
|
157
|
+
} catch (i) {
|
158
|
+
console.error(i);
|
159
|
+
}
|
160
|
+
}, jt = async (t, s) => {
|
161
|
+
try {
|
162
|
+
const i = [], e = o(t, "./saltygen"), n = o(e, "index.css");
|
163
|
+
if (I(s)) {
|
164
|
+
const S = await z(t), f = await _(t, s, e);
|
165
|
+
Object.entries(f).forEach(([h, F]) => {
|
166
|
+
if (!F.generator) return;
|
167
|
+
const c = F.generator._withBuildContext({
|
168
|
+
name: h,
|
169
|
+
config: S
|
170
|
+
}), d = `${c.hash}-${c.priority}.css`, k = `css/${d}`, $ = o(e, k);
|
171
|
+
i.push(d), w($, c.css);
|
172
|
+
});
|
173
|
+
const C = v(n, "utf8").split(`
|
174
|
+
`), r = i.map((h) => `@import url('../saltygen/css/${h}');`), g = [.../* @__PURE__ */ new Set([...C, ...r])].join(`
|
175
|
+
`);
|
176
|
+
w(n, g);
|
177
|
+
}
|
178
|
+
} catch (i) {
|
179
|
+
console.error(i);
|
180
|
+
}
|
181
|
+
}, xt = async (t, s, i = U()) => {
|
182
|
+
try {
|
183
|
+
const e = o(t, "./saltygen");
|
184
|
+
if (I(s)) {
|
185
|
+
const l = v(s, "utf8");
|
186
|
+
l.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== l && await nt(s, l);
|
187
|
+
const f = await z(t), C = await _(t, s, e);
|
188
|
+
let r = l;
|
189
|
+
Object.entries(C).forEach(([g, h]) => {
|
190
|
+
var D;
|
191
|
+
if (h.isKeyframes || !h.generator) return;
|
192
|
+
const F = h.generator._withBuildContext({
|
193
|
+
name: g,
|
194
|
+
config: f,
|
195
|
+
prod: i
|
196
|
+
}), c = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
197
|
+
if (!c) return console.error("Could not find the original declaration");
|
198
|
+
const d = (D = c.at(1)) == null ? void 0 : D.trim(), k = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(r);
|
199
|
+
if (!k) return console.error("Could not find the original declaration");
|
200
|
+
const { index: $ } = k;
|
201
|
+
let j = !1;
|
202
|
+
const u = setTimeout(() => j = !0, 5e3);
|
203
|
+
let a = 0, m = !1, p = 0;
|
204
|
+
for (; !m && !j; ) {
|
205
|
+
const E = r[$ + a];
|
206
|
+
E === "(" && p++, E === ")" && p--, p === 0 && E === ")" && (m = !0), a > r.length && (j = !0), a++;
|
207
|
+
}
|
208
|
+
if (!j) clearTimeout(u);
|
209
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
210
|
+
const P = $ + a, x = r.slice($, P), y = r, b = ` ${g} = styled(${d}, "${F.classNames}", ${JSON.stringify(F.props)});`;
|
211
|
+
r = r.replace(x, b), y === r && console.error("Minimize file failed to change content", { name: g, tagName: d });
|
212
|
+
});
|
213
|
+
const T = B(s, 6);
|
214
|
+
return f.importStrategy === "component" && (r = `import '../../saltygen/css/${T}.css';
|
215
|
+
${r}`), r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
|
216
|
+
}
|
217
|
+
} catch (e) {
|
218
|
+
console.error("Error in minimizeFile:", e);
|
219
|
+
}
|
220
|
+
};
|
221
|
+
export {
|
222
|
+
Ct as a,
|
223
|
+
ut as b,
|
224
|
+
dt as c,
|
225
|
+
_ as d,
|
226
|
+
jt as e,
|
227
|
+
Ft as g,
|
228
|
+
I as i,
|
229
|
+
R as l,
|
230
|
+
xt as m,
|
231
|
+
ft as s
|
232
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";const te=require("esbuild"),se=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),i=require("path"),l=require("fs"),H=require("fs/promises"),J=require("./parse-templates-DVK3iZIl.cjs"),v=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return l.existsSync(t)?t:G(i.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let T;const L=async e=>{if(T)return T;const t=await ie(e);return t==="module"?T="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-BKoD9apd.cjs",document.baseURI).href).endsWith(".cjs"))&&(T="cjs"),T||"esm"},O=v.createLogger({level:"debug",format:v.format.combine(v.format.colorize(),v.format.cli()),transports:[new v.transports.Console({})]}),re=e=>{O.error(e)},I={externalModules:[]},W=e=>{if(I.externalModules.length>0)return I.externalModules;const t=i.join(e,"salty.config.ts"),s=l.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const o=s[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return I.externalModules=o,o},V=e=>i.join(e,"./saltygen"),K=["salty","css","styles","styled"],A=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),R=(e,t=[])=>A(t).test(e),ce=async e=>{const t=V(e),n=i.join(e,"salty.config.ts"),s=i.join(t,"salty.config.js"),o=await L(e),u=W(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:o,external:u});const b=Date.now(),{config:p}=await import(`${s}?t=${b}`);return p},X=async e=>{const t=await ce(e),n=new Set,s=(g,a=[])=>g?Object.entries(g).flatMap(([m,f])=>{if(!f)return;if(typeof f=="object")return s(f,[...a,m]);const P=[...a,m].join(".");n.add(`"${P}"`);const x=[...a.map(N.dashCase),N.dashCase(m)].join("-"),{result:h}=J.parseValueTokens(f);return`--${x}: ${h};`}):[],o=g=>g?Object.entries(g).flatMap(([a,m])=>{const f=s(m);return a==="base"?f.join(""):`${a} { ${f.join("")} }`}):[],u=g=>g?Object.entries(g).flatMap(([a,m])=>Object.entries(m).flatMap(([f,P])=>{const x=s(P,[a]),h=`.${a}-${f}, [data-${a}="${f}"]`,w=x.join("");return`${h} { ${w} }`})):[],b=s(t.variables),p=o(t.responsiveVariables),F=u(t.conditionalVariables),r=V(e),E=i.join(r,"css/variables.css"),d=`:root { ${b.join("")} ${p.join("")} } ${F.join("")}`;l.writeFileSync(E,d);const j=i.join(r,"types/css-tokens.d.ts"),c=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;l.writeFileSync(j,c);const y=i.join(r,"css/global.css"),k=J.parseStyles(t.global,"");l.writeFileSync(y,k);const S=i.join(r,"css/templates.css"),C=J.parseTemplates(t.templates);l.writeFileSync(S,C)},_=async(e,t,n)=>{const s=N.toHash(t),o=i.join(n,"js",s+".js"),u=await L(e),b=W(e);await U.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:u,target:["es2022"],keepNames:!0,external:b});const p=Date.now();return await import(`${o}?t=${p}`)},z=async e=>{const t=V(e),n=i.join(t,"salty.config.js"),{config:s}=await import(n);return s},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=Y())=>{try{t?O.info("Generating CSS in production mode! 🔥"):O.info("Generating CSS in development mode! 🚀");const n=[],s=[],o=V(e),u=i.join(o,"index.css");(()=>{l.existsSync(o)&&se.execSync("rm -rf "+o),l.mkdirSync(o),l.mkdirSync(i.join(o,"css")),l.mkdirSync(i.join(o,"types"))})(),await X(e);const p=await z(e);async function F(c,y){const k=["node_modules","saltygen"],S=l.statSync(c);if(S.isDirectory()){const C=l.readdirSync(c);if(k.some(a=>c.includes(a)))return;await Promise.all(C.map(a=>F(i.join(c,a),i.join(y,a))))}else if(S.isFile()&&R(c)){const g=await _(e,c,o),a=[];Object.entries(g).forEach(([x,h])=>{if(h.isKeyframes&&h.css){const B=`${h.animationName}.css`,Q=`css/${B}`,ee=i.join(o,Q);n.push(B),l.writeFileSync(ee,h.css);return}if(!h.generator)return;const w=h.generator._withBuildContext({name:x,config:p,prod:t}),D=`${w.hash}-${w.priority}.css`;s[w.priority]||(s[w.priority]=[]),s[w.priority].push(D),a.push(D);const M=`css/${D}`,Z=i.join(o,M);l.writeFileSync(Z,w.css)});const m=a.map(x=>`@import url('./${x}');`).join(`
|
2
|
+
`),f=N.toHash(c,6),P=i.join(o,`css/${f}.css`);l.writeFileSync(P,m)}}await F(e,o);const r=n.map(c=>`@import url('./css/${c}');`).join(`
|
3
|
+
`);let $=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
4
|
+
|
5
|
+
${["variables.css","global.css","templates.css"].filter(c=>{try{return l.readFileSync(i.join(o,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
6
|
+
`)}
|
7
|
+
${r}`;if(p.importStrategy!=="component"){const c=s.flat().map(y=>`@import url('./css/${y}');`).join(`
|
8
|
+
`);$+=c}l.writeFileSync(u,$)}catch(n){console.error(n)}},le=async(e,t)=>{try{const n=[],s=i.join(e,"./saltygen"),o=i.join(s,"index.css");if(R(t)){const b=await z(e),p=await _(e,t,s);Object.entries(p).forEach(([j,$])=>{if(!$.generator)return;const c=$.generator._withBuildContext({name:j,config:b}),y=`${c.hash}-${c.priority}.css`,k=`css/${y}`,S=i.join(s,k);n.push(y),l.writeFileSync(S,c.css)});const F=l.readFileSync(o,"utf8").split(`
|
9
|
+
`),r=n.map(j=>`@import url('../saltygen/css/${j}');`),d=[...new Set([...F,...r])].join(`
|
10
|
+
`);l.writeFileSync(o,d)}}catch(n){console.error(n)}},ue=async(e,t,n=Y())=>{try{const s=i.join(e,"./saltygen");if(R(t)){const u=l.readFileSync(t,"utf8");u.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==u&&await H.writeFile(t,u);const p=await z(e),F=await _(e,t,s);let r=u;Object.entries(F).forEach(([d,j])=>{var D;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:d,config:p,prod:n}),c=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(u);if(!c)return console.error("Could not find the original declaration");const y=(D=c.at(1))==null?void 0:D.trim(),k=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(r);if(!k)return console.error("Could not find the original declaration");const{index:S}=k;let C=!1;const g=setTimeout(()=>C=!0,5e3);let a=0,m=!1,f=0;for(;!m&&!C;){const M=r[S+a];M==="("&&f++,M===")"&&f--,f===0&&M===")"&&(m=!0),a>r.length&&(C=!0),a++}if(!C)clearTimeout(g);else throw new Error("Failed to find the end of the styled call and timed out");const P=S+a,x=r.slice(S,P),h=r,w=` ${d} = styled(${y}, "${$.classNames}", ${JSON.stringify($.props)});`;r=r.replace(x,w),h===r&&console.error("Minimize file failed to change content",{name:d,tagName:y})});const E=N.toHash(t,6);return p.importStrategy==="component"&&(r=`import '../../saltygen/css/${E}.css';
|
11
|
+
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(s){console.error("Error in minimizeFile:",s)}};exports.compileSaltyFile=_;exports.generateConfigStyles=X;exports.generateCss=ae;exports.generateFile=le;exports.isSaltyFile=R;exports.logError=re;exports.logger=O;exports.minimizeFile=ue;exports.saltyFileExtensions=K;exports.saltyFileRegExp=A;
|
package/package.json
CHANGED
package/index-CVMlMbWG.js
DELETED
@@ -1,230 +0,0 @@
|
|
1
|
-
import * as W from "esbuild";
|
2
|
-
import { execSync as Z } from "child_process";
|
3
|
-
import { t as R, d as G } from "./dash-case-DMQMcCO6.js";
|
4
|
-
import { join as n } from "path";
|
5
|
-
import { existsSync as H, writeFileSync as C, mkdirSync as v, statSync as Q, readdirSync as tt, readFileSync as E } from "fs";
|
6
|
-
import { readFile as st, writeFile as et } from "fs/promises";
|
7
|
-
import { p as nt, a as ot, b as rt } from "./parse-templates-DUUSaubj.js";
|
8
|
-
import { createLogger as at, format as V, transports as ct } from "winston";
|
9
|
-
const K = (t) => {
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
-
const s = n(t, "package.json");
|
12
|
-
return H(s) ? s : K(n(t, ".."));
|
13
|
-
}, it = async (t) => {
|
14
|
-
const s = K(t);
|
15
|
-
return await st(s, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, lt = async (t) => {
|
18
|
-
const s = await it(t);
|
19
|
-
if (s)
|
20
|
-
return s.type;
|
21
|
-
};
|
22
|
-
let T;
|
23
|
-
const L = async (t) => {
|
24
|
-
if (T) return T;
|
25
|
-
const s = await lt(t);
|
26
|
-
return s === "module" ? T = "esm" : (s === "commonjs" || import.meta.url.endsWith(".cjs")) && (T = "cjs"), T || "esm";
|
27
|
-
}, O = at({
|
28
|
-
level: "debug",
|
29
|
-
format: V.combine(V.colorize(), V.cli()),
|
30
|
-
transports: [new ct.Console({})]
|
31
|
-
}), Ct = (t) => {
|
32
|
-
O.error(t);
|
33
|
-
}, J = {
|
34
|
-
externalModules: []
|
35
|
-
}, q = (t) => {
|
36
|
-
if (J.externalModules.length > 0) return J.externalModules;
|
37
|
-
const s = n(t, "salty.config.ts"), r = E(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
38
|
-
if (!r) return [];
|
39
|
-
const e = r[1].split(",").map((m) => m.replace(/['"`]/g, "").trim());
|
40
|
-
return J.externalModules = e, e;
|
41
|
-
}, N = (t) => n(t, "./saltygen"), pt = ["salty", "css", "styles", "styled"], ft = (t = []) => new RegExp(`\\.(${[...pt, ...t].join("|")})\\.`), _ = (t, s = []) => ft(s).test(t), ut = async (t) => {
|
42
|
-
const s = N(t), o = n(t, "salty.config.ts"), r = n(s, "salty.config.js"), e = await L(t), m = q(t);
|
43
|
-
await W.build({
|
44
|
-
entryPoints: [o],
|
45
|
-
minify: !0,
|
46
|
-
treeShaking: !0,
|
47
|
-
bundle: !0,
|
48
|
-
outfile: r,
|
49
|
-
format: e,
|
50
|
-
external: m
|
51
|
-
});
|
52
|
-
const y = Date.now(), { config: u } = await import(`${r}?t=${y}`);
|
53
|
-
return u;
|
54
|
-
}, gt = async (t) => {
|
55
|
-
const s = await ut(t), o = /* @__PURE__ */ new Set(), r = (l, i = []) => l ? Object.entries(l).flatMap(([f, p]) => {
|
56
|
-
if (!p) return;
|
57
|
-
if (typeof p == "object") return r(p, [...i, f]);
|
58
|
-
const P = [...i, f].join(".");
|
59
|
-
o.add(`"${P}"`);
|
60
|
-
const x = [...i.map(G), G(f)].join("-"), { result: d } = rt(p);
|
61
|
-
return `--${x}: ${d};`;
|
62
|
-
}) : [], e = (l) => l ? Object.entries(l).flatMap(([i, f]) => {
|
63
|
-
const p = r(f);
|
64
|
-
return i === "base" ? p.join("") : `${i} { ${p.join("")} }`;
|
65
|
-
}) : [], m = (l) => l ? Object.entries(l).flatMap(([i, f]) => Object.entries(f).flatMap(([p, P]) => {
|
66
|
-
const x = r(P, [i]), d = `.${i}-${p}, [data-${i}="${p}"]`, b = x.join("");
|
67
|
-
return `${d} { ${b} }`;
|
68
|
-
})) : [], y = r(s.variables), u = e(s.responsiveVariables), c = m(s.conditionalVariables), w = N(t), h = n(w, "css/variables.css"), k = `:root { ${y.join("")} ${u.join("")} } ${c.join("")}`;
|
69
|
-
C(h, k);
|
70
|
-
const S = n(w, "types/css-tokens.d.ts"), a = `type VariableTokens = ${[...o].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
71
|
-
C(S, a);
|
72
|
-
const g = n(w, "css/global.css"), j = nt(s.global, "");
|
73
|
-
C(g, j);
|
74
|
-
const $ = n(w, "css/templates.css"), M = ot(s.templates);
|
75
|
-
C($, M);
|
76
|
-
}, B = async (t, s, o) => {
|
77
|
-
const r = R(s), e = n(o, "js", r + ".js"), m = await L(t), y = q(t);
|
78
|
-
await W.build({
|
79
|
-
entryPoints: [s],
|
80
|
-
minify: !0,
|
81
|
-
treeShaking: !0,
|
82
|
-
bundle: !0,
|
83
|
-
outfile: e,
|
84
|
-
format: m,
|
85
|
-
target: ["es2022"],
|
86
|
-
keepNames: !0,
|
87
|
-
external: y
|
88
|
-
});
|
89
|
-
const u = Date.now();
|
90
|
-
return await import(`${e}?t=${u}`);
|
91
|
-
}, I = async (t) => {
|
92
|
-
const s = N(t), o = n(s, "salty.config.js"), { config: r } = await import(o);
|
93
|
-
return r;
|
94
|
-
}, dt = () => {
|
95
|
-
try {
|
96
|
-
return process.env.NODE_ENV === "production";
|
97
|
-
} catch {
|
98
|
-
return !1;
|
99
|
-
}
|
100
|
-
}, Ft = async (t, s = dt()) => {
|
101
|
-
try {
|
102
|
-
s ? O.info("Generating CSS in production mode! 🔥") : O.info("Generating CSS in development mode! 🚀");
|
103
|
-
const o = [], r = [], e = N(t), m = n(e, "index.css");
|
104
|
-
(() => {
|
105
|
-
H(e) && Z("rm -rf " + e), v(e), v(n(e, "css")), v(n(e, "types"));
|
106
|
-
})(), await gt(t);
|
107
|
-
const u = await I(t);
|
108
|
-
async function c(a, g) {
|
109
|
-
const j = ["node_modules", "saltygen"], $ = Q(a);
|
110
|
-
if ($.isDirectory()) {
|
111
|
-
const M = tt(a);
|
112
|
-
if (j.some((i) => a.includes(i))) return;
|
113
|
-
await Promise.all(M.map((i) => c(n(a, i), n(g, i))));
|
114
|
-
} else if ($.isFile() && _(a)) {
|
115
|
-
const l = await B(t, a, e), i = [];
|
116
|
-
Object.entries(l).forEach(([x, d]) => {
|
117
|
-
if (d.isKeyframes && d.css) {
|
118
|
-
const z = `${d.animationName}.css`, X = `css/${z}`, Y = n(e, X);
|
119
|
-
o.push(z), C(Y, d.css);
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
if (!d.generator) return;
|
123
|
-
const b = d.generator._withBuildContext({
|
124
|
-
name: x,
|
125
|
-
config: u
|
126
|
-
}), D = `${b.hash}-${b.priority}.css`;
|
127
|
-
r[b.priority] || (r[b.priority] = []), r[b.priority].push(D), i.push(D);
|
128
|
-
const A = `css/${D}`, U = n(e, A);
|
129
|
-
C(U, b.css);
|
130
|
-
});
|
131
|
-
const f = i.map((x) => `@import url('./${x}');`).join(`
|
132
|
-
`), p = R(a, 6), P = n(e, `css/${p}.css`);
|
133
|
-
C(P, f);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
await c(t, e);
|
137
|
-
const w = o.map((a) => `@import url('./css/${a}');`).join(`
|
138
|
-
`);
|
139
|
-
let F = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
140
|
-
|
141
|
-
${["variables.css", "global.css", "templates.css"].filter((a) => {
|
142
|
-
try {
|
143
|
-
return E(n(e, "css", a), "utf8").length > 0;
|
144
|
-
} catch {
|
145
|
-
return !1;
|
146
|
-
}
|
147
|
-
}).map((a) => `@import url('./css/${a}');`).join(`
|
148
|
-
`)}
|
149
|
-
${w}`;
|
150
|
-
if (u.importStrategy !== "component") {
|
151
|
-
const a = r.flat().map((g) => `@import url('./css/${g}');`).join(`
|
152
|
-
`);
|
153
|
-
F += a;
|
154
|
-
}
|
155
|
-
C(m, F);
|
156
|
-
} catch (o) {
|
157
|
-
console.error(o);
|
158
|
-
}
|
159
|
-
}, jt = async (t, s) => {
|
160
|
-
try {
|
161
|
-
const o = [], r = n(t, "./saltygen"), e = n(r, "index.css");
|
162
|
-
if (_(s)) {
|
163
|
-
const y = await I(t), u = await B(t, s, r);
|
164
|
-
Object.entries(u).forEach(([S, F]) => {
|
165
|
-
if (!F.generator) return;
|
166
|
-
const a = F.generator._withBuildContext({
|
167
|
-
name: S,
|
168
|
-
config: y
|
169
|
-
}), g = `${a.hash}-${a.priority}.css`, j = `css/${g}`, $ = n(r, j);
|
170
|
-
o.push(g), C($, a.css);
|
171
|
-
});
|
172
|
-
const c = E(e, "utf8").split(`
|
173
|
-
`), w = o.map((S) => `@import url('../saltygen/css/${S}');`), k = [.../* @__PURE__ */ new Set([...c, ...w])].join(`
|
174
|
-
`);
|
175
|
-
C(e, k);
|
176
|
-
}
|
177
|
-
} catch (o) {
|
178
|
-
console.error(o);
|
179
|
-
}
|
180
|
-
}, xt = async (t, s) => {
|
181
|
-
try {
|
182
|
-
const o = n(t, "./saltygen");
|
183
|
-
if (_(s)) {
|
184
|
-
const e = E(s, "utf8");
|
185
|
-
e.replace(/^(?!export\s)const\s.*/gm, (h) => `export ${h}`) !== e && await et(s, e);
|
186
|
-
const y = await I(t), u = await B(t, s, o);
|
187
|
-
let c = e;
|
188
|
-
Object.entries(u).forEach(([h, k]) => {
|
189
|
-
var b;
|
190
|
-
if (k.isKeyframes || !k.generator) return;
|
191
|
-
const S = k.generator._withBuildContext({
|
192
|
-
name: h,
|
193
|
-
config: y
|
194
|
-
}), F = new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(e);
|
195
|
-
if (!F) return console.error("Could not find the original declaration");
|
196
|
-
const a = (b = F.at(1)) == null ? void 0 : b.trim(), g = new RegExp(`\\s${h}[=\\s]+styled\\(`, "g").exec(c);
|
197
|
-
if (!g) return console.error("Could not find the original declaration");
|
198
|
-
const { index: j } = g;
|
199
|
-
let $ = !1;
|
200
|
-
const M = setTimeout(() => $ = !0, 5e3);
|
201
|
-
let l = 0, i = !1, f = 0;
|
202
|
-
for (; !i && !$; ) {
|
203
|
-
const D = c[j + l];
|
204
|
-
D === "(" && f++, D === ")" && f--, f === 0 && D === ")" && (i = !0), l > c.length && ($ = !0), l++;
|
205
|
-
}
|
206
|
-
if (!$) clearTimeout(M);
|
207
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
208
|
-
const p = j + l, P = c.slice(j, p), x = c, d = ` ${h} = styled(${a}, "${S.classNames}", "${S._callerName}", ${JSON.stringify(S.props)});`;
|
209
|
-
c = c.replace(P, d), x === c && console.error("Minimize file failed to change content", { name: h, tagName: a });
|
210
|
-
});
|
211
|
-
const w = R(s, 6);
|
212
|
-
return y.importStrategy === "component" && (c = `import '../../saltygen/css/${w}.css';
|
213
|
-
${c}`), c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
214
|
-
}
|
215
|
-
} catch (o) {
|
216
|
-
console.error("Error in minimizeFile:", o);
|
217
|
-
}
|
218
|
-
};
|
219
|
-
export {
|
220
|
-
Ct as a,
|
221
|
-
ft as b,
|
222
|
-
gt as c,
|
223
|
-
B as d,
|
224
|
-
jt as e,
|
225
|
-
Ft as g,
|
226
|
-
_ as i,
|
227
|
-
O as l,
|
228
|
-
xt as m,
|
229
|
-
pt as s
|
230
|
-
};
|
package/index-DXEpY0wo.cjs
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";const ee=require("esbuild"),te=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),i=require("path"),l=require("fs"),B=require("fs/promises"),R=require("./parse-templates-DVK3iZIl.cjs"),M=require("winston");var J=typeof document<"u"?document.currentScript:null;function se(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const H=se(ee),U=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return l.existsSync(t)?t:U(i.join(e,".."))},ne=async e=>{const t=U(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},oe=async e=>{const t=await ne(e);if(t)return t.type};let E;const G=async e=>{if(E)return E;const t=await oe(e);return t==="module"?E="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-DXEpY0wo.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},v=M.createLogger({level:"debug",format:M.format.combine(M.format.colorize(),M.format.cli()),transports:[new M.transports.Console({})]}),ie=e=>{v.error(e)},q={externalModules:[]},L=e=>{if(q.externalModules.length>0)return q.externalModules;const t=i.join(e,"salty.config.ts"),o=l.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const s=o[1].split(",").map(m=>m.replace(/['"`]/g,"").trim());return q.externalModules=s,s},O=e=>i.join(e,"./saltygen"),W=["salty","css","styles","styled"],K=(e=[])=>new RegExp(`\\.(${[...W,...e].join("|")})\\.`),V=(e,t=[])=>K(t).test(e),re=async e=>{const t=O(e),n=i.join(e,"salty.config.ts"),o=i.join(t,"salty.config.js"),s=await G(e),m=L(e);await H.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:s,external:m});const h=Date.now(),{config:d}=await import(`${o}?t=${h}`);return d},A=async e=>{const t=await re(e),n=new Set,o=(u,a=[])=>u?Object.entries(u).flatMap(([f,p])=>{if(!p)return;if(typeof p=="object")return o(p,[...a,f]);const P=[...a,f].join(".");n.add(`"${P}"`);const x=[...a.map(N.dashCase),N.dashCase(f)].join("-"),{result:y}=R.parseValueTokens(p);return`--${x}: ${y};`}):[],s=u=>u?Object.entries(u).flatMap(([a,f])=>{const p=o(f);return a==="base"?p.join(""):`${a} { ${p.join("")} }`}):[],m=u=>u?Object.entries(u).flatMap(([a,f])=>Object.entries(f).flatMap(([p,P])=>{const x=o(P,[a]),y=`.${a}-${p}, [data-${a}="${p}"]`,w=x.join("");return`${y} { ${w} }`})):[],h=o(t.variables),d=s(t.responsiveVariables),c=m(t.conditionalVariables),b=O(e),j=i.join(b,"css/variables.css"),k=`:root { ${h.join("")} ${d.join("")} } ${c.join("")}`;l.writeFileSync(j,k);const F=i.join(b,"types/css-tokens.d.ts"),r=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;l.writeFileSync(F,r);const g=i.join(b,"css/global.css"),C=R.parseStyles(t.global,"");l.writeFileSync(g,C);const S=i.join(b,"css/templates.css"),T=R.parseTemplates(t.templates);l.writeFileSync(S,T)},_=async(e,t,n)=>{const o=N.toHash(t),s=i.join(n,"js",o+".js"),m=await G(e),h=L(e);await H.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:m,target:["es2022"],keepNames:!0,external:h});const d=Date.now();return await import(`${s}?t=${d}`)},I=async e=>{const t=O(e),n=i.join(t,"salty.config.js"),{config:o}=await import(n);return o},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=ce())=>{try{t?v.info("Generating CSS in production mode! 🔥"):v.info("Generating CSS in development mode! 🚀");const n=[],o=[],s=O(e),m=i.join(s,"index.css");(()=>{l.existsSync(s)&&te.execSync("rm -rf "+s),l.mkdirSync(s),l.mkdirSync(i.join(s,"css")),l.mkdirSync(i.join(s,"types"))})(),await A(e);const d=await I(e);async function c(r,g){const C=["node_modules","saltygen"],S=l.statSync(r);if(S.isDirectory()){const T=l.readdirSync(r);if(C.some(a=>r.includes(a)))return;await Promise.all(T.map(a=>c(i.join(r,a),i.join(g,a))))}else if(S.isFile()&&V(r)){const u=await _(e,r,s),a=[];Object.entries(u).forEach(([x,y])=>{if(y.isKeyframes&&y.css){const z=`${y.animationName}.css`,Z=`css/${z}`,Q=i.join(s,Z);n.push(z),l.writeFileSync(Q,y.css);return}if(!y.generator)return;const w=y.generator._withBuildContext({name:x,config:d}),D=`${w.hash}-${w.priority}.css`;o[w.priority]||(o[w.priority]=[]),o[w.priority].push(D),a.push(D);const X=`css/${D}`,Y=i.join(s,X);l.writeFileSync(Y,w.css)});const f=a.map(x=>`@import url('./${x}');`).join(`
|
2
|
-
`),p=N.toHash(r,6),P=i.join(s,`css/${p}.css`);l.writeFileSync(P,f)}}await c(e,s);const b=n.map(r=>`@import url('./css/${r}');`).join(`
|
3
|
-
`);let $=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
4
|
-
|
5
|
-
${["variables.css","global.css","templates.css"].filter(r=>{try{return l.readFileSync(i.join(s,"css",r),"utf8").length>0}catch{return!1}}).map(r=>`@import url('./css/${r}');`).join(`
|
6
|
-
`)}
|
7
|
-
${b}`;if(d.importStrategy!=="component"){const r=o.flat().map(g=>`@import url('./css/${g}');`).join(`
|
8
|
-
`);$+=r}l.writeFileSync(m,$)}catch(n){console.error(n)}},le=async(e,t)=>{try{const n=[],o=i.join(e,"./saltygen"),s=i.join(o,"index.css");if(V(t)){const h=await I(e),d=await _(e,t,o);Object.entries(d).forEach(([F,$])=>{if(!$.generator)return;const r=$.generator._withBuildContext({name:F,config:h}),g=`${r.hash}-${r.priority}.css`,C=`css/${g}`,S=i.join(o,C);n.push(g),l.writeFileSync(S,r.css)});const c=l.readFileSync(s,"utf8").split(`
|
9
|
-
`),b=n.map(F=>`@import url('../saltygen/css/${F}');`),k=[...new Set([...c,...b])].join(`
|
10
|
-
`);l.writeFileSync(s,k)}}catch(n){console.error(n)}},ue=async(e,t)=>{try{const n=i.join(e,"./saltygen");if(V(t)){const s=l.readFileSync(t,"utf8");s.replace(/^(?!export\s)const\s.*/gm,j=>`export ${j}`)!==s&&await B.writeFile(t,s);const h=await I(e),d=await _(e,t,n);let c=s;Object.entries(d).forEach(([j,k])=>{var w;if(k.isKeyframes||!k.generator)return;const F=k.generator._withBuildContext({name:j,config:h}),$=new RegExp(`\\s${j}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(s);if(!$)return console.error("Could not find the original declaration");const r=(w=$.at(1))==null?void 0:w.trim(),g=new RegExp(`\\s${j}[=\\s]+styled\\(`,"g").exec(c);if(!g)return console.error("Could not find the original declaration");const{index:C}=g;let S=!1;const T=setTimeout(()=>S=!0,5e3);let u=0,a=!1,f=0;for(;!a&&!S;){const D=c[C+u];D==="("&&f++,D===")"&&f--,f===0&&D===")"&&(a=!0),u>c.length&&(S=!0),u++}if(!S)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const p=C+u,P=c.slice(C,p),x=c,y=` ${j} = styled(${r}, "${F.classNames}", "${F._callerName}", ${JSON.stringify(F.props)});`;c=c.replace(P,y),x===c&&console.error("Minimize file failed to change content",{name:j,tagName:r})});const b=N.toHash(t,6);return h.importStrategy==="component"&&(c=`import '../../saltygen/css/${b}.css';
|
11
|
-
${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=_;exports.generateConfigStyles=A;exports.generateCss=ae;exports.generateFile=le;exports.isSaltyFile=V;exports.logError=ie;exports.logger=v;exports.minimizeFile=ue;exports.saltyFileExtensions=W;exports.saltyFileRegExp=K;
|