@salty-css/astro 0.4.1 → 0.4.3-fix-astro-templates-usage-070726.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/dist/integration/astro-template.d.ts.map +1 -0
- package/dist/{astro-vite-plugin.d.ts → integration/astro-vite-plugin.d.ts} +1 -1
- package/dist/integration/astro-vite-plugin.d.ts.map +1 -0
- package/dist/integration/element-props.cjs +1 -0
- package/dist/{element-props.d.ts → integration/element-props.d.ts} +7 -3
- package/dist/integration/element-props.d.ts.map +1 -0
- package/dist/integration/element-props.js +45 -0
- package/dist/{framework-registry.d.ts → integration/framework-registry.d.ts} +1 -1
- package/dist/integration/framework-registry.d.ts.map +1 -0
- package/dist/{load-salty-file.d.ts → integration/load-salty-file.d.ts} +1 -1
- package/dist/integration/load-salty-file.d.ts.map +1 -0
- package/dist/{watch-handlers.d.ts → integration/watch-handlers.d.ts} +1 -1
- package/dist/integration/watch-handlers.d.ts.map +1 -0
- package/dist/integration.cjs +10 -1
- package/dist/integration.js +196 -8
- package/package.json +6 -10
- package/dist/astro-template.d.ts.map +0 -1
- package/dist/astro-vite-plugin-1E5CWsN3.cjs +0 -10
- package/dist/astro-vite-plugin-H1SVOmVT.js +0 -187
- package/dist/astro-vite-plugin.cjs +0 -1
- package/dist/astro-vite-plugin.d.ts.map +0 -1
- package/dist/astro-vite-plugin.js +0 -2
- package/dist/element-props.cjs +0 -1
- package/dist/element-props.d.ts.map +0 -1
- package/dist/element-props.js +0 -46
- package/dist/framework-registry.d.ts.map +0 -1
- package/dist/load-salty-file.d.ts.map +0 -1
- package/dist/watch-handlers.d.ts.map +0 -1
- /package/dist/{astro-template.d.ts → integration/astro-template.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-template.d.ts","sourceRoot":"","sources":["../../src/integration/astro-template.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CA6B1G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-vite-plugin.d.ts","sourceRoot":"","sources":["../../src/integration/astro-vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAiC,MAAM,MAAM,CAAC;AAQnE,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,UAAS,uBAA4B,KAAG,YAmMhF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@salty-css/core/util"),t=require("@salty-css/core/parsers");var n=[`passProps`],r=(r={},i={},a=``,o,s=!1)=>{let{class:c=``,className:l,element:u,as:d,passProps:f=i.passProps,_vks:p,style:m,...h}=r,g={passProps:f};if(i.attr)for(let[e,t]of Object.entries(i.attr))t!==void 0&&(g[e]=t);o&&Object.assign(g,o);let _={...h};i.defaultProps&&Object.assign(_,i.defaultProps),Object.assign(g,_);let v=new Set;for(let e of String(a).split(` `))e&&v.add(e);for(let e of String(c||``).split(` `))e&&v.add(e);for(let e of String(l||``).split(` `))e&&v.add(e);let y={};if(m&&typeof m==`object`)for(let[e,n]of Object.entries(m)){let r=(0,t.parseVariableTokens)(n);y[e]=r?r.transformed:n}let b=new Set(Array.isArray(p)?p:[]);if(i.propValueKeys)for(let t of i.propValueKeys){let n=`css-${t}`,r=_[n];r!==void 0&&(y[`--props-${(0,e.dashCase)(t)}`]=r,b.add(n))}if(i.variantKeys)for(let t of i.variantKeys){let[n,r]=t.split(`=`);if(_[n]!==void 0){let t=(0,e.sanitizeClassName)(`${n}-${_[n]}`);v.add(t),b.add(n)}else if(r!==void 0){let t=(0,e.sanitizeClassName)(`${n}-${r}`);v.add(t)}}if(!s)for(let e of b)f!==!0&&(Array.isArray(f)&&f.includes(e)||typeof f==`string`&&f===e||delete g[e]);for(let e of n)delete g[e];return{class:[...v],style:y,rest:g,element:d??u??i.element,_vks:[...b]}};exports.resolveAstroProps=r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyledGeneratorClientProps } from '
|
|
1
|
+
import { StyledGeneratorClientProps } from '../../../core/dist/generators';
|
|
2
2
|
export interface ResolvedAstroProps {
|
|
3
3
|
class: string[];
|
|
4
4
|
style: Record<string, any>;
|
|
@@ -8,7 +8,7 @@ export interface ResolvedAstroProps {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* SSR equivalent of the React `elementFactory`. Takes the raw `Astro.props` of a
|
|
11
|
-
* generated `.astro` Salty component plus the build-time
|
|
11
|
+
* generated `.astro` Salty component plus the build-time client props and
|
|
12
12
|
* returns cleaned values ready to apply on the underlying `<Element>` tag:
|
|
13
13
|
*
|
|
14
14
|
* - `class` — array for `class:list`
|
|
@@ -16,6 +16,10 @@ export interface ResolvedAstroProps {
|
|
|
16
16
|
* - `rest` — object to `{...spread}` onto the element (variants and `css-*` props removed unless `passProps` allows)
|
|
17
17
|
* - `element` — runtime element override
|
|
18
18
|
* - `_vks` — variant keys consumed at this level, forwarded so wrapping styled components can keep stripping them
|
|
19
|
+
*
|
|
20
|
+
* When `extendsStyled` is set (the component extends another Salty styled
|
|
21
|
+
* component), consumed variant keys are kept in `rest` so the inner component
|
|
22
|
+
* receives them, matching React's `deleteVKS = !extendsComponent || !extendsStyled`.
|
|
19
23
|
*/
|
|
20
|
-
export declare const resolveAstroProps: (astroProps?: Record<string, any>,
|
|
24
|
+
export declare const resolveAstroProps: (astroProps?: Record<string, any>, clientProps?: StyledGeneratorClientProps, baseClassName?: string, additionalProps?: Record<string, any>, extendsStyled?: boolean) => ResolvedAstroProps;
|
|
21
25
|
//# sourceMappingURL=element-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../../src/integration/element-props.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAIxE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,cAAa,0BAA+B,EAC5C,sBAAkB,EAClB,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrC,uBAAqB,KACpB,kBAqFF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { dashCase as e, sanitizeClassName as t } from "@salty-css/core/util";
|
|
2
|
+
import { parseVariableTokens as n } from "@salty-css/core/parsers";
|
|
3
|
+
//#region src/integration/element-props.ts
|
|
4
|
+
var r = ["passProps"], i = (i = {}, a = {}, o = "", s, c = !1) => {
|
|
5
|
+
let { class: l = "", className: u, element: d, as: f, passProps: p = a.passProps, _vks: m, style: h, ...g } = i, _ = { passProps: p };
|
|
6
|
+
if (a.attr) for (let [e, t] of Object.entries(a.attr)) t !== void 0 && (_[e] = t);
|
|
7
|
+
s && Object.assign(_, s);
|
|
8
|
+
let v = { ...g };
|
|
9
|
+
a.defaultProps && Object.assign(v, a.defaultProps), Object.assign(_, v);
|
|
10
|
+
let y = /* @__PURE__ */ new Set();
|
|
11
|
+
for (let e of String(o).split(" ")) e && y.add(e);
|
|
12
|
+
for (let e of String(l || "").split(" ")) e && y.add(e);
|
|
13
|
+
for (let e of String(u || "").split(" ")) e && y.add(e);
|
|
14
|
+
let b = {};
|
|
15
|
+
if (h && typeof h == "object") for (let [e, t] of Object.entries(h)) {
|
|
16
|
+
let r = n(t);
|
|
17
|
+
b[e] = r ? r.transformed : t;
|
|
18
|
+
}
|
|
19
|
+
let x = new Set(Array.isArray(m) ? m : []);
|
|
20
|
+
if (a.propValueKeys) for (let t of a.propValueKeys) {
|
|
21
|
+
let n = `css-${t}`, r = v[n];
|
|
22
|
+
r !== void 0 && (b[`--props-${e(t)}`] = r, x.add(n));
|
|
23
|
+
}
|
|
24
|
+
if (a.variantKeys) for (let e of a.variantKeys) {
|
|
25
|
+
let [n, r] = e.split("=");
|
|
26
|
+
if (v[n] !== void 0) {
|
|
27
|
+
let e = t(`${n}-${v[n]}`);
|
|
28
|
+
y.add(e), x.add(n);
|
|
29
|
+
} else if (r !== void 0) {
|
|
30
|
+
let e = t(`${n}-${r}`);
|
|
31
|
+
y.add(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!c) for (let e of x) p !== !0 && (Array.isArray(p) && p.includes(e) || typeof p == "string" && p === e || delete _[e]);
|
|
35
|
+
for (let e of r) delete _[e];
|
|
36
|
+
return {
|
|
37
|
+
class: [...y],
|
|
38
|
+
style: b,
|
|
39
|
+
rest: _,
|
|
40
|
+
element: f ?? d ?? a.element,
|
|
41
|
+
_vks: [...x]
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { i as resolveAstroProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SaltyCompiler } from '
|
|
1
|
+
import { SaltyCompiler } from '../../../core/dist/compiler/salty-compiler';
|
|
2
2
|
export type SaltyFileTransform = (compiler: SaltyCompiler, file: string) => Promise<string | undefined>;
|
|
3
3
|
export interface FrameworkEntry {
|
|
4
4
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-registry.d.ts","sourceRoot":"","sources":["../../src/integration/framework-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAE7E,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAExG,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,EAa7C,CAAC;AAIF,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,OAAO,CAAC,kBAAkB,CAMvF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,cAAc,GAAG,SAOjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-salty-file.d.ts","sourceRoot":"","sources":["../../src/integration/load-salty-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAOxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,KAAK,kBAAkB,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAyHzG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SaltyCompiler } from '
|
|
1
|
+
import { SaltyCompiler } from '../../../core/dist/compiler/salty-compiler';
|
|
2
2
|
import { HmrContext, ModuleNode } from 'vite';
|
|
3
3
|
/** Vite `handleHotUpdate` hook body: invalidate config + generated-CSS modules. */
|
|
4
4
|
export declare const handleHotUpdate: (saltyCompiler: SaltyCompiler, { file, server, modules }: HmrContext) => Promise<ModuleNode[] | void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-handlers.d.ts","sourceRoot":"","sources":["../../src/integration/watch-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE9C,mFAAmF;AACnF,eAAO,MAAM,eAAe,GAAU,eAAe,aAAa,EAAE,2BAA2B,UAAU,KAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAiCtI,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,WAAW,GAAU,eAAe,aAAa,EAAE,UAAU,MAAM,EAAE,QAAQ;IAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAUjJ,CAAC"}
|
package/dist/integration.cjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@salty-css/core/compiler/salty-compiler"),t=require("@salty-css/core/compiler/helpers"),n=require("@salty-css/core/compiler/get-function-range"),r=require("@salty-css/core/util"),i=require("fs/promises"),a=require("path"),o=require("@salty-css/core/server"),s=require("vite-node/server"),c=require("vite-node/client"),l=require("vite-node/source-map");var u=[{name:`react`,importMarkers:[/['"]@salty-css\/react(\/[^'"]*)?['"]/],loadTransform:async()=>(await import(`@salty-css/react/transform-salty-file`)).transformSaltyFile}],d=new Map,f=e=>{let t=d.get(e.name);if(t)return t;let n=e.loadTransform();return d.set(e.name,n),n},p=e=>{for(let t of u)for(let n of t.importMarkers)if(n.test(e))return t},m=async(e,t)=>{let n=(0,a.join)(e,`astro`,t);try{let e=await(0,i.readFile)(n,`utf-8`);if(!e)return;let t=JSON.parse(e),{clientProps:r={},classNames:a=``,tagIsComponent:o,extendsStyled:s=!1,tagName:c=`div`}=t,l=[`import { resolveAstroProps } from '@salty-css/astro/integration/element-props';`,...t.imports||[]],u=o?c:`__r.element || ${JSON.stringify(r.element||c)}`,d=`${o?` element={__r.element}`:``}${s?` _vks={__r._vks}`:``}`;return`---
|
|
2
|
+
${l.join(`
|
|
3
|
+
`)}
|
|
4
|
+
const __cp = ${JSON.stringify(r)};
|
|
5
|
+
const __r = resolveAstroProps(Astro.props, __cp, ${JSON.stringify(a)}, undefined, ${JSON.stringify(!!s)});
|
|
6
|
+
const Element = ${u};
|
|
7
|
+
---
|
|
8
|
+
<Element class:list={__r.class} style={__r.style} {...__r.rest}${d}><slot/></Element>`}catch(e){console.error(`Error parsing config file:`,e);return}},h=async(e,o)=>{let{compiler:s}=e;try{if((0,t.isSaltyFile)(o,[],!o.includes(`configFile=`))){let e=await s.getDestDir();if(/.+\?configFile=(\w+).+/.test(o)){let t=new URLSearchParams(o.split(`?`)[1]).get(`configFile`);return t?await m(e,t):void 0}let c=await(0,i.readFile)(o,`utf-8`),l=p(c);if(l)return await(await f(l))(s,o);let u=[`import { classNameInstance } from '@salty-css/core/instances/classname-instance';`],d=[],h=[],g=await s.compileSaltyFile(o,e),_=await s.getConfig(),v=Object.entries(g.contents);for(let[l,f]of v){let p=await(0,t.resolveExportValue)(f,1);if(!p.generator)continue;if(p.isClassName){let e=p.generator._withBuildContext({callerName:l,isProduction:s.isProduction,config:_});d.push(`const ${l} = classNameInstance(${JSON.stringify(e.params)});`),h.push(l);continue}let[m,g]=await(0,n.getFunctionRange)(c,l),y=c.slice(m,g),b=/styled\(([^,]+),/.exec(y)?.at(1)?.trim();if(!b){console.warn(`Could not determine tag name for ${l} in ${o}`);continue}let x=p.generator._withBuildContext({callerName:l,isProduction:s.isProduction,config:_}),S={componentName:l,tagName:b.replace(/['"`]/g,``),tagIsComponent:!1,extendsStyled:!1,classNames:x.classNames,imports:[],clientProps:x.clientProps},C=/^\w+$/.test(b);if(S.tagIsComponent=C,C){let e=v.some(([e])=>e===b),t=c.match(RegExp(`import[^;]*${b}[^;]*;`));if(e)S.extendsStyled=!0,S.imports=[`import ${b} from '${o}.astro?configFile=${(0,r.toHash)(b)}.config';`];else if(t){let e=t.at(0);S.extendsStyled=/['"][^'"]*\.(salty|css|styles|styled)\.\w+['"]/.test(e??``),S.imports=[e]}}let w=(0,a.join)(e,`astro`);await(0,i.readFile)(w,`utf-8`).catch(()=>!1)||await(0,i.mkdir)(w,{recursive:!0});let T=(0,r.toHash)(l);await(0,i.writeFile)((0,a.join)(e,`astro`,`${T}.config`),JSON.stringify(S)),u.push(`import ${l} from '${o}.astro?configFile=${T}.config';`),h.push(l)}return`${u.join(`
|
|
9
|
+
`)}\n${d.join(`
|
|
10
|
+
`)}\nexport { ${h.join(`, `)} };`}return}catch(e){console.error(`Error during file compilation:`,e);return}},g=async(e,{file:n,server:r,modules:i})=>{try{if(await(0,o.checkShouldRestart)(n))return await e.generateCss(!1);if(!(0,t.isSaltyFile)(n))return;let a=await e.getDestDir(),s=[];for(let[e,t]of r.moduleGraph.idToModuleMap)e.startsWith(n+`.astro?configFile=`)&&(r.moduleGraph.invalidateModule(t),s.push(t));for(let e of r.moduleGraph.urlToModuleMap.values())e.file&&e.file.startsWith(a)&&(r.moduleGraph.invalidateModule(e),s.push(e));return r.ws.send({type:`update`,updates:[]}),[...i,...s]}catch(e){console.error(`Error during hot update handling:`,e)}},_=async(e,n,r)=>{try{(0,t.isSaltyFile)(n)&&r.event!==`delete`&&(await(0,o.checkShouldRestart)(n)||await e.generateFile(n))}catch(e){console.error(`Error during watch change handling:`,e)}},v=(t,n={})=>{let r,i,a,o,u=new e.SaltyCompiler(t,{mode:n.mode}),d={compiler:u},f=async()=>{if(a&&i&&r)return a;if(!o)throw Error(`[stylegen] vite-node runner requested before configResolved ran`);let{createServer:e,version:t}=await import(`vite`);r=await e({resolve:{alias:o.resolve.alias},server:{middlewareMode:!0,hmr:!1,ws:!1,watch:null},optimizeDeps:{noDiscovery:!0,include:[]}}),Number(t.split(`.`)[0])<6&&await r.pluginContainer.buildStart({});let n=new s.ViteNodeServer(r);return i=n,(0,l.installSourcemapsSupport)({getSourceMap:e=>n.getSourceMap(e)}),a=new c.ViteNodeRunner({root:r.config.root,base:r.config.base,fetchModule:e=>n.fetchModule(e),resolveId:(e,t)=>n.resolveId(e,t)}),a},p=(e,t)=>{let n=e.moduleCache;n.invalidateDepTree?n.invalidateDepTree([t]):n.deleteByModuleId?n.deleteByModuleId(t):n.clear()};u.importFile=async e=>{let t=await f();return p(t,e),t.executeFile(e)};let m=async()=>{let e=r;if(r=void 0,i=void 0,a=void 0,e)try{await e.close()}catch{}},v,y=()=>(v||=u.generateCss().catch(e=>{throw v=void 0,e}),v);return{name:`stylegen`,configResolved:async function(e){o=e,await f();try{await y()}catch(e){throw console.error(`Error during initial CSS generation:`,e),e}},resolveId:function(e){return e.includes(`.astro?configFile=`)?e:null},load:function(e){return h(d,e)},handleHotUpdate:function(e){return g(u,e)},watchChange:{handler:function(e,t){return _(u,e,t)}},closeBundle:async function(){await m()}}},y=(e={})=>({name:`astro-salty-integration`,hooks:{"astro:config:setup":({config:t,updateConfig:n})=>{let{srcDir:r=`src`,rootDir:i=t.root.pathname}=e;n({vite:{plugins:[v((0,a.join)(i,r))]}})}}});exports.default=y,exports.saltyIntegration=y;
|
package/dist/integration.js
CHANGED
|
@@ -1,12 +1,200 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { SaltyCompiler as e } from "@salty-css/core/compiler/salty-compiler";
|
|
2
|
+
import { isSaltyFile as t, resolveExportValue as n } from "@salty-css/core/compiler/helpers";
|
|
3
|
+
import { getFunctionRange as r } from "@salty-css/core/compiler/get-function-range";
|
|
4
|
+
import { toHash as i } from "@salty-css/core/util";
|
|
5
|
+
import { mkdir as a, readFile as o, writeFile as s } from "fs/promises";
|
|
6
|
+
import { join as c } from "path";
|
|
7
|
+
import { checkShouldRestart as l } from "@salty-css/core/server";
|
|
8
|
+
import { ViteNodeServer as u } from "vite-node/server";
|
|
9
|
+
import { ViteNodeRunner as d } from "vite-node/client";
|
|
10
|
+
import { installSourcemapsSupport as f } from "vite-node/source-map";
|
|
11
|
+
//#region src/integration/framework-registry.ts
|
|
12
|
+
var p = [{
|
|
13
|
+
name: "react",
|
|
14
|
+
importMarkers: [/['"]@salty-css\/react(\/[^'"]*)?['"]/],
|
|
15
|
+
loadTransform: async () => (await import(
|
|
16
|
+
/* @vite-ignore */
|
|
17
|
+
"@salty-css/react/transform-salty-file"
|
|
18
|
+
)).transformSaltyFile
|
|
19
|
+
}], m = /* @__PURE__ */ new Map(), h = (e) => {
|
|
20
|
+
let t = m.get(e.name);
|
|
21
|
+
if (t) return t;
|
|
22
|
+
let n = e.loadTransform();
|
|
23
|
+
return m.set(e.name, n), n;
|
|
24
|
+
}, g = (e) => {
|
|
25
|
+
for (let t of p) for (let n of t.importMarkers) if (n.test(e)) return t;
|
|
26
|
+
}, _ = async (e, t) => {
|
|
27
|
+
let n = c(e, "astro", t);
|
|
28
|
+
try {
|
|
29
|
+
let e = await o(n, "utf-8");
|
|
30
|
+
if (!e) return;
|
|
31
|
+
let t = JSON.parse(e), { clientProps: r = {}, classNames: i = "", tagIsComponent: a, extendsStyled: s = !1, tagName: c = "div" } = t, l = ["import { resolveAstroProps } from '@salty-css/astro/integration/element-props';", ...t.imports || []], u = a ? c : `__r.element || ${JSON.stringify(r.element || c)}`, d = `${a ? " element={__r.element}" : ""}${s ? " _vks={__r._vks}" : ""}`;
|
|
32
|
+
return `---
|
|
33
|
+
${l.join("\n")}
|
|
34
|
+
const __cp = ${JSON.stringify(r)};
|
|
35
|
+
const __r = resolveAstroProps(Astro.props, __cp, ${JSON.stringify(i)}, undefined, ${JSON.stringify(!!s)});
|
|
36
|
+
const Element = ${u};
|
|
37
|
+
---
|
|
38
|
+
<Element class:list={__r.class} style={__r.style} {...__r.rest}${d}><slot/></Element>`;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error("Error parsing config file:", e);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}, v = async (e, l) => {
|
|
44
|
+
let { compiler: u } = e;
|
|
45
|
+
try {
|
|
46
|
+
if (t(l, [], !l.includes("configFile="))) {
|
|
47
|
+
let e = await u.getDestDir();
|
|
48
|
+
if (/.+\?configFile=(\w+).+/.test(l)) {
|
|
49
|
+
let t = new URLSearchParams(l.split("?")[1]).get("configFile");
|
|
50
|
+
return t ? await _(e, t) : void 0;
|
|
51
|
+
}
|
|
52
|
+
let t = await o(l, "utf-8"), d = g(t);
|
|
53
|
+
if (d) return await (await h(d))(u, l);
|
|
54
|
+
let f = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], p = [], m = [], v = await u.compileSaltyFile(l, e), y = await u.getConfig(), b = Object.entries(v.contents);
|
|
55
|
+
for (let [d, h] of b) {
|
|
56
|
+
let g = await n(h, 1);
|
|
57
|
+
if (!g.generator) continue;
|
|
58
|
+
if (g.isClassName) {
|
|
59
|
+
let e = g.generator._withBuildContext({
|
|
60
|
+
callerName: d,
|
|
61
|
+
isProduction: u.isProduction,
|
|
62
|
+
config: y
|
|
63
|
+
});
|
|
64
|
+
p.push(`const ${d} = classNameInstance(${JSON.stringify(e.params)});`), m.push(d);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
let [_, v] = await r(t, d), x = t.slice(_, v), S = /styled\(([^,]+),/.exec(x)?.at(1)?.trim();
|
|
68
|
+
if (!S) {
|
|
69
|
+
console.warn(`Could not determine tag name for ${d} in ${l}`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
let C = g.generator._withBuildContext({
|
|
73
|
+
callerName: d,
|
|
74
|
+
isProduction: u.isProduction,
|
|
75
|
+
config: y
|
|
76
|
+
}), w = {
|
|
77
|
+
componentName: d,
|
|
78
|
+
tagName: S.replace(/['"`]/g, ""),
|
|
79
|
+
tagIsComponent: !1,
|
|
80
|
+
extendsStyled: !1,
|
|
81
|
+
classNames: C.classNames,
|
|
82
|
+
imports: [],
|
|
83
|
+
clientProps: C.clientProps
|
|
84
|
+
}, T = /^\w+$/.test(S);
|
|
85
|
+
if (w.tagIsComponent = T, T) {
|
|
86
|
+
let e = b.some(([e]) => e === S), n = t.match(RegExp(`import[^;]*${S}[^;]*;`));
|
|
87
|
+
if (e) w.extendsStyled = !0, w.imports = [`import ${S} from '${l}.astro?configFile=${i(S)}.config';`];
|
|
88
|
+
else if (n) {
|
|
89
|
+
let e = n.at(0);
|
|
90
|
+
w.extendsStyled = /['"][^'"]*\.(salty|css|styles|styled)\.\w+['"]/.test(e ?? ""), w.imports = [e];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let E = c(e, "astro");
|
|
94
|
+
await o(E, "utf-8").catch(() => !1) || await a(E, { recursive: !0 });
|
|
95
|
+
let D = i(d);
|
|
96
|
+
await s(c(e, "astro", `${D}.config`), JSON.stringify(w)), f.push(`import ${d} from '${l}.astro?configFile=${D}.config';`), m.push(d);
|
|
97
|
+
}
|
|
98
|
+
return `${f.join("\n")}\n${p.join("\n")}\nexport { ${m.join(", ")} };`;
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error("Error during file compilation:", e);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}, y = async (e, { file: n, server: r, modules: i }) => {
|
|
106
|
+
try {
|
|
107
|
+
if (await l(n)) return await e.generateCss(!1);
|
|
108
|
+
if (!t(n)) return;
|
|
109
|
+
let a = await e.getDestDir(), o = [];
|
|
110
|
+
for (let [e, t] of r.moduleGraph.idToModuleMap) e.startsWith(n + ".astro?configFile=") && (r.moduleGraph.invalidateModule(t), o.push(t));
|
|
111
|
+
for (let e of r.moduleGraph.urlToModuleMap.values()) e.file && e.file.startsWith(a) && (r.moduleGraph.invalidateModule(e), o.push(e));
|
|
112
|
+
return r.ws.send({
|
|
113
|
+
type: "update",
|
|
114
|
+
updates: []
|
|
115
|
+
}), [...i, ...o];
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.error("Error during hot update handling:", e);
|
|
118
|
+
}
|
|
119
|
+
}, b = async (e, n, r) => {
|
|
120
|
+
try {
|
|
121
|
+
t(n) && r.event !== "delete" && (await l(n) || await e.generateFile(n));
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.error("Error during watch change handling:", e);
|
|
124
|
+
}
|
|
125
|
+
}, x = (t, n = {}) => {
|
|
126
|
+
let r, i, a, o, s = new e(t, { mode: n.mode }), c = { compiler: s }, l = async () => {
|
|
127
|
+
if (a && i && r) return a;
|
|
128
|
+
if (!o) throw Error("[stylegen] vite-node runner requested before configResolved ran");
|
|
129
|
+
let { createServer: e, version: t } = await import("vite");
|
|
130
|
+
r = await e({
|
|
131
|
+
resolve: { alias: o.resolve.alias },
|
|
132
|
+
server: {
|
|
133
|
+
middlewareMode: !0,
|
|
134
|
+
hmr: !1,
|
|
135
|
+
ws: !1,
|
|
136
|
+
watch: null
|
|
137
|
+
},
|
|
138
|
+
optimizeDeps: {
|
|
139
|
+
noDiscovery: !0,
|
|
140
|
+
include: []
|
|
141
|
+
}
|
|
142
|
+
}), Number(t.split(".")[0]) < 6 && await r.pluginContainer.buildStart({});
|
|
143
|
+
let n = new u(r);
|
|
144
|
+
return i = n, f({ getSourceMap: (e) => n.getSourceMap(e) }), a = new d({
|
|
145
|
+
root: r.config.root,
|
|
146
|
+
base: r.config.base,
|
|
147
|
+
fetchModule: (e) => n.fetchModule(e),
|
|
148
|
+
resolveId: (e, t) => n.resolveId(e, t)
|
|
149
|
+
}), a;
|
|
150
|
+
}, p = (e, t) => {
|
|
151
|
+
let n = e.moduleCache;
|
|
152
|
+
n.invalidateDepTree ? n.invalidateDepTree([t]) : n.deleteByModuleId ? n.deleteByModuleId(t) : n.clear();
|
|
153
|
+
};
|
|
154
|
+
s.importFile = async (e) => {
|
|
155
|
+
let t = await l();
|
|
156
|
+
return p(t, e), t.executeFile(e);
|
|
157
|
+
};
|
|
158
|
+
let m = async () => {
|
|
159
|
+
let e = r;
|
|
160
|
+
if (r = void 0, i = void 0, a = void 0, e) try {
|
|
161
|
+
await e.close();
|
|
162
|
+
} catch {}
|
|
163
|
+
}, h, g = () => (h ||= s.generateCss().catch((e) => {
|
|
164
|
+
throw h = void 0, e;
|
|
165
|
+
}), h);
|
|
166
|
+
return {
|
|
167
|
+
name: "stylegen",
|
|
168
|
+
configResolved: async function(e) {
|
|
169
|
+
o = e, await l();
|
|
170
|
+
try {
|
|
171
|
+
await g();
|
|
172
|
+
} catch (e) {
|
|
173
|
+
throw console.error("Error during initial CSS generation:", e), e;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
resolveId: function(e) {
|
|
177
|
+
return e.includes(".astro?configFile=") ? e : null;
|
|
178
|
+
},
|
|
179
|
+
load: function(e) {
|
|
180
|
+
return v(c, e);
|
|
181
|
+
},
|
|
182
|
+
handleHotUpdate: function(e) {
|
|
183
|
+
return y(s, e);
|
|
184
|
+
},
|
|
185
|
+
watchChange: { handler: function(e, t) {
|
|
186
|
+
return b(s, e, t);
|
|
187
|
+
} },
|
|
188
|
+
closeBundle: async function() {
|
|
189
|
+
await m();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}, S = (e = {}) => ({
|
|
5
193
|
name: "astro-salty-integration",
|
|
6
|
-
hooks: { "astro:config:setup": ({ config:
|
|
7
|
-
let { srcDir:
|
|
8
|
-
|
|
194
|
+
hooks: { "astro:config:setup": ({ config: t, updateConfig: n }) => {
|
|
195
|
+
let { srcDir: r = "src", rootDir: i = t.root.pathname } = e;
|
|
196
|
+
n({ vite: { plugins: [x(c(i, r))] } });
|
|
9
197
|
} }
|
|
10
198
|
});
|
|
11
199
|
//#endregion
|
|
12
|
-
export {
|
|
200
|
+
export { S as default, S as saltyIntegration };
|
package/package.json
CHANGED
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/margarita-form/salty-css/issues"
|
|
17
17
|
},
|
|
18
|
-
"version": "0.4.
|
|
18
|
+
"version": "0.4.3-fix-astro-templates-usage-070726.0",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "node ../../node_modules/vite-build/bin/vite.js build --config vite.config.ts",
|
|
22
22
|
"test": "vitest run"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@salty-css/core": "0.4.
|
|
26
|
-
"@salty-css/react": "0.4.
|
|
25
|
+
"@salty-css/core": "0.4.3-fix-astro-templates-usage-070726.0",
|
|
26
|
+
"@salty-css/react": "0.4.3-fix-astro-templates-usage-070726.0",
|
|
27
27
|
"vite": "^7.3.5",
|
|
28
28
|
"vite-node": "^5.3.0"
|
|
29
29
|
},
|
|
@@ -49,10 +49,6 @@
|
|
|
49
49
|
"import": "./dist/index.js",
|
|
50
50
|
"require": "./dist/index.cjs"
|
|
51
51
|
},
|
|
52
|
-
"./astro-vite-plugin": {
|
|
53
|
-
"import": "./dist/astro-vite-plugin.js",
|
|
54
|
-
"require": "./dist/astro-vite-plugin.cjs"
|
|
55
|
-
},
|
|
56
52
|
"./integration": {
|
|
57
53
|
"import": "./dist/integration.js",
|
|
58
54
|
"require": "./dist/integration.cjs"
|
|
@@ -65,9 +61,9 @@
|
|
|
65
61
|
"import": "./dist/class-name.js",
|
|
66
62
|
"require": "./dist/class-name.cjs"
|
|
67
63
|
},
|
|
68
|
-
"./element-props": {
|
|
69
|
-
"import": "./dist/element-props.js",
|
|
70
|
-
"require": "./dist/element-props.cjs"
|
|
64
|
+
"./integration/element-props": {
|
|
65
|
+
"import": "./dist/integration/element-props.js",
|
|
66
|
+
"require": "./dist/integration/element-props.cjs"
|
|
71
67
|
},
|
|
72
68
|
"./runtime": {
|
|
73
69
|
"import": "./dist/runtime.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"astro-template.d.ts","sourceRoot":"","sources":["../src/astro-template.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAwB1G,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
let e=require("@salty-css/core/compiler/salty-compiler"),t=require("@salty-css/core/compiler/helpers"),n=require("@salty-css/core/compiler/get-function-range"),r=require("@salty-css/core/util"),i=require("fs/promises"),a=require("path"),o=require("@salty-css/core/server"),s=require("vite-node/server"),c=require("vite-node/client"),l=require("vite-node/source-map");var u=[{name:`react`,importMarkers:[/['"]@salty-css\/react(\/[^'"]*)?['"]/],loadTransform:async()=>(await import(`@salty-css/react/transform-salty-file`)).transformSaltyFile}],d=new Map,f=e=>{let t=d.get(e.name);if(t)return t;let n=e.loadTransform();return d.set(e.name,n),n},p=e=>{for(let t of u)for(let n of t.importMarkers)if(n.test(e))return t},m=async(e,t)=>{let n=await(0,i.readFile)((0,a.join)(e,`astro`,t),`utf-8`);if(n)try{let e=JSON.parse(n),{clientProps:t={},classNames:r=``,tagIsComponent:i,tagName:a=`div`}=e,o=[`import { resolveAstroProps } from '@salty-css/astro/element-props';`,...e.imports||[]],s=i?a:`__r.element || ${JSON.stringify(t.element||a)}`;return`---
|
|
2
|
-
${o.join(`
|
|
3
|
-
`)}
|
|
4
|
-
const __gp = ${JSON.stringify(t)};
|
|
5
|
-
const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(r)});
|
|
6
|
-
const Element = ${s};
|
|
7
|
-
---
|
|
8
|
-
<Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`}catch(e){console.error(`Error parsing config file:`,e);return}},h=async(e,o)=>{let{compiler:s}=e;try{if((0,t.isSaltyFile)(o,[],!o.includes(`configFile=`))){let e=await s.getDestDir();if(/.+\?configFile=(\w+).+/.test(o)){let t=new URLSearchParams(o.split(`?`)[1]).get(`configFile`);return t?await m(e,t):void 0}let c=await(0,i.readFile)(o,`utf-8`),l=p(c);if(l)return await(await f(l))(s,o);let u=[`import { classNameInstance } from '@salty-css/core/instances/classname-instance';`],d=[],h=[],g=await s.compileSaltyFile(o,e),_=Object.entries(g.contents);for(let[l,f]of _){let p=await(0,t.resolveExportValue)(f,1);if(!p.generator)continue;if(p.isClassName){let e=p.generator._withBuildContext({callerName:l,isProduction:s.isProduction,config:{}});d.push(`const ${l} = classNameInstance(${JSON.stringify(e.params)});`),h.push(l);continue}let[m,g]=await(0,n.getFunctionRange)(c,l),v=c.slice(m,g),y=/styled\(([^,]+),/.exec(v)?.at(1)?.trim();if(!y){console.warn(`Could not determine tag name for ${l} in ${o}`);continue}let b=p.generator._withBuildContext({callerName:l,isProduction:s.isProduction,config:{}}),x={componentName:l,tagName:y.replace(/['"`]/g,``),tagIsComponent:!1,classNames:b.classNames,imports:[],clientProps:b.clientProps},S=/^\w+$/.test(y);if(x.tagIsComponent=S,S){let e=_.some(([e])=>e===y),t=c.match(RegExp(`import[^;]*${y}[^;]*;`));e?x.imports=[`import ${y} from '${o}.astro?configFile=${(0,r.toHash)(y)}.config';`]:t&&(x.imports=[t.at(0)])}let C=(0,a.join)(e,`astro`);await(0,i.readFile)(C,`utf-8`).catch(()=>!1)||await(0,i.mkdir)(C,{recursive:!0});let w=(0,r.toHash)(l);await(0,i.writeFile)((0,a.join)(e,`astro`,`${w}.config`),JSON.stringify(x)),u.push(`import ${l} from '${o}.astro?configFile=${w}.config';`),h.push(l)}return`${u.join(`
|
|
9
|
-
`)}\n${d.join(`
|
|
10
|
-
`)}\nexport { ${h.join(`, `)} };`}return}catch(e){console.error(`Error during file compilation:`,e);return}},g=async(e,{file:n,server:r,modules:i})=>{try{if(await(0,o.checkShouldRestart)(n))return await e.generateCss(!1);if(!(0,t.isSaltyFile)(n))return;let a=await e.getDestDir(),s=[];for(let[e,t]of r.moduleGraph.idToModuleMap)e.startsWith(n+`.astro?configFile=`)&&(r.moduleGraph.invalidateModule(t),s.push(t));for(let e of r.moduleGraph.urlToModuleMap.values())e.file&&e.file.startsWith(a)&&(r.moduleGraph.invalidateModule(e),s.push(e));return r.ws.send({type:`update`,updates:[]}),[...i,...s]}catch(e){console.error(`Error during hot update handling:`,e)}},_=async(e,n,r)=>{try{(0,t.isSaltyFile)(n)&&r.event!==`delete`&&(await(0,o.checkShouldRestart)(n)||await e.generateFile(n))}catch(e){console.error(`Error during watch change handling:`,e)}},v=(t,n={})=>{let r,i,a,o,u=new e.SaltyCompiler(t,{mode:n.mode}),d={compiler:u},f=async()=>{if(a&&i&&r)return a;if(!o)throw Error(`[stylegen] vite-node runner requested before configResolved ran`);let{createServer:e,version:t}=await import(`vite`);r=await e({resolve:{alias:o.resolve.alias},server:{middlewareMode:!0,hmr:!1,ws:!1,watch:null},optimizeDeps:{noDiscovery:!0,include:[]}}),Number(t.split(`.`)[0])<6&&await r.pluginContainer.buildStart({});let n=new s.ViteNodeServer(r);return i=n,(0,l.installSourcemapsSupport)({getSourceMap:e=>n.getSourceMap(e)}),a=new c.ViteNodeRunner({root:r.config.root,base:r.config.base,fetchModule:e=>n.fetchModule(e),resolveId:(e,t)=>n.resolveId(e,t)}),a},p=(e,t)=>{let n=e.moduleCache;n.invalidateDepTree?n.invalidateDepTree([t]):n.deleteByModuleId?n.deleteByModuleId(t):n.clear()};u.importFile=async e=>{let t=await f();return p(t,e),t.executeFile(e)};let m=async()=>{let e=r;if(r=void 0,i=void 0,a=void 0,e)try{await e.close()}catch{}},v,y=()=>(v||=u.generateCss().catch(e=>{throw v=void 0,e}),v);return{name:`stylegen`,configResolved:async function(e){o=e,await f();try{await y()}catch(e){throw console.error(`Error during initial CSS generation:`,e),e}},resolveId:function(e){return e.includes(`.astro?configFile=`)?e:null},load:function(e){return h(d,e)},handleHotUpdate:function(e){return g(u,e)},watchChange:{handler:function(e,t){return _(u,e,t)}},closeBundle:async function(){await m()}}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { SaltyCompiler as e } from "@salty-css/core/compiler/salty-compiler";
|
|
2
|
-
import { isSaltyFile as t, resolveExportValue as n } from "@salty-css/core/compiler/helpers";
|
|
3
|
-
import { getFunctionRange as r } from "@salty-css/core/compiler/get-function-range";
|
|
4
|
-
import { toHash as i } from "@salty-css/core/util";
|
|
5
|
-
import { mkdir as a, readFile as o, writeFile as s } from "fs/promises";
|
|
6
|
-
import { join as c } from "path";
|
|
7
|
-
import { checkShouldRestart as l } from "@salty-css/core/server";
|
|
8
|
-
import { ViteNodeServer as u } from "vite-node/server";
|
|
9
|
-
import { ViteNodeRunner as d } from "vite-node/client";
|
|
10
|
-
import { installSourcemapsSupport as f } from "vite-node/source-map";
|
|
11
|
-
//#region src/framework-registry.ts
|
|
12
|
-
var p = [{
|
|
13
|
-
name: "react",
|
|
14
|
-
importMarkers: [/['"]@salty-css\/react(\/[^'"]*)?['"]/],
|
|
15
|
-
loadTransform: async () => (await import(
|
|
16
|
-
/* @vite-ignore */
|
|
17
|
-
"@salty-css/react/transform-salty-file"
|
|
18
|
-
)).transformSaltyFile
|
|
19
|
-
}], m = /* @__PURE__ */ new Map(), h = (e) => {
|
|
20
|
-
let t = m.get(e.name);
|
|
21
|
-
if (t) return t;
|
|
22
|
-
let n = e.loadTransform();
|
|
23
|
-
return m.set(e.name, n), n;
|
|
24
|
-
}, g = (e) => {
|
|
25
|
-
for (let t of p) for (let n of t.importMarkers) if (n.test(e)) return t;
|
|
26
|
-
}, _ = async (e, t) => {
|
|
27
|
-
let n = await o(c(e, "astro", t), "utf-8");
|
|
28
|
-
if (n) try {
|
|
29
|
-
let e = JSON.parse(n), { clientProps: t = {}, classNames: r = "", tagIsComponent: i, tagName: a = "div" } = e, o = ["import { resolveAstroProps } from '@salty-css/astro/element-props';", ...e.imports || []], s = i ? a : `__r.element || ${JSON.stringify(t.element || a)}`;
|
|
30
|
-
return `---
|
|
31
|
-
${o.join("\n")}
|
|
32
|
-
const __gp = ${JSON.stringify(t)};
|
|
33
|
-
const __r = resolveAstroProps(Astro.props, __gp, ${JSON.stringify(r)});
|
|
34
|
-
const Element = ${s};
|
|
35
|
-
---
|
|
36
|
-
<Element class:list={__r.class} style={__r.style} {...__r.rest}><slot/></Element>`;
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error("Error parsing config file:", e);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}, v = async (e, l) => {
|
|
42
|
-
let { compiler: u } = e;
|
|
43
|
-
try {
|
|
44
|
-
if (t(l, [], !l.includes("configFile="))) {
|
|
45
|
-
let e = await u.getDestDir();
|
|
46
|
-
if (/.+\?configFile=(\w+).+/.test(l)) {
|
|
47
|
-
let t = new URLSearchParams(l.split("?")[1]).get("configFile");
|
|
48
|
-
return t ? await _(e, t) : void 0;
|
|
49
|
-
}
|
|
50
|
-
let t = await o(l, "utf-8"), d = g(t);
|
|
51
|
-
if (d) return await (await h(d))(u, l);
|
|
52
|
-
let f = ["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"], p = [], m = [], v = await u.compileSaltyFile(l, e), y = Object.entries(v.contents);
|
|
53
|
-
for (let [d, h] of y) {
|
|
54
|
-
let g = await n(h, 1);
|
|
55
|
-
if (!g.generator) continue;
|
|
56
|
-
if (g.isClassName) {
|
|
57
|
-
let e = g.generator._withBuildContext({
|
|
58
|
-
callerName: d,
|
|
59
|
-
isProduction: u.isProduction,
|
|
60
|
-
config: {}
|
|
61
|
-
});
|
|
62
|
-
p.push(`const ${d} = classNameInstance(${JSON.stringify(e.params)});`), m.push(d);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
let [_, v] = await r(t, d), b = t.slice(_, v), x = /styled\(([^,]+),/.exec(b)?.at(1)?.trim();
|
|
66
|
-
if (!x) {
|
|
67
|
-
console.warn(`Could not determine tag name for ${d} in ${l}`);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
let S = g.generator._withBuildContext({
|
|
71
|
-
callerName: d,
|
|
72
|
-
isProduction: u.isProduction,
|
|
73
|
-
config: {}
|
|
74
|
-
}), C = {
|
|
75
|
-
componentName: d,
|
|
76
|
-
tagName: x.replace(/['"`]/g, ""),
|
|
77
|
-
tagIsComponent: !1,
|
|
78
|
-
classNames: S.classNames,
|
|
79
|
-
imports: [],
|
|
80
|
-
clientProps: S.clientProps
|
|
81
|
-
}, w = /^\w+$/.test(x);
|
|
82
|
-
if (C.tagIsComponent = w, w) {
|
|
83
|
-
let e = y.some(([e]) => e === x), n = t.match(RegExp(`import[^;]*${x}[^;]*;`));
|
|
84
|
-
e ? C.imports = [`import ${x} from '${l}.astro?configFile=${i(x)}.config';`] : n && (C.imports = [n.at(0)]);
|
|
85
|
-
}
|
|
86
|
-
let T = c(e, "astro");
|
|
87
|
-
await o(T, "utf-8").catch(() => !1) || await a(T, { recursive: !0 });
|
|
88
|
-
let E = i(d);
|
|
89
|
-
await s(c(e, "astro", `${E}.config`), JSON.stringify(C)), f.push(`import ${d} from '${l}.astro?configFile=${E}.config';`), m.push(d);
|
|
90
|
-
}
|
|
91
|
-
return `${f.join("\n")}\n${p.join("\n")}\nexport { ${m.join(", ")} };`;
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
} catch (e) {
|
|
95
|
-
console.error("Error during file compilation:", e);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}, y = async (e, { file: n, server: r, modules: i }) => {
|
|
99
|
-
try {
|
|
100
|
-
if (await l(n)) return await e.generateCss(!1);
|
|
101
|
-
if (!t(n)) return;
|
|
102
|
-
let a = await e.getDestDir(), o = [];
|
|
103
|
-
for (let [e, t] of r.moduleGraph.idToModuleMap) e.startsWith(n + ".astro?configFile=") && (r.moduleGraph.invalidateModule(t), o.push(t));
|
|
104
|
-
for (let e of r.moduleGraph.urlToModuleMap.values()) e.file && e.file.startsWith(a) && (r.moduleGraph.invalidateModule(e), o.push(e));
|
|
105
|
-
return r.ws.send({
|
|
106
|
-
type: "update",
|
|
107
|
-
updates: []
|
|
108
|
-
}), [...i, ...o];
|
|
109
|
-
} catch (e) {
|
|
110
|
-
console.error("Error during hot update handling:", e);
|
|
111
|
-
}
|
|
112
|
-
}, b = async (e, n, r) => {
|
|
113
|
-
try {
|
|
114
|
-
t(n) && r.event !== "delete" && (await l(n) || await e.generateFile(n));
|
|
115
|
-
} catch (e) {
|
|
116
|
-
console.error("Error during watch change handling:", e);
|
|
117
|
-
}
|
|
118
|
-
}, x = (t, n = {}) => {
|
|
119
|
-
let r, i, a, o, s = new e(t, { mode: n.mode }), c = { compiler: s }, l = async () => {
|
|
120
|
-
if (a && i && r) return a;
|
|
121
|
-
if (!o) throw Error("[stylegen] vite-node runner requested before configResolved ran");
|
|
122
|
-
let { createServer: e, version: t } = await import("vite");
|
|
123
|
-
r = await e({
|
|
124
|
-
resolve: { alias: o.resolve.alias },
|
|
125
|
-
server: {
|
|
126
|
-
middlewareMode: !0,
|
|
127
|
-
hmr: !1,
|
|
128
|
-
ws: !1,
|
|
129
|
-
watch: null
|
|
130
|
-
},
|
|
131
|
-
optimizeDeps: {
|
|
132
|
-
noDiscovery: !0,
|
|
133
|
-
include: []
|
|
134
|
-
}
|
|
135
|
-
}), Number(t.split(".")[0]) < 6 && await r.pluginContainer.buildStart({});
|
|
136
|
-
let n = new u(r);
|
|
137
|
-
return i = n, f({ getSourceMap: (e) => n.getSourceMap(e) }), a = new d({
|
|
138
|
-
root: r.config.root,
|
|
139
|
-
base: r.config.base,
|
|
140
|
-
fetchModule: (e) => n.fetchModule(e),
|
|
141
|
-
resolveId: (e, t) => n.resolveId(e, t)
|
|
142
|
-
}), a;
|
|
143
|
-
}, p = (e, t) => {
|
|
144
|
-
let n = e.moduleCache;
|
|
145
|
-
n.invalidateDepTree ? n.invalidateDepTree([t]) : n.deleteByModuleId ? n.deleteByModuleId(t) : n.clear();
|
|
146
|
-
};
|
|
147
|
-
s.importFile = async (e) => {
|
|
148
|
-
let t = await l();
|
|
149
|
-
return p(t, e), t.executeFile(e);
|
|
150
|
-
};
|
|
151
|
-
let m = async () => {
|
|
152
|
-
let e = r;
|
|
153
|
-
if (r = void 0, i = void 0, a = void 0, e) try {
|
|
154
|
-
await e.close();
|
|
155
|
-
} catch {}
|
|
156
|
-
}, h, g = () => (h ||= s.generateCss().catch((e) => {
|
|
157
|
-
throw h = void 0, e;
|
|
158
|
-
}), h);
|
|
159
|
-
return {
|
|
160
|
-
name: "stylegen",
|
|
161
|
-
configResolved: async function(e) {
|
|
162
|
-
o = e, await l();
|
|
163
|
-
try {
|
|
164
|
-
await g();
|
|
165
|
-
} catch (e) {
|
|
166
|
-
throw console.error("Error during initial CSS generation:", e), e;
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
resolveId: function(e) {
|
|
170
|
-
return e.includes(".astro?configFile=") ? e : null;
|
|
171
|
-
},
|
|
172
|
-
load: function(e) {
|
|
173
|
-
return v(c, e);
|
|
174
|
-
},
|
|
175
|
-
handleHotUpdate: function(e) {
|
|
176
|
-
return y(s, e);
|
|
177
|
-
},
|
|
178
|
-
watchChange: { handler: function(e, t) {
|
|
179
|
-
return b(s, e, t);
|
|
180
|
-
} },
|
|
181
|
-
closeBundle: async function() {
|
|
182
|
-
await m();
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
//#endregion
|
|
187
|
-
export { x as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./astro-vite-plugin-1E5CWsN3.cjs");exports.default=e.t,exports.saltyPlugin=e.t;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"astro-vite-plugin.d.ts","sourceRoot":"","sources":["../src/astro-vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAiC,MAAM,MAAM,CAAC;AAQnE,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,UAAS,uBAA4B,KAAG,YAmMhF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/element-props.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@salty-css/core/util"),t=require("@salty-css/core/parsers");var n=[`passProps`],r=(r={},i={},a=``,o)=>{let{class:s=``,className:c,element:l,as:u,passProps:d=i.passProps,_vks:f,style:p,...m}=r,h={passProps:d};if(i.attr)for(let[e,t]of Object.entries(i.attr))t!==void 0&&(h[e]=t);o&&Object.assign(h,o);let g={...m};if(i.defaultProps)for(let[e,t]of Object.entries(i.defaultProps))g[e]===void 0&&(g[e]=t);Object.assign(h,g);let _=new Set;for(let e of String(a).split(` `))e&&_.add(e);for(let e of String(s||``).split(` `))e&&_.add(e);for(let e of String(c||``).split(` `))e&&_.add(e);let v={};if(p&&typeof p==`object`)for(let[e,n]of Object.entries(p)){let r=(0,t.parseVariableTokens)(n);v[e]=r?r.transformed:n}let y=new Set(Array.isArray(f)?f:[]);if(i.propValueKeys)for(let t of i.propValueKeys){let n=`css-${t}`,r=g[n];r!==void 0&&(v[`--props-${(0,e.dashCase)(t)}`]=r,y.add(n))}if(i.variantKeys)for(let t of i.variantKeys){let[n,r]=t.split(`=`);if(g[n]!==void 0){let t=(0,e.sanitizeClassName)(`${n}-${g[n]}`);_.add(t),y.add(n)}else if(r!==void 0){let t=(0,e.sanitizeClassName)(`${n}-${r}`);_.add(t)}}for(let e of y)d!==!0&&(Array.isArray(d)&&d.includes(e)||typeof d==`string`&&d===e||delete h[e]);for(let e of n)delete h[e];return{class:[..._],style:v,rest:h,element:u??l??i.element,_vks:[...y]}};exports.resolveAstroProps=r;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../src/element-props.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAIxE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,iBAAgB,0BAA+B,EAC/C,sBAAkB,EAClB,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACpC,kBAkFF,CAAC"}
|
package/dist/element-props.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { dashCase as e, sanitizeClassName as t } from "@salty-css/core/util";
|
|
2
|
-
import { parseVariableTokens as n } from "@salty-css/core/parsers";
|
|
3
|
-
//#region src/element-props.ts
|
|
4
|
-
var r = ["passProps"], i = (i = {}, a = {}, o = "", s) => {
|
|
5
|
-
let { class: c = "", className: l, element: u, as: d, passProps: f = a.passProps, _vks: p, style: m, ...h } = i, g = { passProps: f };
|
|
6
|
-
if (a.attr) for (let [e, t] of Object.entries(a.attr)) t !== void 0 && (g[e] = t);
|
|
7
|
-
s && Object.assign(g, s);
|
|
8
|
-
let _ = { ...h };
|
|
9
|
-
if (a.defaultProps) for (let [e, t] of Object.entries(a.defaultProps)) _[e] === void 0 && (_[e] = t);
|
|
10
|
-
Object.assign(g, _);
|
|
11
|
-
let v = /* @__PURE__ */ new Set();
|
|
12
|
-
for (let e of String(o).split(" ")) e && v.add(e);
|
|
13
|
-
for (let e of String(c || "").split(" ")) e && v.add(e);
|
|
14
|
-
for (let e of String(l || "").split(" ")) e && v.add(e);
|
|
15
|
-
let y = {};
|
|
16
|
-
if (m && typeof m == "object") for (let [e, t] of Object.entries(m)) {
|
|
17
|
-
let r = n(t);
|
|
18
|
-
y[e] = r ? r.transformed : t;
|
|
19
|
-
}
|
|
20
|
-
let b = new Set(Array.isArray(p) ? p : []);
|
|
21
|
-
if (a.propValueKeys) for (let t of a.propValueKeys) {
|
|
22
|
-
let n = `css-${t}`, r = _[n];
|
|
23
|
-
r !== void 0 && (y[`--props-${e(t)}`] = r, b.add(n));
|
|
24
|
-
}
|
|
25
|
-
if (a.variantKeys) for (let e of a.variantKeys) {
|
|
26
|
-
let [n, r] = e.split("=");
|
|
27
|
-
if (_[n] !== void 0) {
|
|
28
|
-
let e = t(`${n}-${_[n]}`);
|
|
29
|
-
v.add(e), b.add(n);
|
|
30
|
-
} else if (r !== void 0) {
|
|
31
|
-
let e = t(`${n}-${r}`);
|
|
32
|
-
v.add(e);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
for (let e of b) f !== !0 && (Array.isArray(f) && f.includes(e) || typeof f == "string" && f === e || delete g[e]);
|
|
36
|
-
for (let e of r) delete g[e];
|
|
37
|
-
return {
|
|
38
|
-
class: [...v],
|
|
39
|
-
style: y,
|
|
40
|
-
rest: g,
|
|
41
|
-
element: d ?? u ?? a.element,
|
|
42
|
-
_vks: [...b]
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
//#endregion
|
|
46
|
-
export { i as resolveAstroProps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-registry.d.ts","sourceRoot":"","sources":["../src/framework-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAE7E,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAExG,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,EAa7C,CAAC;AAIF,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,OAAO,CAAC,kBAAkB,CAMvF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,cAAc,GAAG,SAOjE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-salty-file.d.ts","sourceRoot":"","sources":["../src/load-salty-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAOxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,KAAK,kBAAkB,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAwGzG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch-handlers.d.ts","sourceRoot":"","sources":["../src/watch-handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE9C,mFAAmF;AACnF,eAAO,MAAM,eAAe,GAAU,eAAe,aAAa,EAAE,2BAA2B,UAAU,KAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAiCtI,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,WAAW,GAAU,eAAe,aAAa,EAAE,UAAU,MAAM,EAAE,QAAQ;IAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAUjJ,CAAC"}
|
|
File without changes
|