@helfy/helfy 0.0.8 → 0.0.9

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.
Files changed (40) hide show
  1. package/README.md +264 -109
  2. package/babel-preset.js +2 -1
  3. package/dist/Helfy/Render/DOM.d.ts +2 -0
  4. package/dist/app/createApp.d.ts +3 -1
  5. package/dist/app/index.d.ts +1 -1
  6. package/dist/app/types.d.ts +10 -0
  7. package/dist/compiler/babel.js +20 -13
  8. package/dist/decorators/Context.decorator.d.ts +22 -5
  9. package/dist/decorators/Effect.decorator.d.ts +1 -1
  10. package/dist/decorators/Inject.decorator.d.ts +8 -3
  11. package/dist/decorators/InjectContainer.decorator.d.ts +16 -0
  12. package/dist/decorators/Store.decorator.d.ts +12 -3
  13. package/dist/decorators/UseCase.decorator.d.ts +21 -0
  14. package/dist/di/InjectParam.decorator.d.ts +0 -11
  15. package/dist/di/Injectable.decorator.d.ts +2 -0
  16. package/dist/di/createViewInstance.d.ts +4 -5
  17. package/dist/di/index.d.ts +3 -2
  18. package/dist/http/ApiClient.decorator.d.ts +19 -0
  19. package/dist/http/FetchHttpClient.d.ts +17 -0
  20. package/dist/http/HttpClient.types.d.ts +19 -0
  21. package/dist/http/Mutation.types.d.ts +22 -0
  22. package/dist/http/MutationBuilder.d.ts +17 -0
  23. package/dist/http/Query.types.d.ts +22 -0
  24. package/dist/http/QueryBuilder.d.ts +16 -0
  25. package/dist/http/QueryCache.d.ts +13 -0
  26. package/dist/http/index.d.ts +18 -0
  27. package/dist/http/mutationConfig.decorator.d.ts +19 -0
  28. package/dist/http/queryConfig.decorator.d.ts +9 -0
  29. package/dist/http/useInfiniteQuery.decorator.d.ts +45 -0
  30. package/dist/http/useMutation.decorator.d.ts +21 -0
  31. package/dist/http/useQuery.decorator.d.ts +25 -0
  32. package/dist/index.d.ts +6 -6
  33. package/dist/index.js +2 -2
  34. package/dist/router/core.d.ts +2 -2
  35. package/dist/router/decorators.d.ts +4 -4
  36. package/dist/router.js +1 -1
  37. package/dist/signals.d.ts +7 -1
  38. package/package.json +1 -1
  39. package/dist/decorators/Observe.decorator.d.ts +0 -1
  40. package/dist/decorators/Provide.decorator.d.ts +0 -22
