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