@salty-css/core 0.0.1-alpha.9 → 0.0.1-alpha.91

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.
Files changed (45) hide show
  1. package/.saltyrc.schema.json +40 -0
  2. package/README.md +83 -8
  3. package/bin/bin-util.d.ts +2 -0
  4. package/bin/index.cjs +2 -0
  5. package/bin/index.d.ts +2 -0
  6. package/bin/index.js +3 -0
  7. package/bin/logger.d.ts +2 -0
  8. package/bin/main.cjs +10 -0
  9. package/bin/main.d.ts +1 -0
  10. package/bin/main.js +233 -0
  11. package/bin/prettier.d.ts +1 -0
  12. package/compiler/get-files.d.ts +3 -0
  13. package/compiler/index.cjs +1 -11
  14. package/compiler/index.d.ts +7 -7
  15. package/compiler/index.js +16 -178
  16. package/config/config-types.d.ts +10 -4
  17. package/dash-case-DKzpenwY.cjs +1 -0
  18. package/dash-case-DMQMcCO6.js +19 -0
  19. package/generator/index.cjs +1 -1
  20. package/generator/index.js +30 -17
  21. package/generator/style-generator.d.ts +11 -4
  22. package/index-84Wroia-.cjs +1 -0
  23. package/index-BGaLvshf.js +232 -0
  24. package/index-BKoD9apd.cjs +11 -0
  25. package/index-D_732b92.js +4 -0
  26. package/package.json +23 -3
  27. package/parse-templates-DUUSaubj.js +96 -0
  28. package/parse-templates-DVK3iZIl.cjs +8 -0
  29. package/pascal-case-BQpR5PdN.js +6 -0
  30. package/pascal-case-iWoaJWwT.cjs +1 -0
  31. package/react-styled-file-CGVf5n1B.js +11 -0
  32. package/react-styled-file-Dkubsz-U.cjs +8 -0
  33. package/react-vanilla-file-CCXbsjIb.js +18 -0
  34. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  35. package/salty.config-BhBY_oOk.js +10 -0
  36. package/salty.config-Dk6ZcCxI.cjs +7 -0
  37. package/types/index.d.ts +10 -4
  38. package/util/camel-case.d.ts +1 -0
  39. package/util/index.cjs +1 -1
  40. package/util/index.d.ts +2 -0
  41. package/util/index.js +7 -15
  42. package/util/module-type.d.ts +1 -0
  43. package/util/pascal-case.d.ts +1 -0
  44. package/parse-templates-BOSK0Tb6.js +0 -90
  45. package/parse-templates-BY1Xai-_.cjs +0 -8
package/compiler/index.js CHANGED
@@ -1,180 +1,18 @@
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";
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";
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({
16
- entryPoints: [n],
17
- minify: !0,
18
- treeShaking: !0,
19
- bundle: !0,
20
- outfile: t,
21
- format: "esm",
22
- external: ["react"]
23
- });
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(".");
31
- 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],
52
- minify: !0,
53
- treeShaking: !0,
54
- bundle: !0,
55
- outfile: t,
56
- format: "esm",
57
- target: ["es2022"],
58
- keepNames: !0,
59
- external: ["react"]
60
- });
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) => {
67
- try {
68
- const e = [], n = [], t = k(s), c = o(t, "index.css");
69
- (() => {
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);
84
- return;
85
- }
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);
94
- });
95
- const F = j.map((l) => `@import url('./${l}');`).join(`
96
- `), x = T(r, 6), m = o(t, `css/${x}.css`);
97
- $(m, F);
98
- }
99
- }
100
- await w(s, t);
101
- const a = e.map((r) => `@import url('./css/${r}');`).join(`
102
- `);
103
- let y = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
104
-
105
- ${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
106
- `)}
107
- ${a}`;
108
- if (d.importStrategy !== "component") {
109
- const r = n.flat().map((f) => `@import url('./css/${f}');`).join(`
110
- `);
111
- y += r;
112
- }
113
- $(c, y);
114
- } catch (e) {
115
- console.error(e);
116
- }
117
- }, it = async (s, e) => {
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);
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);
129
- });
130
- const a = _(c, "utf8").split(`
131
- `), b = n.map((f) => `@import url('../saltygen/css/${f}');`), r = [.../* @__PURE__ */ new Set([...a, ...b])].join(`
132
- `);
133
- $(c, r);
134
- }
135
- } catch (n) {
136
- console.error(n);
137
- }
138
- }, ct = async (s, e) => {
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);
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;
151
- }
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);
163
- });
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;
167
- }
168
- } catch (n) {
169
- console.error(n);
170
- }
171
- };
1
+ import "esbuild";
2
+ import "child_process";
3
+ import "../dash-case-DMQMcCO6.js";
4
+ import "path";
5
+ import "fs";
6
+ import "fs/promises";
7
+ import "../parse-templates-DUUSaubj.js";
8
+ import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-BGaLvshf.js";
172
9
  export {
173
- E as compileSaltyFile,
174
- rt as generateCss,
175
- it as generateFile,
176
- Y as generateVariables,
177
- O as isSaltyFile,
178
- ot as logger,
179
- ct as minimizeFile
10
+ p as compileSaltyFile,
11
+ n as generateConfigStyles,
12
+ g as generateCss,
13
+ F as generateFile,
14
+ y as isSaltyFile,
15
+ x as minimizeFile,
16
+ S as saltyFileExtensions,
17
+ c as saltyFileRegExp
180
18
  };
