@salty-css/astro 0.2.0-fix-astro-fixes-06-2026.3 → 0.2.0

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,12 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("@salty-css/core/compiler/helpers"),L=require("@salty-css/core/compiler/get-function-range"),U=require("@salty-css/core/compiler/salty-compiler"),q=require("@salty-css/core/server"),J=require("@salty-css/core/util"),F=require("fs/promises"),I=require("path"),W=[{name:"react",importMarkers:[/['"]@salty-css\/react(\/[^'"]*)?['"]/],loadTransform:async s=>{const n="@salty-css/react/transform-salty-file";return(s?await s(n):await import(n)).transformSaltyFile}}],T=new Map,V=(s,n)=>{const c=T.get(s.name);if(c)return c;const o=s.loadTransform(n);return T.set(s.name,o),o},z=s=>{for(const n of W)for(const c of n.importMarkers)if(c.test(s))return n},G=(s,n={})=>{let c;const o=new U.SaltyCompiler(s,{mode:n.mode}),b=t=>{const e=Date.now();return import(`${t}?t=${e}`)};let $,j=!1;return o.importFile=async t=>{if(j||!$)return b(t);const e=Date.now();return c=$.ssrLoadModule,$.ssrLoadModule(`${t}?t=${e}`)},{name:"stylegen",configResolved:async function(t){j=t.command==="build";try{await o.generateCss()}catch(e){throw console.error("Error during initial CSS generation:",e),e}},configureServer:function(t){$=t},load:async function(t){var e,l;try{if(M.isSaltyFile(t,[],!t.includes("configFile="))){const h=await o.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const v=new URLSearchParams(t.split("?")[1]).get("configFile");if(!v)return;const p=I.join(h,"astro",v),S=await F.readFile(p,"utf-8");if(!S)return;try{const g=JSON.parse(S),{clientProps:C={},classNames:i="",tagIsComponent:N,tagName:m="div"}=g,_=["import { resolveAstroProps } from '@salty-css/astro/element-props';",...g.imports||[]],O=N?m:`__r.element || ${JSON.stringify(C.element||m)}`;return`---
2
- ${_.join(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("@salty-css/core/compiler/helpers"),b=require("@salty-css/core/compiler/get-function-range"),A=require("@salty-css/core/compiler/salty-compiler"),O=require("@salty-css/core/server"),P=require("@salty-css/core/util"),F=require("fs/promises"),k=require("path"),L=[{name:"react",importMarkers:[/['"]@salty-css\/react(\/[^'"]*)?['"]/],loadTransform:async s=>{const n="@salty-css/react/transform-salty-file";return(s?await s(n):await import(n)).transformSaltyFile}}],q=new Map,B=(s,n)=>{const l=q.get(s.name);if(l)return l;const e=s.loadTransform(n);return q.set(s.name,e),e},U=s=>{for(const n of L)for(const l of n.importMarkers)if(l.test(s))return n},J=(s,n={})=>{let l;const e=new A.SaltyCompiler(s,{mode:n.mode});return{name:"stylegen",configureServer:function(t){e.importFile=async o=>{const a=Date.now();return l=t.ssrLoadModule,t.ssrLoadModule(`${o}?t=${a}`)}},configResolved:async function(){try{await e.generateCss()}catch(t){throw console.error("Error during initial CSS generation:",t),t}},load:async function(t){var o,a;try{if(_.isSaltyFile(t,[],!t.includes("configFile="))){const h=await e.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const C=new URLSearchParams(t.split("?")[1]).get("configFile");if(!C)return;const f=k.join(h,"astro",C),S=await F.readFile(f,"utf-8");if(!S)return;try{const g=JSON.parse(S),{clientProps:$={},classNames:c="",tagIsComponent:N,tagName:m="div"}=g,v=["import { resolveAstroProps } from '@salty-css/astro/element-props';",...g.imports||[]],I=N?m:`__r.element || ${JSON.stringify($.element||m)}`;return`---
2
+ ${v.join(`
3
3
  `)}
4
- const __gp = ${JSON.stringify(C)};
5
- const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
6
- const Element = ${O};
4
+ const __gp = ${JSON.stringify($)};
5
+ const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(c)});
6
+ const Element = ${I};
7
7
  ---
8
- <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`}catch(g){console.error("Error parsing config file:",g);return}}const d=await F.readFile(t,"utf-8"),f=z(d);if(f)return await(await V(f,c))(o,t);const a=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],y=[],R=[],H=await o.compileSaltyFile(t,h),D=Object.entries(H.contents);for(const[r,v]of D){const p=await M.resolveExportValue(v,1);if(!p.generator)continue;if(p.isClassName){const k=p.generator._withBuildContext({callerName:r,isProduction:o.isProduction,config:{}});y.push(`const ${r} = classNameInstance(${JSON.stringify(k.params)});`),R.push(r);continue}const[S,g]=await L.getFunctionRange(d,r),C=d.slice(S,g),i=(l=(e=/styled\(([^,]+),/.exec(C))==null?void 0:e.at(1))==null?void 0:l.trim();if(!i){console.warn(`Could not determine tag name for ${r} in ${t}`);continue}const N=p.generator._withBuildContext({callerName:r,isProduction:o.isProduction,config:{}}),m={componentName:r,tagName:i.replace(/['"`]/g,""),tagIsComponent:!1,classNames:N.classNames,imports:[],clientProps:N.clientProps},x=/^\w+$/.test(i);if(m.tagIsComponent=x,x){const k=D.some(([w])=>w===i),P=d.match(new RegExp(`import[^;]*${i}[^;]*;`));if(k){const w=J.toHash(i),B=`import ${i} from '${t}.astro?configFile=${w}.config';`;m.imports=[B]}else if(P){const w=P.at(0);m.imports=[w]}}const _=I.join(h,"astro");await F.readFile(_,"utf-8").catch(()=>!1)||await F.mkdir(_,{recursive:!0});const E=J.toHash(r),A=I.join(h,"astro",`${E}.config`);await F.writeFile(A,JSON.stringify(m)),a.push(`import ${r} from '${t}.astro?configFile=${E}.config';`),R.push(r)}return`${a.join(`
8
+ <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`}catch(g){console.error("Error parsing config file:",g);return}}const d=await F.readFile(t,"utf-8"),p=U(d);if(p)return await(await B(p,l))(e,t);const i=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],y=[],M=[],T=await e.compileSaltyFile(t,h),j=Object.entries(T.contents);for(const[r,C]of j){const f=await _.resolveExportValue(C,1);if(!f.generator)continue;if(f.isClassName){const E=f.generator._withBuildContext({callerName:r,isProduction:e.isProduction,config:{}});y.push(`const ${r} = classNameInstance(${JSON.stringify(E.params)});`),M.push(r);continue}const[S,g]=await b.getFunctionRange(d,r),$=d.slice(S,g),c=(a=(o=/styled\(([^,]+),/.exec($))==null?void 0:o.at(1))==null?void 0:a.trim();if(!c){console.warn(`Could not determine tag name for ${r} in ${t}`);continue}const N=f.generator._withBuildContext({callerName:r,isProduction:e.isProduction,config:{}}),m={componentName:r,tagName:c.replace(/['"`]/g,""),tagIsComponent:!1,classNames:N.classNames,imports:[],clientProps:N.clientProps},R=/^\w+$/.test(c);if(m.tagIsComponent=R,R){const E=j.some(([w])=>w===c),D=d.match(new RegExp(`import[^;]*${c}[^;]*;`));if(E){const w=P.toHash(c),H=`import ${c} from '${t}.astro?configFile=${w}.config';`;m.imports=[H]}else if(D){const w=D.at(0);m.imports=[w]}}const v=k.join(h,"astro");await F.readFile(v,"utf-8").catch(()=>!1)||await F.mkdir(v,{recursive:!0});const x=P.toHash(r),G=k.join(h,"astro",`${x}.config`);await F.writeFile(G,JSON.stringify(m)),i.push(`import ${r} from '${t}.astro?configFile=${x}.config';`),M.push(r)}return`${i.join(`
9
9
  `)}
10
10
  ${y.join(`
