@salty-css/core 0.0.1-alpha.13 → 0.0.1-alpha.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("esbuild"),J=require("winston"),G=require("child_process"),N=require("../util/index.cjs"),o=require("path"),r=require("fs"),L=require("fs/promises"),_=require("../parse-templates-BY1Xai-_.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(s,n,e.get?e:{enumerable:!0,get:()=>t[n]})}}return s.default=t,Object.freeze(s)}const R=q(K),k=q(J),A=k.createLogger({level:"info",format:k.format.combine(k.format.colorize(),k.format.cli()),transports:[new k.transports.Console({})]}),v=t=>o.join(t,"./saltygen"),M=["salty","css","styles","styled"],z=(t=[])=>new RegExp(`\\.(${[...M,...t].join("|")})\\.`),T=(t,s=[])=>z(s).test(t),U=async t=>{const s=v(t),n=o.join(t,"salty-config.ts"),e=o.join(s,"salty-config.js");await R.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:e,format:"esm",external:["react"]});const a=Date.now(),{config:h}=await import(`${e}?t=${a}`);return h},H=async t=>{const s=await U(t),n=new Set,e=(f,p=[])=>f?Object.entries(f).flatMap(([y,c])=>{if(!c)return;if(typeof c=="object")return e(c,[...p,y]);const x=[...p,y].join(".");n.add(`"${x}"`);const D=[...p.map(N.dashCase),N.dashCase(y)].join("-"),{result:P}=_.parseValueTokens(c);return`--${D}: ${P};`}):[],a=f=>f?Object.entries(f).flatMap(([p,y])=>{const c=e(y);return p==="base"?c.join(""):`${p} { ${c.join("")} }`}):[],h=f=>f?Object.entries(f).flatMap(([p,y])=>Object.entries(y).flatMap(([c,x])=>{const D=e(x,[p]),P=`.${p}-${c}, [data-${p}="${c}"]`,O=D.join("");return`${P} { ${O} }`})):[],b=e(s.variables),w=a(s.responsiveVariables),l=h(s.conditionalVariables),j=v(t),u=o.join(j,"css/variables.css"),i=`:root { ${b.join("")} ${w.join("")} } ${l.join("")}`;r.writeFileSync(u,i);const g=o.join(j,"types/css-tokens.d.ts"),d=`type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;r.writeFileSync(g,d);const m=o.join(j,"css/global.css"),S=_.parseStyles(s.global,"");r.writeFileSync(m,S);const F=o.join(j,"css/templates.css"),C=_.parseTemplates(s.templates);r.writeFileSync(F,C)},V=async(t,s)=>{const n=N.toHash(t),e=o.join(s,"js",n+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:e,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${e}?t=${a}`)},E=async t=>{const s=v(t),n=o.join(s,"salty-config.js"),{config:e}=await import(n);return e},W=async t=>{try{const s=[],n=[],e=v(t),a=o.join(e,"index.css");(()=>{r.existsSync(e)&&G.execSync("rm -rf "+e),r.mkdirSync(e),r.mkdirSync(o.join(e,"css")),r.mkdirSync(o.join(e,"types"))})(),await H(t);const b=await E(t);async function w(i,g){const $=r.statSync(i);if($.isDirectory()){const d=r.readdirSync(i);await Promise.all(d.map(m=>w(o.join(i,m),o.join(g,m))))}else if($.isFile()&&T(i)){const m=await V(i,e),S=[];Object.entries(m).forEach(([p,y])=>{if(y.isKeyframes&&y.css){const O=`${y.animationName}.css`,I=`css/${O}`,B=o.join(e,I);s.push(O),r.writeFileSync(B,y.css);return}if(!y.generator)return;const c=y.generator._withBuildContext({name:p,config:b}),x=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(x),S.push(x);const D=`css/${x}`,P=o.join(e,D);r.writeFileSync(P,c.css)});const F=S.map(p=>`@import url('./${p}');`).join(`
2
- `),C=N.toHash(i,6),f=o.join(e,`css/${C}.css`);r.writeFileSync(f,F)}}await w(t,e);const l=s.map(i=>`@import url('./css/${i}');`).join(`
3
- `);let u=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("esbuild"),G=require("winston"),J=require("child_process"),k=require("../util/index.cjs"),o=require("path"),r=require("fs"),L=require("fs/promises"),_=require("../parse-templates-BY1Xai-_.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(s,n,e.get?e:{enumerable:!0,get:()=>t[n]})}}return s.default=t,Object.freeze(s)}const R=q(K),P=q(G),A=P.createLogger({level:"info",format:P.format.combine(P.format.colorize(),P.format.cli()),transports:[new P.transports.Console({})]}),O=t=>o.join(t,"./saltygen"),M=["salty","css","styles","styled"],z=(t=[])=>new RegExp(`\\.(${[...M,...t].join("|")})\\.`),T=(t,s=[])=>z(s).test(t),U=async t=>{const s=O(t),n=o.join(t,"salty-config.ts"),e=o.join(s,"salty-config.js");await R.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:e,format:"esm",external:["react"]});const a=Date.now(),{config:S}=await import(`${e}?t=${a}`);return S},H=async t=>{const s=await U(t),n=new Set,e=(d,p=[])=>d?Object.entries(d).flatMap(([y,c])=>{if(!c)return;if(typeof c=="object")return e(c,[...p,y]);const x=[...p,y].join(".");n.add(`"${x}"`);const C=[...p.map(k.dashCase),k.dashCase(y)].join("-"),{result:D}=_.parseValueTokens(c);return`--${C}: ${D};`}):[],a=d=>d?Object.entries(d).flatMap(([p,y])=>{const c=e(y);return p==="base"?c.join(""):`${p} { ${c.join("")} }`}):[],S=d=>d?Object.entries(d).flatMap(([p,y])=>Object.entries(y).flatMap(([c,x])=>{const C=e(x,[p]),D=`.${p}-${c}, [data-${p}="${c}"]`,N=C.join("");return`${D} { ${N} }`})):[],b=e(s.variables),w=a(s.responsiveVariables),l=S(s.conditionalVariables),j=O(t),f=o.join(j,"css/variables.css"),i=`:root { ${b.join("")} ${w.join("")} } ${l.join("")}`;r.writeFileSync(f,i);const g=o.join(j,"types/css-tokens.d.ts"),m=`type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;r.writeFileSync(g,m);const u=o.join(j,"css/global.css"),h=_.parseStyles(s.global,"");r.writeFileSync(u,h);const F=o.join(j,"css/templates.css"),v=_.parseTemplates(s.templates);r.writeFileSync(F,v)},V=async(t,s)=>{const n=k.toHash(t),e=o.join(s,"js",n+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:e,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${e}?t=${a}`)},E=async t=>{const s=O(t),n=o.join(s,"salty-config.js"),{config:e}=await import(n);return e},W=async t=>{try{const s=[],n=[],e=O(t),a=o.join(e,"index.css");(()=>{r.existsSync(e)&&J.execSync("rm -rf "+e),r.mkdirSync(e),r.mkdirSync(o.join(e,"css")),r.mkdirSync(o.join(e,"types"))})(),await H(t);const b=await E(t);async function w(i,g){const $=r.statSync(i);if($.isDirectory()){const m=r.readdirSync(i);await Promise.all(m.map(u=>w(o.join(i,u),o.join(g,u))))}else if($.isFile()&&T(i)){const u=await V(i,e),h=[];Object.entries(u).forEach(([p,y])=>{if(y.isKeyframes&&y.css){const N=`${y.animationName}.css`,I=`css/${N}`,B=o.join(e,I);s.push(N),r.writeFileSync(B,y.css);return}if(!y.generator)return;const c=y.generator._withBuildContext({name:p,config:b}),x=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(x),h.push(x);const C=`css/${x}`,D=o.join(e,C);r.writeFileSync(D,c.css)});const F=h.map(p=>`@import url('./${p}');`).join(`
2
+ `),v=k.toHash(i,6),d=o.join(e,`css/${v}.css`);r.writeFileSync(d,F)}}await w(t,e);const l=s.map(i=>`@import url('./css/${i}');`).join(`
3
+ `);let f=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
4
4
 
5
5
  ${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
6
6
  `)}
