@lunora/react 1.0.0-alpha.53 → 1.0.0-alpha.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- 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-D_rXos5T.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-CfPk_sQ5.mjs +2 -0
- package/dist/packem_shared/lunoraQueryOptions-BtQVkawu.mjs +1 -0
- package/dist/packem_shared/query-key-moRe2f9b.mjs +1 -0
- package/dist/packem_shared/stable-key-BrNca3-v.mjs +1 -0
- package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
- package/dist/packem_shared/use-paginated-core-K_o1A7Jq.mjs +2 -0
- package/dist/packem_shared/useAgent-CDYDXIho.mjs +2 -0
- package/dist/packem_shared/useAgentChat-BosdEevp.mjs +2 -0
- package/dist/packem_shared/useAgentState-DybEIPYC.mjs +2 -0
- package/dist/packem_shared/useAgentToolEvents-BiKsdLnM.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-CmYP4Qo-.mjs +2 -0
- package/dist/packem_shared/useHttpStream-ByeMRVTu.mjs +2 -0
- package/dist/packem_shared/useInfiniteQuery-TifTSFTs.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-4-0SLkx7.mjs +2 -0
- package/dist/packem_shared/usePresence-D5NOA_TJ.mjs +2 -0
- package/dist/packem_shared/useQuery-CBd7O0N9.mjs +2 -0
- package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
- package/dist/packem_shared/useStream-OBLaiEg1.mjs +2 -0
- package/dist/packem_shared/useSubscription-BkLhTX0w.mjs +2 -0
- package/dist/packem_shared/useVoiceAgent-BziH3D-1.mjs +2 -0
- package/dist/packem_shared/wire-key-Cd5pGxbN.mjs +1 -0
- package/dist/server.d.mts +19 -1
- package/dist/server.d.ts +19 -1
- package/dist/server.mjs +1 -1
- package/dist/upload.d.mts +22 -1
- package/dist/upload.d.ts +22 -1
- package/package.json +3 -3
- package/dist/packem_shared/AuthLoading-C5eyDVbk.mjs +0 -2
- package/dist/packem_shared/CheckoutButton-DS_DKgNf.mjs +0 -2
- package/dist/packem_shared/LunoraProvider-D6ZS72le.mjs +0 -2
- package/dist/packem_shared/cache-DJEsSdUx.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-BvPwhOFD.mjs +0 -2
- package/dist/packem_shared/lunoraQueryOptions-DWEJoNnh.mjs +0 -1
- package/dist/packem_shared/query-key-DV_Vu-6c.mjs +0 -1
- package/dist/packem_shared/stable-key-BSG0zK_E.mjs +0 -1
- package/dist/packem_shared/stream-state-ksURgmCA.mjs +0 -1
- package/dist/packem_shared/use-paginated-core-_ZSkVafW.mjs +0 -2
- package/dist/packem_shared/useAgent-0Ozf4MwG.mjs +0 -2
- package/dist/packem_shared/useAgentChat-BoY3nZvn.mjs +0 -2
- package/dist/packem_shared/useAgentState-CyY_I9m2.mjs +0 -2
- package/dist/packem_shared/useAgentToolEvents-D24tT5t_.mjs +0 -2
- package/dist/packem_shared/useAuth-BKsFAcDG.mjs +0 -2
- package/dist/packem_shared/useAuthSessions-DCiiklg1.mjs +0 -2
- package/dist/packem_shared/useAuthState-DrW2_avK.mjs +0 -2
- package/dist/packem_shared/useClientQuery-DFKZurlC.mjs +0 -2
- package/dist/packem_shared/useConnectionStatus-CiMP3Mmy.mjs +0 -2
- package/dist/packem_shared/useFlag-Bj6cjeim.mjs +0 -2
- package/dist/packem_shared/useHttpStream-6Mx4bTfB.mjs +0 -2
- package/dist/packem_shared/useInfiniteQuery-CgT2zfA-.mjs +0 -2
- package/dist/packem_shared/useMutation-C_8Nu0F4.mjs +0 -2
- package/dist/packem_shared/useMutator-D3CGrk5-.mjs +0 -2
- package/dist/packem_shared/usePaginatedQuery-CSs8g5Z7.mjs +0 -2
- package/dist/packem_shared/usePresence-Bfa9ESum.mjs +0 -2
- package/dist/packem_shared/useQuery-CDk67eFh.mjs +0 -2
- package/dist/packem_shared/useRateLimit-DqikMrX9.mjs +0 -2
- package/dist/packem_shared/useStream-AQlldZGN.mjs +0 -2
- package/dist/packem_shared/useSubscription-CoFTfvYX.mjs +0 -2
- package/dist/packem_shared/useVoiceAgent-CO0EiOoc.mjs +0 -2
- package/dist/packem_shared/wire-key-BjAV3_Rq.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,9 @@ import { QueryClient } from '@tanstack/react-query';
|
|
|
5
5
|
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
|
|
6
6
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
7
7
|
export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
|
|
8
|
+
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
8
9
|
export { RestrictionError, UploadControl, UploadError, type UploadRestrictions } from '@visulima/storage-client';
|
|
9
10
|
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';
|
|
10
|
-
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
11
11
|
interface AuthGateProps {
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { QueryClient } from '@tanstack/react-query';
|
|
|
5
5
|
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
|
|
6
6
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
7
7
|
export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
|
|
8
|
+
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
8
9
|
export { RestrictionError, UploadControl, UploadError, type UploadRestrictions } from '@visulima/storage-client';
|
|
9
10
|
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';
|
|
10
|
-
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
11
11
|
interface AuthGateProps {
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{AuthLoading as t,Authenticated as o,Unauthenticated as u}from"./packem_shared/AuthLoading-
|
|
2
|
+
import{AuthLoading as t,Authenticated as o,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-BtQVkawu.mjs";import{useAuthSessions as A,useAuthUsers as c,useImpersonate as C,useOrganizations as U}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as E}from"./packem_shared/useAgent-CDYDXIho.mjs";import{useAgentChat as Q}from"./packem_shared/useAgentChat-BosdEevp.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-DybEIPYC.mjs";import{useAgentToolEvents as F}from"./packem_shared/useAgentToolEvents-BiKsdLnM.mjs";import{default as k}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as b}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as z}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-CmYP4Qo-.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-ByeMRVTu.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-TifTSFTs.mjs";import{useMutation as D}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as J}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as N}from"./packem_shared/usePaginatedQuery-4-0SLkx7.mjs";import{hydratePreloaded as X,default as Y}from"./packem_shared/hydratePreloaded-CfPk_sQ5.mjs";import{usePresence as _}from"./packem_shared/usePresence-D5NOA_TJ.mjs";import{default as ee}from"./packem_shared/useQuery-CBd7O0N9.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as ue}from"./packem_shared/useStream-OBLaiEg1.mjs";import{default as ae}from"./packem_shared/useSubscription-BkLhTX0w.mjs";import{useVoiceAgent as fe}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as me,getErrorCode as ie,getRetryAfterMs as de,isConflictError as xe,isForbiddenError as le,isRateLimitedError as he,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as ce,UploadControl as Ce,UploadError as Ue}from"@visulima/storage-client";import{useChunkedRestUpload as Ee,useFileInput as Pe,useMultipartUpload as Qe,usePasteUpload as Se,useTusUpload as Le,useUpload as Re}from"@visulima/storage-client/react";export{t as AuthLoading,o as Authenticated,i as CheckoutButton,d as CustomerPortalButton,f as LunoraProvider,ce as RestrictionError,u as Unauthenticated,Ce as UploadControl,Ue as UploadError,me as createClientQuery,ie as getErrorCode,de as getRetryAfterMs,X as hydratePreloaded,xe as isConflictError,le as isForbiddenError,he as isRateLimitedError,ge as isUnauthorizedError,h as lunoraQueryOptions,E as useAgent,Q as useAgentChat,L as useAgentState,F as useAgentToolEvents,k as useAuth,A as useAuthSessions,a as useAuthState,c as useAuthUsers,x as useCheckout,Ee as useChunkedRestUpload,b as useClientQuery,z as useConnectionStatus,Pe as useFileInput,O as useFlag,T as useFlags,V as useHttpStream,C as useImpersonate,q as useInfiniteQuery,n as useLunora,Qe as useMultipartUpload,D as useMutation,J as useMutator,U as useOrganizations,N as usePaginatedQuery,Se as usePasteUpload,Y as usePreloadedQuery,_ as usePresence,ee as useQuery,te as useRateLimit,ue as useStream,ae as useSubscription,Le as useTusUpload,Re as useUpload,fe 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-moRe2f9b.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-D_rXos5T.mjs";import{useLunora as Q}from"./LunoraProvider-DC06S-p1.mjs";import{l as h,s as q}from"./query-key-moRe2f9b.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-moRe2f9b.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-Cd5pGxbN.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 @@
|
|
|
1
|
+
const c=(t,e)=>t<e?-1:t>e?1:0,s=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(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(r=>s(r)).join(",")}]`;const e=Object.getPrototypeOf(t);if(e!==null&&e!==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 n=t,a=Object.keys(n).toSorted(c),o=[];for(const r of a){const i=n[r];i!==void 0&&o.push(`${JSON.stringify(r)}:${s(i)}`)}return`{${o.join(",")}}`};export{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-D_rXos5T.mjs";import{useLunora as N}from"./LunoraProvider-DC06S-p1.mjs";import{s as i,l as q}from"./query-key-moRe2f9b.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 v}from"react/compiler-runtime";import{useMutation as M}from"./useMutation-BnKec7bE.mjs";import w from"./useSubscription-BkLhTX0w.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-OBLaiEg1.mjs";import L from"./useSubscription-BkLhTX0w.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-BkLhTX0w.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-OBLaiEg1.mjs";import N from"./useSubscription-BkLhTX0w.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-BrNca3-v.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-BrNca3-v.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-K_o1A7Jq.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-K_o1A7Jq.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=(e="sess")=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const s=crypto.getRandomValues(new Uint8Array(16));return`${e}-${Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}`}}return`${e}-${Date.now().toString(36)}`},A=1e4,$=(e,s)=>{const n=E(),{heartbeat:f,intervalMs:l=A,listPresent:y,shardKey:r}=s,c=U(()=>s.sessionId??L(),[s.sessionId]),[v,I]=D(void 0),d=b(s.data),m=b({client:n,heartbeat:f,roomId:e,sessionId:c,shardKey:r});a(()=>{m.current={client:n,heartbeat:f,roomId:e,sessionId:c,shardKey:r}});const o=p(()=>{const{client:t,heartbeat:i,roomId:u,sessionId:g,shardKey:S}=m.current,R={roomId:u,sessionId:g,...d.current===void 0?{}:{data:d.current}};t.mutation(i,R,{shardKey:S}).catch(()=>{})},[]),h=p(t=>{d.current=t,o()},[o]);return a(()=>{o();const t=setInterval(o,l),i=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),()=>{clearInterval(t),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}},[o,l]),a(()=>n.acquireConnectionContext({roomId:e,sessionId:c},{shardKey:r}),[n,e,c,r]),a(()=>{let t=!1;const i=n.subscribe(y,{roomId:e},u=>{t||I(u)},{shardKey:r});return()=>{t=!0,i()}},[n,y.__lunoraRef,e,r]),{present:v,sessionId:c,setData:h}};export{$ 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-D_rXos5T.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-moRe2f9b.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-Cd5pGxbN.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-Cd5pGxbN.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-BrNca3-v.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,7 +4,25 @@ 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
|
+
/**
|
|
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";
|
|
8
26
|
/**
|
|
9
27
|
* Run a query on the server and seed `queryClient` with the result under the
|
|
10
28
|
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
package/dist/server.d.ts
CHANGED
|
@@ -4,7 +4,25 @@ 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
|
+
/**
|
|
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";
|
|
8
26
|
/**
|
|
9
27
|
* Run a query on the server and seed `queryClient` with the result under the
|
|
10
28
|
* 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
|
|
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-moRe2f9b.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-BtQVkawu.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};
|
package/dist/upload.d.mts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
export { RestrictionError, UploadControl, UploadError,
|
|
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';
|
|
2
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';
|
package/dist/upload.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
export { RestrictionError, UploadControl, UploadError,
|
|
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';
|
|
2
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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/react",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.54",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lunora/client": "1.0.0-alpha.
|
|
56
|
+
"@lunora/client": "1.0.0-alpha.50",
|
|
57
57
|
"@lunora/errors": "1.0.0-alpha.21",
|
|
58
58
|
"@lunora/ratelimit": "1.0.0-alpha.22",
|
|
59
|
-
"@visulima/storage-client": "1.0.
|
|
59
|
+
"@visulima/storage-client": "1.0.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@tanstack/react-query": "^5.101.0",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useAuthState as i}from"./useAuthState-DrW2_avK.mjs";const a=t=>{const{children:n}=t,{isAuthenticated:e}=i();return e?n:void 0},r=t=>{const{children:n}=t,{isAuthenticated:e,isLoading:d}=i();return!d&&!e?n:void 0},s=t=>{const{children:n}=t,{isLoading:e}=i();return e?n:void 0};export{s as AuthLoading,a as Authenticated,r as Unauthenticated};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as f}from"react/compiler-runtime";import{useState as E,useCallback as C}from"react";import{jsx as m}from"react/jsx-runtime";const y=a=>{const r=new URL(a,globalThis.location.href);if(r.protocol!=="https:"&&r.protocol!=="http:")throw new Error(`refusing to redirect to a non-http(s) URL: ${r.protocol}`);return r.href},N=a=>{const[r,t]=E(!1),[e,l]=E(void 0);return{checkout:C(async()=>{t(!0),l(void 0);try{const o=await a();globalThis.location.assign(y(o.url))}catch(o){const i=o instanceof Error?o:new Error(String(o));throw l(i),i}finally{t(!1)}},[a]),error:e,pending:r}},k=a=>{const r=f(11),{"aria-label":t,children:e,className:l,disabled:o,onError:i,title:n,trigger:d}=a,{checkout:c,pending:s}=N(d);let u;r[0]!==c||r[1]!==i?(u=()=>{c().catch(p=>{const w=p instanceof Error?p:new Error(String(p));i?.(w)})},r[0]=c,r[1]=i,r[2]=u):u=r[2];const b=u,g=o===!0||s;let h;return r[3]!==t||r[4]!==e||r[5]!==l||r[6]!==b||r[7]!==s||r[8]!==g||r[9]!==n?(h=m("button",{"aria-busy":s,"aria-label":t,className:l,disabled:g,onClick:b,title:n,type:"button",children:e}),r[3]=t,r[4]=e,r[5]=l,r[6]=b,r[7]=s,r[8]=g,r[9]=n,r[10]=h):h=r[10],h},S=a=>{const r=f(11);let t,e;r[0]!==a?({onCheckout:t,...e}=a,r[0]=a,r[1]=t,r[2]=e):(t=r[1],e=r[2]);const{"aria-label":l,children:o,className:i,disabled:n,onError:d,title:c}=e;let s;return r[3]!==l||r[4]!==o||r[5]!==i||r[6]!==n||r[7]!==t||r[8]!==d||r[9]!==c?(s=m(k,{"aria-label":l,className:i,disabled:n,onError:d,title:c,trigger:t,children:o}),r[3]=l,r[4]=o,r[5]=i,r[6]=n,r[7]=t,r[8]=d,r[9]=c,r[10]=s):s=r[10],s},v=a=>{const r=f(11);let t,e;r[0]!==a?({onPortal:t,...e}=a,r[0]=a,r[1]=t,r[2]=e):(t=r[1],e=r[2]);const{"aria-label":l,children:o,className:i,disabled:n,onError:d,title:c}=e;let s;return r[3]!==l||r[4]!==o||r[5]!==i||r[6]!==n||r[7]!==d||r[8]!==t||r[9]!==c?(s=m(k,{"aria-label":l,className:i,disabled:n,onError:d,title:c,trigger:t,children:o}),r[3]=l,r[4]=o,r[5]=i,r[6]=n,r[7]=d,r[8]=t,r[9]=c,r[10]=s):s=r[10],s};export{S as CheckoutButton,v as CustomerPortalButton,N as useCheckout};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as I}from"react/compiler-runtime";import{LunoraError as y}from"@lunora/errors";import{QueryClientContext as C,QueryClientProvider as L,QueryClient as h}from"@tanstack/react-query";import{createContext as N,use as d,useState as T}from"react";import{jsx as c}from"react/jsx-runtime";const f=N(null),v=()=>new h({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),b=t=>{const e=I(9),{children:m,client:a,queryClient:n}=t,r=d(C);let o;e[0]!==r||e[1]!==n?(o=()=>n??r??v(),e[0]=r,e[1]=n,e[2]=o):o=e[2];const[p]=T(o),i=n??r??p;let u;e[3]!==m||e[4]!==a?(u=c(f,{value:a,children:m}),e[3]=m,e[4]=a,e[5]=u):u=e[5];const s=u;if(r===i)return s;let l;return e[6]!==s||e[7]!==i?(l=c(L,{client:i,children:s}),e[6]=s,e[7]=i,e[8]=l):l=e[8],l},q=()=>{const t=d(f);if(!t)throw new y("INTERNAL","useLunora must be used inside <LunoraProvider />");return t};export{b as LunoraProvider,q as useLunora};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as u}from"./query-key-DV_Vu-6c.mjs";class f{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return u(e)}attach(e,n,c,o,h,b={}){const s=u(n);let r=this.entries.get(s);if(!r){r={pollTimer:void 0,refCount:0,unsubscribe:void 0},this.entries.set(s,r);try{r.unsubscribe=this.client.subscribe(c,o,t=>{e.setQueryData(n,t)},{shardKey:h})}catch{r.pollTimer=setInterval(()=>{e.invalidateQueries({queryKey:n}).catch(()=>{})},b.pollIntervalMs??5e3)}}r.refCount+=1;let l=!1;return()=>{if(l)return;l=!0;const t=this.entries.get(s);t&&(t.refCount-=1,t.refCount<=0&&(t.unsubscribe?.(),t.pollTimer&&clearInterval(t.pollTimer),this.entries.delete(s)))}}}const a=new WeakMap,m=i=>{let e=a.get(i);return e||(e=new f(i),a.set(i,e)),e};export{m as b};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as l}from"react/compiler-runtime";import{useQueryClient as d,useQuery as p}from"@tanstack/react-query";import{useEffect as h}from"react";import{b as I}from"./cache-DJEsSdUx.mjs";import{useLunora as q}from"./LunoraProvider-D6ZS72le.mjs";import{i as K,y as N}from"./query-key-DV_Vu-6c.mjs";const P=function(o){const r=l(4),e=q(),t=d(),{args:u,functionPath:c,shardKey:i,value:s}=o,n={__lunoraRef:c},m=N(n,u,i),{data:y}=p({initialData:s,queryFn:()=>e.query(n,u,{shardKey:i}),queryKey:m,staleTime:Number.POSITIVE_INFINITY}),f=K(m);let a;return r[0]!==e||r[1]!==t||r[2]!==f?(a=[e,t,f],r[0]=e,r[1]=t,r[2]=f,r[3]=a):a=r[3],h(()=>I(e).attach(t,m,n,u,i),a),y===void 0?s:y},F=function(o){return P(o)};export{P as default,F as hydratePreloaded};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as s}from"./query-key-DV_Vu-6c.mjs";const u=(n,r,o,e={})=>{const y=o??{};return{queryFn:()=>n.query(r,y,{shardKey:e.shardKey}),queryKey:s(r,y,e.shardKey),staleTime:Number.POSITIVE_INFINITY}};export{u as lunoraQueryOptions};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as n}from"./wire-key-BjAV3_Rq.mjs";const t=o=>n(o),a=(o,r,l)=>["lunora",o.__lunoraRef,r,l??null],e=o=>t(o);export{e as i,t as r,a as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const y=(e,t)=>e<t?-1:e>t?1:0,s=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>s(r)).join(",")}]`;const t=Object.getPrototypeOf(e);if(t!==null&&t!==Object.prototype){const r=e.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 n=e,a=Object.keys(n).toSorted(y),i=[];for(const r of a){const o=n[r];o!==void 0&&i.push(`${JSON.stringify(r)}:${s(o)}`)}return`{${i.join(",")}}`};export{s as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const u=function(r,t){switch(t.type){case"chunk":return{chunks:[...r.chunks,t.chunk],error:void 0,status:"streaming"};case"complete":return{...r,status:"complete"};case"error":return{...r,error:t.error,status:"error"};case"reset":return{chunks:[],error:void 0,status:"idle"};case"start":return{...r,status:"streaming"};default:return r}},a=function(r,t){let n=!0,c=!1;const s=()=>{c||(c=!0,r.cancel())};return(async()=>{try{for await(const e of r){if(!n)return;t({chunk:e,type:"chunk"})}n&&t({type:"complete"})}catch(e){if(!n)return;t({error:e instanceof Error?e:new Error(String(e)),type:"error"})}})().catch(()=>{}),{cancel:s,cleanup:()=>{n=!1,s()}}};export{u as o,a as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{initialPages as R,rebalance as O,derivePaginationStatus as S,applyLoadMore as P}from"@lunora/client/pagination";import{useQueryClient as j}from"@tanstack/react-query";import{useRef as d,useReducer as B,useState as E,useEffect as m,useCallback as N}from"react";import{b as T}from"./cache-DJEsSdUx.mjs";import{useLunora as $}from"./LunoraProvider-D6ZS72le.mjs";import{i,y as I}from"./query-key-DV_Vu-6c.mjs";const z=function(o){const f=d(void 0);return f.current??=o(),f},X=function(o,f,x){const a=$(),n=j(),{initialNumItems:g,shardKey:p}=x,u=f==="skip",y=u?{}:f,[,L]=B(e=>e+1,0),[w,h]=E(()=>R(g)),k=`${i(I(o,y,p))}::${String(g)}`,A=d(k);A.current!==k&&(A.current=k,h(R(g)));const l=w.map(e=>{const t={...y,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},s=I(o,t,p);return{args:t,key:s}}),M=l.map(({key:e})=>i(e)).join("|"),K=d({baseArgs:y,entries:[],fn:o,shardKey:p});m(()=>{K.current={baseArgs:y,entries:l,fn:o,shardKey:p}});const v=z(()=>new Map),Q=d(a);m(()=>{const e=v.current;if(Q.current!==a){for(const r of e.values())r();e.clear(),Q.current=a}if(u){for(const r of e.values())r();e.clear();return}const t=K.current,s=T(a),b=new Set(t.entries.map(({key:r})=>i(r)));for(const[r,c]of e)b.has(r)||(c(),e.delete(r));for(const r of t.entries){const c=i(r.key);e.has(c)||(n.fetchQuery({queryFn:()=>a.query(t.fn,r.args,{shardKey:t.shardKey}),queryKey:r.key,staleTime:0}).catch(()=>{}),e.set(c,s.attach(n,r.key,t.fn,r.args,t.shardKey)))}},[a,n,M,u]),m(()=>()=>{for(const e of v.current.values())e();v.current.clear()},[]),m(()=>n.getQueryCache().subscribe(e=>{if(e.type!=="updated")return;const t=i(e.query.queryKey);l.some(({key:s})=>i(s)===t)&&L()}),[n,M]);const C=u?[]:l.map(({key:e})=>n.getQueryData(e));m(()=>{if(u)return;const e=O(w,C);e&&h(e)});const{status:D}=S(u,C);return{loadMore:N(e=>{h(t=>{const s=K.current,b=t.map(q=>{const F={...s.baseArgs,paginationOpts:{cursor:q.lower,endCursor:q.upper,numItems:q.numItems}};return n.getQueryData(I(s.fn,F,s.shardKey))}),{nextCursor:r,status:c}=S(!1,b);return P(t,c==="CanLoadMore"?r:void 0,e)??t})},[n]),pageResults:C,status:D}};export{X as B};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as T}from"react/compiler-runtime";import{useMutation as h}from"./useMutation-C_8Nu0F4.mjs";import $ from"./useSubscription-CoFTfvYX.mjs";const b={__lunoraRef:""},M=f=>{const t=T(17),{api:w,cancel:a,run:A,runArgs:u,threadKey:e}=f,r=h(A),K=h(a??b);let s;t[0]!==e?(s={key:e},t[0]=e,t[1]=s):s=t[1];const{data:_}=$(w.agents.agentThread,s),n=_,p=n?.status,i=n?.instanceId,{mutate:g}=r,{mutate:l}=K;let o;t[2]!==u||t[3]!==g||t[4]!==e?(o=async(v,I)=>{await g({input:v,threadKey:e,...u,...I})},t[2]=u,t[3]=g,t[4]=e,t[5]=o):o=t[5];const m=o;let c;t[6]!==l||t[7]!==a||t[8]!==i||t[9]!==e?(c=async()=>{a===void 0||i===void 0||await l({instanceId:i,threadKey:e})},t[6]=l,t[7]=a,t[8]=i,t[9]=e,t[10]=c):c=t[10];const y=c;let d;return t[11]!==y||t[12]!==m||t[13]!==r.pending||t[14]!==p||t[15]!==n?(d={cancel:y,pending:r.pending,run:m,status:p,thread:n},t[11]=y,t[12]=m,t[13]=r.pending,t[14]=p,t[15]=n,t[16]=d):d=t[16],d};export{M as useAgent};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as W,maxSeq as X}from"@lunora/client";import{useState as it,useRef as ct}from"react";import{useMutation as Q}from"./useMutation-C_8Nu0F4.mjs";import{useStream as lt}from"./useStream-AQlldZGN.mjs";import Y from"./useSubscription-CoFTfvYX.mjs";const mt={__lunoraRef:""},ut={__lunoraRef:""},dt=[],St=c=>{const t=rt(47),{api:K,cancel:m,limit:u,send:Z,sendArgs:C,stream:d,threadKey:e}=c;let p;t[0]!==u||t[1]!==e?(p=u===void 0?{key:e}:{key:e,limit:u},t[0]=u,t[1]=e,t[2]=p):p=t[2];const B=p,{data:G}=Y(K.agents.agentMessages,B);let f;t[3]!==e?(f={key:e},t[3]=e,t[4]=f):f=t[4];const{data:H}=Y(K.agents.agentThread,f);let h;t[5]!==d||t[6]!==e?(h=d===void 0?"skip":{key:e},t[5]=d,t[6]=e,t[7]=h):h=t[7];const J=h,{chunks:R}=lt(d??ut,J),tt=Q(Z),et=Q(m??mt),nt=Q(K.agents.agentResolveApproval);let g;t[8]===Symbol.for("react.memo_cache_sentinel")?(g=[],t[8]=g):g=t[8];const[$,U]=it(g),j=ct(0),V=H,q=V?.status,o=V?.instanceId,s=G??dt;let y;if(t[9]!==s||t[10]!==$){const n=W($,s),a=X(s);y=n.length===0?s:[...s,...n.map((r,N)=>({content:r.content,optimistic:!0,role:"user",seq:a+1+N}))],t[9]=s,t[10]=$,t[11]=y}else y=t[11];const b=y;let v;t[12]!==s?(v=s.filter(pt),t[12]=s,t[13]=v):v=t[13];const l=v.length;let k;if(t[14]!==l||t[15]!==R||t[16]!==e){let n;t[18]!==l||t[19]!==e?(n=a=>a.kind!=="progress"&&a.threadKey===e&&a.turn>=l,t[18]=l,t[19]=e,t[20]=n):n=t[20],k=R.filter(n).map(ft).join(""),t[14]=l,t[15]=R,t[16]=e,t[17]=k}else k=t[17];const E=k,{mutate:M}=tt,{mutate:T}=et,{mutate:D}=nt;let w;t[21]!==s||t[22]!==C||t[23]!==M||t[24]!==e?(w=async(n,a)=>{const r=j.current;j.current=j.current+1;const N=X(s);U(P=>[...W(P,s),{content:n,id:r,maxDurableSeqAtSend:N}]);try{await M({input:n,threadKey:e,...C,...a})}catch(P){const st=P;throw U(at=>at.filter(ot=>ot.id!==r)),st}},t[21]=s,t[22]=C,t[23]=M,t[24]=e,t[25]=w):w=t[25];const O=w;let S;t[26]!==o||t[27]!==D||t[28]!==e?(S=async(n,a,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${n} — no in-flight run (thread has no instanceId)`);await D({decision:n,instanceId:o,threadKey:e,toolCallId:a,...r===void 0?{}:{note:r}})},t[26]=o,t[27]=D,t[28]=e,t[29]=S):S=t[29];const i=S;let _;t[30]!==i?(_=(n,a)=>i("approve",n,a),t[30]=i,t[31]=_):_=t[31];const z=_;let x;t[32]!==i?(x=(n,a)=>i("reject",n,a),t[32]=i,t[33]=x):x=t[33];const F=x;let A;t[34]!==T||t[35]!==m||t[36]!==o||t[37]!==e?(A=async()=>{m===void 0||o===void 0||await T({instanceId:o,threadKey:e})},t[34]=T,t[35]=m,t[36]=o,t[37]=e,t[38]=A):A=t[38];const L=A;let I;return t[39]!==z||t[40]!==L||t[41]!==b||t[42]!==F||t[43]!==O||t[44]!==q||t[45]!==E?(I={approve:z,cancel:L,messages:b,reject:F,send:O,status:q,streamingText:E},t[39]=z,t[40]=L,t[41]=b,t[42]=F,t[43]=O,t[44]=q,t[45]=E,t[46]=I):I=t[46],I};function pt(c){return c.role==="assistant"}function ft(c){return c.text}export{St as useAgentChat};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c}from"react/compiler-runtime";import d from"./useSubscription-CoFTfvYX.mjs";const p=t=>{const e=c(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:s,error:o}=d(t.api.agents.agentState,r),n=s;let a;return e[2]!==o||e[3]!==n?(a={error:o,state:n},e[2]=o,e[3]=n,e[4]=a):a=e[4],a};export{p as useAgentState};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as v}from"react/compiler-runtime";import{useStream as g}from"./useStream-AQlldZGN.mjs";import y from"./useSubscription-CoFTfvYX.mjs";const I={__lunoraRef:""},k=[],N=l=>{if(l.role==="assistant"&&l.toolCalls)return l.toolCalls.map(o=>({input:o.input,seq:l.seq,toolCallId:o.id,toolName:o.name,type:"call"}));if(l.role==="tool")return l.status==="awaiting_approval"?[{seq:l.seq,type:"awaiting-approval",...l.toolCallId===void 0?{}:{toolCallId:l.toolCallId},...l.toolName===void 0?{}:{toolName:l.toolName}}]:[{output:l.content,seq:l.seq,type:"result",...l.status==="approved"||l.status==="rejected"?{status:l.status}:{},...l.toolCallId===void 0?{}:{toolCallId:l.toolCallId},...l.toolName===void 0?{}:{toolName:l.toolName}}]},_=l=>{const o=v(12),{api:m,limit:a,stream:s,threadKey:t}=l;let r;o[0]!==a||o[1]!==t?(r=a===void 0?{key:t}:{key:t,limit:a},o[0]=a,o[1]=t,o[2]=r):r=o[2];const c=r,{data:f}=y(m.agents.agentMessages,c);let i;o[3]!==s||o[4]!==t?(i=s===void 0?"skip":{key:t},o[3]=s,o[4]=t,o[5]=i):i=o[5];const C=i,{chunks:p}=g(s??I,C),u=f??k;let e;if(o[6]!==p||o[7]!==u||o[8]!==t){e=u.flatMap(q);for(const d of p)d.kind==="progress"&&d.threadKey===t&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});o[6]=p,o[7]=u,o[8]=t,o[9]=e}else e=o[9];let n;return o[10]!==e?(n={events:e},o[10]=e,o[11]=n):n=o[11],n};function q(l){return N(l)??[]}export{_ as useAgentToolEvents};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as m}from"react/compiler-runtime";import{useSyncExternalStore as f}from"react";import{useLunora as p}from"./LunoraProvider-D6ZS72le.mjs";const g=new WeakMap,T=t=>{const e=new Set;let r=null;const a=()=>{for(const n of e)n()};let o=0;const s=n=>{r!==n&&(r=n,a())},l=()=>{o+=1;const n=o;if(t.getAuthToken()===null){s(null);return}t.getCurrentUser().then(u=>{n===o&&s(u)}).catch(()=>{n===o&&s(null)})};let c;return{getSnapshot:()=>r,subscribe:n=>{const u=e.size===0;return e.add(n),u&&(c=t.onAuthTokenChange(l),l()),()=>{e.delete(n),e.size===0&&(c?.(),c=void 0)}}}},d=t=>{let e=g.get(t);return e||(e=T(t),g.set(t,e)),e},v=()=>{const t=m(12),e=p();let r;t[0]!==e?(r=d(e),t[0]=e,t[1]=r):r=t[1];const a=r;let o,s,l;t[2]!==e?(o=k=>e.onAuthTokenChange(k),s=()=>e.getAuthToken(),l=()=>e.getAuthToken(),t[2]=e,t[3]=o,t[4]=s,t[5]=l):(o=t[3],s=t[4],l=t[5]);const c=f(o,s,l),n=f(a.subscribe,a.getSnapshot,A);let u;t[6]!==e?(u=k=>{e.setAuthToken(k)},t[6]=e,t[7]=u):u=t[7];const i=u;let h;return t[8]!==i||t[9]!==c||t[10]!==n?(h={setToken:i,token:c,user:n},t[8]=i,t[9]=c,t[10]=n,t[11]=h):h=t[11],h};function A(){return null}export{v as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as y}from"react/compiler-runtime";import{useMutation as b,useQuery as F,keepPreviousData as v}from"@tanstack/react-query";import{useState as A,useSyncExternalStore as I}from"react";import{useLunora as S}from"./LunoraProvider-D6ZS72le.mjs";const D="lunora-react-admin-auth",P=50;function z(t,e,n,d={}){const{enabled:o=!0,pageSize:u=P}=d,[i,r]=A(u),l=I(f=>t.onAuthTokenChange(f),()=>t.currentIdentity(),()=>t.currentIdentity()),s=[D,l??"anon",...e,i],a=F({enabled:o,placeholderData:v,queryFn:()=>n(i),queryKey:s,staleTime:0}),c=a.data?.rows,h=a.data?.total,m=h!==void 0&&c!==void 0&&c.length<h,p=()=>{m&&r(f=>f+u)},g=()=>{a.refetch().catch(()=>{})};return{data:c,error:a.error??void 0,hasMore:m,loadMore:p,loading:a.isLoading,refetch:g,total:h}}const V=t=>{const e=y(20);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const d=n,o=S(),{enabled:u,filterField:i,filterValue:r,pageSize:l,search:s,searchField:a,sortBy:c,sortDirection:h}=d;let m;e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a||e[6]!==c||e[7]!==h?(m=["users",{filterField:i,filterValue:r,search:s,searchField:a,sortBy:c,sortDirection:h}],e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=c,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==o||e[10]!==i||e[11]!==r||e[12]!==s||e[13]!==a||e[14]!==c||e[15]!==h?(p=f=>o.listAuthUsers({filterField:i,filterValue:r,limit:f,search:s,searchField:a,sortBy:c,sortDirection:h}),e[9]=o,e[10]=i,e[11]=r,e[12]=s,e[13]=a,e[14]=c,e[15]=h,e[16]=p):p=e[16];let g;return e[17]!==u||e[18]!==l?(g={enabled:u,pageSize:l},e[17]=u,e[18]=l,e[19]=g):g=e[19],z(o,m,p,g)},k=t=>{const e=y(8);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const d=n,o=S(),{enabled:u,pageSize:i}=d;let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=["organizations"],e[2]=r):r=e[2];let l;e[3]!==o?(l=a=>o.listAuthOrganizations({limit:a}),e[3]=o,e[4]=l):l=e[4];let s;return e[5]!==u||e[6]!==i?(s={enabled:u,pageSize:i},e[5]=u,e[6]=i,e[7]=s):s=e[7],z(o,r,l,s)},q=t=>{const e=y(10);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const d=n,o=S(),{enabled:u,pageSize:i,userId:r}=d;let l;e[2]!==r?(l=["sessions",{userId:r}],e[2]=r,e[3]=l):l=e[3];let s;e[4]!==o||e[5]!==r?(s=c=>o.listAuthSessions({limit:c,userId:r}),e[4]=o,e[5]=r,e[6]=s):s=e[6];let a;return e[7]!==u||e[8]!==i?(a={enabled:u,pageSize:i},e[7]=u,e[8]=i,e[9]=a):a=e[9],z(o,l,s,a)},x=()=>{const t=y(10),e=S();let n;t[0]!==e?(n={mutationFn:a=>e.impersonateAuthUser({userId:a})},t[0]=e,t[1]=n):n=t[1];const d=b(n),{mutateAsync:o,reset:u}=d;let i;t[2]!==o?(i=a=>o(a),t[2]=o,t[3]=i):i=t[3];const r=i,l=d.error??void 0;let s;return t[4]!==r||t[5]!==d.data||t[6]!==d.isPending||t[7]!==u||t[8]!==l?(s={data:d.data,error:l,impersonate:r,pending:d.isPending,reset:u},t[4]=r,t[5]=d.data,t[6]=d.isPending,t[7]=u,t[8]=l,t[9]=s):s=t[9],s};export{q as useAuthSessions,V as useAuthUsers,x as useImpersonate,k as useOrganizations};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as i}from"react/compiler-runtime";import{useSyncExternalStore as s}from"react";import a from"./useAuth-BKsFAcDG.mjs";const c=()=>()=>{},S=()=>{const t=i(3),{token:u}=a(),o=s(c,f,m),e=o&&u!==null,n=!o;let r;return t[0]!==e||t[1]!==n?(r={isAuthenticated:e,isLoading:n},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function f(){return!0}function m(){return!1}export{S as useAuthState};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useCallback as u,useSyncExternalStore as i}from"react";import{useLunora as l}from"./LunoraProvider-D6ZS72le.mjs";const y=t=>{const e=l(),s=u(r=>e.subscribeClientQuery(t,()=>{r()}),[e,t.key]),n=i(s,()=>e.getClientQuery(t),()=>e.getClientQuery(t)),o=u(r=>{e.setClientQuery(t,r)},[e,t]);return[n,o]};export{y as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as a}from"react/compiler-runtime";import{useSyncExternalStore as s}from"react";import{useLunora as u}from"./LunoraProvider-D6ZS72le.mjs";const f=()=>{const t=a(4),o=u();let n,e,r;return t[0]!==o?(n=c=>o.onConnectionStatus(()=>{c()}),e=()=>o.connectionStatus(),r=()=>o.connectionStatus(),t[0]=o,t[1]=n,t[2]=e,t[3]=r):(n=t[1],e=t[2],r=t[3]),s(n,e,r)};export{f as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useState as _,useRef as y,useEffect as d}from"react";import{useLunora as h}from"./LunoraProvider-D6ZS72le.mjs";import{e as m}from"./stable-key-BSG0zK_E.mjs";const k="__lunora_flags__:eval",F=e=>{const t=typeof e;return t==="boolean"||t==="number"||t==="string"?t:"object"},v={__lunoraRef:k},A=(e,t,r)=>{const g=h(),[a,u]=_(t),c=F(t),n=r===void 0?"":m(r),s=`${e}::${c}::${n}`,f=y(s);f.current!==s&&(f.current=s,u(t));const l=y({context:r,defaultValue:t});return d(()=>{l.current={context:r,defaultValue:t}}),d(()=>{let i=!1;const{context:x,defaultValue:b}=l.current;u(b);let o;try{o=g.subscribe(v,{context:x,default:b,key:e,type:c},p=>{i||u(p)})}catch{return()=>{i=!0}}return()=>{i=!0,o()}},[g,e,c,n]),a},C=(e,t)=>{const r=h(),[g,a]=_(e),u=m(e),c=t===void 0?"":m(t),n=`${u}::${c}`,s=y(n);s.current!==n&&(s.current=n,a(e));const f=y({context:t,flags:e});return d(()=>{f.current={context:t,flags:e}}),d(()=>{let l=!1;const{context:i,flags:x}=f.current;a(x);const b=[];for(const[o,p]of Object.entries(x))try{b.push(r.subscribe(v,{context:i,default:p,key:o,type:F(p)},V=>{l||a(j=>({...j,[o]:V}))}))}catch{}return()=>{l=!0;for(const o of b)o()}},[r,u,c]),g};export{A as useFlag,C as useFlags};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as S}from"react/compiler-runtime";import{useReducer as $,useRef as v,useEffect as _}from"react";import{useLunora as b}from"./LunoraProvider-D6ZS72le.mjs";import{o as E,u as R}from"./stream-state-ksURgmCA.mjs";import{e as H}from"./stable-key-BSG0zK_E.mjs";const z=(r,s,a)=>{const e=S(24);let m;e[0]!==a?(m=a===void 0?{}:a,e[0]=a,e[1]=m):m=e[1];const u=m,c=b();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,n]=$(E,f),o=s==="skip";let p;e[3]!==s||e[4]!==o?(p=o?"skip":H(s),e[3]=s,e[4]=o,e[5]=p):p=e[5];const x=p,k=v(void 0);let i;e[6]!==s||e[7]!==c||e[8]!==u.maxBuffer||e[9]!==r||e[10]!==o?(i=()=>{if(o)return n({type:"reset"}),L;n({type:"reset"}),n({type:"start"});const{cancel:B,cleanup:y}=R(c.httpStream(r,s,{maxBuffer:u.maxBuffer}),n);return k.current=B,()=>{y(),k.current=void 0}},e[6]=s,e[7]=c,e[8]=u.maxBuffer,e[9]=r,e[10]=o,e[11]=i):i=e[11];let h;e[12]!==c||e[13]!==u.maxBuffer||e[14]!==r.method||e[15]!==r.path||e[16]!==x||e[17]!==o?(h=[c,r.method,r.path,x,o,u.maxBuffer],e[12]=c,e[13]=u.maxBuffer,e[14]=r.method,e[15]=r.path,e[16]=x,e[17]=o,e[18]=h):h=e[18],_(i,h);let l;e[19]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{k.current?.()},e[19]=l):l=e[19];let d;return e[20]!==t.chunks||e[21]!==t.error||e[22]!==t.status?(d={cancel:l,chunks:t.chunks,error:t.error,status:t.status},e[20]=t.chunks,e[21]=t.error,e[22]=t.status,e[23]=d):d=e[23],d};function L(){}export{z as useHttpStream};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as P}from"react/compiler-runtime";import{useRef as k,useEffect as F}from"react";import{B as y}from"./use-paginated-core-_ZSkVafW.mjs";const B=(M,c,g)=>{const e=P(15),{initialNumItems:o}=g,{loadMore:s,pageResults:f,status:a}=y(M,c==="skip"?"skip":c,g),N=c==="skip";let t;if(e[0]!==f){t=[];for(const u of f)u&&t.push(u.page);e[0]=f,e[1]=t}else t=e[1];let r;e[2]!==o||e[3]!==s?(r={defaultNumItems:o,loadMore:s},e[2]=o,e[3]=s,e[4]=r):r=e[4];const h=k(r);let i;e[5]!==o||e[6]!==s?(i=()=>{h.current={defaultNumItems:o,loadMore:s}},e[5]=o,e[6]=s,e[7]=i):i=e[7],F(i);let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=u=>{const{defaultNumItems:I,loadMore:L}=h.current;L(u??I)},e[8]=m):m=e[8];const x=m,l=a==="CanLoadMore",d=!N&&a==="LoadingMore",p=!N&&a==="LoadingFirstPage";let n;return e[9]!==t||e[10]!==a||e[11]!==l||e[12]!==d||e[13]!==p?(n={fetchNextPage:x,hasNextPage:l,isFetchingNextPage:d,isLoading:p,pages:t,status:a},e[9]=t,e[10]=a,e[11]=l,e[12]=d,e[13]=p,e[14]=n):n=e[14],n};export{B as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useMutation as E}from"@tanstack/react-query";import{useRef as M,useState as O,useCallback as c}from"react";import{useLunora as U}from"./LunoraProvider-D6ZS72le.mjs";const b=d=>{const f=U(),o=M(0),[a,p]=O(!1),g=E({mutationFn:({args:t,options:r})=>f.mutation(d,t,r),onMutate:()=>{o.current+=1,p(!0)},onSettled:()=>{o.current-=1,p(o.current>0)}}),{data:s,error:i,isError:n,mutateAsync:e,reset:u}=g,l=c((t,r)=>e({args:t,options:r}),[e]),m=c(t=>({data:s,error:i,isError:n,mutate:(r,h)=>e({args:r,options:{optimisticUpdate:t,...h}}),pending:a,reset:u,withOptimisticUpdate:m}),[e,s,i,n,a,u]);return{data:s,error:i,isError:n,mutate:l,pending:a,reset:u,withOptimisticUpdate:m}};export{b as useMutation};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as d}from"react/compiler-runtime";import{createMutatorRunner as p}from"@lunora/client";import{useState as m}from"react";const E=function(s){const t=d(8),[i,c]=m(!1),[r,f]=m(void 0);let e;t[0]!==s?(e=p(s,{setError:f,setPending:c}),t[0]=s,t[1]=e):e=t[1];const{mutate:n,reset:u}=e,a=r!==void 0;let o;return t[2]!==r||t[3]!==n||t[4]!==i||t[5]!==u||t[6]!==a?(o={error:r,isError:a,mutate:n,pending:i,reset:u},t[2]=r,t[3]=n,t[4]=i,t[5]=u,t[6]=a,t[7]=o):o=t[7],o};export{E as useMutator};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as g}from"react/compiler-runtime";import{B as l}from"./use-paginated-core-_ZSkVafW.mjs";const m=(u,a,c)=>{const s=g(7),{loadMore:r,pageResults:i,status:t}=l(u,a==="skip"?"skip":a,c);let o;if(s[0]!==i){o=[];for(const p of i)p&&o.push(...p.page);s[0]=i,s[1]=o}else o=s[1];const n=a!=="skip"&&(t==="LoadingFirstPage"||t==="LoadingMore");let e;return s[2]!==r||s[3]!==o||s[4]!==t||s[5]!==n?(e={isLoading:n,loadMore:r,results:o,status:t},s[2]=r,s[3]=o,s[4]=t,s[5]=n,s[6]=e):e=s[6],e};export{m as usePaginatedQuery};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useMemo as S,useState as U,useRef as I,useEffect as c,useCallback as p}from"react";import{useLunora as $}from"./LunoraProvider-D6ZS72le.mjs";const D=(e="sess")=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const s=crypto.getRandomValues(new Uint8Array(16));return`${e}-${Array.from(s,t=>t.toString(16).padStart(2,"0")).join("")}`}}return`${e}-${Date.now().toString(36)}`},L=1e4,P=(e,s)=>{const t=$(),{heartbeat:m,intervalMs:y=L,listPresent:f,shardKey:o}=s,i=S(()=>s.sessionId??D(),[s.sessionId]),[h,v]=U(void 0),u=I(s.data),l=I({client:t,heartbeat:m,roomId:e,sessionId:i,shardKey:o});c(()=>{l.current={client:t,heartbeat:m,roomId:e,sessionId:i,shardKey:o}});const n=p(()=>{const{client:r,heartbeat:a,roomId:d,sessionId:K,shardKey:g}=l.current,R={roomId:d,sessionId:K,...u.current===void 0?{}:{data:u.current}};r.mutation(a,R,{shardKey:g}).catch(()=>{})},[]),b=p(r=>{u.current=r,n()},[n]);return c(()=>{n();const r=setInterval(n,y),a=()=>{typeof document<"u"&&document.visibilityState==="visible"&&n()};return typeof document<"u"&&document.addEventListener("visibilitychange",a),()=>{clearInterval(r),typeof document<"u"&&document.removeEventListener("visibilitychange",a)}},[n,y]),c(()=>t.acquireConnectionContext({roomId:e,sessionId:i},{shardKey:o}),[t,e,i,o]),c(()=>{let r=!1;const a=t.subscribe(f,{roomId:e},d=>{r||v(d)},{shardKey:o});return()=>{r=!0,a()}},[t,f.__lunoraRef,e,o]),{present:h,sessionId:i,setData:b}};export{P as usePresence};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as N}from"react/compiler-runtime";import{useQueryClient as Q,useQuery as R}from"@tanstack/react-query";import{useState as q,useEffect as h}from"react";import{b as v}from"./cache-DJEsSdUx.mjs";import{useLunora as K}from"./LunoraProvider-D6ZS72le.mjs";import{i as T,y as _}from"./query-key-DV_Vu-6c.mjs";const C=(a,c,p)=>{const e=N(9),l=p===void 0?{}:p,r=K(),i=Q(),{shardKey:u}=l,t=c==="skip",n=t?{}:c,s=_(a,n,u),[o,b]=q(r.isReady);let m,y;e[0]!==r||e[1]!==o?(m=()=>{o||r.whenReady().then(()=>{b(!0)})},y=[r,o],e[0]=r,e[1]=o,e[2]=m,e[3]=y):(m=e[2],y=e[3]),h(m,y);const I=t?void 0:r.peekHydratedQuery(a.__lunoraRef,n,u),{data:$}=R({enabled:!t&&o,initialData:I,queryFn:()=>r.query(a,n,{shardKey:u}),queryKey:s,staleTime:Number.POSITIVE_INFINITY}),f=T(s);let d;return e[4]!==r||e[5]!==i||e[6]!==t||e[7]!==f?(d=[r,i,f,t],e[4]=r,e[5]=i,e[6]=t,e[7]=f,e[8]=d):d=e[8],h(()=>t?k:v(r).attach(i,s,a,n,u),d),t?void 0:$};function k(){}export{C as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{evaluate as u}from"@lunora/ratelimit";import{useRef as d,useReducer as w,useCallback as c,useEffect as R}from"react";const y=(r,a={})=>{const t=a.now??Date.now,f=a.tickMs??1e3,s=d(void 0),[,n]=w(e=>e+1,0),m=c((e=1)=>{const{status:k,value:l}=u(r,s.current,{consume:!0,count:e,now:t(),reserve:!1});return l!==void 0&&(s.current=l),n(),k},[r,t]),v=c((e=1)=>u(r,s.current,{consume:!1,count:e,now:t(),reserve:!1}).status.ok,[r,t]),i=c(()=>{s.current=void 0,n()},[]),{status:o}=u(r,s.current,{consume:!1,count:1,now:t(),reserve:!1});return R(()=>{if(o.ok)return()=>{};const e=setInterval(n,f);return()=>{clearInterval(e)}},[o.ok,f]),{check:v,consume:m,disabled:!o.ok,ok:o.ok,reset:i,retryAfter:o.retryAfter}};export{y as useRateLimit};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as k}from"react/compiler-runtime";import{useReducer as B,useRef as K,useEffect as R}from"react";import{useLunora as v}from"./LunoraProvider-D6ZS72le.mjs";import{o as S,u as E}from"./stream-state-ksURgmCA.mjs";import{t as L}from"./wire-key-BjAV3_Rq.mjs";const A=(a,u,n)=>{const e=k(27);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,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,l]=B(S,f),s=u==="skip";let m;e[3]!==u||e[4]!==s?(m=s?"skip":L(u),e[3]=u,e[4]=s,e[5]=m):m=e[5];const y=m,b=K(void 0);let d;e[6]!==u||e[7]!==o||e[8]!==a||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(d=()=>{if(s)return l({type:"reset"}),T;l({type:"reset"}),l({type:"start"});const{cancel:_,cleanup:x}=E(o.stream(a,u,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),l);return b.current=_,()=>{x(),b.current=void 0}},e[6]=u,e[7]=o,e[8]=a,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=d):d=e[13];let i;e[14]!==o||e[15]!==a.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(i=[o,a.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=a.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=i):i=e[21],R(d,i);let h;e[22]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{b.current?.()},e[22]=h):h=e[22];let p;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(p={cancel:h,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=p):p=e[26],p};function T(){}export{A as useStream};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as b}from"react/compiler-runtime";import{createQuerySubscription as w}from"@lunora/client/query";import{useState as x,useRef as q,useEffect as v}from"react";import{useLunora as A}from"./LunoraProvider-D6ZS72le.mjs";import{t as D}from"./wire-key-BjAV3_Rq.mjs";const B=(o,r,n)=>{const e=b(22);let u;e[0]!==n?(u=n===void 0?{}:n,e[0]=n,e[1]=u):u=e[1];const a=u,s=A();let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={data:void 0,error:void 0},e[2]=c):c=e[2];const[g,p]=x(c),t=r==="skip";let d;e[3]!==r||e[4]!==t?(d=t?"skip":D(r),e[3]=r,e[4]=t,e[5]=d):d=e[5];const y=d;let f;e[6]!==r||e[7]!==o?(f={args:r,fn:o},e[6]=r,e[7]=o,e[8]=f):f=e[8];const _=q(f);let i;e[9]!==r||e[10]!==o?(i=()=>{_.current={args:r,fn:o}},e[9]=r,e[10]=o,e[11]=i):i=e[11],v(i);let l;e[12]!==s||e[13]!==a.shardKey||e[14]!==t?(l=()=>{if(t)return p({data:void 0,error:void 0}),L;let h=!1;const{args:k,fn:E}=_.current,R=w(s,E,k,{onData:K=>{h||p({data:K,error:void 0})},onError:K=>{const S=new Error(K.message);queueMicrotask(()=>{h||p({data:void 0,error:S})})}},{shardKey:a.shardKey});return()=>{h=!0,R()}},e[12]=s,e[13]=a.shardKey,e[14]=t,e[15]=l):l=e[15];let m;return e[16]!==s||e[17]!==o.__lunoraRef||e[18]!==a.shardKey||e[19]!==y||e[20]!==t?(m=[s,o.__lunoraRef,y,a.shardKey,t],e[16]=s,e[17]=o.__lunoraRef,e[18]=a.shardKey,e[19]=y,e[20]=t,e[21]=m):m=e[21],v(l,m),g};function L(){}export{B as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useState as y,useRef as F,useCallback as b,useEffect as O}from"react";import{useLunora as J}from"./LunoraProvider-D6ZS72le.mjs";const G=t=>{if(t.length===0)return 0;let o=0;for(const n of t)o+=n*n;return Math.sqrt(o/t.length)},H=(t,o)=>{const n=o/16e3,a=n>1?Math.floor(t.length/n):t.length,l=new ArrayBuffer(a*2),i=new DataView(l);for(let c=0;c<a;c+=1){const g=t[Math.floor(c*n)]??0,d=Math.max(-1,Math.min(1,g));i.setInt16(c*2,d<0?d*32768:d*32767,!0)}return new Uint8Array(l)},Q=async t=>{const o=globalThis,n=o.navigator?.mediaDevices?.getUserMedia.bind(o.navigator.mediaDevices),a=o.AudioContext??o.webkitAudioContext;if(!n||!a)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await n({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,c=i.createMediaStreamSource(l),g=i.createScriptProcessor(4096,1,1);let d=!1,k=!1,p=0,f=0;return g.onaudioprocess=s=>{const h=s.inputBuffer.getChannelData(0),m=d?0:G(h);if(t.onLevel(m),d)return;if(t.onAudio(H(h,i.sampleRate)),t.isSpeaking()){f=m>=t.interruptThreshold?f+1:0,f>=t.interruptChunks&&(f=0,t.onInterrupt());return}f=0;const T=h.length/i.sampleRate*1e3;if(m>=t.silenceThreshold){k=!0,p=0;return}k&&(p+=T,p>=t.silenceDurationMs&&(k=!1,p=0,t.onSilence()))},c.connect(g),g.connect(i.destination),{setMuted:s=>{d=s},stop:()=>{g.disconnect(),c.disconnect();for(const s of l.getTracks())s.stop();i.close()}}},X=()=>{const t=globalThis,o=t.AudioContext??t.webkitAudioContext;if(!o)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const n=new o,a=new Set;let l=0,i=Promise.resolve(),c=0;const g=async(p,f)=>{if(f!==c)return;let s;try{s=await n.decodeAudioData(p.buffer)}catch{return}if(f!==c)return;const h=n.createBufferSource();h.buffer=s,h.connect(n.destination);const m=Math.max(n.currentTime,l);h.start(m),l=m+s.duration,a.add(h),h.onended=()=>{a.delete(h)}},d=p=>{const f=Uint8Array.from(p),s=c;i=i.then(()=>g(f,s))},k=()=>{c+=1;for(const p of a)try{p.stop()}catch{}a.clear(),l=n.currentTime};return{enqueue:d,interrupt:k,stop:()=>{k(),n.close()}}},I=1,Y=.01,Z=1200,j=.15,z=3,ee=t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,te=t=>{const o=t.__lunoraRef,n=o.startsWith("agents:")?o.slice(7):o;return n.endsWith("Voice")?n.slice(0,-5):n},re=(t,o,n)=>{const a=ee(t),l=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:n});return`${l}/_lunora/voice/${encodeURIComponent(o)}?${i.toString()}`},oe=t=>{const{createMicrophone:o=Q,createSpeaker:n=X,createSocket:a,interruptChunks:l=z,interruptThreshold:i=j,silenceDurationMs:c=Z,silenceThreshold:g=Y,threadKey:d,voice:k}=t,p=J(),[f,s]=y("idle"),[h,m]=y(!1),[T,E]=y(""),[q,M]=y(""),[L,$]=y(0),[D,U]=y(!1),[B,x]=y(void 0),u=F(void 0),C=F(!1),v=b(r=>{const e=u.current?.socket;return e?.readyState===I?(e.send(JSON.stringify(r)),!0):!1},[]),A=b(()=>{const r=u.current;if(u.current=void 0,r){r.microphone?.stop(),r.speaker?.stop();try{r.socket.close()}catch{}}C.current=!1,m(!1),s("idle"),$(0)},[]),V=b(r=>{const e=u.current;switch(r.type){case"assistant_delta":{e&&(e.speaking=!0),s("speaking"),M(S=>S+r.text);break}case"assistant_done":{e&&(e.speaking=!1),M(r.text),s("listening");break}case"error":{e&&(e.speaking=!1),x(new Error(r.message)),s("listening");break}case"interrupted":{e&&(e.speaking=!1,e.suppressAudio=!1),e?.speaker?.interrupt(),s("listening");break}case"ready":{e&&(e.audioFormat=r.audioFormat,e.suppressAudio=!1),m(!0),s("listening");break}case"user_transcript":{e&&(e.suppressAudio=!1),E(r.text),M(""),s("thinking");break}}},[]),W=b(r=>{const e=u.current;!e||e.suppressAudio||(e.speaker??=n({audioFormat:e.audioFormat}),e.speaking=!0,s("speaking"),e.speaker.enqueue(r))},[n]),P=b(async()=>{if(!(u.current||C.current)){C.current=!0,x(void 0),E(""),M("");try{const r=re(p.url,te(k),d),e=(a??(w=>{const _=p.getWebSocketImpl();if(!_)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new _(w)}))(r);e.binaryType="arraybuffer";const S={audioFormat:"mp3",microphone:void 0,socket:e,speaker:void 0,speaking:!1,suppressAudio:!1};u.current=S,e.onmessage=w=>{if(typeof w.data=="string"){try{V(JSON.parse(w.data))}catch{}return}W(new Uint8Array(w.data))},e.onerror=()=>{x(new Error("useVoiceAgent: voice socket error"))},e.onclose=()=>{u.current===S&&A()};const R=await o({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>u.current?.speaking??!1,onAudio:w=>{e.readyState===I&&e.send(w)},onInterrupt:()=>{v({type:"interrupt"}),u.current?.speaker?.interrupt(),u.current&&(u.current.speaking=!1,u.current.suppressAudio=!0),s("listening")},onLevel:$,onSilence:()=>{v({type:"commit"}),s("thinking")},silenceDurationMs:c,silenceThreshold:g});u.current===S?(S.microphone=R,U(!1),s("listening")):R.stop()}catch(r){x(r instanceof Error?r:new Error(String(r))),A()}finally{C.current=!1}}},[p,o,a,W,V,l,i,v,c,g,A,d,k]),K=b(()=>{const r=!D;return u.current?.microphone?.setMuted(r),U(r),r},[D]),N=b(r=>{v({text:r,type:"text"})&&s("thinking")},[v]);return O(()=>A,[A]),{audioLevel:L,connected:h,endCall:A,error:B,interimTranscript:q,isMuted:D,sendText:N,startCall:P,status:f,toggleMute:K,transcript:T}};export{oe as useVoiceAgent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as b}from"./stable-key-BSG0zK_E.mjs";const c=r=>{let t="";for(let a=0;a<r.length;a+=32768)t+=String.fromCharCode(...r.subarray(a,a+32768));return btoa(t)},o="$lunora.wire$",l=64,p="__proto__",d=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>l)throw new RangeError(`wire-codec: value nesting exceeds the ${l}-level limit`);if(r===void 0)return[o,"undefined"];if(r===null)return null;const a=typeof r;if(a==="bigint")return[o,"bigint",r.toString()];if(a==="number"){const e=r;return Number.isNaN(e)?[o,"nan"]:e===1/0?[o,"inf"]:e===-1/0?[o,"-inf"]:e}if(a!=="object")return r;if(r instanceof Date)return[o,"date",i(r.getTime(),t+1)];if(r instanceof Error){const e=r,n={};for(const s of Object.keys(e))e[s]!==void 0&&(n[s]=i(e[s],t+1));const f=[o,"error",e.name,e.message,n];return e.cause!==void 0&&f.push(i(e.cause,t+1)),f}if(r instanceof URL)return[o,"url",r.href];if(r instanceof Map)return[o,"map",[...r.entries()].map(([e,n])=>[i(e,t+1),i(n,t+1)])];if(r instanceof Set)return[o,"set",[...r].map(e=>i(e,t+1))];if(r instanceof ArrayBuffer)return[o,"bytes",c(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const e=r,n=e.constructor.name,f=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return n==="Uint8Array"?[o,"bytes",c(f)]:[o,"bytes",c(f),n]}if(Array.isArray(r)){const e=r.map(n=>i(n,t+1));return e.length>0&&e[0]===o?[o,"arr",e]:e}if(!d(r)){const e=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${e} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const y=r,u={};for(const e of Object.keys(y)){const n=y[e];if(n===void 0)continue;const f=i(n,t+1);e===p?Object.defineProperty(u,e,{configurable:!0,enumerable:!0,value:f,writable:!0}):u[e]=f}return u},g=r=>b(i(r));export{g as t};
|