@salty-css/core 0.0.1-alpha.49 → 0.0.1-alpha.50
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 +3 -3
- package/package.json +1 -1
package/compiler/index.cjs
CHANGED
@@ -7,5 +7,5 @@ ${["@import url('./css/variables.css');","@import url('./css/global.css');","@im
|
|
7
7
|
${o}`;if(b.importStrategy!=="component"){const c=n.flat().map(g=>`@import url('./css/${g}');`).join(`
|
8
8
|
`);u+=c}l.writeFileSync(p,u)}catch(s){console.error(s)}},L=async(t,s)=>{try{const n=[],e=i.join(t,"./saltygen"),p=i.join(e,"index.css");if(E(s)){const b=await R(t),w=await v(s,e);Object.entries(w).forEach(([g,$])=>{if(!$.generator)return;const m=$.generator._withBuildContext({name:g,config:b}),d=`${m.hash}-${m.priority}.css`,h=`css/${d}`,j=i.join(e,h);n.push(d),l.writeFileSync(j,m.css)});const o=l.readFileSync(p,"utf8").split(`
|
9
9
|
`),S=n.map(g=>`@import url('../saltygen/css/${g}');`),c=[...new Set([...o,...S])].join(`
|
10
|
-
`);l.writeFileSync(p,c)}}catch(n){console.error(n)}},U=async(t,s)=>{try{const n=i.join(t,"./saltygen");if(E(s)){const p=l.readFileSync(s,"utf8");p.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==p&&await K.writeFile(s,p);const b=await R(t),w=await v(s,n);let o=p;Object.entries(w).forEach(([u,c])=>{var P;if(c.isKeyframes||!c.generator)return;const g=c.generator._withBuildContext({name:u,config:b}),$=new RegExp(
|
10
|
+
`);l.writeFileSync(p,c)}}catch(n){console.error(n)}},U=async(t,s)=>{try{const n=i.join(t,"./saltygen");if(E(s)){const p=l.readFileSync(s,"utf8");p.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==p&&await K.writeFile(s,p);const b=await R(t),w=await v(s,n);let o=p;Object.entries(w).forEach(([u,c])=>{var P;if(c.isKeyframes||!c.generator)return;const g=c.generator._withBuildContext({name:u,config:b}),$=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(p);if(!$)return console.error("Could not find the original declaration");const m=(P=$.at(1))==null?void 0:P.trim(),d=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(o);if(!d)return console.error("Could not find the original declaration");const{index:h}=d;let j=!1;const k=setTimeout(()=>j=!0,5e3);let f=0,y=!1,a=0;for(;!y&&!j;){const T=o[h+f];T==="("&&a++,T===")"&&a--,a===0&&T===")"&&(y=!0),f>o.length&&(j=!0),f++}if(!j)clearTimeout(k);else throw new Error("Failed to find the end of the styled call and timed out");const r=h+f,F=o.slice(h,r),x=o,D=` ${u} = styled(${m}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`;o=o.replace(F,D),x===o&&console.error("Minimize file failed to change content",{name:u,tagName:m})});const S=N.toHash(s,6);return b.importStrategy==="component"&&(o=`import '../../saltygen/css/${S}.css';
|
11
11
|
${o}`),o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=v;exports.generateConfigStyles=z;exports.generateCss=A;exports.generateFile=L;exports.isSaltyFile=E;exports.minimizeFile=U;exports.saltyFileExtensions=q;exports.saltyFileRegExp=M;
|
package/compiler/index.js
CHANGED
@@ -144,9 +144,9 @@ ${o}`;
|
|
144
144
|
const m = c.generator._withBuildContext({
|
145
145
|
name: y,
|
146
146
|
config: b
|
147
|
-
}), F = new RegExp(
|
147
|
+
}), F = new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(p);
|
148
148
|
if (!F) return console.error("Could not find the original declaration");
|
149
|
-
const u = (P = F.at(1)) == null ? void 0 : P.trim(), g = new RegExp(
|
149
|
+
const u = (P = F.at(1)) == null ? void 0 : P.trim(), g = new RegExp(`\\s${y}[=\\s]+styled\\(`, "g").exec(o);
|
150
150
|
if (!g) return console.error("Could not find the original declaration");
|
151
151
|
const { index: d } = g;
|
152
152
|
let h = !1;
|
@@ -158,7 +158,7 @@ ${o}`;
|
|
158
158
|
}
|
159
159
|
if (!h) clearTimeout(k);
|
160
160
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
161
|
-
const r = d + f, S = o.slice(d, r), C = o, D =
|
161
|
+
const r = d + f, S = o.slice(d, r), C = o, D = ` ${y} = styled(${u}, "${m.classNames}", "${m._callerName}", ${JSON.stringify(m.props)});`;
|
162
162
|
o = o.replace(S, D), C === o && console.error("Minimize file failed to change content", { name: y, tagName: u });
|
163
163
|
});
|
164
164
|
const w = E(e, 6);
|