@salty-css/astro 0.1.0-alpha.3 → 0.1.0-alpha.31

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.
@@ -1,15 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("@salty-css/core/compiler/helpers"),H=require("@salty-css/core/compiler/get-function-range"),J=require("@salty-css/core/compiler/salty-compiler"),O=require("@salty-css/core/server"),P=require("@salty-css/core/util"),d=require("fs/promises"),x=require("path"),b=D=>{const g=new J.SaltyCompiler(D);return{name:"stylegen",configureServer(t){g.importFile=async c=>{const l=Date.now();return t.ssrLoadModule(`${c}?t=${l}`)}},buildStart:async()=>{await g.generateCss()},load:async t=>{var l,C;if(j.isSaltyFile(t)){const $=await g.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const h=new URLSearchParams(t.split("?")[1]).get("configFile");if(!h)return;const m=x.join($,"astro",h),y=await d.readFile(m,"utf-8");if(!y)return;try{const u=JSON.parse(y),{clientProps:o={},classNames:s="",tagIsComponent:f,tagName:a="div"}=u,w=u.imports||[],F=f?a:`props.element || "${o.element||a}"`;let p="";if(o.element&&f&&(p+=` element="${o.element}"`),o.attr)for(const[i,n]of Object.entries(o.attr))p+=` ${i}="${n}"`;p=p.trim();const v=o.variantKeys||[];return`---
2
- ${w.join(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("@salty-css/core/compiler/helpers"),H=require("@salty-css/core/compiler/get-function-range"),b=require("@salty-css/core/compiler/salty-compiler"),j=require("@salty-css/core/server"),I=require("@salty-css/core/util"),f=require("fs/promises"),x=require("path"),M=(D,O={})=>{const n=new b.SaltyCompiler(D,{mode:O.mode});return{name:"stylegen",configureServer:function(t){n.importFile=async e=>{const r=Date.now();return t.ssrLoadModule(`${e}?t=${r}`)}},configResolved:async function(){try{await n.generateCss()}catch(t){throw console.error("Error during initial CSS generation:",t),t}},load:async function(t){var e,r;try{if(N.isSaltyFile(t)){const d=await n.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const y=new URLSearchParams(t.split("?")[1]).get("configFile");if(!y)return;const m=x.join(d,"astro",y),w=await f.readFile(m,"utf-8");if(!w)return;try{const p=JSON.parse(w),{clientProps:F={},classNames:i="",tagIsComponent:$,tagName:a="div"}=p,C=["import { resolveAstroProps } from '@salty-css/astro/element-props';",...p.imports||[]],R=$?a:`__r.element || ${JSON.stringify(F.element||a)}`;return`---
2
+ ${C.join(`
3
3
  `)}
4
- const { props } = Astro;
5
- const Element = ${F};
6
- const variantClasses = [
7
- ${v.map(i=>{const[n,r]=i.split("=");return`props.${n} !== undefined ? "${n}-" + props.${n} : ${r!==void 0?`"${n}-${r}"`:'""'}`}).join(`,
8
- `)}
9
- ]
4
+ const __gp = ${JSON.stringify(F)};
5
+ const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
6
+ const Element = ${R};
10
7
  ---
11
- <Element class:list={["${s}", ...variantClasses, props.class]} ${p} {...props}><slot/></Element>`}catch(u){console.error("Error parsing config file:",u);return}}const R=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],q=[],N=[],S=await d.readFile(t,"utf-8"),k=await g.compileSaltyFile(t,$),I=Object.entries(k.contents);for(const[e,h]of I){const m=await j.resolveExportValue(h,1);if(!m.generator)continue;if(m.isClassName){const i=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}});q.push(`const ${e} = classNameInstance(${JSON.stringify(i.params)});`),N.push(e);continue}const[y,u]=await H.getFunctionRange(S,e),o=S.slice(y,u),s=(C=(l=/styled\(([^,]+),/.exec(o))==null?void 0:l.at(1))==null?void 0:C.trim();if(!s){console.warn(`Could not determine tag name for ${e} in ${t}`);continue}const f=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}}),a={componentName:e,tagName:s.replace(/['"`]/g,""),tagIsComponent:!1,classNames:f.classNames,imports:[],clientProps:f.clientProps},w=/^\w+$/.test(s);if(a.tagIsComponent=w,w){const i=I.some(([r])=>r===s),n=S.match(new RegExp(`import[^;]*${s}[^;]*;`));if(i){const r=P.toHash(s),_=`import ${s} from '${t}.astro?configFile=${r}.config';`;a.imports=[_]}else if(n){const r=n.at(0);a.imports=[r]}}const F=x.join($,"astro");await d.readFile(F,"utf-8").catch(()=>!1)||await d.mkdir(F,{recursive:!0});const v=P.toHash(e),E=x.join($,"astro",`${v}.config`);await d.writeFile(E,JSON.stringify(a)),R.push(`import ${e} from '${t}.astro?configFile=${v}.config';`),N.push(e)}return`${R.join(`
8
+ <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`}catch(p){console.error("Error parsing config file:",p);return}}const h=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],l=[],s=[],u=await f.readFile(t,"utf-8"),q=await n.compileSaltyFile(t,d),E=Object.entries(q.contents);for(const[o,y]of E){const m=await N.resolveExportValue(y,1);if(!m.generator)continue;if(m.isClassName){const _=m.generator._withBuildContext({callerName:o,isProduction:n.isProduction,config:{}});l.push(`const ${o} = classNameInstance(${JSON.stringify(_.params)});`),s.push(o);continue}const[w,p]=await H.getFunctionRange(u,o),F=u.slice(w,p),i=(r=(e=/styled\(([^,]+),/.exec(F))==null?void 0:e.at(1))==null?void 0:r.trim();if(!i){console.warn(`Could not determine tag name for ${o} in ${t}`);continue}const $=m.generator._withBuildContext({callerName:o,isProduction:n.isProduction,config:{}}),a={componentName:o,tagName:i.replace(/['"`]/g,""),tagIsComponent:!1,classNames:$.classNames,imports:[],clientProps:$.clientProps},S=/^\w+$/.test(i);if(a.tagIsComponent=S,S){const _=E.some(([g])=>g===i),P=u.match(new RegExp(`import[^;]*${i}[^;]*;`));if(_){const g=I.toHash(i),G=`import ${i} from '${t}.astro?configFile=${g}.config';`;a.imports=[G]}else if(P){const g=P.at(0);a.imports=[g]}}const C=x.join(d,"astro");await f.readFile(C,"utf-8").catch(()=>!1)||await f.mkdir(C,{recursive:!0});const v=I.toHash(o),J=x.join(d,"astro",`${v}.config`);await f.writeFile(J,JSON.stringify(a)),h.push(`import ${o} from '${t}.astro?configFile=${v}.config';`),s.push(o)}return`${h.join(`
12
9
  `)}
13
- ${q.join(`
10
+ ${l.join(`
14
11
  `)}
