@salty-css/webpack 0.0.1-alpha.70 → 0.0.1-alpha.72

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.
@@ -37,9 +37,9 @@ const nt = (t, s) => {
37
37
  if (!r) return a;
38
38
  if (f === "variants")
39
39
  return Object.entries(r).forEach(([i, p]) => {
40
- p && Object.entries(p).forEach(([h, m]) => {
41
- if (!m) return;
42
- const w = `${s}.${i}-${h}`, $ = T(m, w);
40
+ p && Object.entries(p).forEach(([h, d]) => {
41
+ if (!d) return;
42
+ const w = `${s}.${i}-${h}`, $ = T(d, w);
43
43
  o.push($);
44
44
  });
45
45
  }), a;
@@ -47,7 +47,7 @@ const nt = (t, s) => {
47
47
  return a;
48
48
  if (f === "compoundVariants")
49
49
  return r.forEach((i) => {
50
- const { css: p, ...h } = i, m = Object.entries(h).reduce(($, [S, D]) => `${$}.${S}-${D}`, s), w = T(p, m);
50
+ const { css: p, ...h } = i, d = Object.entries(h).reduce(($, [S, D]) => `${$}.${S}-${D}`, s), w = T(p, d);
51
51
  o.push(w);
52
52
  }), a;
53
53
  if (f.startsWith("@")) {
@@ -58,10 +58,10 @@ const nt = (t, s) => {
58
58
  }`;
59
59
  return o.push(p), a;
60
60
  }
61
- const d = c.includes("&") ? f.replace("&", s) : f.startsWith(":") ? `${s}${f}` : `${s} ${f}`, F = T(r, d);
61
+ const m = c.includes("&") ? f.replace("&", s) : f.startsWith(":") ? `${s}${f}` : `${s} ${f}`, F = T(r, m);
62
62
  return o.push(F), a;
63
63
  }
64
- const C = f.startsWith("-") ? f : E(f), b = (d, F = ";") => a = `${a}${d}${F}`, l = (d) => b(`${C}:${d}`);
64
+ const C = f.startsWith("-") ? f : E(f), b = (m, F = ";") => a = `${a}${m}${F}`, l = (m) => b(`${C}:${m}`);
65
65
  if (typeof r == "number") return l(r);
66
66
  if (typeof r != "string")
67
67
  if ("toString" in r) r = r.toString();
@@ -69,8 +69,8 @@ const nt = (t, s) => {
69
69
  const { modifiers: j } = {}, x = function* () {
70
70
  yield H(r), yield nt(r, j);
71
71
  }();
72
- for (const { result: d, additionalCss: F = [] } of x)
73
- r = d, F.forEach((i) => {
72
+ for (const { result: m, additionalCss: F = [] } of x)
73
+ r = m, F.forEach((i) => {
74
74
  const p = T(i, "");
75
75
  b(p, "");
76
76
  });
@@ -98,7 +98,7 @@ const nt = (t, s) => {
98
98
  }
99
99
  return e.join(`
100
100
  `);
101
- }, K = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", A = {
101
+ }, K = () => (console.log("current meta url:", import.meta.url), import.meta.url.endsWith(".cjs") ? "cjs" : "esm"), A = {
102
102
  externalModules: []
103
103
  }, q = (t) => {
104
104
  if (A.externalModules.length > 0) return A.externalModules;
@@ -120,18 +120,18 @@ const nt = (t, s) => {
120
120
  const y = Date.now(), { config: a } = await import(`${n}?t=${y}`);
121
121
  return a;
122
122
  }, ct = async (t) => {
123
- const s = await it(t), e = /* @__PURE__ */ new Set(), n = (i, p = []) => i ? Object.entries(i).flatMap(([h, m]) => {
124
- if (!m) return;
125
- if (typeof m == "object") return n(m, [...p, h]);
123
+ const s = await it(t), e = /* @__PURE__ */ new Set(), n = (i, p = []) => i ? Object.entries(i).flatMap(([h, d]) => {
124
+ if (!d) return;
125
+ if (typeof d == "object") return n(d, [...p, h]);
126
126
  const w = [...p, h].join(".");
127
127
  e.add(`"${w}"`);
128
- const $ = [...p.map(E), E(h)].join("-"), { result: S } = H(m);
128
+ const $ = [...p.map(E), E(h)].join("-"), { result: S } = H(d);
129
129
  return `--${$}: ${S};`;
130
130
  }) : [], o = (i) => i ? Object.entries(i).flatMap(([p, h]) => {
131
- const m = n(h);
132
- return p === "base" ? m.join("") : `${p} { ${m.join("")} }`;
133
- }) : [], u = (i) => i ? Object.entries(i).flatMap(([p, h]) => Object.entries(h).flatMap(([m, w]) => {
134
- const $ = n(w, [p]), S = `.${p}-${m}, [data-${p}="${m}"]`, D = $.join("");
131
+ const d = n(h);
132
+ return p === "base" ? d.join("") : `${p} { ${d.join("")} }`;
133
+ }) : [], u = (i) => i ? Object.entries(i).flatMap(([p, h]) => Object.entries(h).flatMap(([d, w]) => {
134
+ const $ = n(w, [p]), S = `.${p}-${d}, [data-${p}="${d}"]`, D = $.join("");
135
135
  return `${S} { ${D} }`;
136
136
  })) : [], y = n(s.variables), a = o(s.responsiveVariables), c = u(s.conditionalVariables), r = O(t), f = g(r, "css/variables.css"), C = `:root { ${y.join("")} ${a.join("")} } ${c.join("")}`;
137
137
  P(f, C);
@@ -139,8 +139,8 @@ const nt = (t, s) => {
139
139
  P(b, j);
140
140
  const k = g(r, "css/global.css"), x = T(s.global, "");
141
141
  P(k, x);
142
- const d = g(r, "css/templates.css"), F = J(s.templates);
143
- P(d, F);
142
+ const m = g(r, "css/templates.css"), F = J(s.templates);
143
+ P(m, F);
144
144
  }, W = async (t, s, e) => {
145
145
  const n = R(s), o = g(e, "js", n + ".js"), u = K(), y = q(t);
146
146
  await z.build({
@@ -169,9 +169,9 @@ const nt = (t, s) => {
169
169
  async function a(l, j) {
170
170
  const k = ["node_modules", "saltygen"], x = Q(l);
171
171
  if (x.isDirectory()) {
172
- const d = v(l);
172
+ const m = v(l);
173
173
  if (k.some((i) => l.includes(i))) return;
174
- await Promise.all(d.map((i) => a(g(l, i), g(j, i))));
174
+ await Promise.all(m.map((i) => a(g(l, i), g(j, i))));
175
175
  } else if (x.isFile() && _(l)) {
176
176
  const F = await W(t, l, n), i = [];
177
177
  Object.entries(F).forEach(([w, $]) => {
@@ -190,8 +190,8 @@ const nt = (t, s) => {
190
190
  P(G, S.css);
191
191
  });
192
192
  const p = i.map((w) => `@import url('./${w}');`).join(`
193
- `), h = R(l, 6), m = g(n, `css/${h}.css`);
194
- P(m, p);
193
+ `), h = R(l, 6), d = g(n, `css/${h}.css`);
194
+ P(d, p);
195
195
  }
196
196
  }
197
197
  await a(t, n);
@@ -227,8 +227,8 @@ ${c}`;
227
227
  const j = l.generator._withBuildContext({
228
228
  name: b,
229
229
  config: y
230
- }), k = `${j.hash}-${j.priority}.css`, x = `css/${k}`, d = g(n, x);
231
- e.push(k), P(d, j.css);
230
+ }), k = `${j.hash}-${j.priority}.css`, x = `css/${k}`, m = g(n, x);
231
+ e.push(k), P(m, j.css);
232
232
  });
233
233
  const c = N(o, "utf8").split(`
234
234
  `), r = e.map((b) => `@import url('../saltygen/css/${b}');`), C = [.../* @__PURE__ */ new Set([...c, ...r])].join(`
@@ -257,16 +257,16 @@ ${c}`;
257
257
  const j = (D = l.at(1)) == null ? void 0 : D.trim(), k = new RegExp(`\\s${f}[=\\s]+styled\\(`, "g").exec(c);
258
258
  if (!k) return console.error("Could not find the original declaration");
259
259
  const { index: x } = k;
260
- let d = !1;
261
- const F = setTimeout(() => d = !0, 5e3);
260
+ let m = !1;
261
+ const F = setTimeout(() => m = !0, 5e3);
262
262
  let i = 0, p = !1, h = 0;
263
- for (; !p && !d; ) {
263
+ for (; !p && !m; ) {
264
264
  const M = c[x + i];
265
- M === "(" && h++, M === ")" && h--, h === 0 && M === ")" && (p = !0), i > c.length && (d = !0), i++;
265
+ M === "(" && h++, M === ")" && h--, h === 0 && M === ")" && (p = !0), i > c.length && (m = !0), i++;
266
266
  }
267
- if (!d) clearTimeout(F);
267
+ if (!m) clearTimeout(F);
268
268
  else throw new Error("Failed to find the end of the styled call and timed out");
269
- const m = x + i, w = c.slice(x, m), $ = c, S = ` ${f} = styled(${j}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;
269
+ const d = x + i, w = c.slice(x, d), $ = c, S = ` ${f} = styled(${j}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;
270
270
  c = c.replace(w, S), $ === c && console.error("Minimize file failed to change content", { name: f, tagName: j });
271
271
  });
272
272
  const r = R(s, 6);
@@ -0,0 +1,18 @@
1
+ "use strict";const X=require("esbuild"),Y=require("child_process"),d=require("path"),g=require("fs"),Q=require("fs/promises");var O=typeof document<"u"?document.currentScript:null;function v(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const W=v(X),U=t=>String.fromCharCode(t+(t>25?39:97)),tt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=U(n%52)+s;return s=U(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},et=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},V=(t,e=3)=>{const s=et(5381,JSON.stringify(t))>>>0;return tt(s,e)};function N(t){return t?typeof t!="string"?N(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const st=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,y=>{const{value:a,css:c}=p(y);return c&&s.push(c),a})}),{result:t,additionalCss:s}},z=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${N(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,e,s,n)=>{if(!t)return"";const o=[],p=Object.entries(t).reduce((a,[c,r])=>{const f=c.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(f==="variants")return Object.entries(r).forEach(([i,u])=>{u&&Object.entries(u).forEach(([$,h])=>{if(!h)return;const w=`${e}.${i}-${$}`,j=D(h,w);o.push(j)})}),a;if(f==="defaultVariants")return a;if(f==="compoundVariants")return r.forEach(i=>{const{css:u,...$}=i,h=Object.entries($).reduce((j,[F,P])=>`${j}.${F}-${P}`,e),w=D(u,h);o.push(w)}),a;if(f.startsWith("@")){const i=D(r,e),u=`${f} {
2
+ ${i.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return o.push(u),a}const m=c.includes("&")?f.replace("&",e):f.startsWith(":")?`${e}${f}`:`${e} ${f}`,C=D(r,m);return o.push(C),a}const T=f.startsWith("-")?f:N(f),b=(m,C=";")=>a=`${a}${m}${C}`,l=m=>b(`${T}:${m}`);if(typeof r=="number")return l(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:S}={},x=function*(){yield z(r),yield st(r,S)}();for(const{result:m,additionalCss:C=[]}of x)r=m,C.forEach(i=>{const u=D(i,"");b(u,"")});return l(r)},"");if(!p)return o.join(`
6
+ `);if(!e)return p;let y="";return y=`${e} { ${p} }`,[y,...o].join(`
7
+ `)},B=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const y=o.trim(),a=B(p,[...e,y]);s.push(a)}else n[o]=p}),Object.keys(n).length){const o=e.map(N).join("-"),p=D(n,`.${o}`);s.push(p)}return s.join(`
8
+ `)},L=()=>(console.log("current meta url:",typeof document>"u"?require("url").pathToFileURL(__filename).href:O&&O.tagName.toUpperCase()==="SCRIPT"&&O.src||new URL("index-CDjac-7g.cjs",document.baseURI).href),(typeof document>"u"?require("url").pathToFileURL(__filename).href:O&&O.tagName.toUpperCase()==="SCRIPT"&&O.src||new URL("index-CDjac-7g.cjs",document.baseURI).href).endsWith(".cjs")?"cjs":"esm"),R={externalModules:[]},Z=t=>{if(R.externalModules.length>0)return R.externalModules;const e=d.join(t,"salty.config.ts"),n=g.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return R.externalModules=o,o},M=t=>d.join(t,"./saltygen"),nt=["salty","css","styles","styled"],H=(t=[])=>new RegExp(`\\.(${[...nt,...t].join("|")})\\.`),_=(t,e=[])=>H(e).test(t),ot=async t=>{const e=M(t),s=d.join(t,"salty.config.ts"),n=d.join(e,"salty.config.js"),o=L(),p=Z(t);await W.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:p});const y=Date.now(),{config:a}=await import(`${n}?t=${y}`);return a},rt=async t=>{const e=await ot(t),s=new Set,n=(i,u=[])=>i?Object.entries(i).flatMap(([$,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...u,$]);const w=[...u,$].join(".");s.add(`"${w}"`);const j=[...u.map(N),N($)].join("-"),{result:F}=z(h);return`--${j}: ${F};`}):[],o=i=>i?Object.entries(i).flatMap(([u,$])=>{const h=n($);return u==="base"?h.join(""):`${u} { ${h.join("")} }`}):[],p=i=>i?Object.entries(i).flatMap(([u,$])=>Object.entries($).flatMap(([h,w])=>{const j=n(w,[u]),F=`.${u}-${h}, [data-${u}="${h}"]`,P=j.join("");return`${F} { ${P} }`})):[],y=n(e.variables),a=o(e.responsiveVariables),c=p(e.conditionalVariables),r=M(t),f=d.join(r,"css/variables.css"),T=`:root { ${y.join("")} ${a.join("")} } ${c.join("")}`;g.writeFileSync(f,T);const b=d.join(r,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;g.writeFileSync(b,S);const k=d.join(r,"css/global.css"),x=D(e.global,"");g.writeFileSync(k,x);const m=d.join(r,"css/templates.css"),C=B(e.templates);g.writeFileSync(m,C)},A=async(t,e,s)=>{const n=V(e),o=d.join(s,"js",n+".js"),p=L(),y=Z(t);await W.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,target:["es2022"],keepNames:!0,external:y});const a=Date.now();return await import(`${o}?t=${a}`)},I=async t=>{const e=M(t),s=d.join(e,"salty.config.js"),{config:n}=await import(s);return n},it=async t=>{try{const e=[],s=[],n=M(t),o=d.join(n,"index.css");(()=>{g.existsSync(n)&&Y.execSync("rm -rf "+n),g.mkdirSync(n),g.mkdirSync(d.join(n,"css")),g.mkdirSync(d.join(n,"types"))})(),await rt(t);const y=await I(t);async function a(l,S){const k=["node_modules","saltygen"],x=g.statSync(l);if(x.isDirectory()){const m=g.readdirSync(l);if(k.some(i=>l.includes(i)))return;await Promise.all(m.map(i=>a(d.join(l,i),d.join(S,i))))}else if(x.isFile()&&_(l)){const C=await A(t,l,n),i=[];Object.entries(C).forEach(([w,j])=>{if(j.isKeyframes&&j.css){const q=`${j.animationName}.css`,K=`css/${q}`,G=d.join(n,K);e.push(q),g.writeFileSync(G,j.css);return}if(!j.generator)return;const F=j.generator._withBuildContext({name:w,config:y}),P=`${F.hash}-${F.priority}.css`;s[F.priority]||(s[F.priority]=[]),s[F.priority].push(P),i.push(P);const E=`css/${P}`,J=d.join(n,E);g.writeFileSync(J,F.css)});const u=i.map(w=>`@import url('./${w}');`).join(`
9
+ `),$=V(l,6),h=d.join(n,`css/${$}.css`);g.writeFileSync(h,u)}}await a(t,n);const c=e.map(l=>`@import url('./css/${l}');`).join(`
10
+ `);let b=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
11
+
12
+ ${["variables.css","global.css","templates.css"].filter(l=>{try{return g.readFileSync(d.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
13
+ `)}
14
+ ${c}`;if(y.importStrategy!=="component"){const l=s.flat().map(S=>`@import url('./css/${S}');`).join(`
15
+ `);b+=l}g.writeFileSync(o,b)}catch(e){console.error(e)}},ct=async(t,e)=>{try{const s=[],n=d.join(t,"./saltygen"),o=d.join(n,"index.css");if(_(e)){const y=await I(t),a=await A(t,e,n);Object.entries(a).forEach(([b,l])=>{if(!l.generator)return;const S=l.generator._withBuildContext({name:b,config:y}),k=`${S.hash}-${S.priority}.css`,x=`css/${k}`,m=d.join(n,x);s.push(k),g.writeFileSync(m,S.css)});const c=g.readFileSync(o,"utf8").split(`
16
+ `),r=s.map(b=>`@import url('../saltygen/css/${b}');`),T=[...new Set([...c,...r])].join(`
17
+ `);g.writeFileSync(o,T)}}catch(s){console.error(s)}},at=async(t,e)=>{try{const s=d.join(t,"./saltygen");if(_(e)){const o=g.readFileSync(e,"utf8");o.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==o&&await Q.writeFile(e,o);const y=await I(t),a=await A(t,e,s);let c=o;Object.entries(a).forEach(([f,T])=>{var P;if(T.isKeyframes||!T.generator)return;const b=T.generator._withBuildContext({name:f,config:y}),l=new RegExp(`\\s${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!l)return console.error("Could not find the original declaration");const S=(P=l.at(1))==null?void 0:P.trim(),k=new RegExp(`\\s${f}[=\\s]+styled\\(`,"g").exec(c);if(!k)return console.error("Could not find the original declaration");const{index:x}=k;let m=!1;const C=setTimeout(()=>m=!0,5e3);let i=0,u=!1,$=0;for(;!u&&!m;){const E=c[x+i];E==="("&&$++,E===")"&&$--,$===0&&E===")"&&(u=!0),i>c.length&&(m=!0),i++}if(!m)clearTimeout(C);else throw new Error("Failed to find the end of the styled call and timed out");const h=x+i,w=c.slice(x,h),j=c,F=` ${f} = styled(${S}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;c=c.replace(w,F),j===c&&console.error("Minimize file failed to change content",{name:f,tagName:S})});const r=V(e,6);return y.importStrategy==="component"&&(c=`import '../../saltygen/css/${r}.css';
18
+ ${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(s){console.error("Error in minimizeFile:",s)}};exports.generateCss=it;exports.generateFile=ct;exports.minimizeFile=at;exports.saltyFileRegExp=H;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-mf-G0Xfj.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-CDjac-7g.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as n } from "path";
2
- import { s as u, g as i } from "./index-6sT6Zv96.js";
2
+ import { s as u, g as i } from "./index-B381EEqQ.js";
3
3
  const g = (s, e, o = !1, r = !1) => {
4
4
  var a, l, t;
5
5
  (l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-mf-G0Xfj.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
1
+ "use strict";const i=require("./index-CDjac-7g.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
package/loader.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, m as i } from "./index-6sT6Zv96.js";
1
+ import { a as e, m as i } from "./index-B381EEqQ.js";
2
2
  async function s() {
3
3
  const { dir: t } = this.getOptions(), { resourcePath: a } = this;
4
4
  return await e(t, a), await i(t, a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
3
- "version": "0.0.1-alpha.70",
3
+ "version": "0.0.1-alpha.72",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.70",
37
+ "@salty-css/core": "^0.0.1-alpha.72",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }
@@ -1,18 +0,0 @@
1
- "use strict";const X=require("esbuild"),Y=require("child_process"),d=require("path"),g=require("fs"),Q=require("fs/promises");var M=typeof document<"u"?document.currentScript:null;function v(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const z=v(X),W=t=>String.fromCharCode(t+(t>25?39:97)),tt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=W(n%52)+s;return s=W(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},et=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},_=(t,e=3)=>{const s=et(5381,JSON.stringify(t))>>>0;return tt(s,e)};function O(t){return t?typeof t!="string"?O(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const st=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,y=>{const{value:a,css:c}=p(y);return c&&s.push(c),a})}),{result:t,additionalCss:s}},B=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,e,s,n)=>{if(!t)return"";const o=[],p=Object.entries(t).reduce((a,[c,r])=>{const f=c.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(f==="variants")return Object.entries(r).forEach(([i,u])=>{u&&Object.entries(u).forEach(([$,h])=>{if(!h)return;const w=`${e}.${i}-${$}`,j=D(h,w);o.push(j)})}),a;if(f==="defaultVariants")return a;if(f==="compoundVariants")return r.forEach(i=>{const{css:u,...$}=i,h=Object.entries($).reduce((j,[F,T])=>`${j}.${F}-${T}`,e),w=D(u,h);o.push(w)}),a;if(f.startsWith("@")){const i=D(r,e),u=`${f} {
2
- ${i.replace(`
3
- `,`
4
- `)}
5
- }`;return o.push(u),a}const m=c.includes("&")?f.replace("&",e):f.startsWith(":")?`${e}${f}`:`${e} ${f}`,C=D(r,m);return o.push(C),a}const k=f.startsWith("-")?f:O(f),b=(m,C=";")=>a=`${a}${m}${C}`,l=m=>b(`${k}:${m}`);if(typeof r=="number")return l(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:S}={},x=function*(){yield B(r),yield st(r,S)}();for(const{result:m,additionalCss:C=[]}of x)r=m,C.forEach(i=>{const u=D(i,"");b(u,"")});return l(r)},"");if(!p)return o.join(`
6
- `);if(!e)return p;let y="";return y=`${e} { ${p} }`,[y,...o].join(`
7
- `)},Z=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const y=o.trim(),a=Z(p,[...e,y]);s.push(a)}else n[o]=p}),Object.keys(n).length){const o=e.map(O).join("-"),p=D(n,`.${o}`);s.push(p)}return s.join(`
8
- `)},U=()=>(typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("index-mf-G0Xfj.cjs",document.baseURI).href).endsWith(".cjs")?"cjs":"esm",V={externalModules:[]},H=t=>{if(V.externalModules.length>0)return V.externalModules;const e=d.join(t,"salty.config.ts"),n=g.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return V.externalModules=o,o},N=t=>d.join(t,"./saltygen"),nt=["salty","css","styles","styled"],L=(t=[])=>new RegExp(`\\.(${[...nt,...t].join("|")})\\.`),R=(t,e=[])=>L(e).test(t),ot=async t=>{const e=N(t),s=d.join(t,"salty.config.ts"),n=d.join(e,"salty.config.js"),o=U(),p=H(t);await z.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:p});const y=Date.now(),{config:a}=await import(`${n}?t=${y}`);return a},rt=async t=>{const e=await ot(t),s=new Set,n=(i,u=[])=>i?Object.entries(i).flatMap(([$,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...u,$]);const w=[...u,$].join(".");s.add(`"${w}"`);const j=[...u.map(O),O($)].join("-"),{result:F}=B(h);return`--${j}: ${F};`}):[],o=i=>i?Object.entries(i).flatMap(([u,$])=>{const h=n($);return u==="base"?h.join(""):`${u} { ${h.join("")} }`}):[],p=i=>i?Object.entries(i).flatMap(([u,$])=>Object.entries($).flatMap(([h,w])=>{const j=n(w,[u]),F=`.${u}-${h}, [data-${u}="${h}"]`,T=j.join("");return`${F} { ${T} }`})):[],y=n(e.variables),a=o(e.responsiveVariables),c=p(e.conditionalVariables),r=N(t),f=d.join(r,"css/variables.css"),k=`:root { ${y.join("")} ${a.join("")} } ${c.join("")}`;g.writeFileSync(f,k);const b=d.join(r,"types/css-tokens.d.ts"),S=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;g.writeFileSync(b,S);const P=d.join(r,"css/global.css"),x=D(e.global,"");g.writeFileSync(P,x);const m=d.join(r,"css/templates.css"),C=Z(e.templates);g.writeFileSync(m,C)},A=async(t,e,s)=>{const n=_(e),o=d.join(s,"js",n+".js"),p=U(),y=H(t);await z.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,target:["es2022"],keepNames:!0,external:y});const a=Date.now();return await import(`${o}?t=${a}`)},q=async t=>{const e=N(t),s=d.join(e,"salty.config.js"),{config:n}=await import(s);return n},it=async t=>{try{const e=[],s=[],n=N(t),o=d.join(n,"index.css");(()=>{g.existsSync(n)&&Y.execSync("rm -rf "+n),g.mkdirSync(n),g.mkdirSync(d.join(n,"css")),g.mkdirSync(d.join(n,"types"))})(),await rt(t);const y=await q(t);async function a(l,S){const P=["node_modules","saltygen"],x=g.statSync(l);if(x.isDirectory()){const m=g.readdirSync(l);if(P.some(i=>l.includes(i)))return;await Promise.all(m.map(i=>a(d.join(l,i),d.join(S,i))))}else if(x.isFile()&&R(l)){const C=await A(t,l,n),i=[];Object.entries(C).forEach(([w,j])=>{if(j.isKeyframes&&j.css){const I=`${j.animationName}.css`,K=`css/${I}`,G=d.join(n,K);e.push(I),g.writeFileSync(G,j.css);return}if(!j.generator)return;const F=j.generator._withBuildContext({name:w,config:y}),T=`${F.hash}-${F.priority}.css`;s[F.priority]||(s[F.priority]=[]),s[F.priority].push(T),i.push(T);const E=`css/${T}`,J=d.join(n,E);g.writeFileSync(J,F.css)});const u=i.map(w=>`@import url('./${w}');`).join(`
9
- `),$=_(l,6),h=d.join(n,`css/${$}.css`);g.writeFileSync(h,u)}}await a(t,n);const c=e.map(l=>`@import url('./css/${l}');`).join(`
10
- `);let b=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
11
-
12
- ${["variables.css","global.css","templates.css"].filter(l=>{try{return g.readFileSync(d.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
13
- `)}
14
- ${c}`;if(y.importStrategy!=="component"){const l=s.flat().map(S=>`@import url('./css/${S}');`).join(`
15
- `);b+=l}g.writeFileSync(o,b)}catch(e){console.error(e)}},ct=async(t,e)=>{try{const s=[],n=d.join(t,"./saltygen"),o=d.join(n,"index.css");if(R(e)){const y=await q(t),a=await A(t,e,n);Object.entries(a).forEach(([b,l])=>{if(!l.generator)return;const S=l.generator._withBuildContext({name:b,config:y}),P=`${S.hash}-${S.priority}.css`,x=`css/${P}`,m=d.join(n,x);s.push(P),g.writeFileSync(m,S.css)});const c=g.readFileSync(o,"utf8").split(`
16
- `),r=s.map(b=>`@import url('../saltygen/css/${b}');`),k=[...new Set([...c,...r])].join(`
17
- `);g.writeFileSync(o,k)}}catch(s){console.error(s)}},at=async(t,e)=>{try{const s=d.join(t,"./saltygen");if(R(e)){const o=g.readFileSync(e,"utf8");o.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==o&&await Q.writeFile(e,o);const y=await q(t),a=await A(t,e,s);let c=o;Object.entries(a).forEach(([f,k])=>{var T;if(k.isKeyframes||!k.generator)return;const b=k.generator._withBuildContext({name:f,config:y}),l=new RegExp(`\\s${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!l)return console.error("Could not find the original declaration");const S=(T=l.at(1))==null?void 0:T.trim(),P=new RegExp(`\\s${f}[=\\s]+styled\\(`,"g").exec(c);if(!P)return console.error("Could not find the original declaration");const{index:x}=P;let m=!1;const C=setTimeout(()=>m=!0,5e3);let i=0,u=!1,$=0;for(;!u&&!m;){const E=c[x+i];E==="("&&$++,E===")"&&$--,$===0&&E===")"&&(u=!0),i>c.length&&(m=!0),i++}if(!m)clearTimeout(C);else throw new Error("Failed to find the end of the styled call and timed out");const h=x+i,w=c.slice(x,h),j=c,F=` ${f} = styled(${S}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;c=c.replace(w,F),j===c&&console.error("Minimize file failed to change content",{name:f,tagName:S})});const r=_(e,6);return y.importStrategy==="component"&&(c=`import '../../saltygen/css/${r}.css';
18
- ${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(s){console.error("Error in minimizeFile:",s)}};exports.generateCss=it;exports.generateFile=ct;exports.minimizeFile=at;exports.saltyFileRegExp=L;