@salty-css/core 0.0.1-alpha.59 → 0.0.1-alpha.60
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/compiler/index.cjs +1 -1
- package/compiler/index.js +35 -35
- package/package.json +1 -1
package/compiler/index.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("esbuild"),G=require("child_process"),N=require("../dash-case-DKzpenwY.cjs"),i=require("path"),a=require("fs"),J=require("fs/promises"),R=require("../parse-templates-DVK3iZIl.cjs");var V=typeof document<"u"?document.currentScript:null;function A(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const q=A(L),I=()=>(typeof document>"u"?require("url").pathToFileURL(__filename).href:V&&V.tagName.toUpperCase()==="SCRIPT"&&V.src||new URL("compiler/index.cjs",document.baseURI).href).endsWith(".cjs")?"cjs":"esm",O=e=>i.join(e,"./saltygen"),z=["salty","css","styles","styled"],B=(e=[])=>new RegExp(`\\.(${[...z,...e].join("|")})\\.`),v=(e,s=[])=>B(s).test(e),X=async e=>{const s=O(e),n=i.join(e,"salty.config.ts"),t=i.join(s,"salty.config.js"),l=I();console.log("Module type:",l),await q.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:l});const C=Date.now(),{config:d}=await import(`${t}?t=${C}`);return d},H=async e=>{const s=await X(e),n=new Set,t=(c,u=[])=>c?Object.entries(c).flatMap(([f,p])=>{if(!p)return;if(typeof p=="object")return t(p,[...u,f]);const w=[...u,f].join(".");n.add(`"${w}"`);const m=[...u.map(N.dashCase),N.dashCase(f)].join("-"),{result:h}=R.parseValueTokens(p);return`--${m}: ${h};`}):[],l=c=>c?Object.entries(c).flatMap(([u,f])=>{const p=t(f);return u==="base"?p.join(""):`${u} { ${p.join("")} }`}):[],C=c=>c?Object.entries(c).flatMap(([u,f])=>Object.entries(f).flatMap(([p,w])=>{const m=t(w,[u]),h=`.${u}-${p}, [data-${u}="${p}"]`,D=m.join("");return`${h} { ${D} }`})):[],d=t(s.variables),x=l(s.responsiveVariables),r=C(s.conditionalVariables),F=O(e),j=i.join(F,"css/variables.css"),T=`:root { ${d.join("")} ${x.join("")} } ${r.join("")}`;a.writeFileSync(j,T);const g=i.join(F,"types/css-tokens.d.ts"),y=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;a.writeFileSync(g,y);const $=i.join(F,"css/global.css"),b=R.parseStyles(s.global,"");a.writeFileSync($,b);const S=i.join(F,"css/templates.css"),k=R.parseTemplates(s.templates);a.writeFileSync(S,k)},E=async(e,s)=>{const n=N.toHash(e),t=i.join(s,"js",n+".js"),l=I();console.log("Module type:",l),await q.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:l,target:["es2022"],keepNames:!0});const C=Date.now();return await import(`${t}?t=${C}`)},_=async e=>{const s=O(e),n=i.join(s,"salty.config.js"),{config:t}=await import(n);return t},Y=async e=>{try{const s=[],n=[],t=O(e),l=i.join(t,"index.css");(()=>{a.existsSync(t)&&G.execSync("rm -rf "+t),a.mkdirSync(t),a.mkdirSync(i.join(t,"css")),a.mkdirSync(i.join(t,"types"))})(),await H(e);const d=await _(e);async function x(o,y){const $=["node_modules","saltygen"],b=a.statSync(o);if(b.isDirectory()){const S=a.readdirSync(o);if($.some(c=>o.includes(c)))return;await Promise.all(S.map(c=>x(i.join(o,c),i.join(y,c))))}else if(b.isFile()&&v(o)){const k=await E(o,t),c=[];Object.entries(k).forEach(([w,m])=>{if(m.isKeyframes&&m.css){const M=`${m.animationName}.css`,W=`css/${M}`,K=i.join(t,W);s.push(M),a.writeFileSync(K,m.css);return}if(!m.generator)return;const h=m.generator._withBuildContext({name:w,config:d}),D=`${h.hash}-${h.priority}.css`;n[h.priority]||(n[h.priority]=[]),n[h.priority].push(D),c.push(D);const P=`css/${D}`,U=i.join(t,P);a.writeFileSync(U,h.css)});const u=c.map(w=>`@import url('./${w}');`).join(`
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("esbuild"),G=require("child_process"),N=require("../dash-case-DKzpenwY.cjs"),i=require("path"),a=require("fs"),J=require("fs/promises"),R=require("../parse-templates-DVK3iZIl.cjs");var V=typeof document<"u"?document.currentScript:null;function A(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const q=A(L),I=()=>(typeof document>"u"?require("url").pathToFileURL(__filename).href:V&&V.tagName.toUpperCase()==="SCRIPT"&&V.src||new URL("compiler/index.cjs",document.baseURI).href).endsWith(".cjs")?"cjs":"esm",O=e=>i.join(e,"./saltygen"),z=["salty","css","styles","styled"],B=(e=[])=>new RegExp(`\\.(${[...z,...e].join("|")})\\.`),v=(e,s=[])=>B(s).test(e),X=async e=>{const s=O(e),n=i.join(e,"salty.config.ts"),t=i.join(s,"salty.config.js"),l=I();console.log("Module type:",l),await q.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:l,external:["react"]});const C=Date.now(),{config:d}=await import(`${t}?t=${C}`);return d},H=async e=>{const s=await X(e),n=new Set,t=(c,u=[])=>c?Object.entries(c).flatMap(([f,p])=>{if(!p)return;if(typeof p=="object")return t(p,[...u,f]);const w=[...u,f].join(".");n.add(`"${w}"`);const m=[...u.map(N.dashCase),N.dashCase(f)].join("-"),{result:h}=R.parseValueTokens(p);return`--${m}: ${h};`}):[],l=c=>c?Object.entries(c).flatMap(([u,f])=>{const p=t(f);return u==="base"?p.join(""):`${u} { ${p.join("")} }`}):[],C=c=>c?Object.entries(c).flatMap(([u,f])=>Object.entries(f).flatMap(([p,w])=>{const m=t(w,[u]),h=`.${u}-${p}, [data-${u}="${p}"]`,D=m.join("");return`${h} { ${D} }`})):[],d=t(s.variables),x=l(s.responsiveVariables),r=C(s.conditionalVariables),F=O(e),j=i.join(F,"css/variables.css"),T=`:root { ${d.join("")} ${x.join("")} } ${r.join("")}`;a.writeFileSync(j,T);const g=i.join(F,"types/css-tokens.d.ts"),y=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;a.writeFileSync(g,y);const $=i.join(F,"css/global.css"),b=R.parseStyles(s.global,"");a.writeFileSync($,b);const S=i.join(F,"css/templates.css"),k=R.parseTemplates(s.templates);a.writeFileSync(S,k)},E=async(e,s)=>{const n=N.toHash(e),t=i.join(s,"js",n+".js"),l=I();console.log("Module type:",l),await q.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:l,target:["es2022"],keepNames:!0,external:["react"]});const C=Date.now();return await import(`${t}?t=${C}`)},_=async e=>{const s=O(e),n=i.join(s,"salty.config.js"),{config:t}=await import(n);return t},Y=async e=>{try{const s=[],n=[],t=O(e),l=i.join(t,"index.css");(()=>{a.existsSync(t)&&G.execSync("rm -rf "+t),a.mkdirSync(t),a.mkdirSync(i.join(t,"css")),a.mkdirSync(i.join(t,"types"))})(),await H(e);const d=await _(e);async function x(o,y){const $=["node_modules","saltygen"],b=a.statSync(o);if(b.isDirectory()){const S=a.readdirSync(o);if($.some(c=>o.includes(c)))return;await Promise.all(S.map(c=>x(i.join(o,c),i.join(y,c))))}else if(b.isFile()&&v(o)){const k=await E(o,t),c=[];Object.entries(k).forEach(([w,m])=>{if(m.isKeyframes&&m.css){const M=`${m.animationName}.css`,W=`css/${M}`,K=i.join(t,W);s.push(M),a.writeFileSync(K,m.css);return}if(!m.generator)return;const h=m.generator._withBuildContext({name:w,config:d}),D=`${h.hash}-${h.priority}.css`;n[h.priority]||(n[h.priority]=[]),n[h.priority].push(D),c.push(D);const P=`css/${D}`,U=i.join(t,P);a.writeFileSync(U,h.css)});const u=c.map(w=>`@import url('./${w}');`).join(`
|
2
2
|
`),f=N.toHash(o,6),p=i.join(t,`css/${f}.css`);a.writeFileSync(p,u)}}await x(e,t);const r=s.map(o=>`@import url('./css/${o}');`).join(`
|
3
3
|
`);let g=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
4
4
|
|
package/compiler/index.js
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
import * as _ from "esbuild";
|
2
2
|
import { execSync as G } from "child_process";
|
3
3
|
import { t as E, d as I } from "../dash-case-DMQMcCO6.js";
|
4
|
-
import { join as
|
4
|
+
import { join as r } from "path";
|
5
5
|
import { writeFileSync as w, existsSync as J, mkdirSync as V, statSync as q, readdirSync as A, readFileSync as v } from "fs";
|
6
6
|
import { writeFile as L } from "fs/promises";
|
7
7
|
import { p as U, a as X, b as Y } from "../parse-templates-DUUSaubj.js";
|
8
|
-
const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) =>
|
9
|
-
const e = N(s), n =
|
8
|
+
const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) => r(s, "./saltygen"), Z = ["salty", "css", "styles", "styled"], Q = (s = []) => new RegExp(`\\.(${[...Z, ...s].join("|")})\\.`), M = (s, e = []) => Q(e).test(s), tt = async (s) => {
|
9
|
+
const e = N(s), n = r(s, "salty.config.ts"), t = r(e, "salty.config.js"), a = z();
|
10
10
|
console.log("Module type:", a), await _.build({
|
11
11
|
entryPoints: [n],
|
12
12
|
minify: !0,
|
13
13
|
treeShaking: !0,
|
14
14
|
bundle: !0,
|
15
15
|
outfile: t,
|
16
|
-
format: a
|
17
|
-
|
16
|
+
format: a,
|
17
|
+
external: ["react"]
|
18
18
|
});
|
19
19
|
const C = Date.now(), { config: y } = await import(`${t}?t=${C}`);
|
20
20
|
return y;
|
@@ -32,16 +32,16 @@ const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) => i(s
|
|
32
32
|
}) : [], C = (c) => c ? Object.entries(c).flatMap(([l, m]) => Object.entries(m).flatMap(([p, j]) => {
|
33
33
|
const g = t(j, [l]), d = `.${l}-${p}, [data-${l}="${p}"]`, k = g.join("");
|
34
34
|
return `${d} { ${k} }`;
|
35
|
-
})) : [], y = t(e.variables), x = a(e.responsiveVariables),
|
35
|
+
})) : [], y = t(e.variables), x = a(e.responsiveVariables), i = C(e.conditionalVariables), F = N(s), h = r(F, "css/variables.css"), D = `:root { ${y.join("")} ${x.join("")} } ${i.join("")}`;
|
36
36
|
w(h, D);
|
37
|
-
const u =
|
37
|
+
const u = r(F, "types/css-tokens.d.ts"), f = `type VariableTokens = ${[...n].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
38
38
|
w(u, f);
|
39
|
-
const S =
|
39
|
+
const S = r(F, "css/global.css"), b = U(e.global, "");
|
40
40
|
w(S, b);
|
41
|
-
const $ =
|
41
|
+
const $ = r(F, "css/templates.css"), T = X(e.templates);
|
42
42
|
w($, T);
|
43
43
|
}, O = async (s, e) => {
|
44
|
-
const n = E(s), t =
|
44
|
+
const n = E(s), t = r(e, "js", n + ".js"), a = z();
|
45
45
|
console.log("Module type:", a), await _.build({
|
46
46
|
entryPoints: [s],
|
47
47
|
minify: !0,
|
@@ -50,19 +50,19 @@ const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) => i(s
|
|
50
50
|
outfile: t,
|
51
51
|
format: a,
|
52
52
|
target: ["es2022"],
|
53
|
-
keepNames: !0
|
54
|
-
|
53
|
+
keepNames: !0,
|
54
|
+
external: ["react"]
|
55
55
|
});
|
56
56
|
const C = Date.now();
|
57
57
|
return await import(`${t}?t=${C}`);
|
58
58
|
}, R = async (s) => {
|
59
|
-
const e = N(s), n =
|
59
|
+
const e = N(s), n = r(e, "salty.config.js"), { config: t } = await import(n);
|
60
60
|
return t;
|
61
61
|
}, at = async (s) => {
|
62
62
|
try {
|
63
|
-
const e = [], n = [], t = N(s), a =
|
63
|
+
const e = [], n = [], t = N(s), a = r(t, "index.css");
|
64
64
|
(() => {
|
65
|
-
J(t) && G("rm -rf " + t), V(t), V(
|
65
|
+
J(t) && G("rm -rf " + t), V(t), V(r(t, "css")), V(r(t, "types"));
|
66
66
|
})(), await st(s);
|
67
67
|
const y = await R(s);
|
68
68
|
async function x(o, f) {
|
@@ -70,12 +70,12 @@ const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) => i(s
|
|
70
70
|
if (b.isDirectory()) {
|
71
71
|
const $ = A(o);
|
72
72
|
if (S.some((c) => o.includes(c))) return;
|
73
|
-
await Promise.all($.map((c) => x(
|
73
|
+
await Promise.all($.map((c) => x(r(o, c), r(f, c))));
|
74
74
|
} else if (b.isFile() && M(o)) {
|
75
75
|
const T = await O(o, t), c = [];
|
76
76
|
Object.entries(T).forEach(([j, g]) => {
|
77
77
|
if (g.isKeyframes && g.css) {
|
78
|
-
const B = `${g.animationName}.css`, H = `css/${B}`, K =
|
78
|
+
const B = `${g.animationName}.css`, H = `css/${B}`, K = r(t, H);
|
79
79
|
e.push(B), w(K, g.css);
|
80
80
|
return;
|
81
81
|
}
|
@@ -85,28 +85,28 @@ const z = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", N = (s) => i(s
|
|
85
85
|
config: y
|
86
86
|
}), k = `${d.hash}-${d.priority}.css`;
|
87
87
|
n[d.priority] || (n[d.priority] = []), n[d.priority].push(k), c.push(k);
|
88
|
-
const P = `css/${k}`, W =
|
88
|
+
const P = `css/${k}`, W = r(t, P);
|
89
89
|
w(W, d.css);
|
90
90
|
});
|
91
91
|
const l = c.map((j) => `@import url('./${j}');`).join(`
|
92
|
-
`), m = E(o, 6), p =
|
92
|
+
`), m = E(o, 6), p = r(t, `css/${m}.css`);
|
93
93
|
w(p, l);
|
94
94
|
}
|
95
95
|
}
|
96
96
|
await x(s, t);
|
97
|
-
const
|
97
|
+
const i = e.map((o) => `@import url('./css/${o}');`).join(`
|
98
98
|
`);
|
99
99
|
let u = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
100
100
|
|
101
101
|
${["variables.css", "global.css", "templates.css"].filter((o) => {
|
102
102
|
try {
|
103
|
-
return v(
|
103
|
+
return v(r(t, "css", o), "utf8").length > 0;
|
104
104
|
} catch {
|
105
105
|
return !1;
|
106
106
|
}
|
107
107
|
}).map((o) => `@import url('./css/${o}');`).join(`
|
108
108
|
`)}
|
109
|
-
${
|
109
|
+
${i}`;
|
110
110
|
if (y.importStrategy !== "component") {
|
111
111
|
const o = n.flat().map((f) => `@import url('./css/${f}');`).join(`
|
112
112
|
`);
|
@@ -118,7 +118,7 @@ ${r}`;
|
|
118
118
|
}
|
119
119
|
}, lt = async (s, e) => {
|
120
120
|
try {
|
121
|
-
const n = [], t =
|
121
|
+
const n = [], t = r(s, "./saltygen"), a = r(t, "index.css");
|
122
122
|
if (M(e)) {
|
123
123
|
const y = await R(s), x = await O(e, t);
|
124
124
|
Object.entries(x).forEach(([u, o]) => {
|
@@ -126,11 +126,11 @@ ${r}`;
|
|
126
126
|
const f = o.generator._withBuildContext({
|
127
127
|
name: u,
|
128
128
|
config: y
|
129
|
-
}), S = `${f.hash}-${f.priority}.css`, b = `css/${S}`, $ =
|
129
|
+
}), S = `${f.hash}-${f.priority}.css`, b = `css/${S}`, $ = r(t, b);
|
130
130
|
n.push(S), w($, f.css);
|
131
131
|
});
|
132
|
-
const
|
133
|
-
`), F = n.map((u) => `@import url('../saltygen/css/${u}');`), D = [.../* @__PURE__ */ new Set([...
|
132
|
+
const i = v(a, "utf8").split(`
|
133
|
+
`), F = n.map((u) => `@import url('../saltygen/css/${u}');`), D = [.../* @__PURE__ */ new Set([...i, ...F])].join(`
|
134
134
|
`);
|
135
135
|
w(a, D);
|
136
136
|
}
|
@@ -139,12 +139,12 @@ ${r}`;
|
|
139
139
|
}
|
140
140
|
}, pt = async (s, e) => {
|
141
141
|
try {
|
142
|
-
const n =
|
142
|
+
const n = r(s, "./saltygen");
|
143
143
|
if (M(e)) {
|
144
144
|
const a = v(e, "utf8");
|
145
145
|
a.replace(/^(?!export\s)const\s.*/gm, (h) => `export ${h}`) !== a && await L(e, a);
|
146
146
|
const y = await R(s), x = await O(e, n);
|
147
|
-
let
|
147
|
+
let i = a;
|
148
148
|
Object.entries(x).forEach(([h, D]) => {
|
149
149
|
var k;
|
150
150
|
if (D.isKeyframes || !D.generator) return;
|
@@ -153,24 +153,24 @@ ${r}`;
|
|
153
153
|
config: y
|
154
154
|
}), o = new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
|
155
155
|
if (!o) return console.error("Could not find the original declaration");
|
156
|
-
const f = (k = o.at(1)) == null ? void 0 : k.trim(), S = new RegExp(`\\s${h}[=\\s]+styled\\(`, "g").exec(
|
156
|
+
const f = (k = o.at(1)) == null ? void 0 : k.trim(), S = new RegExp(`\\s${h}[=\\s]+styled\\(`, "g").exec(i);
|
157
157
|
if (!S) return console.error("Could not find the original declaration");
|
158
158
|
const { index: b } = S;
|
159
159
|
let $ = !1;
|
160
160
|
const T = setTimeout(() => $ = !0, 5e3);
|
161
161
|
let c = 0, l = !1, m = 0;
|
162
162
|
for (; !l && !$; ) {
|
163
|
-
const P =
|
164
|
-
P === "(" && m++, P === ")" && m--, m === 0 && P === ")" && (l = !0), c >
|
163
|
+
const P = i[b + c];
|
164
|
+
P === "(" && m++, P === ")" && m--, m === 0 && P === ")" && (l = !0), c > i.length && ($ = !0), c++;
|
165
165
|
}
|
166
166
|
if (!$) clearTimeout(T);
|
167
167
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
168
|
-
const p = b + c, j =
|
169
|
-
|
168
|
+
const p = b + c, j = i.slice(b, p), g = i, d = ` ${h} = styled(${f}, "${u.classNames}", "${u._callerName}", ${JSON.stringify(u.props)});`;
|
169
|
+
i = i.replace(j, d), g === i && console.error("Minimize file failed to change content", { name: h, tagName: f });
|
170
170
|
});
|
171
171
|
const F = E(e, 6);
|
172
|
-
return y.importStrategy === "component" && (
|
173
|
-
${
|
172
|
+
return y.importStrategy === "component" && (i = `import '../../saltygen/css/${F}.css';
|
173
|
+
${i}`), i = i.replace("{ styled }", "{ styledClient as styled }"), i = i.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), i;
|
174
174
|
}
|
175
175
|
} catch (n) {
|
176
176
|
console.error("Error in minimizeFile:", n);
|