11
11
  `)}
12
- export { ${R.join(", ")} };`}return}catch(u){console.error("Error during file compilation:",u);return}},handleHotUpdate:async function({file:t,server:e,modules:l}){try{if(await q.checkShouldRestart(t))return await o.generateCss(!1);if(!M.isSaltyFile(t))return;const d=await o.getDestDir(),f=[];for(const[a,y]of e.moduleGraph.idToModuleMap)a.startsWith(t+".astro?configFile=")&&(e.moduleGraph.invalidateModule(y),f.push(y));for(const a of e.moduleGraph.urlToModuleMap.values())a.file&&a.file.startsWith(d)&&(e.moduleGraph.invalidateModule(a),f.push(a));return e.ws.send({type:"update",updates:[]}),[...l,...f]}catch(u){console.error("Error during hot update handling:",u)}},watchChange:{handler:async function(t,e){try{M.isSaltyFile(t)&&e.event!=="delete"&&(await q.checkShouldRestart(t)||await o.generateFile(t))}catch(l){console.error("Error during watch change handling:",l)}}}}};exports.default=G;exports.saltyPlugin=G;
12
+ export { ${M.join(", ")} };`}return}catch(u){console.error("Error during file compilation:",u);return}},handleHotUpdate:async function({file:t,server:o,modules:a}){try{if(await O.checkShouldRestart(t))return await e.generateCss(!1);if(!_.isSaltyFile(t))return;const d=await e.getDestDir(),p=[];for(const[i,y]of o.moduleGraph.idToModuleMap)i.startsWith(t+".astro?configFile=")&&(o.moduleGraph.invalidateModule(y),p.push(y));for(const i of o.moduleGraph.urlToModuleMap.values())i.file&&i.file.startsWith(d)&&(o.moduleGraph.invalidateModule(i),p.push(i));return o.ws.send({type:"update",updates:[]}),[...a,...p]}catch(u){console.error("Error during hot update handling:",u)}},watchChange:{handler:async function(t,o){try{_.isSaltyFile(t)&&o.event!=="delete"&&(await O.checkShouldRestart(t)||await e.generateFile(t))}catch(a){console.error("Error during watch change handling:",a)}}}}};exports.default=J;exports.saltyPlugin=J;
@@ -1,11 +1,11 @@
1
- import { isSaltyFile as I, resolveExportValue as b } from "@salty-css/core/compiler/helpers";
2
- import { getFunctionRange as U } from "@salty-css/core/compiler/get-function-range";
3
- import { SaltyCompiler as W } from "@salty-css/core/compiler/salty-compiler";
4
- import { checkShouldRestart as P } from "@salty-css/core/server";
5
- import { toHash as G } from "@salty-css/core/util";
6
- import { readFile as R, mkdir as V, writeFile as q } from "fs/promises";
1
+ import { isSaltyFile as M, resolveExportValue as H } from "@salty-css/core/compiler/helpers";
2
+ import { getFunctionRange as L } from "@salty-css/core/compiler/get-function-range";
3
+ import { SaltyCompiler as B } from "@salty-css/core/compiler/salty-compiler";
4
+ import { checkShouldRestart as j } from "@salty-css/core/server";
5
+ import { toHash as J } from "@salty-css/core/util";
6
+ import { readFile as R, mkdir as U, writeFile as W } from "fs/promises";
7
7
  import { join as k } from "path";
8
- const z = [
8
+ const b = [
9
9
  {
10
10
  name: "react",
11
11
  importMarkers: [/['"]@salty-css\/react(\/[^'"]*)?['"]/],
@@ -14,60 +14,51 @@ const z = [
14
14
  return (s ? await s(n) : await import(n)).transformSaltyFile;
15
15
  }
16
16
  }
17
- ], T = /* @__PURE__ */ new Map(), K = (s, n) => {
18
- const c = T.get(s.name);
19
- if (c) return c;
20
- const e = s.loadTransform(n);
21
- return T.set(s.name, e), e;
22
- }, Q = (s) => {
23
- for (const n of z)
24
- for (const c of n.importMarkers)
25
- if (c.test(s)) return n;
26
- }, nt = (s, n = {}) => {
27
- let c;
28
- const e = new W(s, { mode: n.mode }), A = (t) => {
29
- const o = Date.now();
30
- return import(
31
- /* @vite-ignore */
32
- `${t}?t=${o}`
33
- );
34
- };
35
- let F, D = !1;
36
- return e.importFile = async (t) => {
37
- if (D || !F) return A(t);
38
- const o = Date.now();
39
- return c = F.ssrLoadModule, F.ssrLoadModule(`${t}?t=${o}`);
40
- }, {
17
+ ], P = /* @__PURE__ */ new Map(), V = (s, n) => {
18
+ const l = P.get(s.name);
19
+ if (l) return l;
20
+ const o = s.loadTransform(n);
21
+ return P.set(s.name, o), o;
22
+ }, q = (s) => {
23
+ for (const n of b)
24
+ for (const l of n.importMarkers)
25
+ if (l.test(s)) return n;
26
+ }, rt = (s, n = {}) => {
27
+ let l;
28
+ const o = new B(s, { mode: n.mode });
29
+ return {
41
30
  name: "stylegen",
42
- configResolved: async function(t) {
43
- D = t.command === "build";
31
+ configureServer: function(t) {
32
+ o.importFile = async (r) => {
33
+ const a = Date.now();
34
+ return l = t.ssrLoadModule, t.ssrLoadModule(`${r}?t=${a}`);
35
+ };
36
+ },
37
+ configResolved: async function() {
44
38
  try {
45
- await e.generateCss();
46
- } catch (o) {
47
- throw console.error("Error during initial CSS generation:", o), o;
39
+ await o.generateCss();
40
+ } catch (t) {
41
+ throw console.error("Error during initial CSS generation:", t), t;
48
42
  }
49
43
  },
50
- configureServer: function(t) {
51
- F = t;
52
- },
53
44
  load: async function(t) {
54
- var o, l;
45
+ var r, a;
55
46
  try {
56
- if (I(t, [], !t.includes("configFile="))) {
57
- const h = await e.getDestDir();
47
+ if (M(t, [], !t.includes("configFile="))) {
48
+ const h = await o.getDestDir();
58
49
  if (/.+\?configFile=(\w+).+/.test(t)) {
59
- const $ = new URLSearchParams(t.split("?")[1]).get("configFile");
50
+ const F = new URLSearchParams(t.split("?")[1]).get("configFile");
51
+ if (!F) return;
52
+ const d = k(h, "astro", F), $ = await R(d, "utf-8");
60
53
  if (!$) return;
61
- const d = k(h, "astro", $), C = await R(d, "utf-8");
62
- if (!C) return;
63
54
  try {
64
- const g = JSON.parse(C), { clientProps: N = {}, classNames: i = "", tagIsComponent: v, tagName: m = "div" } = g, S = ["import { resolveAstroProps } from '@salty-css/astro/element-props';", ...g.imports || []], j = v ? m : `__r.element || ${JSON.stringify(N.element || m)}`;
55
+ const g = JSON.parse($), { clientProps: C = {}, classNames: c = "", tagIsComponent: N, tagName: m = "div" } = g, S = ["import { resolveAstroProps } from '@salty-css/astro/element-props';", ...g.imports || []], D = N ? m : `__r.element || ${JSON.stringify(C.element || m)}`;
65
56
  return `---
