@lunora/react 1.0.0-alpha.7 → 1.0.0-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/dist/index.d.mts +1077 -296
- package/dist/index.d.ts +1077 -296
- package/dist/index.mjs +1 -18
- package/dist/packem_shared/AuthLoading-dC08yqew.mjs +2 -0
- package/dist/packem_shared/CheckoutButton-D8MutXhg.mjs +2 -0
- package/dist/packem_shared/LunoraProvider-DC06S-p1.mjs +2 -0
- package/dist/packem_shared/cache-I4w1R5RF.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-D6ZG10Q7.mjs +2 -0
- package/dist/packem_shared/lunoraQueryOptions-B5PEocLy.mjs +1 -0
- package/dist/packem_shared/query-key-C6iUhRuD.mjs +1 -0
- package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +38 -0
- package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +38 -0
- package/dist/packem_shared/stable-key-B_BlboiY.mjs +1 -0
- package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
- package/dist/packem_shared/use-paginated-core-D7U-wwgW.mjs +2 -0
- package/dist/packem_shared/useAction-CUSJu4yq.mjs +2 -0
- package/dist/packem_shared/useAgent-BtmvbOfx.mjs +2 -0
- package/dist/packem_shared/useAgentChat-CYdAxCn5.mjs +2 -0
- package/dist/packem_shared/useAgentState-CxeO0Nzo.mjs +2 -0
- package/dist/packem_shared/useAgentToolEvents-MfR_4MA_.mjs +2 -0
- package/dist/packem_shared/useAuth-x4boOoAR.mjs +2 -0
- package/dist/packem_shared/useAuthSessions-Bq4-f3g-.mjs +2 -0
- package/dist/packem_shared/useAuthState-CoOG9XdT.mjs +2 -0
- package/dist/packem_shared/useClientQuery-DFs7trEf.mjs +2 -0
- package/dist/packem_shared/useConnectionStatus-XYsYGiT6.mjs +2 -0
- package/dist/packem_shared/useFlag-HLt4Xzmd.mjs +2 -0
- package/dist/packem_shared/useHttpStream-D9vum8Qx.mjs +2 -0
- package/dist/packem_shared/useInfiniteQuery-DDYp2Df1.mjs +2 -0
- package/dist/packem_shared/useMutation-BnKec7bE.mjs +2 -0
- package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
- package/dist/packem_shared/usePaginatedQuery-B3Q7mppN.mjs +2 -0
- package/dist/packem_shared/usePresence-DsYEO_XX.mjs +2 -0
- package/dist/packem_shared/useQuery-BIkNc_t1.mjs +2 -0
- package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
- package/dist/packem_shared/useStream-CmGOT0qj.mjs +2 -0
- package/dist/packem_shared/useSubscription-BXhI6J-f.mjs +2 -0
- package/dist/packem_shared/useVoiceAgent-BziH3D-1.mjs +2 -0
- package/dist/packem_shared/wire-key-L5JSXhhG.mjs +1 -0
- package/dist/server.d.mts +47 -29
- package/dist/server.d.ts +47 -29
- package/dist/server.mjs +1 -31
- package/dist/upload.d.mts +23 -0
- package/dist/upload.d.ts +23 -0
- package/dist/upload.mjs +2 -0
- package/package.json +10 -4
- package/dist/packem_shared/AuthLoading-DtKgZT2Z.mjs +0 -33
- package/dist/packem_shared/CheckoutButton-CVSry8U1.mjs +0 -185
- package/dist/packem_shared/LunoraProvider-D38Xp16l.mjs +0 -80
- package/dist/packem_shared/cache-CAp1fVNL.mjs +0 -75
- package/dist/packem_shared/hydratePreloaded-B6OHn0eL.mjs +0 -46
- package/dist/packem_shared/lunoraQueryOptions-Cij4KWBK.mjs +0 -16
- package/dist/packem_shared/query-key-B5eRQCbR.mjs +0 -13
- package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +0 -38
- package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +0 -38
- package/dist/packem_shared/stable-key-CaKZv9lp.mjs +0 -30
- package/dist/packem_shared/use-paginated-core-DP72UNWn.mjs +0 -176
- package/dist/packem_shared/useAuth-CNUKtOOp.mjs +0 -129
- package/dist/packem_shared/useAuthState-BiGhtSCs.mjs +0 -36
- package/dist/packem_shared/useConnectionStatus-DRSY9ldm.mjs +0 -30
- package/dist/packem_shared/useFlag-Bg5DpkGv.mjs +0 -224
- package/dist/packem_shared/useInfiniteQuery-BBIDFXBN.mjs +0 -97
- package/dist/packem_shared/useMutation-CrvMXRsk.mjs +0 -67
- package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
- package/dist/packem_shared/usePaginatedQuery-AQO3kdp1.mjs +0 -46
- package/dist/packem_shared/usePresence-D7jLuxj0.mjs +0 -108
- package/dist/packem_shared/useQuery-EB74gtBJ.mjs +0 -42
- package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
- package/dist/packem_shared/useStream-MdYnWDL_.mjs +0 -125
- package/dist/packem_shared/useSubscription-DSJuryrU.mjs +0 -139
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
export { useAuthState } from './packem_shared/useAuthState-BiGhtSCs.mjs';
|
|
4
|
-
export { LunoraProvider, useLunora } from './packem_shared/LunoraProvider-D38Xp16l.mjs';
|
|
5
|
-
export { CheckoutButton, CustomerPortalButton, useCheckout } from './packem_shared/CheckoutButton-CVSry8U1.mjs';
|
|
6
|
-
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-Cij4KWBK.mjs';
|
|
7
|
-
export { default as useAuth } from './packem_shared/useAuth-CNUKtOOp.mjs';
|
|
8
|
-
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-DRSY9ldm.mjs';
|
|
9
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-Bg5DpkGv.mjs';
|
|
10
|
-
export { default as useInfiniteQuery } from './packem_shared/useInfiniteQuery-BBIDFXBN.mjs';
|
|
11
|
-
export { useMutation } from './packem_shared/useMutation-CrvMXRsk.mjs';
|
|
12
|
-
export { useMutator } from './packem_shared/useMutator-IIrLtDiM.mjs';
|
|
13
|
-
export { usePaginatedQuery } from './packem_shared/usePaginatedQuery-AQO3kdp1.mjs';
|
|
14
|
-
export { hydratePreloaded, default as usePreloadedQuery } from './packem_shared/hydratePreloaded-B6OHn0eL.mjs';
|
|
15
|
-
export { usePresence } from './packem_shared/usePresence-D7jLuxj0.mjs';
|
|
16
|
-
export { default as useQuery } from './packem_shared/useQuery-EB74gtBJ.mjs';
|
|
17
|
-
export { useRateLimit } from './packem_shared/useRateLimit-DTEffQEi.mjs';
|
|
18
|
-
export { useStream } from './packem_shared/useStream-MdYnWDL_.mjs';
|
|
19
|
-
export { default as useSubscription } from './packem_shared/useSubscription-DSJuryrU.mjs';
|
|
2
|
+
import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{CheckoutButton as i,CustomerPortalButton as d,useCheckout as x}from"./packem_shared/CheckoutButton-D8MutXhg.mjs";import{lunoraQueryOptions as h}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as c}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as C,useAuthUsers as U,useImpersonate as y,useOrganizations as E}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as Q}from"./packem_shared/useAgent-BtmvbOfx.mjs";import{useAgentChat as L}from"./packem_shared/useAgentChat-CYdAxCn5.mjs";import{useAgentState as F}from"./packem_shared/useAgentState-CxeO0Nzo.mjs";import{useAgentToolEvents as k}from"./packem_shared/useAgentToolEvents-MfR_4MA_.mjs";import{default as b}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as z}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as O}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as H,useFlags as V}from"./packem_shared/useFlag-HLt4Xzmd.mjs";import{useHttpStream as q}from"./packem_shared/useHttpStream-D9vum8Qx.mjs";import{default as D}from"./packem_shared/useInfiniteQuery-DDYp2Df1.mjs";import{useMutation as J}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as N}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as X}from"./packem_shared/usePaginatedQuery-B3Q7mppN.mjs";import{hydratePreloaded as Z,default as _}from"./packem_shared/hydratePreloaded-D6ZG10Q7.mjs";import{usePresence as ee}from"./packem_shared/usePresence-DsYEO_XX.mjs";import{default as oe}from"./packem_shared/useQuery-BIkNc_t1.mjs";import{useRateLimit as ue}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as ae}from"./packem_shared/useStream-CmGOT0qj.mjs";import{default as fe}from"./packem_shared/useSubscription-BXhI6J-f.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as de,getErrorCode as xe,getRetryAfterMs as le,isConflictError as he,isForbiddenError as Ae,isRateLimitedError as ce,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as Ue,UploadControl as ye,UploadError as Ee}from"@visulima/storage-client";import{useChunkedRestUpload as Qe,useFileInput as Se,useMultipartUpload as Le,usePasteUpload as Re,useTusUpload as Fe,useUpload as Me}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,i as CheckoutButton,d as CustomerPortalButton,f as LunoraProvider,Ue as RestrictionError,u as Unauthenticated,ye as UploadControl,Ee as UploadError,de as createClientQuery,xe as getErrorCode,le as getRetryAfterMs,Z as hydratePreloaded,he as isConflictError,Ae as isForbiddenError,ce as isRateLimitedError,ge as isUnauthorizedError,h as lunoraQueryOptions,c as useAction,Q as useAgent,L as useAgentChat,F as useAgentState,k as useAgentToolEvents,b as useAuth,C as useAuthSessions,a as useAuthState,U as useAuthUsers,x as useCheckout,Qe as useChunkedRestUpload,z as useClientQuery,O as useConnectionStatus,Se as useFileInput,H as useFlag,V as useFlags,q as useHttpStream,y as useImpersonate,D as useInfiniteQuery,n as useLunora,Le as useMultipartUpload,J as useMutation,N as useMutator,E as useOrganizations,X as usePaginatedQuery,Re as usePasteUpload,_ as usePreloadedQuery,ee as usePresence,oe as useQuery,ue as useRateLimit,ae as useStream,fe as useSubscription,Fe as useTusUpload,Me as useUpload,me as useVoiceAgent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useAuthState as o}from"./useAuthState-CoOG9XdT.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as p}from"react/compiler-runtime";import{useState as k,useCallback as C}from"react";import{jsx as m}from"react/jsx-runtime";const y=n=>{const t=new URL(n,globalThis.location.href);if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error(`refusing to redirect to a non-http(s) URL: ${t.protocol}`);return t.href},L=n=>{const[t,e]=k(!1),[o,a]=k(void 0);return{checkout:C(async()=>{e(!0),a(void 0);try{const r=await n();globalThis.location.assign(y(r.url))}catch(r){const l=r instanceof Error?r:new Error(String(r));throw a(l),l}finally{e(!1)}},[n]),error:o,pending:t}},E=n=>{const t=p(11),{"aria-label":e,children:o,className:a,disabled:c,onError:r,title:l,trigger:u}=n,{checkout:i,pending:s}=L(u);let d;t[0]!==i||t[1]!==r?(d=()=>{i().catch(g=>{const w=g instanceof Error?g:new Error(String(g));r?.(w)})},t[0]=i,t[1]=r,t[2]=d):d=t[2];const f=d,b=c===!0||s;let h;return t[3]!==e||t[4]!==o||t[5]!==a||t[6]!==f||t[7]!==s||t[8]!==b||t[9]!==l?(h=m("button",{"aria-busy":s,"aria-label":e,className:a,disabled:b,onClick:f,title:l,type:"button",children:o}),t[3]=e,t[4]=o,t[5]=a,t[6]=f,t[7]=s,t[8]=b,t[9]=l,t[10]=h):h=t[10],h},N=n=>{const t=p(11);let e,o;t[0]!==n?({onCheckout:e,...o}=n,t[0]=n,t[1]=e,t[2]=o):(e=t[1],o=t[2]);const{"aria-label":a,children:c,className:r,disabled:l,onError:u,title:i}=o;let s;return t[3]!==a||t[4]!==c||t[5]!==r||t[6]!==l||t[7]!==e||t[8]!==u||t[9]!==i?(s=m(E,{"aria-label":a,className:r,disabled:l,onError:u,title:i,trigger:e,children:c}),t[3]=a,t[4]=c,t[5]=r,t[6]=l,t[7]=e,t[8]=u,t[9]=i,t[10]=s):s=t[10],s},P=n=>{const t=p(11);let e,o;t[0]!==n?({onPortal:e,...o}=n,t[0]=n,t[1]=e,t[2]=o):(e=t[1],o=t[2]);const{"aria-label":a,children:c,className:r,disabled:l,onError:u,title:i}=o;let s;return t[3]!==a||t[4]!==c||t[5]!==r||t[6]!==l||t[7]!==u||t[8]!==e||t[9]!==i?(s=m(E,{"aria-label":a,className:r,disabled:l,onError:u,title:i,trigger:e,children:c}),t[3]=a,t[4]=c,t[5]=r,t[6]=l,t[7]=u,t[8]=e,t[9]=i,t[10]=s):s=t[10],s};export{N as CheckoutButton,P as CustomerPortalButton,L as useCheckout};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as p}from"react/compiler-runtime";import{LunoraError as y}from"@lunora/errors";import{QueryClientContext as L,QueryClientProvider as I,QueryClient as v}from"@tanstack/react-query";import{use as f,useState as x,createContext as N}from"react";import{jsx as m}from"react/jsx-runtime";const C=N(null),Q=()=>new v({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),b=r=>{const e=p(9),{children:c,client:a,queryClient:n}=r,t=f(L);let o;e[0]!==t||e[1]!==n?(o=()=>n??t??Q(),e[0]=t,e[1]=n,e[2]=o):o=e[2];const[d]=x(o),i=n??t??d;let u;e[3]!==c||e[4]!==a?(u=m(C,{value:a,children:c}),e[3]=c,e[4]=a,e[5]=u):u=e[5];const l=u;if(t===i)return l;let s;return e[6]!==l||e[7]!==i?(s=m(I,{client:i,children:l}),e[6]=l,e[7]=i,e[8]=s):s=e[8],s},q=()=>{const r=f(C);if(!r)throw new y("INTERNAL","useLunora must be used inside <LunoraProvider />");return r};export{b as LunoraProvider,q as useLunora};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as a}from"./query-key-C6iUhRuD.mjs";class p{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return a(e)}attach(e,n,l,u,f,h={}){const i=a(n);let r=this.entries.get(i);if(!r){r={pollTimer:void 0,refCount:0,unsubscribe:void 0},this.entries.set(i,r);try{r.unsubscribe=this.client.subscribe(l,u,t=>{e.setQueryData(n,t)},{shardKey:f})}catch{r.pollTimer=setInterval(()=>{e.invalidateQueries({queryKey:n}).catch(()=>{})},h.pollIntervalMs??5e3)}}r.refCount+=1;let o=!1;return()=>{if(o)return;o=!0;const t=this.entries.get(i);t&&(t.refCount-=1,t.refCount<=0&&(t.unsubscribe?.(),t.pollTimer&&clearInterval(t.pollTimer),this.entries.delete(i)))}}}const c=new WeakMap,g=s=>{let e=c.get(s);return e||(e=new p(s),c.set(s,e)),e};export{g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as m}from"react/compiler-runtime";import{useQueryClient as d,useQuery as p}from"@tanstack/react-query";import{useEffect as g}from"react";import{g as I}from"./cache-I4w1R5RF.mjs";import{useLunora as Q}from"./LunoraProvider-DC06S-p1.mjs";import{l as h,s as q}from"./query-key-C6iUhRuD.mjs";const K=function(n){const e=m(4),t=Q(),r=d(),{args:s,functionPath:l,shardKey:u,value:y}=n,i={__lunoraRef:l},a=h(i,s,u),{data:f}=p({initialData:y,queryFn:()=>t.query(i,s,{shardKey:u}),queryKey:a,staleTime:Number.POSITIVE_INFINITY}),c=q(a);let o;return e[0]!==t||e[1]!==r||e[2]!==c?(o=[t,r,c],e[0]=t,e[1]=r,e[2]=c,e[3]=o):o=e[3],g(()=>I(t).attach(r,a,i,s,u),o),f===void 0?y:f},C=function(n){return K(n)};export{K as default,C as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as u}from"./query-key-C6iUhRuD.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as r}from"./wire-key-L5JSXhhG.mjs";const o=e=>r(e),n=(e,s,a)=>["lunora",e.__lunoraRef,s,a??null],t=e=>o(e);export{o as k,n as l,t as s};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=/["\\\u0000-\u001F\uD800-\uDFFF]/,f=t=>a.test(t)?JSON.stringify(t):`"${t}"`,y=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(typeof t=="string")return f(t);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t)){let r="[";for(let n=0;n<t.length;n++)n>0&&(r+=","),r+=y(t[n]);return r+"]"}const i=Object.getPrototypeOf(t);if(i!==null&&i!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const o=t,c=Object.keys(o).sort();let e="{",s=!0;for(const r of c){const n=o[r];n!==void 0&&(s?s=!1:e+=",",e+=f(r),e+=":",e+=y(n))}return e+"}"};export{y as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u=function(r,e){switch(e.type){case"chunk":return{chunks:[...r.chunks,e.chunk],error:void 0,status:"streaming"};case"complete":return{...r,status:"complete"};case"error":return{...r,error:e.error,status:"error"};case"reset":return{chunks:[],error:void 0,status:"idle"};case"start":return{...r,status:"streaming"};default:return r}},o=function(r,e){let n=!0,c=!1;const s=()=>{c||(c=!0,r.cancel())};return(async()=>{try{for await(const t of r){if(!n)return;e({chunk:t,type:"chunk"})}n&&e({type:"complete"})}catch(t){if(!n)return;e({error:t instanceof Error?t:new Error(String(t)),type:"error"})}})().catch(()=>{}),{cancel:s,cleanup:()=>{n=!1,s()}}};export{o as c,u as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{initialPages as M,rebalance as D,derivePaginationStatus as A,applyLoadMore as E}from"@lunora/client/pagination";import{useQueryClient as O}from"@tanstack/react-query";import{useRef as m,useReducer as _,useState as $,useEffect as d,useCallback as j}from"react";import{g as H}from"./cache-I4w1R5RF.mjs";import{useLunora as N}from"./LunoraProvider-DC06S-p1.mjs";import{s as i,l as q}from"./query-key-C6iUhRuD.mjs";const T=function(o){const f=m(void 0);return f.current??=o(),f},Y=function(o,f,L){const a=N(),n=O(),{initialNumItems:g,shardKey:l}=L,c=f==="skip",p=c?{}:f,[,P]=_(e=>e+1,0),[v,K]=$(()=>M(g)),b=`${i(q(o,p,l))}::${String(g)}`,S=m(b);S.current!==b&&(S.current=b,K(M(g)));const h=v.map(e=>{const s={...p,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},r=q(o,s,l);return{args:s,key:r}}),w=h.map(({key:e})=>i(e)).join("|"),k=m({baseArgs:p,entries:[],fn:o,shardKey:l});d(()=>{k.current={baseArgs:p,entries:h,fn:o,shardKey:l}});const C=T(()=>new Map),I=m(a);d(()=>{const e=C.current;if(I.current!==a){for(const t of e.values())t();e.clear(),I.current=a}if(c){for(const t of e.values())t();e.clear();return}const s=k.current,r=H(a),y=new Set(s.entries.map(({key:t})=>i(t)));for(const[t,u]of e)y.has(t)||(u(),e.delete(t));for(const t of s.entries){const u=i(t.key);if(e.has(u))continue;n.fetchQuery({queryFn:()=>a.query(s.fn,t.args,{shardKey:s.shardKey}),queryKey:t.key,staleTime:0}).catch(()=>{}),e.set(u,r.attach(n,t.key,s.fn,t.args,s.shardKey))}},[a,n,w,c]),d(()=>()=>{for(const e of C.current.values())e();C.current.clear()},[]),d(()=>n.getQueryCache().subscribe(r=>{if(r.type!=="updated")return;const y=i(r.query.queryKey);h.some(({key:t})=>i(t)===y)&&P()}),[n,w]);const R=c?[]:h.map(({key:e})=>n.getQueryData(e));d(()=>{if(c)return;const e=D(v,R);e&&K(e)});const{status:x}=A(c,R);return{loadMore:j(e=>{K(s=>{const r=k.current,y=s.map(Q=>{const z={...r.baseArgs,paginationOpts:{cursor:Q.lower,endCursor:Q.upper,numItems:Q.numItems}};return n.getQueryData(q(r.fn,z,r.shardKey))}),{nextCursor:t,status:u}=A(!1,y);return E(s,u==="CanLoadMore"?t:void 0,e)??s})},[n]),pageResults:R,status:x}};export{Y as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
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{useLunora as C}from"./LunoraProvider-DC06S-p1.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as v}from"react/compiler-runtime";import{useMutation as M}from"./useMutation-BnKec7bE.mjs";import w from"./useSubscription-BXhI6J-f.mjs";const N={__lunoraRef:""},x=h=>{const t=v(17),{api:y,cancel:a,run:R,runArgs:l,threadKey:e}=h,c=M(R),_=M(a??N);let s;t[0]!==e?(s={key:e},t[0]=e,t[1]=s):s=t[1];const{data:A}=w(y.agents.agentThread,s),n=A,d=n?.status,o=n?.instanceId,{mutate:f}=c,{mutate:p}=_;let r;t[2]!==l||t[3]!==f||t[4]!==e?(r=async(I,T)=>{await f({input:I,threadKey:e,...l,...T})},t[2]=l,t[3]=f,t[4]=e,t[5]=r):r=t[5];const g=r;let i;t[6]!==p||t[7]!==a||t[8]!==o||t[9]!==e?(i=async()=>{a===void 0||o===void 0||await p({instanceId:o,threadKey:e})},t[6]=p,t[7]=a,t[8]=o,t[9]=e,t[10]=i):i=t[10];const m=i;let u;return t[11]!==m||t[12]!==g||t[13]!==c.pending||t[14]!==d||t[15]!==n?(u={cancel:m,pending:c.pending,run:g,status:d,thread:n},t[11]=m,t[12]=g,t[13]=c.pending,t[14]=d,t[15]=n,t[16]=u):u=t[16],u};export{x as useAgent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as H,maxSeq as J}from"@lunora/client";import{useState as ct,useRef as it}from"react";import{useMutation as Y}from"./useMutation-BnKec7bE.mjs";import{useStream as lt}from"./useStream-CmGOT0qj.mjs";import L from"./useSubscription-BXhI6J-f.mjs";const ut={__lunoraRef:""},mt={__lunoraRef:""},ft=[],St=i=>{const t=rt(47),{api:E,cancel:u,limit:m,send:Q,sendArgs:b,stream:f,threadKey:e}=i;let d;t[0]!==m||t[1]!==e?(d=m===void 0?{key:e}:{key:e,limit:m},t[0]=m,t[1]=e,t[2]=d):d=t[2];const V=d,{data:W}=L(E.agents.agentMessages,V);let p;t[3]!==e?(p={key:e},t[3]=e,t[4]=p):p=t[4];const{data:X}=L(E.agents.agentThread,p);let g;t[5]!==f||t[6]!==e?(g=f===void 0?"skip":{key:e},t[5]=f,t[6]=e,t[7]=g):g=t[7];const Z=g,{chunks:w}=lt(f??mt,Z),tt=Y(Q),et=Y(u??ut),st=Y(E.agents.agentResolveApproval);let h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=[],t[8]=h):h=t[8];const[O,z]=ct(h),T=it(0),B=X,I=B?.status,a=B?.instanceId,n=W??ft;let _;if(t[9]!==n||t[10]!==O){const s=H(O,n),o=J(n);_=s.length===0?n:[...n,...s.map((r,P)=>({content:r.content,optimistic:!0,role:"user",seq:o+1+P}))],t[9]=n,t[10]=O,t[11]=_}else _=t[11];const q=_;let v;t[12]!==n?(v=n.filter(dt),t[12]=n,t[13]=v):v=t[13];const l=v.length;let y;if(t[14]!==l||t[15]!==w||t[16]!==e){let s;t[18]!==l||t[19]!==e?(s=o=>o.kind!=="progress"&&o.threadKey===e&&o.turn>=l,t[18]=l,t[19]=e,t[20]=s):s=t[20],y=w.filter(s).map(pt).join(""),t[14]=l,t[15]=w,t[16]=e,t[17]=y}else y=t[17];const j=y,{mutate:C}=tt,{mutate:D}=et,{mutate:N}=st;let M;t[21]!==n||t[22]!==b||t[23]!==C||t[24]!==e?(M=async(s,o)=>{const r=T.current;T.current=T.current+1;const P=J(n);z(U=>[...H(U,n),{content:s,id:r,maxDurableSeqAtSend:P}]);try{await C({input:s,threadKey:e,...b,...o})}catch(U){const nt=U;throw z(ot=>ot.filter(at=>at.id!==r)),nt}},t[21]=n,t[22]=b,t[23]=C,t[24]=e,t[25]=M):M=t[25];const F=M;let S;t[26]!==a||t[27]!==N||t[28]!==e?(S=async(s,o,r)=>{if(a===void 0)throw new Error(`useAgentChat: cannot ${s} — no in-flight run (thread has no instanceId)`);await N({decision:s,instanceId:a,threadKey:e,toolCallId:o,...r===void 0?{}:{note:r}})},t[26]=a,t[27]=N,t[28]=e,t[29]=S):S=t[29];const c=S;let R;t[30]!==c?(R=(s,o)=>c("approve",s,o),t[30]=c,t[31]=R):R=t[31];const K=R;let A;t[32]!==c?(A=(s,o)=>c("reject",s,o),t[32]=c,t[33]=A):A=t[33];const $=A;let k;t[34]!==D||t[35]!==u||t[36]!==a||t[37]!==e?(k=async()=>{u===void 0||a===void 0||await D({instanceId:a,threadKey:e})},t[34]=D,t[35]=u,t[36]=a,t[37]=e,t[38]=k):k=t[38];const G=k;let x;return t[39]!==K||t[40]!==G||t[41]!==q||t[42]!==$||t[43]!==F||t[44]!==I||t[45]!==j?(x={approve:K,cancel:G,messages:q,reject:$,send:F,status:I,streamingText:j},t[39]=K,t[40]=G,t[41]=q,t[42]=$,t[43]=F,t[44]=I,t[45]=j,t[46]=x):x=t[46],x};function dt(i){return i.role==="assistant"}function pt(i){return i.text}export{St as useAgentChat};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as o}from"react/compiler-runtime";import d from"./useSubscription-BXhI6J-f.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-CmGOT0qj.mjs";import N from"./useSubscription-BXhI6J-f.mjs";const E={__lunoraRef:""},_=[],k=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{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}}]},A=o=>{const t=y(12),{api:c,limit:r,stream:n,threadKey:l}=o;let a;t[0]!==r||t[1]!==l?(a=r===void 0?{key:l}:{key:l,limit:r},t[0]=r,t[1]=l,t[2]=a):a=t[2];const f=a,{data:v}=N(c.agents.agentMessages,f);let i;t[3]!==n||t[4]!==l?(i=n===void 0?"skip":{key:l},t[3]=n,t[4]=l,t[5]=i):i=t[5];const C=i,{chunks:p}=I(n??E,C),s=v??_;let e;if(t[6]!==p||t[7]!==s||t[8]!==l){e=s.flatMap(q);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]=s,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 q(o){return k(o)??[]}export{A as useAgentToolEvents};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as b}from"react/compiler-runtime";import{useSyncExternalStore as g}from"react";import{useLunora as p}from"./LunoraProvider-DC06S-p1.mjs";const k=new WeakMap,S=e=>{const t=new Set;let o=null;const i=()=>{for(const n of t)n()};let s=0;const r=n=>{o!==n&&(o=n,i())},l=()=>{s+=1;const n=s;if(e.getAuthToken()===null){r(null);return}e.getCurrentUser().then(u=>{n===s&&r(u)}).catch(()=>{n===s&&r(null)})};let c;return{getSnapshot:()=>o,subscribe:n=>{const u=t.size===0;return t.add(n),u&&(c=e.onAuthTokenChange(l),l()),()=>{t.delete(n),t.size===0&&(c?.(),c=void 0)}}}},T=e=>{let t=k.get(e);return t||(t=S(e),k.set(e,t)),t},w=()=>{const e=b(12),t=p();let o;e[0]!==t?(o=T(t),e[0]=t,e[1]=o):o=e[1];const i=o;let s,r,l;e[2]!==t?(s=h=>t.onAuthTokenChange(h),r=()=>t.getAuthToken(),l=()=>t.getAuthToken(),e[2]=t,e[3]=s,e[4]=r,e[5]=l):(s=e[3],r=e[4],l=e[5]);const c=g(s,r,l),n=g(i.subscribe,i.getSnapshot,m);let u;e[6]!==t?(u=h=>{t.setAuthToken(h)},e[6]=t,e[7]=u):u=e[7];const a=u;let f;return e[8]!==a||e[9]!==c||e[10]!==n?(f={setToken:a,token:c,user:n},e[8]=a,e[9]=c,e[10]=n,e[11]=f):f=e[11],f};function m(){return null}export{w as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as A}from"react/compiler-runtime";import{useMutation as v,useQuery as z,keepPreviousData as I}from"@tanstack/react-query";import{useState as _,useSyncExternalStore as b}from"react";import{useLunora as y}from"./LunoraProvider-DC06S-p1.mjs";const D="lunora-react-admin-auth",E=50;function S(t,e,r,u={}){const{enabled:a=!0,pageSize:c=E}=u,[i,s]=_(c),l=b(g=>t.onAuthTokenChange(g),()=>t.currentIdentity(),()=>t.currentIdentity()),n=[D,l??"anon",...e,i],o=z({enabled:a,placeholderData:I,queryFn:()=>r(i),queryKey:n,staleTime:0}),d=o.data?.rows,f=o.data?.total,m=f!==void 0&&d!==void 0&&d.length<f,h=()=>{m&&s(g=>g+c)},p=()=>{o.refetch().catch(()=>{})};return{data:d,error:o.error??void 0,hasMore:m,loadMore:h,loading:o.isLoading,refetch:p,total:f}}const M=t=>{const e=A(20);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{enabled:c,filterField:i,filterValue:s,pageSize:l,search:n,searchField:o,sortBy:d,sortDirection:f}=u;let m;e[2]!==i||e[3]!==s||e[4]!==n||e[5]!==o||e[6]!==d||e[7]!==f?(m=["users",{filterField:i,filterValue:s,search:n,searchField:o,sortBy:d,sortDirection:f}],e[2]=i,e[3]=s,e[4]=n,e[5]=o,e[6]=d,e[7]=f,e[8]=m):m=e[8];let h;e[9]!==a||e[10]!==i||e[11]!==s||e[12]!==n||e[13]!==o||e[14]!==d||e[15]!==f?(h=g=>a.listAuthUsers({filterField:i,filterValue:s,limit:g,search:n,searchField:o,sortBy:d,sortDirection:f}),e[9]=a,e[10]=i,e[11]=s,e[12]=n,e[13]=o,e[14]=d,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==c||e[18]!==l?(p={enabled:c,pageSize:l},e[17]=c,e[18]=l,e[19]=p):p=e[19],S(a,m,h,p)},T=t=>{const e=A(8);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{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]!==a?(l=o=>a.listAuthOrganizations({limit:o}),e[3]=a,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(a,s,l,n)},$=t=>{const e=A(10);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const u=r,a=y(),{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]!==a||e[5]!==s?(n=d=>a.listAuthSessions({limit:d,userId:s}),e[4]=a,e[5]=s,e[6]=n):n=e[6];let o;return e[7]!==c||e[8]!==i?(o={enabled:c,pageSize:i},e[7]=c,e[8]=i,e[9]=o):o=e[9],S(a,l,n,o)},q=()=>{const t=A(10),e=y();let r;t[0]!==e?(r={mutationFn:o=>e.impersonateAuthUser({userId:o})},t[0]=e,t[1]=r):r=t[1];const u=v(r),{mutateAsync:a,reset:c}=u;let i;t[2]!==a?(i=o=>a(o),t[2]=a,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{$ as useAuthSessions,M as useAuthUsers,q as useImpersonate,T as useOrganizations};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as u}from"react/compiler-runtime";import{useSyncExternalStore as c}from"react";import i from"./useAuth-x4boOoAR.mjs";const m=()=>()=>{},h=()=>{const t=u(3),{token:s}=i(),r=c(m,f,a),n=r&&s!==null,o=!r;let e;return t[0]!==n||t[1]!==o?(e={isAuthenticated:n,isLoading:o},t[0]=n,t[1]=o,t[2]=e):e=t[2],e};function f(){return!0}function a(){return!1}export{h as useAuthState};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useCallback as n,useSyncExternalStore as l}from"react";import{useLunora as c}from"./LunoraProvider-DC06S-p1.mjs";const y=e=>{const t=c(),u=n(s=>t.subscribeClientQuery(e,()=>{s()}),[t,e.key]),r=l(u,()=>t.getClientQuery(e),()=>t.getClientQuery(e)),o=n(s=>{t.setClientQuery(e,s)},[t,e]);return[r,o]};export{y as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as s}from"react/compiler-runtime";import{useSyncExternalStore as u}from"react";import{useLunora as i}from"./LunoraProvider-DC06S-p1.mjs";const S=()=>{const t=s(4),n=i();let o,e,c;return t[0]!==n?(o=r=>n.onConnectionStatus(()=>{r()}),e=()=>n.connectionStatus(),c=()=>n.connectionStatus(),t[0]=n,t[1]=o,t[2]=e,t[3]=c):(o=t[1],e=t[2],c=t[3]),u(o,e,c)};export{S as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as v,useRef as d,useEffect as m}from"react";import{useLunora as K}from"./LunoraProvider-DC06S-p1.mjs";import{s as g}from"./stable-key-B_BlboiY.mjs";const h="__lunora_flags__:eval",R=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},$={__lunoraRef:h},S=(t,e,r)=>{const p=K(),[i,s]=v(e),c=R(e),o=r===void 0?"":g(r),u=`${t}::${c}::${o}`,l=d(u);l.current!==u&&(l.current=u,s(e));const a=d({context:r,defaultValue:e});return m(()=>{a.current={context:r,defaultValue:e}}),m(()=>{let f=!1;const{context:y,defaultValue:b}=a.current;s(b);let n;try{n=p.subscribe($,{context:y,default:b,key:t,type:c},_=>{f||s(_)})}catch{return()=>{f=!0}}return()=>{f=!0,n()}},[p,t,c,o]),i},j=(t,e)=>{const r=K(),[p,i]=v(t),s=g(t),c=e===void 0?"":g(e),o=`${s}::${c}`,u=d(o);u.current!==o&&(u.current=o,i(t));const l=d({context:e,flags:t});return m(()=>{l.current={context:e,flags:t}}),m(()=>{let a=!1;const{context:f,flags:y}=l.current;i(y);const b=[];for(const[n,_]of Object.entries(y))try{b.push(r.subscribe($,{context:f,default:_,key:n,type:R(_)},C=>{a||i(F=>({...F,[n]:C}))}))}catch{}return()=>{a=!0;for(const n of b)n()}},[r,s,c]),p};export{S as useFlag,j as useFlags};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{useLunora as b}from"./LunoraProvider-DC06S-p1.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./stable-key-B_BlboiY.mjs";const C=(t,c,o)=>{const e=S(24);let m;e[0]!==o?(m=o===void 0?{}:o,e[0]=o,e[1]=m):m=e[1];const f=m,n=b();let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={chunks:[],error:void 0,status:"idle"},e[2]=i):i=e[2];const[s,a]=_(z,i),r=c==="skip";let l;e[3]!==c||e[4]!==r?(l=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=l):l=e[5];const k=l,x=v(void 0);let u;e[6]!==c||e[7]!==n||e[8]!==f.maxBuffer||e[9]!==t||e[10]!==r?(u=()=>{if(r)return a({type:"reset"}),L;a({type:"reset"}),a({type:"start"});const{cancel:B,cleanup:y}=E(n.httpStream(t,c,{maxBuffer:f.maxBuffer}),a);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=n,e[8]=f.maxBuffer,e[9]=t,e[10]=r,e[11]=u):u=e[11];let p;e[12]!==n||e[13]!==f.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[n,t.method,t.path,k,r,f.maxBuffer],e[12]=n,e[13]=f.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(u,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 L(){}export{C as useHttpStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as L}from"react/compiler-runtime";import{useRef as M,useEffect as R}from"react";import{u as y}from"./use-paginated-core-D7U-wwgW.mjs";const b=(h,c,g)=>{const e=L(15),{initialNumItems:s}=g,{loadMore:o,pageResults:u,status:a}=y(h,c==="skip"?"skip":c,g),N=c==="skip";let t;if(e[0]!==u){t=[];for(const f of u)f&&t.push(f.page);e[0]=u,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 P=M(i);let n;e[5]!==s||e[6]!==o?(n=()=>{P.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],R(n);let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=f=>{const{defaultNumItems:I,loadMore:k}=P.current;k(f??I)},e[8]=l):l=e[8];const x=l,m=a==="CanLoadMore",d=!N&&a==="LoadingMore",p=!N&&a==="LoadingFirstPage";let r;return e[9]!==t||e[10]!==a||e[11]!==m||e[12]!==d||e[13]!==p?(r={fetchNextPage:x,hasNextPage:m,isFetchingNextPage:d,isLoading:p,pages:t,status:a},e[9]=t,e[10]=a,e[11]=m,e[12]=d,e[13]=p,e[14]=r):r=e[14],r};export{b as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useMutation as C}from"@tanstack/react-query";import{useRef as R,useState as S,useCallback as p}from"react";import{useLunora as U}from"./LunoraProvider-DC06S-p1.mjs";const x=d=>{const f=U(),o=R(0),[u,c]=S(!1),M=C({mutationFn:({args:t,options:e})=>f.mutation(d,t,e),onMutate:()=>{o.current+=1,c(!0)},onSettled:()=>{o.current-=1,c(o.current>0)}}),{data:r,error:s,isError:a,mutateAsync:n,reset:i}=M,g=p((t,e)=>n({args:t,options:e}),[n]),m=p(t=>({data:r,error:s,isError:a,mutate:(l,b)=>n({args:l,options:{optimisticUpdate:t,...b}}),pending:u,reset:i,withOptimisticUpdate:m}),[n,r,s,a,u,i]);return{data:r,error:s,isError:a,mutate:g,pending:u,reset:i,withOptimisticUpdate:m}};export{x as useMutation};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as p}from"react/compiler-runtime";import{createMutatorRunner as l}from"@lunora/client";import{useState as f}from"react";const E=function(s){const t=p(8),[n,m]=f(!1),[r,a]=f(void 0);let e;t[0]!==s?(e=l(s,{setError:a,setPending:m}),t[0]=s,t[1]=e):e=t[1];const{mutate:i,reset:u}=e,c=r!==void 0;let o;return t[2]!==r||t[3]!==i||t[4]!==n||t[5]!==u||t[6]!==c?(o={error:r,isError:c,mutate:i,pending:n,reset:u},t[2]=r,t[3]=i,t[4]=n,t[5]=u,t[6]=c,t[7]=o):o=t[7],o};export{E as useMutator};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as l}from"react/compiler-runtime";import{u as c}from"./use-paginated-core-D7U-wwgW.mjs";const m=(u,i,d)=>{const e=l(7),{loadMore:p,pageResults:r,status:t}=c(u,i==="skip"?"skip":i,d);let s;if(e[0]!==r){s=[];for(const a of r)a&&s.push(...a.page);e[0]=r,e[1]=s}else s=e[1];const n=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==p||e[3]!==s||e[4]!==t||e[5]!==n?(o={isLoading:n,loadMore:p,results:s,status:t},e[2]=p,e[3]=s,e[4]=t,e[5]=n,e[6]=o):o=e[6],o};export{m as usePaginatedQuery};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useMemo as U,useState as D,useRef as b,useEffect as a,useCallback as p}from"react";import{useLunora as E}from"./LunoraProvider-DC06S-p1.mjs";const L=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}}return Date.now().toString(36)},A=1e4,C=(t,n)=>{const s=E(),{heartbeat:f,intervalMs:l=A,listPresent:y,shardKey:r}=n,c=U(()=>n.sessionId??L(),[n.sessionId]),[v,I]=D(void 0),d=b(n.data),m=b({client:s,heartbeat:f,roomId:t,sessionId:c,shardKey:r});a(()=>{m.current={client:s,heartbeat:f,roomId:t,sessionId:c,shardKey:r}});const o=p(()=>{const{client:e,heartbeat:i,roomId:u,sessionId:g,shardKey:S}=m.current,R={roomId:u,sessionId:g,...d.current===void 0?{}:{data:d.current}};e.mutation(i,R,{shardKey:S}).catch(()=>{})},[]),h=p(e=>{d.current=e,o()},[o]);return a(()=>{o();const e=setInterval(o,l),i=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),()=>{clearInterval(e),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}},[o,l]),a(()=>s.acquireConnectionContext({roomId:t,sessionId:c},{shardKey:r}),[s,t,c,r]),a(()=>{let e=!1;const i=s.subscribe(y,{roomId:t},u=>{e||I(u)},{shardKey:r});return()=>{e=!0,i()}},[s,y.__lunoraRef,t,r]),{present:v,sessionId:c,setData:h}};export{C as usePresence};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as R}from"react/compiler-runtime";import{useQueryClient as q,useQuery as K}from"@tanstack/react-query";import{useState as b,useEffect as f}from"react";import{g as k}from"./cache-I4w1R5RF.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-C6iUhRuD.mjs";const x=(o,m,p)=>{const e=R(9),Q=p===void 0?{}:p,t=v(),a=q(),{shardKey:i}=Q,r=m==="skip",n=r?{}:m,d=N(o,n,i),[s,h]=b(t.isReady);let u,y;e[0]!==t||e[1]!==s?(u=()=>{s||t.whenReady().then(()=>{h(!0)})},y=[t,s],e[0]=t,e[1]=s,e[2]=u,e[3]=y):(u=e[2],y=e[3]),f(u,y);const g=r?void 0:t.peekHydratedQuery(o.__lunoraRef,n,i),{data:I}=K({enabled:!r&&s,initialData:g,queryFn:()=>t.query(o,n,{shardKey:i}),queryKey:d,staleTime:Number.POSITIVE_INFINITY}),l=S(d);let c;return e[4]!==t||e[5]!==a||e[6]!==r||e[7]!==l?(c=[t,a,l,r],e[4]=t,e[5]=a,e[6]=r,e[7]=l,e[8]=c):c=e[8],f(()=>r?T:k(t).attach(a,d,o,n,i),c),r?void 0:I};function T(){}export{x as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{evaluate as u}from"@lunora/ratelimit";import{useRef as i,useReducer as w,useCallback as c,useEffect as R}from"react";const p=(t,a={})=>{const r=a.now??Date.now,l=a.tickMs??1e3,s=i(void 0),[,n]=w(e=>e+1,0),v=c((e=1)=>{const{status:d,value:f}=u(t,s.current,{consume:!0,count:e,now:r(),reserve:!1});return f!==void 0&&(s.current=f),n(),d},[t,r]),k=c((e=1)=>u(t,s.current,{consume:!1,count:e,now:r(),reserve:!1}).status.ok,[t,r]),m=c(()=>{s.current=void 0,n()},[]),{status:o}=u(t,s.current,{consume:!1,count:1,now:r(),reserve:!1});return R(()=>{if(o.ok)return()=>{};const e=setInterval(n,l);return()=>{clearInterval(e)}},[o.ok,l]),{check:k,consume:v,disabled:!o.ok,ok:o.ok,reset:m,retryAfter:o.retryAfter}};export{p as useRateLimit};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./wire-key-L5JSXhhG.mjs";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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as q}from"react/compiler-runtime";import{createQuerySubscription as w}from"@lunora/client/query";import{useState as x,useRef as A,useEffect as v}from"react";import{useLunora as D}from"./LunoraProvider-DC06S-p1.mjs";import{s as F}from"./wire-key-L5JSXhhG.mjs";const j=(t,r,a)=>{const e=q(22);let l;e[0]!==a?(l=a===void 0?{}:a,e[0]=a,e[1]=l):l=e[1];const o=l,i=D();let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={data:void 0,error:void 0},e[2]=n):n=e[2];const[R,p]=x(n),s=r==="skip";let c;e[3]!==r||e[4]!==s?(c=s?"skip":F(r),e[3]=r,e[4]=s,e[5]=c):c=e[5];const y=c;let d;e[6]!==r||e[7]!==t?(d={args:r,fn:t},e[6]=r,e[7]=t,e[8]=d):d=e[8];const K=A(d);let f;e[9]!==r||e[10]!==t?(f=()=>{K.current={args:r,fn:t}},e[9]=r,e[10]=t,e[11]=f):f=e[11],v(f);let u;e[12]!==i||e[13]!==o.shardKey||e[14]!==s?(u=()=>{if(s)return p({data:void 0,error:void 0}),L;let b=!1;const{args:S,fn:k}=K.current,E=w(i,k,S,{onData:h=>{b||p({data:h,error:void 0})},onError:h=>{const z=new Error(h.message);queueMicrotask(()=>{b||p({data:void 0,error:z})})}},{shardKey:o.shardKey});return()=>{b=!0,E()}},e[12]=i,e[13]=o.shardKey,e[14]=s,e[15]=u):u=e[15];let m;return e[16]!==i||e[17]!==t.__lunoraRef||e[18]!==o.shardKey||e[19]!==y||e[20]!==s?(m=[i,t.__lunoraRef,y,o.shardKey,s],e[16]=i,e[17]=t.__lunoraRef,e[18]=o.shardKey,e[19]=y,e[20]=s,e[21]=m):m=e[21],v(u,m),R};function L(){}export{j as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as w,useRef as W,useCallback as b,useEffect as J}from"react";import{useLunora as K}from"./LunoraProvider-DC06S-p1.mjs";const G=16e3,j=e=>{if(e.length===0)return 0;let o=0;for(const r of e)o+=r*r;return Math.sqrt(o/e.length)},z=(e,o)=>{const r=o/G,c=r>1?Math.floor(e.length/r):e.length,l=new ArrayBuffer(c*2),i=new DataView(l);for(let a=0;a<c;a+=1){const k=e[Math.floor(a*r)]??0,p=Math.max(-1,Math.min(1,k));i.setInt16(a*2,p<0?p*32768:p*32767,!0)}return new Uint8Array(l)},Q=async e=>{const o=globalThis,r=o.navigator?.mediaDevices?.getUserMedia.bind(o.navigator.mediaDevices),c=o.AudioContext??o.webkitAudioContext;if(!r||!c)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await r({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new c,a=i.createMediaStreamSource(l),k=i.createScriptProcessor(4096,1,1);let p=!1,g=!1,d=0,f=0;return k.onaudioprocess=s=>{const h=s.inputBuffer.getChannelData(0),m=p?0:j(h);if(e.onLevel(m),p)return;if(e.onAudio(z(h,i.sampleRate)),e.isSpeaking()){f=m>=e.interruptThreshold?f+1:0,f>=e.interruptChunks&&(f=0,e.onInterrupt());return}f=0;const x=h.length/i.sampleRate*1e3;if(m>=e.silenceThreshold){g=!0,d=0;return}g&&(d+=x,d>=e.silenceDurationMs&&(g=!1,d=0,e.onSilence()))},a.connect(k),k.connect(i.destination),{setMuted:s=>{p=s},stop:()=>{k.disconnect(),a.disconnect();for(const s of l.getTracks())s.stop();i.close()}}},X=()=>{const e=globalThis,o=e.AudioContext??e.webkitAudioContext;if(!o)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const r=new o,c=new Set;let l=0,i=Promise.resolve(),a=0;const k=async(d,f)=>{if(f!==a)return;let s;try{s=await r.decodeAudioData(d.buffer)}catch{return}if(f!==a)return;const h=r.createBufferSource();h.buffer=s,h.connect(r.destination);const m=Math.max(r.currentTime,l);h.start(m),l=m+s.duration,c.add(h),h.onended=()=>{c.delete(h)}},p=d=>{const f=Uint8Array.from(d),s=a;i=i.then(()=>k(f,s))},g=()=>{a+=1;for(const d of c)try{d.stop()}catch{}c.clear(),l=r.currentTime};return{enqueue:p,interrupt:g,stop:()=>{g(),r.close()}}},P=1,Y=.01,Z=1200,ee=.15,te=3,ne=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,re=e=>{const o=e.__lunoraRef,r=o.startsWith("agents:")?o.slice(7):o;return r.endsWith("Voice")?r.slice(0,-5):r},se=(e,o,r)=>{const c=ne(e),l=c.endsWith("/")?c.slice(0,-1):c,i=new URLSearchParams({threadKey:r});return`${l}/_lunora/voice/${encodeURIComponent(o)}?${i.toString()}`},ie=e=>{const{createMicrophone:o=Q,createSpeaker:r=X,createSocket:c,interruptChunks:l=te,interruptThreshold:i=ee,silenceDurationMs:a=Z,silenceThreshold:k=Y,threadKey:p,voice:g}=e,d=K(),[f,s]=w("idle"),[h,m]=w(!1),[x,U]=w(""),[V,C]=w(""),[H,_]=w(0),[R,L]=w(!1),[O,v]=w(void 0),u=W(void 0),E=W(!1),T=b(t=>{const n=u.current?.socket;return n?.readyState===P?(n.send(JSON.stringify(t)),!0):!1},[]),y=b(()=>{const t=u.current;if(u.current=void 0,t){t.microphone?.stop(),t.speaker?.stop();try{t.socket.close()}catch{}}E.current=!1,m(!1),s("idle"),_(0)},[]),D=b(t=>{const n=u.current;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),s("speaking"),C(S=>S+t.text);break}case"assistant_done":{n&&(n.speaking=!1),C(t.text),s("listening");break}case"error":{n&&(n.speaking=!1),v(new Error(t.message)),s("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),s("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),m(!0),s("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),U(t.text),C(""),s("thinking");break}}},[]),F=b(t=>{const n=u.current;!n||n.suppressAudio||(n.speaker??=r({audioFormat:n.audioFormat}),n.speaking=!0,s("speaking"),n.speaker.enqueue(t))},[r]),q=b(async()=>{if(!(u.current||E.current)){E.current=!0,v(void 0),U(""),C("");try{const t=se(d.url,re(g),p),S=(c??(A=>{const N=d.getWebSocketImpl();if(!N)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new N(A)}))(t);S.binaryType="arraybuffer";const M={audioFormat:"mp3",microphone:void 0,socket:S,speaker:void 0,speaking:!1,suppressAudio:!1};u.current=M,S.onmessage=A=>{if(typeof A.data=="string"){try{D(JSON.parse(A.data))}catch{}return}F(new Uint8Array(A.data))},S.onerror=()=>{v(new Error("useVoiceAgent: voice socket error"))},S.onclose=()=>{u.current===M&&y()};const I=await o({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>u.current?.speaking??!1,onAudio:A=>{S.readyState===P&&S.send(A)},onInterrupt:()=>{T({type:"interrupt"}),u.current?.speaker?.interrupt(),u.current&&(u.current.speaking=!1,u.current.suppressAudio=!0),s("listening")},onLevel:_,onSilence:()=>{T({type:"commit"}),s("thinking")},silenceDurationMs:a,silenceThreshold:k});u.current===M?(M.microphone=I,L(!1),s("listening")):I.stop()}catch(t){v(t instanceof Error?t:new Error(String(t))),y()}finally{E.current=!1}}},[d,o,c,F,D,l,i,T,a,k,y,p,g]),B=b(()=>{const t=!R;return u.current?.microphone?.setMuted(t),L(t),t},[R]),$=b(t=>{T({text:t,type:"text"})&&s("thinking")},[T]);return J(()=>y,[y]),{audioLevel:H,connected:h,endCall:y,error:O,interimTranscript:V,isMuted:R,sendText:$,startCall:q,status:f,toggleMute:B,transcript:x}};export{ie as useVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as d}from"./stable-key-B_BlboiY.mjs";const u=r=>{let t="";for(let c=0;c<r.length;c+=32768)t+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(t)},e="$lunora.wire$",b=64,m="__proto__",p=r=>{if(r===null||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);return t===null||t===Object.prototype},i=(r,t=0)=>{if(t>b)throw new RangeError(`wire-codec: value nesting exceeds the ${b}-level limit`);if(r===void 0)return[e,"undefined"];if(r===null)return null;const f=typeof r;if(f==="bigint")return[e,"bigint",r.toString()];if(f==="number"){const n=r;return Number.isNaN(n)?[e,"nan"]:n===1/0?[e,"inf"]:n===-1/0?[e,"-inf"]:n}if(f!=="object")return r;if(r instanceof Date)return[e,"date",i(r.getTime(),t+1)];if(r instanceof Error){const n=r,o={};for(const y of Object.keys(n))n[y]!==void 0&&(o[y]=i(n[y],t+1));const s=[e,"error",n.name,n.message,o];return n.cause!==void 0&&s.push(i(n.cause,t+1)),s}if(r instanceof URL)return[e,"url",r.href];if(r instanceof Map)return[e,"map",[...r.entries()].map(([n,o])=>[i(n,t+1),i(o,t+1)])];if(r instanceof Set)return[e,"set",[...r].map(n=>i(n,t+1))];if(r instanceof ArrayBuffer)return[e,"bytes",u(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const n=r,o=n.constructor.name,s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return o==="Uint8Array"?[e,"bytes",u(s)]:[e,"bytes",u(s),o]}if(Array.isArray(r)){const n=r.map(o=>i(o,t+1));return n.length>0&&n[0]===e?[e,"arr",n]:n}if(!p(r)){const n=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${n} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const c=r,a={};for(const n of Object.keys(c)){const o=c[n];if(o===void 0)continue;const s=i(o,t+1);n===m?Object.defineProperty(a,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):a[n]=s}return a},w=r=>d(i(r));export{w as s};
|
package/dist/server.d.mts
CHANGED
|
@@ -4,20 +4,38 @@ import { ServerClientOptions } from '@lunora/client/ssr';
|
|
|
4
4
|
export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
6
|
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
9
|
+
* Server-side data-loading helpers for React Server Components.
|
|
10
|
+
*
|
|
11
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
12
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
13
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
14
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
15
|
+
* `@lunora/react`, which is a client boundary.
|
|
16
|
+
*
|
|
17
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
18
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
19
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
20
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
21
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
22
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
23
|
+
* `usePreloadedQuery`.
|
|
24
|
+
*/
|
|
25
|
+
type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
|
|
26
|
+
/**
|
|
27
|
+
* Run a query on the server and seed `queryClient` with the result under the
|
|
28
|
+
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
|
29
|
+
* `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
|
|
30
|
+
* flash, no duplicate fetch on the client.
|
|
31
|
+
*
|
|
32
|
+
* Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
|
|
33
|
+
* from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
|
|
34
|
+
* the client subtree in `HydrationBoundary`, and the client hooks pick the value
|
|
35
|
+
* up from cache. Errors propagate — wrap the call if you'd rather render a
|
|
36
|
+
* fallback than fail the server render. Drop the `await` for fire-and-forget
|
|
37
|
+
* prefetch when you don't need the data present on the very first paint.
|
|
38
|
+
*/
|
|
21
39
|
declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
|
|
22
40
|
shardKey?: string;
|
|
23
41
|
}) => Promise<void>;
|
|
@@ -27,25 +45,25 @@ interface ServerCallOptions {
|
|
|
27
45
|
shardKey?: string;
|
|
28
46
|
}
|
|
29
47
|
/**
|
|
30
|
-
* Run a query once on the server and return its result — the standalone
|
|
31
|
-
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
32
|
-
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
33
|
-
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
34
|
-
*
|
|
35
|
-
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
36
|
-
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
37
|
-
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
38
|
-
* avoid rebuilding the transport each time. Errors propagate.
|
|
39
|
-
*/
|
|
48
|
+
* Run a query once on the server and return its result — the standalone
|
|
49
|
+
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
50
|
+
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
51
|
+
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
52
|
+
*
|
|
53
|
+
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
54
|
+
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
55
|
+
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
56
|
+
* avoid rebuilding the transport each time. Errors propagate.
|
|
57
|
+
*/
|
|
40
58
|
declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
41
59
|
/**
|
|
42
|
-
* Run a mutation once on the server and return its result. Server-side calls go
|
|
43
|
-
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
44
|
-
* client-only and never engage here. Errors propagate.
|
|
45
|
-
*/
|
|
60
|
+
* Run a mutation once on the server and return its result. Server-side calls go
|
|
61
|
+
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
62
|
+
* client-only and never engage here. Errors propagate.
|
|
63
|
+
*/
|
|
46
64
|
declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
47
65
|
/**
|
|
48
|
-
* Run an action once on the server and return its result. Errors propagate.
|
|
49
|
-
*/
|
|
66
|
+
* Run an action once on the server and return its result. Errors propagate.
|
|
67
|
+
*/
|
|
50
68
|
declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
51
69
|
export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
package/dist/server.d.ts
CHANGED
|
@@ -4,20 +4,38 @@ import { ServerClientOptions } from '@lunora/client/ssr';
|
|
|
4
4
|
export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
6
|
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
9
|
+
* Server-side data-loading helpers for React Server Components.
|
|
10
|
+
*
|
|
11
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
12
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
13
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
14
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
15
|
+
* `@lunora/react`, which is a client boundary.
|
|
16
|
+
*
|
|
17
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
18
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
19
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
20
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
21
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
22
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
23
|
+
* `usePreloadedQuery`.
|
|
24
|
+
*/
|
|
25
|
+
type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
|
|
26
|
+
/**
|
|
27
|
+
* Run a query on the server and seed `queryClient` with the result under the
|
|
28
|
+
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
|
29
|
+
* `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
|
|
30
|
+
* flash, no duplicate fetch on the client.
|
|
31
|
+
*
|
|
32
|
+
* Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
|
|
33
|
+
* from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
|
|
34
|
+
* the client subtree in `HydrationBoundary`, and the client hooks pick the value
|
|
35
|
+
* up from cache. Errors propagate — wrap the call if you'd rather render a
|
|
36
|
+
* fallback than fail the server render. Drop the `await` for fire-and-forget
|
|
37
|
+
* prefetch when you don't need the data present on the very first paint.
|
|
38
|
+
*/
|
|
21
39
|
declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
|
|
22
40
|
shardKey?: string;
|
|
23
41
|
}) => Promise<void>;
|
|
@@ -27,25 +45,25 @@ interface ServerCallOptions {
|
|
|
27
45
|
shardKey?: string;
|
|
28
46
|
}
|
|
29
47
|
/**
|
|
30
|
-
* Run a query once on the server and return its result — the standalone
|
|
31
|
-
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
32
|
-
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
33
|
-
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
34
|
-
*
|
|
35
|
-
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
36
|
-
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
37
|
-
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
38
|
-
* avoid rebuilding the transport each time. Errors propagate.
|
|
39
|
-
*/
|
|
48
|
+
* Run a query once on the server and return its result — the standalone
|
|
49
|
+
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
50
|
+
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
51
|
+
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
52
|
+
*
|
|
53
|
+
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
54
|
+
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
55
|
+
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
56
|
+
* avoid rebuilding the transport each time. Errors propagate.
|
|
57
|
+
*/
|
|
40
58
|
declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
41
59
|
/**
|
|
42
|
-
* Run a mutation once on the server and return its result. Server-side calls go
|
|
43
|
-
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
44
|
-
* client-only and never engage here. Errors propagate.
|
|
45
|
-
*/
|
|
60
|
+
* Run a mutation once on the server and return its result. Server-side calls go
|
|
61
|
+
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
62
|
+
* client-only and never engage here. Errors propagate.
|
|
63
|
+
*/
|
|
46
64
|
declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
47
65
|
/**
|
|
48
|
-
* Run an action once on the server and return its result. Errors propagate.
|
|
49
|
-
*/
|
|
66
|
+
* Run an action once on the server and return its result. Errors propagate.
|
|
67
|
+
*/
|
|
50
68
|
declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
51
69
|
export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
package/dist/server.mjs
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
3
|
-
import { l as lunoraQueryKey } from './packem_shared/query-key-B5eRQCbR.mjs';
|
|
4
|
-
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-Cij4KWBK.mjs';
|
|
5
|
-
export { preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
6
|
-
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
-
|
|
8
|
-
const prefetchQuery = async (queryClient, client, function_, args, options = {}) => {
|
|
9
|
-
const argsRecord = args ?? {};
|
|
10
|
-
await queryClient.prefetchQuery({
|
|
11
|
-
queryFn: () => client.query(function_, argsRecord, {
|
|
12
|
-
shardKey: options.shardKey
|
|
13
|
-
}),
|
|
14
|
-
queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
|
|
15
|
-
// Match the client hooks: Lunora is push-driven, so the seeded value is
|
|
16
|
-
// never considered stale by TanStack — the WS subscription that attaches
|
|
17
|
-
// on mount is the only freshness signal.
|
|
18
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const fetchQuery = async (options, function_, args, callOptions = {}) => createServerClient(options).query(function_, args, {
|
|
22
|
-
shardKey: callOptions.shardKey
|
|
23
|
-
});
|
|
24
|
-
const fetchMutation = async (options, function_, args, callOptions = {}) => createServerClient(options).mutation(function_, args, {
|
|
25
|
-
shardKey: callOptions.shardKey
|
|
26
|
-
});
|
|
27
|
-
const fetchAction = async (options, function_, args, callOptions = {}) => createServerClient(options).action(function_, args, {
|
|
28
|
-
shardKey: callOptions.shardKey
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
|
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-C6iUhRuD.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-B5PEocLy.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};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { RestrictionError, UploadControl, UploadError,
|
|
2
|
+
/**
|
|
3
|
+
* `@lunora/react/upload` — end-user file-upload hooks.
|
|
4
|
+
*
|
|
5
|
+
* A thin re-export of `@visulima/storage-client`'s React upload hooks (Lunora
|
|
6
|
+
* does not hand-roll the uploader). `useUpload` auto-selects TUS / chunked-REST /
|
|
7
|
+
* multipart by file size; the TUS path gives live progress, pause/resume and
|
|
8
|
+
* resume-after-a-dropped-connection. Point the hook's endpoint at a route backed
|
|
9
|
+
* by `@lunora/storage/upload`'s RLS-gated handler — end-user uploads gated by
|
|
10
|
+
* _your_ per-user policy, not an `adminToken`.
|
|
11
|
+
*
|
|
12
|
+
* ### TanStack Query
|
|
13
|
+
*
|
|
14
|
+
* The upload hooks re-exported here (`useUpload`, `useMultipartUpload`,
|
|
15
|
+
* `useTusUpload`, `useChunkedRestUpload`, `useFileInput`, `usePasteUpload`) hold
|
|
16
|
+
* their own state and need no `QueryClientProvider`. `@visulima/storage-client`'s
|
|
17
|
+
* _data_ hooks (`useGetFileList` etc.) do use TanStack Query — and `LunoraProvider`
|
|
18
|
+
* already mounts a `QueryClient`, so they work inside a Lunora app without extra
|
|
19
|
+
* wiring. That is the reconciliation: Lunora's own `useQuery` and the visulima
|
|
20
|
+
* upload hooks coexist because the upload hooks never touch the query cache.
|
|
21
|
+
*/
|
|
22
|
+
type UploadRestrictions } from '@visulima/storage-client';
|
|
23
|
+
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';
|