@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.
- package/astro-vite-plugin.cjs +7 -7
- package/astro-vite-plugin.js +88 -97
- 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 _=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(
|
|
5
|
-
const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(
|
|
6
|
-
const Element = ${
|
|
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"),
|
|
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 { ${
|
|
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;
|
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 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
|
|
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
|
-
],
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
},
|
|
23
|
-
for (const n of
|
|
24
|
-
for (const
|
|
25
|
-
if (
|
|
26
|
-
},
|
|
27
|
-
let
|
|
28
|
-
const
|
|
29
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
|
46
|
-
} catch (
|
|
47
|
-
throw console.error("Error during initial CSS generation:",
|
|
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
|
|
45
|
+
var r, a;
|
|
55
46
|
try {
|
|
56
|
-
if (
|
|
57
|
-
const h = await
|
|
47
|
+
if (M(t, [], !t.includes("configFile="))) {
|
|
48
|
+
const h = await o.getDestDir();
|
|
58
49
|
if (/.+\?configFile=(\w+).+/.test(t)) {
|
|
59
|
-
const
|
|
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(
|
|
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(
|
|
69
|
-
const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(
|
|
70
|
-
const Element = ${
|
|
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
|
|
79
|
-
if (
|
|
80
|
-
return await (await
|
|
81
|
-
const
|
|
82
|
-
for (const [
|
|
83
|
-
const d = await
|
|
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
|
|
87
|
-
callerName:
|
|
88
|
-
isProduction:
|
|
77
|
+
const E = d.generator._withBuildContext({
|
|
78
|
+
callerName: e,
|
|
79
|
+
isProduction: o.isProduction,
|
|
89
80
|
config: {}
|
|
90
81
|
});
|
|
91
|
-
w.push(`const ${
|
|
82
|
+
w.push(`const ${e} = classNameInstance(${JSON.stringify(E.params)});`), v.push(e);
|
|
92
83
|
continue;
|
|
93
84
|
}
|
|
94
|
-
const [
|
|
95
|
-
if (!
|
|
96
|
-
console.warn(`Could not determine tag name for ${
|
|
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
|
|
100
|
-
callerName:
|
|
101
|
-
isProduction:
|
|
90
|
+
const N = d.generator._withBuildContext({
|
|
91
|
+
callerName: e,
|
|
92
|
+
isProduction: o.isProduction,
|
|
102
93
|
config: {}
|
|
103
94
|
}), m = {
|
|
104
|
-
componentName:
|
|
105
|
-
tagName:
|
|
95
|
+
componentName: e,
|
|
96
|
+
tagName: c.replace(/['"`]/g, ""),
|
|
106
97
|
tagIsComponent: !1,
|
|
107
|
-
classNames:
|
|
98
|
+
classNames: N.classNames,
|
|
108
99
|
imports: [],
|
|
109
|
-
clientProps:
|
|
110
|
-
},
|
|
111
|
-
if (m.tagIsComponent =
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
const y =
|
|
115
|
-
m.imports = [
|
|
116
|
-
} else if (
|
|
117
|
-
const y =
|
|
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
|
|
123
|
-
const
|
|
124
|
-
await
|
|
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 `${
|
|
117
|
+
return `${i.join(`
|
|
127
118
|
`)}
|
|
128
119
|
${w.join(`
|
|
129
120
|
`)}
|
|
130
|
-
export { ${
|
|
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:
|
|
129
|
+
handleHotUpdate: async function({ file: t, server: r, modules: a }) {
|
|
139
130
|
try {
|
|
140
|
-
if (await
|
|
141
|
-
if (!
|
|
142
|
-
const
|
|
143
|
-
for (const [
|
|
144
|
-
|
|
145
|
-
for (const
|
|
146
|
-
|
|
147
|
-
return
|
|
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,
|
|
144
|
+
handler: async function(t, r) {
|
|
154
145
|
try {
|
|
155
|
-
|
|
156
|
-
} catch (
|
|
157
|
-
console.error("Error during watch change handling:",
|
|
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
|
-
|
|
165
|
-
|
|
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
|
|
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
|
|
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
|
|
86
|
+
"@salty-css/react": "0.2.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@salty-css/react": {
|