@lunora/angular 1.0.0-alpha.85 → 1.0.0-alpha.87

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/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
2
2
  import { FunctionReference, LunoraClient, SubscriptionErrorCallback, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle, ActionCallOptions } from '@lunora/client';
3
3
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
4
+ import { AuthStatus } from '@lunora/client/auth';
4
5
  import { PaginationStatus } from '@lunora/client/pagination';
5
6
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
7
  export { SKIP } from '@lunora/client/query';
@@ -518,6 +519,12 @@ interface AuthOptions {
518
519
  interface AuthResult {
519
520
  /** Set the auth token (sign-in / sign-out). */
520
521
  setToken: (token: string | null) => void;
522
+ /**
523
+ * The resolved auth state. Branch on this, not on `user() === null` — see the
524
+ * contract in `@lunora/client/auth`; `user` is `null` both when signed out
525
+ * and when a held credential's identity could not be resolved.
526
+ */
527
+ status: Signal<AuthStatus>;
521
528
  /** The current auth token, or `null`. */
522
529
  token: Signal<string | null>;
523
530
  /** The resolved user from `store.getUser()`, or `null`. */
@@ -545,18 +552,20 @@ declare const auth: (options?: AuthOptions) => AuthResult;
545
552
  * @experimental
546
553
  */
547
554
  interface AuthGateResult {
548
- /** `true` once a token is set and the user has resolved. */
555
+ /** `true` once a credential is held and nothing has contradicted it. */
549
556
  isAuthenticated: Signal<boolean>;
550
- /** `true` while a token is set but the user hasn't resolved yet. */
557
+ /** `true` while a credential's first identity resolve is in flight. */
551
558
  isLoading: Signal<boolean>;
552
559
  }
553
560
  /**
554
561
  * Derived auth-gate signals for template gating (Angular's `\@if` control
555
562
  * flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
556
563
  * component the way React/Vue/Solid do, so this exposes the same three-state
557
- * logic as two booleans instead: a token with no resolved user yet is
558
- * `isLoading`; a token with a resolved user is `isAuthenticated`; no token is
559
- * neither (the signed-out state a template checks for with a plain `\@else`).
564
+ * logic as two booleans instead, mapped from the shared `AuthStatus` contract in
565
+ * `@lunora/client/auth`: a credential whose first identity resolve is in flight
566
+ * is `isLoading`; a credential nothing has contradicted — including one whose
567
+ * identity endpoint is unreachable — is `isAuthenticated`; no session is neither
568
+ * (the signed-out state a template checks for with a plain `\@else`).
560
569
  *
561
570
  * Call from an injection context (component/service field or constructor):
562
571
  * ```ts
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
2
2
  import { FunctionReference, LunoraClient, SubscriptionErrorCallback, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle, ActionCallOptions } from '@lunora/client';
3
3
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, LunoraClientOptions, MutationCallOptions, Preloaded, ReturnOf, SubscriptionError, Unsubscribe } from '@lunora/client';
4
+ import { AuthStatus } from '@lunora/client/auth';
4
5
  import { PaginationStatus } from '@lunora/client/pagination';
5
6
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
7
  export { SKIP } from '@lunora/client/query';
@@ -518,6 +519,12 @@ interface AuthOptions {
518
519
  interface AuthResult {
519
520
  /** Set the auth token (sign-in / sign-out). */
520
521
  setToken: (token: string | null) => void;
522
+ /**
523
+ * The resolved auth state. Branch on this, not on `user() === null` — see the
524
+ * contract in `@lunora/client/auth`; `user` is `null` both when signed out
525
+ * and when a held credential's identity could not be resolved.
526
+ */
527
+ status: Signal<AuthStatus>;
521
528
  /** The current auth token, or `null`. */
522
529
  token: Signal<string | null>;
523
530
  /** The resolved user from `store.getUser()`, or `null`. */
@@ -545,18 +552,20 @@ declare const auth: (options?: AuthOptions) => AuthResult;
545
552
  * @experimental
546
553
  */
547
554
  interface AuthGateResult {
548
- /** `true` once a token is set and the user has resolved. */
555
+ /** `true` once a credential is held and nothing has contradicted it. */
549
556
  isAuthenticated: Signal<boolean>;
550
- /** `true` while a token is set but the user hasn't resolved yet. */
557
+ /** `true` while a credential's first identity resolve is in flight. */
551
558
  isLoading: Signal<boolean>;
552
559
  }
553
560
  /**
554
561
  * Derived auth-gate signals for template gating (Angular's `\@if` control
555
562
  * flow), built on {@link auth}. Angular has no JSX-style `Authenticated` slot
556
563
  * component the way React/Vue/Solid do, so this exposes the same three-state
557
- * logic as two booleans instead: a token with no resolved user yet is
558
- * `isLoading`; a token with a resolved user is `isAuthenticated`; no token is
559
- * neither (the signed-out state a template checks for with a plain `\@else`).
564
+ * logic as two booleans instead, mapped from the shared `AuthStatus` contract in
565
+ * `@lunora/client/auth`: a credential whose first identity resolve is in flight
566
+ * is `isLoading`; a credential nothing has contradicted — including one whose
567
+ * identity endpoint is unreachable — is `isAuthenticated`; no session is neither
568
+ * (the signed-out state a template checks for with a plain `\@else`).
560
569
  *
561
570
  * Call from an injection context (component/service field or constructor):
562
571
  * ```ts
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{agent as t}from"./packem_shared/agent-CRHBczS6.mjs";import{agentChat as m}from"./packem_shared/agentChat-B5YgDVPn.mjs";import{agentState as f}from"./packem_shared/agentState-B4sPm-HF.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-COeASEbE.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-BgwruT_M.mjs";import{LUNORA_CLIENT as c,injectLunoraClient as s,provideLunora as l}from"./packem_shared/LUNORA_CLIENT-B0toApHY.mjs";import{connectionStatus as L}from"./packem_shared/connectionStatus-UhmuwzMa.mjs";import{flag as v,flags as y}from"./packem_shared/flag-CwhMtUIL.mjs";import{hydratePreloaded as C}from"./packem_shared/hydratePreloaded-CduDQN77.mjs";import{liveQuery as S}from"./packem_shared/liveQuery-BTIv0WUM.mjs";import{mutate as I}from"./packem_shared/mutate-BZvLQLyu.mjs";import{mutator as P}from"./packem_shared/mutator-DjG1yGk8.mjs";import{infiniteQuery as b,paginatedQuery as j}from"./packem_shared/infiniteQuery-BDeinyXj.mjs";import{presence as K}from"./packem_shared/presence-QJB5dStR.mjs";import{rateLimit as R}from"./packem_shared/rateLimit-B3h9qzh-.mjs";import{runAction as _}from"./packem_shared/runAction-BfiPq4Xz.mjs";import{stream as q}from"./packem_shared/stream--U4Wx7Wx.mjs";import{subscription as z}from"./packem_shared/subscription-TT5Jlxw0.mjs";import{voiceAgent as D}from"./packem_shared/voiceAgent-BCA6dkvc.mjs";import{SKIP as H}from"@lunora/client/query";export{c as LUNORA_CLIENT,H as SKIP,t as agent,m as agentChat,f as agentState,n as agentToolEvents,i as auth,u as authGate,L as connectionStatus,v as flag,y as flags,C as hydratePreloaded,b as infiniteQuery,s as injectLunoraClient,S as liveQuery,I as mutate,P as mutator,j as paginatedQuery,K as presence,l as provideLunora,R as rateLimit,_ as runAction,q as stream,z as subscription,D as voiceAgent};
1
+ import{agent as t}from"./packem_shared/agent-BCt1D_wQ.mjs";import{agentChat as m}from"./packem_shared/agentChat-DMMjTLnF.mjs";import{agentState as f}from"./packem_shared/agentState-Cdyss0S4.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-BOp6-TK8.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-C3dB8sYS.mjs";import{LUNORA_CLIENT as c,injectLunoraClient as s,provideLunora as l}from"./packem_shared/LUNORA_CLIENT-B0toApHY.mjs";import{connectionStatus as L}from"./packem_shared/connectionStatus-UhmuwzMa.mjs";import{flag as v,flags as y}from"./packem_shared/flag-BJxkgJR2.mjs";import{hydratePreloaded as C}from"./packem_shared/hydratePreloaded-gUUl_6tS.mjs";import{liveQuery as S}from"./packem_shared/liveQuery-ZIgKq4et.mjs";import{mutate as I}from"./packem_shared/mutate-BZvLQLyu.mjs";import{mutator as P}from"./packem_shared/mutator-DjG1yGk8.mjs";import{infiniteQuery as b,paginatedQuery as j}from"./packem_shared/infiniteQuery-yZS4F7PI.mjs";import{presence as K}from"./packem_shared/presence-DUkZtSSL.mjs";import{rateLimit as R}from"./packem_shared/rateLimit-B3h9qzh-.mjs";import{runAction as _}from"./packem_shared/runAction-BfiPq4Xz.mjs";import{stream as q}from"./packem_shared/stream-CVSnLbC2.mjs";import{subscription as z}from"./packem_shared/subscription-B_Xj8Ezd.mjs";import{voiceAgent as D}from"./packem_shared/voiceAgent-CyPFWGUt.mjs";import{SKIP as H}from"@lunora/client/query";export{c as LUNORA_CLIENT,H as SKIP,t as agent,m as agentChat,f as agentState,n as agentToolEvents,i as auth,u as authGate,L as connectionStatus,v as flag,y as flags,C as hydratePreloaded,b as infiniteQuery,s as injectLunoraClient,S as liveQuery,I as mutate,P as mutator,j as paginatedQuery,K as presence,l as provideLunora,R as rateLimit,_ as runAction,q as stream,z as subscription,D as voiceAgent};
@@ -1 +1 @@
1
- import{computed as o,signal as R}from"@angular/core";import{resolveLunoraClient as h}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as v}from"./subscription-TT5Jlxw0.mjs";const x=t=>{const{api:i,cancel:c,onError:d,run:l,runArgs:u,threadKey:n}=t,a=h(t.client),{data:f,error:m}=v(i.agents.agentThread,{key:n},{client:a,destroyRef:t.destroyRef,onError:d}),r=o(()=>f()),y=o(()=>r()?.status),s=R(!1),g=async(e,p)=>{s.set(!0);try{await a.mutation(l,{input:e,threadKey:n,...u,...p})}finally{s.set(!1)}};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await a.mutation(c,{instanceId:e,threadKey:n})},error:m,pending:s.asReadonly(),run:g,status:y,thread:r}};export{x as agent};
1
+ import{computed as o,signal as R}from"@angular/core";import{resolveLunoraClient as h}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as v}from"./subscription-B_Xj8Ezd.mjs";const x=t=>{const{api:i,cancel:c,onError:d,run:l,runArgs:u,threadKey:n}=t,a=h(t.client),{data:f,error:m}=v(i.agents.agentThread,{key:n},{client:a,destroyRef:t.destroyRef,onError:d}),r=o(()=>f()),y=o(()=>r()?.status),s=R(!1),g=async(e,p)=>{s.set(!0);try{await a.mutation(l,{input:e,threadKey:n,...u,...p})}finally{s.set(!1)}};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await a.mutation(c,{instanceId:e,threadKey:n})},error:m,pending:s.asReadonly(),run:g,status:y,thread:r}};export{x as agent};
@@ -1 +1 @@
1
- import{computed as a,signal as L}from"@angular/core";import{reconcileOptimistic as k,maxSeq as w}from"@lunora/client";import{resolveLunoraClient as N}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as $}from"./stream--U4Wx7Wx.mjs";import{subscription as x}from"./subscription-TT5Jlxw0.mjs";const z={__lunoraRef:""},W=m=>{const{api:d,cancel:g,limit:h,onError:f,send:A,sendArgs:E,stream:y,threadKey:r}=m,s=N(m.client),{destroyRef:l}=m,b=h===void 0?{key:r}:{key:r,limit:h},{data:I,error:S}=x(d.agents.agentMessages,b,{client:s,destroyRef:l,onError:f}),{data:j,error:q}=x(d.agents.agentThread,{key:r},{client:s,destroyRef:l,onError:f}),C=a(()=>S()??q()),_=y===void 0?"skip":{key:r},{chunks:D}=$(y??z,_,{client:s,destroyRef:l}),c=L([]);let v=0;const u=a(()=>j()),T=a(()=>u()?.status),i=a(()=>I()??[]),K=a(()=>{const t=i(),e=k(c(),t);if(e.length===0)return t;const n=w(t);return[...t,...e.map((o,p)=>({content:o.content,optimistic:!0,role:"user",seq:n+1+p}))]}),M=a(()=>{const t=i().filter(e=>e.role==="assistant").length;return D().filter(e=>e.kind!=="progress"&&e.threadKey===r&&e.turn>=t).map(e=>e.text).join("")}),O=async(t,e)=>{const n=v;v+=1;const o=w(i());c.set([...k(c(),i()),{content:t,id:n,maxDurableSeqAtSend:o}]);try{await s.mutation(A,{input:t,threadKey:r,...E,...e})}catch(p){throw c.set(c().filter(F=>F.id!==n)),p}},R=async(t,e,n)=>{const o=u()?.instanceId;if(o===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await s.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:o,threadKey:r,toolCallId:e,...n===void 0?{}:{note:n}})};return{approve:async(t,e)=>R("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await s.mutation(g,{instanceId:t,threadKey:r})},error:C,messages:K,reject:async(t,e)=>R("reject",t,e),send:O,status:T,streamingText:M}};export{W as agentChat};
1
+ import{computed as a,signal as L}from"@angular/core";import{reconcileOptimistic as k,maxSeq as w}from"@lunora/client";import{resolveLunoraClient as N}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as $}from"./stream-CVSnLbC2.mjs";import{subscription as x}from"./subscription-B_Xj8Ezd.mjs";const z={__lunoraRef:""},W=m=>{const{api:d,cancel:g,limit:h,onError:f,send:A,sendArgs:E,stream:y,threadKey:r}=m,s=N(m.client),{destroyRef:l}=m,b=h===void 0?{key:r}:{key:r,limit:h},{data:I,error:S}=x(d.agents.agentMessages,b,{client:s,destroyRef:l,onError:f}),{data:j,error:q}=x(d.agents.agentThread,{key:r},{client:s,destroyRef:l,onError:f}),C=a(()=>S()??q()),_=y===void 0?"skip":{key:r},{chunks:D}=$(y??z,_,{client:s,destroyRef:l}),c=L([]);let v=0;const u=a(()=>j()),T=a(()=>u()?.status),i=a(()=>I()??[]),K=a(()=>{const t=i(),e=k(c(),t);if(e.length===0)return t;const n=w(t);return[...t,...e.map((o,p)=>({content:o.content,optimistic:!0,role:"user",seq:n+1+p}))]}),M=a(()=>{const t=i().filter(e=>e.role==="assistant").length;return D().filter(e=>e.kind!=="progress"&&e.threadKey===r&&e.turn>=t).map(e=>e.text).join("")}),O=async(t,e)=>{const n=v;v+=1;const o=w(i());c.set([...k(c(),i()),{content:t,id:n,maxDurableSeqAtSend:o}]);try{await s.mutation(A,{input:t,threadKey:r,...E,...e})}catch(p){throw c.set(c().filter(F=>F.id!==n)),p}},R=async(t,e,n)=>{const o=u()?.instanceId;if(o===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await s.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:o,threadKey:r,toolCallId:e,...n===void 0?{}:{note:n}})};return{approve:async(t,e)=>R("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await s.mutation(g,{instanceId:t,threadKey:r})},error:C,messages:K,reject:async(t,e)=>R("reject",t,e),send:O,status:T,streamingText:M}};export{W as agentChat};
@@ -1 +1 @@
1
- import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-TT5Jlxw0.mjs";const d=t=>{const{data:e,error:r}=n(t.api.agents.agentState,{key:t.threadKey},{client:t.client,destroyRef:t.destroyRef}),a=c(()=>e());return{error:r,state:a}};export{d as agentState};
1
+ import{computed as c}from"@angular/core";import{subscription as n}from"./subscription-B_Xj8Ezd.mjs";const d=t=>{const{data:e,error:r}=n(t.api.agents.agentState,{key:t.threadKey},{client:t.client,destroyRef:t.destroyRef}),a=c(()=>e());return{error:r,state:a}};export{d as agentState};
@@ -1 +1 @@
1
- import{computed as v}from"@angular/core";import{resolveLunoraClient as f}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as C}from"./stream--U4Wx7Wx.mjs";import{subscription as y}from"./subscription-TT5Jlxw0.mjs";const I={__lunoraRef:""},N=[],m=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},R=t=>{const{api:l,limit:n,stream:e,threadKey:r}=t,a=f(t.client),{destroyRef:i}=t,u=n===void 0?{key:r}:{key:r,limit:n},{data:p}=y(l.agents.agentMessages,u,{client:a,destroyRef:i}),s=e===void 0?"skip":{key:r},{chunks:c}=C(e??I,s,{client:a,destroyRef:i});return{events:v(()=>{const d=(p()??N).flatMap(o=>m(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{R as agentToolEvents};
1
+ import{computed as v}from"@angular/core";import{resolveLunoraClient as f}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as C}from"./stream-CVSnLbC2.mjs";import{subscription as y}from"./subscription-B_Xj8Ezd.mjs";const I={__lunoraRef:""},N=[],m=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},R=t=>{const{api:l,limit:n,stream:e,threadKey:r}=t,a=f(t.client),{destroyRef:i}=t,u=n===void 0?{key:r}:{key:r,limit:n},{data:p}=y(l.agents.agentMessages,u,{client:a,destroyRef:i}),s=e===void 0?"skip":{key:r},{chunks:c}=C(e??I,s,{client:a,destroyRef:i});return{events:v(()=>{const d=(p()??N).flatMap(o=>m(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{R as agentToolEvents};
@@ -0,0 +1 @@
1
+ import{inject as h,DestroyRef as k,signal as o,computed as c}from"@angular/core";import{getIdentityStore as l,isLoadingStatus as y,isAuthenticatedStatus as m}from"@lunora/client/auth";import{resolveLunoraClient as A}from"./LUNORA_CLIENT-B0toApHY.mjs";const T=(s={})=>{const t=A(s.client),n=s.destroyRef??h(k),e=l(t),u=o(t.getAuthToken()),r=o(e.getUser()),a=o(e.getStatus()),i=t.onAuthTokenChange(()=>{u.set(t.getAuthToken())}),d=e.subscribe(()=>{r.set(e.getUser()),a.set(e.getStatus())});return n.onDestroy(()=>{i(),d()}),{setToken:g=>{t.setAuthToken(g)},status:a.asReadonly(),token:u.asReadonly(),user:r.asReadonly()}},p=(s={})=>{const{status:t}=T(s),n=c(()=>y(t()));return{isAuthenticated:c(()=>m(t())),isLoading:n}};export{T as auth,p as authGate};
@@ -1 +1 @@
1
- import{inject as l,DestroyRef as u,signal as a}from"@angular/core";import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as d}from"./platform-R29Vk-0v.mjs";const m="__lunora_flags__:eval",_=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:m},y=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:_(e.default)},c=>{n(c)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},k=(t,e,n={})=>{const c=i(n.client),f=n.destroyRef===void 0,o=n.destroyRef??l(u),r=a(e);return d(f)&&o.onDestroy(y(c,{default:e,key:t},s=>{r.set(s)})),r.asReadonly()},h=(t,e={})=>{const n=i(e.client),c=e.destroyRef===void 0,f=e.destroyRef??l(u),o=a({...t});if(!d(c))return o.asReadonly();const r=[];for(const[s,b]of Object.entries(t))r.push(y(n,{default:b,key:s},R=>{o.set({...o(),[s]:R})}));return f.onDestroy(()=>{for(const s of r)s()}),o.asReadonly()};export{k as flag,h as flags};
1
+ import{inject as l,DestroyRef as u,signal as a}from"@angular/core";import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as d}from"./platform-DNlq-CRU.mjs";const m="__lunora_flags__:eval",_=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:m},y=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:_(e.default)},c=>{n(c)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},k=(t,e,n={})=>{const c=i(n.client),f=n.destroyRef===void 0,o=n.destroyRef??l(u),r=a(e);return d(f)&&o.onDestroy(y(c,{default:e,key:t},s=>{r.set(s)})),r.asReadonly()},h=(t,e={})=>{const n=i(e.client),c=e.destroyRef===void 0,f=e.destroyRef??l(u),o=a({...t});if(!d(c))return o.asReadonly();const r=[];for(const[s,b]of Object.entries(t))r.push(y(n,{default:b,key:s},R=>{o.set({...o(),[s]:R})}));return f.onDestroy(()=>{for(const s of r)s()}),o.asReadonly()};export{k as flag,h as flags};
@@ -1 +1 @@
1
- import{inject as m,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h}from"./platform-R29Vk-0v.mjs";const x=(s,e={})=>{const c=v(e.client),a=e.destroyRef===void 0,i=e.destroyRef??m(b),{args:d,functionPath:f,shardKey:l,value:u}=s,t=n(u),o=n(void 0),y={__lunoraRef:f};if(h(a)){const R=c.subscribe(y,d,r=>{t.set(r),o.set(void 0)},{onError:r=>{o.set(r)},shardKey:l});i.onDestroy(R)}return{data:t.asReadonly(),error:o.asReadonly()}};export{x as hydratePreloaded};
1
+ import{inject as m,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h}from"./platform-DNlq-CRU.mjs";const x=(s,e={})=>{const c=v(e.client),a=e.destroyRef===void 0,i=e.destroyRef??m(b),{args:d,functionPath:f,shardKey:l,value:u}=s,t=n(u),o=n(void 0),y={__lunoraRef:f};if(h(a)){const R=c.subscribe(y,d,r=>{t.set(r),o.set(void 0)},{onError:r=>{o.set(r)},shardKey:l});i.onDestroy(R)}return{data:t.asReadonly(),error:o.asReadonly()}};export{x as hydratePreloaded};
@@ -0,0 +1 @@
1
+ import{computed as m,inject as q,DestroyRef as z,signal as b}from"@angular/core";import{initialPages as H,derivePaginationStatus as _,applyLoadMore as J,rebalance as T}from"@lunora/client/pagination";import{s as B,a as U,b as X}from"./platform-DNlq-CRU.mjs";import{resolveLunoraClient as E}from"./LUNORA_CLIENT-B0toApHY.mjs";const h=(o,t)=>`${o}::${X(t)}`,L=(o,t)=>({...t,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}}),$=(o,t,n,i)=>{const r=E(n.client),K=n.destroyRef===void 0&&i===void 0,{initialNumItems:a,shardKey:w}=n,g=o.__lunoraRef,l=t==="skip"?{}:t,e=b(H(a)),x=b([]),D=b("LoadingFirstPage"),C=b(void 0),R=new Map,y=new Map,F=new Set,S=()=>{const f=e().map(s=>{const u=h(g,L(s,l));return y.get(u)});x.set(f);const{status:P}=_(t==="skip",f);D.set(P)},W=(p,f)=>{const P=s=>h(g,L(s,l));for(const s of f){const u=P(s);if(y.has(u))continue;const d=p.find(c=>c.lower===s.lower);if(d){const c=y.get(P(d));c&&y.set(u,c)}}},G=p=>{const f=new Set;for(const s of p)f.add(h(g,L(s,l)));for(const[s,u]of R)f.has(u.currentKey)||(u.unsub(),R.delete(s),y.delete(u.currentKey));const P=new Set([...R.values()].map(s=>s.currentKey));for(const s of p){const u=L(s,l),d=h(g,u);if(P.has(d))continue;const c={currentKey:d,unsub:void 0};F.add(d);const j=r.subscribe(o,u,M=>{if(y.set(c.currentKey,M),F.delete(c.currentKey),C.set(void 0),S(),F.size===0){const v=e(),k=T(v,x());k&&(W(v,k),e.set(k),I(k),S())}},{onError:M=>{F.delete(d),C.set(M);const v=e(),k=v.at(-1);v.length>1&&k&&!y.has(d)&&h(g,L(k,l))===d&&(e.set(v.slice(0,-1)),I(e())),S(),n.onError?.(M)},shardKey:w});c.unsub=j,R.set(d,c),P.add(d)}};let N=!1,O=!1;const I=p=>{if(N){O=!0;return}N=!0;try{let f=p;do O=!1,G(f),f=e();while(O)}finally{N=!1}};t!=="skip"&&B(K)&&I(e()),S();const Q=()=>{for(const p of R.values())p.unsub();R.clear(),y.clear()};return i===void 0?(n.destroyRef??q(z)).onDestroy(Q):i(Q),{error:C,loadMore:p=>{if(t==="skip")return;const{nextCursor:f,status:P}=_(!1,x());if(P!=="CanLoadMore")return;const s=J(e(),f,p);if(!s)return;const u=e().at(-1),d=s.at(-2);if(u&&d){const c=h(g,L(u,l)),j=h(g,L(d,l)),M=R.get(c);if(M&&c!==j){const v=y.get(c);v&&y.set(j,v),M.unsub(),R.delete(c),y.delete(c)}}C.set(void 0),e.set(s),I(e()),S()},pageResults:x,skipped:m(()=>t==="skip"),status:D}},V=(o,t,n)=>{if(typeof t!="function")return $(o,t,n);const i=E(n.client),r=n.destroyRef===void 0,K=n.destroyRef??q(z),a=b(void 0);return B(r)&&U(t,{destroyRef:K,injector:n.injector},(w,g)=>{const l=[];a.set($(o,w,{...n,client:i},e=>l.push(e))),g(()=>{for(const e of l)e()})}),{error:m(()=>a()?.error()),loadMore:w=>{a()?.loadMore(w)},pageResults:m(()=>a()?.pageResults()??[]),skipped:m(()=>a()?.skipped()??t()==="skip"),status:m(()=>a()?.status()??"LoadingFirstPage")}},se=(o,t,n)=>{const i=V(o,t,n),r=m(()=>i.pageResults().flatMap(a=>a?.page??[])),K=m(()=>{const a=i.status();return!i.skipped()&&(a==="LoadingFirstPage"||a==="LoadingMore")});return{error:i.error,isLoading:K,loadMore:i.loadMore,results:r,status:i.status}},ne=(o,t,n)=>{const{initialNumItems:i}=n,r=V(o,t,n),K=m(()=>r.pageResults().flatMap(e=>e?[e.page]:[])),a=m(()=>!r.skipped()&&r.status()==="LoadingFirstPage"),w=m(()=>r.status()==="CanLoadMore"),g=m(()=>!r.skipped()&&r.status()==="LoadingMore"),l=e=>{r.loadMore(e??i)};return{error:r.error,fetchNextPage:l,hasNextPage:w,isFetchingNextPage:g,isLoading:a,pages:K,status:r.status}};export{ne as infiniteQuery,se as paginatedQuery};
@@ -1 +1 @@
1
- import{inject as u,DestroyRef as y,signal as v}from"@angular/core";import{createQuerySubscription as m}from"@lunora/client/query";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p,a as b}from"./platform-R29Vk-0v.mjs";const g=(c,t,e={})=>{const i=R(e.client),a=e.destroyRef===void 0,s=e.destroyRef??u(y),o=v(void 0),n=(r,f)=>{o.set(void 0);const l=m(i,c,r,{onData:d=>{o.set(d)},onError:e.onError,onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});f(l)};return p(a)&&(typeof t=="function"?b(t,{destroyRef:s,injector:e.injector},n):n(t,r=>s.onDestroy(r))),o.asReadonly()};export{g as liveQuery};
1
+ import{inject as u,DestroyRef as y,signal as v}from"@angular/core";import{createQuerySubscription as m}from"@lunora/client/query";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p,a as b}from"./platform-DNlq-CRU.mjs";const g=(c,t,e={})=>{const i=R(e.client),a=e.destroyRef===void 0,s=e.destroyRef??u(y),o=v(void 0),n=(r,f)=>{o.set(void 0);const l=m(i,c,r,{onData:d=>{o.set(d)},onError:e.onError,onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});f(l)};return p(a)&&(typeof t=="function"?b(t,{destroyRef:s,injector:e.injector},n):n(t,r=>s.onDestroy(r))),o.asReadonly()};export{g as liveQuery};
@@ -0,0 +1 @@
1
+ import{inject as m,PLATFORM_ID as O,computed as j,effect as w,untracked as A,NgZone as S}from"@angular/core";const h=/["\\\u0000-\u001F\uD800-\uDFFF]/,p=r=>h.test(r)?JSON.stringify(r):`"${r}"`,b=r=>{if(r===void 0)return"null";if(typeof r=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof r=="number"){if(Number.isNaN(r))return"nan";if(r===1/0)return"inf";if(r===-1/0)return"-inf";if(Object.is(r,-0))return"-0"}if(typeof r=="string")return p(r);if(r===null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r)){let n="[";for(let o=0;o<r.length;o++)o>0&&(n+=","),n+=b(r[o]);return n+"]"}const e=Object.getPrototypeOf(r);if(e!==null&&e!==Object.prototype){const n=r.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${n} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=r,c=Object.keys(s).sort();let f="{",t=!0;for(const n of c){const o=s[n];o!==void 0&&(t?t=!1:f+=",",f+=p(n),f+=":",f+=b(o))}return f+"}"},y=r=>{let e="";for(let c=0;c<r.length;c+=32768)e+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(e)},i="$lunora.wire$",g=64,l="__proto__",k=r=>{if(r===null||typeof r!="object")return!1;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype},a=(r,e=0)=>{if(e>g)throw new RangeError(`wire-codec: value nesting exceeds the ${g}-level limit`);if(r===void 0)return[i,"undefined"];if(r===null)return null;const s=typeof r;if(s==="bigint")return[i,"bigint",r.toString()];if(s==="number"){const t=r;return Number.isNaN(t)?[i,"nan"]:t===1/0?[i,"inf"]:t===-1/0?[i,"-inf"]:t}if(s!=="object")return r;if(r instanceof Date)return[i,"date",a(r.getTime(),e+1)];if(r instanceof Error){const t=r,n={};for(const u of Object.keys(t)){if(t[u]===void 0)continue;const d=a(t[u],e+1);u===l?Object.defineProperty(n,u,{configurable:!0,enumerable:!0,value:d,writable:!0}):n[u]=d}const o=[i,"error",String(t.name),String(t.message),n];return t.cause!==void 0&&o.push(a(t.cause,e+1)),o}if(r instanceof URL)return[i,"url",r.href];if(r instanceof Map)return[i,"map",[...r.entries()].map(([t,n])=>[a(t,e+1),a(n,e+1)])];if(r instanceof Set)return[i,"set",[...r].map(t=>a(t,e+1))];if(r instanceof ArrayBuffer)return[i,"bytes",y(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const t=r,n=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return n==="Uint8Array"?[i,"bytes",y(o)]:[i,"bytes",y(o),n]}if(Array.isArray(r)){const t=r.map(n=>a(n,e+1));return t.length>0&&t[0]===i?[i,"arr",t]:t}if(!k(r)){const t=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const c=r,f={};for(const t of Object.keys(c)){const n=c[t];if(n===void 0)continue;const o=a(n,e+1);t===l?Object.defineProperty(f,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):f[t]=o}return f},E=r=>b(a(r)),D=r=>r?m(O,{optional:!0})!=="server":!0,N=r=>{const e=r?m(S,{optional:!0}):void 0;return e?s=>e.runOutsideAngular(s):s=>s()},P=(r,e)=>N(r)(e),_=(r,e,s)=>{let c;const f=j(()=>E(r()));try{c=w(t=>{f(),A(()=>{s(r(),t)})},{injector:e.injector,manualCleanup:!0})}catch(t){throw e.injector!==void 0?t:new Error("reactive `args` need an injection context: call this primitive from a component/service field or constructor, or pass `injector` alongside `destroyRef`.",{cause:t})}e.destroyRef.onDestroy(()=>{c.destroy()})};export{_ as a,E as b,N as o,P as r,D as s};
@@ -1 +1 @@
1
- import{inject as D,DestroyRef as S,signal as m}from"@angular/core";import{resolveLunoraClient as U}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as C,r as E}from"./platform-R29Vk-0v.mjs";const A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const n=crypto.getRandomValues(new Uint8Array(16));return Array.from(n,e=>e.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},w=1e4,M=(n,e)=>{const i=U(e.client),u=e.destroyRef===void 0,v=e.destroyRef??D(S),{heartbeat:p,listPresent:b,shardKey:a}=e,o=e.intervalMs??w,c=e.sessionId??A(),f=m(void 0),d=m(void 0);if(!Number.isFinite(o)||o<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(o)}`);let l=e.data;const r=()=>{const t={roomId:n,sessionId:c};l!==void 0&&(t.data=l),i.mutation(p,t,{shardKey:a}).catch(()=>{})},g=t=>{l=t,r()};if(C(u)){const t=i.acquireConnectionContext({roomId:n,sessionId:c},{shardKey:a});r();const y=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()},R=E(u,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",y),setInterval(r,o))),I={roomId:n},h=i.subscribe(b,I,s=>{f.set(s),d.set(void 0)},{onError:s=>{d.set(s),e.onError?.(s)},shardKey:a});v.onDestroy(()=>{clearInterval(R),typeof document<"u"&&document.removeEventListener("visibilitychange",y),t(),h()})}return{error:d.asReadonly(),present:f.asReadonly(),sessionId:c,setData:g}};export{M as presence};
1
+ import{inject as D,DestroyRef as S,signal as m}from"@angular/core";import{resolveLunoraClient as U}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as C,r as E}from"./platform-DNlq-CRU.mjs";const A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const n=crypto.getRandomValues(new Uint8Array(16));return Array.from(n,e=>e.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},w=1e4,M=(n,e)=>{const i=U(e.client),u=e.destroyRef===void 0,v=e.destroyRef??D(S),{heartbeat:p,listPresent:b,shardKey:a}=e,o=e.intervalMs??w,c=e.sessionId??A(),f=m(void 0),d=m(void 0);if(!Number.isFinite(o)||o<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(o)}`);let l=e.data;const r=()=>{const t={roomId:n,sessionId:c};l!==void 0&&(t.data=l),i.mutation(p,t,{shardKey:a}).catch(()=>{})},g=t=>{l=t,r()};if(C(u)){const t=i.acquireConnectionContext({roomId:n,sessionId:c},{shardKey:a});r();const y=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()},R=E(u,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",y),setInterval(r,o))),I={roomId:n},h=i.subscribe(b,I,s=>{f.set(s),d.set(void 0)},{onError:s=>{d.set(s),e.onError?.(s)},shardKey:a});v.onDestroy(()=>{clearInterval(R),typeof document<"u"&&document.removeEventListener("visibilitychange",y),t(),h()})}return{error:d.asReadonly(),present:f.asReadonly(),sessionId:c,setData:g}};export{M as presence};
@@ -1 +1 @@
1
- import{inject as R,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as k}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p}from"./platform-R29Vk-0v.mjs";const g=(u,o,e={})=>{const d=k(e.client),m=e.destroyRef??R(b),y=e.destroyRef===void 0,a=n([]),c=n(void 0),t=n("idle");let s=!0,l;const f=()=>{s=!1,l?.()};if(o!=="skip"&&p(y)){t.set("streaming");const i=d.stream(u,o,{durable:e.durable,maxBuffer:e.maxBuffer,shardKey:e.shardKey});l=()=>{i.cancel()},(async()=>{try{for await(const r of i){if(!s)return;a.update(h=>[...h,r])}s&&t.set("complete")}catch(r){if(!s)return;c.set(r instanceof Error?r:new Error(String(r))),t.set("error")}})().catch(()=>{})}return m.onDestroy(f),{cancel:f,chunks:a.asReadonly(),error:c.asReadonly(),status:t.asReadonly()}};export{g as stream};
1
+ import{inject as R,DestroyRef as b,signal as n}from"@angular/core";import{resolveLunoraClient as k}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as p}from"./platform-DNlq-CRU.mjs";const g=(u,o,e={})=>{const d=k(e.client),m=e.destroyRef??R(b),y=e.destroyRef===void 0,a=n([]),c=n(void 0),t=n("idle");let s=!0,l;const f=()=>{s=!1,l?.()};if(o!=="skip"&&p(y)){t.set("streaming");const i=d.stream(u,o,{durable:e.durable,maxBuffer:e.maxBuffer,shardKey:e.shardKey});l=()=>{i.cancel()},(async()=>{try{for await(const r of i){if(!s)return;a.update(h=>[...h,r])}s&&t.set("complete")}catch(r){if(!s)return;c.set(r instanceof Error?r:new Error(String(r))),t.set("error")}})().catch(()=>{})}return m.onDestroy(f),{cancel:f,chunks:a.asReadonly(),error:c.asReadonly(),status:t.asReadonly()}};export{g as stream};
@@ -1 +1 @@
1
- import{inject as m,DestroyRef as R,signal as a}from"@angular/core";import{createQuerySubscription as p}from"@lunora/client/query";import{resolveLunoraClient as b}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h,a as j}from"./platform-R29Vk-0v.mjs";const C=(d,n,e={})=>{const f=b(e.client),v=e.destroyRef===void 0,i=e.destroyRef??m(R),l=e.onError,o=a(void 0),r=a(void 0),c=(t,u)=>{if(o.set(void 0),r.set(void 0),t==="skip")return;const y=p(f,d,t,{onData:s=>{o.set(s),r.set(void 0)},onError:s=>{r.set(s),o.set(void 0),l?.(s)},onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});u(y)};return h(v)&&(typeof n=="function"?j(n,{destroyRef:i,injector:e.injector},c):c(n,t=>i.onDestroy(t))),{data:o.asReadonly(),error:r.asReadonly()}};export{C as subscription};
1
+ import{inject as m,DestroyRef as R,signal as a}from"@angular/core";import{createQuerySubscription as p}from"@lunora/client/query";import{resolveLunoraClient as b}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as h,a as j}from"./platform-DNlq-CRU.mjs";const C=(d,n,e={})=>{const f=b(e.client),v=e.destroyRef===void 0,i=e.destroyRef??m(R),l=e.onError,o=a(void 0),r=a(void 0),c=(t,u)=>{if(o.set(void 0),r.set(void 0),t==="skip")return;const y=p(f,d,t,{onData:s=>{o.set(s),r.set(void 0)},onError:s=>{r.set(s),o.set(void 0),l?.(s)},onReset:()=>{o.set(void 0)}},{shardKey:e.shardKey});u(y)};return h(v)&&(typeof n=="function"?j(n,{destroyRef:i,injector:e.injector},c):c(n,t=>i.onDestroy(t))),{data:o.asReadonly(),error:r.asReadonly()}};export{C as subscription};
@@ -1 +1 @@
1
- import{inject as B,DestroyRef as K,signal as T}from"@angular/core";import{resolveLunoraClient as V}from"./LUNORA_CLIENT-B0toApHY.mjs";import{o as q}from"./platform-R29Vk-0v.mjs";const D="/_lunora/ws",j="/_lunora/voice/",J=4001,L=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,G=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},X=(e,r)=>{if(r===void 0||r==="")return L(e);if(r.endsWith(D))return r.slice(0,-D.length);try{return new URL(r).origin}catch{return L(e)}},z=e=>{const r=X(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},Q=(e,r)=>{if(r?.code===J)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},Y=(e,r,s)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},Z=16e3,ee=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},te=(e,r)=>{const s=r/Z,i=s>1?Math.floor(e.length/s):e.length,k=new ArrayBuffer(i*2),l=new DataView(k);for(let u=0;u<i;u+=1){const y=e[Math.floor(u*s)]??0,d=Math.max(-1,Math.min(1,y));l.setInt16(u*2,d<0?d*32768:d*32767,!0)}return new Uint8Array(k)},ne=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!s||!i)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const k=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(k),y=l.createScriptProcessor(4096,1,1);let d=!1,m=!1,c=0,g=0;return y.onaudioprocess=p=>{const h=p.inputBuffer.getChannelData(0),a=d?0:ee(h);if(e.onLevel(a),d)return;if(e.onAudio(te(h,l.sampleRate)),e.isTurnActive()){g=a>=e.interruptThreshold?g+1:0,g>=e.interruptChunks&&(g=0,e.onInterrupt());return}g=0;const v=h.length/l.sampleRate*1e3;if(a>=e.silenceThreshold){m=!0,c=0;return}m&&(c+=v,c>=e.silenceDurationMs&&(m=!1,c=0,e.onSilence()))},u.connect(y),y.connect(l.destination),{setMuted:p=>{d=p},stop:()=>{y.disconnect(),u.disconnect();for(const p of k.getTracks())p.stop();l.close()}}},re=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let k=0,l=Promise.resolve(),u=0;const y=async(c,g)=>{if(g!==u)return;let p;try{p=await s.decodeAudioData(c.buffer)}catch{return}if(g!==u)return;const h=s.createBufferSource();h.buffer=p,h.connect(s.destination);const a=Math.max(s.currentTime,k);h.start(a),k=a+p.duration,i.add(h),h.onended=()=>{i.delete(h)}},d=c=>{const g=Uint8Array.from(c),p=u;l=l.then(()=>y(g,p))},m=()=>{u+=1;for(const c of i)try{c.stop()}catch{}i.clear(),k=s.currentTime};return{enqueue:d,interrupt:m,stop:()=>{m(),s.close()}}},F=1,se=.01,oe=1200,ae=.15,ie=3,de=e=>{const{createMicrophone:r=ne,createSpeaker:s=re,createSocket:i,interruptChunks:k=ie,interruptThreshold:l=ae,silenceDurationMs:u=oe,silenceThreshold:y=se,threadKey:d,voice:m}=e,c=V(e.client),g=e.destroyRef===void 0,p=e.destroyRef??B(K),h=q(g),a=T("idle"),v=T(!1),_=T(""),S=T(""),x=T(0),R=T(!1),w=T(void 0);let o,b=!1;const M=t=>{const n=o?.socket;return n?.readyState===F?(n.send(JSON.stringify(t)),!0):!1},E=()=>{const t=o;if(o=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}b=!1,v.set(!1),a.set("idle"),x.set(0)},W=E,N=t=>{const n=o;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),a.set("speaking"),S.update(I=>I+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),S.set(t.text),a.set("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),w.set(new Error(t.message)),a.set("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),a.set("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),v.set(!0),a.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),_.set(t.text),S.set(""),a.set("thinking");break}}},O=t=>{const n=o;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,a.set("speaking"),n.speaker.enqueue(t))},P=async()=>{if(o||b)return;b=!0,w.set(void 0),_.set(""),S.set("");let t;try{const n=z({agent:G(m.__lunoraRef),httpUrl:c.url,threadKey:typeof d=="function"?d():d,wsUrl:c.wsUrl}),I=i??(f=>{const C=c.getWebSocketImpl();if(!C)throw new Error("voiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(f)}),A=h(()=>I(n));A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},o=t,t.unwatchIdentity=Y(c,"voiceAgent",f=>{o===t&&(w.set(f),E())}),A.onmessage=f=>{if(typeof f.data=="string"){try{N(JSON.parse(f.data))}catch{}return}O(new Uint8Array(f.data))},A.onerror=()=>{w.set(new Error("voiceAgent: voice socket error"))},A.onclose=f=>{if(o!==t)return;const C=Q("voiceAgent",f);C&&w.set(C),E()};const U=await h(async()=>r({interruptChunks:k,interruptThreshold:l,isTurnActive:()=>(o?.speaking??!1)||(o?.awaitingTurn??!1),onAudio:f=>{A.readyState===F&&A.send(f)},onInterrupt:()=>{M({type:"interrupt"}),o?.speaker?.interrupt(),o&&(o.awaitingTurn=!1,o.speaking=!1,o.suppressAudio=!0),a.set("listening")},onLevel:f=>{x.set(f)},onSilence:()=>{M({type:"commit"}),o&&(o.awaitingTurn=!0),a.set("thinking")},silenceDurationMs:u,silenceThreshold:y}));o===t?(t.microphone=U,R.set(!1),t.speaking||a.set("listening")):U.stop()}catch(n){o===t&&(w.set(n instanceof Error?n:new Error(String(n))),E())}finally{b=!1}},H=()=>{const t=!R();return o?.microphone?.setMuted(t),R.set(t),t},$=t=>{M({text:t,type:"text"})&&(o&&(o.awaitingTurn=!0),a.set("thinking"))};return p.onDestroy(E),{audioLevel:x.asReadonly(),connected:v.asReadonly(),endCall:W,error:w.asReadonly(),interimTranscript:S.asReadonly(),isMuted:R.asReadonly(),sendText:$,startCall:P,status:a.asReadonly(),toggleMute:H,transcript:_.asReadonly()}};export{de as voiceAgent};
1
+ import{inject as B,DestroyRef as K,signal as T}from"@angular/core";import{resolveLunoraClient as V}from"./LUNORA_CLIENT-B0toApHY.mjs";import{o as q}from"./platform-DNlq-CRU.mjs";const D="/_lunora/ws",j="/_lunora/voice/",J=4001,L=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,G=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},X=(e,r)=>{if(r===void 0||r==="")return L(e);if(r.endsWith(D))return r.slice(0,-D.length);try{return new URL(r).origin}catch{return L(e)}},z=e=>{const r=X(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},Q=(e,r)=>{if(r?.code===J)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},Y=(e,r,s)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},Z=16e3,ee=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},te=(e,r)=>{const s=r/Z,i=s>1?Math.floor(e.length/s):e.length,k=new ArrayBuffer(i*2),l=new DataView(k);for(let u=0;u<i;u+=1){const y=e[Math.floor(u*s)]??0,d=Math.max(-1,Math.min(1,y));l.setInt16(u*2,d<0?d*32768:d*32767,!0)}return new Uint8Array(k)},ne=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!s||!i)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const k=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(k),y=l.createScriptProcessor(4096,1,1);let d=!1,m=!1,c=0,g=0;return y.onaudioprocess=p=>{const h=p.inputBuffer.getChannelData(0),a=d?0:ee(h);if(e.onLevel(a),d)return;if(e.onAudio(te(h,l.sampleRate)),e.isTurnActive()){g=a>=e.interruptThreshold?g+1:0,g>=e.interruptChunks&&(g=0,e.onInterrupt());return}g=0;const v=h.length/l.sampleRate*1e3;if(a>=e.silenceThreshold){m=!0,c=0;return}m&&(c+=v,c>=e.silenceDurationMs&&(m=!1,c=0,e.onSilence()))},u.connect(y),y.connect(l.destination),{setMuted:p=>{d=p},stop:()=>{y.disconnect(),u.disconnect();for(const p of k.getTracks())p.stop();l.close()}}},re=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let k=0,l=Promise.resolve(),u=0;const y=async(c,g)=>{if(g!==u)return;let p;try{p=await s.decodeAudioData(c.buffer)}catch{return}if(g!==u)return;const h=s.createBufferSource();h.buffer=p,h.connect(s.destination);const a=Math.max(s.currentTime,k);h.start(a),k=a+p.duration,i.add(h),h.onended=()=>{i.delete(h)}},d=c=>{const g=Uint8Array.from(c),p=u;l=l.then(()=>y(g,p))},m=()=>{u+=1;for(const c of i)try{c.stop()}catch{}i.clear(),k=s.currentTime};return{enqueue:d,interrupt:m,stop:()=>{m(),s.close()}}},F=1,se=.01,oe=1200,ae=.15,ie=3,de=e=>{const{createMicrophone:r=ne,createSpeaker:s=re,createSocket:i,interruptChunks:k=ie,interruptThreshold:l=ae,silenceDurationMs:u=oe,silenceThreshold:y=se,threadKey:d,voice:m}=e,c=V(e.client),g=e.destroyRef===void 0,p=e.destroyRef??B(K),h=q(g),a=T("idle"),v=T(!1),_=T(""),S=T(""),x=T(0),R=T(!1),w=T(void 0);let o,b=!1;const M=t=>{const n=o?.socket;return n?.readyState===F?(n.send(JSON.stringify(t)),!0):!1},E=()=>{const t=o;if(o=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}b=!1,v.set(!1),a.set("idle"),x.set(0)},W=E,N=t=>{const n=o;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),a.set("speaking"),S.update(I=>I+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),S.set(t.text),a.set("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),w.set(new Error(t.message)),a.set("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),a.set("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),v.set(!0),a.set("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),_.set(t.text),S.set(""),a.set("thinking");break}}},O=t=>{const n=o;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,a.set("speaking"),n.speaker.enqueue(t))},P=async()=>{if(o||b)return;b=!0,w.set(void 0),_.set(""),S.set("");let t;try{const n=z({agent:G(m.__lunoraRef),httpUrl:c.url,threadKey:typeof d=="function"?d():d,wsUrl:c.wsUrl}),I=i??(f=>{const C=c.getWebSocketImpl();if(!C)throw new Error("voiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new C(f)}),A=h(()=>I(n));A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},o=t,t.unwatchIdentity=Y(c,"voiceAgent",f=>{o===t&&(w.set(f),E())}),A.onmessage=f=>{if(typeof f.data=="string"){try{N(JSON.parse(f.data))}catch{}return}O(new Uint8Array(f.data))},A.onerror=()=>{w.set(new Error("voiceAgent: voice socket error"))},A.onclose=f=>{if(o!==t)return;const C=Q("voiceAgent",f);C&&w.set(C),E()};const U=await h(async()=>r({interruptChunks:k,interruptThreshold:l,isTurnActive:()=>(o?.speaking??!1)||(o?.awaitingTurn??!1),onAudio:f=>{A.readyState===F&&A.send(f)},onInterrupt:()=>{M({type:"interrupt"}),o?.speaker?.interrupt(),o&&(o.awaitingTurn=!1,o.speaking=!1,o.suppressAudio=!0),a.set("listening")},onLevel:f=>{x.set(f)},onSilence:()=>{M({type:"commit"}),o&&(o.awaitingTurn=!0),a.set("thinking")},silenceDurationMs:u,silenceThreshold:y}));o===t?(t.microphone=U,R.set(!1),t.speaking||a.set("listening")):U.stop()}catch(n){o===t&&(w.set(n instanceof Error?n:new Error(String(n))),E())}finally{b=!1}},H=()=>{const t=!R();return o?.microphone?.setMuted(t),R.set(t),t},$=t=>{M({text:t,type:"text"})&&(o&&(o.awaitingTurn=!0),a.set("thinking"))};return p.onDestroy(E),{audioLevel:x.asReadonly(),connected:v.asReadonly(),endCall:W,error:w.asReadonly(),interimTranscript:S.asReadonly(),isMuted:R.asReadonly(),sendText:$,startCall:P,status:a.asReadonly(),toggleMute:H,transcript:_.asReadonly()}};export{de as voiceAgent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/angular",
3
- "version": "1.0.0-alpha.85",
3
+ "version": "1.0.0-alpha.87",
4
4
  "description": "Angular reactive adapter for Lunora — signal-based live queries and mutations",
5
5
  "keywords": [
6
6
  "angular",
@@ -53,8 +53,8 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@lunora/client": "1.0.0-alpha.101",
57
- "@lunora/ratelimit": "1.0.0-alpha.57",
56
+ "@lunora/client": "1.0.0-alpha.104",
57
+ "@lunora/ratelimit": "1.0.0-alpha.58",
58
58
  "@visulima/storage-client": "1.0.3"
59
59
  },
60
60
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{inject as k,DestroyRef as d,signal as u,computed as c}from"@angular/core";import{getIdentityStore as h}from"@lunora/client/auth";import{resolveLunoraClient as g}from"./LUNORA_CLIENT-B0toApHY.mjs";const m=(n={})=>{const t=g(n.client),o=n.destroyRef??k(d),e=h(t),s=u(t.getAuthToken()),r=u(e.getUser()),i=t.onAuthTokenChange(()=>{s.set(t.getAuthToken())}),l=e.subscribe(()=>{r.set(e.getUser())});return o.onDestroy(()=>{i(),l()}),{setToken:a=>{t.setAuthToken(a)},token:s.asReadonly(),user:r.asReadonly()}},R=(n={})=>{const{token:t,user:o}=m(n),e=c(()=>t()!==null&&o()===null);return{isAuthenticated:c(()=>t()!==null&&o()!==null),isLoading:e}};export{m as auth,R as authGate};
@@ -1 +0,0 @@
1
- import{computed as k,inject as V,DestroyRef as z,signal as L}from"@angular/core";import{initialPages as v,derivePaginationStatus as U,applyLoadMore as tt,rebalance as et}from"@lunora/client/pagination";import{resolveLunoraClient as G}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as H,a as nt}from"./platform-R29Vk-0v.mjs";const rt=/["\\\u0000-\u001F\uD800-\uDFFF]/,J=t=>rt.test(t)?JSON.stringify(t):`"${t}"`,$=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(typeof t=="string")return J(t);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t)){let r="[";for(let c=0;c<t.length;c++)c>0&&(r+=","),r+=$(t[c]);return r+"]"}const n=Object.getPrototypeOf(t);if(n!==null&&n!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const o=t,i=Object.keys(o).sort();let s="{",e=!0;for(const r of i){const c=o[r];c!==void 0&&(e?e=!1:s+=",",s+=J(r),s+=":",s+=$(c))}return s+"}"},D=t=>{let n="";for(let i=0;i<t.length;i+=32768)n+=String.fromCharCode(...t.subarray(i,i+32768));return btoa(n)},l="$lunora.wire$",W=64,q="__proto__",ot=t=>{if(t===null||typeof t!="object")return!1;const n=Object.getPrototypeOf(t);return n===null||n===Object.prototype},h=(t,n=0)=>{if(n>W)throw new RangeError(`wire-codec: value nesting exceeds the ${W}-level limit`);if(t===void 0)return[l,"undefined"];if(t===null)return null;const o=typeof t;if(o==="bigint")return[l,"bigint",t.toString()];if(o==="number"){const e=t;return Number.isNaN(e)?[l,"nan"]:e===1/0?[l,"inf"]:e===-1/0?[l,"-inf"]:e}if(o!=="object")return t;if(t instanceof Date)return[l,"date",h(t.getTime(),n+1)];if(t instanceof Error){const e=t,r={};for(const u of Object.keys(e)){if(e[u]===void 0)continue;const d=h(e[u],n+1);u===q?Object.defineProperty(r,u,{configurable:!0,enumerable:!0,value:d,writable:!0}):r[u]=d}const c=[l,"error",String(e.name),String(e.message),r];return e.cause!==void 0&&c.push(h(e.cause,n+1)),c}if(t instanceof URL)return[l,"url",t.href];if(t instanceof Map)return[l,"map",[...t.entries()].map(([e,r])=>[h(e,n+1),h(r,n+1)])];if(t instanceof Set)return[l,"set",[...t].map(e=>h(e,n+1))];if(t instanceof ArrayBuffer)return[l,"bytes",D(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){const e=t,r=e.constructor.name,c=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return r==="Uint8Array"?[l,"bytes",D(c)]:[l,"bytes",D(c),r]}if(Array.isArray(t)){const e=t.map(r=>h(r,n+1));return e.length>0&&e[0]===l?[l,"arr",e]:e}if(!ot(t)){const e=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${e} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const i=t,s={};for(const e of Object.keys(i)){const r=i[e];if(r===void 0)continue;const c=h(r,n+1);e===q?Object.defineProperty(s,e,{configurable:!0,enumerable:!0,value:c,writable:!0}):s[e]=c}return s},st=t=>$(h(t)),K=(t,n)=>`${t}::${st(n)}`,M=(t,n)=>({...n,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),Q=(t,n,o,i)=>{const s=G(o.client),e=o.destroyRef===void 0&&i===void 0,{initialNumItems:r,shardKey:c}=o,u=t.__lunoraRef,d=n==="skip"?{}:n,a=L(v(r)),E=L([]),B=L("LoadingFirstPage"),C=L(void 0),O=new Map,m=new Map,A=new Set,N=()=>{const b=a().map(f=>{const p=K(u,M(f,d));return m.get(p)});E.set(b);const{status:P}=U(n==="skip",b);B.set(P)},Y=(w,b)=>{const P=f=>K(u,M(f,d));for(const f of b){const p=P(f);if(m.has(p))continue;const g=w.find(y=>y.lower===f.lower);if(g){const y=m.get(P(g));y&&m.set(p,y)}}},Z=w=>{const b=new Set;for(const f of w)b.add(K(u,M(f,d)));for(const[f,p]of O)b.has(p.currentKey)||(p.unsub(),O.delete(f),m.delete(p.currentKey));const P=new Set([...O.values()].map(f=>f.currentKey));for(const f of w){const p=M(f,d),g=K(u,p);if(P.has(g))continue;const y={currentKey:g,unsub:void 0};A.add(g);const x=s.subscribe(t,p,R=>{if(m.set(y.currentKey,R),A.delete(y.currentKey),C.set(void 0),N(),A.size===0){const S=a(),j=et(S,E());j&&(Y(S,j),a.set(j),F(j),N())}},{onError:R=>{A.delete(g),C.set(R);const S=a(),j=S.at(-1);S.length>1&&j&&!m.has(g)&&K(u,M(j,d))===g&&(a.set(S.slice(0,-1)),F(a())),N(),o.onError?.(R)},shardKey:c});y.unsub=x,O.set(g,y),P.add(g)}};let I=!1,_=!1;const F=w=>{if(I){_=!0;return}I=!0;try{let b=w;do _=!1,Z(b),b=a();while(_)}finally{I=!1}};n!=="skip"&&H(e)&&F(a()),N();const T=()=>{for(const w of O.values())w.unsub();O.clear(),m.clear()};return i===void 0?(o.destroyRef??V(z)).onDestroy(T):i(T),{error:C,loadMore:w=>{if(n==="skip")return;const{nextCursor:b,status:P}=U(!1,E());if(P!=="CanLoadMore")return;const f=tt(a(),b,w);if(!f)return;const p=a().at(-1),g=f.at(-2);if(p&&g){const y=K(u,M(p,d)),x=K(u,M(g,d)),R=O.get(y);if(R&&y!==x){const S=m.get(y);S&&m.set(x,S),R.unsub(),O.delete(y),m.delete(y)}}C.set(void 0),a.set(f),F(a()),N()},pageResults:E,skipped:k(()=>n==="skip"),status:B}},X=(t,n,o)=>{if(typeof n!="function")return Q(t,n,o);const i=G(o.client),s=o.destroyRef===void 0,e=o.destroyRef??V(z),r=L(void 0);return H(s)&&nt(n,{destroyRef:e,injector:o.injector},(c,u)=>{const d=[];r.set(Q(t,c,{...o,client:i},a=>d.push(a))),u(()=>{for(const a of d)a()})}),{error:k(()=>r()?.error()),loadMore:c=>{r()?.loadMore(c)},pageResults:k(()=>r()?.pageResults()??[]),skipped:k(()=>r()?.skipped()??n()==="skip"),status:k(()=>r()?.status()??"LoadingFirstPage")}},dt=(t,n,o)=>{const i=X(t,n,o),s=k(()=>i.pageResults().flatMap(r=>r?.page??[])),e=k(()=>{const r=i.status();return!i.skipped()&&(r==="LoadingFirstPage"||r==="LoadingMore")});return{error:i.error,isLoading:e,loadMore:i.loadMore,results:s,status:i.status}},yt=(t,n,o)=>{const{initialNumItems:i}=o,s=X(t,n,o),e=k(()=>s.pageResults().flatMap(a=>a?[a.page]:[])),r=k(()=>!s.skipped()&&s.status()==="LoadingFirstPage"),c=k(()=>s.status()==="CanLoadMore"),u=k(()=>!s.skipped()&&s.status()==="LoadingMore"),d=a=>{s.loadMore(a??i)};return{error:s.error,fetchNextPage:d,hasNextPage:c,isFetchingNextPage:u,isLoading:r,pages:e,status:s.status}};export{yt as infiniteQuery,dt as paginatedQuery};
@@ -1 +0,0 @@
1
- import{inject as s,PLATFORM_ID as c,effect as a,untracked as u,NgZone as d}from"@angular/core";const p=r=>r?s(c,{optional:!0})!=="server":!0,l=r=>{const e=r?s(d,{optional:!0}):void 0;return e?t=>e.runOutsideAngular(t):t=>t()},v=(r,e)=>l(r)(e),g=(r,e,t)=>{let n;try{n=a(o=>{const i=r();u(()=>{t(i,o)})},{injector:e.injector,manualCleanup:!0})}catch(o){throw e.injector!==void 0?o:new Error("reactive `args` need an injection context: call this primitive from a component/service field or constructor, or pass `injector` alongside `destroyRef`.",{cause:o})}e.destroyRef.onDestroy(()=>{n.destroy()})};export{g as a,l as o,v as r,p as s};