@lunora/angular 1.0.0-alpha.63 → 1.0.0-alpha.64

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,5 +1,5 @@
1
1
  import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
2
- import { FunctionReference, LunoraClient, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, ActionCallOptions } from '@lunora/client';
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
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
@@ -136,6 +136,12 @@ interface AgentOptions {
136
136
  * `inject(DestroyRef)` — the calling component/service.
137
137
  */
138
138
  destroyRef?: DestroyRef;
139
+ /**
140
+ * Called when the live thread subscription reports an error (a session
141
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
142
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
143
+ */
144
+ onError?: SubscriptionErrorCallback;
139
145
  /**
140
146
  * The app mutation that starts (or continues) a run — a thin wrapper over
141
147
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -157,6 +163,8 @@ interface AgentResult {
157
163
  * no-op when no `cancel` mutation was supplied or no run is in flight.
158
164
  */
159
165
  cancel: () => Promise<void>;
166
+ /** The live thread subscription's last error, or `undefined`. */
167
+ error: Signal<SubscriptionError | undefined>;
160
168
  /** `true` while a `run` invocation is in flight. */
161
169
  pending: Signal<boolean>;
162
170
  /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
@@ -246,6 +254,12 @@ interface AgentChatOptions {
246
254
  destroyRef?: DestroyRef;
247
255
  /** History depth forwarded to `agents:agentMessages`. */
248
256
  limit?: number;
257
+ /**
258
+ * Called when the live history or thread subscription reports an error (a
259
+ * session expiry, an RLS denial). Without it — and without reading `error` —
260
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
261
+ */
262
+ onError?: SubscriptionErrorCallback;
249
263
  /**
250
264
  * The app mutation that starts (or continues) a run — a thin wrapper over
251
265
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -275,6 +289,8 @@ interface AgentChatResult {
275
289
  * no-op when no `cancel` mutation was supplied or no run is in flight.
276
290
  */
277
291
  cancel: () => Promise<void>;
292
+ /** The history or thread subscription's last error, or `undefined`. */
293
+ error: Signal<SubscriptionError | undefined>;
278
294
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
279
295
  messages: Signal<ReadonlyArray<AgentChatMessage>>;
280
296
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
@@ -1017,6 +1033,12 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
1017
1033
  intervalMs?: number;
1018
1034
  /** The `api.*` reference for the presence listPresent query. */
1019
1035
  listPresent: L;
1036
+ /**
1037
+ * Called when the `listPresent` subscription reports an error (a session
1038
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
1039
+ * failure is invisible and `present` is cleared until a later frame arrives.
1040
+ */
1041
+ onError?: SubscriptionErrorCallback;
1020
1042
  /**
1021
1043
  * Stable id for this presence row. Defaults to a fresh per-call id.
1022
1044
  * Pass a user/connection id to control deduping across tabs.
@@ -1030,6 +1052,8 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
1030
1052
  * @experimental
1031
1053
  */
1032
1054
  interface PresenceResult<L extends ListPresentReference> {
1055
+ /** The `listPresent` subscription's last error, or `undefined`. */
1056
+ error: Signal<SubscriptionError | undefined>;
1033
1057
  /** The present members for the room. `undefined` until the first push. */
1034
1058
  present: Signal<ReturnOf<L> | undefined>;
1035
1059
  /** This mount's session id (generated when not supplied). */
@@ -1193,8 +1217,8 @@ interface StreamResult<T> {
1193
1217
  * chunk the server pushes — use it for token-by-token deltas and other append-only
1194
1218
  * feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
1195
1219
  * stream (mirrors `subscription`); the stream tears down when the owning
1196
- * `DestroyRef` fires. The Angular counterpart to React's `useStream`, re-expressed
1197
- * with signals.
1220
+ * `DestroyRef` fires. Nothing opens on the Angular server platform (SSR). The
1221
+ * Angular counterpart to React's `useStream`, re-expressed with signals.
1198
1222
  *
1199
1223
  * Call from an injection context (component/service field or constructor):
1200
1224
  * ```ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DestroyRef, Signal, InjectionToken, EnvironmentProviders, Injector } from '@angular/core';
2
- import { FunctionReference, LunoraClient, SubscriptionError, User, LunoraClientOptions, ConnectionStatus, Preloaded, ArgsOf, ReturnOf, MutationCallOptions, MutatorHandle, SubscriptionErrorCallback, ActionCallOptions } from '@lunora/client';
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
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
@@ -136,6 +136,12 @@ interface AgentOptions {
136
136
  * `inject(DestroyRef)` — the calling component/service.
137
137
  */
138
138
  destroyRef?: DestroyRef;
139
+ /**
140
+ * Called when the live thread subscription reports an error (a session
141
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
142
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
143
+ */
144
+ onError?: SubscriptionErrorCallback;
139
145
  /**
140
146
  * The app mutation that starts (or continues) a run — a thin wrapper over
141
147
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -157,6 +163,8 @@ interface AgentResult {
157
163
  * no-op when no `cancel` mutation was supplied or no run is in flight.
158
164
  */
159
165
  cancel: () => Promise<void>;
166
+ /** The live thread subscription's last error, or `undefined`. */
167
+ error: Signal<SubscriptionError | undefined>;
160
168
  /** `true` while a `run` invocation is in flight. */
161
169
  pending: Signal<boolean>;
162
170
  /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
@@ -246,6 +254,12 @@ interface AgentChatOptions {
246
254
  destroyRef?: DestroyRef;
247
255
  /** History depth forwarded to `agents:agentMessages`. */
248
256
  limit?: number;
257
+ /**
258
+ * Called when the live history or thread subscription reports an error (a
259
+ * session expiry, an RLS denial). Without it — and without reading `error` —
260
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
261
+ */
262
+ onError?: SubscriptionErrorCallback;
249
263
  /**
250
264
  * The app mutation that starts (or continues) a run — a thin wrapper over
251
265
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -275,6 +289,8 @@ interface AgentChatResult {
275
289
  * no-op when no `cancel` mutation was supplied or no run is in flight.
276
290
  */
277
291
  cancel: () => Promise<void>;
292
+ /** The history or thread subscription's last error, or `undefined`. */
293
+ error: Signal<SubscriptionError | undefined>;
278
294
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
279
295
  messages: Signal<ReadonlyArray<AgentChatMessage>>;
280
296
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
@@ -1017,6 +1033,12 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
1017
1033
  intervalMs?: number;
1018
1034
  /** The `api.*` reference for the presence listPresent query. */
1019
1035
  listPresent: L;
1036
+ /**
1037
+ * Called when the `listPresent` subscription reports an error (a session
1038
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
1039
+ * failure is invisible and `present` is cleared until a later frame arrives.
1040
+ */
1041
+ onError?: SubscriptionErrorCallback;
1020
1042
  /**
1021
1043
  * Stable id for this presence row. Defaults to a fresh per-call id.
1022
1044
  * Pass a user/connection id to control deduping across tabs.
@@ -1030,6 +1052,8 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
1030
1052
  * @experimental
1031
1053
  */
1032
1054
  interface PresenceResult<L extends ListPresentReference> {
1055
+ /** The `listPresent` subscription's last error, or `undefined`. */
1056
+ error: Signal<SubscriptionError | undefined>;
1033
1057
  /** The present members for the room. `undefined` until the first push. */
1034
1058
  present: Signal<ReturnOf<L> | undefined>;
1035
1059
  /** This mount's session id (generated when not supplied). */
@@ -1193,8 +1217,8 @@ interface StreamResult<T> {
1193
1217
  * chunk the server pushes — use it for token-by-token deltas and other append-only
1194
1218
  * feeds. Pass `"skip"` as `args` to keep the primitive mounted without opening a
1195
1219
  * stream (mirrors `subscription`); the stream tears down when the owning
1196
- * `DestroyRef` fires. The Angular counterpart to React's `useStream`, re-expressed
1197
- * with signals.
1220
+ * `DestroyRef` fires. Nothing opens on the Angular server platform (SSR). The
1221
+ * Angular counterpart to React's `useStream`, re-expressed with signals.
1198
1222
  *
1199
1223
  * Call from an injection context (component/service field or constructor):
1200
1224
  * ```ts
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{agent as t}from"./packem_shared/agent-CsE5xjQK.mjs";import{agentChat as m}from"./packem_shared/agentChat-kyvh-ktM.mjs";import{agentState as f}from"./packem_shared/agentState-B4sPm-HF.mjs";import{agentToolEvents as n}from"./packem_shared/agentToolEvents-CzZN-jQB.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-CWifTPMf.mjs";import{presence as K}from"./packem_shared/presence-DqzvJjBN.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-AffQZjVg.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-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-DRb9pcnA.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};
@@ -0,0 +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};
@@ -0,0 +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};
@@ -0,0 +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};
@@ -0,0 +1 @@
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},S=(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",S(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=S(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",e.name,e.message,r];return e.cause!==void 0&&c.push(S(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])=>[S(e,n+1),S(r,n+1)])];if(t instanceof Set)return[l,"set",[...t].map(e=>S(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=>S(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=S(r,n+1);e===q?Object.defineProperty(s,e,{configurable:!0,enumerable:!0,value:c,writable:!0}):s[e]=c}return s},st=t=>$(S(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 h=a(),j=et(h,E());j&&(Y(h,j),a.set(j),F(j),N())}},{onError:R=>{A.delete(g),C.set(R);const h=a(),j=h.at(-1);h.length>1&&j&&!m.has(g)&&K(u,M(j,d))===g&&(a.set(h.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 h=m.get(y);h&&m.set(x,h),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};
@@ -0,0 +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};
@@ -0,0 +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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/angular",
3
- "version": "1.0.0-alpha.63",
3
+ "version": "1.0.0-alpha.64",
4
4
  "description": "Angular reactive adapter for Lunora — signal-based live queries and mutations",
5
5
  "keywords": [
6
6
  "angular",
@@ -1 +0,0 @@
1
- import{inject as p,DestroyRef as R,computed as o,signal as h}from"@angular/core";import{resolveLunoraClient as v}from"./LUNORA_CLIENT-B0toApHY.mjs";import{subscription as w}from"./subscription-TT5Jlxw0.mjs";const k=e=>{const{api:i,cancel:r,run:d,runArgs:l,threadKey:n}=e,a=v(e.client),u=e.destroyRef??p(R),{data:f}=w(i.agents.agentThread,{key:n},{client:a,destroyRef:u}),s=o(()=>f()),y=o(()=>s()?.status),c=h(!1),m=async(t,g)=>{c.set(!0);try{await a.mutation(d,{input:t,threadKey:n,...l,...g})}finally{c.set(!1)}};return{cancel:async()=>{const t=s()?.instanceId;r===void 0||t===void 0||await a.mutation(r,{instanceId:t,threadKey:n})},pending:c.asReadonly(),run:m,status:y,thread:s}};export{k as agent};
@@ -1 +0,0 @@
1
- import{inject as K,DestroyRef as M,signal as O,computed as c}from"@angular/core";import{reconcileOptimistic as R,maxSeq as k}from"@lunora/client";import{resolveLunoraClient as F}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as L}from"./stream-AffQZjVg.mjs";import{subscription as w}from"./subscription-TT5Jlxw0.mjs";const N={__lunoraRef:""},U=m=>{const{api:d,cancel:g,limit:f,send:x,sendArgs:A,stream:h,threadKey:n}=m,r=F(m.client),l=m.destroyRef??K(M),I=f===void 0?{key:n}:{key:n,limit:f},{data:b}=w(d.agents.agentMessages,I,{client:r,destroyRef:l}),{data:j}=w(d.agents.agentThread,{key:n},{client:r,destroyRef:l}),S=h===void 0?"skip":{key:n},{chunks:q}=L(h??N,S,{client:r,destroyRef:l}),o=O([]);let y=0;const u=c(()=>j()),C=c(()=>u()?.status),i=c(()=>b()??[]),D=c(()=>{const t=i(),e=R(o(),t);if(e.length===0)return t;const s=k(t);return[...t,...e.map((a,p)=>({content:a.content,optimistic:!0,role:"user",seq:s+1+p}))]}),_=c(()=>{const t=i().filter(e=>e.role==="assistant").length;return q().filter(e=>e.kind!=="progress"&&e.threadKey===n&&e.turn>=t).map(e=>e.text).join("")}),E=async(t,e)=>{const s=y;y+=1;const a=k(i());o.set([...R(o(),i()),{content:t,id:s,maxDurableSeqAtSend:a}]);try{await r.mutation(x,{input:t,threadKey:n,...A,...e})}catch(p){throw o.set(o().filter(T=>T.id!==s)),p}},v=async(t,e,s)=>{const a=u()?.instanceId;if(a===void 0)throw new Error(`agentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await r.mutation(d.agents.agentResolveApproval,{decision:t,instanceId:a,threadKey:n,toolCallId:e,...s===void 0?{}:{note:s}})};return{approve:async(t,e)=>v("approve",t,e),cancel:async()=>{const t=u()?.instanceId;g===void 0||t===void 0||await r.mutation(g,{instanceId:t,threadKey:n})},messages:D,reject:async(t,e)=>v("reject",t,e),send:E,status:C,streamingText:_}};export{U as agentChat};
@@ -1 +0,0 @@
1
- import{inject as v,DestroyRef as f,computed as y}from"@angular/core";import{resolveLunoraClient as C}from"./LUNORA_CLIENT-B0toApHY.mjs";import{stream as I}from"./stream-AffQZjVg.mjs";import{subscription as N}from"./subscription-TT5Jlxw0.mjs";const m={__lunoraRef:""},E=[],R=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.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}}]},A=t=>{const{api:r,limit:e,stream:n,threadKey:l}=t,a=C(t.client),i=t.destroyRef??v(f),u=e===void 0?{key:l}:{key:l,limit:e},{data:s}=N(r.agents.agentMessages,u,{client:a,destroyRef:i}),p=n===void 0?"skip":{key:l},{chunks:c}=I(n??m,p,{client:a,destroyRef:i});return{events:y(()=>{const d=(s()??E).flatMap(o=>R(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===l&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{A as agentToolEvents};
@@ -1 +0,0 @@
1
- import{computed as O,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 n="[";for(let s=0;s<t.length;s++)s>0&&(n+=","),n+=$(t[s]);return n+"]"}const r=Object.getPrototypeOf(t);if(r!==null&&r!==Object.prototype){const n=t.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 o=t,i=Object.keys(o).sort();let c="{",e=!0;for(const n of i){const s=o[n];s!==void 0&&(e?e=!1:c+=",",c+=J(n),c+=":",c+=$(s))}return c+"}"},D=t=>{let r="";for(let i=0;i<t.length;i+=32768)r+=String.fromCharCode(...t.subarray(i,i+32768));return btoa(r)},l="$lunora.wire$",W=64,q="__proto__",ot=t=>{if(t===null||typeof t!="object")return!1;const r=Object.getPrototypeOf(t);return r===null||r===Object.prototype},S=(t,r=0)=>{if(r>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",S(t.getTime(),r+1)];if(t instanceof Error){const e=t,n={};for(const u of Object.keys(e)){if(e[u]===void 0)continue;const y=S(e[u],r+1);u===q?Object.defineProperty(n,u,{configurable:!0,enumerable:!0,value:y,writable:!0}):n[u]=y}const s=[l,"error",e.name,e.message,n];return e.cause!==void 0&&s.push(S(e.cause,r+1)),s}if(t instanceof URL)return[l,"url",t.href];if(t instanceof Map)return[l,"map",[...t.entries()].map(([e,n])=>[S(e,r+1),S(n,r+1)])];if(t instanceof Set)return[l,"set",[...t].map(e=>S(e,r+1))];if(t instanceof ArrayBuffer)return[l,"bytes",D(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){const e=t,n=e.constructor.name,s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return n==="Uint8Array"?[l,"bytes",D(s)]:[l,"bytes",D(s),n]}if(Array.isArray(t)){const e=t.map(n=>S(n,r+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,c={};for(const e of Object.keys(i)){const n=i[e];if(n===void 0)continue;const s=S(n,r+1);e===q?Object.defineProperty(c,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):c[e]=s}return c},st=t=>$(S(t)),K=(t,r)=>`${t}::${st(r)}`,M=(t,r)=>({...r,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),Q=(t,r,o,i)=>{const c=G(o.client),e=o.destroyRef===void 0&&i===void 0,{initialNumItems:n,shardKey:s}=o,u=t.__lunoraRef,y=r==="skip"?{}:r,a=L(v(n)),E=L([]),B=L("LoadingFirstPage"),A=L(void 0),R=new Map,m=new Map,C=new Set,N=()=>{const b=a().map(f=>{const g=K(u,M(f,y));return m.get(g)});E.set(b);const{status:P}=U(r==="skip",b);B.set(P)},Y=(w,b)=>{const P=f=>K(u,M(f,y));for(const f of b){const g=P(f);if(m.has(g))continue;const p=w.find(d=>d.lower===f.lower);if(p){const d=m.get(P(p));d&&m.set(g,d)}}},Z=w=>{const b=new Set;for(const f of w)b.add(K(u,M(f,y)));for(const[f,g]of R)b.has(g.currentKey)||(g.unsub(),R.delete(f),m.delete(g.currentKey));const P=new Set([...R.values()].map(f=>f.currentKey));for(const f of w){const g=M(f,y),p=K(u,g);if(P.has(p))continue;const d={currentKey:p,unsub:void 0};C.add(p);const x=c.subscribe(t,g,j=>{if(m.set(d.currentKey,j),C.delete(d.currentKey),A.set(void 0),N(),C.size===0){const h=a(),k=et(h,E());k&&(Y(h,k),a.set(k),F(k),N())}},{onError:j=>{C.delete(p),A.set(j);const h=a(),k=h.at(-1);h.length>1&&k&&!m.has(p)&&K(u,M(k,y))===p&&(a.set(h.slice(0,-1)),F(a())),N(),o.onError?.(j)},shardKey:s});d.unsub=x,R.set(p,d),P.add(p)}};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}};r!=="skip"&&H(e)&&F(a()),N();const T=()=>{for(const w of R.values())w.unsub();R.clear(),m.clear()};return i===void 0?(o.destroyRef??V(z)).onDestroy(T):i(T),{error:A,loadMore:w=>{if(r==="skip")return;const{nextCursor:b,status:P}=U(!1,E());if(P!=="CanLoadMore")return;const f=tt(a(),b,w);if(!f)return;const g=a().at(-1),p=f.at(-2);if(g&&p){const d=K(u,M(g,y)),x=K(u,M(p,y)),j=R.get(d);if(j&&d!==x){const h=m.get(d);h&&m.set(x,h),j.unsub(),R.delete(d),m.delete(d)}}A.set(void 0),a.set(f),F(a()),N()},pageResults:E,status:B}},X=(t,r,o)=>{if(typeof r!="function")return Q(t,r,o);const i=G(o.client),c=o.destroyRef===void 0,e=o.destroyRef??V(z),n=L(void 0);return H(c)&&nt(r,{destroyRef:e,injector:o.injector},(s,u)=>{const y=[];n.set(Q(t,s,{...o,client:i},a=>y.push(a))),u(()=>{for(const a of y)a()})}),{error:O(()=>n()?.error()),loadMore:s=>{n()?.loadMore(s)},pageResults:O(()=>n()?.pageResults()??[]),status:O(()=>n()?.status()??"LoadingFirstPage")}},yt=(t,r,o)=>{const i=X(t,r,o),c=O(()=>i.pageResults().flatMap(n=>n?.page??[])),e=O(()=>{const n=i.status();return n==="LoadingFirstPage"||n==="LoadingMore"});return{error:i.error,isLoading:e,loadMore:i.loadMore,results:c,status:i.status}},dt=(t,r,o)=>{const{initialNumItems:i}=o,c=X(t,r,o),e=O(()=>c.pageResults().flatMap(a=>a?[a.page]:[])),n=O(()=>c.status()==="LoadingFirstPage"),s=O(()=>c.status()==="CanLoadMore"),u=O(()=>c.status()==="LoadingMore"),y=a=>{c.loadMore(a??i)};return{error:c.error,fetchNextPage:y,hasNextPage:s,isFetchingNextPage:u,isLoading:n,pages:e,status:c.status}};export{dt as infiniteQuery,yt as paginatedQuery};
@@ -1 +0,0 @@
1
- import{inject as I,DestroyRef as h,signal as D}from"@angular/core";import{resolveLunoraClient as S}from"./LUNORA_CLIENT-B0toApHY.mjs";import{s as U,r as C}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")},E=1e4,x=(n,e)=>{const s=S(e.client),d=e.destroyRef===void 0,f=e.destroyRef??I(h),{heartbeat:y,listPresent:m,shardKey:i}=e,o=e.intervalMs??E,a=e.sessionId??A(),u=D(void 0);if(!Number.isFinite(o)||o<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(o)}`);let c=e.data;const r=()=>{const t={roomId:n,sessionId:a};c!==void 0&&(t.data=c),s.mutation(y,t,{shardKey:i}).catch(()=>{})},p=t=>{c=t,r()};if(U(d)){const t=s.acquireConnectionContext({roomId:n,sessionId:a},{shardKey:i});r();const l=()=>{typeof document<"u"&&document.visibilityState==="visible"&&r()},v=C(d,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",l),setInterval(r,o))),b={roomId:n},g=s.subscribe(m,b,R=>{u.set(R)},{shardKey:i});f.onDestroy(()=>{clearInterval(v),typeof document<"u"&&document.removeEventListener("visibilitychange",l),t(),g()})}return{present:u.asReadonly(),sessionId:a,setData:p}};export{x as presence};
@@ -1 +0,0 @@
1
- import{inject as h,DestroyRef as R,signal as s}from"@angular/core";import{resolveLunoraClient as b}from"./LUNORA_CLIENT-B0toApHY.mjs";const x=(u,n,e={})=>{const d=b(e.client),m=e.destroyRef??h(R),c=s([]),o=s(void 0),t=s("idle");let a=!0,l;const f=()=>{a=!1,l?.()};if(n!=="skip"){t.set("streaming");const i=d.stream(u,n,{durable:e.durable,maxBuffer:e.maxBuffer,shardKey:e.shardKey});l=()=>{i.cancel()},(async()=>{try{for await(const r of i){if(!a)return;c.update(y=>[...y,r])}a&&t.set("complete")}catch(r){if(!a)return;o.set(r instanceof Error?r:new Error(String(r))),t.set("error")}})().catch(()=>{})}return m.onDestroy(f),{cancel:f,chunks:c.asReadonly(),error:o.asReadonly(),status:t.asReadonly()}};export{x as stream};