@salty-css/core 0.0.1-alpha.16 → 0.0.1-alpha.161

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 (64) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +143 -26
  3. package/bin/bin-util.d.ts +1 -0
  4. package/bin/index.cjs +1 -8
  5. package/bin/index.js +2 -117
  6. package/bin/logger.d.ts +1 -0
  7. package/bin/main.cjs +11 -0
  8. package/bin/main.d.ts +1 -0
  9. package/bin/main.js +260 -0
  10. package/compiler/get-files.d.ts +3 -0
  11. package/compiler/index.cjs +1 -11
  12. package/compiler/index.d.ts +26 -4
  13. package/compiler/index.js +18 -172
  14. package/config/define-config.d.ts +1 -1
  15. package/config/index.cjs +1 -1
  16. package/config/index.d.ts +2 -1
  17. package/config/index.js +10 -2
  18. package/css/index.cjs +1 -1
  19. package/css/index.d.ts +4 -1
  20. package/css/index.js +121 -2
  21. package/css/keyframes.d.ts +22 -0
  22. package/css/media.d.ts +87 -0
  23. package/css/merge.d.ts +6 -0
  24. package/css/token.d.ts +1 -0
  25. package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
  26. package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
  27. package/factories/define-global-styles.d.ts +7 -0
  28. package/factories/define-variables.d.ts +15 -0
  29. package/factories/index.cjs +1 -0
  30. package/factories/index.d.ts +2 -0
  31. package/factories/index.js +27 -0
  32. package/generator/index.cjs +1 -1
  33. package/generator/index.js +50 -35
  34. package/generator/parse-modifiers.d.ts +1 -1
  35. package/generator/parse-styles.d.ts +2 -2
  36. package/generator/parse-templates.d.ts +2 -0
  37. package/generator/style-generator.d.ts +8 -0
  38. package/index-BixulVRN.js +397 -0
  39. package/index-C6uCnypW.cjs +29 -0
  40. package/merge-BVm9us1A.js +4 -0
  41. package/merge-DxGoJDHv.cjs +1 -0
  42. package/package.json +12 -2
  43. package/parse-styles-3zK35muR.cjs +7 -0
  44. package/parse-styles-DrLhKtqW.js +75 -0
  45. package/parse-templates-BKvQLGeN.cjs +2 -0
  46. package/parse-templates-BdcpkXBG.js +27 -0
  47. package/react-vanilla-file-CCXbsjIb.js +18 -0
  48. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  49. package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
  50. package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
  51. package/server/index.cjs +1 -0
  52. package/server/index.d.ts +1 -0
  53. package/server/index.js +11 -0
  54. package/server/should-restart.d.ts +1 -0
  55. package/templates/salty-reset.d.ts +2 -0
  56. package/types/cli-types.d.ts +10 -0
  57. package/{config → types}/config-types.d.ts +15 -5
  58. package/types/index.d.ts +46 -19
  59. package/util/dot-case.d.ts +1 -0
  60. package/util/index.cjs +1 -1
  61. package/util/index.js +1 -1
  62. package/util/module-type.d.ts +1 -0
  63. package/parse-templates-D4p3pgQR.js +0 -92
  64. package/parse-templates-W0YfTmOT.cjs +0 -8
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-C6uCnypW.cjs"),i=async t=>{if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
@@ -0,0 +1 @@
1
+ export * from './should-restart';
@@ -0,0 +1,11 @@
1
+ import { readFile as i } from "fs/promises";
2
+ import { i as r } from "../index-BixulVRN.js";
3
+ const c = async (t) => {
4
+ if (t.includes("salty.config")) return !0;
5
+ if (!r(t)) return !1;
6
+ const s = await i(t, "utf-8");
7
+ return !!/.+define[A-Z]\w+/.test(s);
8
+ };
9
+ export {
10
+ c as checkShouldRestart
11
+ };
@@ -0,0 +1 @@
1
+ export declare const checkShouldRestart: (filename: string) => Promise<boolean>;
@@ -0,0 +1,2 @@
1
+ import { GlobalStyles } from '../types/config-types';
2
+ export declare const saltyReset: GlobalStyles;
@@ -0,0 +1,10 @@
1
+ export interface RCFile {
2
+ defaultProject?: string;
3
+ projects?: {
4
+ dir?: string;
5
+ framework?: string;
6
+ components?: string;
7
+ configDir?: string;
8
+ saltygenDir?: string;
9
+ }[];
10
+ }
@@ -1,7 +1,6 @@
1
- import { CssStyles } from '../types';
2
- type CssTemplate = CssStyles | {
3
- [key: PropertyKey]: CssTemplate;
4
- };
1
+ import { CssProperties, CssStyles } from '../types';
2
+ import { OrString } from '../types/util-types';
3
+ export type GlobalStyles = Record<string, CssProperties>;
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,11 @@ 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
+ reset?: 'default' | 'none' | GlobalStyles;
52
+ /**
53
+ * The global styles that are imported in the root of the project.
54
+ */
55
+ global?: GlobalStyles;
50
56
  /**
51
57
  * The templates that can be used in styles to create reusable css.
52
58
  */