15
- export { ${N.join(", ")} };`}},handleHotUpdate:async({file:t,server:c})=>{await O.checkShouldRestart(t)&&c.restart()},watchChange:{handler:async(t,c)=>{j.isSaltyFile(t)&&c.event!=="delete"&&(await O.checkShouldRestart(t)||await g.generateFile(t))}}}};exports.default=b;exports.saltyPlugin=b;
12
+ export { ${s.join(", ")} };`}return}catch(c){console.error("Error during file compilation:",c);return}},handleHotUpdate:async function({file:t,server:e,modules:r}){try{if(await j.checkShouldRestart(t))return await n.generateCss(!1);if(!N.isSaltyFile(t))return;const h=await n.getDestDir(),l=[];for(const[s,u]of e.moduleGraph.idToModuleMap)s.startsWith(t+".astro?configFile=")&&(e.moduleGraph.invalidateModule(u),l.push(u));for(const s of e.moduleGraph.urlToModuleMap.values())s.file&&s.file.startsWith(h)&&(e.moduleGraph.invalidateModule(s),l.push(s));return e.ws.send({type:"update",updates:[]}),[...r,...l]}catch(c){console.error("Error during hot update handling:",c)}},watchChange:{handler:async function(t,e){try{N.isSaltyFile(t)&&e.event!=="delete"&&(await j.checkShouldRestart(t)||await n.generateFile(t))}catch(r){console.error("Error during watch change handling:",r)}}}}};exports.default=M;exports.saltyPlugin=M;
@@ -1,3 +1,10 @@
1
+ import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
1
2
  import { PluginOption } from 'vite';
