@salty-css/core 0.0.1-alpha.7 → 0.0.1-alpha.70

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.js CHANGED
@@ -1,180 +1,196 @@
1
- import * as M from "esbuild";
2
- import * as N from "winston";
3
- import { execSync as z } from "child_process";
4
- import { toHash as T, dashCase as I } from "../util/index.js";
1
+ import * as z from "esbuild";
2
+ import { execSync as q } from "child_process";
3
+ import { t as v, d as _ } from "../dash-case-DMQMcCO6.js";
5
4
  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";
7
- import { writeFile as L } from "fs/promises";
8
- import { p as q, a as A, b as U } from "../parse-templates-BOSK0Tb6.js";
9
- const ot = N.createLogger({
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"], O = (s) => new RegExp(`\\.(${W.join("|")})\\.`).test(s), X = async (s) => {
14
- const e = k(s), n = o(s, "salty-config.ts"), t = o(e, "salty-config.js");
15
- await M.build({
5
+ import { writeFileSync as F, existsSync as A, mkdirSync as E, statSync as L, readdirSync as U, readFileSync as M } from "fs";
6
+ import { writeFile as X } from "fs/promises";
7
+ import { p as Y, a as Z, b as Q } from "../parse-templates-DUUSaubj.js";
8
+ const W = () => import.meta.url.endsWith(".cjs") ? "cjs" : "esm", V = {
9
+ externalModules: []
10
+ }, H = (t) => {
11
+ if (V.externalModules.length > 0) return V.externalModules;
12
+ const e = o(t, "salty.config.ts"), s = M(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
13
+ if (!s) return [];
14
+ const a = s[1].split(",").map((w) => w.replace(/['"`]/g, "").trim());
15
+ return V.externalModules = a, a;
16
+ }, N = (t) => o(t, "./saltygen"), tt = ["salty", "css", "styles", "styled"], st = (t = []) => new RegExp(`\\.(${[...tt, ...t].join("|")})\\.`), O = (t, e = []) => st(e).test(t), et = async (t) => {
17
+ const e = N(t), n = o(t, "salty.config.ts"), s = o(e, "salty.config.js"), a = W(), w = H(t);
18
+ await z.build({
16
19
  entryPoints: [n],
17
20
  minify: !0,
18
21
  treeShaking: !0,
19
22
  bundle: !0,
20
- outfile: t,
21
- format: "esm",
22
- external: ["react"]
23
+ outfile: s,
24
+ format: a,
25
+ external: w
23
26
  });
24
- const c = Date.now(), { config: S } = await import(`${t}?t=${c}`);
25
- return S;
26
- }, Y = async (s) => {
27
- const e = await X(s), n = /* @__PURE__ */ new Set(), t = (m, l = []) => m ? Object.entries(m).flatMap(([p, i]) => {
28
- if (!i) return;
29
- if (typeof i == "object") return t(i, [...l, p]);
30
- const C = [...l, p].join(".");
27
+ const f = Date.now(), { config: y } = await import(`${s}?t=${f}`);
28
+ return y;
29
+ }, nt = async (t) => {
30
+ const e = await et(t), n = /* @__PURE__ */ new Set(), s = (i, l = []) => i ? Object.entries(i).flatMap(([m, p]) => {
31
+ if (!p) return;
32
+ if (typeof p == "object") return s(p, [...l, m]);
33
+ const C = [...l, m].join(".");
31
34
  n.add(`"${C}"`);
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]) => {
35
- const i = t(p);
36
- return l === "base" ? i.join("") : `${l} { ${i.join("")} }`;
37
- }) : [], S = (m) => m ? Object.entries(m).flatMap(([l, p]) => Object.entries(p).flatMap(([i, C]) => {
38
- const D = t(C, [l]), P = `.${l}-${i}, [data-${l}="${i}"]`, V = D.join("");
39
- return `${P} { ${V} }`;
40
- })) : [], d = t(e.variables), w = c(e.responsiveVariables), a = S(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"), j = q(e.global, "");
45
- $(g, j);
46
- const F = o(b, "css/templates.css"), x = A(e.templates);
47
- $(F, x);
48
- }, E = async (s, e) => {
49
- const n = T(s), t = o(e, "js", n + ".js");
50
- await M.build({
51
- entryPoints: [s],
35
+ const d = [...l.map(_), _(m)].join("-"), { result: h } = Q(p);
36
+ return `--${d}: ${h};`;
37
+ }) : [], a = (i) => i ? Object.entries(i).flatMap(([l, m]) => {
38
+ const p = s(m);
39
+ return l === "base" ? p.join("") : `${l} { ${p.join("")} }`;
40
+ }) : [], w = (i) => i ? Object.entries(i).flatMap(([l, m]) => Object.entries(m).flatMap(([p, C]) => {
41
+ const d = s(C, [l]), h = `.${l}-${p}, [data-${l}="${p}"]`, k = d.join("");
42
+ return `${h} { ${k} }`;
43
+ })) : [], f = s(e.variables), y = a(e.responsiveVariables), r = w(e.conditionalVariables), S = N(t), $ = o(S, "css/variables.css"), D = `:root { ${f.join("")} ${y.join("")} } ${r.join("")}`;
44
+ F($, D);
45
+ const g = o(S, "types/css-tokens.d.ts"), u = `type VariableTokens = ${[...n].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
46
+ F(g, u);
47
+ const j = o(S, "css/global.css"), x = Y(e.global, "");
48
+ F(j, x);
49
+ const b = o(S, "css/templates.css"), T = Z(e.templates);
50
+ F(b, T);
51
+ }, R = async (t, e, n) => {
52
+ const s = v(e), a = o(n, "js", s + ".js"), w = W(), f = H(t);
53
+ await z.build({
54
+ entryPoints: [e],
52
55
  minify: !0,
53
56
  treeShaking: !0,
54
57
  bundle: !0,
55
- outfile: t,
56
- format: "esm",
58
+ outfile: a,
59
+ format: w,
57
60
  target: ["es2022"],
58
61
  keepNames: !0,
59
- external: ["react"]
62
+ external: f
60
63
  });
61
- const c = Date.now();
62
- return await import(`${t}?t=${c}`);
63
- }, R = async (s) => {
64
- const e = k(s), n = o(e, "salty-config.js"), { config: t } = await import(n);
65
- return t;
66
- }, rt = async (s) => {
64
+ const y = Date.now();
65
+ return await import(`${a}?t=${y}`);
66
+ }, B = async (t) => {
67
+ const e = N(t), n = o(e, "salty.config.js"), { config: s } = await import(n);
68
+ return s;
69
+ }, pt = async (t) => {
67
70
  try {
68
- const e = [], n = [], t = k(s), c = o(t, "index.css");
71
+ const e = [], n = [], s = N(t), a = o(s, "index.css");
69
72
  (() => {
70
- H(t) && z("rm -rf " + t), v(t), v(o(t, "css")), v(o(t, "types"));
71
- })(), await Y(s);
72
- const d = await R(s);
73
- async function w(r, f) {
74
- const h = J(r);
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), j = [];
80
- Object.entries(g).forEach(([l, p]) => {
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);
73
+ A(s) && q("rm -rf " + s), E(s), E(o(s, "css")), E(o(s, "types"));
74
+ })(), await nt(t);
75
+ const f = await B(t);
76
+ async function y(c, u) {
77
+ const j = ["node_modules", "saltygen"], x = L(c);
78
+ if (x.isDirectory()) {
79
+ const b = U(c);
80
+ if (j.some((i) => c.includes(i))) return;
81
+ await Promise.all(b.map((i) => y(o(c, i), o(u, i))));
82
+ } else if (x.isFile() && O(c)) {
83
+ const T = await R(t, c, s), i = [];
84
+ Object.entries(T).forEach(([C, d]) => {
85
+ if (d.isKeyframes && d.css) {
86
+ const I = `${d.animationName}.css`, G = `css/${I}`, J = o(s, G);
87
+ e.push(I), F(J, d.css);
84
88
  return;
85
89
  }
86
- if (!p.generator) return;
87
- const i = p.generator._withBuildContext({
88
- name: l,
89
- config: d
90
- }), C = `${i.hash}-${i.priority}.css`;
91
- n[i.priority] || (n[i.priority] = []), n[i.priority].push(C), j.push(C);
92
- const D = `css/${C}`, P = o(t, D);
93
- $(P, i.css);
90
+ if (!d.generator) return;
91
+ const h = d.generator._withBuildContext({
92
+ name: C,
93
+ config: f
94
+ }), k = `${h.hash}-${h.priority}.css`;
95
+ n[h.priority] || (n[h.priority] = []), n[h.priority].push(k), i.push(k);
96
+ const P = `css/${k}`, K = o(s, P);
97
+ F(K, h.css);
94
98
  });
95
- const F = j.map((l) => `@import url('./${l}');`).join(`
96
- `), x = T(r, 6), m = o(t, `css/${x}.css`);
97
- $(m, F);
99
+ const l = i.map((C) => `@import url('./${C}');`).join(`
100
+ `), m = v(c, 6), p = o(s, `css/${m}.css`);
101
+ F(p, l);
98
102
  }
99
103
  }
100
- await w(s, t);
101
- const a = e.map((r) => `@import url('./css/${r}');`).join(`
104
+ await y(t, s);
105
+ const r = e.map((c) => `@import url('./css/${c}');`).join(`
102
106
  `);
103
- let y = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
107
+ let g = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
104
108
 
105
- ${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
109
+ ${["variables.css", "global.css", "templates.css"].filter((c) => {
110
+ try {
111
+ return M(o(s, "css", c), "utf8").length > 0;
112
+ } catch {
113
+ return !1;
114
+ }
115
+ }).map((c) => `@import url('./css/${c}');`).join(`
106
116
  `)}
107
- ${a}`;
108
- if (d.importStrategy !== "component") {
109
- const r = n.flat().map((f) => `@import url('./css/${f}');`).join(`
117
+ ${r}`;
118
+ if (f.importStrategy !== "component") {
119
+ const c = n.flat().map((u) => `@import url('./css/${u}');`).join(`
110
120
  `);
111
- y += r;
121
+ g += c;
112
122
  }
113
- $(c, y);
123
+ F(a, g);
114
124
  } catch (e) {
115
125
  console.error(e);
116
126
  }
117
- }, it = async (s, e) => {
127
+ }, ft = async (t, e) => {
118
128
  try {
119
- const n = [], t = o(s, "./saltygen"), c = o(t, "index.css");
129
+ const n = [], s = o(t, "./saltygen"), a = o(s, "index.css");
120
130
  if (O(e)) {
121
- const d = await R(s), w = await E(e, t);
122
- Object.entries(w).forEach(([f, h]) => {
123
- if (!h.generator) return;
124
- const u = h.generator._withBuildContext({
125
- name: f,
126
- config: d
127
- }), g = `${u.hash}-${u.priority}.css`, j = `css/${g}`, F = o(t, j);
128
- n.push(g), $(F, u.css);
131
+ const f = await B(t), y = await R(t, e, s);
132
+ Object.entries(y).forEach(([g, c]) => {
133
+ if (!c.generator) return;
134
+ const u = c.generator._withBuildContext({
135
+ name: g,
136
+ config: f
137
+ }), j = `${u.hash}-${u.priority}.css`, x = `css/${j}`, b = o(s, x);
138
+ n.push(j), F(b, u.css);
129
139
  });
130
- const a = _(c, "utf8").split(`
131
- `), b = n.map((f) => `@import url('../saltygen/css/${f}');`), r = [.../* @__PURE__ */ new Set([...a, ...b])].join(`
140
+ const r = M(a, "utf8").split(`
141
+ `), S = n.map((g) => `@import url('../saltygen/css/${g}');`), D = [.../* @__PURE__ */ new Set([...r, ...S])].join(`
132
142
  `);
133
- $(c, r);
143
+ F(a, D);
134
144
  }
135
145
  } catch (n) {
136
146
  console.error(n);
137
147
  }
138
- }, ct = async (s, e) => {
148
+ }, ut = async (t, e) => {
139
149
  try {
140
- const n = o(s, "./saltygen");
150
+ const n = o(t, "./saltygen");
141
151
  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);
145
- let a = c;
146
- Object.entries(w).forEach(([y, r]) => {
147
- var m;
148
- if (r.isKeyframes) {
149
- console.log("value", r);
150
- return;
152
+ const a = M(e, "utf8");
153
+ a.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== a && await X(e, a);
154
+ const f = await B(t), y = await R(t, e, n);
155
+ let r = a;
156
+ Object.entries(y).forEach(([$, D]) => {
157
+ var k;
158
+ if (D.isKeyframes || !D.generator) return;
159
+ const g = D.generator._withBuildContext({
160
+ name: $,
161
+ config: f
162
+ }), c = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
163
+ if (!c) return console.error("Could not find the original declaration");
164
+ const u = (k = c.at(1)) == null ? void 0 : k.trim(), j = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(r);
165
+ if (!j) return console.error("Could not find the original declaration");
166
+ const { index: x } = j;
167
+ let b = !1;
168
+ const T = setTimeout(() => b = !0, 5e3);
169
+ let i = 0, l = !1, m = 0;
170
+ for (; !l && !b; ) {
171
+ const P = r[x + i];
172
+ P === "(" && m++, P === ")" && m--, m === 0 && P === ")" && (l = !0), i > r.length && (b = !0), i++;
151
173
  }
152
- if (!r.generator) return;
153
- const f = r.generator._withBuildContext({
154
- name: y,
155
- config: d
156
- }), h = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
157
- if (!h)
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: j } = f.props, F = `${y} = styled(${u}, "${f.classNames}", "${f._callerName}", ${JSON.stringify(g)}, ${JSON.stringify(
160
- j
161
- )});`, x = new RegExp(`${y}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
162
- a = a.replace(x, F);
174
+ if (!b) clearTimeout(T);
175
+ else throw new Error("Failed to find the end of the styled call and timed out");
176
+ const p = x + i, C = r.slice(x, p), d = r, h = ` ${$} = styled(${u}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`;
177
+ r = r.replace(C, h), d === r && console.error("Minimize file failed to change content", { name: $, tagName: u });
163
178
  });
164
- const b = T(e, 6);
165
- return d.importStrategy === "component" && (a = `import '../../saltygen/css/${b}.css';
166
- ${a}`), a = a.replace("{ styled }", "{ styledClient as styled }"), a = a.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), a;
179
+ const S = v(e, 6);
180
+ return f.importStrategy === "component" && (r = `import '../../saltygen/css/${S}.css';
181
+ ${r}`), r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
167
182
  }
168
183
  } catch (n) {
169
- console.error(n);
184
+ console.error("Error in minimizeFile:", n);
170
185
  }
171
186
  };
172
187
  export {
173
- E as compileSaltyFile,
174
- rt as generateCss,
175
- it as generateFile,
176
- Y as generateVariables,
188
+ R as compileSaltyFile,
189
+ nt as generateConfigStyles,
190
+ pt as generateCss,
191
+ ft as generateFile,
177
192
  O as isSaltyFile,
178
- ot as logger,
179
- ct as minimizeFile
193
+ ut as minimizeFile,
194
+ tt as saltyFileExtensions,
195
+ st as saltyFileRegExp
180
196
  };
@@ -1,7 +1,6 @@
1
1
  import { CssStyles } from '../types';
2
- type CssTemplate = CssStyles | {
3
- [key: PropertyKey]: CssTemplate;
4
- };
2
+ import { OrString } from '../types/util-types';
3
+ export type GlobalStyles = Record<string, CssStyles>;
5
4
  export type CssVariables = Record<string, unknown>;
6
5
  export interface CssResponsiveVariables {
7
6
  [key: string]: CssVariables;
@@ -11,6 +10,9 @@ export interface CssConditionalVariables {
11
10
  [key: PropertyKey]: CssVariables;
12
11
  };
13
12
  }
13
+ type CssTemplate = CssStyles | {
14
+ [key: PropertyKey]: CssTemplate;
15
+ };
14
16
  export interface CssTemplates {
15
17
  [key: PropertyKey]: {
16
18
  [key: PropertyKey]: CssTemplate;
@@ -30,11 +32,11 @@ export interface SaltyConfig {
30
32
  * - `root` will import the css file from the root of the project.
31
33
  * - `component` will import the css file from the component's directory.
32
34
  */
33
- importStrategy: 'root' | 'component';
35
+ importStrategy?: 'root' | 'component';
34
36
  /**
35
37
  * Base variables that can be used in all styles as they are applied globally to :root.
36
38
  */
37
- variables: CssVariables;
39
+ variables?: CssVariables;
38
40
  /**
39
41
  * Variables that are defined for different media queries.
40
42
  */
@@ -46,7 +48,7 @@ export interface SaltyConfig {
46
48
  /**
47
49
  * The global styles that are imported in the root of the project.
48
50
  */
49
- global: CssStyles;
51
+ global?: GlobalStyles;
50
52
  /**
51
53
  * The templates that can be used in styles to create reusable css.
52
54
  */
@@ -55,5 +57,9 @@ export interface SaltyConfig {
55
57
  * The modifiers that can transform css values.
56
58
  */
57
59
  modifiers?: CssModifiers;
60
+ /**
61
+ * Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
62
+ */
63
+ externalModules?: ('react' | 'react-dom' | OrString)[];
58
64
  }
59
65
  export {};
@@ -0,0 +1 @@
1
+ "use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=3)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,t)=>(t>0?"-":"")+r.toLowerCase()):""}exports.dashCase=s;exports.toHash=c;
@@ -0,0 +1,19 @@
1
+ const n = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), o = (e, r) => {
2
+ let t = "", a;
3
+ for (a = Math.abs(e); a > 52; a = a / 52 | 0) t = n(a % 52) + t;
4
+ return t = n(a % 52) + t, t.length < r ? t = t.padStart(r, "a") : t.length > r && (t = t.slice(-r)), t;
5
+ }, i = (e, r) => {
6
+ let t = r.length;
7
+ for (; t; ) e = e * 33 ^ r.charCodeAt(--t);
8
+ return e;
9
+ }, c = (e, r = 3) => {
10
+ const t = i(5381, JSON.stringify(e)) >>> 0;
11
+ return o(t, r);
12
+ };
13
+ function s(e) {
14
+ return e ? typeof e != "string" ? s(String(e)) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
15
+ }
16
+ export {
17
+ s as d,
18
+ c as t
19
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../util/index.cjs"),a=require("../parse-templates-BY1Xai-_.cjs");class o{constructor(t,s,e){this.tagName=t,this.styles=s,this.options=e}get hash(){return n.toHash(this.styles)}get priority(){var t;return typeof this.tagName=="function"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.options;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?a.getTemplateKeys(this._context.config.templates):[]}get css(){var t;return a.parseStyles(this.styles,`.${this.cssClassName}`,this.priority,(t=this._context)==null?void 0:t.config)}get props(){const{element:t}=this.options,s=this.styles.variants?Object.keys(this.styles.variants).map(e=>{var r;const i=(r=this.styles.defaultVariants)==null?void 0:r[e];return i!==void 0?`${e}=${String(i)}`: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";var m=Object.defineProperty;var l=(a,t,s)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>l(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-DKzpenwY.cjs"),p=require("../parse-templates-DVK3iZIl.cjs");class g{constructor(t,s){c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return u.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?p.getTemplateKeys(this._context.config.templates):[]}get css(){var e;const{base:t={},variants:s={},compoundVariants:r=[]}=this.params,i={...t,variants:s,compoundVariants:r};return p.parseStyles(i,`.${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 n;const o=(n=this.params.defaultVariants)==null?void 0:n[e];return o!==void 0?`${e}=${String(o)}`:e}):void 0,r=new Set([]),i=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return i&&i.forEach((e,o,n)=>{const h=n.at(1);h&&r.add(h)}),{element:t,variantKeys:s,propValueKeys:[...r]}}_withBuildContext(t){this._context=t;const{name:s,config:r}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=g;
@@ -1,18 +1,23 @@
1
- import { toHash as a } from "../util/index.js";
2
- import { g as n, p as o } from "../parse-templates-BOSK0Tb6.js";
3
- class p {
4
- constructor(t, s, e) {
5
- this.tagName = t, this.styles = s, this.options = e;
1
+ var h = Object.defineProperty;
2
+ var m = (e, t, s) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => m(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { t as l } from "../dash-case-DMQMcCO6.js";
5
+ import { g, p as u } from "../parse-templates-DUUSaubj.js";
6
+ class d {
7
+ constructor(t, s) {
8
+ c(this, "_callerName");
9
+ c(this, "_context");
10
+ this.tagName = t, this.params = s;
6
11
  }
7
12
  get hash() {
8
- return a(this.styles);
13
+ return l(this.params.base || this.params);
9
14
  }
10
15
  get priority() {
11
16
  var t;
12
- return typeof this.tagName == "function" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
17
+ return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
13
18
  }
14
19
  get classNames() {
15
- const t = [this.hash], { className: s } = this.options;
20
+ const t = [this.hash], { className: s } = this.params;
16
21
  return s && t.push(s), t.join(" ");
17
22
  }
18
23
  get cssClassName() {
@@ -23,29 +28,34 @@ class p {
23
28
  }
24
29
  get templateKeys() {
25
30
  var t;
26
- return (t = this._context) != null && t.config.templates ? n(this._context.config.templates) : [];
31
+ return (t = this._context) != null && t.config.templates ? g(this._context.config.templates) : [];
27
32
  }
28
33
  get css() {
29
- var t;
30
- return o(this.styles, `.${this.cssClassName}`, this.priority, (t = this._context) == null ? void 0 : t.config);
34
+ var a;
35
+ const { base: t = {}, variants: s = {}, compoundVariants: r = [] } = this.params, i = { ...t, variants: s, compoundVariants: r };
36
+ return u(i, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
31
37
  }
32
38
  get props() {
33
- const { element: t } = this.options, s = this.styles.variants ? Object.keys(this.styles.variants).map((e) => {
34
- var r;
35
- const i = (r = this.styles.defaultVariants) == null ? void 0 : r[e];
36
- return i !== void 0 ? `${e}=${String(i)}` : e;
37
- }) : void 0;
38
- return {
39
+ const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
40
+ var n;
41
+ const o = (n = this.params.defaultVariants) == null ? void 0 : n[a];
42
+ return o !== void 0 ? `${a}=${String(o)}` : a;
43
+ }) : void 0, r = /* @__PURE__ */ new Set([]), i = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
44
+ return i && i.forEach((a, o, n) => {
45
+ const p = n.at(1);
46
+ p && r.add(p);
47
+ }), {
39
48
  element: t,
40
- variantKeys: s
49
+ variantKeys: s,
50
+ propValueKeys: [...r]
41
51
  };
42
52
  }
43
53
  _withBuildContext(t) {
44
54
  this._context = t;
45
- const { name: s, config: e } = t;
55
+ const { name: s, config: r } = t;
46
56
  return this._callerName = s, this;
47
57
  }
48
58
  }
49
59
  export {
50
- p as StyleComponentGenerator
60
+ d as StyleComponentGenerator
51
61
  };
@@ -1,14 +1,18 @@
1
- import { GeneratorOptions, Styles, Tag } from '../types';
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
- styles: Styles;
5
- private options;
9
+ params: StyledParams;
6
10
  _callerName: string | undefined;
7
11
  _context: {
8
12
  name: string;
9
13
  config: any;
10
14
  } | undefined;
11
- constructor(tagName: Tag<any>, styles: Styles, options: GeneratorOptions);
15
+ constructor(tagName: Tag<any>, params: StyledParams);
12
16
  get hash(): string;
13
17
  get priority(): number;
14
18
  get classNames(): string;
@@ -16,10 +20,7 @@ export declare class StyleComponentGenerator {
16
20
  get cssDisplayNameVar(): string;
17
21
  get templateKeys(): string[];
18
22
  get css(): string;
19
- get props(): {
20
- element: string | undefined;
21
- variantKeys: string[] | undefined;
22
- };
23
+ get props(): GeneratorProps;
23
24
  _withBuildContext(context: {
24
25
  name: string;
25
26
  config: any;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="/* Empty */";exports.default=e;
@@ -0,0 +1,4 @@
1
+ const t = "/* Empty */";
2
+ export {
3
+ t as default
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.70",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -10,7 +10,12 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "homepage": "https://github.com/margarita-form/salty-css",
13
+ "description": "Core library for Salty CSS. Will be used by other Salty CSS libraries and plugins.",
14
+ "homepage": "https://salty-css.dev/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/margarita-form/salty-css.git"
18
+ },
14
19
  "bugs": {
15
20
  "url": "https://github.com/margarita-form/salty-css/issues"
16
21
  },
@@ -19,13 +24,22 @@
19
24
  "!**/*.tsbuildinfo"
20
25
  ],
21
26
  "nx": {
27
+ "sourceRoot": "libs/core/src",
22
28
  "name": "core"
23
29
  },
24
30
  "peerDependencies": {
25
- "clsx": ">=2.x",
31
+ "commander": ">=12.x",
32
+ "ejs": ">=3.x",
33
+ "esbuild": ">=0.21.x",
34
+ "ora": ">=8.x",
35
+ "react": ">=18.x || >=19.x",
26
36
  "winston": ">=3.x"
27
37
  },
28
38
  "exports": {
39
+ "./bin/main": {
40
+ "import": "./bin/main.js",
41
+ "require": "./bin/main.cjs"
42
+ },
29
43
  "./compiler": {
30
44
  "import": "./compiler/index.js",
31
45
  "require": "./compiler/index.cjs"
@@ -50,5 +64,11 @@
50
64
  "import": "./util/index.js",
51
65
  "require": "./util/index.cjs"
52
66
  }
67
+ },
68
+ "bin": {
69
+ "salty": "./bin/index.js",
70
+ "salty-css": "./bin/index.js",
71
+ "salty-css-cjs": "./bin/index.cjs",
72
+ "@salty-css/core": "./bin/index.js"
53
73
  }
54
74
  }