7
7
  ${l}`;if(b.importStrategy!=="component"){const i=n.flat().map(g=>`@import url('./css/${g}');`).join(`
8
- `);u+=i}r.writeFileSync(a,u)}catch(s){console.error(s)}},X=async(t,s)=>{try{const n=[],e=o.join(t,"./saltygen"),a=o.join(e,"index.css");if(T(s)){const b=await E(t),w=await V(s,e);Object.entries(w).forEach(([g,$])=>{if(!$.generator)return;const d=$.generator._withBuildContext({name:g,config:b}),m=`${d.hash}-${d.priority}.css`,S=`css/${m}`,F=o.join(e,S);n.push(m),r.writeFileSync(F,d.css)});const l=r.readFileSync(a,"utf8").split(`
8
+ `);f+=i}r.writeFileSync(a,f)}catch(s){console.error(s)}},X=async(t,s)=>{try{const n=[],e=o.join(t,"./saltygen"),a=o.join(e,"index.css");if(T(s)){const b=await E(t),w=await V(s,e);Object.entries(w).forEach(([g,$])=>{if(!$.generator)return;const m=$.generator._withBuildContext({name:g,config:b}),u=`${m.hash}-${m.priority}.css`,h=`css/${u}`,F=o.join(e,h);n.push(u),r.writeFileSync(F,m.css)});const l=r.readFileSync(a,"utf8").split(`
9
9
  `),j=n.map(g=>`@import url('../saltygen/css/${g}');`),i=[...new Set([...l,...j])].join(`