2
- export declare const saltyPlugin: (dir: string) => PluginOption;
3
+ export interface SaltyAstroPluginOptions {
4
+ /**
5
+ * Explicit build mode. Defaults to NODE_ENV-based detection.
6
+ */
7
+ mode?: SaltyCompilerMode;
8
+ }
9
+ export declare const saltyPlugin: (dir: string, options?: SaltyAstroPluginOptions) => PluginOption;
3
10
  export default saltyPlugin;
@@ -1,120 +1,135 @@
1
- import { isSaltyFile as D, resolveExportValue as A } from "@salty-css/core/compiler/helpers";
2
- import { getFunctionRange as B } from "@salty-css/core/compiler/get-function-range";
3
- import { SaltyCompiler as H } from "@salty-css/core/compiler/salty-compiler";
4
- import { checkShouldRestart as O } from "@salty-css/core/server";
1
+ import { isSaltyFile as S, resolveExportValue as A } from "@salty-css/core/compiler/helpers";
2
+ import { getFunctionRange as H } from "@salty-css/core/compiler/get-function-range";
3
+ import { SaltyCompiler as k } from "@salty-css/core/compiler/salty-compiler";
4
+ import { checkShouldRestart as D } from "@salty-css/core/server";
5
5
  import { toHash as P } from "@salty-css/core/util";