66
57
  ${S.join(`
67
58
  `)}
68
- const __gp = ${JSON.stringify(N)};
69
- const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
70
- const Element = ${j};
59
+ const __gp = ${JSON.stringify(C)};
60
+ const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(c)});
61
+ const Element = ${D};
71
62
  ---
72
63
  <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`;
73
64
  } catch (g) {
@@ -75,59 +66,59 @@ const z = [
75
66
  return;
76
67
  }
77
68
  }
78
- const u = await R(t, "utf-8"), p = Q(u);
79
- if (p)
80
- return await (await K(p, c))(e, t);
81
- const a = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], w = [], _ = [], B = await e.compileSaltyFile(t, h), O = Object.entries(B.contents);
82
- for (const [r, $] of O) {
83
- const d = await b($, 1);
69
+ const p = await R(t, "utf-8"), u = q(p);
70
+ if (u)
71
+ return await (await V(u, l))(o, t);
72
+ const i = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], w = [], v = [], G = await o.compileSaltyFile(t, h), I = Object.entries(G.contents);
73
+ for (const [e, F] of I) {
74
+ const d = await H(F, 1);
84
75
  if (!d.generator) continue;
85
76
  if (d.isClassName) {
86
- const M = d.generator._withBuildContext({
87
- callerName: r,
88
- isProduction: e.isProduction,
77
+ const E = d.generator._withBuildContext({
78
+ callerName: e,
79
+ isProduction: o.isProduction,
89
80
  config: {}
90
81
  });
91
- w.push(`const ${r} = classNameInstance(${JSON.stringify(M.params)});`), _.push(r);
82
+ w.push(`const ${e} = classNameInstance(${JSON.stringify(E.params)});`), v.push(e);
92
83
  continue;
93
84
  }
94
- const [C, g] = await U(u, r), N = u.slice(C, g), i = (l = (o = /styled\(([^,]+),/.exec(N)) == null ? void 0 : o.at(1)) == null ? void 0 : l.trim();
95
- if (!i) {
96
- console.warn(`Could not determine tag name for ${r} in ${t}`);
85
+ const [$, g] = await L(p, e), C = p.slice($, g), c = (a = (r = /styled\(([^,]+),/.exec(C)) == null ? void 0 : r.at(1)) == null ? void 0 : a.trim();
86
+ if (!c) {
87
+ console.warn(`Could not determine tag name for ${e} in ${t}`);
97
88
  continue;
98
89
  }
99
- const v = d.generator._withBuildContext({
100
- callerName: r,
101
- isProduction: e.isProduction,
90
+ const N = d.generator._withBuildContext({
91
+ callerName: e,
92
+ isProduction: o.isProduction,
102
93
  config: {}
103
94
  }), m = {
104
- componentName: r,
105
- tagName: i.replace(/['"`]/g, ""),
95
+ componentName: e,
96
+ tagName: c.replace(/['"`]/g, ""),
106
97
  tagIsComponent: !1,
107
- classNames: v.classNames,
98
+ classNames: N.classNames,
108
99
  imports: [],
109
- clientProps: v.clientProps
110
- }, x = /^\w+$/.test(i);
111
- if (m.tagIsComponent = x, x) {
112
- const M = O.some(([y]) => y === i), J = u.match(new RegExp(`import[^;]*${i}[^;]*;`));
113
- if (M) {
114
- const y = G(i), L = `import ${i} from '${t}.astro?configFile=${y}.config';`;
115
- m.imports = [L];
116
- } else if (J) {
117
- const y = J.at(0);
100
+ clientProps: N.clientProps
101
+ }, _ = /^\w+$/.test(c);
102
+ if (m.tagIsComponent = _, _) {
103
+ const E = I.some(([y]) => y === c), O = p.match(new RegExp(`import[^;]*${c}[^;]*;`));
104
+ if (E) {
105
+ const y = J(c), A = `import ${c} from '${t}.astro?configFile=${y}.config';`;
106
+ m.imports = [A];
107
+ } else if (O) {
108
+ const y = O.at(0);
118
109
  m.imports = [y];
119
110
  }
120
111
  }
121
112
  const S = k(h, "astro");
122
- await R(S, "utf-8").catch(() => !1) || await V(S, { recursive: !0 });
123
- const E = G(r), H = k(h, "astro", `${E}.config`);
124
- await q(H, JSON.stringify(m)), a.push(`import ${r} from '${t}.astro?configFile=${E}.config';`), _.push(r);
113
+ await R(S, "utf-8").catch(() => !1) || await U(S, { recursive: !0 });
114
+ const x = J(e), T = k(h, "astro", `${x}.config`);
115
+ await W(T, JSON.stringify(m)), i.push(`import ${e} from '${t}.astro?configFile=${x}.config';`), v.push(e);
125
116
  }
126
- return `${a.join(`
117
+ return `${i.join(`
127
118
  `)}
128
119
  ${w.join(`
129
120
  `)}
130
- export { ${_.join(", ")} };`;
121
+ export { ${v.join(", ")} };`;
131
122
  }
132
123
  return;
133
124
  } catch (f) {
@@ -135,32 +126,32 @@ export { ${_.join(", ")} };`;
135
126
  return;
136
127
  }