10
- `);r.writeFileSync(a,i)}}catch(n){console.error(n)}},Y=async(t,s)=>{try{const n=o.join(t,"./saltygen");if(T(s)){let a=r.readFileSync(s,"utf8");a.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==a&&await L.writeFile(s,a);const b=await E(t),w=await V(s,n);let l=a;Object.entries(w).forEach(([u,i])=>{var f;if(i.isKeyframes){console.log("value",i);return}if(!i.generator)return;const g=i.generator._withBuildContext({name:u,config:b}),$=new RegExp(`${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const d=(f=$.at(1))==null?void 0:f.trim(),{element:m,variantKeys:S}=g.props,F=`${u} = styled(${d}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(m)}, ${JSON.stringify(S)});`,C=new RegExp(`${u}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(C,F)});const j=N.toHash(s,6);return b.importStrategy==="component"&&(l=`import '../../saltygen/css/${j}.css';
10
+ `);r.writeFileSync(a,i)}}catch(n){console.error(n)}},Y=async(t,s)=>{try{const n=o.join(t,"./saltygen");if(T(s)){const a=r.readFileSync(s,"utf8");a.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==a&&await L.writeFile(s,a);const b=await E(t),w=await V(s,n);let l=a;Object.entries(w).forEach(([f,i])=>{var F;if(i.isKeyframes){console.log("value",i);return}if(!i.generator)return;const g=i.generator._withBuildContext({name:f,config:b}),$=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const m=(F=$.at(1))==null?void 0:F.trim(),u=`${f} = styled(${m}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`,h=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(h,u)});const j=k.toHash(s,6);return b.importStrategy==="component"&&(l=`import '../../saltygen/css/${j}.css';
11
11
  ${l}`),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error(n)}};exports.compileSaltyFile=V;exports.generateCss=W;exports.generateFile=X;exports.generateVariables=H;exports.isSaltyFile=T;exports.logger=A;exports.minimizeFile=Y;exports.saltyFileExtensions=M;exports.saltyFileRegExp=z;
package/compiler/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import * as M from "esbuild";
2
- import * as N from "winston";
3
- import { execSync as z } from "child_process";
2
+ import * as P from "winston";
3
+ import { execSync as H } from "child_process";
4
4
  import { toHash as T, dashCase as I } from "../util/index.js";
5
- import { join as o } from "path";
6
- import { writeFileSync as $, existsSync as H, mkdirSync as v, statSync as J, readdirSync as G, readFileSync as _ } from "fs";
5
+ import { join as n } from "path";
6
+ import { writeFileSync as $, existsSync as K, mkdirSync as v, statSync as G, readdirSync as J, readFileSync as _ } from "fs";
7
7
  import { writeFile as L } from "fs/promises";
8
8
  import { p as q, a as A, b as U } from "../parse-templates-BOSK0Tb6.js";
9
- const rt = N.createLogger({
9
+ const rt = P.createLogger({
10
10
  level: "info",
11
- format: N.format.combine(N.format.colorize(), N.format.cli()),
12
- transports: [new N.transports.Console({})]
13
- }), k = (s) => o(s, "./saltygen"), W = ["salty", "css", "styles", "styled"], X = (s = []) => new RegExp(`\\.(${[...W, ...s].join("|")})\\.`), O = (s, e = []) => X(e).test(s), Y = async (s) => {
14
- const e = k(s), n = o(s, "salty-config.ts"), t = o(e, "salty-config.js");
11
+ format: P.format.combine(P.format.colorize(), P.format.cli()),
12
+ transports: [new P.transports.Console({})]
13
+ }), V = (s) => n(s, "./saltygen"), W = ["salty", "css", "styles", "styled"], X = (s = []) => new RegExp(`\\.(${[...W, ...s].join("|")})\\.`), E = (s, e = []) => X(e).test(s), Y = async (s) => {
14
+ const e = V(s), o = n(s, "salty-config.ts"), t = n(e, "salty-config.js");
15
15
  await M.build({
16
- entryPoints: [n],
16
+ entryPoints: [o],
17
17
  minify: !0,
18
18
  treeShaking: !0,
19
19
  bundle: !0,
@@ -21,32 +21,32 @@ const rt = N.createLogger({
21
21
  format: "esm",
22
22
  external: ["react"]
23
23
  });
24
- const c = Date.now(), { config: j } = await import(`${t}?t=${c}`);
25
- return j;
24
+ const c = Date.now(), { config: S } = await import(`${t}?t=${c}`);
25
+ return S;
26
26
  }, Z = async (s) => {
27
- const e = await Y(s), n = /* @__PURE__ */ new Set(), t = (m, l = []) => m ? Object.entries(m).flatMap(([p, i]) => {
27
+ const e = await Y(s), o = /* @__PURE__ */ new Set(), t = (u, l = []) => u ? Object.entries(u).flatMap(([p, i]) => {
28
28
  if (!i) return;
29
29
  if (typeof i == "object") return t(i, [...l, p]);
30
30
  const x = [...l, p].join(".");
31
- n.add(`"${x}"`);
32
- const D = [...l.map(I), I(p)].join("-"), { result: P } = U(i);
33
- return `--${D}: ${P};`;
34
- }) : [], c = (m) => m ? Object.entries(m).flatMap(([l, p]) => {
31
+ o.add(`"${x}"`);
32
+ const C = [...l.map(I), I(p)].join("-"), { result: D } = U(i);
33
+ return `--${C}: ${D};`;
34
+ }) : [], c = (u) => u ? Object.entries(u).flatMap(([l, p]) => {
35
35
  const i = t(p);
36
36
  return l === "base" ? i.join("") : `${l} { ${i.join("")} }`;
37
- }) : [], j = (m) => m ? Object.entries(m).flatMap(([l, p]) => Object.entries(p).flatMap(([i, x]) => {
38
- const D = t(x, [l]), P = `.${l}-${i}, [data-${l}="${i}"]`, V = D.join("");
39
- return `${P} { ${V} }`;
40
- })) : [], d = t(e.variables), w = c(e.responsiveVariables), a = j(e.conditionalVariables), b = k(s), y = o(b, "css/variables.css"), r = `:root { ${d.join("")} ${w.join("")} } ${a.join("")}`;
41
- $(y, r);
42
- const f = o(b, "types/css-tokens.d.ts"), u = `type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
43
- $(f, u);
44
- const g = o(b, "css/global.css"), F = q(e.global, "");
45
- $(g, F);
46
- const S = o(b, "css/templates.css"), C = A(e.templates);
47
- $(S, C);
48
- }, E = async (s, e) => {
49
- const n = T(s), t = o(e, "js", n + ".js");
37
+ }) : [], S = (u) => u ? Object.entries(u).flatMap(([l, p]) => Object.entries(p).flatMap(([i, x]) => {
38
+ const C = t(x, [l]), D = `.${l}-${i}, [data-${l}="${i}"]`, N = C.join("");
39
+ return `${D} { ${N} }`;
40
+ })) : [], d = t(e.variables), w = c(e.responsiveVariables), a = S(e.conditionalVariables), b = V(s), m = n(b, "css/variables.css"), r = `:root { ${d.join("")} ${w.join("")} } ${a.join("")}`;
41
+ $(m, r);
42
+ const f = n(b, "types/css-tokens.d.ts"), g = `type VariableTokens = ${[...o].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
43
+ $(f, g);
44
+ const y = n(b, "css/global.css"), F = q(e.global, "");
45
+ $(y, F);
46
+ const j = n(b, "css/templates.css"), k = A(e.templates);
47
+ $(j, k);
48
+ }, O = async (s, e) => {
49
+ const o = T(s), t = n(e, "js", o + ".js");
50
50
  await M.build({
51
51
  entryPoints: [s],
52
52
  minify: !0,
@@ -61,26 +61,26 @@ const rt = N.createLogger({
61
61
  const c = Date.now();
62
62
  return await import(`${t}?t=${c}`);
63
63
  }, R = async (s) => {
64
- const e = k(s), n = o(e, "salty-config.js"), { config: t } = await import(n);
64
+ const e = V(s), o = n(e, "salty-config.js"), { config: t } = await import(o);
65
65
  return t;
66
66
  }, it = async (s) => {
67
67
  try {
68
- const e = [], n = [], t = k(s), c = o(t, "index.css");
68
+ const e = [], o = [], t = V(s), c = n(t, "index.css");
69
69
  (() => {
70
- H(t) && z("rm -rf " + t), v(t), v(o(t, "css")), v(o(t, "types"));
70
+ K(t) && H("rm -rf " + t), v(t), v(n(t, "css")), v(n(t, "types"));
71
71
  })(), await Z(s);
72
72
  const d = await R(s);
73
73
  async function w(r, f) {
74
- const h = J(r);
74
+ const h = G(r);
75
75
  if (h.isDirectory()) {
76
- const u = G(r);
77
- await Promise.all(u.map((g) => w(o(r, g), o(f, g))));
78
- } else if (h.isFile() && O(r)) {
79
- const g = await E(r, t), F = [];
80
- Object.entries(g).forEach(([l, p]) => {
76
+ const g = J(r);
77
+ await Promise.all(g.map((y) => w(n(r, y), n(f, y))));
78
+ } else if (h.isFile() && E(r)) {
79
+ const y = await O(r, t), F = [];
80
+ Object.entries(y).forEach(([l, p]) => {
81
81
  if (p.isKeyframes && p.css) {
82
- const V = `${p.animationName}.css`, B = `css/${V}`, K = o(t, B);
83
- e.push(V), $(K, p.css);
82
+ const N = `${p.animationName}.css`, B = `css/${N}`, z = n(t, B);
83
+ e.push(N), $(z, p.css);
84
84
  return;
85
85
  }
86
86
  if (!p.generator) return;
@@ -88,93 +88,91 @@ const rt = N.createLogger({
88
88
  name: l,
89
89
  config: d
90
90
  }), x = `${i.hash}-${i.priority}.css`;
91
- n[i.priority] || (n[i.priority] = []), n[i.priority].push(x), F.push(x);
92
- const D = `css/${x}`, P = o(t, D);
93
- $(P, i.css);
91
+ o[i.priority] || (o[i.priority] = []), o[i.priority].push(x), F.push(x);
92
+ const C = `css/${x}`, D = n(t, C);
93
+ $(D, i.css);
94
94
  });
95
- const S = F.map((l) => `@import url('./${l}');`).join(`
96
- `), C = T(r, 6), m = o(t, `css/${C}.css`);
97
- $(m, S);
95
+ const j = F.map((l) => `@import url('./${l}');`).join(`
96
+ `), k = T(r, 6), u = n(t, `css/${k}.css`);
97
+ $(u, j);
98
98
  }
99
99
  }
100
100
  await w(s, t);
101
101
  const a = e.map((r) => `@import url('./css/${r}');`).join(`
102
102
  `);
103
- let y = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
103
+ let m = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
104
104
 
105
105
  ${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
106
106
  `)}
