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