137
128
  },
138
- handleHotUpdate: async function({ file: t, server: o, modules: l }) {
129
+ handleHotUpdate: async function({ file: t, server: r, modules: a }) {
139
130
  try {
140
- if (await P(t)) return await e.generateCss(!1);
141
- if (!I(t)) return;
142
- const u = await e.getDestDir(), p = [];
143
- for (const [a, w] of o.moduleGraph.idToModuleMap)
144
- a.startsWith(t + ".astro?configFile=") && (o.moduleGraph.invalidateModule(w), p.push(w));
145
- for (const a of o.moduleGraph.urlToModuleMap.values())
146
- a.file && a.file.startsWith(u) && (o.moduleGraph.invalidateModule(a), p.push(a));
147
- return o.ws.send({ type: "update", updates: [] }), [...l, ...p];
131
+ if (await j(t)) return await o.generateCss(!1);
132
+ if (!M(t)) return;
133
+ const p = await o.getDestDir(), u = [];
134
+ for (const [i, w] of r.moduleGraph.idToModuleMap)
135
+ i.startsWith(t + ".astro?configFile=") && (r.moduleGraph.invalidateModule(w), u.push(w));
136
+ for (const i of r.moduleGraph.urlToModuleMap.values())
137
+ i.file && i.file.startsWith(p) && (r.moduleGraph.invalidateModule(i), u.push(i));
138
+ return r.ws.send({ type: "update", updates: [] }), [...a, ...u];
148
139
  } catch (f) {
149
140
  console.error("Error during hot update handling:", f);
150
141
  }
151
142
  },
152
143
  watchChange: {
153
- handler: async function(t, o) {
144
+ handler: async function(t, r) {
154
145
  try {
155
- I(t) && o.event !== "delete" && (await P(t) || await e.generateFile(t));
156
- } catch (l) {
157
- console.error("Error during watch change handling:", l);
146
+ M(t) && r.event !== "delete" && (await j(t) || await o.generateFile(t));
147
+ } catch (a) {
148
+ console.error("Error during watch change handling:", a);
158
149
  }
159
150
  }
160
151
  }
161
152
  };
162
153
  };
163
154
  export {
164
- nt as default,
165
- nt as saltyPlugin
155
+ rt as default,
156
+ rt as saltyPlugin
166
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/astro",
3
- "version": "0.2.0-fix-astro-fixes-06-2026.3",
3
+ "version": "0.2.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -78,12 +78,12 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@salty-css/core": "0.2.0-fix-astro-fixes-06-2026.3",
81
+ "@salty-css/core": "0.2.0",
82
82
  "astro": "^5.13.2",
83
83
  "vite": "^6.3.5"
84
84
  },
85
85
  "peerDependencies": {
86
- "@salty-css/react": "0.2.0-fix-astro-fixes-06-2026.3"
86
+ "@salty-css/react": "0.2.0"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@salty-css/react": {