@salty-css/core 0.0.1-alpha.3 → 0.0.1-alpha.30

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 (63) hide show
  1. package/README.md +23 -19
  2. package/bin/bin-util.d.ts +2 -0
  3. package/bin/index.cjs +2 -0
  4. package/bin/index.d.ts +2 -0
  5. package/bin/index.js +3 -0
  6. package/bin/logger.d.ts +2 -0
  7. package/bin/main.cjs +8 -0
  8. package/bin/main.d.ts +1 -0
  9. package/bin/main.js +141 -0
  10. package/bin/prettier.d.ts +1 -0
  11. package/compiler/index.cjs +11 -0
  12. package/{dist/compiler → compiler}/index.d.ts +4 -4
  13. package/compiler/index.js +174 -0
  14. package/{dist/config → config}/config-types.d.ts +3 -3
  15. package/dash-case-DKzpenwY.cjs +1 -0
  16. package/{dist/util/index.js → dash-case-DMQMcCO6.js} +5 -5
  17. package/generator/index.cjs +1 -0
  18. package/generator/index.js +61 -0
  19. package/{dist/generator → generator}/style-generator.d.ts +9 -8
  20. package/index-84Wroia-.cjs +1 -0
  21. package/index-D_732b92.js +4 -0
  22. package/package.json +39 -20
  23. package/{dist/parse-templates-BOSK0Tb6.js → parse-templates-D4p3pgQR.js} +26 -24
  24. package/parse-templates-W0YfTmOT.cjs +8 -0
  25. package/pascal-case-BQpR5PdN.js +6 -0
  26. package/pascal-case-iWoaJWwT.cjs +1 -0
  27. package/react-styled-file-CGVf5n1B.js +11 -0
  28. package/react-styled-file-Dkubsz-U.cjs +8 -0
  29. package/salty.config-BupieCfE.cjs +6 -0
  30. package/salty.config-D9ANEDiH.js +9 -0
  31. package/{dist/types → types}/index.d.ts +7 -2
  32. package/util/camel-case.d.ts +1 -0
  33. package/util/index.cjs +1 -0
  34. package/util/index.d.ts +4 -0
  35. package/util/index.js +11 -0
  36. package/util/pascal-case.d.ts +1 -0
  37. package/dist/README.md +0 -107
  38. package/dist/compiler/index.cjs +0 -11
  39. package/dist/compiler/index.js +0 -180
  40. package/dist/generator/index.cjs +0 -1
  41. package/dist/generator/index.js +0 -51
  42. package/dist/package.json +0 -50
  43. package/dist/parse-templates-BY1Xai-_.cjs +0 -8
  44. package/dist/util/index.cjs +0 -1
  45. package/dist/util/index.d.ts +0 -2
  46. /package/{dist/config → config}/define-config.d.ts +0 -0
  47. /package/{dist/config → config}/index.cjs +0 -0
  48. /package/{dist/config → config}/index.d.ts +0 -0
  49. /package/{dist/config → config}/index.js +0 -0
  50. /package/{dist/css → css}/index.cjs +0 -0
  51. /package/{dist/css → css}/index.d.ts +0 -0
  52. /package/{dist/css → css}/index.js +0 -0
  53. /package/{dist/generator → generator}/index.d.ts +0 -0
  54. /package/{dist/generator → generator}/parse-modifiers.d.ts +0 -0
  55. /package/{dist/generator → generator}/parse-styles.d.ts +0 -0
  56. /package/{dist/generator → generator}/parse-templates.d.ts +0 -0
  57. /package/{dist/generator → generator}/parse-tokens.d.ts +0 -0
  58. /package/{dist/generator → generator}/parser-types.d.ts +0 -0
  59. /package/{dist/types → types}/index.cjs +0 -0
  60. /package/{dist/types → types}/index.js +0 -0
  61. /package/{dist/types → types}/util-types.d.ts +0 -0
  62. /package/{dist/util → util}/dash-case.d.ts +0 -0
  63. /package/{dist/util → util}/to-hash.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.30",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -15,36 +15,55 @@
15
15
  "url": "https://github.com/margarita-form/salty-css/issues"
16
16
  },
17
17
  "files": [
18
- "dist",
18
+ "**/*",
19
19
  "!**/*.tsbuildinfo"
20
20
  ],