@@ -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;
@@ -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"),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";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 o=(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){o(this,"_isProd");o(this,"_callerName");o(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:i=[]}=this.params,r={...t,variants:s,compoundVariants:i};return p.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 n;const c=(n=this.params.defaultVariants)==null?void 0:n[e];return c!==void 0?`${e}=${String(c)}`:e}):void 0,i=new Set([]),r=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return r&&r.forEach((e,c,n)=>{const h=n.at(1);h&&i.add(h)}),{element:t,variantKeys:s,propValueKeys:[...i],attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:i,prod:r}=t;return this._isProd=r,this._callerName=s,this}}exports.StyleComponentGenerator=g;
@@ -1,11 +1,17 @@
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
+ var p = Object.defineProperty;
2
+ var m = (e, t, s) => t in e ? p(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var n = (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 N {
4
7
  constructor(t, s) {
8
+ n(this, "_isProd");
9
+ n(this, "_callerName");
10
+ n(this, "_context");
5
11
  this.tagName = t, this.params = s;
6
12
  }
7
13
  get hash() {
8
- return i(this.params.base || this.params);
14
+ return l(this.params.base || this.params);
9
15
  }
10
16
  get priority() {
11
17
  var t;
@@ -23,30 +29,37 @@ class p {
23
29
  }
24
30
  get templateKeys() {
25
31
  var t;
26
- return (t = this._context) != null && t.config.templates ? n(this._context.config.templates) : [];
32
+ return (t = this._context) != null && t.config.templates ? g(this._context.config.templates) : [];
27
33
  }
28
34
  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);
35
+ var a;
36
+ const { base: t = {}, variants: s = {}, compoundVariants: i = [] } = this.params, r = { ...t, variants: s, compoundVariants: i };
37
+ return u(r, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
32
38
  }
33
39
  get props() {
34
40
  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 {
41
+ var o;
42
+ const c = (o = this.params.defaultVariants) == null ? void 0 : o[a];
43
+ return c !== void 0 ? `${a}=${String(c)}` : a;
44
+ }) : void 0, i = /* @__PURE__ */ new Set([]), r = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
45
+ return r && r.forEach((a, c, o) => {
46
+ const h = o.at(1);
47
+ h && i.add(h);
48
+ }), {
40
49
  element: t,
41
- variantKeys: s
50
+ variantKeys: s,
51
+ propValueKeys: [...i],
52
+ attr: {
53
+ "data-component-name": this._isProd ? void 0 : this._callerName
54
+ }
42
55
  };
43
56
  }
44
57
  _withBuildContext(t) {
45
58
  this._context = t;
46
- const { name: s, config: a } = t;
47
- return this._callerName = s, this;
59
+ const { name: s, config: i, prod: r } = t;
60
+ return this._isProd = r, this._callerName = s, this;
48
61
  }
49
62
  }
50
63
  export {
51
- p as StyleComponentGenerator
64
+ N as StyleComponentGenerator
52
65
  };
@@ -1,7 +1,16 @@
1
1
  import { StyledParams, Tag } from '../types';
2
+ export interface GeneratorProps {
3
+ element?: string;
4
+ variantKeys?: string[];
5
+ propValueKeys?: string[];
6
+ attr: {
7
+ [key: string]: any;
8
+ };
9
+ }
2
10
  export declare class StyleComponentGenerator {
3
11
  tagName: Tag<any>;
4
12
  params: StyledParams;
13
+ _isProd: boolean | undefined;
5
14
  _callerName: string | undefined;
6
15
  _context: {
7
16
  name: string;
@@ -15,12 +24,10 @@ export declare class StyleComponentGenerator {
15
24
  get cssDisplayNameVar(): string;
16
25
  get templateKeys(): string[];
17
26
  get css(): string;
18
- get props(): {
19
- element: string | undefined;
20
- variantKeys: string[] | undefined;
21
- };
27
+ get props(): GeneratorProps;
22
28
  _withBuildContext(context: {
23
29
  name: string;
24
30
  config: any;
31
+ prod: boolean;
25
32
  }): this;
26
33
  }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="/* Empty */";exports.default=e;
@@ -0,0 +1,232 @@
1
+ import * as H from "esbuild";
2
+ import { execSync as Q } from "child_process";
3
+ import { t as B, d as W } from "./dash-case-DMQMcCO6.js";
4
+ import { join as o } from "path";
5
+ import { existsSync as K, writeFileSync as w, mkdirSync as V, statSync as tt, readdirSync as st, readFileSync as v } from "fs";
6
+ import { readFile as et, writeFile as nt } from "fs/promises";
7
+ import { p as ot, a as rt, b as ct } from "./parse-templates-DUUSaubj.js";
8
+ import { createLogger as at, format as J, transports as it } from "winston";
9
+ const L = (t) => {
10
+ if (!t || t === "/") throw new Error("Could not find package.json file");
11
+ const s = o(t, "package.json");
12
+ return K(s) ? s : L(o(t, ".."));
13
+ }, lt = async (t) => {
14
+ const s = L(t);
15
+ return await et(s, "utf-8").then(JSON.parse).catch(() => {
16
+ });
17
+ }, pt = async (t) => {
18
+ const s = await lt(t);
19
+ if (s)
20
+ return s.type;
21
+ };
22
+ let M;
23
+ const q = async (t) => {
24
+ if (M) return M;
25
+ const s = await pt(t);
26
+ return s === "module" ? M = "esm" : (s === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
27
+ }, R = at({
28
+ level: "debug",
29
+ format: J.combine(J.colorize(), J.cli()),
30
+ transports: [new it.Console({})]
31
+ }), Ct = (t) => {
32
+ R.error(t);
33
+ }, O = {
34
+ externalModules: []
35
+ }, A = (t) => {
36
+ if (O.externalModules.length > 0) return O.externalModules;
37
+ const s = o(t, "salty.config.ts"), e = v(s, "utf8").match(/externalModules:\s?\[(.*)\]/);
38
+ if (!e) return [];
39
+ const n = e[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
40
+ return O.externalModules = n, n;
41
+ }, N = (t) => o(t, "./saltygen"), ft = ["salty", "css", "styles", "styled"], ut = (t = []) => new RegExp(`\\.(${[...ft, ...t].join("|")})\\.`), I = (t, s = []) => ut(s).test(t), gt = async (t) => {
42
+ const s = N(t), i = o(t, "salty.config.ts"), e = o(s, "salty.config.js"), n = await q(t), l = A(t);
43
+ await H.build({
44
+ entryPoints: [i],
45
+ minify: !0,
46
+ treeShaking: !0,
47
+ bundle: !0,
48
+ outfile: e,
49
+ format: n,
50
+ external: l
51
+ });
52
+ const S = Date.now(), { config: f } = await import(`${e}?t=${S}`);
53
+ return f;
54
+ }, dt = async (t) => {
55
+ const s = await gt(t), i = /* @__PURE__ */ new Set(), e = (u, a = []) => u ? Object.entries(u).flatMap(([m, p]) => {
56
+ if (!p) return;
57
+ if (typeof p == "object") return e(p, [...a, m]);
58
+ const P = [...a, m].join(".");
59
+ i.add(`"${P}"`);
60
+ const x = [...a.map(W), W(m)].join("-"), { result: y } = ct(p);
61
+ return `--${x}: ${y};`;
62
+ }) : [], n = (u) => u ? Object.entries(u).flatMap(([a, m]) => {
63
+ const p = e(m);
64
+ return a === "base" ? p.join("") : `${a} { ${p.join("")} }`;
65
+ }) : [], l = (u) => u ? Object.entries(u).flatMap(([a, m]) => Object.entries(m).flatMap(([p, P]) => {
66
+ const x = e(P, [a]), y = `.${a}-${p}, [data-${a}="${p}"]`, b = x.join("");
67
+ return `${y} { ${b} }`;
68
+ })) : [], S = e(s.variables), f = n(s.responsiveVariables), C = l(s.conditionalVariables), r = N(t), T = o(r, "css/variables.css"), g = `:root { ${S.join("")} ${f.join("")} } ${C.join("")}`;
69
+ w(T, g);
70
+ const h = o(r, "types/css-tokens.d.ts"), c = `type VariableTokens = ${[...i].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
71
+ w(h, c);
72
+ const d = o(r, "css/global.css"), k = ot(s.global, "");
73
+ w(d, k);
74
+ const $ = o(r, "css/templates.css"), j = rt(s.templates);
75
+ w($, j);
76
+ }, _ = async (t, s, i) => {
77
+ const e = B(s), n = o(i, "js", e + ".js"), l = await q(t), S = A(t);
78
+ await H.build({
79
+ entryPoints: [s],
80
+ minify: !0,
81
+ treeShaking: !0,
82
+ bundle: !0,
83
+ outfile: n,
84
+ format: l,
85
+ target: ["es2022"],
86
+ keepNames: !0,
87
+ external: S
88
+ });
89
+ const f = Date.now();
90
+ return await import(`${n}?t=${f}`);
91
+ }, z = async (t) => {
92
+ const s = N(t), i = o(s, "salty.config.js"), { config: e } = await import(i);
93
+ return e;
94
+ }, U = () => {
95
+ try {
96
+ return process.env.NODE_ENV === "production";
97
+ } catch {
98
+ return !1;
99
+ }
100
+ }, Ft = async (t, s = U()) => {
101
+ try {
102
+ s ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
103
+ const i = [], e = [], n = N(t), l = o(n, "index.css");
104
+ (() => {
105
+ K(n) && Q("rm -rf " + n), V(n), V(o(n, "css")), V(o(n, "types"));
106
+ })(), await dt(t);
107
+ const f = await z(t);
108
+ async function C(c, d) {
109
+ const k = ["node_modules", "saltygen"], $ = tt(c);
110
+ if ($.isDirectory()) {
111
+ const j = st(c);
112
+ if (k.some((a) => c.includes(a))) return;
113
+ await Promise.all(j.map((a) => C(o(c, a), o(d, a))));
114
+ } else if ($.isFile() && I(c)) {
115
+ const u = await _(t, c, n), a = [];
116
+ Object.entries(u).forEach(([x, y]) => {
117
+ if (y.isKeyframes && y.css) {
118
+ const G = `${y.animationName}.css`, Y = `css/${G}`, Z = o(n, Y);
119
+ i.push(G), w(Z, y.css);
120
+ return;
121
+ }
122
+ if (!y.generator) return;
123
+ const b = y.generator._withBuildContext({
124
+ name: x,
125
+ config: f,
126
+ prod: s
127
+ }), D = `${b.hash}-${b.priority}.css`;
128
+ e[b.priority] || (e[b.priority] = []), e[b.priority].push(D), a.push(D);
129
+ const E = `css/${D}`, X = o(n, E);
130
+ w(X, b.css);
131
+ });
132
+ const m = a.map((x) => `@import url('./${x}');`).join(`
133
+ `), p = B(c, 6), P = o(n, `css/${p}.css`);
134
+ w(P, m);
135
+ }
136
+ }
137
+ await C(t, n);
138
+ const r = i.map((c) => `@import url('./css/${c}');`).join(`
139
+ `);
140
+ let F = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
141
+
142
+ ${["variables.css", "global.css", "templates.css"].filter((c) => {
143
+ try {
144
+ return v(o(n, "css", c), "utf8").length > 0;
145
+ } catch {
146
+ return !1;
147
+ }
148
+ }).map((c) => `@import url('./css/${c}');`).join(`
149
+ `)}
150
+ ${r}`;
151
+ if (f.importStrategy !== "component") {
152
+ const c = e.flat().map((d) => `@import url('./css/${d}');`).join(`
153
+ `);
154
+ F += c;
155
+ }
156
+ w(l, F);
157
+ } catch (i) {
158
+ console.error(i);
159
+ }
160
+ }, jt = async (t, s) => {
161
+ try {
162
+ const i = [], e = o(t, "./saltygen"), n = o(e, "index.css");
163
+ if (I(s)) {
164
+ const S = await z(t), f = await _(t, s, e);
165
+ Object.entries(f).forEach(([h, F]) => {
166
+ if (!F.generator) return;
167
+ const c = F.generator._withBuildContext({
168
+ name: h,
169
+ config: S
170
+ }), d = `${c.hash}-${c.priority}.css`, k = `css/${d}`, $ = o(e, k);
171
+ i.push(d), w($, c.css);
172
+ });
173
+ const C = v(n, "utf8").split(`
174
+ `), r = i.map((h) => `@import url('../saltygen/css/${h}');`), g = [.../* @__PURE__ */ new Set([...C, ...r])].join(`
175
+ `);
176
+ w(n, g);
177
+ }
178
+ } catch (i) {
179
+ console.error(i);
180
+ }
181
+ }, xt = async (t, s, i = U()) => {
182
+ try {
183
+ const e = o(t, "./saltygen");
184
+ if (I(s)) {
185
+ const l = v(s, "utf8");
186
+ l.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== l && await nt(s, l);
187
+ const f = await z(t), C = await _(t, s, e);
188
+ let r = l;
189
+ Object.entries(C).forEach(([g, h]) => {
190
+ var D;
191
+ if (h.isKeyframes || !h.generator) return;
192
+ const F = h.generator._withBuildContext({
193
+ name: g,
194
+ config: f,
195
+ prod: i
196
+ }), c = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
197
+ if (!c) return console.error("Could not find the original declaration");
198
+ const d = (D = c.at(1)) == null ? void 0 : D.trim(), k = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(r);
199
+ if (!k) return console.error("Could not find the original declaration");
200
+ const { index: $ } = k;
201
+ let j = !1;
202
+ const u = setTimeout(() => j = !0, 5e3);
203
+ let a = 0, m = !1, p = 0;
204
+ for (; !m && !j; ) {
205
+ const E = r[$ + a];
206
+ E === "(" && p++, E === ")" && p--, p === 0 && E === ")" && (m = !0), a > r.length && (j = !0), a++;
207
+ }
208
+ if (!j) clearTimeout(u);
209
+ else throw new Error("Failed to find the end of the styled call and timed out");
210
+ const P = $ + a, x = r.slice($, P), y = r, b = ` ${g} = styled(${d}, "${F.classNames}", ${JSON.stringify(F.props)});`;
211
+ r = r.replace(x, b), y === r && console.error("Minimize file failed to change content", { name: g, tagName: d });
212
+ });
213
+ const T = B(s, 6);
214
+ return f.importStrategy === "component" && (r = `import '../../saltygen/css/${T}.css';
215
+ ${r}`), r = r.replace("{ styled }", "{ styledClient as styled }"), r = r.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), r;
216
+ }
217
+ } catch (e) {
218
+ console.error("Error in minimizeFile:", e);
219
+ }
220
+ };
221
+ export {
222
+ Ct as a,
223
+ ut as b,
224
+ dt as c,
225
+ _ as d,
226
+ jt as e,
227
+ Ft as g,
228
+ I as i,
229
+ R as l,
230
+ xt as m,
231
+ ft as s
232
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";const te=require("esbuild"),se=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),i=require("path"),l=require("fs"),H=require("fs/promises"),J=require("./parse-templates-DVK3iZIl.cjs"),v=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return l.existsSync(t)?t:G(i.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let T;const L=async e=>{if(T)return T;const t=await ie(e);return t==="module"?T="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-BKoD9apd.cjs",document.baseURI).href).endsWith(".cjs"))&&(T="cjs"),T||"esm"},O=v.createLogger({level:"debug",format:v.format.combine(v.format.colorize(),v.format.cli()),transports:[new v.transports.Console({})]}),re=e=>{O.error(e)},I={externalModules:[]},W=e=>{if(I.externalModules.length>0)return I.externalModules;const t=i.join(e,"salty.config.ts"),s=l.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const o=s[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return I.externalModules=o,o},V=e=>i.join(e,"./saltygen"),K=["salty","css","styles","styled"],A=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),R=(e,t=[])=>A(t).test(e),ce=async e=>{const t=V(e),n=i.join(e,"salty.config.ts"),s=i.join(t,"salty.config.js"),o=await L(e),u=W(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:o,external:u});const b=Date.now(),{config:p}=await import(`${s}?t=${b}`);return p},X=async e=>{const t=await ce(e),n=new Set,s=(g,a=[])=>g?Object.entries(g).flatMap(([m,f])=>{if(!f)return;if(typeof f=="object")return s(f,[...a,m]);const P=[...a,m].join(".");n.add(`"${P}"`);const x=[...a.map(N.dashCase),N.dashCase(m)].join("-"),{result:h}=J.parseValueTokens(f);return`--${x}: ${h};`}):[],o=g=>g?Object.entries(g).flatMap(([a,m])=>{const f=s(m);return a==="base"?f.join(""):`${a} { ${f.join("")} }`}):[],u=g=>g?Object.entries(g).flatMap(([a,m])=>Object.entries(m).flatMap(([f,P])=>{const x=s(P,[a]),h=`.${a}-${f}, [data-${a}="${f}"]`,w=x.join("");return`${h} { ${w} }`})):[],b=s(t.variables),p=o(t.responsiveVariables),F=u(t.conditionalVariables),r=V(e),E=i.join(r,"css/variables.css"),d=`:root { ${b.join("")} ${p.join("")} } ${F.join("")}`;l.writeFileSync(E,d);const j=i.join(r,"types/css-tokens.d.ts"),c=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;l.writeFileSync(j,c);const y=i.join(r,"css/global.css"),k=J.parseStyles(t.global,"");l.writeFileSync(y,k);const S=i.join(r,"css/templates.css"),C=J.parseTemplates(t.templates);l.writeFileSync(S,C)},_=async(e,t,n)=>{const s=N.toHash(t),o=i.join(n,"js",s+".js"),u=await L(e),b=W(e);await U.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:u,target:["es2022"],keepNames:!0,external:b});const p=Date.now();return await import(`${o}?t=${p}`)},z=async e=>{const t=V(e),n=i.join(t,"salty.config.js"),{config:s}=await import(n);return s},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=Y())=>{try{t?O.info("Generating CSS in production mode! 🔥"):O.info("Generating CSS in development mode! 🚀");const n=[],s=[],o=V(e),u=i.join(o,"index.css");(()=>{l.existsSync(o)&&se.execSync("rm -rf "+o),l.mkdirSync(o),l.mkdirSync(i.join(o,"css")),l.mkdirSync(i.join(o,"types"))})(),await X(e);const p=await z(e);async function F(c,y){const k=["node_modules","saltygen"],S=l.statSync(c);if(S.isDirectory()){const C=l.readdirSync(c);if(k.some(a=>c.includes(a)))return;await Promise.all(C.map(a=>F(i.join(c,a),i.join(y,a))))}else if(S.isFile()&&R(c)){const g=await _(e,c,o),a=[];Object.entries(g).forEach(([x,h])=>{if(h.isKeyframes&&h.css){const B=`${h.animationName}.css`,Q=`css/${B}`,ee=i.join(o,Q);n.push(B),l.writeFileSync(ee,h.css);return}if(!h.generator)return;const w=h.generator._withBuildContext({name:x,config:p,prod:t}),D=`${w.hash}-${w.priority}.css`;s[w.priority]||(s[w.priority]=[]),s[w.priority].push(D),a.push(D);const M=`css/${D}`,Z=i.join(o,M);l.writeFileSync(Z,w.css)});const m=a.map(x=>`@import url('./${x}');`).join(`
2
+ `),f=N.toHash(c,6),P=i.join(o,`css/${f}.css`);l.writeFileSync(P,m)}}await F(e,o);const r=n.map(c=>`@import url('./css/${c}');`).join(`
3
+ `);let $=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
4
+
5
+ ${["variables.css","global.css","templates.css"].filter(c=>{try{return l.readFileSync(i.join(o,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
6
+ `)}
7
+ ${r}`;if(p.importStrategy!=="component"){const c=s.flat().map(y=>`@import url('./css/${y}');`).join(`
8
+ `);$+=c}l.writeFileSync(u,$)}catch(n){console.error(n)}},le=async(e,t)=>{try{const n=[],s=i.join(e,"./saltygen"),o=i.join(s,"index.css");if(R(t)){const b=await z(e),p=await _(e,t,s);Object.entries(p).forEach(([j,$])=>{if(!$.generator)return;const c=$.generator._withBuildContext({name:j,config:b}),y=`${c.hash}-${c.priority}.css`,k=`css/${y}`,S=i.join(s,k);n.push(y),l.writeFileSync(S,c.css)});const F=l.readFileSync(o,"utf8").split(`
9
+ `),r=n.map(j=>`@import url('../saltygen/css/${j}');`),d=[...new Set([...F,...r])].join(`
10
+ `);l.writeFileSync(o,d)}}catch(n){console.error(n)}},ue=async(e,t,n=Y())=>{try{const s=i.join(e,"./saltygen");if(R(t)){const u=l.readFileSync(t,"utf8");u.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==u&&await H.writeFile(t,u);const p=await z(e),F=await _(e,t,s);let r=u;Object.entries(F).forEach(([d,j])=>{var D;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:d,config:p,prod:n}),c=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(u);if(!c)return console.error("Could not find the original declaration");const y=(D=c.at(1))==null?void 0:D.trim(),k=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(r);if(!k)return console.error("Could not find the original declaration");const{index:S}=k;let C=!1;const g=setTimeout(()=>C=!0,5e3);let a=0,m=!1,f=0;for(;!m&&!C;){const M=r[S+a];M==="("&&f++,M===")"&&f--,f===0&&M===")"&&(m=!0),a>r.length&&(C=!0),a++}if(!C)clearTimeout(g);else throw new Error("Failed to find the end of the styled call and timed out");const P=S+a,x=r.slice(S,P),h=r,w=` ${d} = styled(${y}, "${$.classNames}", ${JSON.stringify($.props)});`;r=r.replace(x,w),h===r&&console.error("Minimize file failed to change content",{name:d,tagName:y})});const E=N.toHash(t,6);return p.importStrategy==="component"&&(r=`import '../../saltygen/css/${E}.css';
11
+ ${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(s){console.error("Error in minimizeFile:",s)}};exports.compileSaltyFile=_;exports.generateConfigStyles=X;exports.generateCss=ae;exports.generateFile=le;exports.isSaltyFile=R;exports.logError=re;exports.logger=O;exports.minimizeFile=ue;exports.saltyFileExtensions=K;exports.saltyFileRegExp=A;
@@ -0,0 +1,4 @@
1
+ const t = "/* Empty */";
2
+ export {
3
+ t as default
4
+ };