6
- import { readFile as x, mkdir as K, writeFile as L } from "fs/promises";
7
- import { join as S } from "path";
8
- const T = (b) => {
9
- const u = new H(b);
6
+ import { readFile as v, mkdir as B, writeFile as L } from "fs/promises";
7
+ import { join as x } from "path";
8
+ const Q = (M, O = {}) => {
9
+ const n = new k(M, { mode: O.mode });
10
10
  return {
11
11
  name: "stylegen",
12
- configureServer(t) {
13
- u.importFile = async (c) => {
14
- const l = Date.now();
15
- return t.ssrLoadModule(`${c}?t=${l}`);
12
+ configureServer: function(t) {
13
+ n.importFile = async (o) => {
14
+ const r = Date.now();
15
+ return t.ssrLoadModule(`${o}?t=${r}`);
16
16
  };
17
17
  },
18
- buildStart: async () => {
19
- await u.generateCss();
18
+ configResolved: async function() {
19
+ try {
20
+ await n.generateCss();
21
+ } catch (t) {
22
+ throw console.error("Error during initial CSS generation:", t), t;
23
+ }
20
24
  },
21
- load: async (t) => {
22
- var l, F;
23
- if (D(t)) {
24
- const d = await u.getDestDir();
25
- if (/.+\?configFile=(\w+).+/.test(t)) {
26
- const $ = new URLSearchParams(t.split("?")[1]).get("configFile");
27
- if (!$) return;
28
- const m = S(d, "astro", $), w = await x(m, "utf-8");
29
- if (!w) return;
30
- try {
31
- const p = JSON.parse(w), { clientProps: n = {}, classNames: s = "", tagIsComponent: g, tagName: r = "div" } = p, h = p.imports || [], y = g ? r : `props.element || "${n.element || r}"`;
32
- let f = "";
33
- if (n.element && g && (f += ` element="${n.element}"`), n.attr) for (const [i, o] of Object.entries(n.attr)) f += ` ${i}="${o}"`;
34
- f = f.trim();
35
- const C = n.variantKeys || [];
36
- return `---
37
- ${h.join(`
38
- `)}
39
- const { props } = Astro;
40
- const Element = ${y};
41
- const variantClasses = [
42
- ${C.map((i) => {
43
- const [o, a] = i.split("=");
44
- return `props.${o} !== undefined ? "${o}-" + props.${o} : ${a !== void 0 ? `"${o}-${a}"` : '""'}`;
45
- }).join(`,
25
+ load: async function(t) {
26
+ var o, r;
27
+ try {
28
+ if (S(t)) {
29
+ const f = await n.getDestDir();
30
+ if (/.+\?configFile=(\w+).+/.test(t)) {
31
+ const h = new URLSearchParams(t.split("?")[1]).get("configFile");
32
+ if (!h) return;
33
+ const p = x(f, "astro", h), y = await v(p, "utf-8");
34
+ if (!y) return;
35
+ try {
36
+ const u = JSON.parse(y), { clientProps: w = {}, classNames: i = "", tagIsComponent: $, tagName: a = "div" } = u, F = ["import { resolveAstroProps } from '@salty-css/astro/element-props';", ...u.imports || []], I = $ ? a : `__r.element || ${JSON.stringify(w.element || a)}`;
37
+ return `---
38
+ ${F.join(`
46
39
  `)}
47
- ]
40
+ const __gp = ${JSON.stringify(w)};
41
+ const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
42
+ const Element = ${I};
48
43
  ---
49
- <Element class:list={["${s}", ...variantClasses, props.class]} ${f} {...props}><slot/></Element>`;
50
- } catch (p) {
51
- console.error("Error parsing config file:", p);
52
- return;
44
+ <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`;
45
+ } catch (u) {
46
+ console.error("Error parsing config file:", u);
47
+ return;
48
+ }
53
49
  }
54
- }
55
- const j = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], R = [], v = [], N = await x(t, "utf-8"), k = await u.compileSaltyFile(t, d), I = Object.entries(k.contents);
56
- for (const [e, $] of I) {
57
- const m = await A($, 1);
58
- if (!m.generator) continue;
59
- if (m.isClassName) {
60
- const i = m.generator._withBuildContext({
50
+ const g = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], l = [], s = [], m = await v(t, "utf-8"), j = await n.compileSaltyFile(t, f), E = Object.entries(j.contents);
51
+ for (const [e, h] of E) {
52
+ const p = await A(h, 1);
53
+ if (!p.generator) continue;
54
+ if (p.isClassName) {
55
+ const _ = p.generator._withBuildContext({
56
+ callerName: e,
57
+ isProduction: n.isProduction,
58
+ config: {}
59
+ });
60
+ l.push(`const ${e} = classNameInstance(${JSON.stringify(_.params)});`), s.push(e);
61
+ continue;
62
+ }
63
+ const [y, u] = await H(m, e), w = m.slice(y, u), i = (r = (o = /styled\(([^,]+),/.exec(w)) == null ? void 0 : o.at(1)) == null ? void 0 : r.trim();
64
+ if (!i) {
65
+ console.warn(`Could not determine tag name for ${e} in ${t}`);
66
+ continue;
67
+ }
68
+ const $ = p.generator._withBuildContext({
61
69
  callerName: e,
62
- isProduction: !1,
70
+ isProduction: n.isProduction,
63
71
  config: {}
64
- });
65
- R.push(`const ${e} = classNameInstance(${JSON.stringify(i.params)});`), v.push(e);
66
- continue;
67
- }
68
- const [w, p] = await B(N, e), n = N.slice(w, p), s = (F = (l = /styled\(([^,]+),/.exec(n)) == null ? void 0 : l.at(1)) == null ? void 0 : F.trim();
69
- if (!s) {
70
- console.warn(`Could not determine tag name for ${e} in ${t}`);
71
- continue;
72
- }
73
- const g = m.generator._withBuildContext({
74
- callerName: e,
75
- isProduction: !1,
76
- config: {}
77
- }), r = {
78
- componentName: e,
79
- tagName: s.replace(/['"`]/g, ""),
80
- tagIsComponent: !1,
81
- classNames: g.classNames,
82
- imports: [],
83
- clientProps: g.clientProps
84
- }, h = /^\w+$/.test(s);
85
- if (r.tagIsComponent = h, h) {
86
- const i = I.some(([a]) => a === s), o = N.match(new RegExp(`import[^;]*${s}[^;]*;`));
87
- if (i) {
88
- const a = P(s), J = `import ${s} from '${t}.astro?configFile=${a}.config';`;
89
- r.imports = [J];
90
- } else if (o) {
91
- const a = o.at(0);
92
- r.imports = [a];
72
+ }), a = {
73
+ componentName: e,
74
+ tagName: i.replace(/['"`]/g, ""),
75
+ tagIsComponent: !1,
76
+ classNames: $.classNames,
77
+ imports: [],
78
+ clientProps: $.clientProps
79
+ }, N = /^\w+$/.test(i);
80
+ if (a.tagIsComponent = N, N) {
81
+ const _ = E.some(([d]) => d === i), R = m.match(new RegExp(`import[^;]*${i}[^;]*;`));
82
+ if (_) {
83
+ const d = P(i), G = `import ${i} from '${t}.astro?configFile=${d}.config';`;
84
+ a.imports = [G];
85
+ } else if (R) {
86
+ const d = R.at(0);
87
+ a.imports = [d];
88
+ }
93
89
  }
90
+ const F = x(f, "astro");
91
+ await v(F, "utf-8").catch(() => !1) || await B(F, { recursive: !0 });
92
+ const C = P(e), J = x(f, "astro", `${C}.config`);
93
+ await L(J, JSON.stringify(a)), g.push(`import ${e} from '${t}.astro?configFile=${C}.config';`), s.push(e);
94
94
  }
95
- const y = S(d, "astro");
96
- await x(y, "utf-8").catch(() => !1) || await K(y, { recursive: !0 });
97
- const C = P(e), E = S(d, "astro", `${C}.config`);
98
- await L(E, JSON.stringify(r)), j.push(`import ${e} from '${t}.astro?configFile=${C}.config';`), v.push(e);
99
- }
100
- return `${j.join(`
95
+ return `${g.join(`
101
96
  `)}
102
- ${R.join(`
97
+ ${l.join(`
103
98
  `)}
104
- export { ${v.join(", ")} };`;
99
+ export { ${s.join(", ")} };`;
100
+ }
101
+ return;
102
+ } catch (c) {
103
+ console.error("Error during file compilation:", c);
104
+ return;
105
105
  }
106
106
  },
107
- handleHotUpdate: async ({ file: t, server: c }) => {
108
- await O(t) && c.restart();
107
+ handleHotUpdate: async function({ file: t, server: o, modules: r }) {
108
+ try {
109
+ if (await D(t)) return await n.generateCss(!1);
110
+ if (!S(t)) return;
111
+ const g = await n.getDestDir(), l = [];
112
+ for (const [s, m] of o.moduleGraph.idToModuleMap)
113
+ s.startsWith(t + ".astro?configFile=") && (o.moduleGraph.invalidateModule(m), l.push(m));
114
+ for (const s of o.moduleGraph.urlToModuleMap.values())
115
+ s.file && s.file.startsWith(g) && (o.moduleGraph.invalidateModule(s), l.push(s));
116
+ return o.ws.send({ type: "update", updates: [] }), [...r, ...l];
117
+ } catch (c) {
118
+ console.error("Error during hot update handling:", c);
119
+ }
109
120
  },
110
121
  watchChange: {
111
- handler: async (t, c) => {
112
- D(t) && c.event !== "delete" && (await O(t) || await u.generateFile(t));
122
+ handler: async function(t, o) {
123
+ try {
124
+ S(t) && o.event !== "delete" && (await D(t) || await n.generateFile(t));
125
+ } catch (r) {
126
+ console.error("Error during watch change handling:", r);
127
+ }
113
128
  }
114
129
  }
115
130
  };
116
131
  };
117
132
  export {
118
- T as default,
119
- T as saltyPlugin
133
+ Q as default,
134
+ Q as saltyPlugin
120
135
  };
package/class-name.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@salty-css/core/generators"),u=r=>{const s=new i.ClassNameGenerator(r),t=a=>{const e=new String(a);return Object.assign(e,{get isClassName(){return!0},variant:(n,c)=>{const o=`${n}-${c}`,l=`${e} ${o}`;return t(l)},generator:s}),e};return t(s.cssClassName)};exports.className=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@salty-css/core/generators"),C=o=>{const c=new m.ClassNameGenerator(o),t=i=>{const e=new String(i);return Object.assign(e,{get isClassName(){return!0},variant:(r,n)=>{const a=`${r}-${n}`,s=`${e} ${a}`;return t(s)},variants:r=>{const n=Object.entries(r).reduce((s,[l,u])=>(s+=` ${l}-${u}`,s),""),a=`${e}${n}`.trim();return t(a)},generator:c}),e};return t(c.cssClassName)};exports.className=C;
package/class-name.d.ts CHANGED
@@ -4,6 +4,7 @@ interface ClassNameMethods<STYLE_PARAMS extends StyledParams> {
4
4
  generator: ClassNameGenerator<STYLE_PARAMS>;
5
5
  isClassName: boolean;
6
6
  variant: (name: string, value: string) => string & ClassNameFunction<STYLE_PARAMS>;
7
+ variants: (variants: Record<string, string>) => string & ClassNameFunction<STYLE_PARAMS>;
7
8
  }
8
9
  type ClassNameFunction<STYLE_PARAMS extends StyledParams> = string & ClassNameMethods<STYLE_PARAMS>;
9
10
  export declare const className: <const STYLE_PARAMS extends StyledParams>(params: STYLE_PARAMS) => ClassNameFunction<STYLE_PARAMS>;
package/class-name.js CHANGED
@@ -1,20 +1,24 @@
1
- import { ClassNameGenerator as l } from "@salty-css/core/generators";
2
- const C = (r) => {
3
- const t = new l(r), e = (a) => {
4
- const s = new String(a);
1
+ import { ClassNameGenerator as u } from "@salty-css/core/generators";
2
+ const $ = (c) => {
3
+ const o = new u(c), e = (i) => {
4
+ const s = new String(i);
5
5
  return Object.assign(s, {
6
6
  get isClassName() {
7
7
  return !0;
8
8
  },
9
- variant: (n, o) => {
10
- const c = `${n}-${o}`, i = `${s} ${c}`;
11
- return e(i);
9
+ variant: (r, n) => {
10
+ const a = `${r}-${n}`, t = `${s} ${a}`;
11
+ return e(t);
12
12
  },
13
- generator: t
13
+ variants: (r) => {
14
+ const n = Object.entries(r).reduce((t, [l, m]) => (t += ` ${l}-${m}`, t), ""), a = `${s}${n}`.trim();
15
+ return e(a);
16
+ },
17
+ generator: o
14
18
  }), s;
15
19
  };
16
- return e(t.cssClassName);
20
+ return e(o.cssClassName);
17
21
  };
18
22
  export {
19
- C as className
23
+ $ as className
20
24
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@salty-css/core/css/dynamic-styles"),n=async(t,a)=>{const s=e.getDynamicStylesClassName(t),y=await e.getDynamicStylesCss(t,a||`.${s}`);return{className:s,css:y}};Object.defineProperty(exports,"getDynamicStylesClassName",{enumerable:!0,get:()=>e.getDynamicStylesClassName});Object.defineProperty(exports,"getDynamicStylesCss",{enumerable:!0,get:()=>e.getDynamicStylesCss});exports.resolveDynamicStyles=n;
@@ -0,0 +1,20 @@
1
+ import { BaseStyles } from '@salty-css/core/types';
2
+ import { getDynamicStylesClassName, getDynamicStylesCss } from '@salty-css/core/css/dynamic-styles';
3
+ export { getDynamicStylesClassName, getDynamicStylesCss };
4
+ /**
5
+ * Resolve dynamic styles for SSR usage inside an `.astro` component.
6
+ *
7
+ * @example
8
+ * ```astro
9
+ * ---
10
+ * import { resolveDynamicStyles } from '@salty-css/astro/dynamic-styles';
11
+ * const { className, css } = await resolveDynamicStyles({ color: 'red' });
12
+ * ---
13
+ * <style set:html={css}></style>
14
+ * <div class={className}><slot/></div>
15
+ * ```
16
+ */
17
+ export declare const resolveDynamicStyles: (styles: BaseStyles, scope?: string) => Promise<{
18
+ className: string;
19
+ css: string;
20
+ }>;
@@ -0,0 +1,11 @@
1
+ import { getDynamicStylesClassName as c, getDynamicStylesCss as m } from "@salty-css/core/css/dynamic-styles";
2
+ import { getDynamicStylesClassName as r, getDynamicStylesCss as i } from "@salty-css/core/css/dynamic-styles";
3
+ const y = async (s, t) => {
4
+ const e = c(s), a = await m(s, t || `.${e}`);
5
+ return { className: e, css: a };
6
+ };
7
+ export {
8
+ r as getDynamicStylesClassName,
9
+ i as getDynamicStylesCss,
10
+ y as resolveDynamicStyles
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@salty-css/core/util"),j=require("@salty-css/core/parsers"),A=["passProps"],O=(p={},t={},y="",d)=>{const{class:v="",className:m,element:k,passProps:i=t.passProps,_vks:u,style:r,...b}=p,n={passProps:i};if(t.attr)for(const[s,e]of Object.entries(t.attr))e!==void 0&&(n[s]=e);d&&Object.assign(n,d);const c={...b};if(t.defaultProps)for(const[s,e]of Object.entries(t.defaultProps))c[s]===void 0&&(c[s]=e);Object.assign(n,c);const f=new Set;for(const s of String(y).split(" "))s&&f.add(s);for(const s of String(v||"").split(" "))s&&f.add(s);for(const s of String(m||"").split(" "))s&&f.add(s);const l={};if(r&&typeof r=="object")for(const[s,e]of Object.entries(r)){const o=j.parseVariableTokens(e);l[s]=o?o.transformed:e}const a=new Set(Array.isArray(u)?u:[]);if(t.propValueKeys)for(const s of t.propValueKeys){const e=`css-${s}`,o=c[e];o!==void 0&&(l[`--props-${S.dashCase(s)}`]=o,a.add(e))}if(t.variantKeys)for(const s of t.variantKeys){const[e,o]=s.split("=");c[e]!==void 0?(f.add(`${e}-${c[e]}`),a.add(e)):o!==void 0&&f.add(`${e}-${o}`)}for(const s of a)i!==!0&&(Array.isArray(i)&&i.includes(s)||typeof i=="string"&&i===s||delete n[s]);for(const s of A)delete n[s];return{class:[...f],style:l,rest:n,element:k||t.element,_vks:[...a]}};exports.resolveAstroProps=O;
@@ -0,0 +1,20 @@
1
+ import { StyledGeneratorClientProps } from '@salty-css/core/generators';
2
+ export interface ResolvedAstroProps {
3
+ class: string[];
4
+ style: Record<string, any>;
5
+ rest: Record<string, any>;
6
+ element?: string;
7
+ _vks: string[];
8
+ }
9
+ /**
10
+ * SSR equivalent of the React `elementFactory`. Takes the raw `Astro.props` of a
11
+ * generated `.astro` Salty component plus the build-time generator props and
12
+ * returns cleaned values ready to apply on the underlying `<Element>` tag:
13
+ *
14
+ * - `class` — array for `class:list`
15
+ * - `style` — object for `style={}`
16
+ * - `rest` — object to `{...spread}` onto the element (variants and `css-*` props removed unless `passProps` allows)
17
+ * - `element` — runtime element override
18
+ * - `_vks` — variant keys consumed at this level, forwarded so wrapping styled components can keep stripping them
19
+ */
20
+ export declare const resolveAstroProps: (astroProps?: Record<string, any>, generatorProps?: StyledGeneratorClientProps, baseClassName?: string, additionalProps?: Record<string, any>) => ResolvedAstroProps;
@@ -0,0 +1,56 @@
1
+ import { dashCase as j } from "@salty-css/core/util";
2
+ import { parseVariableTokens as S } from "@salty-css/core/parsers";
3
+ const $ = ["passProps"], O = (y = {}, t = {}, m = "", d) => {
4
+ const {
5
+ class: u = "",
6
+ className: v,
7
+ element: k,
8
+ passProps: i = t.passProps,
9
+ _vks: p,
10
+ style: l,
11
+ ...b
12
+ } = y, n = { passProps: i };
13
+ if (t.attr)
14
+ for (const [s, e] of Object.entries(t.attr))
15
+ e !== void 0 && (n[s] = e);
16
+ d && Object.assign(n, d);
17
+ const c = { ...b };
18
+ if (t.defaultProps)
19
+ for (const [s, e] of Object.entries(t.defaultProps))
20
+ c[s] === void 0 && (c[s] = e);
21
+ Object.assign(n, c);
22
+ const f = /* @__PURE__ */ new Set();
23
+ for (const s of String(m).split(" ")) s && f.add(s);
24
+ for (const s of String(u || "").split(" ")) s && f.add(s);
25
+ for (const s of String(v || "").split(" ")) s && f.add(s);
26
+ const r = {};
27
+ if (l && typeof l == "object")
28
+ for (const [s, e] of Object.entries(l)) {
29
+ const o = S(e);
30
+ r[s] = o ? o.transformed : e;
31
+ }
32
+ const a = new Set(Array.isArray(p) ? p : []);
33
+ if (t.propValueKeys)
34
+ for (const s of t.propValueKeys) {
35
+ const e = `css-${s}`, o = c[e];
36
+ o !== void 0 && (r[`--props-${j(s)}`] = o, a.add(e));
37
+ }
38
+ if (t.variantKeys)
39
+ for (const s of t.variantKeys) {
40
+ const [e, o] = s.split("=");
41
+ c[e] !== void 0 ? (f.add(`${e}-${c[e]}`), a.add(e)) : o !== void 0 && f.add(`${e}-${o}`);
42
+ }
43
+ for (const s of a)
44
+ i !== !0 && (Array.isArray(i) && i.includes(s) || typeof i == "string" && i === s || delete n[s]);
45
+ for (const s of $) delete n[s];
46
+ return {
47
+ class: [...f],
48
+ style: r,
49
+ rest: n,
50
+ element: k || t.element,
51
+ _vks: [...a]
52
+ };
53
+ };
54
+ export {
55
+ O as resolveAstroProps
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/astro",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.31",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -48,6 +48,18 @@
48
48
  "import": "./class-name.js",
49
49
  "require": "./class-name.cjs"
50
50
  },
51
+ "./element-props": {
52
+ "import": "./element-props.js",
53
+ "require": "./element-props.cjs"
54
+ },
55
+ "./dynamic-styles": {
56
+ "import": "./dynamic-styles.js",
57
+ "require": "./dynamic-styles.cjs"
58
+ },
59
+ "./runtime": {
60
+ "import": "./runtime.js",
61
+ "require": "./runtime.cjs"
62
+ },
51
63
  "./keyframes": {
52
64
  "import": "./keyframes.js",
53
65
  "require": "./keyframes.cjs"
@@ -66,7 +78,7 @@
66
78
  }
67
79
  },
68
80
  "dependencies": {
69
- "@salty-css/core": "^0.1.0-alpha.3",
81
+ "@salty-css/core": "^0.1.0-alpha.31",
70
82
  "astro": "^5.13.2",
71
83
  "vite": "^6.3.5"
72
84
  }
package/runtime.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@salty-css/core/runtime");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
package/runtime.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@salty-css/core/runtime';
package/runtime.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@salty-css/core/runtime";