21
21
  "nx": {
22
+ "sourceRoot": "libs/core/src",
22
23
  "name": "core"
23
24
  },
25
+ "peerDependencies": {
26
+ "commander": ">=12.x",
27
+ "ejs": ">=3.x",
28
+ "esbuild": ">=0.21.x",
29
+ "ora": ">=8.x",
30
+ "react": ">=18.x || >=19.x",
31
+ "winston": ">=3.x"
32
+ },
24
33
  "exports": {
25
- ".": {
26
- "import": "./index.js",
27
- "require": "./index.cjs"
34
+ "./bin/main": {
35
+ "import": "./bin/main.js",
36
+ "require": "./bin/main.cjs"
37
+ },
38
+ "./compiler": {
39
+ "import": "./compiler/index.js",
40
+ "require": "./compiler/index.cjs"
28
41
  },
29
- "./react/styled": {
30
- "import": "./react/styled.js",
31
- "require": "./react/styled.cjs"
42
+ "./css": {
43
+ "import": "./css/index.js",
44
+ "require": "./css/index.cjs"
32
45
  },
33
- "./react/styled-client": {
34
- "import": "./react/styled-client.js",
35
- "require": "./react/styled-client.cjs"
46
+ "./generator": {
47
+ "import": "./generator/index.js",
48
+ "require": "./generator/index.cjs"
36
49
  },
37
- "./react/css-helpers": {
38
- "import": "./react/css-helpers.js",
39
- "require": "./react/css-helpers.cjs"
50
+ "./config": {
51
+ "import": "./config/index.js",
52
+ "require": "./config/index.cjs"
40
53
  },
41
- "./vite": {
42
- "import": "./vite/index.js",
43
- "require": "./vite/index.cjs"
54
+ "./types": {
55
+ "import": "./types/index.js",
56
+ "require": "./types/index.cjs"
44
57
  },
45
- "./webpack/salty-loader": {
46
- "import": "./webpack/salty-loader.js",
47
- "require": "./webpack/salty-loader.cjs"
58
+ "./util": {
59
+ "import": "./util/index.js",
60
+ "require": "./util/index.cjs"
48
61
  }
62
+ },
63
+ "bin": {
64
+ "salty": "./bin/index.js",
65
+ "salty-css": "./bin/index.js",
66
+ "salty-css-cjs": "./bin/index.cjs",
67
+ "@salty-css/core": "./bin/index.js"
49
68
  }
50
69
  }
@@ -1,22 +1,23 @@
1
- import { dashCase as O } from "./util/index.js";
2
- const N = (s, r) => {
3
- if (typeof s != "string") return { result: s };
4
- if (!r) return { result: s };
1
+ import { d as O } from "./dash-case-DMQMcCO6.js";
2
+ const N = (t, r) => {
3
+ if (typeof t != "string") return { result: t };
4
+ if (!r) return { result: t };
5
5
  const e = [];
6
6
  return Object.values(r).forEach((n) => {
7
7
  const { pattern: o, transform: c } = n;
8
- s = s.replace(o, (h) => {
8
+ t = t.replace(o, (h) => {
9
9
  const { value: i, css: m } = c(h);
10
10
  return m && e.push(m), i;
11
11
  });
12
- }), { result: s, additionalCss: e };
13
- }, P = (s) => typeof s != "string" ? { result: s } : /\{[^{}]+\}/g.test(s) ? { result: s.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: s }, d = (s, r, e, n) => {
14
- const o = [], c = Object.entries(s).reduce((i, [m, t]) => {
12
+ }), { result: t, additionalCss: e };
13
+ }, P = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: t }, d = (t, r, e, n) => {
14
+ if (!t) return "";
15
+ const o = [], c = Object.entries(t).reduce((i, [m, s]) => {
15
16
  const p = m.trim();
16
- if (typeof t == "function" && (t = t()), typeof t == "object") {
17
- if (!t) return i;
17
+ if (typeof s == "function" && (s = s()), typeof s == "object") {
18
+ if (!s) return i;
18
19
  if (p === "variants")
19
- return Object.entries(t).forEach(([u, f]) => {
20
+ return Object.entries(s).forEach(([u, f]) => {
20
21
  f && Object.entries(f).forEach(([b, j]) => {
21
22
  if (!j) return;
22
23
  const l = `${r}.${u}-${b}`, y = d(j, l, e);
@@ -26,39 +27,39 @@ const N = (s, r) => {
26
27
  if (p === "defaultVariants")
27
28
  return i;
28
29
  if (p === "compoundVariants")
29
- return t.forEach((u) => {
30
+ return s.forEach((u) => {
30
31
  const { css: f, ...b } = u, j = Object.entries(b).reduce((y, [V, W]) => `${y}.${V}-${W}`, r), l = d(f, j, e);
31
32
  o.push(l);
32
33
  }), i;
33
34
  if (p.startsWith("@")) {
34
- const u = d(t, r, e), f = `${p} {
35
+ const u = d(s, r, e), f = `${p} {
35
36
  ${u.replace(`
36
37
  `, `
37
38
  `)}
38
39
  }`;
39
40
  return o.push(f), i;
40
41
  }
41
- const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(t, $, e);
42
+ const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(s, $, e);
42
43
  return o.push(a), i;
43
44
  }
44
45
  if (n != null && n.templates && n.templates[p]) {
45
- const a = t.split(".").reduce((f, b) => f[b], n.templates[p]), u = d(a, "");
46
+ const a = s.split(".").reduce((f, b) => f[b], n.templates[p]), u = d(a, "");
46
47
  return `${i}${u}`;
47
48
  }
48
49
  const g = p.startsWith("-") ? p : O(p), E = ($, a = ";") => i = `${i}${$}${a}`, S = ($) => E(`${g}:${$}`);
49
- if (typeof t == "number") return S(t);
50
- if (typeof t != "string")
51
- if ("toString" in t) t = t.toString();
50
+ if (typeof s == "number") return S(s);
51
+ if (typeof s != "string")
52
+ if ("toString" in s) s = s.toString();
52
53
  else return i;
53
54
  const { modifiers: k } = n || {}, T = function* () {
54
- yield P(t), yield N(t, k);
55
+ yield P(s), yield N(s, k);
55
56
  }();
56
57
  for (const { result: $, additionalCss: a = [] } of T)
57
- t = $, a.forEach((u) => {
58
+ s = $, a.forEach((u) => {
58
59
  const f = d(u, "");
59
60
  E(f, "");
60
61
  });
61
- return S(t);
62
+ return S(s);
62
63
  }, "");
63
64
  if (!c) return o.join(`
64
65
  `);
@@ -66,9 +67,10 @@ const N = (s, r) => {
66
67
  let h = "";
67
68
  return e !== void 0 ? h = `@layer l${e} { ${r} { ${c} } }` : h = `${r} { ${c} }`, [h, ...o].join(`
68
69
  `);
69
- }, _ = (s, r = []) => {
70
+ }, _ = (t, r = []) => {
71
+ if (!t) return "";
70
72
  const e = [], n = {};
71
- if (Object.entries(s).forEach(([o, c]) => {
73
+ if (Object.entries(t).forEach(([o, c]) => {
72
74
  if (typeof c == "object") {
73
75
  if (!c) return;
74
76
  const h = o.trim(), i = _(c, [...r, h]);
@@ -81,7 +83,7 @@ const N = (s, r) => {
81
83
  }
82
84
  return e.join(`
83
85
  `);
84
- }, A = (s) => Object.keys(s);
86
+ }, A = (t) => Object.keys(t);
85
87
  export {
86
88
  _ as a,
87
89
  P as b,
@@ -0,0 +1,8 @@
1
+ "use strict";const O=require("./dash-case-DKzpenwY.cjs"),N=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:c}=n;t=t.replace(o,a=>{const{value:i,css:l}=c(a);return l&&r.push(l),i})}),{result:t,additionalCss:r}},k=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},h=(t,e,r,n)=>{if(!t)return"";const o=[],c=Object.entries(t).reduce((i,[l,s])=>{const p=l.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return i;if(p==="variants")return Object.entries(s).forEach(([u,f])=>{f&&Object.entries(f).forEach(([m,j])=>{if(!j)return;const y=`${e}.${u}-${m}`,b=h(j,y,r);o.push(b)})}),i;if(p==="defaultVariants")return i;if(p==="compoundVariants")return s.forEach(u=>{const{css:f,...m}=u,j=Object.entries(m).reduce((b,[q,K])=>`${b}.${q}-${K}`,e),y=h(f,j,r);o.push(y)}),i;if(p.startsWith("@")){const u=h(s,e,r),f=`${p} {
2
+ ${u.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return o.push(f),i}const $=l.includes("&")?p.replace("&",e):p.startsWith(":")?`${e}${p}`:`${e} ${p}`,d=h(s,$,r);return o.push(d),i}if(n!=null&&n.templates&&n.templates[p]){const d=s.split(".").reduce((f,m)=>f[m],n.templates[p]),u=h(d,"");return`${i}${u}`}const V=p.startsWith("-")?p:O.dashCase(p),T=($,d=";")=>i=`${i}${$}${d}`,S=$=>T(`${V}:${$}`);if(typeof s=="number")return S(s);if(typeof s!="string")if("toString"in s)s=s.toString();else return i;const{modifiers:g}=n||{},W=function*(){yield k(s),yield N(s,g)}();for(const{result:$,additionalCss:d=[]}of W)s=$,d.forEach(u=>{const f=h(u,"");T(f,"")});return S(s)},"");if(!c)return o.join(`
6
+ `);if(!e)return c;let a="";return r!==void 0?a=`@layer l${r} { ${e} { ${c} } }`:a=`${e} { ${c} }`,[a,...o].join(`
7
+ `)},E=(t,e=[])=>{if(!t)return"";const r=[],n={};if(Object.entries(t).forEach(([o,c])=>{if(typeof c=="object"){if(!c)return;const a=o.trim(),i=E(c,[...e,a]);r.push(i)}else n[o]=c}),Object.keys(n).length){const o=e.map(O.dashCase).join("-"),c=h(n,`.${o}`);r.push(c)}return r.join(`
8
+ `)},P=t=>Object.keys(t);exports.getTemplateKeys=P;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=k;
@@ -0,0 +1,6 @@
1
+ function p(e) {
2
+ return e ? typeof e != "string" ? p(String(e)) : e.replace(/\s/g, "-").replace(/[-_]([a-z0-9])/g, (a) => a[1].toUpperCase()).replace(/^[a-z]/, (a) => a.toUpperCase()) : "";
3
+ }
4
+ export {
5
+ p
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";function r(e){return e?typeof e!="string"?r(String(e)):e.replace(/\s/g,"-").replace(/[-_]([a-z0-9])/g,a=>a[1].toUpperCase()).replace(/^[a-z]/,a=>a.toUpperCase()):""}exports.pascalCase=r;
@@ -0,0 +1,11 @@
1
+ const e = `import { styled } from "@salty-css/react/styled";
2
+
3
+ export const <%- name %> = styled('<%- tag %>', {
4
+ <% if(className) { %>className: '<%- className %>',<% } %>
5
+ base: {
6
+ // Add your styles here
7
+ }
8
+ })`;
9
+ export {
10
+ e as default
11
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { styled } from "@salty-css/react/styled";
2
+
3
+ export const <%- name %> = styled('<%- tag %>', {
4
+ <% if(className) { %>className: '<%- className %>',<% } %>
5
+ base: {
6
+ // Add your styles here
7
+ }
8
+ })`;exports.default=e;
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=`import { defineConfig } from '@salty-css/core/config';
2
+
3
+ export const config = defineConfig({
4
+ // Add your custom config here
5
+ });
6
+ `;exports.default=o;
@@ -0,0 +1,9 @@
1
+ const n = `import { defineConfig } from '@salty-css/core/config';
2
+
3
+ export const config = defineConfig({
4
+ // Add your custom config here
5
+ });
6
+ `;
7
+ export {
8
+ n as default
9
+ };
@@ -7,6 +7,7 @@ export type CreateElementProps = {
7
7
  className?: string;
8
8
  element?: string;
9
9
  passVariantProps?: boolean;
10
+ style?: any;
10
11
  /** vks = Variant key set */
11
12
  _vks?: Set<string>;
12
13
  };
@@ -38,9 +39,13 @@ type Variants = {
38
39
  compoundVariants?: CompoundVariant[];
39
40
  };
40
41
  type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
41
- export type VariantProps<STYLES extends Styles> = STYLES['variants'] extends undefined ? {} : {
42
+ export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? object : {
42
43
  [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
43
44
  };
45
+ type CssValuePropKey = `props-${string}`;
46
+ export type ValueProps = {
47
+ [key: CssValuePropKey]: string;
48
+ };
44
49
  export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
45
50
  type StylePropertyValue = Record<never, never> & unknown;
46
51
  export type CssStyles = {
@@ -53,6 +58,6 @@ export interface GeneratorOptions {
53
58
  element?: string;
54
59
  }
55
60
  export interface StyledParams extends GeneratorOptions, Variants {
56
- base: CssStyles;
61
+ base?: CssStyles;
57
62
  }
58
63
  export {};
@@ -0,0 +1 @@
1
+ export declare function camelCase(str: PropertyKey): string;
package/util/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-DKzpenwY.cjs"),t=require("../pascal-case-iWoaJWwT.cjs");function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/-([a-z])/g,r=>r[1].toUpperCase()):""}exports.dashCase=a.dashCase;exports.toHash=a.toHash;exports.pascalCase=t.pascalCase;exports.camelCase=s;
@@ -0,0 +1,4 @@
1
+ export * from './camel-case';
2
+ export * from './dash-case';
3
+ export * from './pascal-case';
4
+ export * from './to-hash';
package/util/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { d as o, t as s } from "../dash-case-DMQMcCO6.js";
2
+ import { p as f } from "../pascal-case-BQpR5PdN.js";
3
+ function r(e) {
4
+ return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
5
+ }
6
+ export {
7
+ r as camelCase,
8
+ o as dashCase,
9
+ f as pascalCase,
10
+ s as toHash
11
+ };
@@ -0,0 +1 @@
1
+ export declare function pascalCase(str: PropertyKey): string;
package/dist/README.md DELETED
@@ -1,107 +0,0 @@
1
- # Salty Css
2
-
3
- ## Basic usage example with Button
4
-
5
- ### Initial requirements
6
-
7
- 1. Add `saltyPlugin` to vite or webpack config from `@salty-css/vite` or `@salty-css/webpack`
8
- 2. Create `salty-config.ts` to the root of your project
9
- 3. Import global styles to any regular .css file from `saltygen/index.css` (does not exist during first run, cli command coming later)
10
- 4. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
11
-
12
- ### Code examples
13
-
14
- **Salty config**
15
-
16
- ```tsx
17
- import { defineConfig } from '@salty-css/core/config';
18
-
19
- export const config = defineConfig({
20
- variables: {
21
- colors: {
22
- brand: '#111',
23
- highlight: 'yellow',
24
- },
25
- },
26
- global: {
27
- html: {
28
- backgroundColor: '#f8f8f8',
29
- },
30
- },
31
- });
32
- ```
33
-
34
- **Your React component file**
35
-
36
- ```tsx
37
- import { Wrapper } from '../components/wrapper/wrapper.css';
38
- import { Button } from '../components/button/button.css';
39
-
40
- export const IndexPage = () => {
41
- return (
42
- <Wrapper>
43
- <Button variant="solid" onClick={() => alert('It is a button.')}>
44
- Outlined
45
- </Button>
46
- </Wrapper>
47
- );
48
- };
49
- ```
50
-
51
- **Wrapper** (`components/wrapper/wrapper.css.ts`)
52
-
53
- ```tsx
54
- import { styled } from '@salty-css/react/styled';
55
-
56
- export const Wrapper = styled('div', {
57
- display: 'block',
58
- padding: '2vw',
59
- });
60
- ```
61
-
62
- **Button** (`components/button/button.css.ts`)
63
-
64
- ```tsx
65
- import { styled } from '@salty-css/react/styled';
66
-
67
- export const Button = styled('button', {
68
- display: 'block',
69
- padding: `0.6em 1.2em`,
70
- border: '1px solid currentColor',
71
- background: 'transparent',
72
- color: 'currentColor/40',
73
- cursor: 'pointer',
74
- transition: '200ms',
75
- textDecoration: 'none',
76
- '&:hover': {
77
- background: 'black',
78
- borderColor: 'black',
79
- color: 'white',
80
- },
81
- '&:disabled': {
82
- opacity: 0.25,
83
- pointerEvents: 'none',
84
- },
85
- variants: {
86
- variant: {
87
- outlined: {
88
- // same as default styles
89
- },
90
- solid: {
91
- '&:not(:hover)': {
92
- background: 'black',
93
- borderColor: 'black',
94
- color: 'white',
95
- },
96
- '&:hover': {
97
- background: 'transparent',
98
- borderColor: 'currentColor',
99
- color: 'currentColor',
100
- },
101
- },
102
- },
103
- },
104
- });
105
- ```
106
-
107
- More examples coming soon
@@ -1,11 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("esbuild"),B=require("winston"),K=require("child_process"),N=require("../util/index.cjs"),o=require("path"),r=require("fs"),J=require("fs/promises"),_=require("../parse-templates-BY1Xai-_.cjs");function E(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const M=E(I),k=E(B),G=k.createLogger({level:"info",format:k.format.combine(k.format.colorize(),k.format.cli()),transports:[new k.transports.Console({})]}),v=e=>o.join(e,"./saltygen"),L=["salty","css","styles","styled"],T=e=>new RegExp(`\\.(${L.join("|")})\\.`).test(e),A=async e=>{const s=v(e),n=o.join(e,"salty-config.ts"),t=o.join(s,"salty-config.js");await M.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:"esm",external:["react"]});const a=Date.now(),{config:h}=await import(`${t}?t=${a}`);return h},R=async e=>{const s=await A(e),n=new Set,t=(f,p=[])=>f?Object.entries(f).flatMap(([y,c])=>{if(!c)return;if(typeof c=="object")return t(c,[...p,y]);const C=[...p,y].join(".");n.add(`"${C}"`);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=t(y);return p==="base"?c.join(""):`${p} { ${c.join("")} }`}):[],h=f=>f?Object.entries(f).flatMap(([p,y])=>Object.entries(y).flatMap(([c,C])=>{const D=t(C,[p]),P=`.${p}-${c}, [data-${p}="${c}"]`,O=D.join("");return`${P} { ${O} }`})):[],b=t(s.variables),w=a(s.responsiveVariables),l=h(s.conditionalVariables),j=v(e),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"),x=_.parseTemplates(s.templates);r.writeFileSync(F,x)},V=async(e,s)=>{const n=N.toHash(e),t=o.join(s,"js",n+".js");await M.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:t,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${t}?t=${a}`)},q=async e=>{const s=v(e),n=o.join(s,"salty-config.js"),{config:t}=await import(n);return t},U=async e=>{try{const s=[],n=[],t=v(e),a=o.join(t,"index.css");(()=>{r.existsSync(t)&&K.execSync("rm -rf "+t),r.mkdirSync(t),r.mkdirSync(o.join(t,"css")),r.mkdirSync(o.join(t,"types"))})(),await R(e);const b=await q(e);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,t),S=[];Object.entries(m).forEach(([p,y])=>{if(y.isKeyframes&&y.css){const O=`${y.animationName}.css`,z=`css/${O}`,H=o.join(t,z);s.push(O),r.writeFileSync(H,y.css);return}if(!y.generator)return;const c=y.generator._withBuildContext({name:p,config:b}),C=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(C),S.push(C);const D=`css/${C}`,P=o.join(t,D);r.writeFileSync(P,c.css)});const F=S.map(p=>`@import url('./${p}');`).join(`
2
- `),x=N.toHash(i,6),f=o.join(t,`css/${x}.css`);r.writeFileSync(f,F)}}await w(e,t);const l=s.map(i=>`@import url('./css/${i}');`).join(`
3
- `);let u=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
4
-
5
- ${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
6
- `)}
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)}},W=async(e,s)=>{try{const n=[],t=o.join(e,"./saltygen"),a=o.join(t,"index.css");if(T(s)){const b=await q(e),w=await V(s,t);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(t,S);n.push(m),r.writeFileSync(F,d.css)});const l=r.readFileSync(a,"utf8").split(`
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)}},X=async(e,s)=>{try{const n=o.join(e,"./saltygen");if(T(s)){let a=r.readFileSync(s,"utf8");a.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==a&&await J.writeFile(s,a);const b=await q(e),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)});`,x=new RegExp(`${u}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(x,F)});const j=N.toHash(s,6);return b.importStrategy==="component"&&(l=`import '../../saltygen/css/${j}.css';
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=U;exports.generateFile=W;exports.generateVariables=R;exports.isSaltyFile=T;exports.logger=G;exports.minimizeFile=X;
@@ -1,180 +0,0 @@
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
- };
172
- 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
180
- };
@@ -1 +0,0 @@
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;