@salty-css/astro 0.1.0-refactor-add-additional-paths-to-config-cache.1 → 0.1.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 S=require("@salty-css/core/compiler/helpers"),G=require("@salty-css/core/compiler/get-function-range"),j=require("@salty-css/core/server"),I=require("@salty-css/core/util"),f=require("fs/promises"),x=require("path"),M=D=>{const n=D.compiler;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(S.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:N,tagName:a="div"}=p,$=["import { resolveAstroProps } from '@salty-css/astro/element-props';",...p.imports||[]],R=N?a:`__r.element || ${JSON.stringify(F.element||a)}`;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(F)};
5
- const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
6
- const Element = ${R};
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(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"),O=await n.compileSaltyFile(t,d),E=Object.entries(O.contents);for(const[o,y]of E){const m=await S.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 G.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 N=m.generator._withBuildContext({callerName:o,isProduction:n.isProduction,config:{}}),a={componentName:o,tagName:i.replace(/['"`]/g,""),tagIsComponent:!1,classNames:N.classNames,imports:[],clientProps:N.clientProps},v=/^\w+$/.test(i);if(a.tagIsComponent=v,v){const _=E.some(([g])=>g===i),P=u.match(new RegExp(`import[^;]*${i}[^;]*;`));if(_){const g=I.toHash(i),J=`import ${i} from '${t}.astro?configFile=${g}.config';`;a.imports=[J]}else if(P){const g=P.at(0);a.imports=[g]}}const $=x.join(d,"astro");await f.readFile($,"utf-8").catch(()=>!1)||await f.mkdir($,{recursive:!0});const C=I.toHash(o),q=x.join(d,"astro",`${C}.config`);await f.writeFile(q,JSON.stringify(a)),h.push(`import ${o} from '${t}.astro?configFile=${C}.config';`),s.push(o)}return`${h.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
- ${l.join(`
10
+ ${y.join(`
11
11
  `)}
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(!S.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{S.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;
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,14 +1,10 @@
1
- import { SaltyCompiler, SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
1
+ import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
2
2
  import { PluginOption } from 'vite';
3
3
  export interface SaltyAstroPluginOptions {
4
4
  /**
5
5
  * Explicit build mode. Defaults to NODE_ENV-based detection.
6
6
  */
7
7
  mode?: SaltyCompilerMode;
8
- /**
9
- * Reuse an existing SaltyCompiler instance instead of creating a new one.
10
- */
11
- compiler: SaltyCompiler;
12
8
  }
13
- export declare const saltyPlugin: (options: SaltyAstroPluginOptions) => PluginOption;
9
+ export declare const saltyPlugin: (dir: string, options?: SaltyAstroPluginOptions) => PluginOption;
14
10
  export default saltyPlugin;
@@ -1,134 +1,157 @@
1
- import { isSaltyFile as v, resolveExportValue as G } from "@salty-css/core/compiler/helpers";
2
- import { getFunctionRange as A } from "@salty-css/core/compiler/get-function-range";
3
- import { checkShouldRestart as D } from "@salty-css/core/server";
4
- import { toHash as P } from "@salty-css/core/util";
5
- import { readFile as S, mkdir as H, writeFile as k } from "fs/promises";
6
- import { join as x } from "path";
7
- const q = (M) => {
8
- const n = M.compiler;
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
+ import { join as k } from "path";
8
+ const b = [
9
+ {
10
+ name: "react",
11
+ importMarkers: [/['"]@salty-css\/react(\/[^'"]*)?['"]/],
12
+ loadTransform: async (s) => {
13
+ const n = "@salty-css/react/transform-salty-file";
14
+ return (s ? await s(n) : await import(n)).transformSaltyFile;
15
+ }
16
+ }
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 });
9
29
  return {
10
30
  name: "stylegen",
11
31
  configureServer: function(t) {
12
- n.importFile = async (o) => {
13
- const r = Date.now();
14
- return t.ssrLoadModule(`${o}?t=${r}`);
32
+ o.importFile = async (r) => {
33
+ const a = Date.now();
34
+ return l = t.ssrLoadModule, t.ssrLoadModule(`${r}?t=${a}`);
15
35
  };
16
36
  },
17
37
  configResolved: async function() {
18
38
  try {
19
- await n.generateCss();
39
+ await o.generateCss();
20
40
  } catch (t) {
21
41
  throw console.error("Error during initial CSS generation:", t), t;
22
42
  }
23
43
  },
24
44
  load: async function(t) {
25
- var o, r;
45
+ var r, a;
26
46
  try {
27
- if (v(t)) {
28
- const f = await n.getDestDir();
47
+ if (M(t, [], !t.includes("configFile="))) {
48
+ const h = await o.getDestDir();
29
49
  if (/.+\?configFile=(\w+).+/.test(t)) {
30
- const h = new URLSearchParams(t.split("?")[1]).get("configFile");
31
- if (!h) return;
32
- const p = x(f, "astro", h), y = await S(p, "utf-8");
33
- if (!y) return;
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");
53
+ if (!$) return;
34
54
  try {
35
- 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)}`;
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)}`;
36
56
  return `---
37
- ${F.join(`
57
+ ${S.join(`
38
58
  `)}
39
- const __gp = ${JSON.stringify(w)};
40
- const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(i)});
41
- const Element = ${I};
59
+ const __gp = ${JSON.stringify(C)};
60
+ const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(c)});
61
+ const Element = ${D};
42
62
  ---
43
63
  <Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`;
44
- } catch (u) {
45
- console.error("Error parsing config file:", u);
64
+ } catch (g) {
65
+ console.error("Error parsing config file:", g);
46
66
  return;
47
67
  }
48
68
  }
49
- const g = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], l = [], s = [], m = await S(t, "utf-8"), O = await n.compileSaltyFile(t, f), E = Object.entries(O.contents);
50
- for (const [e, h] of E) {
51
- const p = await G(h, 1);
52
- if (!p.generator) continue;
53
- if (p.isClassName) {
54
- const _ = p.generator._withBuildContext({
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);
75
+ if (!d.generator) continue;
76
+ if (d.isClassName) {
77
+ const E = d.generator._withBuildContext({
55
78
  callerName: e,
56
- isProduction: n.isProduction,
79
+ isProduction: o.isProduction,
57
80
  config: {}
58
81
  });
59
- l.push(`const ${e} = classNameInstance(${JSON.stringify(_.params)});`), s.push(e);
82
+ w.push(`const ${e} = classNameInstance(${JSON.stringify(E.params)});`), v.push(e);
60
83
  continue;
61
84
  }
62
- const [y, u] = await A(m, e), w = m.slice(y, u), i = (r = (o = /styled\(([^,]+),/.exec(w)) == null ? void 0 : o.at(1)) == null ? void 0 : r.trim();
63
- if (!i) {
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) {
64
87
  console.warn(`Could not determine tag name for ${e} in ${t}`);
65
88
  continue;
66
89
  }
67
- const $ = p.generator._withBuildContext({
90
+ const N = d.generator._withBuildContext({
68
91
  callerName: e,
69
- isProduction: n.isProduction,
92
+ isProduction: o.isProduction,
70
93
  config: {}
71
- }), a = {
94
+ }), m = {
72
95
  componentName: e,
73
- tagName: i.replace(/['"`]/g, ""),
96
+ tagName: c.replace(/['"`]/g, ""),
74
97
  tagIsComponent: !1,
75
- classNames: $.classNames,
98
+ classNames: N.classNames,
76
99
  imports: [],
77
- clientProps: $.clientProps
78
- }, N = /^\w+$/.test(i);
79
- if (a.tagIsComponent = N, N) {
80
- const _ = E.some(([d]) => d === i), R = m.match(new RegExp(`import[^;]*${i}[^;]*;`));
81
- if (_) {
82
- const d = P(i), J = `import ${i} from '${t}.astro?configFile=${d}.config';`;
83
- a.imports = [J];
84
- } else if (R) {
85
- const d = R.at(0);
86
- a.imports = [d];
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);
109
+ m.imports = [y];
87
110
  }
88
111
  }
89
- const F = x(f, "astro");
90
- await S(F, "utf-8").catch(() => !1) || await H(F, { recursive: !0 });
91
- const C = P(e), j = x(f, "astro", `${C}.config`);
92
- await k(j, JSON.stringify(a)), g.push(`import ${e} from '${t}.astro?configFile=${C}.config';`), s.push(e);
112
+ const S = k(h, "astro");
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);
93
116
  }
94
- return `${g.join(`
117
+ return `${i.join(`
95
118
  `)}
96
- ${l.join(`
119
+ ${w.join(`
97
120
  `)}
98
- export { ${s.join(", ")} };`;
121
+ export { ${v.join(", ")} };`;
99
122
  }
100
123
  return;
101
- } catch (c) {
102
- console.error("Error during file compilation:", c);
124
+ } catch (f) {
125
+ console.error("Error during file compilation:", f);
103
126
  return;
104
127
  }
105
128
  },
106
- handleHotUpdate: async function({ file: t, server: o, modules: r }) {
129
+ handleHotUpdate: async function({ file: t, server: r, modules: a }) {
107
130
  try {
108
- if (await D(t)) return await n.generateCss(!1);
109
- if (!v(t)) return;
110
- const g = await n.getDestDir(), l = [];
111
- for (const [s, m] of o.moduleGraph.idToModuleMap)
112
- s.startsWith(t + ".astro?configFile=") && (o.moduleGraph.invalidateModule(m), l.push(m));
113
- for (const s of o.moduleGraph.urlToModuleMap.values())
114
- s.file && s.file.startsWith(g) && (o.moduleGraph.invalidateModule(s), l.push(s));
115
- return o.ws.send({ type: "update", updates: [] }), [...r, ...l];
116
- } catch (c) {
117
- console.error("Error during hot update handling:", c);
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];
139
+ } catch (f) {
140
+ console.error("Error during hot update handling:", f);
118
141
  }
119
142
  },
120
143
  watchChange: {
121
- handler: async function(t, o) {
144
+ handler: async function(t, r) {
122
145
  try {
123
- v(t) && o.event !== "delete" && (await D(t) || await n.generateFile(t));
124
- } catch (r) {
125
- console.error("Error during watch change handling:", r);
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);
126
149
  }
127
150
  }
128
151
  }
129
152
  };
130
153
  };
131
154
  export {
132
- q as default,
133
- q as saltyPlugin
155
+ rt as default,
156
+ rt as saltyPlugin
134
157
  };
@@ -0,0 +1,12 @@
1
+ import { SaltyCompiler } from '@salty-css/core/compiler/salty-compiler';
2
+ type Importer = undefined | ((path: string) => Promise<any>);
3
+ export type SaltyFileTransform = (compiler: SaltyCompiler, file: string) => Promise<string | undefined>;
4
+ export interface FrameworkEntry {
5
+ name: string;
6
+ importMarkers: RegExp[];
7
+ loadTransform: (importer: Importer) => Promise<SaltyFileTransform>;
8
+ }
9
+ export declare const frameworkRegistry: FrameworkEntry[];
10
+ export declare const getFrameworkTransform: (entry: FrameworkEntry, importer: Importer) => Promise<SaltyFileTransform>;
11
+ export declare const detectFramework: (source: string) => FrameworkEntry | undefined;
12
+ export {};
package/integration.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@salty-css/core/compiler/salty-compiler"),s=require("@salty-css/core/compiler/copy-config-cache"),g=require("./astro-vite-plugin.cjs"),d=require("path"),f=require("url"),a=(n={})=>{let e,t;return{name:"astro-salty-integration",hooks:{"astro:config:setup":({config:o,updateConfig:r})=>{const{srcDir:i="src",rootDir:c=o.root.pathname,mode:l}=n;t=d.join(c,i),e=new u.SaltyCompiler(t,{mode:l}),r({vite:{plugins:[g.default({compiler:e})]}})},"astro:build:done":async({dir:o})=>{if(!e||!t||!e.isProduction)return;const r=f.fileURLToPath(o),i=s.resolveCopyConfigCacheDestinations(n.copyConfigCache,r,t);await s.copyConfigCacheTo(e,i)}}}};exports.default=a;exports.saltyIntegration=a;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./astro-vite-plugin.cjs"),u=require("path"),t=(e={})=>({name:"astro-salty-integration",hooks:{"astro:config:setup":({config:r,updateConfig:o})=>{const{srcDir:i="src",rootDir:n=r.root.pathname}=e,s=u.join(n,i);o({vite:{plugins:[a.default(s)]}})}}});exports.default=t;exports.saltyIntegration=t;
package/integration.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { AstroIntegration } from 'astro';
2
- import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
3
- import { CopyConfigCacheOption } from '@salty-css/core/compiler/copy-config-cache';
4
2
  interface SaltyIntegrationOptions {
5
3
  /**
6
4
  * The source directory where SaltyCSS Config is located.
@@ -12,20 +10,6 @@ interface SaltyIntegrationOptions {
12
10
  * Default is the current directory of the Astro configuration.
13
11
  */
14
12
  rootDir?: string;
15
- /**
16
- * Explicit build mode. Defaults to NODE_ENV-based detection.
17
- */
18
- mode?: SaltyCompilerMode;
19
- /**
20
- * Where to copy the Salty `config-cache.json` after a production build.
21
- *
22
- * - `true` (default) → copy to Astro's `dist` output dir.
23
- * - `false` → no copy.
24
- * - `string | string[]` → copy to the default destination PLUS each listed path.
25
- * Useful for adapters that emit a separate server bundle (e.g. Cloudflare's
26
- * `dist/_worker.js/`, Vercel's `.vercel/output/functions/...`).
27
- */
28
- copyConfigCache?: CopyConfigCacheOption;
29
13
  }
30
14
  export declare const saltyIntegration: (options?: SaltyIntegrationOptions) => AstroIntegration;
31
15
  export default saltyIntegration;
package/integration.js CHANGED
@@ -1,28 +1,19 @@
1
- import { SaltyCompiler as c } from "@salty-css/core/compiler/salty-compiler";
2
- import { resolveCopyConfigCacheDestinations as m, copyConfigCacheTo as l } from "@salty-css/core/compiler/copy-config-cache";
3
- import f from "./astro-vite-plugin.js";
4
- import { join as p } from "path";
5
- import { fileURLToPath as u } from "url";
6
- const D = (e = {}) => {
7
- let o, t;
8
- return {
9
- name: "astro-salty-integration",
10
- hooks: {
11
- "astro:config:setup": ({ config: r, updateConfig: i }) => {
12
- const { srcDir: n = "src", rootDir: a = r.root.pathname, mode: s } = e;
13
- t = p(a, n), o = new c(t, { mode: s }), i({
14
- vite: { plugins: [f({ compiler: o })] }
15
- });
16
- },
17
- "astro:build:done": async ({ dir: r }) => {
18
- if (!o || !t || !o.isProduction) return;
19
- const i = u(r), n = m(e.copyConfigCache, i, t);
20
- await l(o, n);
21
- }
1
+ import a from "./astro-vite-plugin.js";
2
+ import { join as e } from "path";
3
+ const l = (t = {}) => ({
4
+ name: "astro-salty-integration",
5
+ hooks: {
6
+ "astro:config:setup": ({ config: o, updateConfig: r }) => {
7
+ const { srcDir: i = "src", rootDir: n = o.root.pathname } = t, s = e(n, i);
8
+ r({
9
+ vite: {
10
+ plugins: [a(s)]
11
+ }
12
+ });
22
13
  }
23
- };
24
- };
14
+ }
15
+ });
25
16
  export {
26
- D as default,
27
- D as saltyIntegration
17
+ l as default,
18
+ l as saltyIntegration
28
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/astro",
3
- "version": "0.1.0-refactor-add-additional-paths-to-config-cache.1",
3
+ "version": "0.1.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -52,10 +52,6 @@
52
52
  "import": "./element-props.js",
53
53
  "require": "./element-props.cjs"
54
54
  },
55
- "./dynamic-styles": {
56
- "import": "./dynamic-styles.js",
57
- "require": "./dynamic-styles.cjs"
58
- },
59
55
  "./runtime": {
60
56
  "import": "./runtime.js",
61
57
  "require": "./runtime.cjs"
@@ -78,8 +74,16 @@
78
74
  }
79
75
  },
80
76
  "dependencies": {
81
- "@salty-css/core": "^0.1.0-refactor-add-additional-paths-to-config-cache.1",
77
+ "@salty-css/core": "0.1.0",
82
78
  "astro": "^5.13.2",
83
79
  "vite": "^6.3.5"
80
+ },
81
+ "peerDependencies": {
82
+ "@salty-css/react": "0.1.0"
83
+ },
84
+ "peerDependenciesMeta": {
85
+ "@salty-css/react": {
86
+ "optional": true
87
+ }
84
88
  }
85
89
  }
@@ -1 +0,0 @@
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;
@@ -1,20 +0,0 @@
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
- }>;
package/dynamic-styles.js DELETED
@@ -1,11 +0,0 @@
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
- };