@salty-css/core 0.0.1-alpha.210 → 0.0.1-alpha.211
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 +11 -10
- package/config/index.cjs +1 -1
- package/config/index.js +10 -9
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/define-templates-4A2yHcMF.js +52 -0
- package/define-templates-Cunsb_Tr.cjs +1 -0
- package/generators/index.cjs +1 -1
- package/generators/index.js +1 -1
- package/index-B6M9WK93.cjs +38 -0
- package/index-B_bv7TCc.js +503 -0
- package/package.json +1 -1
- package/parse-styles-C6OYNcYI.cjs +5 -0
- package/parse-styles-Cc_Ir3PV.js +132 -0
- package/parsers/index.cjs +1 -1
- package/parsers/index.js +18 -64
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/index-B9PS8nEw.cjs +0 -38
- package/index-BzhU5E_2.js +0 -502
- package/parse-styles-B4adoYza.cjs +0 -5
- package/parse-styles-Bi-5cRYF.js +0 -128
package/parsers/index.js
CHANGED
@@ -1,76 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
constructor(t) {
|
7
|
-
this._current = t;
|
1
|
+
import { media as t } from "../css/media.js";
|
2
|
+
import { T as f, a as d, d as m } from "../define-templates-4A2yHcMF.js";
|
3
|
+
class a {
|
4
|
+
constructor(r) {
|
5
|
+
this._current = r;
|
8
6
|
}
|
9
7
|
get isGlobalDefine() {
|
10
8
|
return !0;
|
11
9
|
}
|
12
10
|
}
|
13
|
-
const
|
14
|
-
class
|
15
|
-
constructor(
|
16
|
-
this._current =
|
11
|
+
const o = (e) => new a(e), i = (e) => e(t);
|
12
|
+
class s {
|
13
|
+
constructor(r) {
|
14
|
+
this._current = r;
|
17
15
|
}
|
18
16
|
get isDefineVariables() {
|
19
17
|
return !0;
|
20
18
|
}
|
21
19
|
}
|
22
|
-
const
|
23
|
-
class o {
|
24
|
-
constructor(t) {
|
25
|
-
s(this, "_path");
|
26
|
-
this.params = t;
|
27
|
-
}
|
28
|
-
get _current() {
|
29
|
-
return this.params.template;
|
30
|
-
}
|
31
|
-
get isDefineTemplate() {
|
32
|
-
return !0;
|
33
|
-
}
|
34
|
-
_setPath(t) {
|
35
|
-
return this._path = t, this;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
class h {
|
39
|
-
constructor(t) {
|
40
|
-
s(this, "_path");
|
41
|
-
s(this, "templates", []);
|
42
|
-
this.params = t, Object.entries(t).forEach(([r, a]) => {
|
43
|
-
this.templates.push(
|
44
|
-
new o({
|
45
|
-
name: r,
|
46
|
-
template: a
|
47
|
-
})
|
48
|
-
);
|
49
|
-
});
|
50
|
-
}
|
51
|
-
get _current() {
|
52
|
-
return this.params;
|
53
|
-
}
|
54
|
-
get _children() {
|
55
|
-
return Object.fromEntries(
|
56
|
-
this.templates.map((t) => [t.params.name, t])
|
57
|
-
);
|
58
|
-
}
|
59
|
-
get isDefineTemplates() {
|
60
|
-
return !0;
|
61
|
-
}
|
62
|
-
_setPath(t) {
|
63
|
-
return this._path = t, this.templates.forEach((r) => r._setPath(t)), this;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
const d = (e) => new h(e);
|
20
|
+
const l = (e) => new s(e);
|
67
21
|
export {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
22
|
+
a as GlobalStylesFactory,
|
23
|
+
f as TemplateFactory,
|
24
|
+
d as TemplatesFactory,
|
25
|
+
s as VariablesFactory,
|
26
|
+
o as defineGlobalStyles,
|
27
|
+
i as defineMediaQuery,
|
28
|
+
m as defineTemplates,
|
29
|
+
l as defineVariables
|
76
30
|
};
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-B6M9WK93.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
|
package/server/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "../index-
|
2
|
+
import { i as e } from "../index-B_bv7TCc.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|
package/index-B9PS8nEw.cjs
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";const Ce=require("esbuild"),xe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-B4adoYza.cjs"),B=require("winston"),M=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function Ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pe=Ne(Ce),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[r,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const a=r.trim(),y=await ye(o,[...t,a]);s.push(y)}else n[r]=o;if(Object.keys(n).length){const r=t.map(D.dashCase).join("-"),o="t_"+D.toHash(r,4),a=await X.parseAndJoinStyles(n,`.${r}, .${o}`);s.push(a)}return s.join(`
|
2
|
-
`)},Pe=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(r=>`"${r}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,r])=>{const o=t?`${t}.${n}`:n;return typeof r=="object"?me(r,o,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:ge(i.join(e,".."))},ke=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await ke(e);if(t)return t.type};let H;const he=async e=>{if(H)return H;const t=await De(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-B9PS8nEw.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),_e=e=>{G.error(e)};function Se(e){return e?typeof e!="string"?Se(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 Oe={"*, *::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"}},V={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(V.externalModules.length>0)return V.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await re(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),Y=(e,t=[])=>we(t).test(e),be=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(i.join(e,".."))},re=async e=>{var n,r;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(o=>e.endsWith(o.dir||""));return s||((r=t.projects)==null?void 0:r.find(o=>o.dir===t.defaultProject))},Ee=async e=>{const t=await re(e),s=await v(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),o=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:o,external:a});const y=Date.now(),{config:F}=await import(`${r}?t=${y}`);return F},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await K(e,m,s);Object.entries(b).forEach(([N,O])=>{O.isMedia?n.mediaQueries.push([N,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${N};;${R}`))})}));const r=await Ee(e),o={...r},a=new Set,y=(m,b=[])=>m?Object.entries(m).flatMap(([R,N])=>{if(!N)return;if(typeof N=="object")return y(N,[...b,R]);const O=Se(R),te=D.dashCase(R),se=[...b,O].join(".");a.add(`"${se}"`);const U=[...b.map(D.dashCase),te].join("-"),ue=X.parseVariableTokens(N);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${N};`}):[],F=m=>m?Object.entries(m).flatMap(([b,R])=>{const N=y(R);return b==="base"?N.join(""):`${b} { ${N.join("")} }`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([N,O])=>{const te=y(O,[b]),se=`.${b}-${N}, [data-${b}="${N}"]`,U=te.join("");return`${se} { ${U} }`})):[],d=m=>({...m,responsive:void 0,conditional:void 0}),g=m=>n.variables.map(b=>m==="static"?d(b._current):b._current[m]),p=M.mergeObjects(d(r.variables),g("static")),j=y(p),h=M.mergeObjects((le=r.variables)==null?void 0:le.responsive,g("responsive")),C=F(h),P=M.mergeObjects((fe=r.variables)==null?void 0:fe.conditional,g("conditional")),k=l(P),J=i.join(s,"css/_variables.css"),E=`:root { ${j.join("")} ${C.join("")} } ${k.join("")}`;c.writeFileSync(J,E),o.staticVariables=p;const q=i.join(s,"css/_global.css"),_=M.mergeObjects(r.global,n.globalStyles),I=await X.parseAndJoinStyles(_,"");c.writeFileSync(q,`@layer global { ${I} }`);const f=i.join(s,"css/_reset.css"),w=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Oe,u=await X.parseAndJoinStyles(w,"");c.writeFileSync(f,`@layer reset { ${u} }`);const $=i.join(s,"css/_templates.css"),x=M.mergeObjects(r.templates,n.templates),T=await ye(x),W=Pe(x);c.writeFileSync($,`@layer templates { ${T} }`),o.templates=x;const A=M.mergeFactories(n.templates);o.templatePaths=Object.fromEntries(Object.entries(A).map(([m,b])=>[m,b._path]));const{mediaQueries:z}=n;o.mediaQueries=Object.fromEntries(z.map(([m,b])=>[`@${m}`,b]));const L=z.map(([m])=>`'@${m}'`).join(" | "),ee=i.join(s,"types/css-tokens.d.ts"),Z=`
|
3
|
-
// Variable types
|
4
|
-
type VariableTokens = ${[...a].join("|")};
|
5
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
6
|
-
|
7
|
-
// Template types
|
8
|
-
type TemplateTokens = {
|
9
|
-
${Object.entries(W).map(([m,b])=>`${m}?: ${b}`).join(`
|
10
|
-
`)}
|
11
|
-
}
|
12
|
-
|
13
|
-
// Media query types
|
14
|
-
type MediaQueryKeys = ${L||"''"};
|
15
|
-
`;c.writeFileSync(ee,Z);const Fe=i.join(s,"cache/config-cache.json");c.writeFileSync(Fe,JSON.stringify(o,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const a=r.exec(e);if(a){const y=a.at(1);if(ie.some(l=>y==null?void 0:y.includes(l)))return t}return"styled('div',"}),Te=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
16
|
-
|
17
|
-
${e}`:`globalThis.saltyConfig = {};
|
18
|
-
|
19
|
-
${e}`}catch{return e}},K=async(e,t,s)=>{const n=D.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const o=i.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Te(a,e);const y=i.join(s,"js",n+".js"),F=await re(e),l=i.join(e,(F==null?void 0:F.configDir)||"","salty.config.ts"),d=je(l),g=await he(e);await pe.build({stdin:{contents:a,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const P=c.readFileSync(C.path,"utf8");return{contents:de(P),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${y}?t=${p}`),outputFilePath:y}},Re=async e=>{const t=await v(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Re(e),s=await v(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:o}=await import(`${n}?t=${r}`);return M.mergeObjects(o,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ve=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const r=[],o=[],a=await v(e),y=i.join(a,"index.css");s&&(()=>{c.existsSync(a)&&xe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(i.join(a,"css")),c.mkdirSync(i.join(a,"types")),c.mkdirSync(i.join(a,"js")),c.mkdirSync(i.join(a,"cache"))})();const l=new Set,d=new Set;async function g(f){const S=["node_modules","saltygen"],w=c.statSync(f);if(w.isDirectory()){const u=c.readdirSync(f);if(S.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>g(i.join(f,x))))}else if(w.isFile()&&Y(f)){l.add(f);const $=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test($)&&d.add(f)}}await g(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:S}=await K(e,f,a);Object.entries(S).forEach(([w,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:w}):u.isClassName?p.classNames.push({...u,src:f,name:w}):u.generator&&p.components.push({...u,src:f,name:w})})}));const j=await ae(e);for(const f of p.keyframes){const{value:S}=f,w=`a_${S.animationName}.css`,u=`css/${w}`,$=i.join(a,u);r.push(w),c.writeFileSync($,S.css)}const h={};for(const f of p.components){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j});o[u.priority]||(o[u.priority]=[]);const $=await u.css;if(!$)continue;o[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}for(const f of p.classNames){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j}),$=await u.css;if(!$)continue;o[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}j.importStrategy==="component"&&Object.entries(h).forEach(([f,S])=>{const w=S.map(W=>`@import url('./${W}');`).join(`
|
20
|
-
`),u=D.toHash(f,6),$=i.parse(f),x=D.dashCase($.name),T=i.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(T,w||"/* Empty file */")});const C=r.map(f=>`@import url('./css/${f}');`).join(`
|
21
|
-
`);let E=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
22
|
-
|
23
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return c.readFileSync(i.join(a,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
24
|
-
`)}
|
25
|
-
${C}`;if(j.importStrategy!=="component"){const f=o.reduce((S,w,u)=>{const $=w.reduce((A,z)=>{var Z;const L=i.join(a,"css",z),ee=c.readFileSync(L,"utf8"),Q=((Z=/.*-([^-]+)-\d+.css/.exec(z))==null?void 0:Z.at(1))||D.toHash(L,6);return A.includes(Q)?A:`${A}
|
26
|
-
/*start:${Q}-${z}*/
|
27
|
-
${ee}
|
28
|
-
/*end:${Q}*/
|
29
|
-
`},""),x=`l_${u}.css`,T=i.join(a,"css",x),W=`@layer l${u} { ${$}
|
30
|
-
}`;return c.writeFileSync(T,W),`${S}
|
31
|
-
@import url('./css/${x}');`},"");E+=f}c.writeFileSync(y,E);const _=Date.now()-n,I=_<200?"🔥":_<500?"🚀":_<1e3?"🎉":_<2e3?"🚗":_<5e3?"🤔":"🥴";G.info(`Generated CSS in ${_}ms! ${I}`)}catch(n){console.error(n)}},Me=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=[],a=await ae(e),{contents:y}=await K(e,t,n);for(const[F,l]of Object.entries(y)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,P=i.join(n,C);c.writeFileSync(P,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),C=await h.css;if(!C)continue;o[0].push(h.cssFileName);const P=`css/${h.cssFileName}`,k=i.join(n,P);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),g=await d.css;if(!g)continue;const p=`css/${d.cssFileName}`,j=i.join(n,p);c.writeFileSync(j,g),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")o.forEach((F,l)=>{const d=`l_${l}.css`,g=i.join(n,"css",d);let p=c.readFileSync(g,"utf8");F.forEach(j=>{var k;const h=i.join(n,"css",j),C=((k=/.*-([^-]+)-\d+.css/.exec(j))==null?void 0:k.at(1))||D.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),E=`/*start:${C}-${j}*/
|
32
|
-
${J}
|
33
|
-
/*end:${C}*/
|
34
|
-
`;p=`${p.replace(/\}$/,"")}
|
35
|
-
${E}
|
36
|
-
}`}}),c.writeFileSync(g,p)});else{const F=o.flat().map(j=>`@import url('./${j}');`).join(`
|
37
|
-
`),l=D.toHash(t,6),d=i.parse(t),g=D.dashCase(d.name),p=i.join(n,`css/f_${g}-${l}.css`);c.writeFileSync(p,F||"/* Empty file */")}}}catch(n){console.error(n)}},ve=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=c.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==o&&await oe.writeFile(t,o);const y=await ae(e),{contents:F}=await K(e,t,n);let l=o;if(Object.entries(F).forEach(([d,g])=>{var u;if(g.isKeyframes||!g.generator)return;const p=g.generator._withBuildContext({callerName:d,isProduction:s,config:y}),j=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!j)return console.error("Could not find the original declaration");const h=(u=j.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:P}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let E=0,q=!1,_=0;for(;!q&&!k;){const $=l[P+E];$==="("&&_++,$===")"&&_--,_===0&&$===")"&&(q=!0),E>l.length&&(k=!0),E++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const I=P+E,f=l.slice(P,I),S=l,w=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,w),S===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),y.importStrategy==="component"){const d=D.toHash(t,6),g=i.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(g.name)}-${d}.css`}';
|
38
|
-
${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=K;exports.generateConfigStyles=$e;exports.generateCss=Ve;exports.generateFile=Me;exports.isSaltyFile=Y;exports.logError=_e;exports.logger=G;exports.minimizeFile=ve;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;
|
package/index-BzhU5E_2.js
DELETED
@@ -1,502 +0,0 @@
|
|
1
|
-
import * as gt from "esbuild";
|
2
|
-
import { execSync as Nt } from "child_process";
|
3
|
-
import { d as G, t as v } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as r, parse as Y } from "path";
|
5
|
-
import { existsSync as it, writeFileSync as x, mkdirSync as I, readFileSync as T, statSync as Pt, readdirSync as kt } from "fs";
|
6
|
-
import { readFile as yt, writeFile as Dt } from "fs/promises";
|
7
|
-
import { p as at, a as _t } from "./parse-styles-Bi-5cRYF.js";
|
8
|
-
import { createLogger as Et, format as ot, transports as Tt } from "winston";
|
9
|
-
import { mergeObjects as B, mergeFactories as Ot } from "./css/merge.js";
|
10
|
-
const ht = async (t, e = []) => {
|
11
|
-
if (!t) return "";
|
12
|
-
const s = [], n = {};
|
13
|
-
for (const [a, o] of Object.entries(t))
|
14
|
-
if (typeof o != "function") if (o && typeof o == "object") {
|
15
|
-
const i = a.trim(), d = await ht(o, [...e, i]);
|
16
|
-
s.push(d);
|
17
|
-
} else
|
18
|
-
n[a] = o;
|
19
|
-
if (Object.keys(n).length) {
|
20
|
-
const a = e.map(G).join("-"), o = "t_" + v(a, 4), i = await at(n, `.${a}, .${o}`);
|
21
|
-
s.push(i);
|
22
|
-
}
|
23
|
-
return s.join(`
|
24
|
-
`);
|
25
|
-
}, Vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((a) => `"${a}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, a]) => {
|
26
|
-
const o = e ? `${e}.${n}` : n;
|
27
|
-
return typeof a == "object" ? $t(a, o, s) : s.add(e);
|
28
|
-
}), [...s]) : [], bt = (t) => {
|
29
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
30
|
-
const e = r(t, "package.json");
|
31
|
-
return it(e) ? e : bt(r(t, ".."));
|
32
|
-
}, Mt = async (t) => {
|
33
|
-
const e = bt(t);
|
34
|
-
return await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
35
|
-
});
|
36
|
-
}, vt = async (t) => {
|
37
|
-
const e = await Mt(t);
|
38
|
-
if (e)
|
39
|
-
return e.type;
|
40
|
-
};
|
41
|
-
let W;
|
42
|
-
const wt = async (t) => {
|
43
|
-
if (W) return W;
|
44
|
-
const e = await vt(t);
|
45
|
-
return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
|
46
|
-
}, X = Et({
|
47
|
-
level: "debug",
|
48
|
-
format: ot.combine(ot.colorize(), ot.cli()),
|
49
|
-
transports: [new Tt.Console({})]
|
50
|
-
}), Ut = (t) => {
|
51
|
-
X.error(t);
|
52
|
-
};
|
53
|
-
function St(t) {
|
54
|
-
return t ? typeof t != "string" ? St(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
55
|
-
}
|
56
|
-
const Rt = {
|
57
|
-
/** Set box model to border-box */
|
58
|
-
"*, *::before, *::after": {
|
59
|
-
boxSizing: "border-box"
|
60
|
-
},
|
61
|
-
/** Remove default margin and padding */
|
62
|
-
"*": {
|
63
|
-
margin: 0
|
64
|
-
},
|
65
|
-
/** Remove adjust font properties */
|
66
|
-
html: {
|
67
|
-
lineHeight: 1.15,
|
68
|
-
textSizeAdjust: "100%",
|
69
|
-
WebkitFontSmoothing: "antialiased"
|
70
|
-
},
|
71
|
-
/** Make media elements responsive */
|
72
|
-
"img, picture, video, canvas, svg": {
|
73
|
-
display: "block",
|
74
|
-
maxWidth: "100%"
|
75
|
-
},
|
76
|
-
/** Avoid overflow of text */
|
77
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
78
|
-
overflowWrap: "break-word"
|
79
|
-
},
|
80
|
-
/** Improve text wrapping */
|
81
|
-
p: {
|
82
|
-
textWrap: "pretty"
|
83
|
-
},
|
84
|
-
"h1, h2, h3, h4, h5, h6": {
|
85
|
-
textWrap: "balance"
|
86
|
-
},
|
87
|
-
/** Improve link color */
|
88
|
-
a: {
|
89
|
-
color: "currentColor"
|
90
|
-
},
|
91
|
-
/** Improve button line height */
|
92
|
-
button: {
|
93
|
-
lineHeight: "1em",
|
94
|
-
color: "currentColor"
|
95
|
-
},
|
96
|
-
/** Improve form elements */
|
97
|
-
"input, optgroup, select, textarea": {
|
98
|
-
fontFamily: "inherit",
|
99
|
-
fontSize: "100%",
|
100
|
-
lineHeight: "1.15em"
|
101
|
-
}
|
102
|
-
}, M = {
|
103
|
-
externalModules: [],
|
104
|
-
rcFile: void 0,
|
105
|
-
destDir: void 0
|
106
|
-
}, Ct = (t) => {
|
107
|
-
if (M.externalModules.length > 0) return M.externalModules;
|
108
|
-
const s = T(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
109
|
-
if (!s) return [];
|
110
|
-
const n = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
|
111
|
-
return M.externalModules = n, n;
|
112
|
-
}, R = async (t) => {
|
113
|
-
if (M.destDir) return M.destDir;
|
114
|
-
const e = await ct(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
115
|
-
return M.destDir = s, s;
|
116
|
-
}, jt = ["salty", "css", "styles", "styled"], Jt = (t = []) => new RegExp(`\\.(${[...jt, ...t].join("|")})\\.`), rt = (t, e = []) => Jt(e).test(t), Ft = async (t) => {
|
117
|
-
if (M.rcFile) return M.rcFile;
|
118
|
-
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
119
|
-
const e = r(t, ".saltyrc.json"), s = await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
120
|
-
});
|
121
|
-
return s ? (M.rcFile = s, s) : Ft(r(t, ".."));
|
122
|
-
}, ct = async (t) => {
|
123
|
-
var n, a;
|
124
|
-
const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((o) => t.endsWith(o.dir || ""));
|
125
|
-
return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
|
126
|
-
}, zt = async (t) => {
|
127
|
-
const e = await ct(t), s = await R(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await wt(t), i = Ct(n);
|
128
|
-
await gt.build({
|
129
|
-
entryPoints: [n],
|
130
|
-
minify: !0,
|
131
|
-
treeShaking: !0,
|
132
|
-
bundle: !0,
|
133
|
-
outfile: a,
|
134
|
-
format: o,
|
135
|
-
external: i
|
136
|
-
});
|
137
|
-
const d = Date.now(), { config: C } = await import(`${a}?t=${d}`);
|
138
|
-
return C;
|
139
|
-
}, Wt = async (t, e) => {
|
140
|
-
var ut, pt;
|
141
|
-
const s = await R(t), n = {
|
142
|
-
mediaQueries: [],
|
143
|
-
globalStyles: [],
|
144
|
-
variables: [],
|
145
|
-
templates: []
|
146
|
-
};
|
147
|
-
await Promise.all(
|
148
|
-
[...e].map(async (m) => {
|
149
|
-
const { contents: w, outputFilePath: V } = await tt(t, m, s);
|
150
|
-
Object.entries(w).forEach(([N, _]) => {
|
151
|
-
_.isMedia ? n.mediaQueries.push([N, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${N};;${V}`));
|
152
|
-
});
|
153
|
-
})
|
154
|
-
);
|
155
|
-
const a = await zt(t), o = { ...a }, i = /* @__PURE__ */ new Set(), d = (m, w = []) => m ? Object.entries(m).flatMap(([V, N]) => {
|
156
|
-
if (!N) return;
|
157
|
-
if (typeof N == "object") return d(N, [...w, V]);
|
158
|
-
const _ = St(V), st = G(V), nt = [...w, _].join(".");
|
159
|
-
i.add(`"${nt}"`);
|
160
|
-
const U = [...w.map(G), st].join("-"), dt = _t(N);
|
161
|
-
return dt ? `--${U}: ${dt.transformed};` : `--${U}: ${N};`;
|
162
|
-
}) : [], C = (m) => m ? Object.entries(m).flatMap(([w, V]) => {
|
163
|
-
const N = d(V);
|
164
|
-
return w === "base" ? N.join("") : `${w} { ${N.join("")} }`;
|
165
|
-
}) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
|
166
|
-
const st = d(_, [w]), nt = `.${w}-${N}, [data-${w}="${N}"]`, U = st.join("");
|
167
|
-
return `${nt} { ${U} }`;
|
168
|
-
})) : [], u = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), g = (m) => n.variables.map((w) => m === "static" ? u(w._current) : w._current[m]), p = B(u(a.variables), g("static")), $ = d(p), y = B((ut = a.variables) == null ? void 0 : ut.responsive, g("responsive")), j = C(y), P = B((pt = a.variables) == null ? void 0 : pt.conditional, g("conditional")), k = c(P), J = r(s, "css/_variables.css"), E = `:root { ${$.join("")} ${j.join("")} } ${k.join("")}`;
|
169
|
-
x(J, E), o.staticVariables = p;
|
170
|
-
const H = r(s, "css/_global.css"), D = B(a.global, n.globalStyles), K = await at(D, "");
|
171
|
-
x(H, `@layer global { ${K} }`);
|
172
|
-
const l = r(s, "css/_reset.css"), b = a.reset === "none" ? {} : typeof a.reset == "object" ? a.reset : Rt, f = await at(b, "");
|
173
|
-
x(l, `@layer reset { ${f} }`);
|
174
|
-
const S = r(s, "css/_templates.css"), F = B(a.templates, n.templates), O = await ht(F), A = Vt(F);
|
175
|
-
x(S, `@layer templates { ${O} }`), o.templates = F;
|
176
|
-
const L = Ot(n.templates);
|
177
|
-
o.templatePaths = Object.fromEntries(Object.entries(L).map(([m, w]) => [m, w._path]));
|
178
|
-
const { mediaQueries: z } = n;
|
179
|
-
o.mediaQueries = Object.fromEntries(z.map(([m, w]) => [`@${m}`, w]));
|
180
|
-
const Q = z.map(([m]) => `'@${m}'`).join(" | "), et = r(s, "types/css-tokens.d.ts"), q = `
|
181
|
-
// Variable types
|
182
|
-
type VariableTokens = ${[...i].join("|")};
|
183
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
184
|
-
|
185
|
-
// Template types
|
186
|
-
type TemplateTokens = {
|
187
|
-
${Object.entries(A).map(([m, w]) => `${m}?: ${w}`).join(`
|
188
|
-
`)}
|
189
|
-
}
|
190
|
-
|
191
|
-
// Media query types
|
192
|
-
type MediaQueryKeys = ${Q || "''"};
|
193
|
-
`;
|
194
|
-
x(et, q);
|
195
|
-
const xt = r(s, "cache/config-cache.json");
|
196
|
-
x(xt, JSON.stringify(o, null, 2));
|
197
|
-
}, mt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
198
|
-
if (/^['"`]/.test(s)) return e;
|
199
|
-
const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
200
|
-
if (!a.test(t)) return e;
|
201
|
-
const i = a.exec(t);
|
202
|
-
if (i) {
|
203
|
-
const d = i.at(1);
|
204
|
-
if (jt.some((c) => d == null ? void 0 : d.includes(c))) return e;
|
205
|
-
}
|
206
|
-
return "styled('div',";
|
207
|
-
}), It = (t, e) => {
|
208
|
-
try {
|
209
|
-
const s = T(r(e, "saltygen/cache/config-cache.json"), "utf8");
|
210
|
-
return s ? `globalThis.saltyConfig = ${s};
|
211
|
-
|
212
|
-
${t}` : `globalThis.saltyConfig = {};
|
213
|
-
|
214
|
-
${t}`;
|
215
|
-
} catch {
|
216
|
-
return t;
|
217
|
-
}
|
218
|
-
}, tt = async (t, e, s) => {
|
219
|
-
const n = v(e), a = r(s, "./temp");
|
220
|
-
it(a) || I(a);
|
221
|
-
const o = Y(e);
|
222
|
-
let i = T(e, "utf8");
|
223
|
-
i = mt(i), i = It(i, t);
|
224
|
-
const d = r(s, "js", n + ".js"), C = await ct(t), c = r(t, (C == null ? void 0 : C.configDir) || "", "salty.config.ts"), u = Ct(c), g = await wt(t);
|
225
|
-
await gt.build({
|
226
|
-
stdin: {
|
227
|
-
contents: i,
|
228
|
-
sourcefile: o.base,
|
229
|
-
resolveDir: o.dir,
|
230
|
-
loader: "tsx"
|
231
|
-
},
|
232
|
-
minify: !1,
|
233
|
-
treeShaking: !0,
|
234
|
-
bundle: !0,
|
235
|
-
outfile: d,
|
236
|
-
format: g,
|
237
|
-
target: ["node20"],
|
238
|
-
keepNames: !0,
|
239
|
-
external: u,
|
240
|
-
packages: "external",
|
241
|
-
plugins: [
|
242
|
-
{
|
243
|
-
name: "test",
|
244
|
-
setup: (y) => {
|
245
|
-
y.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
|
246
|
-
const P = T(j.path, "utf8");
|
247
|
-
return { contents: mt(P), loader: "ts" };
|
248
|
-
});
|
249
|
-
}
|
250
|
-
}
|
251
|
-
]
|
252
|
-
});
|
253
|
-
const p = Date.now();
|
254
|
-
return { contents: await import(`${d}?t=${p}`), outputFilePath: d };
|
255
|
-
}, Bt = async (t) => {
|
256
|
-
const e = await R(t), s = r(e, "cache/config-cache.json"), n = T(s, "utf8");
|
257
|
-
if (!n) throw new Error("Could not find config cache file");
|
258
|
-
return JSON.parse(n);
|
259
|
-
}, lt = async (t) => {
|
260
|
-
const e = await Bt(t), s = await R(t), n = r(s, "salty.config.js"), a = Date.now(), { config: o } = await import(`${n}?t=${a}`);
|
261
|
-
return B(o, e);
|
262
|
-
}, ft = () => {
|
263
|
-
try {
|
264
|
-
return process.env.NODE_ENV === "production";
|
265
|
-
} catch {
|
266
|
-
return !1;
|
267
|
-
}
|
268
|
-
}, Xt = async (t, e = ft(), s = !0) => {
|
269
|
-
try {
|
270
|
-
const n = Date.now();
|
271
|
-
e ? X.info("Generating CSS in production mode! 🔥") : X.info("Generating CSS in development mode! 🚀");
|
272
|
-
const a = [], o = [], i = await R(t), d = r(i, "index.css");
|
273
|
-
s && (() => {
|
274
|
-
it(i) && Nt("rm -rf " + i), I(i, { recursive: !0 }), I(r(i, "css")), I(r(i, "types")), I(r(i, "js")), I(r(i, "cache"));
|
275
|
-
})();
|
276
|
-
const c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
277
|
-
async function g(l) {
|
278
|
-
const h = ["node_modules", "saltygen"], b = Pt(l);
|
279
|
-
if (b.isDirectory()) {
|
280
|
-
const f = kt(l);
|
281
|
-
if (h.some((F) => l.includes(F))) return;
|
282
|
-
await Promise.all(f.map((F) => g(r(l, F))));
|
283
|
-
} else if (b.isFile() && rt(l)) {
|
284
|
-
c.add(l);
|
285
|
-
const S = T(l, "utf8");
|
286
|
-
/define[\w\d]+\(/.test(S) && u.add(l);
|
287
|
-
}
|
288
|
-
}
|
289
|
-
await g(t), await Wt(t, u);
|
290
|
-
const p = {
|
291
|
-
keyframes: [],
|
292
|
-
components: [],
|
293
|
-
classNames: []
|
294
|
-
};
|
295
|
-
await Promise.all(
|
296
|
-
[...c].map(async (l) => {
|
297
|
-
const { contents: h } = await tt(t, l, i);
|
298
|
-
Object.entries(h).forEach(([b, f]) => {
|
299
|
-
f.isKeyframes ? p.keyframes.push({
|
300
|
-
value: f,
|
301
|
-
src: l,
|
302
|
-
name: b
|
303
|
-
}) : f.isClassName ? p.classNames.push({
|
304
|
-
...f,
|
305
|
-
src: l,
|
306
|
-
name: b
|
307
|
-
}) : f.generator && p.components.push({
|
308
|
-
...f,
|
309
|
-
src: l,
|
310
|
-
name: b
|
311
|
-
});
|
312
|
-
});
|
313
|
-
})
|
314
|
-
);
|
315
|
-
const $ = await lt(t);
|
316
|
-
for (const l of p.keyframes) {
|
317
|
-
const { value: h } = l, b = `a_${h.animationName}.css`, f = `css/${b}`, S = r(i, f);
|
318
|
-
a.push(b), x(S, h.css);
|
319
|
-
}
|
320
|
-
const y = {};
|
321
|
-
for (const l of p.components) {
|
322
|
-
const { src: h, name: b } = l;
|
323
|
-
y[h] || (y[h] = []);
|
324
|
-
const f = l.generator._withBuildContext({
|
325
|
-
callerName: b,
|
326
|
-
isProduction: e,
|
327
|
-
config: $
|
328
|
-
});
|
329
|
-
o[f.priority] || (o[f.priority] = []);
|
330
|
-
const S = await f.css;
|
331
|
-
if (!S) continue;
|
332
|
-
o[f.priority].push(f.cssFileName);
|
333
|
-
const F = `css/${f.cssFileName}`, O = r(i, F);
|
334
|
-
x(O, S), $.importStrategy === "component" && y[h].push(f.cssFileName);
|
335
|
-
}
|
336
|
-
for (const l of p.classNames) {
|
337
|
-
const { src: h, name: b } = l;
|
338
|
-
y[h] || (y[h] = []);
|
339
|
-
const f = l.generator._withBuildContext({
|
340
|
-
callerName: b,
|
341
|
-
isProduction: e,
|
342
|
-
config: $
|
343
|
-
}), S = await f.css;
|
344
|
-
if (!S) continue;
|
345
|
-
o[0].push(f.cssFileName);
|
346
|
-
const F = `css/${f.cssFileName}`, O = r(i, F);
|
347
|
-
x(O, S), $.importStrategy === "component" && y[h].push(f.cssFileName);
|
348
|
-
}
|
349
|
-
$.importStrategy === "component" && Object.entries(y).forEach(([l, h]) => {
|
350
|
-
const b = h.map((A) => `@import url('./${A}');`).join(`
|
351
|
-
`), f = v(l, 6), S = Y(l), F = G(S.name), O = r(i, `css/f_${F}-${f}.css`);
|
352
|
-
x(O, b || "/* Empty file */");
|
353
|
-
});
|
354
|
-
const j = a.map((l) => `@import url('./css/${l}');`).join(`
|
355
|
-
`);
|
356
|
-
let E = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
357
|
-
|
358
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
359
|
-
try {
|
360
|
-
return T(r(i, "css", l), "utf8").length > 0;
|
361
|
-
} catch {
|
362
|
-
return !1;
|
363
|
-
}
|
364
|
-
}).map((l) => `@import url('./css/${l}');`).join(`
|
365
|
-
`)}
|
366
|
-
${j}`;
|
367
|
-
if ($.importStrategy !== "component") {
|
368
|
-
const l = o.reduce((h, b, f) => {
|
369
|
-
const S = b.reduce((L, z) => {
|
370
|
-
var q;
|
371
|
-
const Q = r(i, "css", z), et = T(Q, "utf8"), Z = ((q = /.*-([^-]+)-\d+.css/.exec(z)) == null ? void 0 : q.at(1)) || v(Q, 6);
|
372
|
-
return L.includes(Z) ? L : `${L}
|
373
|
-
/*start:${Z}-${z}*/
|
374
|
-
${et}
|
375
|
-
/*end:${Z}*/
|
376
|
-
`;
|
377
|
-
}, ""), F = `l_${f}.css`, O = r(i, "css", F), A = `@layer l${f} { ${S}
|
378
|
-
}`;
|
379
|
-
return x(O, A), `${h}
|
380
|
-
@import url('./css/${F}');`;
|
381
|
-
}, "");
|
382
|
-
E += l;
|
383
|
-
}
|
384
|
-
x(d, E);
|
385
|
-
const D = Date.now() - n, K = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
|
386
|
-
X.info(`Generated CSS in ${D}ms! ${K}`);
|
387
|
-
} catch (n) {
|
388
|
-
console.error(n);
|
389
|
-
}
|
390
|
-
}, Yt = async (t, e, s = ft()) => {
|
391
|
-
try {
|
392
|
-
const n = await R(t);
|
393
|
-
if (rt(e)) {
|
394
|
-
const o = [], i = await lt(t), { contents: d } = await tt(t, e, n);
|
395
|
-
for (const [C, c] of Object.entries(d)) {
|
396
|
-
if (c.isKeyframes && c.css) {
|
397
|
-
const j = `css/${`a_${c.animationName}.css`}`, P = r(n, j);
|
398
|
-
x(P, await c.css);
|
399
|
-
return;
|
400
|
-
}
|
401
|
-
if (c.isClassName) {
|
402
|
-
const y = c.generator._withBuildContext({
|
403
|
-
callerName: C,
|
404
|
-
isProduction: s,
|
405
|
-
config: i
|
406
|
-
}), j = await y.css;
|
407
|
-
if (!j) continue;
|
408
|
-
o[0].push(y.cssFileName);
|
409
|
-
const P = `css/${y.cssFileName}`, k = r(n, P);
|
410
|
-
x(k, j);
|
411
|
-
}
|
412
|
-
if (!c.generator) return;
|
413
|
-
const u = c.generator._withBuildContext({
|
414
|
-
callerName: C,
|
415
|
-
isProduction: s,
|
416
|
-
config: i
|
417
|
-
}), g = await u.css;
|
418
|
-
if (!g) continue;
|
419
|
-
const p = `css/${u.cssFileName}`, $ = r(n, p);
|
420
|
-
x($, g), o[u.priority] || (o[u.priority] = []), o[u.priority].push(u.cssFileName);
|
421
|
-
}
|
422
|
-
if (i.importStrategy !== "component")
|
423
|
-
o.forEach((C, c) => {
|
424
|
-
const u = `l_${c}.css`, g = r(n, "css", u);
|
425
|
-
let p = T(g, "utf8");
|
426
|
-
C.forEach(($) => {
|
427
|
-
var k;
|
428
|
-
const y = r(n, "css", $), j = ((k = /.*-([^-]+)-\d+.css/.exec($)) == null ? void 0 : k.at(1)) || v(y, 6);
|
429
|
-
if (!p.includes(j)) {
|
430
|
-
const J = T(y, "utf8"), E = `/*start:${j}-${$}*/
|
431
|
-
${J}
|
432
|
-
/*end:${j}*/
|
433
|
-
`;
|
434
|
-
p = `${p.replace(/\}$/, "")}
|
435
|
-
${E}
|
436
|
-
}`;
|
437
|
-
}
|
438
|
-
}), x(g, p);
|
439
|
-
});
|
440
|
-
else {
|
441
|
-
const C = o.flat().map(($) => `@import url('./${$}');`).join(`
|
442
|
-
`), c = v(e, 6), u = Y(e), g = G(u.name), p = r(n, `css/f_${g}-${c}.css`);
|
443
|
-
x(p, C || "/* Empty file */");
|
444
|
-
}
|
445
|
-
}
|
446
|
-
} catch (n) {
|
447
|
-
console.error(n);
|
448
|
-
}
|
449
|
-
}, te = async (t, e, s = ft()) => {
|
450
|
-
try {
|
451
|
-
const n = await R(t);
|
452
|
-
if (rt(e)) {
|
453
|
-
const o = T(e, "utf8");
|
454
|
-
o.replace(/^(?!export\s)const\s.*/gm, (u) => `export ${u}`) !== o && await Dt(e, o);
|
455
|
-
const d = await lt(t), { contents: C } = await tt(t, e, n);
|
456
|
-
let c = o;
|
457
|
-
if (Object.entries(C).forEach(([u, g]) => {
|
458
|
-
var f;
|
459
|
-
if (g.isKeyframes || !g.generator) return;
|
460
|
-
const p = g.generator._withBuildContext({
|
461
|
-
callerName: u,
|
462
|
-
isProduction: s,
|
463
|
-
config: d
|
464
|
-
}), $ = new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
|
465
|
-
if (!$) return console.error("Could not find the original declaration");
|
466
|
-
const y = (f = $.at(1)) == null ? void 0 : f.trim(), j = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(c);
|
467
|
-
if (!j) return console.error("Could not find the original declaration");
|
468
|
-
const { index: P } = j;
|
469
|
-
let k = !1;
|
470
|
-
const J = setTimeout(() => k = !0, 5e3);
|
471
|
-
let E = 0, H = !1, D = 0;
|
472
|
-
for (; !H && !k; ) {
|
473
|
-
const S = c[P + E];
|
474
|
-
S === "(" && D++, S === ")" && D--, D === 0 && S === ")" && (H = !0), E > c.length && (k = !0), E++;
|
475
|
-
}
|
476
|
-
if (!k) clearTimeout(J);
|
477
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
478
|
-
const K = P + E, l = c.slice(P, K), h = c, b = ` ${u} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;
|
479
|
-
c = c.replace(l, b), h === c && console.error("Minimize file failed to change content", { name: u, tagName: y });
|
480
|
-
}), d.importStrategy === "component") {
|
481
|
-
const u = v(e, 6), g = Y(e);
|
482
|
-
c = `import '../../saltygen/css/${`f_${G(g.name)}-${u}.css`}';
|
483
|
-
${c}`;
|
484
|
-
}
|
485
|
-
return c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
|
486
|
-
}
|
487
|
-
} catch (n) {
|
488
|
-
console.error("Error in minimizeFile:", n);
|
489
|
-
}
|
490
|
-
};
|
491
|
-
export {
|
492
|
-
Ut as a,
|
493
|
-
Jt as b,
|
494
|
-
Wt as c,
|
495
|
-
tt as d,
|
496
|
-
Yt as e,
|
497
|
-
Xt as g,
|
498
|
-
rt as i,
|
499
|
-
X as l,
|
500
|
-
te as m,
|
501
|
-
jt as s
|
502
|
-
};
|