@lunora/react 1.0.0-alpha.265 → 1.0.0-alpha.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/index.d.mts +3 -10
  2. package/dist/index.d.ts +3 -10
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AuthLoading-BNDsvgQ4.mjs → AuthLoading-Dqb9692o.mjs} +1 -1
  5. package/dist/packem_shared/{LunoraProvider-B5zAiX86.mjs → LunoraProvider-CypI20I0.mjs} +1 -1
  6. package/dist/packem_shared/hydratePreloaded-C94hJet3.mjs +2 -0
  7. package/dist/packem_shared/lunora-provider-D15UPNFD.mjs +2 -0
  8. package/dist/packem_shared/{query-core-CqnQ_-E5.mjs → query-core-DG86Lpnw.mjs} +1 -1
  9. package/dist/packem_shared/use-paginated-core-Ot5YZ7W3.mjs +2 -0
  10. package/dist/packem_shared/{useAction-DnbG-lGf.mjs → useAction-CIlUzQVY.mjs} +1 -1
  11. package/dist/packem_shared/{useAgent-C4XTDKr3.mjs → useAgent-BBuc2RNx.mjs} +1 -1
  12. package/dist/packem_shared/{useAgentApprovals-DIrIfUkR.mjs → useAgentApprovals-yiIGlGck.mjs} +1 -1
  13. package/dist/packem_shared/{useAgentChat-DgdA3BU5.mjs → useAgentChat-Igz_15YO.mjs} +1 -1
  14. package/dist/packem_shared/{useAgentState-CZkoGPL4.mjs → useAgentState-DbQmCmhH.mjs} +1 -1
  15. package/dist/packem_shared/{useAgentToolEvents-BrIFgqyT.mjs → useAgentToolEvents-vgG15IZX.mjs} +1 -1
  16. package/dist/packem_shared/{useAuth-Do03WzEi.mjs → useAuth-DTiEKNfL.mjs} +1 -1
  17. package/dist/packem_shared/useAuthSessions-BJNwMlyl.mjs +2 -0
  18. package/dist/packem_shared/{useAuthState-CR-hIsvP.mjs → useAuthState-CFScqFAf.mjs} +1 -1
  19. package/dist/packem_shared/{useClientQuery-47csppXE.mjs → useClientQuery-D01Sx8wn.mjs} +1 -1
  20. package/dist/packem_shared/{useConnectionStatus-B4A2Vw8x.mjs → useConnectionStatus-VYjmmafS.mjs} +1 -1
  21. package/dist/packem_shared/{useFlag-DhCr93VG.mjs → useFlag-CHzI2R8e.mjs} +1 -1
  22. package/dist/packem_shared/{useHttpStream-D0biamGu.mjs → useHttpStream-B32eZ6DN.mjs} +1 -1
  23. package/dist/packem_shared/{useInfiniteQuery-C6B9M0s9.mjs → useInfiniteQuery-CeMlqAp6.mjs} +1 -1
  24. package/dist/packem_shared/{useLiveTopic-COTTJo8q.mjs → useLiveTopic-DzP_8Gf3.mjs} +1 -1
  25. package/dist/packem_shared/{useMutation-DmI3aZBl.mjs → useMutation-BfuQVXiY.mjs} +1 -1
  26. package/dist/packem_shared/{usePaginatedQuery-CK5xnM3r.mjs → usePaginatedQuery-t6CEO-xB.mjs} +1 -1
  27. package/dist/packem_shared/{usePresence-Bgw_pYzz.mjs → usePresence-UDDcnYXw.mjs} +1 -1
  28. package/dist/packem_shared/useQuery-BewsLSm_.mjs +2 -0
  29. package/dist/packem_shared/{useStream-De5SDR6Y.mjs → useStream-D__0Rgzf.mjs} +1 -1
  30. package/dist/packem_shared/{useSubscription-CC39EoMT.mjs → useSubscription-P-_MNJm6.mjs} +1 -1
  31. package/dist/packem_shared/useSuspenseQuery-5wC1or5S.mjs +2 -0
  32. package/dist/packem_shared/{useVoiceAgent-TyztaWYJ.mjs → useVoiceAgent-iTIf7__2.mjs} +1 -1
  33. package/dist/server.d.mts +60 -6
  34. package/dist/server.d.ts +60 -6
  35. package/dist/server.mjs +1 -1
  36. package/package.json +3 -3
  37. package/dist/packem_shared/hydratePreloaded-B6d3r_u1.mjs +0 -2
  38. package/dist/packem_shared/lunora-provider-CW9Gd-pp.mjs +0 -2
  39. package/dist/packem_shared/lunoraQueryOptions-IJB_aFzi.mjs +0 -1
  40. package/dist/packem_shared/query-key-BysXrewF.mjs +0 -1
  41. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +0 -38
  42. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +0 -38
  43. package/dist/packem_shared/use-paginated-core-D9QnfDFs.mjs +0 -2
  44. package/dist/packem_shared/useAuthSessions-BYqSu44Q.mjs +0 -2
  45. package/dist/packem_shared/useQuery-CHjpBW-E.mjs +0 -2
  46. package/dist/packem_shared/useSuspenseQuery-ZsmWeJKm.mjs +0 -2
package/dist/index.d.mts CHANGED
@@ -2,11 +2,11 @@ import { ReactNode, ReactElement } from 'react';
2
2
  import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, OnlineOnlyOption, MutatorHandle, Preloaded } from '@lunora/client';
