@salty-css/astro 0.0.1-alpha.340 → 0.1.0-alpha.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,14 +1,14 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("@salty-css/core/compiler/helpers"),H=require("@salty-css/core/compiler/get-function-range"),J=require("@salty-css/core/compiler/as-class"),O=require("@salty-css/core/server"),P=require("@salty-css/core/util"),d=require("fs/promises"),x=require("path"),b=D=>{const g=new J.SaltyCompiler(D);return{name:"stylegen",configureServer(t){g.importFile=async c=>{const l=Date.now();return t.ssrLoadModule(`${c}?t=${l}`)}},buildStart:async()=>{await g.generateCss()},load:async t=>{var l,C;if(j.isSaltyFile(t)){const $=await g.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const h=new URLSearchParams(t.split("?")[1]).get("configFile");if(!h)return;const m=x.join($,"astro",h),y=await d.readFile(m,"utf-8");if(!y)return;try{const u=JSON.parse(y),{clientProps:o={},classNames:s="",tagIsComponent:f,tagName:r="div"}=u,w=u.imports||[],F=f?r:`props.element || "${o.element||r}"`;let p="";if(o.element&&f&&(p+=` element="${o.element}"`),o.attr)for(const[i,n]of Object.entries(o.attr))p+=` ${i}="${n}"`;p=p.trim();const v=o.variantKeys||[];return`---
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("@salty-css/core/compiler/helpers"),H=require("@salty-css/core/compiler/get-function-range"),J=require("@salty-css/core/compiler/salty-compiler"),O=require("@salty-css/core/server"),P=require("@salty-css/core/util"),d=require("fs/promises"),x=require("path"),b=D=>{const g=new J.SaltyCompiler(D);return{name:"stylegen",configureServer(t){g.importFile=async c=>{const l=Date.now();return t.ssrLoadModule(`${c}?t=${l}`)}},buildStart:async()=>{await g.generateCss()},load:async t=>{var l,C;if(j.isSaltyFile(t)){const $=await g.getDestDir();if(/.+\?configFile=(\w+).+/.test(t)){const h=new URLSearchParams(t.split("?")[1]).get("configFile");if(!h)return;const m=x.join($,"astro",h),y=await d.readFile(m,"utf-8");if(!y)return;try{const u=JSON.parse(y),{clientProps:o={},classNames:s="",tagIsComponent:f,tagName:a="div"}=u,w=u.imports||[],F=f?a:`props.element || "${o.element||a}"`;let p="";if(o.element&&f&&(p+=` element="${o.element}"`),o.attr)for(const[i,n]of Object.entries(o.attr))p+=` ${i}="${n}"`;p=p.trim();const v=o.variantKeys||[];return`---
2
2
  ${w.join(`
3
3
  `)}
4
4
  const { props } = Astro;
5
5
  const Element = ${F};
6
6
  const variantClasses = [
7
- ${v.map(i=>{const[n,a]=i.split("=");return`props.${n} !== undefined ? "${n}-" + props.${n} : ${a!==void 0?`"${n}-${a}"`:'""'}`}).join(`,
7
+ ${v.map(i=>{const[n,r]=i.split("=");return`props.${n} !== undefined ? "${n}-" + props.${n} : ${r!==void 0?`"${n}-${r}"`:'""'}`}).join(`,
8
8
  `)}
9
9
  ]
10
10
  ---
11
- <Element class:list={["${s}", ...variantClasses, props.class]} ${p} {...props}><slot/></Element>`}catch(u){console.error("Error parsing config file:",u);return}}const R=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],q=[],N=[],S=await d.readFile(t,"utf-8"),k=await g.compileSaltyFile(t,$),I=Object.entries(k.contents);for(const[e,h]of I){const m=await j.resolveExportValue(h,1);if(!m.generator)continue;if(m.isClassName){const i=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}});q.push(`const ${e} = classNameInstance(${JSON.stringify(i.params)});`),N.push(e);continue}const[y,u]=await H.getFunctionRange(S,e),o=S.slice(y,u),s=(C=(l=/styled\(([^,]+),/.exec(o))==null?void 0:l.at(1))==null?void 0:C.trim();if(!s){console.warn(`Could not determine tag name for ${e} in ${t}`);continue}const f=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}}),r={componentName:e,tagName:s.replace(/['"`]/g,""),tagIsComponent:!1,classNames:f.classNames,imports:[],clientProps:f.clientProps},w=/^\w+$/.test(s);if(r.tagIsComponent=w,w){const i=I.some(([a])=>a===s),n=S.match(new RegExp(`import[^;]*${s}[^;]*;`));if(i){const a=P.toHash(s),_=`import ${s} from '${t}.astro?configFile=${a}.config';`;r.imports=[_]}else if(n){const a=n.at(0);r.imports=[a]}}const F=x.join($,"astro");await d.readFile(F,"utf-8").catch(()=>!1)||await d.mkdir(F,{recursive:!0});const v=P.toHash(e),E=x.join($,"astro",`${v}.config`);await d.writeFile(E,JSON.stringify(r)),R.push(`import ${e} from '${t}.astro?configFile=${v}.config';`),N.push(e)}return`${R.join(`
11
+ <Element class:list={["${s}", ...variantClasses, props.class]} ${p} {...props}><slot/></Element>`}catch(u){console.error("Error parsing config file:",u);return}}const R=["import { classNameInstance } from '@salty-css/core/instances/classname-instance';"],q=[],N=[],S=await d.readFile(t,"utf-8"),k=await g.compileSaltyFile(t,$),I=Object.entries(k.contents);for(const[e,h]of I){const m=await j.resolveExportValue(h,1);if(!m.generator)continue;if(m.isClassName){const i=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}});q.push(`const ${e} = classNameInstance(${JSON.stringify(i.params)});`),N.push(e);continue}const[y,u]=await H.getFunctionRange(S,e),o=S.slice(y,u),s=(C=(l=/styled\(([^,]+),/.exec(o))==null?void 0:l.at(1))==null?void 0:C.trim();if(!s){console.warn(`Could not determine tag name for ${e} in ${t}`);continue}const f=m.generator._withBuildContext({callerName:e,isProduction:!1,config:{}}),a={componentName:e,tagName:s.replace(/['"`]/g,""),tagIsComponent:!1,classNames:f.classNames,imports:[],clientProps:f.clientProps},w=/^\w+$/.test(s);if(a.tagIsComponent=w,w){const i=I.some(([r])=>r===s),n=S.match(new RegExp(`import[^;]*${s}[^;]*;`));if(i){const r=P.toHash(s),_=`import ${s} from '${t}.astro?configFile=${r}.config';`;a.imports=[_]}else if(n){const r=n.at(0);a.imports=[r]}}const F=x.join($,"astro");await d.readFile(F,"utf-8").catch(()=>!1)||await d.mkdir(F,{recursive:!0});const v=P.toHash(e),E=x.join($,"astro",`${v}.config`);await d.writeFile(E,JSON.stringify(a)),R.push(`import ${e} from '${t}.astro?configFile=${v}.config';`),N.push(e)}return`${R.join(`
12
12
  `)}
13
13
  ${q.join(`
14
14
  `)}
@@ -1,6 +1,6 @@
1
1
  import { isSaltyFile as D, resolveExportValue as A } from "@salty-css/core/compiler/helpers";
2
2
  import { getFunctionRange as B } from "@salty-css/core/compiler/get-function-range";
3
- import { SaltyCompiler as H } from "@salty-css/core/compiler/as-class";
3
+ import { SaltyCompiler as H } from "@salty-css/core/compiler/salty-compiler";
4
4
  import { checkShouldRestart as O } from "@salty-css/core/server";
5
5
  import { toHash as P } from "@salty-css/core/util";
6
6
  import { readFile as x, mkdir as K, writeFile as L } from "fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/astro",
3
- "version": "0.0.1-alpha.340",
3
+ "version": "0.1.0-alpha.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -66,7 +66,7 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "@salty-css/core": "^0.0.1-alpha.340",
69
+ "@salty-css/core": "^0.1.0-alpha.0",
70
70
  "astro": "^5.13.2",
71
71
  "vite": "^6.3.5"
72
72
  }