@salty-css/core 0.0.1-alpha.10 → 0.0.1-alpha.100

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 +11 -0
  9. package/bin/main.d.ts +1 -0
  10. package/bin/main.js +245 -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 +35 -20
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.10",
3
+ "version": "0.0.1-alpha.100",
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
  }
@@ -0,0 +1,96 @@
1
+ import { d as O } from "./dash-case-DMQMcCO6.js";
2
+ const W = (s, r) => {
3
+ if (typeof s != "string") return { result: s };
4
+ if (!r) return { result: s };
5
+ const o = [];
6
+ return Object.values(r).forEach((i) => {
7
+ const { pattern: p, transform: c } = i;
8
+ s = s.replace(p, (a) => {
9
+ const { value: e, css: m } = c(a);
10
+ return m && o.push(m), e;
11
+ });
12
+ }), { result: s, additionalCss: o };
13
+ }, N = (s) => typeof s != "string" ? { result: s } : /\{[^{}]+\}/g.test(s) ? { result: s.replace(/\{([^{}]+)\}/g, (...i) => `var(--${O(i[1].replaceAll(".", "-"))})`) } : { result: s }, d = (s, r, o, i) => {
14
+ if (!s) return "";
15
+ const p = [], c = Object.entries(s).reduce((e, [m, t]) => {
16
+ const n = m.trim();
17
+ if (typeof t == "function" && (t = t()), typeof t == "object") {
18
+ if (!t) return e;
19
+ if (n === "variants")
20
+ return Object.entries(t).forEach(([f, u]) => {
21
+ u && Object.entries(u).forEach(([b, l]) => {
22
+ if (!l) return;
23
+ const j = `${r}.${f}-${b}`, y = d(l, j, o);
24
+ p.push(y);
25
+ });
26
+ }), e;
27
+ if (n === "defaultVariants")
28
+ return e;
29
+ if (n === "compoundVariants")
30
+ return t.forEach((f) => {
31
+ const { css: u, ...b } = f, l = Object.entries(b).reduce((y, [V, w]) => `${y}.${V}-${w}`, r), j = d(u, l, o);
32
+ p.push(j);
33
+ }), e;
34
+ if (n.startsWith("@")) {
35
+ const f = d(t, r, o), u = `${n} {
36
+ ${f.replace(`
37
+ `, `
38
+ `)}
39
+ }`;
40
+ return p.push(u), e;
41
+ }
42
+ const $ = m.includes("&") ? n.replace("&", r) : n.startsWith(":") ? `${r}${n}` : `${r} ${n}`, h = d(t, $, o);
43
+ return p.push(h), e;
44
+ }
45
+ if (i != null && i.templates && i.templates[n]) {
46
+ const h = t.split(".").reduce((f, u) => f[u], i.templates[n]);
47
+ if (h) {
48
+ const f = d(h, "");
49
+ return `${e}${f}`;
50
+ }
51
+ return console.warn(`Template "${n}" with path of "${t}" was not found in config!`), e;
52
+ }
53
+ const S = n.startsWith("-") ? n : O(n), g = ($, h = ";") => e = `${e}${$}${h}`, E = ($) => g(`${S}:${$}`);
54
+ if (typeof t == "number") return E(t);
55
+ if (typeof t != "string")
56
+ if ("toString" in t) t = t.toString();
57
+ else return e;
58
+ const { modifiers: T } = i || {}, k = function* () {
59
+ yield N(t), yield W(t, T);
60
+ }();
61
+ for (const { result: $, additionalCss: h = [] } of k)
62
+ t = $, h.forEach((f) => {
63
+ const u = d(f, "");
64
+ g(u, "");
65
+ });
66
+ return E(t);
67
+ }, "");
68
+ if (!c) return p.join(`
69
+ `);
70
+ if (!r) return c;
71
+ let a = "";
72
+ return o !== void 0 ? a = `@layer l${o} { ${r} { ${c} } }` : a = `${r} { ${c} }`, [a, ...p].join(`
73
+ `);
74
+ }, P = (s, r = []) => {
75
+ if (!s) return "";
76
+ const o = [], i = {};
77
+ if (Object.entries(s).forEach(([p, c]) => {
78
+ if (typeof c == "object") {
79
+ if (!c) return;
80
+ const a = p.trim(), e = P(c, [...r, a]);
81
+ o.push(e);
82
+ } else
83
+ i[p] = c;
84
+ }), Object.keys(i).length) {
85
+ const p = r.map(O).join("-"), c = d(i, `.${p}`);
86
+ o.push(c);
87
+ }
88
+ return o.join(`
89
+ `);
90
+ }, x = (s) => Object.keys(s);
91
+ export {
92
+ P as a,
93
+ N as b,
94
+ x as g,
95
+ d as p
96
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";const T=require("./dash-case-DKzpenwY.cjs"),K=(e,s)=>{if(typeof e!="string")return{result:e};if(!s)return{result:e};const o=[];return Object.values(s).forEach(i=>{const{pattern:p,transform:c}=i;e=e.replace(p,d=>{const{value:r,css:l}=c(d);return l&&o.push(l),r})}),{result:e,additionalCss:o}},g=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...i)=>`var(--${T.dashCase(i[1].replaceAll(".","-"))})`)}:{result:e},a=(e,s,o,i)=>{if(!e)return"";const p=[],c=Object.entries(e).reduce((r,[l,t])=>{const n=l.trim();if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return r;if(n==="variants")return Object.entries(t).forEach(([f,u])=>{u&&Object.entries(u).forEach(([j,m])=>{if(!m)return;const y=`${s}.${f}-${j}`,b=a(m,y,o);p.push(b)})}),r;if(n==="defaultVariants")return r;if(n==="compoundVariants")return t.forEach(f=>{const{css:u,...j}=f,m=Object.entries(j).reduce((b,[W,q])=>`${b}.${W}-${q}`,s),y=a(u,m,o);p.push(y)}),r;if(n.startsWith("@")){const f=a(t,s,o),u=`${n} {
2
+ ${f.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return p.push(u),r}const $=l.includes("&")?n.replace("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`,h=a(t,$,o);return p.push(h),r}if(i!=null&&i.templates&&i.templates[n]){const h=t.split(".").reduce((f,u)=>f[u],i.templates[n]);if(h){const f=a(h,"");return`${r}${f}`}return console.warn(`Template "${n}" with path of "${t}" was not found in config!`),r}const E=n.startsWith("-")?n:T.dashCase(n),O=($,h=";")=>r=`${r}${$}${h}`,S=$=>O(`${E}:${$}`);if(typeof t=="number")return S(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return r;const{modifiers:V}=i||{},w=function*(){yield g(t),yield K(t,V)}();for(const{result:$,additionalCss:h=[]}of w)t=$,h.forEach(f=>{const u=a(f,"");O(u,"")});return S(t)},"");if(!c)return p.join(`
6
+ `);if(!s)return c;let d="";return o!==void 0?d=`@layer l${o} { ${s} { ${c} } }`:d=`${s} { ${c} }`,[d,...p].join(`
7
+ `)},k=(e,s=[])=>{if(!e)return"";const o=[],i={};if(Object.entries(e).forEach(([p,c])=>{if(typeof c=="object"){if(!c)return;const d=p.trim(),r=k(c,[...s,d]);o.push(r)}else i[p]=c}),Object.keys(i).length){const p=s.map(T.dashCase).join("-"),c=a(i,`.${p}`);o.push(c)}return o.join(`
8
+ `)},N=e=>Object.keys(e);exports.getTemplateKeys=N;exports.parseStyles=a;exports.parseTemplates=k;exports.parseValueTokens=g;
@@ -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,18 @@
1
+ const n = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
2
+
3
+ interface <%- componentName %>Props {
4
+ text?: string;
5
+ }
6
+
7
+ export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
8
+ return (
9
+ <<%- styledComponentName %>>
10
+ {text}
11
+ </<%- styledComponentName %>>
12
+ );
13
+ };
14
+
15
+ export default <%- componentName %>;`;
16
+ export {
17
+ n as default
18
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { <%- styledComponentName %> } from "./<%- fileName %>.css";
2
+
3
+ interface <%- componentName %>Props {
4
+ text?: string;
5
+ }
6
+
7
+ export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
8
+ return (
9
+ <<%- styledComponentName %>>
10
+ {text}
11
+ </<%- styledComponentName %>>
12
+ );
13
+ };
14
+
15
+ export default <%- componentName %>;`;exports.default=e;
@@ -0,0 +1,10 @@
1
+ const n = `import { defineConfig } from '@salty-css/core/config';
2
+
3
+ export const config = defineConfig({
4
+ // Add your custom config here
5
+ externalModules: ['react', 'react-dom']
6
+ });
7
+ `;
8
+ export {
9
+ n as default
10
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { defineConfig } from '@salty-css/core/config';
2
+
3
+ export const config = defineConfig({
4
+ // Add your custom config here
5
+ externalModules: ['react', 'react-dom']
6
+ });
7
+ `;exports.default=e;
package/types/index.d.ts CHANGED
@@ -1,32 +1,39 @@
1
- import { AllHTMLAttributes, ReactDOM, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { StyleComponentGenerator } from '../generator';
3
- import { OrString } from './util-types';
3
+ import { OrAny, OrString } from './util-types';
4
+ import type * as CSS from 'csstype';
4
5
  export type CreateElementProps = {
5
6
  extend?: Tag<any>;
6
7
  children?: ReactNode;
7
8
  className?: string;
8
9
  element?: string;
9
- passVariantProps?: boolean;
10
- style?: any;
10
+ passVariantProps?: boolean | string | string[];
11
+ style?: CssProperties & {
12
+ [key: string]: OrAny | PropertyValueToken;
13
+ };
11
14
  /** vks = Variant key set */
12
15
  _vks?: Set<string>;
13
16
  };
14
- export type StyledComponentProps = Record<string, unknown> & CreateElementProps & CssRuntimeValues;
17
+ export type StyledComponentProps = Record<string, unknown> & CreateElementProps;
15
18
  type FnComponent<PROPS extends StyledComponentProps> = {
16
- (props: PROPS): ReactNode;
19
+ (props: OrAny | PROPS): ReactNode;
17
20
  generator?: StyleComponentGenerator;
18
21
  };
19
- export type Tag<PROPS extends StyledComponentProps> = OrString | keyof ReactDOM | FnComponent<PROPS>;
20
- export type CompoundVariant = {
21
- [key: PropertyKey]: any;
22
- css: CssStyles;
22
+ export type Tag<PROPS extends StyledComponentProps> = OrString | keyof HTMLElementTagNameMap | FnComponent<PROPS>;
23
+ type CSSPropertyValueFunction = (params?: any) => any;
24
+ type CssProperties = {
25
+ [key in keyof CSS.Properties]: CSS.Properties[key] | PropertyValueToken | CSSPropertyValueFunction;
23
26
  };
24
- type InvalidVariantKeys = keyof AllHTMLAttributes<HTMLElement>;
25
- type StyleKeys = keyof Required<AllHTMLAttributes<HTMLElement>>['style'];
26
- export type StyleValue<K extends string> = K extends StyleKeys ? Required<AllHTMLAttributes<HTMLElement>>['style'][K] : never;
27
+ type CssPropertyKeys = keyof CssProperties;
28
+ export type StyleValue<K extends string> = K extends CssPropertyKeys ? CssProperties[K] : never;
29
+ type InvalidVariantKeys = '';
27
30
  type VariantOptions = {
28
31
  [key in InvalidVariantKeys]?: never;
29
32
  };
33
+ export type CompoundVariant = {
34
+ [key: PropertyKey]: any;
35
+ css: CssStyles;
36
+ };
30
37
  type Variants = {
31
38
  variants?: VariantOptions & {
32
39
  [key: PropertyKey]: {
@@ -38,17 +45,19 @@ type Variants = {
38
45
  };
39
46
  compoundVariants?: CompoundVariant[];
40
47
  };
41
- type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
42
- export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? {} : {
48
+ type BooleanVariantValue = 'true' | 'false' | boolean;
49
+ type VariantPropValue<T> = T extends 'true' ? BooleanVariantValue : T extends 'false' ? BooleanVariantValue : T;
50
+ export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? object : {
43
51
  [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
44
52
  };
45
- export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
46
- export type CssRuntimeValues = {
47
- cssValues?: Record<string, unknown>;
53
+ type CssValuePropKey = `props-${string}`;
54
+ export type ValueProps = {
55
+ [key: CssValuePropKey]: string;
48
56
  };
57
+ export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : object;
49
58
  type StylePropertyValue = Record<never, never> & unknown;
50
59
  export type CssStyles = {
51
- [key in StyleKeys | OrString]?: StyleValue<key> | StylePropertyValue | PropertyValueToken | CssStyles;
60
+ [key in OrString]?: CssProperties | StylePropertyValue | PropertyValueToken | CssStyles;
52
61
  };
53
62
  export type Styles = CssStyles & Variants;
54
63
  export interface GeneratorOptions {
@@ -56,7 +65,13 @@ export interface GeneratorOptions {
56
65
  displayName?: string;
57
66
  element?: string;
58
67
  }
68
+ interface Base extends CssProperties, CssStyles, CssPseudos {
69
+ }
70
+ type Pseudos = CSS.Pseudos | `&${CSS.Pseudos}`;
71
+ type CssPseudos = {
72
+ [P in Pseudos]?: Base;
73
+ };
59
74
  export interface StyledParams extends GeneratorOptions, Variants {
60
- base?: CssStyles;
75
+ base?: Base;
61
76
  }
62
77
  export {};
@@ -0,0 +1 @@
1
+ export declare function camelCase(str: PropertyKey): string;
package/util/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=t=>String.fromCharCode(t+(t>25?39:97)),o=(t,r)=>{let e="",a;for(a=Math.abs(t);a>52;a=a/52|0)e=n(a%52)+e;return e=n(a%52)+e,e.length<r?e=e.padStart(r,"a"):e.length>r&&(e=e.slice(-r)),e},i=(t,r)=>{let e=r.length;for(;e;)t=t*33^r.charCodeAt(--e);return t},s=(t,r=3)=>{const e=i(5381,JSON.stringify(t))>>>0;return o(e,r)};function c(t){return t?typeof t!="string"?String(t):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,e)=>(e>0?"-":"")+r.toLowerCase()):""}exports.dashCase=c;exports.toHash=s;
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;
package/util/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ export * from './camel-case';
1
2
  export * from './dash-case';
3
+ export * from './pascal-case';
2
4
  export * from './to-hash';
package/util/index.js CHANGED
@@ -1,19 +1,11 @@
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
- }, s = (e, r = 3) => {
10
- const t = i(5381, JSON.stringify(e)) >>> 0;
11
- return o(t, r);
12
- };
13
- function c(e) {
14
- return e ? typeof e != "string" ? String(e) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
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()) : "";
15
5
  }
16
6
  export {
17
- c as dashCase,
7
+ r as camelCase,
8
+ o as dashCase,
9
+ f as pascalCase,
18
10
  s as toHash
19
11
  };
@@ -0,0 +1 @@
1
+ export declare const detectCurrentModuleType: (dirname: string) => Promise<"esm" | "cjs">;
@@ -0,0 +1 @@
1
+ export declare function pascalCase(str: PropertyKey): string;
@@ -1,90 +0,0 @@
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 };
5
- const e = [];
6
- return Object.values(r).forEach((n) => {
7
- const { pattern: o, transform: c } = n;
8
- s = s.replace(o, (h) => {
9
- const { value: i, css: m } = c(h);
10
- return m && e.push(m), i;
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]) => {
15
- const p = m.trim();
16
- if (typeof t == "function" && (t = t()), typeof t == "object") {
17
- if (!t) return i;
18
- if (p === "variants")
19
- return Object.entries(t).forEach(([u, f]) => {
20
- f && Object.entries(f).forEach(([b, j]) => {
21
- if (!j) return;
22
- const l = `${r}.${u}-${b}`, y = d(j, l, e);
23
- o.push(y);
24
- });
25
- }), i;
26
- if (p === "defaultVariants")
27
- return i;
28
- if (p === "compoundVariants")
29
- return t.forEach((u) => {
30
- const { css: f, ...b } = u, j = Object.entries(b).reduce((y, [V, W]) => `${y}.${V}-${W}`, r), l = d(f, j, e);
31
- o.push(l);
32
- }), i;
33
- if (p.startsWith("@")) {
34
- const u = d(t, r, e), f = `${p} {
35
- ${u.replace(`
36
- `, `
37
- `)}
38
- }`;
39
- return o.push(f), i;
40
- }
41
- const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(t, $, e);
42
- return o.push(a), i;
43
- }
44
- 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
- return `${i}${u}`;
47
- }
48
- 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();
52
- else return i;
53
- const { modifiers: k } = n || {}, T = function* () {
54
- yield P(t), yield N(t, k);
55
- }();
56
- for (const { result: $, additionalCss: a = [] } of T)
57
- t = $, a.forEach((u) => {
58
- const f = d(u, "");
59
- E(f, "");
60
- });
61
- return S(t);
62
- }, "");
63
- if (!c) return o.join(`
64
- `);
65
- if (!r) return c;
66
- let h = "";
67
- return e !== void 0 ? h = `@layer l${e} { ${r} { ${c} } }` : h = `${r} { ${c} }`, [h, ...o].join(`
68
- `);
69
- }, _ = (s, r = []) => {
70
- const e = [], n = {};
71
- if (Object.entries(s).forEach(([o, c]) => {
72
- if (typeof c == "object") {
73
- if (!c) return;
74
- const h = o.trim(), i = _(c, [...r, h]);
75
- e.push(i);
76
- } else
77
- n[o] = c;
78
- }), Object.keys(n).length) {
79
- const o = r.map(O).join("-"), c = d(n, `.${o}`);
80
- e.push(c);
81
- }
82
- return e.join(`
83
- `);
84
- }, A = (s) => Object.keys(s);
85
- export {
86
- _ as a,
87
- P as b,
88
- A as g,
89
- d as p
90
- };
@@ -1,8 +0,0 @@
1
- "use strict";const O=require("./util/index.cjs"),K=(s,e)=>{if(typeof s!="string")return{result:s};if(!e)return{result:s};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:c}=n;s=s.replace(o,a=>{const{value:i,css:l}=c(a);return l&&r.push(l),i})}),{result:s,additionalCss:r}},k=s=>typeof s!="string"?{result:s}:/\{[^{}]+\}/g.test(s)?{result:s.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O.dashCase(n[1].replaceAll(".","-"))})`)}:{result:s},h=(s,e,r,n)=>{const o=[],c=Object.entries(s).reduce((i,[l,t])=>{const p=l.trim();if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return i;if(p==="variants")return Object.entries(t).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 t.forEach(u=>{const{css:f,...m}=u,j=Object.entries(m).reduce((b,[_,q])=>`${b}.${_}-${q}`,e),y=h(f,j,r);o.push(y)}),i;if(p.startsWith("@")){const u=h(t,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(t,$,r);return o.push(d),i}if(n!=null&&n.templates&&n.templates[p]){const d=t.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 t=="number")return S(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return i;const{modifiers:g}=n||{},W=function*(){yield k(t),yield K(t,g)}();for(const{result:$,additionalCss:d=[]}of W)t=$,d.forEach(u=>{const f=h(u,"");T(f,"")});return S(t)},"");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=(s,e=[])=>{const r=[],n={};if(Object.entries(s).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
- `)},N=s=>Object.keys(s);exports.getTemplateKeys=N;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=k;