3
3
  export { type ArgsOf, type AuthImpersonation, type AuthPage, type AuthSession, type AuthUser, type ClientQueryRef, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamRef, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type SubscriptionError, type SubscriptionErrorCallback, type User, createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
6
- import { AuthStatus } from '@lunora/client/auth';
5
+ import { AuthStatus, AuthUsersListFilter } from '@lunora/client/auth';
7
6
  import { PaginationStatus } from '@lunora/client/pagination';
8
7
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
9
8
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
9
+ export { type LunoraQueryOptions, lunoraQueryOptions } from '@lunora/client/query';
10
10
  export { RestrictionError, UploadControl, UploadError, type UploadRestrictions } from '@visulima/storage-client';
11
11
  export { type UploadMethod, type UploadResult, type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
12
12
  interface AuthGateProps {
@@ -268,14 +268,7 @@ interface AdminAuthQueryOptions {
268
268
  pageSize?: number;
269
269
  }
270
270
  /** Options for {@link useAuthUsers}. */
271
- interface UseAuthUsersOptions extends AdminAuthQueryOptions {
272
- filterField?: string;
273
- filterValue?: string;
274
- search?: string;
275
- searchField?: string;
276
- sortBy?: string;
277
- sortDirection?: "asc" | "desc";
278
- }
271
+ interface UseAuthUsersOptions extends AdminAuthQueryOptions, AuthUsersListFilter {}
279
272
  /**
280
273
  * List authenticated users, paged and optionally searched/filtered/sorted.
281
274
  * Hits the admin-gated `GET /_lunora/admin/auth/users` HTTP endpoint via
package/dist/index.d.ts CHANGED
@@ -2,11 +2,11 @@ import { ReactNode, ReactElement } from 'react';
2
2
  import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, OnlineOnlyOption, MutatorHandle, Preloaded } from '@lunora/client';
3
3
  export { type ArgsOf, type AuthImpersonation, type AuthPage, type AuthSession, type AuthUser, type ClientQueryRef, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamRef, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type SubscriptionError, type SubscriptionErrorCallback, type User, createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
6
- import { AuthStatus } from '@lunora/client/auth';
5
+ import { AuthStatus, AuthUsersListFilter } from '@lunora/client/auth';
7
6
  import { PaginationStatus } from '@lunora/client/pagination';
8
7
  export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
9
8
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
9
+ export { type LunoraQueryOptions, lunoraQueryOptions } from '@lunora/client/query';
10
10
  export { RestrictionError, UploadControl, UploadError, type UploadRestrictions } from '@visulima/storage-client';
11
11
  export { type UploadMethod, type UploadResult, type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
12
12
  interface AuthGateProps {
@@ -268,14 +268,7 @@ interface AdminAuthQueryOptions {
268
268
  pageSize?: number;
269
269
  }
270
270
  /** Options for {@link useAuthUsers}. */
271
- interface UseAuthUsersOptions extends AdminAuthQueryOptions {
272
- filterField?: string;
273
- filterValue?: string;
274
- search?: string;
275
- searchField?: string;
276
- sortBy?: string;
277
- sortDirection?: "asc" | "desc";
278
- }
271
+ interface UseAuthUsersOptions extends AdminAuthQueryOptions, AuthUsersListFilter {}
279
272
  /**
280
273
  * List authenticated users, paged and optionally searched/filtered/sorted.
281
274
  * Hits the admin-gated `GET /_lunora/admin/auth/users` HTTP endpoint via
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-BNDsvgQ4.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CR-hIsvP.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-CW9Gd-pp.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-IJB_aFzi.mjs";import{useAction as d}from"./packem_shared/useAction-DnbG-lGf.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as c,useOrganizations as h,useSignUpInvitations as U}from"./packem_shared/useAuthSessions-BYqSu44Q.mjs";import{useAgent as S}from"./packem_shared/useAgent-C4XTDKr3.mjs";import{useAgentApprovals as E}from"./packem_shared/useAgentApprovals-DIrIfUkR.mjs";import{useAgentChat as L}from"./packem_shared/useAgentChat-DgdA3BU5.mjs";import{useAgentState as v}from"./packem_shared/useAgentState-CZkoGPL4.mjs";import{useAgentToolEvents as F}from"./packem_shared/useAgentToolEvents-BrIFgqyT.mjs";import{default as M}from"./packem_shared/useAuth-Do03WzEi.mjs";import{default as b}from"./packem_shared/useClientQuery-47csppXE.mjs";import{default as O}from"./packem_shared/useConnectionStatus-B4A2Vw8x.mjs";import{useFlag as H,useFlags as V}from"./packem_shared/useFlag-DhCr93VG.mjs";import{useHttpStream as q}from"./packem_shared/useHttpStream-D0biamGu.mjs";import{default as B}from"./packem_shared/useInfiniteQuery-C6B9M0s9.mjs";import{useLiveTopic as G}from"./packem_shared/useLiveTopic-COTTJo8q.mjs";import{useMutation as K}from"./packem_shared/useMutation-DmI3aZBl.mjs";import{useMutator as W}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as Y}from"./packem_shared/usePaginatedQuery-CK5xnM3r.mjs";import{hydratePreloaded as _,default as $}from"./packem_shared/hydratePreloaded-B6d3r_u1.mjs";import{usePresence as re}from"./packem_shared/usePresence-Bgw_pYzz.mjs";import{default as te}from"./packem_shared/useQuery-CHjpBW-E.mjs";import{useRateLimit as se}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as pe}from"./packem_shared/useStream-De5SDR6Y.mjs";import{default as ne}from"./packem_shared/useSubscription-CC39EoMT.mjs";import{default as me}from"./packem_shared/useSuspenseQuery-ZsmWeJKm.mjs";import{useVoiceAgent as de}from"./packem_shared/useVoiceAgent-TyztaWYJ.mjs";import{createClientQuery as Ae,getErrorCode as ge,getRetryAfterMs as ce,isConflictError as he,isForbiddenError as Ue,isRateLimitedError as ye,isUnauthorizedError as Se}from"@lunora/client";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,Ae as createClientQuery,ge as getErrorCode,ce as getRetryAfterMs,_ as hydratePreloaded,he as isConflictError,Ue as isForbiddenError,ye as isRateLimitedError,Se as isUnauthorizedError,m as lunoraQueryOptions,d as useAction,S as useAgent,E as useAgentApprovals,L as useAgentChat,v as useAgentState,F as useAgentToolEvents,M as useAuth,A as useAuthSessions,a as useAuthState,g as useAuthUsers,ve as useChunkedRestUpload,b as useClientQuery,O as useConnectionStatus,Re as useFileInput,H as useFlag,V as useFlags,q as useHttpStream,c as useImpersonate,B as useInfiniteQuery,G as useLiveTopic,n as useLunora,Fe as useMultipartUpload,K as useMutation,W as useMutator,h as useOrganizations,Y as usePaginatedQuery,Ie as usePasteUpload,$ as usePreloadedQuery,re as usePresence,te as useQuery,se as useRateLimit,U as useSignUpInvitations,pe as useStream,ne as useSubscription,me as useSuspenseQuery,Me as useTusUpload,Te as useUpload,de as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-Dqb9692o.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CFScqFAf.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-D15UPNFD.mjs";import{useAction as m}from"./packem_shared/useAction-CIlUzQVY.mjs";import{useAuthSessions as d,useAuthUsers as l,useImpersonate as A,useOrganizations as g,useSignUpInvitations as c}from"./packem_shared/useAuthSessions-BJNwMlyl.mjs";import{useAgent as U}from"./packem_shared/useAgent-BBuc2RNx.mjs";import{useAgentApprovals as S}from"./packem_shared/useAgentApprovals-yiIGlGck.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-Igz_15YO.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-DbQmCmhH.mjs";import{useAgentToolEvents as v}from"./packem_shared/useAgentToolEvents-vgG15IZX.mjs";import{default as F}from"./packem_shared/useAuth-DTiEKNfL.mjs";import{default as M}from"./packem_shared/useClientQuery-D01Sx8wn.mjs";import{default as b}from"./packem_shared/useConnectionStatus-VYjmmafS.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-CHzI2R8e.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-B32eZ6DN.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-CeMlqAp6.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-DzP_8Gf3.mjs";import{useMutation as G}from"./packem_shared/useMutation-BfuQVXiY.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-t6CEO-xB.mjs";import{hydratePreloaded as Y,default as Z}from"./packem_shared/hydratePreloaded-C94hJet3.mjs";import{usePresence as $}from"./packem_shared/usePresence-UDDcnYXw.mjs";import{default as re}from"./packem_shared/useQuery-BewsLSm_.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-D__0Rgzf.mjs";import{default as pe}from"./packem_shared/useSubscription-P-_MNJm6.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-5wC1or5S.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-iTIf7__2.mjs";import{createClientQuery as de,getErrorCode as le,getRetryAfterMs as Ae,isConflictError as ge,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{lunoraQueryOptions as Se}from"@lunora/client/query";import{RestrictionError as Ee,UploadControl as Qe,UploadError as Le}from"@visulima/storage-client";import{useChunkedRestUpload as ve,useFileInput as Re,useMultipartUpload as Fe,usePasteUpload as Ie,useTusUpload as Me,useUpload as Te}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ee as RestrictionError,u as Unauthenticated,Qe as UploadControl,Le as UploadError,de as createClientQuery,le as getErrorCode,Ae as getRetryAfterMs,Y as hydratePreloaded,ge as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,Se as lunoraQueryOptions,m as useAction,U as useAgent,S as useAgentApprovals,E as useAgentChat,L as useAgentState,v as useAgentToolEvents,F as useAuth,d as useAuthSessions,a as useAuthState,l as useAuthUsers,ve as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Re as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,A as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Fe as useMultipartUpload,G as useMutation,K as useMutator,g as useOrganizations,W as usePaginatedQuery,Ie as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,c as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Me as useTusUpload,Te as useUpload,me as useVoiceAgent};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useAuthState as o}from"./useAuthState-CR-hIsvP.mjs";const s=t=>{const{children:n}=t,{isAuthenticated:i}=o();return i?n:void 0},d=t=>{const{children:n}=t,{isAuthenticated:i,isLoading:e}=o();return!e&&!i?n:void 0},r=t=>{const{children:n}=t,{isLoading:i}=o();return i?n:void 0};export{r as AuthLoading,s as Authenticated,d as Unauthenticated};
2
+ import{useAuthState as o}from"./useAuthState-CFScqFAf.mjs";const s=t=>{const{children:n}=t,{isAuthenticated:i}=o();return i?n:void 0},d=t=>{const{children:n}=t,{isAuthenticated:i,isLoading:e}=o();return!e&&!i?n:void 0},r=t=>{const{children:n}=t,{isLoading:i}=o();return i?n:void 0};export{r as AuthLoading,s as Authenticated,d as Unauthenticated};
@@ -1 +1 @@
1
- import{L as e,u as o,a as u}from"./lunora-provider-CW9Gd-pp.mjs";export{e as LunoraProvider,o as useLunora,u as useLunoraClientSwapped};
1
+ import{L as e,u as o,a as u}from"./lunora-provider-D15UPNFD.mjs";export{e as LunoraProvider,o as useLunora,u as useLunoraClientSwapped};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as K}from"react/compiler-runtime";import{useQueryClient as P,useQuery as N}from"@tanstack/react-query";import{useRef as T,useEffect as I,useSyncExternalStore as w,useState as x}from"react";import{u as F,g as L,a as O,s as V}from"./lunora-provider-D15UPNFD.mjs";import{lunoraQueryKey as z}from"@lunora/client/query";const D=function(o,r){const e=K(11);let s;e[0]!==r?(s=r===void 0?{}:r,e[0]=r,e[1]=s):s=e[1];const i=s,t=F(),n=P(),S=T(i.onError);let c;e[2]!==i.onError?(c=()=>{S.current=i.onError},e[2]=i.onError,e[3]=c):c=e[3],I(c);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=h=>{S.current?.(h)},e[4]=u):u=e[4];const b=u,m=L(t);let a;e[5]!==t?(a=()=>t.identityEpoch(),e[5]=t,e[6]=a):a=e[6];const _=w(m.subscribeIdentityEpoch,a,Y),[Q]=x(t),R=O(),{args:p,functionPath:q,shardKey:l}=o,g=_===0&&!R&&t===Q?o.value:void 0,d={__lunoraRef:q},f=z(d,p,l),{data:v}=N({initialData:g,queryFn:async h=>{const{signal:C}=h;return m.liveValue(n,f,C,{fetch:async()=>t.query(d,p,{shardKey:l}),shardKey:l})},queryKey:f,staleTime:Number.POSITIVE_INFINITY}),E=V(f);let y;return e[7]!==t||e[8]!==n||e[9]!==E?(y=[t,n,E,b],e[7]=t,e[8]=n,e[9]=E,e[10]=y):y=e[10],I(()=>m.attach(n,f,d,p,l,{onError:b}),y),v===void 0?g:v},G=function(o,r={}){return D(o,r)};function Y(){return 0}export{D as default,G as hydratePreloaded};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as W}from"react/compiler-runtime";import{LunoraError as D}from"@lunora/errors";import{QueryClientContext as M,QueryClientProvider as A,QueryClient as N}from"@tanstack/react-query";import{use as Q,useState as S,useEffect as T,useRef as z,createContext as P}from"react";import{stableWireKey as R}from"@lunora/wire";import{jsx as m}from"react/jsx-runtime";const b=r=>R(r),K=r=>b(r),E=r=>{r!==void 0&&(r.cancel({silent:!0}),r.setState({...r.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))},I={status:"idle"},F=(r,e)=>{for(const s of r.waiters)s(e);r.waiters.clear()},_=1e4,U=async(r,e,s)=>new Promise((i,d)=>{if(e.aborted){d(e.reason);return}let u,h;const l=()=>{clearTimeout(u),h?.(),r.waiters.delete(n),e.removeEventListener("abort",t)},t=()=>{l(),d(e.reason)},n=c=>{l(),i(c)};u=setTimeout(()=>{n(!1)},_),r.waiters.add(n),e.addEventListener("abort",t,{once:!0}),h=s(()=>{n(!1)}),r.waiters.has(n)||h()});class V{constructor(e){this.client=e}client;entries=new Map;live=new Map;identityWatched=new Set;listening=!1;hasConsumers(e){return this.entries.has(b(e))}async liveValue(e,s,i,d){const{fetch:u,shardKey:h,waitForPush:l=!0}=d;if(!("window"in globalThis)||this.client.getWebSocketImpl()===void 0)return u();const t=b(s),n=this.liveFor(t),c=n.state.status==="pushed"?e.getQueryData(s)??n.state.value:void 0;if(c!==void 0)return c;if(l&&n.state.status!=="errored"&&!this.client.isCrossTabFollower()&&this.client.expectsPush({shardKey:h})){let o;try{o=await U(n,i,f=>this.client.onConnectionStatus(()=>{this.client.expectsPush({shardKey:h})||f()}))}finally{this.forgetIdleLive(t)}if(o)return this.liveValue(e,s,i,d)}const p=n.state;let a;try{a=await u()}finally{this.forgetIdleLive(t)}if(n.state!==p&&n.state.status==="pushed"){const o=e.getQueryData(s);return o!==void 0?o:n.state.value}return a}clearOnIdentityChange(e){this.listenForIdentityChange(),this.identityWatched.add(e)}stopClearingOnIdentityChange(e){this.identityWatched.delete(e)}subscribeIdentityEpoch=e=>(this.listenForIdentityChange(),this.client.onIdentityChange(e));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{for(const e of this.identityWatched)this.clearQueries(e)}))}clearQueries(e){const s=e.getQueryCache();for(const i of s.findAll({queryKey:["lunora"]}))E(i),i.getObserversCount()===0&&!this.hasConsumers(i.queryKey)&&s.remove(i)}attach(e,s,i,d,u,h={}){const l=b(s);let t=this.entries.get(l);if(!t){t={clients:new Map([[e,0]]),errorCallbacks:new Set,unsubscribe:void 0},this.entries.set(l,t);const a=t;try{t.unsubscribe=this.client.subscribe(i,d,o=>{const f=this.liveFor(l);if(o===void 0){f.state=I;for(const v of a.clients.keys())E(v.getQueryCache().find({exact:!0,queryKey:s}));return}for(const v of a.clients.keys())v.setQueryData(s,o);f.state={status:"pushed",value:o},F(f,!0)},{onError:o=>{const f=this.liveFor(l);f.state.status!=="pushed"&&(f.state={status:"errored"},F(f,!1));for(const v of a.errorCallbacks)v(o)},shardKey:u})}catch(o){throw this.entries.delete(l),this.dropLive(l),o}}t.clients.set(e,(t.clients.get(e)??0)+1);const n=this.live.get(l);n?.state.status==="pushed"&&e.setQueryData(s,n.state.value);const{onError:c}=h;c&&t.errorCallbacks.add(c);let p=!1;return()=>{if(p)return;p=!0;const a=this.entries.get(l);if(!a)return;const o=(a.clients.get(e)??1)-1;o>0?a.clients.set(e,o):a.clients.delete(e),c&&a.errorCallbacks.delete(c),a.clients.size===0&&(a.unsubscribe?.(),this.entries.delete(l),this.dropLive(l))}}liveFor(e){let s=this.live.get(e);return s||(s={state:I,waiters:new Set},this.live.set(e,s)),s}forgetIdleLive(e){!this.entries.has(e)&&this.live.get(e)?.waiters.size===0&&this.live.delete(e)}dropLive(e){const s=this.live.get(e);s!==void 0&&(s.waiters.size===0?this.live.delete(e):s.state=I)}}const x=new WeakMap,L=r=>{let e=x.get(r);return e||(e=new V(r),x.set(r,e)),e},k=P(null),O=P(!1),B=()=>new N({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),X=r=>{const e=W(20),{children:s,client:i,queryClient:d}=r,u=Q(M);let h;e[0]!==u||e[1]!==d?(h=()=>d??u??B(),e[0]=u,e[1]=d,e[2]=h):h=e[2];const[l]=S(h),t=d??u??l;let n,c;e[3]!==i||e[4]!==t?(n=()=>{L(i).clearOnIdentityChange(t)},c=[i,t],e[3]=i,e[4]=t,e[5]=n,e[6]=c):(n=e[5],c=e[6]),T(n,c);const p=z(i);let a,o;e[7]!==i||e[8]!==t?(a=()=>{p.current!==i&&(L(p.current).stopClearingOnIdentityChange(t),p.current=i,L(i).clearQueries(t),t.invalidateQueries({queryKey:["lunora"]}))},o=[i,t],e[7]=i,e[8]=t,e[9]=a,e[10]=o):(a=e[9],o=e[10]),T(a,o);const[f]=S(i),v=i!==f;let g;e[11]!==s||e[12]!==v?(g=m(O,{value:v,children:s}),e[11]=s,e[12]=v,e[13]=g):g=e[13];let w;e[14]!==i||e[15]!==g?(w=m(k,{value:i,children:g}),e[14]=i,e[15]=g,e[16]=w):w=e[16];const y=w;if(u===t)return y;let C;return e[17]!==y||e[18]!==t?(C=m(A,{client:t,children:y}),e[17]=y,e[18]=t,e[19]=C):C=e[19],C},Z=()=>Q(O),q=()=>{const r=Q(k);if(!r)throw new D("INTERNAL","useLunora must be used inside <LunoraProvider />");return r};export{X as L,Z as a,L as g,K as s,q as u};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as R}from"react/compiler-runtime";import{useRef as $,useEffect as b}from"react";import{g as h}from"./lunora-provider-CW9Gd-pp.mjs";const x=g=>{const e=R(16),{args:a,argsKey:E,client:r,function_:n,onError:s,queryClient:t,queryKey:m,shardKey:i,skipped:o}=g,p=`${n.__lunoraRef}\0${E}\0${i??""}`,y=$(s);let c;e[0]!==s?(c=()=>{y.current=s},e[0]=s,e[1]=c):c=e[1],b(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=K=>{y.current?.(K)},e[2]=u):u=e[2];const _=u;let f;e[3]!==a||e[4]!==r||e[5]!==n||e[6]!==t||e[7]!==m||e[8]!==i||e[9]!==o?(f=()=>o?S:h(r).attach(t,m,n,a,i,{onError:_}),e[3]=a,e[4]=r,e[5]=n,e[6]=t,e[7]=m,e[8]=i,e[9]=o,e[10]=f):f=e[10];let l;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==p?(l=[r,t,p,o,_],e[11]=r,e[12]=t,e[13]=o,e[14]=p,e[15]=l):l=e[15],b(f,l)};function S(){}export{x as u};
2
+ import{c as R}from"react/compiler-runtime";import{useRef as $,useEffect as b}from"react";import{g as h}from"./lunora-provider-D15UPNFD.mjs";const x=g=>{const e=R(16),{args:a,argsKey:E,client:r,function_:n,onError:s,queryClient:t,queryKey:m,shardKey:i,skipped:o}=g,p=`${n.__lunoraRef}\0${E}\0${i??""}`,y=$(s);let c;e[0]!==s?(c=()=>{y.current=s},e[0]=s,e[1]=c):c=e[1],b(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=K=>{y.current?.(K)},e[2]=u):u=e[2];const _=u;let f;e[3]!==a||e[4]!==r||e[5]!==n||e[6]!==t||e[7]!==m||e[8]!==i||e[9]!==o?(f=()=>o?S:h(r).attach(t,m,n,a,i,{onError:_}),e[3]=a,e[4]=r,e[5]=n,e[6]=t,e[7]=m,e[8]=i,e[9]=o,e[10]=f):f=e[10];let l;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==p?(l=[r,t,p,o,_],e[11]=r,e[12]=t,e[13]=o,e[14]=p,e[15]=l):l=e[15],b(f,l)};function S(){}export{x as u};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{initialPages as T,rebalance as j,derivePaginationStatus as D,applyLoadMore as Y}from"@lunora/client/pagination";import{useQueryClient as B,CancelledError as G}from"@tanstack/react-query";import{useRef as g,useReducer as J,useState as z,useEffect as l,useCallback as U}from"react";import{u as W,s as i,g as X}from"./lunora-provider-D15UPNFD.mjs";import{lunoraQueryKey as R}from"@lunora/client/query";const Z=function(c){const m=g(void 0);return m.current??=c(),m},oe=function(c,m,I){const y=W(),o=B(),{initialNumItems:S,shardKey:p}=I,f=m==="skip",K=f?{}:m,[,H]=J(s=>s+1,0),[P,k]=z(()=>T(S)),[V,v]=z(void 0),A=g(I.onError);l(()=>{A.current=I.onError});const E=`${i(R(c,K,p))}::${String(S)}`,F=g(E);F.current!==E&&(F.current=E,k(T(S)),v(void 0));const C=P.map(s=>{const t={...K,paginationOpts:{cursor:s.lower,endCursor:s.upper,numItems:s.numItems}},n=R(c,t,p);return{args:t,key:n}}),x=C.map(({key:s})=>i(s)).join("|"),b=g({baseArgs:K,entries:[],fn:c,shardKey:p});l(()=>{b.current={baseArgs:K,entries:C,fn:c,shardKey:p}});const L=(s,t,n)=>{v(n),k(a=>{const e=b.current,r=a.at(-1);if(a.length<=1||!r||o.getQueryData(t)!==void 0)return a;const d={...e.baseArgs,paginationOpts:{cursor:r.lower,endCursor:r.upper,numItems:r.numItems}};return i(R(e.fn,d,e.shardKey))===s?a.slice(0,-1):a}),A.current?.(n)},Q=Z(()=>new Map),M=g(y);l(()=>{const s=Q.current;if(M.current!==y){for(const e of s.values())e();s.clear(),M.current=y}if(f){for(const e of s.values())e();s.clear();return}const t=b.current,n=X(y),a=new Set(t.entries.map(({key:e})=>i(e)));for(const[e,r]of s)a.has(e)||(r(),s.delete(e));for(const e of t.entries){const r=i(e.key);if(s.has(r))continue;const d=async()=>y.query(t.fn,e.args,{shardKey:t.shardKey}),h=()=>{o.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:async({signal:u})=>n.liveValue(o,e.key,u,{fetch:d,shardKey:t.shardKey}),queryKey:e.key,staleTime:0}).catch(u=>{if(u instanceof G){n.hasConsumers(e.key)&&h();return}L(r,e.key,u instanceof Error?{code:u.code,message:u.message}:{message:String(u)})})};h();const w=n.attach(o,e.key,t.fn,e.args,t.shardKey,{onError:O=>{L(r,e.key,O)}}),N=e.key;s.set(r,()=>{w(),n.hasConsumers(N)||o.removeQueries({exact:!0,queryKey:N})})}},[y,o,x,f]),l(()=>()=>{for(const s of Q.current.values())s();Q.current.clear()},[]),l(()=>{const s=o.getQueryCache(),t=new Set(C.map(({key:e})=>i(e))),n=c.__lunoraRef;return s.subscribe(e=>{if(e.type!=="updated")return;const r=e.query.queryKey;if(r[1]!==n)return;const d=i(r);t.has(d)&&(v(void 0),H())})},[o,x]);const q=f?[]:C.map(({key:s})=>o.getQueryData(s));l(()=>{if(f)return;const s=j(P,q);s&&k(s)});const{status:_}=D(f,q),$=U(s=>{v(void 0),k(t=>{const n=b.current,a=t.map(h=>{const w={...n.baseArgs,paginationOpts:{cursor:h.lower,endCursor:h.upper,numItems:h.numItems}};return o.getQueryData(R(n.fn,w,n.shardKey))}),{nextCursor:e,status:r}=D(!1,a);return Y(t,r==="CanLoadMore"?e:void 0,s)??t})},[o]);return{error:V,loadMore:$,pageResults:q,status:_}};export{oe as u};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as R}from"react/compiler-runtime";import{createCallRunner as k}from"@lunora/client";import{useMutation as x}from"@tanstack/react-query";import{useState as n}from"react";import{u as C}from"./lunora-provider-CW9Gd-pp.mjs";const S=a=>{const t=R(12),i=C(),[c,g]=n(void 0),[l,m]=n(void 0),[u,M]=n(!1);let o;t[0]!==i||t[1]!==a?(o={mutationFn:async e=>{const{args:y,options:A}=e;return i.action(a,y,A)},networkMode:"always",retry:0},t[0]=i,t[1]=a,t[2]=o):o=t[2];const{mutateAsync:d,reset:p}=x(o);let s;t[3]!==d||t[4]!==p?(s=()=>({call:k(async(e,y)=>d({args:e,options:y}),{setError:m,setPending:M,setResult:e=>{g(()=>e),m(void 0)}}),reset:()=>{g(void 0),m(void 0),p()}}),t[3]=d,t[4]=p,t[5]=s):s=t[5];const[w]=n(s),{call:f,reset:v}=w;let r;return t[6]!==f||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==v?(r={call:f,data:c,error:l,pending:u,reset:v},t[6]=f,t[7]=c,t[8]=l,t[9]=u,t[10]=v,t[11]=r):r=t[11],r};export{S as useAction};
2
+ import{c as R}from"react/compiler-runtime";import{createCallRunner as k}from"@lunora/client";import{useMutation as x}from"@tanstack/react-query";import{useState as n}from"react";import{u as C}from"./lunora-provider-D15UPNFD.mjs";const S=a=>{const t=R(12),i=C(),[c,g]=n(void 0),[l,m]=n(void 0),[u,M]=n(!1);let o;t[0]!==i||t[1]!==a?(o={mutationFn:async e=>{const{args:y,options:A}=e;return i.action(a,y,A)},networkMode:"always",retry:0},t[0]=i,t[1]=a,t[2]=o):o=t[2];const{mutateAsync:d,reset:p}=x(o);let s;t[3]!==d||t[4]!==p?(s=()=>({call:k(async(e,y)=>d({args:e,options:y}),{setError:m,setPending:M,setResult:e=>{g(()=>e),m(void 0)}}),reset:()=>{g(void 0),m(void 0),p()}}),t[3]=d,t[4]=p,t[5]=s):s=t[5];const[w]=n(s),{call:f,reset:v}=w;let r;return t[6]!==f||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==v?(r={call:f,data:c,error:l,pending:u,reset:v},t[6]=f,t[7]=c,t[8]=l,t[9]=u,t[10]=v,t[11]=r):r=t[11],r};export{S as useAction};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-DmI3aZBl.mjs";import O from"./useSubscription-CC39EoMT.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
2
+ import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BfuQVXiY.mjs";import O from"./useSubscription-P-_MNJm6.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as p}from"react/compiler-runtime";import c from"./useSubscription-CC39EoMT.mjs";const m=n=>{const e=p(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:a,error:r}=c(n.api.agents.agentPendingApprovals,t),s=a;let o;return e[1]!==r||e[2]!==s?(o={approvals:s,error:r},e[1]=r,e[2]=s,e[3]=o):o=e[3],o};export{m as useAgentApprovals};
2
+ import{c as p}from"react/compiler-runtime";import c from"./useSubscription-P-_MNJm6.mjs";const m=n=>{const e=p(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:a,error:r}=c(n.api.agents.agentPendingApprovals,t),s=a;let o;return e[1]!==r||e[2]!==s?(o={approvals:s,error:r},e[1]=r,e[2]=s,e[3]=o):o=e[3],o};export{m as useAgentApprovals};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-CW9Gd-pp.mjs";import{useMutation as s}from"./useMutation-DmI3aZBl.mjs";import{useStream as at}from"./useStream-De5SDR6Y.mjs";import d from"./useSubscription-CC39EoMT.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],kt=A=>{const{api:r,cancel:m,limit:g,onError:i,send:E,sendArgs:_,stream:v,threadKey:e}=A,T=g===void 0?{key:e}:{key:e,limit:g},{data:w,error:x}=d(r.agents.agentMessages,T,{onError:i}),{data:G,error:I}=d(r.agents.agentThread,{key:e},{onError:i}),{data:O,error:b}=d(r.agents.agentApprovalGrants,{key:e},{onError:i}),C=v===void 0?"skip":{key:e},{chunks:D}=at(v??st,C),j=s(E),q=s(m??ot),F=s(r.agents.agentResolveApproval),N=s(r.agents.agentRevokeApprovalGrant),K=s(r.agents.agentDeclineSecret),P=rt(),[Y,u]=nt([]),h=k(0),f=k(e);f.current!==e&&(f.current=e,u([]));const y=G,L=y?.status,c=y?.instanceId,a=w??ct,S=M(Y,a),U=R(a),$=S.length===0?a:[...a,...S.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],z=a.filter(t=>t.role==="assistant").length,B=D.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=z).map(t=>t.text).join(""),{mutate:H}=j,{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,X=async(t,n)=>{const o=h.current;h.current+=1;const Z=R(a);u(p=>[...M(p,a),{content:t,id:o,maxDurableSeqAtSend:Z}]);try{await H({input:t,threadKey:e,..._,...n})}catch(p){throw u(tt=>tt.filter(et=>et.id!==o)),p}},l=async(t,n,o)=>{if(c===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await Q({decision:t,instanceId:c,threadKey:e,toolCallId:n,...o===void 0?{}:{note:o}})};return{approvalGrants:O??it,approve:(t,n)=>l("approve",t,n),approveForThread:(t,n)=>l("approve_for_thread",t,n),cancel:async()=>{m===void 0||c===void 0||await J({instanceId:c,threadKey:e})},declineSecret:async t=>{await W({threadKey:e,toolCallId:t})},error:x??I??b,messages:$,reject:(t,n)=>l("reject",t,n),revokeGrant:async t=>{await V({threadKey:e,toolName:t})},send:X,status:L,streamingText:B,supplySecret:async(t,n)=>{await P.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{kt as useAgentChat};
2
+ import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as nt,useRef as k}from"react";import{u as rt}from"./lunora-provider-D15UPNFD.mjs";import{useMutation as s}from"./useMutation-BfuQVXiY.mjs";import{useStream as at}from"./useStream-D__0Rgzf.mjs";import d from"./useSubscription-P-_MNJm6.mjs";const ot={__lunoraRef:""},st={__lunoraRef:""},ct=[],it=[],kt=A=>{const{api:r,cancel:m,limit:g,onError:i,send:E,sendArgs:_,stream:v,threadKey:e}=A,T=g===void 0?{key:e}:{key:e,limit:g},{data:w,error:x}=d(r.agents.agentMessages,T,{onError:i}),{data:G,error:I}=d(r.agents.agentThread,{key:e},{onError:i}),{data:O,error:b}=d(r.agents.agentApprovalGrants,{key:e},{onError:i}),C=v===void 0?"skip":{key:e},{chunks:D}=at(v??st,C),j=s(E),q=s(m??ot),F=s(r.agents.agentResolveApproval),N=s(r.agents.agentRevokeApprovalGrant),K=s(r.agents.agentDeclineSecret),P=rt(),[Y,u]=nt([]),h=k(0),f=k(e);f.current!==e&&(f.current=e,u([]));const y=G,L=y?.status,c=y?.instanceId,a=w??ct,S=M(Y,a),U=R(a),$=S.length===0?a:[...a,...S.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:U+1+n}))],z=a.filter(t=>t.role==="assistant").length,B=D.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=z).map(t=>t.text).join(""),{mutate:H}=j,{mutate:J}=q,{mutate:Q}=F,{mutate:V}=N,{mutate:W}=K,X=async(t,n)=>{const o=h.current;h.current+=1;const Z=R(a);u(p=>[...M(p,a),{content:t,id:o,maxDurableSeqAtSend:Z}]);try{await H({input:t,threadKey:e,..._,...n})}catch(p){throw u(tt=>tt.filter(et=>et.id!==o)),p}},l=async(t,n,o)=>{if(c===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await Q({decision:t,instanceId:c,threadKey:e,toolCallId:n,...o===void 0?{}:{note:o}})};return{approvalGrants:O??it,approve:(t,n)=>l("approve",t,n),approveForThread:(t,n)=>l("approve_for_thread",t,n),cancel:async()=>{m===void 0||c===void 0||await J({instanceId:c,threadKey:e})},declineSecret:async t=>{await W({threadKey:e,toolCallId:t})},error:x??I??b,messages:$,reject:(t,n)=>l("reject",t,n),revokeGrant:async t=>{await V({threadKey:e,toolName:t})},send:X,status:L,streamingText:B,supplySecret:async(t,n)=>{await P.mutation(r.agents.agentSupplySecret,{secret:n,threadKey:e,toolCallId:t},{onlineOnly:!0})}}};export{kt as useAgentChat};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as o}from"react/compiler-runtime";import d from"./useSubscription-CC39EoMT.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
2
+ import{c as o}from"react/compiler-runtime";import d from"./useSubscription-P-_MNJm6.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as C}from"react/compiler-runtime";import{useStream as y}from"./useStream-De5SDR6Y.mjs";import _ from"./useSubscription-CC39EoMT.mjs";const I={__lunoraRef:""},N=[],S={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:S[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(r=>({input:r.input,seq:o.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},m=o=>{const t=C(12),{api:r,limit:n,stream:i,threadKey:l}=o;let a;t[0]!==n||t[1]!==l?(a=n===void 0?{key:l}:{key:l,limit:n},t[0]=n,t[1]=l,t[2]=a):a=t[2];const v=a,{data:f}=_(r.agents.agentMessages,v);let s;t[3]!==i||t[4]!==l?(s=i===void 0?"skip":{key:l},t[3]=i,t[4]=l,t[5]=s):s=t[5];const E=s,{chunks:p}=y(i??I,E),c=f??N;let e;if(t[6]!==p||t[7]!==c||t[8]!==l){e=c.flatMap(A);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=c,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function A(o){return q(o)??[]}export{m as useAgentToolEvents};
2
+ import{c as C}from"react/compiler-runtime";import{useStream as y}from"./useStream-D__0Rgzf.mjs";import _ from"./useSubscription-P-_MNJm6.mjs";const I={__lunoraRef:""},N=[],S={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=o=>{const t=o.status===void 0?void 0:S[o.status];if(t!==void 0)return{seq:o.seq,type:t,...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}},q=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(r=>({input:r.input,seq:o.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(o.role!=="tool")return;const t=k(o);return t!==void 0?[t]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},m=o=>{const t=C(12),{api:r,limit:n,stream:i,threadKey:l}=o;let a;t[0]!==n||t[1]!==l?(a=n===void 0?{key:l}:{key:l,limit:n},t[0]=n,t[1]=l,t[2]=a):a=t[2];const v=a,{data:f}=_(r.agents.agentMessages,v);let s;t[3]!==i||t[4]!==l?(s=i===void 0?"skip":{key:l},t[3]=i,t[4]=l,t[5]=s):s=t[5];const E=s,{chunks:p}=y(i??I,E),c=f??N;let e;if(t[6]!==p||t[7]!==c||t[8]!==l){e=c.flatMap(A);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=c,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function A(o){return q(o)??[]}export{m as useAgentToolEvents};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as h}from"react/compiler-runtime";import{getIdentityStore as k}from"@lunora/client/auth";import{useSyncExternalStore as p}from"react";import{u as A}from"./lunora-provider-CW9Gd-pp.mjs";const _=()=>{const t=h(13),e=A();let o;t[0]!==e?(o=k(e),t[0]=e,t[1]=o):o=t[1];const n=o;let s,r,u;t[2]!==e?(s=g=>e.onAuthTokenChange(g),r=()=>e.getAuthToken(),u=()=>e.getAuthToken(),t[2]=e,t[3]=s,t[4]=r,t[5]=u):(s=t[3],r=t[4],u=t[5]);const i=p(s,r,u),f=p(n.subscribe,n.getUser,T),m=p(n.subscribe,n.getStatus,b);let l;t[6]!==e?(l=g=>{e.setAuthToken(g)},t[6]=e,t[7]=l):l=t[7];const a=l;let c;return t[8]!==a||t[9]!==m||t[10]!==i||t[11]!==f?(c={setToken:a,status:m,token:i,user:f},t[8]=a,t[9]=m,t[10]=i,t[11]=f,t[12]=c):c=t[12],c};function T(){return null}function b(){return"loading"}export{_ as default};
2
+ import{c as h}from"react/compiler-runtime";import{getIdentityStore as k}from"@lunora/client/auth";import{useSyncExternalStore as p}from"react";import{u as A}from"./lunora-provider-D15UPNFD.mjs";const _=()=>{const t=h(13),e=A();let o;t[0]!==e?(o=k(e),t[0]=e,t[1]=o):o=t[1];const n=o;let s,r,u;t[2]!==e?(s=g=>e.onAuthTokenChange(g),r=()=>e.getAuthToken(),u=()=>e.getAuthToken(),t[2]=e,t[3]=s,t[4]=r,t[5]=u):(s=t[3],r=t[4],u=t[5]);const i=p(s,r,u),f=p(n.subscribe,n.getUser,T),m=p(n.subscribe,n.getStatus,b);let l;t[6]!==e?(l=g=>{e.setAuthToken(g)},t[6]=e,t[7]=l):l=t[7];const a=l;let c;return t[8]!==a||t[9]!==m||t[10]!==i||t[11]!==f?(c={setToken:a,status:m,token:i,user:f},t[8]=a,t[9]=m,t[10]=i,t[11]=f,t[12]=c):c=t[12],c};function T(){return null}function b(){return"loading"}export{_ as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as m}from"react/compiler-runtime";import{authSessionsList as v,authUsersList as L,authOrganizationsList as I,authSignUpInvitationsList as b,ADMIN_AUTH_DEFAULT_PAGE_SIZE as z,subscribeAdminAuthIdentity as U,adminAuthListQueryKey as P,adminAuthListHasMore as M}from"@lunora/client/auth";import{useMutation as $,useQuery as q,keepPreviousData as D}from"@tanstack/react-query";import{useState as E,useSyncExternalStore as _}from"react";import{u as p}from"./lunora-provider-D15UPNFD.mjs";function f(e,t,i={}){const{enabled:r=!0,pageSize:n=z}=i,[o,a]=E(n),s=_(d=>U(e,d),()=>e.currentIdentity(),()=>e.currentIdentity()),c=P(s,t,o),u=q({enabled:r,placeholderData:(d,S)=>S?.queryKey[1]===c[1]?D(d):void 0,queryFn:()=>t.fetchPage(o),queryKey:c,staleTime:0}),l=u.data?.rows,g=u.data?.total,h=M(u.data),y=()=>{h&&a(d=>d+n)},A=()=>{u.refetch().catch(()=>{})};return{data:l,error:u.error??void 0,hasMore:h,loadMore:y,loading:u.isLoading,refetch:A,total:g}}const H=e=>{const t=m(3),i=e===void 0?{}:e,r=p(),{enabled:n,pageSize:o,...a}=i;let s;return t[0]!==n||t[1]!==o?(s={enabled:n,pageSize:o},t[0]=n,t[1]=o,t[2]=s):s=t[2],f(r,L(r,a),s)},O=e=>{const t=m(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const r=i,n=p(),{enabled:o,pageSize:a}=r;let s;t[2]!==n?(s=I(n),t[2]=n,t[3]=s):s=t[3];let c;return t[4]!==o||t[5]!==a?(c={enabled:o,pageSize:a},t[4]=o,t[5]=a,t[6]=c):c=t[6],f(n,s,c)},Q=e=>{const t=m(7);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const r=i,n=p(),{enabled:o,pageSize:a}=r;let s;t[2]!==n?(s=b(n),t[2]=n,t[3]=s):s=t[3];let c;return t[4]!==o||t[5]!==a?(c={enabled:o,pageSize:a},t[4]=o,t[5]=a,t[6]=c):c=t[6],f(n,s,c)},k=e=>{const t=m(3),i=e===void 0?{}:e,r=p(),{enabled:n,pageSize:o,userId:a}=i;let s;return t[0]!==n||t[1]!==o?(s={enabled:n,pageSize:o},t[0]=n,t[1]=o,t[2]=s):s=t[2],f(r,v(r,{userId:a}),s)},G=()=>{const e=m(10),t=p();let i;e[0]!==t?(i={mutationFn:l=>t.impersonateAuthUser({userId:l})},e[0]=t,e[1]=i):i=e[1];const r=$(i),{mutateAsync:n,reset:o}=r;let a;e[2]!==n?(a=l=>n(l),e[2]=n,e[3]=a):a=e[3];const s=a,c=r.error??void 0;let u;return e[4]!==s||e[5]!==r.data||e[6]!==r.isPending||e[7]!==o||e[8]!==c?(u={data:r.data,error:c,impersonate:s,pending:r.isPending,reset:o},e[4]=s,e[5]=r.data,e[6]=r.isPending,e[7]=o,e[8]=c,e[9]=u):u=e[9],u};export{k as useAuthSessions,H as useAuthUsers,G as useImpersonate,O as useOrganizations,Q as useSignUpInvitations};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as u}from"react/compiler-runtime";import{isAuthenticatedStatus as r,isLoadingStatus as a}from"@lunora/client/auth";import n from"./useAuth-Do03WzEi.mjs";const m=()=>{const t=u(7),{status:e}=n();let s;t[0]!==e?(s=r(e),t[0]=e,t[1]=s):s=t[1];let i;t[2]!==e?(i=a(e),t[2]=e,t[3]=i):i=t[3];let o;return t[4]!==s||t[5]!==i?(o={isAuthenticated:s,isLoading:i},t[4]=s,t[5]=i,t[6]=o):o=t[6],o};export{m as useAuthState};
2
+ import{c as u}from"react/compiler-runtime";import{isAuthenticatedStatus as r,isLoadingStatus as a}from"@lunora/client/auth";import n from"./useAuth-DTiEKNfL.mjs";const m=()=>{const t=u(7),{status:e}=n();let s;t[0]!==e?(s=r(e),t[0]=e,t[1]=s):s=t[1];let i;t[2]!==e?(i=a(e),t[2]=e,t[3]=i):i=t[3];let o;return t[4]!==s||t[5]!==i?(o={isAuthenticated:s,isLoading:i},t[4]=s,t[5]=i,t[6]=o):o=t[6],o};export{m as useAuthState};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useCallback as u,useSyncExternalStore as l}from"react";import{u as c}from"./lunora-provider-CW9Gd-pp.mjs";const y=e=>{const t=c(),n=u(s=>t.subscribeClientQuery(e,()=>{s()}),[t,e.key]),r=l(n,()=>t.getClientQuery(e),()=>t.getClientQuery(e)),o=u(s=>{t.setClientQuery(e,s)},[t,e]);return[r,o]};export{y as default};
2
+ import{useCallback as u,useSyncExternalStore as l}from"react";import{u as c}from"./lunora-provider-D15UPNFD.mjs";const y=e=>{const t=c(),n=u(s=>t.subscribeClientQuery(e,()=>{s()}),[t,e.key]),r=l(n,()=>t.getClientQuery(e),()=>t.getClientQuery(e)),o=u(s=>{t.setClientQuery(e,s)},[t,e]);return[r,o]};export{y as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as r}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{u as a}from"./lunora-provider-CW9Gd-pp.mjs";const S=()=>{const t=r(4),n=a();let o,e,s;return t[0]!==n?(o=c=>n.onConnectionStatus(()=>{c()}),e=()=>n.connectionStatus(),s=()=>n.connectionStatus(),t[0]=n,t[1]=o,t[2]=e,t[3]=s):(o=t[1],e=t[2],s=t[3]),u(o,e,s)};export{S as default};
2
+ import{c as r}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{u as a}from"./lunora-provider-D15UPNFD.mjs";const S=()=>{const t=r(4),n=a();let o,e,s;return t[0]!==n?(o=c=>n.onConnectionStatus(()=>{c()}),e=()=>n.connectionStatus(),s=()=>n.connectionStatus(),t[0]=n,t[1]=o,t[2]=e,t[3]=s):(o=t[1],e=t[2],s=t[3]),u(o,e,s)};export{S as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useState as _,useRef as i,useEffect as b}from"react";import{u as d}from"./lunora-provider-CW9Gd-pp.mjs";import{stableStringify as K}from"@lunora/wire";const g="__lunora_flags__:eval",m=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:g},F=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:m(e.default)},s=>{n(s)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},S=(t,e)=>{const n=d(),[s,r]=_(e),o=m(e),u=`${t}::${o}`,f=i(u);f.current!==u&&(f.current=u,r(e));const l=i(e);return b(()=>{l.current=e}),b(()=>{let a=!1;const c=l.current;r(c);const p=F(n,{default:c,key:t},y=>{a||r(y)});return()=>{a=!0,p()}},[n,t,o]),s},h=t=>{const e=d(),[n,s]=_(t),r=K(t),o=i(r);o.current!==r&&(o.current=r,s(t));const u=i(t);return b(()=>{u.current=t}),b(()=>{let f=!1;const l=u.current;s(l);const a=[];for(const[c,p]of Object.entries(l))a.push(F(e,{default:p,key:c},y=>{f||s(R=>({...R,[c]:y}))}));return()=>{f=!0;for(const c of a)c()}},[e,r]),n};export{S as useFlag,h as useFlags};
2
+ import{useState as _,useRef as i,useEffect as b}from"react";import{u as d}from"./lunora-provider-D15UPNFD.mjs";import{stableStringify as K}from"@lunora/wire";const g="__lunora_flags__:eval",m=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:g},F=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:m(e.default)},s=>{n(s)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},S=(t,e)=>{const n=d(),[s,r]=_(e),o=m(e),u=`${t}::${o}`,f=i(u);f.current!==u&&(f.current=u,r(e));const l=i(e);return b(()=>{l.current=e}),b(()=>{let a=!1;const c=l.current;r(c);const p=F(n,{default:c,key:t},y=>{a||r(y)});return()=>{a=!0,p()}},[n,t,o]),s},h=t=>{const e=d(),[n,s]=_(t),r=K(t),o=i(r);o.current!==r&&(o.current=r,s(t));const u=i(t);return b(()=>{u.current=t}),b(()=>{let f=!1;const l=u.current;s(l);const a=[];for(const[c,p]of Object.entries(l))a.push(F(e,{default:p,key:c},y=>{f||s(R=>({...R,[c]:y}))}));return()=>{f=!0;for(const c of a)c()}},[e,r]),n};export{S as useFlag,h as useFlags};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{u as b}from"./lunora-provider-CW9Gd-pp.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{stableWireKey as H}from"@lunora/wire";const w=(t,c,n)=>{const e=S(24);let m;e[0]!==n?(m=n===void 0?{}:n,e[0]=n,e[1]=m):m=e[1];const o=m,f=b();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={chunks:[],error:void 0,status:"idle"},e[2]=a):a=e[2];const[s,i]=_(z,a),r=c==="skip";let u;e[3]!==c||e[4]!==r?(u=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=u):u=e[5];const k=u,x=v(void 0);let l;e[6]!==c||e[7]!==f||e[8]!==o.maxBuffer||e[9]!==t||e[10]!==r?(l=()=>{if(r)return i({type:"reset"}),K;i({type:"reset"}),i({type:"start"});const{cancel:B,cleanup:y}=E(f.httpStream(t,c,{maxBuffer:o.maxBuffer}),i);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=f,e[8]=o.maxBuffer,e[9]=t,e[10]=r,e[11]=l):l=e[11];let p;e[12]!==f||e[13]!==o.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[f,t.method,t.path,k,r,o.maxBuffer],e[12]=f,e[13]=o.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(l,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function K(){}export{w as useHttpStream};
2
+ import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{u as b}from"./lunora-provider-D15UPNFD.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{stableWireKey as H}from"@lunora/wire";const w=(t,c,n)=>{const e=S(24);let m;e[0]!==n?(m=n===void 0?{}:n,e[0]=n,e[1]=m):m=e[1];const o=m,f=b();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={chunks:[],error:void 0,status:"idle"},e[2]=a):a=e[2];const[s,i]=_(z,a),r=c==="skip";let u;e[3]!==c||e[4]!==r?(u=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=u):u=e[5];const k=u,x=v(void 0);let l;e[6]!==c||e[7]!==f||e[8]!==o.maxBuffer||e[9]!==t||e[10]!==r?(l=()=>{if(r)return i({type:"reset"}),K;i({type:"reset"}),i({type:"start"});const{cancel:B,cleanup:y}=E(f.httpStream(t,c,{maxBuffer:o.maxBuffer}),i);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=f,e[8]=o.maxBuffer,e[9]=t,e[10]=r,e[11]=l):l=e[11];let p;e[12]!==f||e[13]!==o.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[f,t.method,t.path,k,r,o.maxBuffer],e[12]=f,e[13]=o.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(l,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function K(){}export{w as useHttpStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-D9QnfDFs.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
2
+ import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-Ot5YZ7W3.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as D}from"react/compiler-runtime";import{liveTopicSubscription as R,subscribeLiveTopic as C}from"@lunora/client";import{stableWireKey as M}from"@lunora/wire";import{useState as W,useRef as $,useEffect as y}from"react";import{u as g}from"./lunora-provider-CW9Gd-pp.mjs";function F(b,f){const t=D(8),d=f===void 0?{}:f,o=R(g(),b,d),{headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}=o,e=M({headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}),[p,l]=W(),m=p?.key===e?p:void 0,s=$(o);let n;t[0]!==o?(n=()=>{s.current=o},t[0]=o,t[1]=n):n=t[1],y(n);let i,c;t[2]!==e?(i=()=>{const x=C({...s.current,onError:r=>{l(E=>({error:r,key:e,lastEvent:E?.key===e?E.lastEvent:void 0})),s.current.onError?.(r)},onEvent:r=>{l({error:void 0,key:e,lastEvent:r}),s.current.onEvent?.(r)}});return()=>{x(),l(void 0)}},c=[e],t[2]=e,t[3]=i,t[4]=c):(i=t[3],c=t[4]),y(i,c);const a=m?.error,v=m?.lastEvent;let u;return t[5]!==a||t[6]!==v?(u={error:a,lastEvent:v},t[5]=a,t[6]=v,t[7]=u):u=t[7],u}export{F as useLiveTopic};
2
+ import{c as D}from"react/compiler-runtime";import{liveTopicSubscription as R,subscribeLiveTopic as C}from"@lunora/client";import{stableWireKey as M}from"@lunora/wire";import{useState as W,useRef as $,useEffect as y}from"react";import{u as g}from"./lunora-provider-D15UPNFD.mjs";function F(b,f){const t=D(8),d=f===void 0?{}:f,o=R(g(),b,d),{headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}=o,e=M({headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}),[p,l]=W(),m=p?.key===e?p:void 0,s=$(o);let n;t[0]!==o?(n=()=>{s.current=o},t[0]=o,t[1]=n):n=t[1],y(n);let i,c;t[2]!==e?(i=()=>{const x=C({...s.current,onError:r=>{l(E=>({error:r,key:e,lastEvent:E?.key===e?E.lastEvent:void 0})),s.current.onError?.(r)},onEvent:r=>{l({error:void 0,key:e,lastEvent:r}),s.current.onEvent?.(r)}});return()=>{x(),l(void 0)}},c=[e],t[2]=e,t[3]=i,t[4]=c):(i=t[3],c=t[4]),y(i,c);const a=m?.error,v=m?.lastEvent;let u;return t[5]!==a||t[6]!==v?(u={error:a,lastEvent:v},t[5]=a,t[6]=v,t[7]=u):u=t[7],u}export{F as useLiveTopic};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useQueryClient as k,useMutation as v,onlineManager as g}from"@tanstack/react-query";import{useRef as A,useState as P,useCallback as O}from"react";import{u as Q}from"./lunora-provider-CW9Gd-pp.mjs";const R=async()=>new Promise(n=>{if(g.isOnline()){n();return}const r=g.subscribe(u=>{u&&(r(),n())})}),x=n=>{const r=Q(),u=k(),a=n.sensitive===!0,c=A(0),[l,p]=P(!1),b=v({mutationFn:async({args:e,options:t})=>(!(a||t?.onlineOnly===!0)&&!r.canQueueOffline(t?.shardKey)&&await R(),r.mutation(n,e,t)),networkMode:"always",...a?{gcTime:0}:{},retry:0,onMutate:()=>{c.current+=1,p(!0)},onSettled:(e,t,o)=>{if(c.current-=1,p(c.current>0),a||o.options?.onlineOnly===!0){const i=u.getMutationCache();for(const h of i.findAll({predicate:C=>C.state.variables===o}))i.remove(h)}}}),{data:m,error:d,isError:f,mutateAsync:s,reset:y}=b,w=O((e,t)=>s({args:e,options:t}),[s]),M=O(e=>({data:m,error:d,isError:f,mutate:(o,i)=>s({args:o,options:{optimisticUpdate:e,...i}}),pending:l,reset:y,withOptimisticUpdate:M}),[s,m,d,f,l,y]);return{data:m,error:d,isError:f,mutate:w,pending:l,reset:y,withOptimisticUpdate:M}};export{x as useMutation};
2
+ import{useQueryClient as k,useMutation as v,onlineManager as g}from"@tanstack/react-query";import{useRef as A,useState as P,useCallback as O}from"react";import{u as Q}from"./lunora-provider-D15UPNFD.mjs";const R=async()=>new Promise(n=>{if(g.isOnline()){n();return}const r=g.subscribe(u=>{u&&(r(),n())})}),x=n=>{const r=Q(),u=k(),a=n.sensitive===!0,c=A(0),[l,p]=P(!1),b=v({mutationFn:async({args:e,options:t})=>(!(a||t?.onlineOnly===!0)&&!r.canQueueOffline(t?.shardKey)&&await R(),r.mutation(n,e,t)),networkMode:"always",...a?{gcTime:0}:{},retry:0,onMutate:()=>{c.current+=1,p(!0)},onSettled:(e,t,o)=>{if(c.current-=1,p(c.current>0),a||o.options?.onlineOnly===!0){const i=u.getMutationCache();for(const h of i.findAll({predicate:C=>C.state.variables===o}))i.remove(h)}}}),{data:m,error:d,isError:f,mutateAsync:s,reset:y}=b,w=O((e,t)=>s({args:e,options:t}),[s]),M=O(e=>({data:m,error:d,isError:f,mutate:(o,i)=>s({args:o,options:{optimisticUpdate:e,...i}}),pending:l,reset:y,withOptimisticUpdate:M}),[s,m,d,f,l,y]);return{data:m,error:d,isError:f,mutate:w,pending:l,reset:y,withOptimisticUpdate:M}};export{x as useMutation};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-D9QnfDFs.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
2
+ import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-Ot5YZ7W3.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useMemo as _,useState as w,useRef as l,useEffect as u,useCallback as E}from"react";import{u as D}from"./lunora-provider-CW9Gd-pp.mjs";const V=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},C=1e4,P=(e,r)=>{const t=D(),{heartbeat:g,intervalMs:y=C,listPresent:m,shardKey:s}=r;V(y);const o=_(()=>r.sessionId??A(),[r.sessionId]),d=JSON.stringify([m.__lunoraRef,e,s??""]),[b,p]=w(),h=b?.client===t&&b.key===d?b:void 0,R=l(r.onError);u(()=>{R.current=r.onError});const v=l(r.data),I=l(!1),S=l({client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s});u(()=>{S.current={client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s}});const i=E(()=>{const{client:n,heartbeat:c,roomId:a,sessionId:f,shardKey:k}=S.current,L={roomId:a,sessionId:f,...v.current===void 0?{}:{data:v.current}};n.mutation(c,L,{shardKey:k}).catch(()=>{})},[]),U=E(n=>{v.current=n,I.current&&i()},[i]);return u(()=>(I.current=!0,()=>{I.current=!1}),[]),u(()=>{i();const n=setInterval(i,y),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};return typeof document<"u"&&document.addEventListener("visibilitychange",c),()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c)}},[i,y,t,e,o,s]),u(()=>t.acquireConnectionContext({roomId:e,sessionId:o},{shardKey:s}),[t,e,o,s]),u(()=>{let n=!1;const c=t.subscribe(m,{roomId:e},a=>{n||p({client:t,error:void 0,key:d,present:a})},{onError:a=>{n||p(f=>({client:t,error:a,key:d,present:f?.client===t&&f.key===d?f.present:void 0})),R.current?.(a)},shardKey:s});return()=>{n=!0,c(),p(void 0)}},[t,m.__lunoraRef,e,d,s]),{error:h?.error,present:h?.present,sessionId:o,setData:U}};export{P as usePresence};
2
+ import{useMemo as _,useState as w,useRef as l,useEffect as u,useCallback as E}from"react";import{u as D}from"./lunora-provider-D15UPNFD.mjs";const V=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},A=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},C=1e4,P=(e,r)=>{const t=D(),{heartbeat:g,intervalMs:y=C,listPresent:m,shardKey:s}=r;V(y);const o=_(()=>r.sessionId??A(),[r.sessionId]),d=JSON.stringify([m.__lunoraRef,e,s??""]),[b,p]=w(),h=b?.client===t&&b.key===d?b:void 0,R=l(r.onError);u(()=>{R.current=r.onError});const v=l(r.data),I=l(!1),S=l({client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s});u(()=>{S.current={client:t,heartbeat:g,roomId:e,sessionId:o,shardKey:s}});const i=E(()=>{const{client:n,heartbeat:c,roomId:a,sessionId:f,shardKey:k}=S.current,L={roomId:a,sessionId:f,...v.current===void 0?{}:{data:v.current}};n.mutation(c,L,{shardKey:k}).catch(()=>{})},[]),U=E(n=>{v.current=n,I.current&&i()},[i]);return u(()=>(I.current=!0,()=>{I.current=!1}),[]),u(()=>{i();const n=setInterval(i,y),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};return typeof document<"u"&&document.addEventListener("visibilitychange",c),()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c)}},[i,y,t,e,o,s]),u(()=>t.acquireConnectionContext({roomId:e,sessionId:o},{shardKey:s}),[t,e,o,s]),u(()=>{let n=!1;const c=t.subscribe(m,{roomId:e},a=>{n||p({client:t,error:void 0,key:d,present:a})},{onError:a=>{n||p(f=>({client:t,error:a,key:d,present:f?.client===t&&f.key===d?f.present:void 0})),R.current?.(a)},shardKey:s});return()=>{n=!0,c(),p(void 0)}},[t,m.__lunoraRef,e,d,s]),{error:h?.error,present:h?.present,sessionId:o,setData:U}};export{P as usePresence};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as k}from"react/compiler-runtime";import{useQueryClient as q,useQuery as E}from"@tanstack/react-query";import{useState as F,useEffect as N}from"react";import{u as T,g as V}from"./lunora-provider-D15UPNFD.mjs";import{u as A}from"./query-core-DG86Lpnw.mjs";import{stableWireKey as C}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as D}from"@lunora/client/query";const P=(s,K,R)=>{const e=k(26),v=R===void 0?{}:R,t=T(),y=q(),{onError:Q,shardKey:r}=v,u=K==="skip",o=u?{}:K,l=C(o),a=D(s.__lunoraRef,l,r),[n,b]=F(t.isReady);let d,c;e[0]!==t||e[1]!==n?(d=()=>{n||t.whenReady().then(()=>{b(!0)})},c=[t,n],e[0]=t,e[1]=n,e[2]=d,e[3]=c):(d=e[2],c=e[3]),N(d,c);let m;if(!u){const h=t.peekHydratedQueryByKey(s.__lunoraRef,l,r);m=h===void 0?t.peekActiveQuerySnapshot(s.__lunoraRef,o,r).value:h}const g=!u&&n;let i;e[4]!==o||e[5]!==t||e[6]!==s||e[7]!==y||e[8]!==a||e[9]!==r?(i=async h=>{const{signal:S}=h;return V(t).liveValue(y,a,S,{fetch:async()=>t.query(s,o,{shardKey:r}),shardKey:r})},e[4]=o,e[5]=t,e[6]=s,e[7]=y,e[8]=a,e[9]=r,e[10]=i):i=e[10];let p;e[11]!==m||e[12]!==a||e[13]!==g||e[14]!==i?(p={enabled:g,initialData:m,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[11]=m,e[12]=a,e[13]=g,e[14]=i,e[15]=p):p=e[15];const{data:I}=E(p);let f;return e[16]!==l||e[17]!==o||e[18]!==t||e[19]!==s||e[20]!==Q||e[21]!==y||e[22]!==a||e[23]!==r||e[24]!==u?(f={args:o,argsKey:l,client:t,function_:s,onError:Q,queryClient:y,queryKey:a,shardKey:r,skipped:u},e[16]=l,e[17]=o,e[18]=t,e[19]=s,e[20]=Q,e[21]=y,e[22]=a,e[23]=r,e[24]=u,e[25]=f):f=e[25],A(f),u?void 0:I};export{P as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{u as v}from"./lunora-provider-CW9Gd-pp.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{stableWireKey as E}from"@lunora/wire";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
2
+ import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{u as v}from"./lunora-provider-D15UPNFD.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{stableWireKey as E}from"@lunora/wire";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{c as O}from"react/compiler-runtime";import{createQuerySubscription as j}from"@lunora/client/query";import{LunoraError as L}from"@lunora/errors";import{useState as M,useRef as R,useEffect as E}from"react";import{u as q}from"./lunora-provider-CW9Gd-pp.mjs";import{stableWireKey as x}from"@lunora/wire";const A=Object.freeze({data:void 0,error:void 0}),W=(t,n,b)=>{const e=O(20),r=b===void 0?{}:b,o=q(),a=n==="skip",c=a?"skip":x(n),i=JSON.stringify([t.__lunoraRef,c,r.shardKey??""]),[y,p]=M(void 0),v=R(r.onError);let u;e[0]!==r.onError?(u=()=>{v.current=r.onError},e[0]=r.onError,e[1]=u):u=e[1],E(u);let d;e[2]!==n||e[3]!==t?(d={args:n,fn:t},e[2]=n,e[3]=t,e[4]=d):d=e[4];const K=R(d);let l;e[5]!==n||e[6]!==t?(l=()=>{K.current={args:n,fn:t}},e[5]=n,e[6]=t,e[7]=l):l=e[7],E(l);let f;e[8]!==o||e[9]!==i||e[10]!==r.shardKey||e[11]!==a?(f=()=>{if(a)return D;let h=!1;const{args:k,fn:w}=K.current,S=j(o,w,k,{onData:s=>{h||p({client:o,key:i,result:{data:s,error:void 0}})},onError:s=>{const z=Object.assign(s.code===void 0?new Error(s.message):new L(s.code,s.message),s.why===void 0?{}:{why:s.why});v.current?.(s),queueMicrotask(()=>{h||p({client:o,key:i,result:{data:void 0,error:z}})})}},{shardKey:r.shardKey});return()=>{h=!0,S(),p(void 0)}},e[8]=o,e[9]=i,e[10]=r.shardKey,e[11]=a,e[12]=f):f=e[12];let m;return e[13]!==o||e[14]!==t.__lunoraRef||e[15]!==i||e[16]!==r.shardKey||e[17]!==c||e[18]!==a?(m=[o,t.__lunoraRef,i,c,r.shardKey,a],e[13]=o,e[14]=t.__lunoraRef,e[15]=i,e[16]=r.shardKey,e[17]=c,e[18]=a,e[19]=m):m=e[19],E(f,m),y?.client===o&&y.key===i?y.result:A};function D(){}export{W as default};
2
+ import{c as O}from"react/compiler-runtime";import{createQuerySubscription as j}from"@lunora/client/query";import{LunoraError as L}from"@lunora/errors";import{useState as M,useRef as R,useEffect as E}from"react";import{u as q}from"./lunora-provider-D15UPNFD.mjs";import{stableWireKey as x}from"@lunora/wire";const A=Object.freeze({data:void 0,error:void 0}),W=(t,n,b)=>{const e=O(20),r=b===void 0?{}:b,o=q(),a=n==="skip",c=a?"skip":x(n),i=JSON.stringify([t.__lunoraRef,c,r.shardKey??""]),[y,p]=M(void 0),v=R(r.onError);let u;e[0]!==r.onError?(u=()=>{v.current=r.onError},e[0]=r.onError,e[1]=u):u=e[1],E(u);let d;e[2]!==n||e[3]!==t?(d={args:n,fn:t},e[2]=n,e[3]=t,e[4]=d):d=e[4];const K=R(d);let l;e[5]!==n||e[6]!==t?(l=()=>{K.current={args:n,fn:t}},e[5]=n,e[6]=t,e[7]=l):l=e[7],E(l);let f;e[8]!==o||e[9]!==i||e[10]!==r.shardKey||e[11]!==a?(f=()=>{if(a)return D;let h=!1;const{args:k,fn:w}=K.current,S=j(o,w,k,{onData:s=>{h||p({client:o,key:i,result:{data:s,error:void 0}})},onError:s=>{const z=Object.assign(s.code===void 0?new Error(s.message):new L(s.code,s.message),s.why===void 0?{}:{why:s.why});v.current?.(s),queueMicrotask(()=>{h||p({client:o,key:i,result:{data:void 0,error:z}})})}},{shardKey:r.shardKey});return()=>{h=!0,S(),p(void 0)}},e[8]=o,e[9]=i,e[10]=r.shardKey,e[11]=a,e[12]=f):f=e[12];let m;return e[13]!==o||e[14]!==t.__lunoraRef||e[15]!==i||e[16]!==r.shardKey||e[17]!==c||e[18]!==a?(m=[o,t.__lunoraRef,i,c,r.shardKey,a],e[13]=o,e[14]=t.__lunoraRef,e[15]=i,e[16]=r.shardKey,e[17]=c,e[18]=a,e[19]=m):m=e[19],E(f,m),y?.client===o&&y.key===i?y.result:A};function D(){}export{W as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as h}from"react/compiler-runtime";import{useQueryClient as R,useSuspenseQuery as S}from"@tanstack/react-query";import{u as I,g as b}from"./lunora-provider-D15UPNFD.mjs";import{u as q}from"./query-core-DG86Lpnw.mjs";import{stableWireKey as F}from"@lunora/wire";import{lunoraQueryKeyFromArgsKey as k}from"@lunora/client/query";const E=(s,m,c)=>{const e=h(21),f=c===void 0?{}:c,r=I(),u=R(),{onError:d,shardKey:t}=f,y=m,o=F(y),a=k(s.__lunoraRef,o,t),p=r.isReady?r.peekHydratedQueryByKey(s.__lunoraRef,o,t):void 0;let i;e[0]!==o||e[1]!==y||e[2]!==r||e[3]!==s||e[4]!==u||e[5]!==a||e[6]!==t?(i=async K=>{const{signal:Q}=K;return await r.whenReady(),r.peekHydratedQueryByKey(s.__lunoraRef,o,t)??b(r).liveValue(u,a,Q,{fetch:async()=>r.query(s,y,{shardKey:t}),waitForPush:!1})},e[0]=o,e[1]=y,e[2]=r,e[3]=s,e[4]=u,e[5]=a,e[6]=t,e[7]=i):i=e[7];let l;e[8]!==p||e[9]!==a||e[10]!==i?(l={initialData:p,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[8]=p,e[9]=a,e[10]=i,e[11]=l):l=e[11];const{data:g}=S(l);let n;return e[12]!==o||e[13]!==y||e[14]!==r||e[15]!==s||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==t?(n={args:y,argsKey:o,client:r,function_:s,onError:d,queryClient:u,queryKey:a,shardKey:t,skipped:!1},e[12]=o,e[13]=y,e[14]=r,e[15]=s,e[16]=d,e[17]=u,e[18]=a,e[19]=t,e[20]=n):n=e[20],q(n),g};export{E as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{u as X}from"./lunora-provider-CW9Gd-pp.mjs";const N="/_lunora/ws",j="/_lunora/voice/",z=4001,O=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return O(e);if(r.endsWith(N))return r.slice(0,-N.length);try{return new URL(r).origin}catch{return O(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,c=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${c.toString()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(e,r,s)=>{const c=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==c&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},se=(e,r)=>{const s=r/ne,c=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(c*2),l=new DataView(d);for(let u=0;u<c;u+=1){const g=e[Math.floor(u*s)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},oe=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),c=r.AudioContext??r.webkitAudioContext;if(!s||!c)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new c,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=o=>{const f=o.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(se(f,l.sampleRate)),e.isTurnActive()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,a=0;return}w&&(a+=x,a>=e.silenceDurationMs&&(w=!1,a=0,e.onSilence()))},u.connect(g),g.connect(l.destination),{setMuted:o=>{p=o},stop:()=>{g.disconnect(),u.disconnect();for(const o of d.getTracks())o.stop();l.close()}}},ie=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,c=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let o;try{o=await s.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=s.createBufferSource();f.buffer=o,f.connect(s.destination);const m=Math.max(s.currentTime,d);f.start(m),d=m+o.duration,c.add(f),f.onended=()=>{c.delete(f)}},p=a=>{const h=Uint8Array.from(a),o=u;l=l.then(()=>g(h,o))},w=()=>{u+=1;for(const a of c)try{a.stop()}catch{}c.clear(),d=s.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),s.close()}}},P=1,ce=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=oe,createSpeaker:s=ie,createSocket:c,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ce,threadKey:p,voice:w}=e,a=X(),[h,o]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,v]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),i=W(void 0),_=W(!1),C=y(n=>{const t=i.current?.socket;return t?.readyState===P?(t.send(JSON.stringify(n)),!0):!1},[]),A=y(()=>{const n=i.current;if(i.current=void 0,n){n.unwatchIdentity?.(),n.microphone?.stop(),n.speaker?.stop(),n.socket.onmessage=null,n.socket.onerror=null,n.socket.onclose=null;try{n.socket.close()}catch{}}_.current=!1,m(!1),o("idle"),R(0)},[]),L=y(n=>{const t=i.current;switch(n.type){case"assistant_delta":{t&&(t.speaking=!0),o("speaking"),v(F=>F+n.text);break}case"assistant_discarded":{t&&(t.suppressAudio=!0),t?.speaker?.interrupt(),v("");break}case"assistant_done":{t&&(t.awaitingTurn=!1,t.speaking=!1),v(n.text),o("listening");break}case"error":{t&&(t.awaitingTurn=!1,t.speaking=!1),E(new Error(n.message)),o("listening");break}case"interrupted":{t&&(t.awaitingTurn=!1,t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),o("listening");break}case"ready":{t&&(t.audioFormat=n.audioFormat,t.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),M(n.text),v(""),o("thinking");break}}},[]),D=y(n=>{const t=i.current;!t||t.suppressAudio||(t.speaker??=s({audioFormat:t.audioFormat}),t.speaking=!0,o("speaking"),t.speaker.enqueue(n))},[s]),q=y(async()=>{if(i.current||_.current)return;_.current=!0,E(void 0),M(""),v("");let n;try{const t=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(c??(k=>{const b=a.getWebSocketImpl();if(!b)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new b(k)}))(t);S.binaryType="arraybuffer",n={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},i.current=n,n.unwatchIdentity=te(a,"useVoiceAgent",k=>{i.current===n&&(E(k),A())}),S.onmessage=k=>{if(typeof k.data=="string"){try{L(JSON.parse(k.data))}catch{}return}D(new Uint8Array(k.data))},S.onerror=()=>{E(new Error("useVoiceAgent: voice socket error"))},S.onclose=k=>{if(i.current!==n)return;const b=ee("useVoiceAgent",k);b&&E(b),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(i.current?.speaking??!1)||(i.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{C({type:"interrupt"}),i.current?.speaker?.interrupt(),i.current&&(i.current.awaitingTurn=!1,i.current.speaking=!1,i.current.suppressAudio=!0),o("listening")},onLevel:R,onSilence:()=>{C({type:"commit"}),i.current&&(i.current.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:g});i.current===n?(n.microphone=V,U(!1),n.speaking||o("listening")):V.stop()}catch(t){i.current===n&&(E(t instanceof Error?t:new Error(String(t))),A())}finally{_.current=!1}},[a,r,c,D,L,d,l,C,u,g,A,p,w]),K=y(()=>{const n=!I;return i.current?.microphone?.setMuted(n),U(n),n},[I]),J=y(n=>{C({text:n,type:"text"})&&(i.current&&(i.current.awaitingTurn=!0),o("thinking"))},[C]);return G(()=>A,[A]),{audioLevel:$,connected:f,endCall:A,error:B,interimTranscript:H,isMuted:I,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{he as useVoiceAgent};
2
+ import{useState as T,useRef as W,useCallback as y,useEffect as G}from"react";import{u as X}from"./lunora-provider-D15UPNFD.mjs";const N="/_lunora/ws",j="/_lunora/voice/",z=4001,O=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return O(e);if(r.endsWith(N))return r.slice(0,-N.length);try{return new URL(r).origin}catch{return O(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,c=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${c.toString()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(e,r,s)=>{const c=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==c&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},se=(e,r)=>{const s=r/ne,c=s>1?Math.floor(e.length/s):e.length,d=new ArrayBuffer(c*2),l=new DataView(d);for(let u=0;u<c;u+=1){const g=e[Math.floor(u*s)]??0,p=Math.max(-1,Math.min(1,g));l.setInt16(u*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(d)},oe=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),c=r.AudioContext??r.webkitAudioContext;if(!s||!c)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new c,u=l.createMediaStreamSource(d),g=l.createScriptProcessor(4096,1,1);let p=!1,w=!1,a=0,h=0;return g.onaudioprocess=o=>{const f=o.inputBuffer.getChannelData(0),m=p?0:re(f);if(e.onLevel(m),p)return;if(e.onAudio(se(f,l.sampleRate)),e.isTurnActive()){h=m>=e.interruptThreshold?h+1:0,h>=e.interruptChunks&&(h=0,e.onInterrupt());return}h=0;const x=f.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,a=0;return}w&&(a+=x,a>=e.silenceDurationMs&&(w=!1,a=0,e.onSilence()))},u.connect(g),g.connect(l.destination),{setMuted:o=>{p=o},stop:()=>{g.disconnect(),u.disconnect();for(const o of d.getTracks())o.stop();l.close()}}},ie=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,c=new Set;let d=0,l=Promise.resolve(),u=0;const g=async(a,h)=>{if(h!==u)return;let o;try{o=await s.decodeAudioData(a.buffer)}catch{return}if(h!==u)return;const f=s.createBufferSource();f.buffer=o,f.connect(s.destination);const m=Math.max(s.currentTime,d);f.start(m),d=m+o.duration,c.add(f),f.onended=()=>{c.delete(f)}},p=a=>{const h=Uint8Array.from(a),o=u;l=l.then(()=>g(h,o))},w=()=>{u+=1;for(const a of c)try{a.stop()}catch{}c.clear(),d=s.currentTime};return{enqueue:p,interrupt:w,stop:()=>{w(),s.close()}}},P=1,ce=.01,ae=1200,ue=.15,le=3,he=e=>{const{createMicrophone:r=oe,createSpeaker:s=ie,createSocket:c,interruptChunks:d=le,interruptThreshold:l=ue,silenceDurationMs:u=ae,silenceThreshold:g=ce,threadKey:p,voice:w}=e,a=X(),[h,o]=T("idle"),[f,m]=T(!1),[x,M]=T(""),[H,v]=T(""),[$,R]=T(0),[I,U]=T(!1),[B,E]=T(void 0),i=W(void 0),_=W(!1),C=y(n=>{const t=i.current?.socket;return t?.readyState===P?(t.send(JSON.stringify(n)),!0):!1},[]),A=y(()=>{const n=i.current;if(i.current=void 0,n){n.unwatchIdentity?.(),n.microphone?.stop(),n.speaker?.stop(),n.socket.onmessage=null,n.socket.onerror=null,n.socket.onclose=null;try{n.socket.close()}catch{}}_.current=!1,m(!1),o("idle"),R(0)},[]),L=y(n=>{const t=i.current;switch(n.type){case"assistant_delta":{t&&(t.speaking=!0),o("speaking"),v(F=>F+n.text);break}case"assistant_discarded":{t&&(t.suppressAudio=!0),t?.speaker?.interrupt(),v("");break}case"assistant_done":{t&&(t.awaitingTurn=!1,t.speaking=!1),v(n.text),o("listening");break}case"error":{t&&(t.awaitingTurn=!1,t.speaking=!1),E(new Error(n.message)),o("listening");break}case"interrupted":{t&&(t.awaitingTurn=!1,t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),o("listening");break}case"ready":{t&&(t.audioFormat=n.audioFormat,t.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),M(n.text),v(""),o("thinking");break}}},[]),D=y(n=>{const t=i.current;!t||t.suppressAudio||(t.speaker??=s({audioFormat:t.audioFormat}),t.speaking=!0,o("speaking"),t.speaker.enqueue(n))},[s]),q=y(async()=>{if(i.current||_.current)return;_.current=!0,E(void 0),M(""),v("");let n;try{const t=Z({agent:Q(w.__lunoraRef),httpUrl:a.url,threadKey:p,wsUrl:a.wsUrl}),S=(c??(k=>{const b=a.getWebSocketImpl();if(!b)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new b(k)}))(t);S.binaryType="arraybuffer",n={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},i.current=n,n.unwatchIdentity=te(a,"useVoiceAgent",k=>{i.current===n&&(E(k),A())}),S.onmessage=k=>{if(typeof k.data=="string"){try{L(JSON.parse(k.data))}catch{}return}D(new Uint8Array(k.data))},S.onerror=()=>{E(new Error("useVoiceAgent: voice socket error"))},S.onclose=k=>{if(i.current!==n)return;const b=ee("useVoiceAgent",k);b&&E(b),A()};const V=await r({interruptChunks:d,interruptThreshold:l,isTurnActive:()=>(i.current?.speaking??!1)||(i.current?.awaitingTurn??!1),onAudio:k=>{S.readyState===P&&S.send(k)},onInterrupt:()=>{C({type:"interrupt"}),i.current?.speaker?.interrupt(),i.current&&(i.current.awaitingTurn=!1,i.current.speaking=!1,i.current.suppressAudio=!0),o("listening")},onLevel:R,onSilence:()=>{C({type:"commit"}),i.current&&(i.current.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:g});i.current===n?(n.microphone=V,U(!1),n.speaking||o("listening")):V.stop()}catch(t){i.current===n&&(E(t instanceof Error?t:new Error(String(t))),A())}finally{_.current=!1}},[a,r,c,D,L,d,l,C,u,g,A,p,w]),K=y(()=>{const n=!I;return i.current?.microphone?.setMuted(n),U(n),n},[I]),J=y(n=>{C({text:n,type:"text"})&&(i.current&&(i.current.awaitingTurn=!0),o("thinking"))},[C]);return G(()=>A,[A]),{audioLevel:$,connected:f,endCall:A,error:B,interimTranscript:H,isMuted:I,sendText:J,startCall:q,status:h,toggleMute:K,transcript:x}};export{he as useVoiceAgent};
package/dist/server.d.mts CHANGED
@@ -1,9 +1,4 @@
1
1
  import { FunctionReference, ArgsOf, ReturnOf, LunoraClient } from '@lunora/client';
2
- export { type ArgsOf, type FunctionReference, type Preloaded, type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
3
- import { ServerClientOptions } from '@lunora/client/ssr';
4
- export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
5
- import { QueryClient } from '@tanstack/react-query';
6
- export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
7
2
  export {
8
3
  /**
9
4
  * Server-side data-loading helpers for React Server Components.
@@ -22,7 +17,66 @@ export {
22
17
  * serializable `Preloaded` value you hand to a client component that calls
23
18
  * `usePreloadedQuery`.
24
19
  */
25
- type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
20
+ type ArgsOf,
21
+ /**
22
+ * Server-side data-loading helpers for React Server Components.
23
+ *
24
+ * This module is the server half of `@lunora/react`: it carries no
25
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
26
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
27
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
28
+ * `@lunora/react`, which is a client boundary.
29
+ *
30
+ * Two flows are supported, mirroring the two common RSC patterns. First,
31
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
32
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
33
+ * the client renders with data on the first paint and a live WS subscription
34
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
35
+ * serializable `Preloaded` value you hand to a client component that calls
36
+ * `usePreloadedQuery`.
37
+ */
38
+ type FunctionReference,
39
+ /**
40
+ * Server-side data-loading helpers for React Server Components.
41
+ *
42
+ * This module is the server half of `@lunora/react`: it carries no
43
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
44
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
45
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
46
+ * `@lunora/react`, which is a client boundary.
47
+ *
48
+ * Two flows are supported, mirroring the two common RSC patterns. First,
49
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
50
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
51
+ * the client renders with data on the first paint and a live WS subscription
52
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
53
+ * serializable `Preloaded` value you hand to a client component that calls
54
+ * `usePreloadedQuery`.
55
+ */
56
+ type Preloaded,
57
+ /**
58
+ * Server-side data-loading helpers for React Server Components.
59
+ *
60
+ * This module is the server half of `@lunora/react`: it carries no
61
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
62
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
63
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
64
+ * `@lunora/react`, which is a client boundary.
65
+ *
66
+ * Two flows are supported, mirroring the two common RSC patterns. First,
67
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
68
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
69
+ * the client renders with data on the first paint and a live WS subscription
70
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
71
+ * serializable `Preloaded` value you hand to a client component that calls
72
+ * `usePreloadedQuery`.
73
+ */
74
+ type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
75
+ import { ServerClientOptions } from '@lunora/client/ssr';
76
+ export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
77
+ import { QueryClient } from '@tanstack/react-query';
78
+ export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
79
+ export { type LunoraQueryOptions, lunoraQueryOptions } from '@lunora/client/query';
26
80
  /**
27
81
  * Run a query on the server and seed `queryClient` with the result under the
28
82
  * same key the client hooks use (see `lunoraQueryKey`), so a later
package/dist/server.d.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  import { FunctionReference, ArgsOf, ReturnOf, LunoraClient } from '@lunora/client';
2
- export { type ArgsOf, type FunctionReference, type Preloaded, type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
3
- import { ServerClientOptions } from '@lunora/client/ssr';
4
- export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
5
- import { QueryClient } from '@tanstack/react-query';
6
- export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
7
2
  export {
8
3
  /**
9
4
  * Server-side data-loading helpers for React Server Components.
@@ -22,7 +17,66 @@ export {
22
17
  * serializable `Preloaded` value you hand to a client component that calls
23
18
  * `usePreloadedQuery`.
24
19
  */
25
- type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
20
+ type ArgsOf,
21
+ /**
22
+ * Server-side data-loading helpers for React Server Components.
23
+ *
24
+ * This module is the server half of `@lunora/react`: it carries no
25
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
26
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
27
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
28
+ * `@lunora/react`, which is a client boundary.
29
+ *
30
+ * Two flows are supported, mirroring the two common RSC patterns. First,
31
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
32
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
33
+ * the client renders with data on the first paint and a live WS subscription
34
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
35
+ * serializable `Preloaded` value you hand to a client component that calls
36
+ * `usePreloadedQuery`.
37
+ */
38
+ type FunctionReference,
39
+ /**
40
+ * Server-side data-loading helpers for React Server Components.
41
+ *
42
+ * This module is the server half of `@lunora/react`: it carries no
43
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
44
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
45
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
46
+ * `@lunora/react`, which is a client boundary.
47
+ *
48
+ * Two flows are supported, mirroring the two common RSC patterns. First,
49
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
50
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
51
+ * the client renders with data on the first paint and a live WS subscription
52
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
53
+ * serializable `Preloaded` value you hand to a client component that calls
54
+ * `usePreloadedQuery`.
55
+ */
56
+ type Preloaded,
57
+ /**
58
+ * Server-side data-loading helpers for React Server Components.
59
+ *
60
+ * This module is the server half of `@lunora/react`: it carries no
61
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
62
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
63
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
64
+ * `@lunora/react`, which is a client boundary.
65
+ *
66
+ * Two flows are supported, mirroring the two common RSC patterns. First,
67
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
68
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
69
+ * the client renders with data on the first paint and a live WS subscription
70
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
71
+ * serializable `Preloaded` value you hand to a client component that calls
72
+ * `usePreloadedQuery`.
73
+ */
74
+ type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
75
+ import { ServerClientOptions } from '@lunora/client/ssr';
76
+ export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
77
+ import { QueryClient } from '@tanstack/react-query';
78
+ export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
79
+ export { type LunoraQueryOptions, lunoraQueryOptions } from '@lunora/client/query';
26
80
  /**
27
81
  * Run a query on the server and seed `queryClient` with the result under the
28
82
  * same key the client hooks use (see `lunoraQueryKey`), so a later
package/dist/server.mjs CHANGED
@@ -1 +1 @@
1
- import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{l as d}from"./packem_shared/query-key-BysXrewF.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-IJB_aFzi.mjs";import{preloadQuery as v,preloadedQueryResult as N}from"@lunora/client";import{HydrationBoundary as T,dehydrate as g}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const s=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,s,{shardKey:y.shardKey}),queryKey:d(e,s,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},h=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),i=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),l=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,K as createServerClient,g as dehydrate,f as deserializePreloaded,l as fetchAction,i as fetchMutation,h as fetchQuery,Q as getServerSession,S as lunoraQueryOptions,u as prefetchQuery,v as preloadQuery,N as preloadedQueryResult,x as serializePreloaded};
1
+ import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{preloadQuery as S,preloadedQueryResult as q}from"@lunora/client";import{lunoraQueryKey as d}from"@lunora/client/query";import{lunoraQueryOptions as N}from"@lunora/client/query";import{HydrationBoundary as T,dehydrate as g}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const s=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,s,{shardKey:y.shardKey}),queryKey:d(e,s,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},h=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),i=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),l=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,K as createServerClient,g as dehydrate,f as deserializePreloaded,l as fetchAction,i as fetchMutation,h as fetchQuery,Q as getServerSession,N as lunoraQueryOptions,u as prefetchQuery,S as preloadQuery,q as preloadedQueryResult,x as serializePreloaded};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.265",
3
+ "version": "1.0.0-alpha.267",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -57,9 +57,9 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@lunora/client": "1.0.0-alpha.252",
60
+ "@lunora/client": "1.0.0-alpha.254",
61
61
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
62
- "@lunora/ratelimit": "1.0.0-alpha.171",
62
+ "@lunora/ratelimit": "1.0.0-alpha.173",
63
63
  "@lunora/wire": "1.0.0-alpha.2",
64
64
  "@visulima/storage-client": "1.0.9"
65
65
  },
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as K}from"react/compiler-runtime";import{useQueryClient as P,useQuery as N}from"@tanstack/react-query";import{useRef as T,useEffect as I,useSyncExternalStore as w,useState as x}from"react";import{u as F,g as L,a as O}from"./lunora-provider-CW9Gd-pp.mjs";import{l as V,s as z}from"./query-key-BysXrewF.mjs";const D=function(o,r){const e=K(11);let s;e[0]!==r?(s=r===void 0?{}:r,e[0]=r,e[1]=s):s=e[1];const i=s,t=F(),n=P(),S=T(i.onError);let c;e[2]!==i.onError?(c=()=>{S.current=i.onError},e[2]=i.onError,e[3]=c):c=e[3],I(c);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=h=>{S.current?.(h)},e[4]=u):u=e[4];const b=u,m=L(t);let a;e[5]!==t?(a=()=>t.identityEpoch(),e[5]=t,e[6]=a):a=e[6];const _=w(m.subscribeIdentityEpoch,a,Y),[Q]=x(t),R=O(),{args:p,functionPath:q,shardKey:l}=o,g=_===0&&!R&&t===Q?o.value:void 0,d={__lunoraRef:q},f=V(d,p,l),{data:v}=N({initialData:g,queryFn:async h=>{const{signal:C}=h;return m.liveValue(n,f,C,{fetch:async()=>t.query(d,p,{shardKey:l}),shardKey:l})},queryKey:f,staleTime:Number.POSITIVE_INFINITY}),E=z(f);let y;return e[7]!==t||e[8]!==n||e[9]!==E?(y=[t,n,E,b],e[7]=t,e[8]=n,e[9]=E,e[10]=y):y=e[10],I(()=>m.attach(n,f,d,p,l,{onError:b}),y),v===void 0?g:v},G=function(o,r={}){return D(o,r)};function Y(){return 0}export{D as default,G as hydratePreloaded};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as W}from"react/compiler-runtime";import{LunoraError as D}from"@lunora/errors";import{QueryClientContext as M,QueryClientProvider as A,QueryClient as N}from"@tanstack/react-query";import{use as Q,useState as S,useEffect as T,useRef as R,createContext as x}from"react";import{k as b}from"./query-key-BysXrewF.mjs";import{jsx as m}from"react/jsx-runtime";const E=n=>{n!==void 0&&(n.cancel({silent:!0}),n.setState({...n.state,data:void 0,dataUpdatedAt:0,error:null,fetchStatus:"idle",status:"pending"}))},I={status:"idle"},F=(n,e)=>{for(const s of n.waiters)s(e);n.waiters.clear()},_=1e4,z=async(n,e,s)=>new Promise((i,d)=>{if(e.aborted){d(e.reason);return}let u,h;const l=()=>{clearTimeout(u),h?.(),n.waiters.delete(r),e.removeEventListener("abort",t)},t=()=>{l(),d(e.reason)},r=c=>{l(),i(c)};u=setTimeout(()=>{r(!1)},_),n.waiters.add(r),e.addEventListener("abort",t,{once:!0}),h=s(()=>{r(!1)}),n.waiters.has(r)||h()});class U{constructor(e){this.client=e}client;entries=new Map;live=new Map;identityWatched=new Set;listening=!1;hasConsumers(e){return this.entries.has(b(e))}async liveValue(e,s,i,d){const{fetch:u,shardKey:h,waitForPush:l=!0}=d;if(!("window"in globalThis)||this.client.getWebSocketImpl()===void 0)return u();const t=b(s),r=this.liveFor(t),c=r.state.status==="pushed"?e.getQueryData(s)??r.state.value:void 0;if(c!==void 0)return c;if(l&&r.state.status!=="errored"&&!this.client.isCrossTabFollower()&&this.client.expectsPush({shardKey:h})){let o;try{o=await z(r,i,f=>this.client.onConnectionStatus(()=>{this.client.expectsPush({shardKey:h})||f()}))}finally{this.forgetIdleLive(t)}if(o)return this.liveValue(e,s,i,d)}const p=r.state;let a;try{a=await u()}finally{this.forgetIdleLive(t)}if(r.state!==p&&r.state.status==="pushed"){const o=e.getQueryData(s);return o!==void 0?o:r.state.value}return a}clearOnIdentityChange(e){this.listenForIdentityChange(),this.identityWatched.add(e)}stopClearingOnIdentityChange(e){this.identityWatched.delete(e)}subscribeIdentityEpoch=e=>(this.listenForIdentityChange(),this.client.onIdentityChange(e));listenForIdentityChange(){this.listening||(this.listening=!0,this.client.onIdentityChange(()=>{for(const e of this.identityWatched)this.clearQueries(e)}))}clearQueries(e){const s=e.getQueryCache();for(const i of s.findAll({queryKey:["lunora"]}))E(i),i.getObserversCount()===0&&!this.hasConsumers(i.queryKey)&&s.remove(i)}attach(e,s,i,d,u,h={}){const l=b(s);let t=this.entries.get(l);if(!t){t={clients:new Map([[e,0]]),errorCallbacks:new Set,unsubscribe:void 0},this.entries.set(l,t);const a=t;try{t.unsubscribe=this.client.subscribe(i,d,o=>{const f=this.liveFor(l);if(o===void 0){f.state=I;for(const v of a.clients.keys())E(v.getQueryCache().find({exact:!0,queryKey:s}));return}for(const v of a.clients.keys())v.setQueryData(s,o);f.state={status:"pushed",value:o},F(f,!0)},{onError:o=>{const f=this.liveFor(l);f.state.status!=="pushed"&&(f.state={status:"errored"},F(f,!1));for(const v of a.errorCallbacks)v(o)},shardKey:u})}catch(o){throw this.entries.delete(l),this.dropLive(l),o}}t.clients.set(e,(t.clients.get(e)??0)+1);const r=this.live.get(l);r?.state.status==="pushed"&&e.setQueryData(s,r.state.value);const{onError:c}=h;c&&t.errorCallbacks.add(c);let p=!1;return()=>{if(p)return;p=!0;const a=this.entries.get(l);if(!a)return;const o=(a.clients.get(e)??1)-1;o>0?a.clients.set(e,o):a.clients.delete(e),c&&a.errorCallbacks.delete(c),a.clients.size===0&&(a.unsubscribe?.(),this.entries.delete(l),this.dropLive(l))}}liveFor(e){let s=this.live.get(e);return s||(s={state:I,waiters:new Set},this.live.set(e,s)),s}forgetIdleLive(e){!this.entries.has(e)&&this.live.get(e)?.waiters.size===0&&this.live.delete(e)}dropLive(e){const s=this.live.get(e);s!==void 0&&(s.waiters.size===0?this.live.delete(e):s.state=I)}}const k=new WeakMap,L=n=>{let e=k.get(n);return e||(e=new U(n),k.set(n,e)),e},P=x(null),O=x(!1),V=()=>new N({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),J=n=>{const e=W(20),{children:s,client:i,queryClient:d}=n,u=Q(M);let h;e[0]!==u||e[1]!==d?(h=()=>d??u??V(),e[0]=u,e[1]=d,e[2]=h):h=e[2];const[l]=S(h),t=d??u??l;let r,c;e[3]!==i||e[4]!==t?(r=()=>{L(i).clearOnIdentityChange(t)},c=[i,t],e[3]=i,e[4]=t,e[5]=r,e[6]=c):(r=e[5],c=e[6]),T(r,c);const p=R(i);let a,o;e[7]!==i||e[8]!==t?(a=()=>{p.current!==i&&(L(p.current).stopClearingOnIdentityChange(t),p.current=i,L(i).clearQueries(t),t.invalidateQueries({queryKey:["lunora"]}))},o=[i,t],e[7]=i,e[8]=t,e[9]=a,e[10]=o):(a=e[9],o=e[10]),T(a,o);const[f]=S(i),v=i!==f;let g;e[11]!==s||e[12]!==v?(g=m(O,{value:v,children:s}),e[11]=s,e[12]=v,e[13]=g):g=e[13];let w;e[14]!==i||e[15]!==g?(w=m(P,{value:i,children:g}),e[14]=i,e[15]=g,e[16]=w):w=e[16];const C=w;if(u===t)return C;let y;return e[17]!==C||e[18]!==t?(y=m(A,{client:t,children:C}),e[17]=C,e[18]=t,e[19]=y):y=e[19],y},X=()=>Q(O),Z=()=>{const n=Q(P);if(!n)throw new D("INTERNAL","useLunora must be used inside <LunoraProvider />");return n};export{J as L,X as a,L as g,Z as u};
@@ -1 +0,0 @@
1
- import{l as u}from"./query-key-BysXrewF.mjs";const t=(a,r,s,e={})=>{const y=s??{};return{queryFn:()=>a.query(r,y,{shardKey:e.shardKey}),queryKey:u(r,y,e.shardKey),staleTime:Number.POSITIVE_INFINITY}};export{t as lunoraQueryOptions};
@@ -1 +0,0 @@
1
- import{stableWireKey as a}from"@lunora/wire";const o=e=>a(e),l=(e,r,s)=>["lunora",e,r,s??null],y=(e,r,s)=>l(e.__lunoraRef,a(r),s),u=e=>o(e);export{l as a,o as k,y as l,u as s};
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{initialPages as T,rebalance as Y,derivePaginationStatus as D,applyLoadMore as _}from"@lunora/client/pagination";import{useQueryClient as B,CancelledError as G}from"@tanstack/react-query";import{useRef as m,useReducer as J,useState as z,useEffect as h,useCallback as U}from"react";import{u as W,g as X}from"./lunora-provider-CW9Gd-pp.mjs";import{s as u,l as I}from"./query-key-BysXrewF.mjs";const Z=function(i){const l=m(void 0);return l.current??=i(),l},oe=function(i,l,R){const y=W(),a=B(),{initialNumItems:S,shardKey:g}=R,f=l==="skip",p=f?{}:l,[,H]=J(e=>e+1,0),[P,K]=z(()=>T(S)),[V,k]=z(void 0),A=m(R.onError);h(()=>{A.current=R.onError});const E=`${u(I(i,p,g))}::${String(S)}`,x=m(E);x.current!==E&&(x.current=E,K(T(S)),k(void 0));const C=P.map(e=>{const t={...p,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},r=I(i,t,g);return{args:t,key:r}}),F=C.map(({key:e})=>u(e)).join("|"),b=m({baseArgs:p,entries:[],fn:i,shardKey:g});h(()=>{b.current={baseArgs:p,entries:C,fn:i,shardKey:g}});const L=(e,t,r)=>{k(r),K(n=>{const s=b.current,o=n.at(-1);if(n.length<=1||!o||a.getQueryData(t)!==void 0)return n;const v={...s.baseArgs,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}};return u(I(s.fn,v,s.shardKey))===e?n.slice(0,-1):n}),A.current?.(r)},Q=Z(()=>new Map),M=m(y);h(()=>{const e=Q.current;if(M.current!==y){for(const s of e.values())s();e.clear(),M.current=y}if(f){for(const s of e.values())s();e.clear();return}const t=b.current,r=X(y),n=new Set(t.entries.map(({key:s})=>u(s)));for(const[s,o]of e)n.has(s)||(o(),e.delete(s));for(const s of t.entries){const o=u(s.key);if(e.has(o))continue;const v=async()=>y.query(t.fn,s.args,{shardKey:t.shardKey}),d=()=>{a.fetchQuery({gcTime:Number.POSITIVE_INFINITY,queryFn:async({signal:c})=>r.liveValue(a,s.key,c,{fetch:v,shardKey:t.shardKey}),queryKey:s.key,staleTime:0}).catch(c=>{if(c instanceof G){r.hasConsumers(s.key)&&d();return}L(o,s.key,c instanceof Error?{code:c.code,message:c.message}:{message:String(c)})})};d();const w=r.attach(a,s.key,t.fn,s.args,t.shardKey,{onError:O=>{L(o,s.key,O)}}),N=s.key;e.set(o,()=>{w(),r.hasConsumers(N)||a.removeQueries({exact:!0,queryKey:N})})}},[y,a,F,f]),h(()=>()=>{for(const e of Q.current.values())e();Q.current.clear()},[]),h(()=>{const e=a.getQueryCache(),t=new Set(C.map(({key:n})=>u(n)));return e.subscribe(n=>{if(n.type!=="updated")return;const s=u(n.query.queryKey);t.has(s)&&(k(void 0),H())})},[a,F]);const q=f?[]:C.map(({key:e})=>a.getQueryData(e));h(()=>{if(f)return;const e=Y(P,q);e&&K(e)});const{status:$}=D(f,q),j=U(e=>{k(void 0),K(t=>{const r=b.current,n=t.map(d=>{const w={...r.baseArgs,paginationOpts:{cursor:d.lower,endCursor:d.upper,numItems:d.numItems}};return a.getQueryData(I(r.fn,w,r.shardKey))}),{nextCursor:s,status:o}=D(!1,n);return _(t,o==="CanLoadMore"?s:void 0,e)??t})},[a]);return{error:V,loadMore:j,pageResults:q,status:$}};export{oe as u};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as y}from"react/compiler-runtime";import{useMutation as z,useQuery as _,keepPreviousData as b}from"@tanstack/react-query";import{useState as U,useSyncExternalStore as D}from"react";import{u as A}from"./lunora-provider-CW9Gd-pp.mjs";const E="lunora-react-admin-auth",F=50;function S(t,e,o,u={}){const{enabled:r=!0,pageSize:c=F}=u,[i,s]=U(c),l=D(m=>{const v=t.onAuthTokenChange(m),I=t.onIdentityChange(m);return()=>{v(),I()}},()=>t.currentIdentity(),()=>t.currentIdentity()),n=[E,l??"anon",...e,i],a=_({enabled:r,placeholderData:(m,v)=>v?.queryKey[1]===n[1]?b(m):void 0,queryFn:()=>o(i),queryKey:n,staleTime:0}),d=a.data?.rows,f=a.data?.total,p=f!==void 0&&d!==void 0&&d.length<f,h=()=>{p&&s(m=>m+c)},g=()=>{a.refetch().catch(()=>{})};return{data:d,error:a.error??void 0,hasMore:p,loadMore:h,loading:a.isLoading,refetch:g,total:f}}const q=t=>{const e=y(20);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,filterField:i,filterValue:s,pageSize:l,search:n,searchField:a,sortBy:d,sortDirection:f}=u;let p;e[2]!==i||e[3]!==s||e[4]!==n||e[5]!==a||e[6]!==d||e[7]!==f?(p=["users",{filterField:i,filterValue:s,search:n,searchField:a,sortBy:d,sortDirection:f}],e[2]=i,e[3]=s,e[4]=n,e[5]=a,e[6]=d,e[7]=f,e[8]=p):p=e[8];let h;e[9]!==r||e[10]!==i||e[11]!==s||e[12]!==n||e[13]!==a||e[14]!==d||e[15]!==f?(h=m=>r.listAuthUsers({filterField:i,filterValue:s,limit:m,search:n,searchField:a,sortBy:d,sortDirection:f}),e[9]=r,e[10]=i,e[11]=s,e[12]=n,e[13]=a,e[14]=d,e[15]=f,e[16]=h):h=e[16];let g;return e[17]!==c||e[18]!==l?(g={enabled:c,pageSize:l},e[17]=c,e[18]=l,e[19]=g):g=e[19],S(r,p,h,g)},M=t=>{const e=y(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["organizations"],e[2]=s):s=e[2];let l;e[3]!==r?(l=a=>r.listAuthOrganizations({limit:a}),e[3]=r,e[4]=l):l=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],S(r,s,l,n)},k=t=>{const e=y(8);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i}=u;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=["sign-up-invitations"],e[2]=s):s=e[2];let l;e[3]!==r?(l=a=>r.listAuthSignUpInvitations({limit:a}),e[3]=r,e[4]=l):l=e[4];let n;return e[5]!==c||e[6]!==i?(n={enabled:c,pageSize:i},e[5]=c,e[6]=i,e[7]=n):n=e[7],S(r,s,l,n)},K=t=>{const e=y(10);let o;e[0]!==t?(o=t===void 0?{}:t,e[0]=t,e[1]=o):o=e[1];const u=o,r=A(),{enabled:c,pageSize:i,userId:s}=u;let l;e[2]!==s?(l=["sessions",{userId:s}],e[2]=s,e[3]=l):l=e[3];let n;e[4]!==r||e[5]!==s?(n=d=>r.listAuthSessions({limit:d,userId:s}),e[4]=r,e[5]=s,e[6]=n):n=e[6];let a;return e[7]!==c||e[8]!==i?(a={enabled:c,pageSize:i},e[7]=c,e[8]=i,e[9]=a):a=e[9],S(r,l,n,a)},w=()=>{const t=y(10),e=A();let o;t[0]!==e?(o={mutationFn:a=>e.impersonateAuthUser({userId:a})},t[0]=e,t[1]=o):o=t[1];const u=z(o),{mutateAsync:r,reset:c}=u;let i;t[2]!==r?(i=a=>r(a),t[2]=r,t[3]=i):i=t[3];const s=i,l=u.error??void 0;let n;return t[4]!==s||t[5]!==u.data||t[6]!==u.isPending||t[7]!==c||t[8]!==l?(n={data:u.data,error:l,impersonate:s,pending:u.isPending,reset:c},t[4]=s,t[5]=u.data,t[6]=u.isPending,t[7]=c,t[8]=l,t[9]=n):n=t[9],n};export{K as useAuthSessions,q as useAuthUsers,w as useImpersonate,M as useOrganizations,k as useSignUpInvitations};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as k}from"react/compiler-runtime";import{useQueryClient as q,useQuery as E}from"@tanstack/react-query";import{useState as F,useEffect as N}from"react";import{u as T,g as V}from"./lunora-provider-CW9Gd-pp.mjs";import{u as A}from"./query-core-CqnQ_-E5.mjs";import{a as C}from"./query-key-BysXrewF.mjs";import{stableWireKey as D}from"@lunora/wire";const P=(s,K,R)=>{const e=k(26),v=R===void 0?{}:R,t=T(),y=q(),{onError:Q,shardKey:r}=v,u=K==="skip",o=u?{}:K,l=D(o),a=C(s.__lunoraRef,l,r),[n,b]=F(t.isReady);let d,c;e[0]!==t||e[1]!==n?(d=()=>{n||t.whenReady().then(()=>{b(!0)})},c=[t,n],e[0]=t,e[1]=n,e[2]=d,e[3]=c):(d=e[2],c=e[3]),N(d,c);let m;if(!u){const h=t.peekHydratedQueryByKey(s.__lunoraRef,l,r);m=h===void 0?t.peekActiveQuerySnapshot(s.__lunoraRef,o,r).value:h}const g=!u&&n;let i;e[4]!==o||e[5]!==t||e[6]!==s||e[7]!==y||e[8]!==a||e[9]!==r?(i=async h=>{const{signal:S}=h;return V(t).liveValue(y,a,S,{fetch:async()=>t.query(s,o,{shardKey:r}),shardKey:r})},e[4]=o,e[5]=t,e[6]=s,e[7]=y,e[8]=a,e[9]=r,e[10]=i):i=e[10];let p;e[11]!==m||e[12]!==a||e[13]!==g||e[14]!==i?(p={enabled:g,initialData:m,queryFn:i,queryKey:a,staleTime:Number.POSITIVE_INFINITY},e[11]=m,e[12]=a,e[13]=g,e[14]=i,e[15]=p):p=e[15];const{data:I}=E(p);let f;return e[16]!==l||e[17]!==o||e[18]!==t||e[19]!==s||e[20]!==Q||e[21]!==y||e[22]!==a||e[23]!==r||e[24]!==u?(f={args:o,argsKey:l,client:t,function_:s,onError:Q,queryClient:y,queryKey:a,shardKey:r,skipped:u},e[16]=l,e[17]=o,e[18]=t,e[19]=s,e[20]=Q,e[21]=y,e[22]=a,e[23]=r,e[24]=u,e[25]=f):f=e[25],A(f),u?void 0:I};export{P as default};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as h}from"react/compiler-runtime";import{useQueryClient as R,useSuspenseQuery as S}from"@tanstack/react-query";import{u as I,g as b}from"./lunora-provider-CW9Gd-pp.mjs";import{u as q}from"./query-core-CqnQ_-E5.mjs";import{a as F}from"./query-key-BysXrewF.mjs";import{stableWireKey as k}from"@lunora/wire";const E=(s,m,c)=>{const e=h(21),f=c===void 0?{}:c,r=I(),u=R(),{onError:d,shardKey:a}=f,y=m,o=k(y),t=F(s.__lunoraRef,o,a),p=r.isReady?r.peekHydratedQueryByKey(s.__lunoraRef,o,a):void 0;let i;e[0]!==o||e[1]!==y||e[2]!==r||e[3]!==s||e[4]!==u||e[5]!==t||e[6]!==a?(i=async K=>{const{signal:Q}=K;return await r.whenReady(),r.peekHydratedQueryByKey(s.__lunoraRef,o,a)??b(r).liveValue(u,t,Q,{fetch:async()=>r.query(s,y,{shardKey:a}),waitForPush:!1})},e[0]=o,e[1]=y,e[2]=r,e[3]=s,e[4]=u,e[5]=t,e[6]=a,e[7]=i):i=e[7];let l;e[8]!==p||e[9]!==t||e[10]!==i?(l={initialData:p,queryFn:i,queryKey:t,staleTime:Number.POSITIVE_INFINITY},e[8]=p,e[9]=t,e[10]=i,e[11]=l):l=e[11];const{data:g}=S(l);let n;return e[12]!==o||e[13]!==y||e[14]!==r||e[15]!==s||e[16]!==d||e[17]!==u||e[18]!==t||e[19]!==a?(n={args:y,argsKey:o,client:r,function_:s,onError:d,queryClient:u,queryKey:t,shardKey:a,skipped:!1},e[12]=o,e[13]=y,e[14]=r,e[15]=s,e[16]=d,e[17]=u,e[18]=t,e[19]=a,e[20]=n):n=e[20],q(n),g};export{E as default};