107
107
  ${a}`;
108
108
  if (d.importStrategy !== "component") {
109
- const r = n.flat().map((f) => `@import url('./css/${f}');`).join(`
109
+ const r = o.flat().map((f) => `@import url('./css/${f}');`).join(`
110
110
  `);
111
- y += r;
111
+ m += r;
112
112
  }
113
- $(c, y);
113
+ $(c, m);
114
114
  } catch (e) {
115
115
  console.error(e);
116
116
  }
117
117
  }, ct = async (s, e) => {
118
118
  try {
119
- const n = [], t = o(s, "./saltygen"), c = o(t, "index.css");
120
- if (O(e)) {
121
- const d = await R(s), w = await E(e, t);
119
+ const o = [], t = n(s, "./saltygen"), c = n(t, "index.css");
120
+ if (E(e)) {
121
+ const d = await R(s), w = await O(e, t);
122
122
  Object.entries(w).forEach(([f, h]) => {
123
123
  if (!h.generator) return;
124
- const u = h.generator._withBuildContext({
124
+ const g = h.generator._withBuildContext({
125
125
  name: f,
126
126
  config: d
127
- }), g = `${u.hash}-${u.priority}.css`, F = `css/${g}`, S = o(t, F);
128
- n.push(g), $(S, u.css);
127
+ }), y = `${g.hash}-${g.priority}.css`, F = `css/${y}`, j = n(t, F);
128
+ o.push(y), $(j, g.css);
129
129
  });
130
130
  const a = _(c, "utf8").split(`
131
- `), b = n.map((f) => `@import url('../saltygen/css/${f}');`), r = [.../* @__PURE__ */ new Set([...a, ...b])].join(`
131
+ `), b = o.map((f) => `@import url('../saltygen/css/${f}');`), r = [.../* @__PURE__ */ new Set([...a, ...b])].join(`
132
132
  `);
133
133
  $(c, r);
134
134
  }
135
- } catch (n) {
136
- console.error(n);
135
+ } catch (o) {
136
+ console.error(o);
137
137
  }
138
138
  }, at = async (s, e) => {
139
139
  try {
140
- const n = o(s, "./saltygen");
141
- if (O(e)) {
142
- let c = _(e, "utf8");
143
- c.replace(/^(?!export\s)const\s.*/gm, (y) => `export ${y}`) !== c && await L(e, c);
144
- const d = await R(s), w = await E(e, n);
140
+ const o = n(s, "./saltygen");
141
+ if (E(e)) {
142
+ const c = _(e, "utf8");
143
+ c.replace(/^(?!export\s)const\s.*/gm, (m) => `export ${m}`) !== c && await L(e, c);
144
+ const d = await R(s), w = await O(e, o);
145
145
  let a = c;
146
- Object.entries(w).forEach(([y, r]) => {
147
- var m;
146
+ Object.entries(w).forEach(([m, r]) => {
147
+ var j;
148
148
  if (r.isKeyframes) {
149
149
  console.log("value", r);
150
150
  return;
151
151
  }
152
152
  if (!r.generator) return;
153
153
  const f = r.generator._withBuildContext({
154
- name: y,
154
+ name: m,
155
155
  config: d
156
- }), h = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
156
+ }), h = new RegExp(`${m}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
157
157
  if (!h)
158
158
  return console.error("Could not find the original declaration");
159
- const u = (m = h.at(1)) == null ? void 0 : m.trim(), { element: g, variantKeys: F } = f.props, S = `${y} = styled(${u}, "${f.classNames}", "${f._callerName}", ${JSON.stringify(g)}, ${JSON.stringify(
160
- F
161
- )});`, C = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
162
- a = a.replace(C, S);
159
+ const g = (j = h.at(1)) == null ? void 0 : j.trim(), y = `${m} = styled(${g}, "${f.classNames}", "${f._callerName}", ${JSON.stringify(f.props)});`, F = new RegExp(`${m}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
160
+ a = a.replace(F, y);
163
161
  });
164
162
  const b = T(e, 6);
165
163
  return d.importStrategy === "component" && (a = `import '../../saltygen/css/${b}.css';
166
164
  ${a}`), a = a.replace("{ styled }", "{ styledClient as styled }"), a = a.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), a;
167
165
  }
168
- } catch (n) {
169
- console.error(n);
166
+ } catch (o) {
167
+ console.error(o);
170
168
  }
171
169
  };
172
170
  export {
173
- E as compileSaltyFile,
171
+ O as compileSaltyFile,
174
172
  it as generateCss,
175
173
  ct as generateFile,
176
174
  Z as generateVariables,
177
- O as isSaltyFile,
175
+ E as isSaltyFile,
178
176
  rt as logger,
179
177
  at as minimizeFile,
180
178
  W as saltyFileExtensions,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../util/index.cjs"),i=require("../parse-templates-BY1Xai-_.cjs");class o{constructor(t,s){this.tagName=t,this.params=s}get hash(){return n.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?i.getTemplateKeys(this._context.config.templates):[]}get css(){var a;const{base:t={},variants:s={},compoundVariants:e=[]}=this.params,r={...t,variants:s,compoundVariants:e};return i.parseStyles(r,`.${this.cssClassName}`,this.priority,(a=this._context)==null?void 0:a.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var a;const r=(a=this.params.defaultVariants)==null?void 0:a[e];return r!==void 0?`${e}=${String(r)}`:e}):void 0;return{element:t,variantKeys:s}}_withBuildContext(t){this._context=t;const{name:s,config:e}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../util/index.cjs"),c=require("../parse-templates-BY1Xai-_.cjs");class h{constructor(t,s){this.tagName=t,this.params=s}get hash(){return p.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?c.getTemplateKeys(this._context.config.templates):[]}get css(){var e;const{base:t={},variants:s={},compoundVariants:a=[]}=this.params,r={...t,variants:s,compoundVariants:a};return c.parseStyles(r,`.${this.cssClassName}`,this.priority,(e=this._context)==null?void 0:e.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var i;const n=(i=this.params.defaultVariants)==null?void 0:i[e];return n!==void 0?`${e}=${String(n)}`:e}):void 0,a=new Set([]),r=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return r&&r.forEach((e,n,i)=>{const o=i.at(1);o&&a.add(o)}),{element:t,variantKeys:s,propValueKeys:[...a]}}_withBuildContext(t){this._context=t;const{name:s,config:a}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=h;
@@ -1,11 +1,11 @@
1
- import { toHash as i } from "../util/index.js";
2
- import { g as n, p as o } from "../parse-templates-BOSK0Tb6.js";
3
- class p {
1
+ import { toHash as p } from "../util/index.js";
2
+ import { g as c, p as h } from "../parse-templates-BOSK0Tb6.js";
3
+ class u {
4
4
  constructor(t, s) {
5
5
  this.tagName = t, this.params = s;
6
6
  }
7
7
  get hash() {
8
- return i(this.params.base || this.params);
8
+ return p(this.params.base || this.params);
9
9
  }
10
10
  get priority() {
11
11
  var t;
@@ -23,30 +23,34 @@ class p {
23
23
  }
24
24
  get templateKeys() {
25
25
  var t;
26
- return (t = this._context) != null && t.config.templates ? n(this._context.config.templates) : [];
26
+ return (t = this._context) != null && t.config.templates ? c(this._context.config.templates) : [];
27
27
  }
28
28
  get css() {
29
- var e;
30
- const { base: t = {}, variants: s = {}, compoundVariants: a = [] } = this.params, r = { ...t, variants: s, compoundVariants: a };
31
- return o(r, `.${this.cssClassName}`, this.priority, (e = this._context) == null ? void 0 : e.config);
29
+ var a;
30
+ const { base: t = {}, variants: s = {}, compoundVariants: e = [] } = this.params, r = { ...t, variants: s, compoundVariants: e };
31
+ return h(r, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
32
32
  }
33
33
  get props() {
34
34
  const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
35
- var e;
36
- const r = (e = this.params.defaultVariants) == null ? void 0 : e[a];
37
- return r !== void 0 ? `${a}=${String(r)}` : a;
38
- }) : void 0;
39
- return {
35
+ var i;
36
+ const n = (i = this.params.defaultVariants) == null ? void 0 : i[a];
37
+ return n !== void 0 ? `${a}=${String(n)}` : a;
38
+ }) : void 0, e = /* @__PURE__ */ new Set([]), r = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
39
+ return r && r.forEach((a, n, i) => {
40
+ const o = i.at(1);
41
+ o && e.add(o);
42
+ }), {
40
43
  element: t,
41
- variantKeys: s
44
+ variantKeys: s,
45
+ propValueKeys: [...e]
42
46
  };
43
47
  }
44
48
  _withBuildContext(t) {
45
49
  this._context = t;
46
- const { name: s, config: a } = t;
50
+ const { name: s, config: e } = t;
47
51
  return this._callerName = s, this;
48
52
  }
49
53
  }
50
54
  export {
51
- p as StyleComponentGenerator
55
+ u as StyleComponentGenerator
52
56
  };
@@ -1,4 +1,9 @@
1
1
  import { StyledParams, Tag } from '../types';
2
+ export interface GeneratorProps {
3
+ element?: string;
4
+ variantKeys?: string[];
5
+ propValueKeys?: string[];
6
+ }
2
7
  export declare class StyleComponentGenerator {
3
8
  tagName: Tag<any>;
4
9
  params: StyledParams;
@@ -15,10 +20,7 @@ export declare class StyleComponentGenerator {
15
20
  get cssDisplayNameVar(): string;
16
21
  get templateKeys(): string[];
17
22
  get css(): string;
18
- get props(): {
19
- element: string | undefined;
20
- variantKeys: string[] | undefined;
21
- };
23
+ get props(): GeneratorProps;
22
24
  _withBuildContext(context: {
23
25
  name: string;
24
26
  config: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.14",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/types/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export type CreateElementProps = {
11
11
  /** vks = Variant key set */
12
12
  _vks?: Set<string>;
13
13
  };
14
- export type StyledComponentProps = Record<string, unknown> & CreateElementProps & CssRuntimeValues;
14
+ export type StyledComponentProps = Record<string, unknown> & CreateElementProps;
15
15
  type FnComponent<PROPS extends StyledComponentProps> = {
16
16
  (props: PROPS): ReactNode;
17
17
  generator?: StyleComponentGenerator;
@@ -39,13 +39,14 @@ type Variants = {
39
39
  compoundVariants?: CompoundVariant[];
40
40
  };
41
41
  type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
42
- export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? {} : {
42
+ export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? object : {
43
43
  [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
44
44
  };
45
- export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
46
- export type CssRuntimeValues = {
47
- cssValues?: Record<string, unknown>;
45
+ type CssValuePropKey = `props-${string}`;
46
+ export type ValueProps = {
47
+ [key: CssValuePropKey]: string;
48
48
  };
49
+ export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
49
50
  type StylePropertyValue = Record<never, never> & unknown;
50
51
  export type CssStyles = {
51
52
  [key in StyleKeys | OrString]?: StyleValue<key> | StylePropertyValue | PropertyValueToken | CssStyles;