@@ -55,5 +61,9 @@ export interface SaltyConfig {
55
61
  * The modifiers that can transform css values.
56
62
  */
57
63
  modifiers?: CssModifiers;
64
+ /**
65
+ * 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.
66
+ */
67
+ externalModules?: ('react' | 'react-dom' | OrString)[];
58
68
  }
59
69
  export {};
package/types/index.d.ts CHANGED
@@ -1,36 +1,44 @@
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 { NeverObj, 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
+ passProps?: boolean | string | string[];
11
+ style?: CssProperties | {
12
+ [key: string]: PropertyValueToken | NeverObj;
13
+ };
11
14
  /** vks = Variant key set */
12
15
  _vks?: Set<string>;
13
16
  };
14
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
+ export type CssProperties = {
25
+ [key in keyof CSS.Properties]: CSS.Properties[key] | PropertyValueToken | CSSPropertyValueFunction | NeverObj;
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 = '' | 'css';
27
30
  type VariantOptions = {
28
31
  [key in InvalidVariantKeys]?: never;
29
32
  };
33
+ export type CompoundVariant = {
34
+ [key: PropertyKey]: string | boolean | undefined;
35
+ } | {
36
+ css: CSSinJS;
37
+ };
30
38
  type Variants = {
31
39
  variants?: VariantOptions & {
32
40
  [key: PropertyKey]: {
33
- [key: string]: Styles;
41
+ [key: PropertyKey]: CSSinJS;
34
42
  };
35
43
  };
36
44
  defaultVariants?: {
@@ -38,26 +46,45 @@ type Variants = {
38
46
  };
39
47
  compoundVariants?: CompoundVariant[];
40
48
  };
41
- type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
42
- export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? object : {
43
- [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
49
+ type BooleanVariantValue = 'true' | 'false' | boolean;
50
+ type VariantPropValue<T> = T extends 'true' ? BooleanVariantValue : T extends 'false' ? BooleanVariantValue : T extends boolean ? BooleanVariantValue : T | '';
51
+ type PickType<T, K extends AllKeys<T>> = T extends {
52
+ [k in K]?: any;
53
+ } ? T[K] : undefined;
54
+ type AllKeys<T> = T extends any ? keyof T : never;
55
+ export type Merge<T> = {
56
+ [k in AllKeys<T>]?: PickType<T, k>;
44
57
  };
58
+ export type VariantProps<STYLES extends StyledParams, B = STYLES['variants'] extends undefined ? object : STYLES['variants'], C = STYLES['compoundVariants'] extends CompoundVariant[] ? Merge<STYLES['compoundVariants'][number]> : object> = Merge<{
59
+ [K in keyof B]?: K extends 'css' ? never : VariantPropValue<keyof B[K]>;
60
+ } | {
61
+ [K in keyof C]?: K extends 'css' ? never : VariantPropValue<C[K]>;
62
+ }>;
45
63
  type CssValuePropKey = `props-${string}`;
46
64
  export type ValueProps = {
47
65
  [key: CssValuePropKey]: string;
48
66
  };
49
- export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
67
+ export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : object;
50
68
  type StylePropertyValue = Record<never, never> & unknown;
69
+ export type CSSinJS = CssProperties | StylePropertyValue | TemplateTokens | CssPseudos;
51
70
  export type CssStyles = {
52
- [key in StyleKeys | OrString]?: StyleValue<key> | StylePropertyValue | PropertyValueToken | CssStyles;
71
+ [key in OrString]?: CSSinJS;
53
72
  };
54
73
  export type Styles = CssStyles & Variants;
55
74
  export interface GeneratorOptions {
56
75
  className?: string;
57
76
  displayName?: string;
58
77
  element?: string;
78
+ passProps?: boolean | string | string[];
79
+ defaultProps?: Record<PropertyKey, unknown>;
80
+ }
81
+ interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens {
59
82
  }
83
+ type Pseudos = CSS.Pseudos | `&${CSS.Pseudos}`;
84
+ type CssPseudos = {
85
+ [P in Pseudos]?: CssStyles;
86
+ };
60
87
  export interface StyledParams extends GeneratorOptions, Variants {
61
- base?: CssStyles;
88
+ base?: Base;
62
89
  }
63
90
  export {};
@@ -0,0 +1 @@
1
+ export declare function dotCase(str: PropertyKey): string;
package/util/index.cjs CHANGED
@@ -1 +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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-BJEkFEGQ.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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as o, t as s } from "../dash-case-DMQMcCO6.js";
1
+ import { d as o, t as s } from "../dash-case-DBThphLm.js";
2
2
  import { p as f } from "../pascal-case-BQpR5PdN.js";
3
3
  function r(e) {
4
4
  return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
@@ -0,0 +1 @@
1
+ export declare const detectCurrentModuleType: (dirname: string) => Promise<"esm" | "cjs">;
@@ -1,92 +0,0 @@
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
- const e = [];
6
- return Object.values(r).forEach((n) => {
7
- const { pattern: o, transform: c } = n;
8
- t = t.replace(o, (h) => {
9
- const { value: i, css: m } = c(h);
10
- return m && e.push(m), i;
11
- });
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]) => {
16
- const p = m.trim();
17
- if (typeof s == "function" && (s = s()), typeof s == "object") {
18
- if (!s) return i;
19
- if (p === "variants")
20
- return Object.entries(s).forEach(([u, f]) => {
21
- f && Object.entries(f).forEach(([b, j]) => {
22
- if (!j) return;
23
- const l = `${r}.${u}-${b}`, y = d(j, l, e);
24
- o.push(y);
25
- });
26
- }), i;
27
- if (p === "defaultVariants")
28
- return i;
29
- if (p === "compoundVariants")
30
- return s.forEach((u) => {
31
- const { css: f, ...b } = u, j = Object.entries(b).reduce((y, [V, W]) => `${y}.${V}-${W}`, r), l = d(f, j, e);
32
- o.push(l);
33
- }), i;
34
- if (p.startsWith("@")) {
35
- const u = d(s, r, e), f = `${p} {
36
- ${u.replace(`
37
- `, `
38
- `)}
39
- }`;
40
- return o.push(f), i;
41
- }
42
- const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(s, $, e);
43
- return o.push(a), i;
44
- }
45
- if (n != null && n.templates && n.templates[p]) {
46
- const a = s.split(".").reduce((f, b) => f[b], n.templates[p]), u = d(a, "");
47
- return `${i}${u}`;
48
- }
49
- const g = p.startsWith("-") ? p : O(p), E = ($, a = ";") => i = `${i}${$}${a}`, S = ($) => E(`${g}:${$}`);
50
- if (typeof s == "number") return S(s);
51
- if (typeof s != "string")
52
- if ("toString" in s) s = s.toString();
53
- else return i;
54
- const { modifiers: k } = n || {}, T = function* () {
55
- yield P(s), yield N(s, k);
56
- }();
57
- for (const { result: $, additionalCss: a = [] } of T)
58
- s = $, a.forEach((u) => {
59
- const f = d(u, "");
60
- E(f, "");
61
- });
62
- return S(s);
63
- }, "");
64
- if (!c) return o.join(`
65
- `);
66
- if (!r) return c;
67
- let h = "";
68
- return e !== void 0 ? h = `@layer l${e} { ${r} { ${c} } }` : h = `${r} { ${c} }`, [h, ...o].join(`
69
- `);
70
- }, _ = (t, r = []) => {
71
- if (!t) return "";
72
- const e = [], n = {};
73
- if (Object.entries(t).forEach(([o, c]) => {
74
- if (typeof c == "object") {
75
- if (!c) return;
76
- const h = o.trim(), i = _(c, [...r, h]);
77
- e.push(i);
78
- } else
79
- n[o] = c;
80
- }), Object.keys(n).length) {
81
- const o = r.map(O).join("-"), c = d(n, `.${o}`);
82
- e.push(c);
83
- }
84
- return e.join(`
85
- `);
86
- }, A = (t) => Object.keys(t);
87
- export {
88
- _ as a,
89
- P as b,
90
- A as g,
91
- d as p
92
- };
@@ -1,8 +0,0 @@
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;