@@ -1,26 +1,33 @@
1
- var j=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var V=j((Ae,$)=>{var S=require("fs"),w=require("path"),{parse:ee}=require("@babel/parser"),te=require("@babel/traverse").default,je=w.resolve(process.cwd(),process.argv[2]||"src"),Ne=w.resolve(process.cwd(),process.argv[3]||".helfy");function q(t,r=[]){if(!S.existsSync(t))return r;let e=S.readdirSync(t,{withFileTypes:!0});for(let n of e){let s=w.join(t,n.name);n.isDirectory()&&n.name!=="node_modules"&&n.name!=="generated"&&n.name!==".helfy"?q(s,r):n.isFile()&&/\.(ts|tsx)$/.test(n.name)&&r.push(s)}return r}function ne(t,r){let e=[],n=w.resolve(process.cwd(),r||".helfy");for(let s of t){let i=S.readFileSync(s,"utf-8"),o=()=>{let a=[],y=/@Injectable\s*<(\w+)>\s*\(\s*\)/g,h=/export\s+(?:default\s+)?class\s+(\w+)/g,g,c=[];for(;(g=y.exec(i))!==null;)c.push(g[1]);let p=[];for(;(g=h.exec(i))!==null;)p.push(g[1]);if(c.length&&p.length){let f=c[c.length-1],d=p[p.length-1],u=w.relative(n,s).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),x=u.startsWith(".")?u:"./"+u;a.push({interfaceName:f,className:d,filePath:s,importPath:x})}return a},m;try{m=ee(i,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(a){let y=o();e.push(...y);continue}te(m,{ClassDeclaration(a){var h,g;let y=(h=a.node.id)==null?void 0:h.name;if(y)for(let c of a.node.decorators||[]){let p=c.expression;if(p.type!=="CallExpression")continue;let f=p.callee;if((f.name||(f.type==="Identifier"?f.name:null))!=="Injectable")continue;let u=f.typeParameters||p.typeParameters;if(!u||!((g=u.params)!=null&&g.length))continue;let x=u.params[0],b=null;if(x.type==="TSTypeReference"&&x.typeName&&(b=x.typeName.name),!b)continue;let _=w.relative(n,s).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),I=_.startsWith(".")?_:"./"+_;e.push({interfaceName:b,className:y,filePath:s,importPath:I})}}})}return e}function re(t){return t.length===0?`// Auto-generated by helfy di-scanner. No @Injectable<IX>() found.
1
+ var H=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var ae=H((ct,z)=>{var $=require("fs"),E=require("path"),{parse:se}=require("@babel/parser"),ie=require("@babel/traverse").default,it=E.resolve(process.cwd(),process.argv[2]||"src"),ot=E.resolve(process.cwd(),process.argv[3]||".helfy");function oe(n,r=[]){if(!$.existsSync(n))return r;let e=$.readdirSync(n,{withFileTypes:!0});for(let t of e){let i=E.join(n,t.name);t.isDirectory()&&t.name!=="node_modules"&&t.name!=="generated"&&t.name!==".helfy"?oe(i,r):t.isFile()&&/\.(ts|tsx)$/.test(t.name)&&r.push(i)}return r}function be(n,r){let e=[],t=E.resolve(process.cwd(),r||".helfy");for(let i of n){let s=$.readFileSync(i,"utf-8"),a=()=>{let l=[],p=/@(?:Injectable|Service|UseCase|ApiClient)\s*<(\w+)>\s*\(\s*\)/g,y=/export\s+(?:default\s+)?class\s+(\w+)/g,u,f=[];for(;(u=p.exec(s))!==null;)f.push(u[1]);let m=[];for(;(u=y.exec(s))!==null;)m.push(u[1]);if(f.length&&m.length){let d=f[f.length-1],h=m[m.length-1],g=E.relative(t,i).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),N=g.startsWith(".")?g:"./"+g;l.push({interfaceName:d,className:h,filePath:i,importPath:N})}return l},c;try{c=se(s,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(l){let p=a();e.push(...p);continue}ie(c,{ClassDeclaration(l){var y,u;let p=(y=l.node.id)==null?void 0:y.name;if(p)for(let f of l.node.decorators||[]){let m=f.expression;if(m.type!=="CallExpression")continue;let d=m.callee,h=d.name||(d.type==="Identifier"?d.name:null);if(h!=="Injectable"&&h!=="Service"&&h!=="UseCase"&&h!=="ApiClient")continue;let g=d.typeParameters||m.typeParameters;if(!g||!((u=g.params)!=null&&u.length))continue;let N=g.params[0],I=null;if(N.type==="TSTypeReference"&&N.typeName&&(I=N.typeName.name),!I)continue;let C=E.relative(t,i).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),x=C.startsWith(".")?C:"./"+C;e.push({interfaceName:I,className:p,filePath:i,importPath:x})}}})}return e}function we(n,r){let e=[],t=E.resolve(process.cwd(),r||".helfy");for(let i of n){let s=$.readFileSync(i,"utf-8"),a=()=>{let p=[],y=/@Store\s*\(?\s*\)?/g,u=/export\s+(?:default\s+)?class\s+(\w+)/g,f,m=y.exec(s)!==null,d=[];for(;(f=u.exec(s))!==null;)d.push(f[1]);if(m&&d.length){let h=d[d.length-1],g=E.relative(t,i).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),N=g.startsWith(".")?g:"./"+g,I=/export\s+default\s+(\w+)/.test(s)||/export\s+default\s+class\s+/.test(s);p.push({className:h,filePath:i,importPath:N,defaultExport:I})}return p},c;try{c=se(s,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(p){let y=a();e.push(...y);continue}let l=Pe(c);ie(c,{ClassDeclaration(p){var u,f;let y=(u=p.node.id)==null?void 0:u.name;if(y)for(let m of p.node.decorators||[]){let d=m.expression,h=null,g=null;if(d.type==="CallExpression"){let x=d.callee;h=x.name||(x.type==="Identifier"?x.name:null);let S=x.typeParameters||d.typeParameters;if((f=S==null?void 0:S.params)!=null&&f.length){let _=S.params[0];(_==null?void 0:_.type)==="TSTypeReference"&&_.typeName&&(g=_.typeName.name)}}else d.type==="Identifier"&&(h=d.name);if(h!=="Store")continue;let N=E.relative(t,i).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),I=N.startsWith(".")?N:"./"+N,C=l===y||p.findParent(x=>{var S;return(S=x.isExportDefaultDeclaration)==null?void 0:S.call(x)});e.push({className:y,filePath:i,importPath:I,defaultExport:C,interfaceName:g})}}})}return e}function Pe(n){for(let r of n.program.body)if(r.type==="ExportDefaultDeclaration"){let e=r.declaration;if((e==null?void 0:e.type)==="Identifier")return e.name;if((e==null?void 0:e.type)==="ClassDeclaration"&&e.id)return e.id.name}return null}function Ee(n,r){let e=n.map(s=>` ${s.interfaceName}: Symbol.for("helfy:di:${s.interfaceName}"),`),t=r.map(s=>s.interfaceName?` ${s.interfaceName}: Symbol.for("helfy:di:${s.interfaceName}"),`:` ${s.className}: Symbol.for("helfy:di:${s.className}"),`),i=[...e,...t];return i.length===0?`// Auto-generated by helfy di-scanner. No @Injectable/@Service/@Store found.
2
2
  export const __DI__ = {} as Record<string, symbol>;
3
3
  `:`// Auto-generated by helfy di-scanner. Do not edit.
4
4
  export const __DI__ = {
5
- ${t.map(e=>` ${e.interfaceName}: Symbol.for("helfy:di:${e.interfaceName}"),`).join(`
5
+ ${i.join(`
6
6
  `)}
7
7
  } as const;
8
- `}function ie(t){if(t.length===0)return`// Auto-generated by helfy di-scanner. No @Injectable<IX>() found.
8
+ `}function De(n,r){if(!(n.length>0||r.length>0))return`// Auto-generated by helfy di-scanner. No @Injectable/@Service/@Store found.
9
9
  import type { Container } from "@helfy/helfy";
10
10
  import { __DI__ } from "./di-tokens";
11
11
 
12
12
  export function registerAllServices(_container: Container): void {}
13
- `;let r=t.map(s=>` container.bind(__DI__.${s.interfaceName}, { useClass: ${s.className} });`),e=t.map(s=>`import { ${s.className} } from "${s.importPath}";`);return`// Auto-generated by helfy di-scanner. Do not edit.
13
+ `;let t=n.map(l=>` container.bind(__DI__.${l.interfaceName}, { useClass: ${l.className} });`),i=r.map(l=>l.interfaceName?` container.bind(__DI__.${l.interfaceName}, { useClass: ${l.className} });`:` container.bind(${l.className}, { useClass: ${l.className} });`),s=n.map(l=>`import { ${l.className} } from "${l.importPath}";`),a=r.map(l=>l.defaultExport?`import ${l.className} from "${l.importPath}";`:`import { ${l.className} } from "${l.importPath}";`);return`// Auto-generated by helfy di-scanner. Do not edit.
14
14
  import { Container } from "@helfy/helfy";
15
15
  import { __DI__ } from "./di-tokens";
16
- ${[...new Set(e)].join(`
16
+ ${[...new Set([...s,...a])].join(`
17
17
  `)}
18
18
 
19
19
  export function registerAllServices(container: Container): void {
20
- ${r.join(`
20
+ ${[...t,...i].join(`
21
21
  `)}
22
22
  }
23
- `}function M(t,r){let e=w.resolve(process.cwd(),t||"src"),n=w.resolve(process.cwd(),r||".helfy");if(!S.existsSync(e))return 0;let s=q(e),i=ne(s,n),o={};for(let a of i)(o[a.interfaceName]=o[a.interfaceName]||[]).push(a);for(let[a,y]of Object.entries(o))if(y.length>1)throw new Error(`[helfy-di] Multiple implementations for ${a}: `+y.map(h=>h.className).join(", "));S.mkdirSync(n,{recursive:!0}),S.writeFileSync(w.join(n,"di-tokens.ts"),re(i),"utf-8"),S.writeFileSync(w.join(n,"di-registry.ts"),ie(i),"utf-8");let m=i.map(a=>a.interfaceName);return S.writeFileSync(w.join(n,"di-interfaces.json"),JSON.stringify(m),"utf-8"),i.length}function se(){let t=w.resolve(process.cwd(),process.argv[2]||"src"),r=w.resolve(process.cwd(),process.argv[3]||".helfy");S.existsSync(t)||(console.warn("[helfy-di] src dir not found:",t),process.exit(0));try{let e=M(process.argv[2],process.argv[3]);console.log(`[helfy-di] Generated di-registry.ts with ${e} bindings`)}catch(e){console.error(e.message),process.exit(1)}}require.main===$&&se();$.exports={runScan:M}});var H=j((Re,T)=>{var C=require("fs"),P=require("path"),{parse:oe}=require("@babel/parser"),ce=require("@babel/traverse").default;function O(t,r=[]){if(!C.existsSync(t))return r;let e=C.readdirSync(t,{withFileTypes:!0});for(let n of e){let s=P.join(t,n.name);n.isDirectory()&&n.name!=="node_modules"&&n.name!=="generated"&&n.name!==".helfy"?O(s,r):n.isFile()&&/\.(ts|tsx)$/.test(n.name)&&r.push(s)}return r}function ae(t,r,e){let n=[],s=P.resolve(process.cwd(),r||"src"),i=P.resolve(process.cwd(),e||".helfy");for(let o of t){let m=C.readFileSync(o,"utf-8"),a=()=>{let h=[],g=/@View\s*(?:\([^)]*\))?\s*(?:\r?\n)+\s*export\s+(?:default\s+)?class\s+(\w+)/g,c;for(;(c=g.exec(m))!==null;){let p=c[1],f=P.relative(s,o).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),d=f.startsWith(".")?f.slice(1):f,u=P.relative(i,o).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),x=u.startsWith(".")?u:"./"+u;h.push({className:p,modulePath:d,importPath:x})}return h},y;try{y=oe(m,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(h){n.push(...a());continue}ce(y,{ClassDeclaration(h){var c;let g=(c=h.node.id)==null?void 0:c.name;if(g)for(let p of h.node.decorators||[]){let f=p.expression,d=null;if(f.type==="CallExpression"){let I=f.callee;d=I.name||(I.type==="Identifier"?I.name:null)}else f.type==="Identifier"&&(d=f.name);if(d!=="View")continue;let u=P.relative(s,o).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),x=u.startsWith(".")?u.slice(1):u,b=P.relative(i,o).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),_=b.startsWith(".")?b:"./"+b;n.push({className:g,modulePath:x,importPath:_});break}}})}return n}function le(t){if(t.length===0)return`// Auto-generated by helfy view-scanner. No @View classes found.
23
+ `}function ce(n,r){let e=E.resolve(process.cwd(),n||"src"),t=E.resolve(process.cwd(),r||".helfy");if(!$.existsSync(e))return 0;let i=oe(e),s=be(i,t),a=we(i,t),c={};for(let p of s)(c[p.interfaceName]=c[p.interfaceName]||[]).push(p);for(let[p,y]of Object.entries(c))if(y.length>1)throw new Error(`[helfy-di] Multiple implementations for ${p}: `+y.map(u=>u.className).join(", "));$.mkdirSync(t,{recursive:!0}),$.writeFileSync(E.join(t,"di-tokens.ts"),Ee(s,a),"utf-8"),$.writeFileSync(E.join(t,"di-registry.ts"),De(s,a),"utf-8");let l=[...s.map(p=>p.interfaceName),...a.map(p=>p.interfaceName||p.className)].filter(Boolean);return $.writeFileSync(E.join(t,"di-interfaces.json"),JSON.stringify(l),"utf-8"),s.length+a.length}function Te(){let n=E.resolve(process.cwd(),process.argv[2]||"src"),r=E.resolve(process.cwd(),process.argv[3]||".helfy");$.existsSync(n)||(console.warn("[helfy-di] src dir not found:",n),process.exit(0));try{let e=ce(process.argv[2],process.argv[3]);console.log(`[helfy-di] Generated di-registry.ts with ${e} bindings`)}catch(e){console.error(e.message),process.exit(1)}}require.main===z&&Te();z.exports={runScan:ce}});var pe=H((at,Z)=>{var F=require("fs"),q=require("path"),{parse:Ae}=require("@babel/parser"),Re=require("@babel/traverse").default;function le(n,r=[]){if(!F.existsSync(n))return r;let e=F.readdirSync(n,{withFileTypes:!0});for(let t of e){let i=q.join(n,t.name);t.isDirectory()&&t.name!=="node_modules"&&t.name!=="generated"&&t.name!==".helfy"?le(i,r):t.isFile()&&/\.(ts|tsx)$/.test(t.name)&&r.push(i)}return r}function je(n){let r=[],e=new Set;for(let t of n){let i=F.readFileSync(t,"utf-8"),s=()=>{let c=[],l=/@Context\s*<(\w+)>\s*\(\s*\)/g,p=/@useCtx\s*<(\w+)>\s*(?:\()?/g,y=/export\s+(?:default\s+)?class\s+(\w+)/g,u,f=[];for(;(u=l.exec(i))!==null;)f.push(u[1]);let m=[];for(;(u=p.exec(i))!==null;)m.push(u[1]);let d=[];for(;(u=y.exec(i))!==null;)d.push(u[1]);if(f.length&&d.length){let h=f[f.length-1],g=d[d.length-1];c.push({interfaceName:h,className:g,filePath:t})}return f.forEach(h=>e.add(h)),m.forEach(h=>e.add(h)),c},a;try{a=Ae(i,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(c){let l=s();r.push(...l);continue}Re(a,{ClassDeclaration(c){var p,y;let l=(p=c.node.id)==null?void 0:p.name;if(l)for(let u of c.node.decorators||[]){let f=u.expression;if(f.type!=="CallExpression")continue;let m=f.callee;if((m.name||(m.type==="Identifier"?m.name:null))!=="Context")continue;let h=m.typeParameters||f.typeParameters;if(!h||!((y=h.params)!=null&&y.length))continue;let g=h.params[0],N=null;g.type==="TSTypeReference"&&g.typeName&&(N=g.typeName.name),N&&(r.push({interfaceName:N,className:l,filePath:t}),e.add(N))}},CallExpression(c){var f,m;let l=c.node.callee;if((l.type==="Identifier"?l.name:l.type==="MemberExpression"&&((f=l.property)==null?void 0:f.name)||null)!=="useCtx")return;let y=l.typeParameters||c.node.typeParameters;if(!((m=y==null?void 0:y.params)!=null&&m.length))return;let u=y.params[0];u.type==="TSTypeReference"&&u.typeName&&e.add(u.typeName.name)}})}return{contextBindings:r,allInterfaces:Array.from(e)}}function $e(n){return n.length===0?`// Auto-generated by helfy ctx-scanner. No @Context<IX>() or @useCtx<IX>() found.
24
+ export const __CTX__ = {} as Record<string, symbol>;
25
+ `:`// Auto-generated by helfy ctx-scanner. Do not edit.
26
+ export const __CTX__ = {
27
+ ${n.map(e=>` ${e}: Symbol.for("helfy:ctx:${e}"),`).join(`
28
+ `)}
29
+ } as const;
30
+ `}function fe(n,r){let e=q.resolve(process.cwd(),n||"src"),t=q.resolve(process.cwd(),r||".helfy");if(!F.existsSync(e))return 0;let i=le(e),{contextBindings:s,allInterfaces:a}=je(i),c={};for(let p of s)(c[p.interfaceName]=c[p.interfaceName]||[]).push(p);for(let[p,y]of Object.entries(c))if(y.length>1)throw new Error(`[helfy-ctx] Multiple implementations for ${p}: `+y.map(u=>u.className).join(", "));F.mkdirSync(t,{recursive:!0}),F.writeFileSync(q.join(t,"ctx-tokens.ts"),$e(a),"utf-8");let l=a;return F.writeFileSync(q.join(t,"ctx-interfaces.json"),JSON.stringify(l),"utf-8"),a.length}function ke(){let n=q.resolve(process.cwd(),process.argv[2]||"src"),r=q.resolve(process.cwd(),process.argv[3]||".helfy");F.existsSync(n)||(console.warn("[helfy-ctx] src dir not found:",n),process.exit(0));try{let e=fe(process.argv[2],process.argv[3]);console.log(`[helfy-ctx] Generated ctx-tokens.ts with ${e} bindings`)}catch(e){console.error(e.message),process.exit(1)}}require.main===Z&&ke();Z.exports={runContextScan:fe}});var de=H((lt,ee)=>{var M=require("fs"),R=require("path"),{parse:Le}=require("@babel/parser"),Fe=require("@babel/traverse").default;function ue(n,r=[]){if(!M.existsSync(n))return r;let e=M.readdirSync(n,{withFileTypes:!0});for(let t of e){let i=R.join(n,t.name);t.isDirectory()&&t.name!=="node_modules"&&t.name!=="generated"&&t.name!==".helfy"?ue(i,r):t.isFile()&&/\.(ts|tsx)$/.test(t.name)&&r.push(i)}return r}function qe(n,r,e){let t=[],i=R.resolve(process.cwd(),r||"src"),s=R.resolve(process.cwd(),e||".helfy");for(let a of n){let c=M.readFileSync(a,"utf-8"),l=()=>{let y=[],u=/@View\s*(?:\([^)]*\))?\s*(?:\r?\n)+\s*export\s+(?:default\s+)?class\s+(\w+)/g,f;for(;(f=u.exec(c))!==null;){let m=f[1],d=R.relative(i,a).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),h=d.startsWith(".")?d.slice(1):d,g=R.relative(s,a).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),N=g.startsWith(".")?g:"./"+g;y.push({className:m,modulePath:h,importPath:N})}return y},p;try{p=Le(c,{sourceType:"module",plugins:["typescript","decorators-legacy","jsx"]})}catch(y){t.push(...l());continue}Fe(p,{ClassDeclaration(y){var f;let u=(f=y.node.id)==null?void 0:f.name;if(u)for(let m of y.node.decorators||[]){let d=m.expression,h=null;if(d.type==="CallExpression"){let x=d.callee;h=x.name||(x.type==="Identifier"?x.name:null)}else d.type==="Identifier"&&(h=d.name);if(h!=="View")continue;let g=R.relative(i,a).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),N=g.startsWith(".")?g.slice(1):g,I=R.relative(s,a).replace(/\\/g,"/").replace(/\.(ts|tsx)$/,""),C=I.startsWith(".")?I:"./"+I;t.push({className:u,modulePath:N,importPath:C});break}}})}return t}function Me(n){if(n.length===0)return`// Auto-generated by helfy view-scanner. No @View classes found.
24
31
  import type { HelfyViewComponent } from "@helfy/helfy";
25
32
 
26
33
  declare global {
@@ -32,13 +39,13 @@ declare global {
32
39
  export type HelfyViewInstance<T> = T extends { new (...args: any[]): infer I }
33
40
  ? I extends HelfyViewComponent ? I : never
34
41
  : never;
35
- `;let r=t.map(i=>` ${i.className}: InstanceType<typeof import("${i.importPath}").${i.className}>;`),e=[],n={};for(let i of t)n[i.modulePath]||(n[i.modulePath]=[]),n[i.modulePath].push(i.className);let s=` onMount?(): void;
42
+ `;let r=n.map(s=>` ${s.className}: InstanceType<typeof import("${s.importPath}").${s.className}>;`),e=[],t={};for(let s of n)t[s.modulePath]||(t[s.modulePath]=[]),t[s.modulePath].push(s.className);let i=` onMount?(): void;
36
43
  onAttached?(): void;
37
- onDestroy?(): void;`;for(let[i,o]of Object.entries(n)){let m=o.map(a=>` interface ${a} {
38
- ${s}
44
+ onDestroy?(): void;`;for(let[s,a]of Object.entries(t)){let c=a.map(l=>` interface ${l} {
45
+ ${i}
39
46
  }`).join(`
40
- `);e.push(`declare module "${i}" {
41
- ${m}
47
+ `);e.push(`declare module "${s}" {
48
+ ${c}
42
49
  }`)}return`// Auto-generated by helfy view-scanner. Do not edit.
43
50
 
44
51
  import type { HelfyViewComponent } from "@helfy/helfy";
@@ -59,4 +66,4 @@ export type HelfyViewInstance<T> = T extends { new (...args: any[]): infer I }
59
66
  ${e.join(`
60
67
 
61
68
  `)}
62
- `}function W(t,r){let e=P.resolve(process.cwd(),t||"src"),n=P.resolve(process.cwd(),r||".helfy");if(!C.existsSync(e))return 0;let s=O(e),i=ae(s,t,n),o=le(i);return C.mkdirSync(n,{recursive:!0}),C.writeFileSync(P.join(n,"helfy-views.d.ts"),o,"utf-8"),i.length}function fe(){let t=process.argv[2]||"src",r=process.argv[3]||".helfy";C.existsSync(P.resolve(process.cwd(),t))||(console.warn("[helfy-views] src dir not found:",t),process.exit(0));try{let e=W(t,r);console.log(`[helfy-views] Generated helfy-views.d.ts with ${e} View classes`)}catch(e){console.error(e.message),process.exit(1)}}require.main===T&&fe();T.exports={runViewScan:W}});var Y=j(($e,X)=>{var R=require("path"),J=require("fs"),l=require("@babel/types"),D=null;function ue(t){if(D)return D;let r=R.join(t,"di-interfaces.json");if(!J.existsSync(r))return D=[],D;try{D=JSON.parse(J.readFileSync(r,"utf-8"))}catch(e){D=[]}return D}function B(t,r,e="di-tokens"){let n=R.dirname(t),s=R.relative(n,r).replace(/\\/g,"/");return s.startsWith(".")||(s="./"+s),s+"/"+e}function U(t,r,e){var h,g,c;if(!(r!=null&&r.file))return null;let n=t.findParent(p=>p.isProgram());if(!n)return null;let s=((h=r.file.opts)==null?void 0:h.filename)||r.filename||"",i=B(s,e,"di-tokens"),o=n.node.body.find(p=>p.type==="ImportDeclaration"&&(p.source.value.includes("di-tokens")||p.source.value.includes("di-registry")));if(o)return((c=(g=o.specifiers.find(p=>{var f;return((f=p.imported)==null?void 0:f.name)==="__DI__"}))==null?void 0:g.local)==null?void 0:c.name)||"__DI__";let m=l.identifier("__DI__"),a=l.importSpecifier(m,m),y=l.importDeclaration([a],l.stringLiteral(i));return n.node.body.unshift(y),"__DI__"}function pe(t){return(t.node.decorators||[]).some(r=>{var n;let e=r.expression;return e.type==="CallExpression"&&((n=e.callee)==null?void 0:n.name)==="diParams"})}function de(t,r){if(!(r!=null&&r.file))return;let e=t.findParent(i=>i.isProgram());if(!e)return;let n=e.node.body.find(i=>i.type==="ImportDeclaration"&&(i.source.value==="@helfy/helfy"||i.source.value==="@helfy/helfy/"));if(!n){let i=l.importSpecifier(l.identifier("diParams"),l.identifier("diParams"));e.node.body.unshift(l.importDeclaration([i],l.stringLiteral("@helfy/helfy")));return}n.specifiers.some(i=>{var o,m;return((o=i.imported)==null?void 0:o.name)==="diParams"||((m=i.local)==null?void 0:m.name)==="diParams"})||n.specifiers.push(l.importSpecifier(l.identifier("diParams"),l.identifier("diParams")))}function me(t){var e,n,s;if(!t||t.type!=="CallExpression")return!1;let r=t.callee;if(r.type==="Identifier")return r.name==="createApp";if(r.type==="MemberExpression")return((e=r.property)==null?void 0:e.name)==="createApp";if(r.type==="SequenceExpression"&&((n=r.expressions)==null?void 0:n.length)===2){let i=r.expressions[1];if(i.type==="Identifier")return i.name==="createApp";if(i.type==="MemberExpression")return((s=i.property)==null?void 0:s.name)==="createApp"}return!1}function ye(t){var e,n;if(!t||t.type!=="CallExpression"||((e=t.arguments)==null?void 0:e.length)!==0)return!1;let r=t.callee;return r.type==="Identifier"&&r.name==="logger"||r.type==="MemberExpression"&&((n=r.property)==null?void 0:n.name)==="logger"}function he(t){let e=(t.type==="TSParameterProperty"?t.parameter:t).typeAnnotation;if(!(e!=null&&e.typeAnnotation))return null;let n=e.typeAnnotation;return n.type==="TSTypeReference"&&n.typeName&&n.typeName.name||null}var{runScan:ge}=V(),{runViewScan:xe}=H();X.exports=function(r,e){let n=R.resolve(process.cwd(),(e==null?void 0:e.generatedPath)||".helfy");function s(i,o){var g,c;let m=B(o,n,"di-registry"),a=i.node.body.find(p=>p.type==="ImportDeclaration"&&p.source.value.includes("di-registry")),y=(g=a==null?void 0:a.specifiers)==null?void 0:g.find(p=>{var f,d;return((f=p.imported)==null?void 0:f.name)==="registerAllServices"||((d=p.local)==null?void 0:d.name)==="registerAllServices"}),h=((c=y==null?void 0:y.local)==null?void 0:c.name)||"registerAllServices";if(!a){let p=l.importSpecifier(l.identifier("registerAllServices"),l.identifier("registerAllServices"));i.node.body.unshift(l.importDeclaration([p],l.stringLiteral(m)))}return h}return{name:"helfy-di",pre(){var i,o;ge((i=e==null?void 0:e.srcDir)!=null?i:"src",(e==null?void 0:e.generatedPath)||".helfy"),xe((o=e==null?void 0:e.srcDir)!=null?o:"src",(e==null?void 0:e.generatedPath)||".helfy")},visitor:{CallExpression(i,o){var u,x,b,_;let m=i.node,a=i.findParent(I=>I.isProgram());if(!a)return;let y=((x=(u=o.file)==null?void 0:u.opts)==null?void 0:x.filename)||o.filename||"";if(m.arguments.length===0){let I=m.callee;if(I.type==="MemberExpression"&&((b=I.property)==null?void 0:b.name)==="useDI"){let A=s(a,y);m.arguments.push(l.identifier(A));return}}if(!me(m))return;let h=i.parentPath;if(!h)return;let g=h.node;if(!g||g.type!=="MemberExpression"||i.key!=="object")return;let c=(_=g.property)==null?void 0:_.name;if(!["router","mount","configureContainer","container"].includes(c))return;let f=s(a,y),d=l.callExpression(l.memberExpression(m,l.identifier("useDI")),[l.identifier(f)]);i.replaceWith(d)},ClassDeclaration(i,o){var h,g,c,p;let m=ue(n);for(let f of i.node.decorators||[]){let d=f.expression;if(d.type!=="CallExpression")continue;let u=d.callee;if(u.name!=="Injectable")continue;let b=u.typeParameters||d.typeParameters;if(!((h=b==null?void 0:b.params)!=null&&h.length))continue;let _=b.params[0],I=null;if(_.type==="TSTypeReference"&&_.typeName&&(I=_.typeName.name),!I)continue;let A=U(i,o,n);if(!A)continue;let F=[l.memberExpression(l.identifier(A),l.identifier(I))],E=(g=d.arguments)==null?void 0:g[0];(E==null?void 0:E.type)==="StringLiteral"&&/^(singleton|transient|scoped)$/.test(E.value)&&F.push(E),f.expression=l.callExpression(l.identifier("Injectable"),F),delete u.typeParameters,d.typeParameters&&delete d.typeParameters}let a={};for(let f of i.node.body.body){if(f.type!=="ClassMethod"||((c=f.key)==null?void 0:c.name)!=="constructor")continue;let d=f.params,u=d.length-1;for(let x=0;x<d.length;x++){if(d.length>1&&x===u)continue;let b=d[x],_=he(b);if(!_||!m.includes(_))continue;let I=U(i,o,n);I&&(a[x]=l.memberExpression(l.identifier(I),l.identifier(_)))}break}if(Object.keys(a).length>0&&!pe(i)){let d=Object.keys(a).map(Number).sort((x,b)=>x-b).map(x=>l.objectProperty(l.numericLiteral(x),a[x]));de(i,o);let u=l.decorator(l.callExpression(l.identifier("diParams"),[l.objectExpression(d)]));i.node.decorators=i.node.decorators||[],i.node.decorators.unshift(u)}let y=(p=i.node.id)==null?void 0:p.name;if(y)for(let f of i.node.body.body){let d=f.decorators;if(Array.isArray(d))for(let u of d){let x=u.expression;ye(x)&&(u.expression=l.callExpression(x.callee,[l.stringLiteral(`<${y}>`)]))}}}}}}});var z=j((Te,K)=>{var v=require("@babel/types"),L=["_jsx","jsx","jsxs","_jsxs","jsxDEV","_jsxDEV"],ve=new Set(["$_ref","$_key","$slots","$_bind","$_bind_value","$_bind_checked","__source","__self","field"]);function be(t){var n,s;if(!t||t.type!=="CallExpression"||((n=t.arguments)==null?void 0:n.length)<2)return!1;let r=t.callee,e=r.type==="Identifier"?r.name:r.type==="MemberExpression"&&((s=r.property)==null?void 0:s.type)==="Identifier"?r.property.name:null;return e&&L.includes(e)}var G=["_if","_ifelse","_rIf","_rIfElse","forin","_forin","_rForin","_slot","_callSlot"];function N(t){var r;if(!t)return!1;if(t.type==="CallExpression"){let e=t.callee,n=(e==null?void 0:e.type)==="MemberExpression"&&((r=e.property)==null?void 0:r.type)==="Identifier"?e.property.name:(e==null?void 0:e.type)==="Identifier"?e.name:null;if(n&&(L.includes(n)||G.includes(n)))return!0}return t.type==="ConditionalExpression"?N(t.consequent)||N(t.alternate):t.type==="LogicalExpression"?N(t.left)||N(t.right):!1}function k(t){var r;if(!t||v.isStringLiteral(t)||v.isNumericLiteral(t)||v.isBooleanLiteral(t)||v.isNullLiteral(t)||t.type==="UnaryExpression"&&t.operator==="void")return!0;if(t.type==="CallExpression"){let e=t.callee,n=(e==null?void 0:e.type)==="MemberExpression"&&((r=e.property)==null?void 0:r.type)==="Identifier"?e.property.name:(e==null?void 0:e.type)==="Identifier"?e.name:null;if(n&&G.includes(n)||n&&L.includes(n))return!0}return!!N(t)}function Ie(t){if(!t||t.type!=="Identifier")return!1;let r=t.name;return!(ve.has(r)||r.startsWith("on")&&r.length>2||r.startsWith("$_"))}function _e(t,r){var i;let e=t.findParent(o=>o.isProgram());if(!e)return"createReactiveChild";let n=e.node.body.find(o=>o.type==="ImportDeclaration"&&(o.source.value==="@helfy/helfy"||o.source.value.endsWith("/helfy")));if(n){let o=n.specifiers.find(m=>{var a,y;return(((a=m.imported)==null?void 0:a.name)||((y=m.local)==null?void 0:y.name))==="createReactiveChild"});return o?((i=o.local)==null?void 0:i.name)||"createReactiveChild":(n.specifiers.push(v.importSpecifier(v.identifier("createReactiveChild"),v.identifier("createReactiveChild"))),"createReactiveChild")}let s=v.importSpecifier(v.identifier("createReactiveChild"),v.identifier("createReactiveChild"));return e.node.body.unshift(v.importDeclaration([s],v.stringLiteral("@helfy/helfy"))),"createReactiveChild"}function we(t){let r=t.findParent(e=>{var n,s,i,o;return((n=e.isClassMethod)==null?void 0:n.call(e))||((s=e.isObjectMethod)==null?void 0:s.call(e))||((i=e.isFunctionDeclaration)==null?void 0:i.call(e))&&((o=e.parent)==null?void 0:o.type)==="ClassBody"});if(!r&&typeof t.getFunctionParent=="function"){let e=t.getFunctionParent(),n=e==null?void 0:e.node;n&&(n.type==="ClassMethod"||n.type==="ClassPrivateMethod"||n.type==="ObjectMethod")&&(r=e)}return r?v.thisExpression():null}K.exports=function(r){return{name:"helfy-reactive-expressions",visitor:{CallExpression(e,n){var g;if(!be(e.node))return;let s=e.node.arguments[1];if(!s||s.type!=="ObjectExpression")return;let i=we(e),o=i!=null?i:v.nullLiteral(),m=_e(e,n),a=v.identifier(m);n.slotCounter==null&&(n.slotCounter=0);let y=()=>{let c=n.slotCounter;return n.slotCounter+=1,c};function h(c){return v.callExpression(a,[o,v.numericLiteral(y()),v.arrowFunctionExpression([],c)])}for(let c of s.properties){if(c.type!=="ObjectProperty"||c.computed)continue;let p=((g=c.key)==null?void 0:g.type)==="Identifier"?c.key.name:null;if(p){if(p==="children"){let f=c.value;if(k(f))continue;if(v.isArrayExpression(f)){let d=f.elements.map(u=>!u||v.isSpreadElement(u)||k(u)?u:h(u));c.value=v.arrayExpression(d)}else c.value=h(c.value);continue}Ie(c.key)&&(k(c.value)||(c.value=h(c.value)))}}}}}}});var Z=j((ke,Q)=>{var Pe=z();Q.exports=function(r,e){return{plugins:[[Pe,e||{}]]}}});var Se=Y(),Ce=Z();module.exports={diPlugin:Se,reactivePreset:Ce};
69
+ `}function me(n,r){let e=R.resolve(process.cwd(),n||"src"),t=R.resolve(process.cwd(),r||".helfy");if(!M.existsSync(e))return 0;let i=ue(e),s=qe(i,n,t),a=Me(s);return M.mkdirSync(t,{recursive:!0}),M.writeFileSync(R.join(t,"helfy-views.d.ts"),a,"utf-8"),s.length}function Ve(){let n=process.argv[2]||"src",r=process.argv[3]||".helfy";M.existsSync(R.resolve(process.cwd(),n))||(console.warn("[helfy-views] src dir not found:",n),process.exit(0));try{let e=me(n,r);console.log(`[helfy-views] Generated helfy-views.d.ts with ${e} View classes`)}catch(e){console.error(e.message),process.exit(1)}}require.main===ee&&Ve();ee.exports={runViewScan:me}});var ve=H((ft,xe)=>{var J=require("path"),Q=require("fs"),o=require("@babel/types"),V=null;function ye(n){if(V)return V;let r=J.join(n,"di-interfaces.json");if(!Q.existsSync(r))return V=[],V;try{V=JSON.parse(Q.readFileSync(r,"utf-8"))}catch(e){V=[]}return V}function te(n,r,e="di-tokens"){let t=J.dirname(n),i=J.relative(t,r).replace(/\\/g,"/");return i.startsWith(".")||(i="./"+i),i+"/"+e}function W(n,r,e){var y,u,f;if(!(r!=null&&r.file))return null;let t=n.findParent(m=>m.isProgram());if(!t)return null;let i=((y=r.file.opts)==null?void 0:y.filename)||r.filename||"",s=te(i,e,"di-tokens"),a=t.node.body.find(m=>m.type==="ImportDeclaration"&&(m.source.value.includes("di-tokens")||m.source.value.includes("di-registry")));if(a)return((f=(u=a.specifiers.find(m=>{var d;return((d=m.imported)==null?void 0:d.name)==="__DI__"}))==null?void 0:u.local)==null?void 0:f.name)||"__DI__";let c=o.identifier("__DI__"),l=o.importSpecifier(c,c),p=o.importDeclaration([l],o.stringLiteral(s));return t.node.body.unshift(p),"__DI__"}function Oe(n,r){if(!(r!=null&&r.file))return;let e=n.findParent(i=>i.isProgram());if(!e)return;let t=e.node.body.find(i=>i.type==="ImportDeclaration"&&(i.source.value==="@helfy/helfy"||i.source.value==="@helfy/helfy/"));if(t){t.specifiers.some(s=>{var a,c;return((a=s.imported)==null?void 0:a.name)==="HttpClientToken"||((c=s.local)==null?void 0:c.name)==="HttpClientToken"})||t.specifiers.push(o.importSpecifier(o.identifier("HttpClientToken"),o.identifier("HttpClientToken")));return}e.node.body.unshift(o.importDeclaration([o.importSpecifier(o.identifier("HttpClientToken"),o.identifier("HttpClientToken"))],o.stringLiteral("@helfy/helfy")))}function He(n){return(n.node.decorators||[]).some(r=>{var t;let e=r.expression;return e.type==="CallExpression"&&((t=e.callee)==null?void 0:t.name)==="diParams"})}function We(n,r){if(!(r!=null&&r.file))return;let e=n.findParent(s=>s.isProgram());if(!e)return;let t=e.node.body.find(s=>s.type==="ImportDeclaration"&&(s.source.value==="@helfy/helfy"||s.source.value==="@helfy/helfy/"));if(!t){let s=o.importSpecifier(o.identifier("diParams"),o.identifier("diParams"));e.node.body.unshift(o.importDeclaration([s],o.stringLiteral("@helfy/helfy")));return}t.specifiers.some(s=>{var a,c;return((a=s.imported)==null?void 0:a.name)==="diParams"||((c=s.local)==null?void 0:c.name)==="diParams"})||t.specifiers.push(o.importSpecifier(o.identifier("diParams"),o.identifier("diParams")))}function Be(n){var e,t,i;if(!n||n.type!=="CallExpression")return!1;let r=n.callee;if(r.type==="Identifier")return r.name==="createApp";if(r.type==="MemberExpression")return((e=r.property)==null?void 0:e.name)==="createApp";if(r.type==="SequenceExpression"&&((t=r.expressions)==null?void 0:t.length)===2){let s=r.expressions[1];if(s.type==="Identifier")return s.name==="createApp";if(s.type==="MemberExpression")return((i=s.property)==null?void 0:i.name)==="createApp"}return!1}function Xe(n){var e,t;if(!n||n.type!=="CallExpression"||((e=n.arguments)==null?void 0:e.length)!==0)return!1;let r=n.callee;return r.type==="Identifier"&&r.name==="logger"||r.type==="MemberExpression"&&((t=r.property)==null?void 0:t.name)==="logger"}function Ue(n){let e=(n.type==="TSParameterProperty"?n.parameter:n).typeAnnotation;if(!(e!=null&&e.typeAnnotation))return null;let t=e.typeAnnotation;return t.type==="TSTypeReference"&&t.typeName&&t.typeName.name||null}var{runScan:Je}=ae(),{runContextScan:Ge}=pe(),{runViewScan:Ye}=de(),O=null;function he(n){if(O)return O;let r=J.join(n,"ctx-interfaces.json");if(!Q.existsSync(r))return O=[],O;try{O=JSON.parse(Q.readFileSync(r,"utf-8"))}catch(e){O=[]}return O}function ge(n,r,e){var u,f,m,d;if(!(r!=null&&r.file))return null;let t=n.findParent?n.findParent(h=>h.isProgram()):null;if(!t||!((u=t.isProgram)!=null&&u.call(t)))return null;let i=t.node,s=((f=r.file.opts)==null?void 0:f.filename)||r.filename||"",a=te(s,e,"ctx-tokens"),c=i.body.find(h=>h.type==="ImportDeclaration"&&h.source.value.includes("ctx-tokens"));if(c)return((d=(m=c.specifiers.find(h=>{var g;return((g=h.imported)==null?void 0:g.name)==="__CTX__"}))==null?void 0:m.local)==null?void 0:d.name)||"__CTX__";let l=o.identifier("__CTX__"),p=o.importSpecifier(l,l),y=o.importDeclaration([p],o.stringLiteral(a));return i.body.unshift(y),"__CTX__"}xe.exports=function(r,e){let t=J.resolve(process.cwd(),(e==null?void 0:e.generatedPath)||".helfy");function i(s,a){var u,f;let c=te(a,t,"di-registry"),l=s.node.body.find(m=>m.type==="ImportDeclaration"&&m.source.value.includes("di-registry")),p=(u=l==null?void 0:l.specifiers)==null?void 0:u.find(m=>{var d,h;return((d=m.imported)==null?void 0:d.name)==="registerAllServices"||((h=m.local)==null?void 0:h.name)==="registerAllServices"}),y=((f=p==null?void 0:p.local)==null?void 0:f.name)||"registerAllServices";if(!l){let m=o.importSpecifier(o.identifier("registerAllServices"),o.identifier("registerAllServices"));s.node.body.unshift(o.importDeclaration([m],o.stringLiteral(c)))}return y}return{name:"helfy-di",pre(){var s,a,c;Je((s=e==null?void 0:e.srcDir)!=null?s:"src",(e==null?void 0:e.generatedPath)||".helfy"),Ge((a=e==null?void 0:e.srcDir)!=null?a:"src",(e==null?void 0:e.generatedPath)||".helfy"),Ye((c=e==null?void 0:e.srcDir)!=null?c:"src",(e==null?void 0:e.generatedPath)||".helfy")},visitor:{CallExpression(s,a){var x,S,_,D,k,B,K,X,L,T,j;let c=s.node,l=s.findParent(v=>v.isProgram());if(!l)return;let p=((S=(x=a.file)==null?void 0:x.opts)==null?void 0:S.filename)||a.filename||"",y=he(t),u=c.callee,f=u.type==="Identifier"?u.name:u.type==="MemberExpression"&&((_=u.property)==null?void 0:_.name)||null;if(f==="useCtx"){let v=u.typeParameters||c.typeParameters;if((D=v==null?void 0:v.params)!=null&&D.length){let b=v.params[0],w=null;if(b.type==="TSTypeReference"&&b.typeName&&(w=b.typeName.name),w&&y.includes(w)){let A=ge(s,a,t);if(A){let U=[o.memberExpression(o.identifier(A),o.identifier(w)),...c.arguments];s.replaceWith(o.callExpression(u,U));return}}}}let m=ye(t);if(f==="useInfiniteQuery"&&((k=c.arguments)==null?void 0:k.length)===1){let v=u.typeParameters||c.typeParameters;if((B=v==null?void 0:v.params)!=null&&B.length){let b=v.params[0],w=null;if(b.type==="TSTypeReference"&&b.typeName&&(w=b.typeName.name),w&&m.includes(w)){let A=W(s,a,t);if(A){let U=[o.memberExpression(o.identifier(A),o.identifier(w)),c.arguments[0]];s.replaceWith(o.callExpression(u,U));return}}}}if(f==="useMutation"||f==="useQuery"){let v=u.typeParameters||c.typeParameters;if((K=v==null?void 0:v.params)!=null&&K.length&&((X=c.arguments)==null?void 0:X.length)===1){let b=v.params[0],w=null;if(b.type==="TSTypeReference"&&b.typeName&&(w=b.typeName.name),w&&m.includes(w)){let A=W(s,a,t);if(A){let U=[o.memberExpression(o.identifier(A),o.identifier(w)),c.arguments[0]];s.replaceWith(o.callExpression(u,U));return}}}}if(f==="inject"){let v=u.typeParameters||c.typeParameters;if((L=v==null?void 0:v.params)!=null&&L.length&&(!c.arguments||c.arguments.length===0)){let b=v.params[0],w=null;if(b.type==="TSTypeReference"&&b.typeName&&(w=b.typeName.name),w&&m.includes(w)){let A=W(s,a,t);if(A){let Y=o.memberExpression(o.identifier(A),o.identifier(w));s.replaceWith(o.callExpression(u,[Y]));return}}}}if(c.arguments.length===0){let v=c.callee;if(v.type==="MemberExpression"&&((T=v.property)==null?void 0:T.name)==="useDI"){let b=i(l,p);c.arguments.push(o.identifier(b));return}}if(!Be(c))return;let d=s.parentPath;if(!d)return;let h=d.node;if(!h||h.type!=="MemberExpression"||s.key!=="object")return;let g=(j=h.property)==null?void 0:j.name;if(!["http","router","mount","configureContainer","container"].includes(g))return;let I=i(l,p),C=o.callExpression(o.memberExpression(c,o.identifier("useDI")),[o.identifier(I)]);s.replaceWith(C)},ClassDeclaration(s,a){var f,m,d,h,g,N;let c=ye(t),l=he(t);for(let I of s.node.decorators||[]){let C=I.expression;if(C.type!=="CallExpression")continue;let x=C.callee,S=x.name;if(S==="Context"){let T=x.typeParameters||C.typeParameters;if(!((f=T==null?void 0:T.params)!=null&&f.length))continue;let j=T.params[0],v=null;if(j.type==="TSTypeReference"&&j.typeName&&(v=j.typeName.name),!v||!l.includes(v))continue;let b=ge(s,a,t);if(!b)continue;let w=o.memberExpression(o.identifier(b),o.identifier(v));I.expression=o.callExpression(o.identifier("Context"),[w]),delete x.typeParameters,C.typeParameters&&delete C.typeParameters;continue}if(S==="Store"){let T=x.typeParameters||C.typeParameters;if(!((m=T==null?void 0:T.params)!=null&&m.length))continue;let j=T.params[0],v=null;if(j.type==="TSTypeReference"&&j.typeName&&(v=j.typeName.name),!v||!c.includes(v))continue;let b=W(s,a,t);if(!b)continue;let w=o.memberExpression(o.identifier(b),o.identifier(v));I.expression=o.callExpression(o.identifier("Store"),[w]),delete x.typeParameters,C.typeParameters&&delete C.typeParameters;continue}if(S!=="Injectable"&&S!=="Service"&&S!=="UseCase"&&S!=="ApiClient")continue;let _=x.typeParameters||C.typeParameters;if(!((d=_==null?void 0:_.params)!=null&&d.length))continue;let D=_.params[0],k=null;if(D.type==="TSTypeReference"&&D.typeName&&(k=D.typeName.name),!k)continue;let B=W(s,a,t);if(!B)continue;let X=[o.memberExpression(o.identifier(B),o.identifier(k))],L=(h=C.arguments)==null?void 0:h[0];(L==null?void 0:L.type)==="StringLiteral"&&/^(singleton|transient|scoped)$/.test(L.value)&&X.push(L),I.expression=o.callExpression(o.identifier(S),X),delete x.typeParameters,C.typeParameters&&delete C.typeParameters}let p={};if(!(s.node.decorators||[]).some(I=>{var x,S,_,D,k;let C=((S=(x=I.expression)==null?void 0:x.callee)==null?void 0:S.name)||((k=(D=(_=I.expression)==null?void 0:_.callee)==null?void 0:D.property)==null?void 0:k.name);return C==="View"||C==="Context"}))for(let I of s.node.body.body){if(I.type!=="ClassMethod"||((g=I.key)==null?void 0:g.name)!=="constructor")continue;let C=I.params;for(let x=0;x<C.length;x++){let S=C[x],_=Ue(S);if(!_)continue;if(_==="HttpClient"){Oe(s,a),p[x]=o.identifier("HttpClientToken");continue}if(!c.includes(_))continue;let D=W(s,a,t);D&&(p[x]=o.memberExpression(o.identifier(D),o.identifier(_)))}break}if(Object.keys(p).length>0&&!He(s)){let C=Object.keys(p).map(Number).sort((S,_)=>S-_).map(S=>o.objectProperty(o.numericLiteral(S),p[S]));We(s,a);let x=o.decorator(o.callExpression(o.identifier("diParams"),[o.objectExpression(C)]));s.node.decorators=s.node.decorators||[],s.node.decorators.unshift(x)}let u=(N=s.node.id)==null?void 0:N.name;if(u)for(let I of s.node.body.body){let C=I.decorators;if(Array.isArray(C))for(let x of C){let S=x.expression;Xe(S)&&(x.expression=o.callExpression(S.callee,[o.stringLiteral(`<${u}>`)]))}}}}}}});var Ie=H((pt,Se)=>{var P=require("@babel/types"),re=["_jsx","jsx","jsxs","_jsxs","jsxDEV","_jsxDEV"],Qe=new Set(["$_ref","$_key","$slots","$_bind","$_bind_value","$_bind_checked","__source","__self","field","$field"]);function Ke(n){var t,i;if(!n||n.type!=="CallExpression"||((t=n.arguments)==null?void 0:t.length)<2)return!1;let r=n.callee,e=r.type==="Identifier"?r.name:r.type==="MemberExpression"&&((i=r.property)==null?void 0:i.type)==="Identifier"?r.property.name:null;return e&&re.includes(e)}var Ce=["_if","_ifelse","_rIf","_rIfElse","forin","_forin","_rForin","_slot","_callSlot"];function G(n){var r;if(!n)return!1;if(n.type==="CallExpression"){let e=n.callee,t=(e==null?void 0:e.type)==="MemberExpression"&&((r=e.property)==null?void 0:r.type)==="Identifier"?e.property.name:(e==null?void 0:e.type)==="Identifier"?e.name:null;if(t&&(re.includes(t)||Ce.includes(t)))return!0}return n.type==="ConditionalExpression"?G(n.consequent)||G(n.alternate):n.type==="LogicalExpression"?G(n.left)||G(n.right):!1}function ne(n){var r;if(!n||P.isStringLiteral(n)||P.isNumericLiteral(n)||P.isBooleanLiteral(n)||P.isNullLiteral(n)||n.type==="UnaryExpression"&&n.operator==="void")return!0;if(n.type==="CallExpression"){let e=n.callee,t=(e==null?void 0:e.type)==="MemberExpression"&&((r=e.property)==null?void 0:r.type)==="Identifier"?e.property.name:(e==null?void 0:e.type)==="Identifier"?e.name:null;if(t&&Ce.includes(t)||t&&re.includes(t))return!0}return!!G(n)}function ze(n){if(!n||n.type!=="Identifier")return!1;let r=n.name;return!(Qe.has(r)||r.startsWith("on")&&r.length>2||r.startsWith("$_"))}function Ze(n,r){var s;let e=n.findParent(a=>a.isProgram());if(!e)return"createReactiveChild";let t=e.node.body.find(a=>a.type==="ImportDeclaration"&&(a.source.value==="@helfy/helfy"||a.source.value.endsWith("/helfy")));if(t){let a=t.specifiers.find(c=>{var l,p;return(((l=c.imported)==null?void 0:l.name)||((p=c.local)==null?void 0:p.name))==="createReactiveChild"});return a?((s=a.local)==null?void 0:s.name)||"createReactiveChild":(t.specifiers.push(P.importSpecifier(P.identifier("createReactiveChild"),P.identifier("createReactiveChild"))),"createReactiveChild")}let i=P.importSpecifier(P.identifier("createReactiveChild"),P.identifier("createReactiveChild"));return e.node.body.unshift(P.importDeclaration([i],P.stringLiteral("@helfy/helfy"))),"createReactiveChild"}function et(n){let r=n.findParent(e=>{var t,i,s,a;return((t=e.isClassMethod)==null?void 0:t.call(e))||((i=e.isObjectMethod)==null?void 0:i.call(e))||((s=e.isFunctionDeclaration)==null?void 0:s.call(e))&&((a=e.parent)==null?void 0:a.type)==="ClassBody"});if(!r&&typeof n.getFunctionParent=="function"){let e=n.getFunctionParent(),t=e==null?void 0:e.node;t&&(t.type==="ClassMethod"||t.type==="ClassPrivateMethod"||t.type==="ObjectMethod")&&(r=e)}return r?P.thisExpression():null}Se.exports=function(r){return{name:"helfy-reactive-expressions",visitor:{CallExpression(e,t){var u;if(!Ke(e.node))return;let i=e.node.arguments[1];if(!i||i.type!=="ObjectExpression")return;let s=et(e),a=s!=null?s:P.nullLiteral(),c=Ze(e,t),l=P.identifier(c);t.slotCounter==null&&(t.slotCounter=0);let p=()=>{let f=t.slotCounter;return t.slotCounter+=1,f};function y(f){return P.callExpression(l,[a,P.numericLiteral(p()),P.arrowFunctionExpression([],f)])}for(let f of i.properties){if(f.type!=="ObjectProperty"||f.computed)continue;let m=((u=f.key)==null?void 0:u.type)==="Identifier"?f.key.name:null;if(m){if(m==="children"){let d=f.value;if(ne(d))continue;if(P.isArrayExpression(d)){let h=d.elements.map(g=>!g||P.isSpreadElement(g)||ne(g)?g:y(g));f.value=P.arrayExpression(h)}else f.value=y(f.value);continue}ze(f.key)&&(ne(f.value)||(f.value=y(f.value)))}}}}}}});var _e=H((ut,Ne)=>{var tt=Ie();Ne.exports=function(r,e){return{plugins:[[tt,e||{}]]}}});var nt=ve(),rt=_e();module.exports={diPlugin:nt,reactivePreset:rt};
@@ -2,14 +2,31 @@
2
2
  export declare const CONTEXT_MARKER: unique symbol;
3
3
  /** Unique key for injector lookup (survives minification; set by @Context) */
4
4
  export declare const CONTEXT_INJECT_KEY: unique symbol;
5
+ /** Token for interface-based injection (set by @Context<IX>(__CTX__.IX)) */
6
+ export declare const CONTEXT_INTERFACE_TOKEN: unique symbol;
5
7
  export declare function isContextClass(ctor: unknown): ctor is new (...args: any[]) => any;
6
8
  export declare function getContextInjectKey(ctor: new (...args: any[]) => any): symbol;
7
9
  /**
8
10
  * Makes a class a non-rendering context provider.
9
11
  * The class does not implement render() — framework renders only its children.
10
- * Use @provide on fields to expose values for @inject lookup.
11
- * Use @provide({ reactive: true }) for reactive fields (consumers re-render on change).
12
+ * Uses @state for reactive fields, @computed for derived values.
13
+ * Public methods are exposed automatically. @effect for side-effects (not exposed).
14
+ *
15
+ * @param tokenOrBase - When called with symbol (from __CTX__), enables interface-based injection.
16
+ * When called with no args (@Context<IX>()), babel plugin transforms to Context(__CTX__.IX).
17
+ *
18
+ * Convention: DI params first, props last. Props come from JSX attributes.
19
+ * createViewInstance resolves DI from container/context; last arg = viewProps.
12
20
  */
13
- export declare function Context<T extends {
14
- new (...args: any[]): {};
15
- }>(Base: T): T;
21
+ type Constructor = new (...args: any[]) => {};
22
+ /** Extract props type from last constructor param. Developer defines props interface (same as View). */
23
+ type PropsParam<C> = C extends new (...args: [...infer _, infer P]) => any ? P : Record<string, unknown>;
24
+ /** For JSX: props from last param. DI params resolved by createViewInstance. */
25
+ export type ContextComponent<C extends Constructor> = new (props?: PropsParam<C>) => InstanceType<C>;
26
+ /** @Context<IX>() — babel plugin transforms to Context(__CTX__.IX). Type param IX is compile-time only. */
27
+ export declare function Context<T = void>(): <C extends Constructor>(Base: C) => C;
28
+ /** @Context — direct application, no factory */
29
+ export declare function Context<T extends Constructor>(Base: T): T;
30
+ /** @Context(__CTX__.IX) — interface token from babel plugin */
31
+ export declare function Context(token: symbol): <T extends Constructor>(Base: T) => T;
32
+ export {};
@@ -9,7 +9,7 @@ export declare const EFFECT_FIELDS: unique symbol;
9
9
  * console.log(this.priority);
10
10
  * }
11
11
  *
12
- * Внутри метода можно читать @state, @observe, @ctx и computed‑поля —
12
+ * Внутри метода можно читать @state, @useCtx и computed‑поля —
13
13
  * эффект будет переисполняться при изменении любых прочитанных реактивных полей.
14
14
  */
15
15
  export declare function effect(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
@@ -6,7 +6,7 @@ export interface InjectOptions {
6
6
  /** Subscribe to this field on the resolved context for scheduleUpdate (used when injecting full context) */
7
7
  subscribeField?: string;
8
8
  }
9
- /** Metadata for @inject fields */
9
+ /** Metadata for @useCtx fields */
10
10
  export declare const INJECT_FIELDS: unique symbol;
11
11
  export interface InjectDescriptor {
12
12
  key: any;
@@ -15,11 +15,16 @@ export interface InjectDescriptor {
15
15
  }
16
16
  /**
17
17
  * Injects a value from the hierarchical context chain.
18
- * @param ContextClass - Context class (injection key)
18
+ * @param token - Context class or symbol from __CTX__ (for interface-based injection)
19
19
  * @param fieldOrOptions - Field name for partial inject, or options
20
20
  * @param options - Optional: { optional, defaultValue }
21
+ *
22
+ * For interface-based injection, use @useCtx<IX>() or @useCtx<IX>("field") —
23
+ * babel plugin transforms to useCtx(__CTX__.IX) at compile time.
21
24
  */
22
- export declare function ctx(ContextClass: new (...args: any[]) => any, fieldOrOptions?: string | InjectOptions, options?: InjectOptions): (target: object, propertyKey: string | symbol) => void;
25
+ export declare function useCtx<T = void>(): (target: object, propertyKey: string | symbol) => void;
26
+ export declare function useCtx<T = void>(field: string): (target: object, propertyKey: string | symbol) => void;
27
+ export declare function useCtx(token: (new (...args: any[]) => any) | symbol, fieldOrOptions?: string | InjectOptions, options?: InjectOptions): (target: object, propertyKey: string | symbol) => void;
23
28
  /**
24
29
  * Hierarchical lookup: walk up _parentView, check _injector for key.
25
30
  */
@@ -0,0 +1,16 @@
1
+ /** Metadata for @inject fields (global container) */
2
+ export declare const INJECT_CONTAINER_FIELDS: unique symbol;
3
+ export interface InjectContainerDescriptor {
4
+ token: symbol | (new (...args: any[]) => any);
5
+ propertyKey: string | symbol;
6
+ }
7
+ /**
8
+ * Injects a value from the global DI container.
9
+ * Use for View/Context: DI via fields, constructor only receives props from JSX.
10
+ *
11
+ * @inject<IX>() private service!: IX;
12
+ * Babel plugin transforms to @inject(__DI__.IX).
13
+ */
14
+ export declare function inject<T = void>(): (target: object, propertyKey: string | symbol) => void;
15
+ export declare function inject(token: symbol | (new (...args: any[]) => any)): (target: object, propertyKey: string | symbol) => void;
16
+ export declare function resolveInjectContainer(token: symbol | (new (...args: any[]) => any)): unknown;
@@ -1,7 +1,16 @@
1
+ import type { InjectionToken } from "../di/Container";
1
2
  /** Static marker to identify @Store classes (used by logger for tag coloring) */
2
3
  export declare const STORE_MARKER: unique symbol;
3
- export declare function Store<T extends {
4
+ type Constructor = new (...args: any[]) => {};
5
+ /**
6
+ * @Store() — register by class.
7
+ * @Store<IX>() — Babel transforms to @Store(__DI__.IX), inject by interface.
8
+ * @Store(token) — register by interface token (runtime).
9
+ */
10
+ export declare function Store<T = void>(): <C extends Constructor>(target: C) => C & {
4
11
  new (...args: any[]): {};
5
- }>(Base: T): {
12
+ };
13
+ export declare function Store<T = void>(token: InjectionToken): <C extends Constructor>(target: C) => C & {
6
14
  new (...args: any[]): {};
7
- } & T;
15
+ };
16
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { InjectionToken } from "../di/Container";
2
+ import type { ScopeType } from "../di/Container";
3
+ /** Static marker to identify @UseCase classes (for future lint rules) */
4
+ export declare const USE_CASE_MARKER: unique symbol;
5
+ type Constructor = new (...args: any[]) => unknown;
6
+ /**
7
+ * Marks a class as a use case (business scenario / interactor).
8
+ * Same DI mechanics as @Injectable / @Service.
9
+ * Scope: 'singleton' | 'transient' | 'scoped'.
10
+ *
11
+ * @example
12
+ * @UseCase<ICreateTodoUseCase>()
13
+ * export class CreateTodoUseCase implements ICreateTodoUseCase {
14
+ * constructor(private store: TodoStore, private repo: TodoRepository) {}
15
+ * async execute(dto: CreateTodoDto) { ... }
16
+ * }
17
+ */
18
+ export declare function UseCase<T = void>(): <C extends Constructor>(target: C) => C;
19
+ export declare function UseCase(token: InjectionToken): <C extends Constructor>(target: C) => C;
20
+ export declare function UseCase(token: InjectionToken, scope: ScopeType): <C extends Constructor>(target: C) => C;
21
+ export {};
@@ -6,14 +6,3 @@ export declare const INJECT_PARAM_TOKENS: unique symbol;
6
6
  * @internal
7
7
  */
8
8
  export declare function diParams(tokens: Record<number, InjectionToken>): <T extends new (...args: any[]) => any>(ctor: T) => T;
9
- /**
10
- * Specifies the injection token for a constructor parameter.
11
- * Use when the token differs from the parameter type (e.g. interfaces, abstract classes).
12
- *
13
- * @example
14
- * constructor(
15
- * @inject('IAuthService') private auth: IAuthService,
16
- * @inject(LoggerToken) private logger: ILogger,
17
- * )
18
- */
19
- export declare function inject(token: InjectionToken): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
@@ -25,4 +25,6 @@ export declare function Injectable(token: InjectionToken, scope: ScopeType): <C
25
25
  export declare function getScopeMetadata(ctor: new (...args: any[]) => any): ScopeType | undefined;
26
26
  export declare function isInjectable(ctor: unknown): ctor is new (...args: any[]) => any;
27
27
  export declare function getInjectableToken(ctor: new (...args: any[]) => any): InjectionToken | undefined;
28
+ /** Alias for @Injectable. Prefer @Service for infrastructure services. */
29
+ export declare const Service: typeof Injectable;
28
30
  export {};
@@ -1,7 +1,6 @@
1
- import "reflect-metadata";
2
- import { Container } from "./Container";
1
+ import type { Container } from "./Container";
3
2
  /**
4
- * Creates a View component instance with constructor injection.
5
- * Resolves DI params from container and @Context tree; last param receives viewProps.
3
+ * Creates a View/Context instance. Constructor receives only viewProps (from JSX).
4
+ * DI for View/Context is via @inject (container) and @useCtx (context tree) field decorators.
6
5
  */
7
- export declare function createViewInstance<T>(container: Container | null, ViewCtor: new (...args: any[]) => T, viewProps: Record<string, unknown>, contextHost: object | null): T;
6
+ export declare function createViewInstance<T>(_container: Container | null, ViewCtor: new (...args: any[]) => T, viewProps: Record<string, unknown>, _contextHost: object | null): T;
@@ -1,6 +1,7 @@
1
1
  export { Container } from "./Container";
2
2
  export type { InjectionToken, ProviderOptions, ScopeType, UseClassProvider, UseValueProvider, UseFactoryProvider, } from "./Container";
3
- export { Injectable, isInjectable, getScopeMetadata } from "./Injectable.decorator";
4
- export { inject, diParams } from "./InjectParam.decorator";
3
+ export { Injectable, Service, isInjectable, getScopeMetadata } from "./Injectable.decorator";
4
+ export { UseCase } from "../decorators/UseCase.decorator";
5
+ export { diParams } from "./InjectParam.decorator";
5
6
  export { createViewInstance } from "./createViewInstance";
6
7
  export { setRootContainer, getRootContainer } from "./rootContainer";
@@ -0,0 +1,19 @@
1
+ import type { InjectionToken } from "../di/Container";
2
+ import type { ScopeType } from "../di/Container";
3
+ type Constructor = new (...args: any[]) => unknown;
4
+ /**
5
+ * Marks a class as API client implementing interface T.
6
+ * Registers in DI by interface (like @Service).
7
+ * ApiClient classes receive HttpClient via constructor injection.
8
+ *
9
+ * @example
10
+ * @ApiClient<TodoApi>()
11
+ * export class TodoApiImpl implements TodoApi {
12
+ * constructor(private readonly http: HttpClient) {}
13
+ * // ...
14
+ * }
15
+ */
16
+ export declare function ApiClient<T = void>(): <C extends Constructor>(target: C) => C;
17
+ export declare function ApiClient(token: InjectionToken): <C extends Constructor>(target: C) => C;
18
+ export declare function ApiClient(token: InjectionToken, scope: ScopeType): <C extends Constructor>(target: C) => C;
19
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { HttpClient, HttpRequestConfig } from "./HttpClient.types";
2
+ export interface FetchHttpClientConfig {
3
+ baseUrl?: string;
4
+ headers?: Record<string, string>;
5
+ timeout?: number;
6
+ }
7
+ /** Default HttpClient implementation using native fetch */
8
+ export declare class FetchHttpClient implements HttpClient {
9
+ private readonly config;
10
+ constructor(config?: FetchHttpClientConfig);
11
+ private request;
12
+ get<T>(url: string, config?: HttpRequestConfig): Promise<T>;
13
+ post<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
14
+ put<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
15
+ patch<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
16
+ delete<T>(url: string, config?: HttpRequestConfig): Promise<T>;
17
+ }
@@ -0,0 +1,19 @@
1
+ /** Request config (overrides for a single request) */
2
+ export interface HttpRequestConfig {
3
+ /** Base URL (prepended to relative paths) */
4
+ baseUrl?: string;
5
+ /** Request headers */
6
+ headers?: Record<string, string>;
7
+ /** Timeout in ms */
8
+ timeout?: number;
9
+ }
10
+ /** HTTP client interface */
11
+ export interface HttpClient {
12
+ get<T>(url: string, config?: HttpRequestConfig): Promise<T>;
13
+ post<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
14
+ put<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
15
+ patch<T, B = unknown>(url: string, body: B, config?: HttpRequestConfig): Promise<T>;
16
+ delete<T>(url: string, config?: HttpRequestConfig): Promise<T>;
17
+ }
18
+ /** DI token for HttpClient */
19
+ export declare const HttpClientToken: unique symbol;
@@ -0,0 +1,22 @@
1
+ export interface MutationOptions<TData, TVariables> {
2
+ mutationFn: (variables: TVariables) => Promise<TData>;
3
+ onSuccess?: (data: TData, variables: TVariables) => void;
4
+ onError?: (error: unknown, variables: TVariables) => void;
5
+ /** Invalidate these queryKeys after success */
6
+ invalidateQueries?: readonly unknown[][];
7
+ optimisticFn?: (variables: TVariables) => {
8
+ updates: Array<{
9
+ queryKey: readonly unknown[];
10
+ data?: unknown;
11
+ updater?: (prev: unknown) => unknown;
12
+ }>;
13
+ rollback?: () => void;
14
+ };
15
+ }
16
+ export interface Mutation<TData, TVariables> {
17
+ mutate: (variables: TVariables) => Promise<TData>;
18
+ mutateAsync: (variables: TVariables) => Promise<TData>;
19
+ isPending: boolean;
20
+ isError: boolean;
21
+ error: unknown;
22
+ }
@@ -0,0 +1,17 @@
1
+ import type { Mutation, MutationOptions } from "./Mutation.types";
2
+ export declare class MutationBuilder<TData, TVariables> {
3
+ private mutationFn;
4
+ private _invalidateQueries;
5
+ private _optimisticFn?;
6
+ fn(fn: (variables: TVariables) => Promise<TData>): this;
7
+ invalidateQueries(keys: readonly unknown[][]): this;
8
+ optimisticFn(fn: (variables: TVariables) => {
9
+ updates: Array<{
10
+ queryKey: readonly unknown[];
11
+ data?: unknown;
12
+ updater?: (prev: unknown) => unknown;
13
+ }>;
14
+ rollback?: () => void;
15
+ }): this;
16
+ build(decoratorOptions?: Partial<Pick<MutationOptions<TData, TVariables>, "invalidateQueries" | "optimisticFn">>): Mutation<TData, TVariables>;
17
+ }
@@ -0,0 +1,22 @@
1
+ export interface QueryOptions<T> {
2
+ /** Cache key (array) */
3
+ queryKey: readonly unknown[];
4
+ /** Loader function */
5
+ queryFn: () => Promise<T>;
6
+ /** Data freshness time (ms). Default 0 */
7
+ staleTime?: number;
8
+ /** Cache TTL after unmount (ms). Default 5 * 60 * 1000 */
9
+ gcTime?: number;
10
+ /** Refetch on window focus. Default false */
11
+ refetchOnWindowFocus?: boolean;
12
+ /** Refetch on reconnect. Default true */
13
+ refetchOnReconnect?: boolean;
14
+ }
15
+ export interface Query<T> {
16
+ data: T | undefined;
17
+ isLoading: boolean;
18
+ isFetching: boolean;
19
+ isError: boolean;
20
+ error: unknown;
21
+ refetch: () => Promise<void>;
22
+ }
@@ -0,0 +1,16 @@
1
+ import type { Query } from "./Query.types";
2
+ export declare class QueryBuilder<T> {
3
+ private queryKey;
4
+ private queryFn;
5
+ private _staleTime;
6
+ private _gcTime;
7
+ private _refetchOnWindowFocus;
8
+ private _refetchOnReconnect;
9
+ constructor(queryKey: readonly unknown[]);
10
+ fn(fn: () => Promise<T>): this;
11
+ staleTime(ms: number): this;
12
+ gcTime(ms: number): this;
13
+ refetchOnWindowFocus(enabled?: boolean): this;
14
+ refetchOnReconnect(enabled?: boolean): this;
15
+ build(): Query<T>;
16
+ }
@@ -0,0 +1,13 @@
1
+ import type { Query, QueryOptions } from "./Query.types";
2
+ export declare function setQueryCacheMaxSize(size: number): void;
3
+ declare const QUERY_SUBSCRIBE: unique symbol;
4
+ interface QueryCacheAPI {
5
+ getOrCreate<T>(queryKey: readonly unknown[], options: Omit<QueryOptions<T>, "queryKey">): Query<T>;
6
+ subscribe(key: string): () => void;
7
+ invalidate(queryKey: readonly unknown[]): void;
8
+ set(queryKey: readonly unknown[], data: unknown): void;
9
+ setWithUpdater<T>(queryKey: readonly unknown[], updater: (prev: T | undefined) => T): void;
10
+ }
11
+ export { QUERY_SUBSCRIBE };
12
+ declare function createCache(): QueryCacheAPI;
13
+ export declare function getOrCreateQueryCache(): ReturnType<typeof createCache>;
@@ -0,0 +1,18 @@
1
+ export type { HttpClient, HttpRequestConfig, } from "./HttpClient.types";
2
+ export { HttpClientToken } from "./HttpClient.types";
3
+ export { FetchHttpClient } from "./FetchHttpClient";
4
+ export type { FetchHttpClientConfig } from "./FetchHttpClient";
5
+ export type { Query, QueryOptions } from "./Query.types";
6
+ export type { Mutation, MutationOptions } from "./Mutation.types";
7
+ export { QueryBuilder } from "./QueryBuilder";
8
+ export { MutationBuilder } from "./MutationBuilder";
9
+ export { getOrCreateQueryCache, setQueryCacheMaxSize, QUERY_SUBSCRIBE, } from "./QueryCache";
10
+ export { ApiClient } from "./ApiClient.decorator";
11
+ export { queryConfig, QUERY_CONFIG_KEY } from "./queryConfig.decorator";
12
+ export { mutationConfig } from "./mutationConfig.decorator";
13
+ export { useMutation, resolveUseMutation, USE_MUTATION_FIELDS, } from "./useMutation.decorator";
14
+ export type { UseMutationDescriptor } from "./useMutation.decorator";
15
+ export { useQuery, resolveUseQuery, setupUseQueryRefetchAndSubscribe, USE_QUERY_FIELDS, } from "./useQuery.decorator";
16
+ export type { UseQueryDescriptor, UseQueryKeyOrGetter } from "./useQuery.decorator";
17
+ export { useInfiniteQuery, resolveUseInfiniteQuery, setupUseInfiniteQuery, USE_INFINITE_QUERY_FIELDS, } from "./useInfiniteQuery.decorator";
18
+ export type { UseInfiniteQueryConfig, InfiniteQueryKeyDescriptor, UseInfiniteQueryDescriptor, InfiniteQueryResult, } from "./useInfiniteQuery.decorator";
@@ -0,0 +1,19 @@
1
+ import type { MutationBuilder } from "./MutationBuilder";
2
+ import type { MutationOptions } from "./Mutation.types";
3
+ export interface MutationConfigOptions<TData, TVariables> {
4
+ invalidateQueries?: readonly unknown[][];
5
+ optimisticFn?: MutationOptions<TData, TVariables>["optimisticFn"];
6
+ }
7
+ /**
8
+ * Decorator for ApiClient mutation methods.
9
+ * Merges options (invalidateQueries, optimisticFn) into the Mutation returned by the method.
10
+ *
11
+ * @example
12
+ * @mutationConfig({ invalidateQueries: [['todo']], optimisticFn: (dto) => ({ ... }) })
13
+ * create(dto: AddTodoDto) {
14
+ * return new MutationBuilder<TodoItem, AddTodoDto>()
15
+ * .fn((d) => this.http.post<TodoItem>('/todos', d))
16
+ * .build();
17
+ * }
18
+ */
19
+ export declare function mutationConfig<TData = unknown, TVariables = unknown>(options?: MutationConfigOptions<TData, TVariables>): <T extends (...args: any[]) => MutationBuilder<TData, TVariables>>(_target: object, _propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
@@ -0,0 +1,9 @@
1
+ declare const QUERY_CONFIG_KEY: unique symbol;
2
+ /**
3
+ * Decorator for ApiClient methods that return QueryBuilder or Query.
4
+ * If QueryBuilder, calls .build() and returns Query<T>.
5
+ *
6
+ * @param keyTemplate - Template for cache key (e.g. 'todos' or 'todo/:id'). Used for @useQuery resolution.
7
+ */
8
+ export declare function queryConfig(keyTemplate: string): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
9
+ export { QUERY_CONFIG_KEY };