@lunora/react 1.0.0-alpha.32 → 1.0.0-alpha.34
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.mjs +1 -28
- package/dist/packem_shared/AuthLoading-eLWn4Z7G.mjs +2 -0
- package/dist/packem_shared/CheckoutButton-DS_DKgNf.mjs +2 -0
- package/dist/packem_shared/LunoraProvider-InsjxtOB.mjs +2 -0
- package/dist/packem_shared/cache-odCgnNLz.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-DltXxPnp.mjs +2 -0
- package/dist/packem_shared/lunoraQueryOptions-BhiUY9ZF.mjs +1 -0
- package/dist/packem_shared/query-key-Y92N0Dci.mjs +1 -0
- package/dist/packem_shared/stable-key-BSG0zK_E.mjs +1 -0
- package/dist/packem_shared/use-paginated-core-DYjRFno_.mjs +2 -0
- package/dist/packem_shared/useAgent-DNKxqQ9F.mjs +2 -0
- package/dist/packem_shared/useAgentChat-BmYXshp0.mjs +2 -0
- package/dist/packem_shared/useAgentState-DO0yz6OU.mjs +2 -0
- package/dist/packem_shared/useAgentToolEvents-DTWZCIfd.mjs +2 -0
- package/dist/packem_shared/useAuth-CWkJn7i9.mjs +2 -0
- package/dist/packem_shared/useAuthState-jnCMkIwt.mjs +2 -0
- package/dist/packem_shared/useClientQuery-EPo__hzu.mjs +2 -0
- package/dist/packem_shared/useConnectionStatus-PL5D-S7t.mjs +2 -0
- package/dist/packem_shared/useFlag-Dh7bXXPx.mjs +2 -0
- package/dist/packem_shared/useHttpStream-DFswZrRk.mjs +2 -0
- package/dist/packem_shared/useInfiniteQuery-DyExohf2.mjs +2 -0
- package/dist/packem_shared/useMutation-B4uL3Rde.mjs +2 -0
- package/dist/packem_shared/useMutator-D3CGrk5-.mjs +2 -0
- package/dist/packem_shared/usePaginatedQuery-Roo_jyC9.mjs +2 -0
- package/dist/packem_shared/usePresence-SJBy81um.mjs +2 -0
- package/dist/packem_shared/useQuery-m-trnMUV.mjs +2 -0
- package/dist/packem_shared/useRateLimit-DqikMrX9.mjs +2 -0
- package/dist/packem_shared/useStream-CGcSWvPI.mjs +2 -0
- package/dist/packem_shared/useSubscription-CiQk8tFR.mjs +2 -0
- package/dist/packem_shared/useVoiceAgent-4gj2W2jc.mjs +2 -0
- package/dist/packem_shared/wire-key-8Ju6XYoB.mjs +1 -0
- package/dist/server.mjs +1 -31
- package/dist/upload.mjs +1 -2
- package/package.json +3 -3
- package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
- package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
- package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
- package/dist/packem_shared/cache-JeuDAXfE.mjs +0 -80
- package/dist/packem_shared/hydratePreloaded-2omLtadR.mjs +0 -54
- package/dist/packem_shared/lunoraQueryOptions-CefbPBId.mjs +0 -16
- package/dist/packem_shared/query-key-LGnArBTB.mjs +0 -13
- package/dist/packem_shared/stable-key-DePnevIy.mjs +0 -38
- package/dist/packem_shared/use-paginated-core-xxvd1YA0.mjs +0 -179
- package/dist/packem_shared/useAgent-BNLlIYHz.mjs +0 -101
- package/dist/packem_shared/useAgentChat-0cebQe7-.mjs +0 -304
- package/dist/packem_shared/useAgentState-Cqyd3Dfy.mjs +0 -37
- package/dist/packem_shared/useAgentToolEvents-gF7U4_KY.mjs +0 -129
- package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
- package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
- package/dist/packem_shared/useClientQuery-DIkNT4QA.mjs +0 -17
- package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
- package/dist/packem_shared/useFlag-Beyeiq2b.mjs +0 -128
- package/dist/packem_shared/useHttpStream-oc4s1pMy.mjs +0 -127
- package/dist/packem_shared/useInfiniteQuery-CJNw1XaZ.mjs +0 -97
- package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
- package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
- package/dist/packem_shared/usePaginatedQuery-DWzydaVR.mjs +0 -46
- package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
- package/dist/packem_shared/useQuery-CE8_QUgh.mjs +0 -77
- package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
- package/dist/packem_shared/useStream-GYNgc9J5.mjs +0 -128
- package/dist/packem_shared/useSubscription-DcDlvVuI.mjs +0 -139
- package/dist/packem_shared/useVoiceAgent-w7fzAMSB.mjs +0 -422
- package/dist/packem_shared/wire-key-Bg8BJ8YM.mjs +0 -101
package/dist/index.mjs
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
export { useAuthState } from './packem_shared/useAuthState-CyF35qZR.mjs';
|
|
4
|
-
export { LunoraProvider, useLunora } from './packem_shared/LunoraProvider-BsuiW4Lk.mjs';
|
|
5
|
-
export { CheckoutButton, CustomerPortalButton, useCheckout } from './packem_shared/CheckoutButton-DUite8jJ.mjs';
|
|
6
|
-
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-CefbPBId.mjs';
|
|
7
|
-
export { useAgent } from './packem_shared/useAgent-BNLlIYHz.mjs';
|
|
8
|
-
export { useAgentChat } from './packem_shared/useAgentChat-0cebQe7-.mjs';
|
|
9
|
-
export { useAgentState } from './packem_shared/useAgentState-Cqyd3Dfy.mjs';
|
|
10
|
-
export { useAgentToolEvents } from './packem_shared/useAgentToolEvents-gF7U4_KY.mjs';
|
|
11
|
-
export { default as useAuth } from './packem_shared/useAuth-BSutjJaa.mjs';
|
|
12
|
-
export { default as useClientQuery } from './packem_shared/useClientQuery-DIkNT4QA.mjs';
|
|
13
|
-
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-PJ7vyCHy.mjs';
|
|
14
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-Beyeiq2b.mjs';
|
|
15
|
-
export { useHttpStream } from './packem_shared/useHttpStream-oc4s1pMy.mjs';
|
|
16
|
-
export { default as useInfiniteQuery } from './packem_shared/useInfiniteQuery-CJNw1XaZ.mjs';
|
|
17
|
-
export { useMutation } from './packem_shared/useMutation-BeqeIjTr.mjs';
|
|
18
|
-
export { useMutator } from './packem_shared/useMutator-IIrLtDiM.mjs';
|
|
19
|
-
export { usePaginatedQuery } from './packem_shared/usePaginatedQuery-DWzydaVR.mjs';
|
|
20
|
-
export { hydratePreloaded, default as usePreloadedQuery } from './packem_shared/hydratePreloaded-2omLtadR.mjs';
|
|
21
|
-
export { usePresence } from './packem_shared/usePresence-Rnx1Fznc.mjs';
|
|
22
|
-
export { default as useQuery } from './packem_shared/useQuery-CE8_QUgh.mjs';
|
|
23
|
-
export { useRateLimit } from './packem_shared/useRateLimit-DTEffQEi.mjs';
|
|
24
|
-
export { useStream } from './packem_shared/useStream-GYNgc9J5.mjs';
|
|
25
|
-
export { default as useSubscription } from './packem_shared/useSubscription-DcDlvVuI.mjs';
|
|
26
|
-
export { useVoiceAgent } from './packem_shared/useVoiceAgent-w7fzAMSB.mjs';
|
|
27
|
-
export { createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
28
|
-
export { RestrictionError, UploadControl, UploadError } from '@visulima/storage-client';
|
|
29
|
-
export { useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
|
|
2
|
+
import{AuthLoading as t,Authenticated as o,Unauthenticated as u}from"./packem_shared/AuthLoading-eLWn4Z7G.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-jnCMkIwt.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-InsjxtOB.mjs";import{CheckoutButton as d,CustomerPortalButton as i,useCheckout as x}from"./packem_shared/CheckoutButton-DS_DKgNf.mjs";import{lunoraQueryOptions as c}from"./packem_shared/lunoraQueryOptions-BhiUY9ZF.mjs";import{useAgent as h}from"./packem_shared/useAgent-DNKxqQ9F.mjs";import{useAgentChat as A}from"./packem_shared/useAgentChat-BmYXshp0.mjs";import{useAgentState as U}from"./packem_shared/useAgentState-DO0yz6OU.mjs";import{useAgentToolEvents as P}from"./packem_shared/useAgentToolEvents-DTWZCIfd.mjs";import{default as S}from"./packem_shared/useAuth-CWkJn7i9.mjs";import{default as R}from"./packem_shared/useClientQuery-EPo__hzu.mjs";import{default as M}from"./packem_shared/useConnectionStatus-PL5D-S7t.mjs";import{useFlag as b,useFlags as v}from"./packem_shared/useFlag-Dh7bXXPx.mjs";import{useHttpStream as I}from"./packem_shared/useHttpStream-DFswZrRk.mjs";import{default as z}from"./packem_shared/useInfiniteQuery-DyExohf2.mjs";import{useMutation as O}from"./packem_shared/useMutation-B4uL3Rde.mjs";import{useMutator as j}from"./packem_shared/useMutator-D3CGrk5-.mjs";import{usePaginatedQuery as w}from"./packem_shared/usePaginatedQuery-Roo_jyC9.mjs";import{hydratePreloaded as G,default as J}from"./packem_shared/hydratePreloaded-DltXxPnp.mjs";import{usePresence as N}from"./packem_shared/usePresence-SJBy81um.mjs";import{default as X}from"./packem_shared/useQuery-m-trnMUV.mjs";import{useRateLimit as Z}from"./packem_shared/useRateLimit-DqikMrX9.mjs";import{useStream as $}from"./packem_shared/useStream-CGcSWvPI.mjs";import{default as re}from"./packem_shared/useSubscription-CiQk8tFR.mjs";import{useVoiceAgent as oe}from"./packem_shared/useVoiceAgent-4gj2W2jc.mjs";import{createClientQuery as se,getErrorCode as ae,getRetryAfterMs as pe,isConflictError as fe,isForbiddenError as ne,isRateLimitedError as me,isUnauthorizedError as de}from"@lunora/client";import{RestrictionError as xe,UploadControl as le,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as he,useFileInput as Ce,useMultipartUpload as Ae,usePasteUpload as ye,useTusUpload as Ue,useUpload as Ee}from"@visulima/storage-client/react";export{t as AuthLoading,o as Authenticated,d as CheckoutButton,i as CustomerPortalButton,f as LunoraProvider,xe as RestrictionError,u as Unauthenticated,le as UploadControl,ce as UploadError,se as createClientQuery,ae as getErrorCode,pe as getRetryAfterMs,G as hydratePreloaded,fe as isConflictError,ne as isForbiddenError,me as isRateLimitedError,de as isUnauthorizedError,c as lunoraQueryOptions,h as useAgent,A as useAgentChat,U as useAgentState,P as useAgentToolEvents,S as useAuth,a as useAuthState,x as useCheckout,he as useChunkedRestUpload,R as useClientQuery,M as useConnectionStatus,Ce as useFileInput,b as useFlag,v as useFlags,I as useHttpStream,z as useInfiniteQuery,n as useLunora,Ae as useMultipartUpload,O as useMutation,j as useMutator,w as usePaginatedQuery,ye as usePasteUpload,J as usePreloadedQuery,N as usePresence,X as useQuery,Z as useRateLimit,$ as useStream,re as useSubscription,Ue as useTusUpload,Ee as useUpload,oe as useVoiceAgent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useAuthState as i}from"./useAuthState-jnCMkIwt.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as L}from"react/compiler-runtime";import{LunoraError as d}from"@lunora/errors";import{QueryClientContext as y,QueryClientProvider as C,QueryClient as N}from"@tanstack/react-query";import{createContext as h,use as f,useState as v}from"react";import{jsx as c}from"react/jsx-runtime";const p=h(null),T=()=>new N({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),b=o=>{const e=L(9),{children:a,client:m,queryClient:n}=o,r=f(y);let i;e[0]!==r||e[1]!==n?(i=()=>n??r??T(),e[0]=r,e[1]=n,e[2]=i):i=e[2];const[I]=v(i),t=n??r??I;if(!t)throw new d("INTERNAL","LunoraProvider: failed to resolve a QueryClient");let u;e[3]!==a||e[4]!==m?(u=c(p,{value:m,children:a}),e[3]=a,e[4]=m,e[5]=u):u=e[5];const l=u;if(r===t)return l;let s;return e[6]!==l||e[7]!==t?(s=c(C,{client:t,children:l}),e[6]=l,e[7]=t,e[8]=s):s=e[8],s},q=()=>{const o=f(p);if(!o)throw new d("INTERNAL","useLunora must be used inside <LunoraProvider />");return o};export{b as LunoraProvider,q as useLunora};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as u}from"./query-key-Y92N0Dci.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-odCgnNLz.mjs";import{useLunora as q}from"./LunoraProvider-InsjxtOB.mjs";import{i as K,y as N}from"./query-key-Y92N0Dci.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as s}from"./query-key-Y92N0Dci.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as n}from"./wire-key-8Ju6XYoB.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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-odCgnNLz.mjs";import{useLunora as $}from"./LunoraProvider-InsjxtOB.mjs";import{i,y as I}from"./query-key-Y92N0Dci.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as T}from"react/compiler-runtime";import{useMutation as h}from"./useMutation-B4uL3Rde.mjs";import $ from"./useSubscription-CiQk8tFR.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as re}from"react/compiler-runtime";import{useState as oe,useRef as se}from"react";import{useMutation as L}from"./useMutation-B4uL3Rde.mjs";import{useStream as ae}from"./useStream-CGcSWvPI.mjs";import P from"./useSubscription-CiQk8tFR.mjs";const ie={__lunoraRef:""},ce={__lunoraRef:""},le=[],Q=(a,e)=>{const u=e.filter(i=>i.role==="user"),c=new Set;return a.filter(i=>{for(let l=i.durableUserCountAtSend;l<u.length;l+=1){const f=u[l];if(f!==void 0&&!c.has(l)&&f.content===i.content)return c.add(l),!1}return!0})},ve=a=>{const e=re(49),{api:u,cancel:c,limit:i,send:l,sendArgs:f,stream:g,threadKey:t}=a;let p;e[0]!==i||e[1]!==t?(p=i===void 0?{key:t}:{key:t,limit:i},e[0]=i,e[1]=t,e[2]=p):p=e[2];const V=p,{data:W}=P(u.agents.agentMessages,V);let y;e[3]!==t?(y={key:t},e[3]=t,e[4]=y):y=e[4];const{data:X}=P(u.agents.agentThread,y);let v;e[5]!==g||e[6]!==t?(v=g===void 0?"skip":{key:t},e[5]=g,e[6]=t,e[7]=v):v=e[7];const Y=v,{chunks:R}=ae(g??ce,Y),Z=L(l),z=L(c??ie),G=L(u.agents.agentResolveApproval);let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=[],e[8]=w):w=e[8];const[$,N]=oe(w),b=se(0),O=X,q=O?.status,s=O?.instanceId,r=W??le;let C;if(e[9]!==r||e[10]!==$){const o=Q($,r);let n;if(e[12]!==r){n=-1;for(const d of r)d.seq>n&&(n=d.seq);e[12]=r,e[13]=n}else n=e[13];C=o.length===0?r:[...r,...o.map((d,H)=>({content:d.content,optimistic:!0,role:"user",seq:n+1+H}))],e[9]=r,e[10]=$,e[11]=C}else C=e[11];const x=C;let I;e[14]!==r?(I=r.filter(de),e[14]=r,e[15]=I):I=e[15];const m=I.length;let k;if(e[16]!==m||e[17]!==R||e[18]!==t){let o;e[20]!==m||e[21]!==t?(o=n=>n.kind!=="progress"&&n.threadKey===t&&n.turn>=m,e[20]=m,e[21]=t,e[22]=o):o=e[22],k=R.filter(o).map(ue).join(""),e[16]=m,e[17]=R,e[18]=t,e[19]=k}else k=e[19];const T=k,{mutate:E}=Z,{mutate:M}=z,{mutate:h}=G;let A;e[23]!==r||e[24]!==f||e[25]!==E||e[26]!==t?(A=async(o,n)=>{const d=b.current;b.current=b.current+1;const H=r.filter(fe).length;N(J=>[...Q(J,r),{content:o,durableUserCountAtSend:H,id:d}]);try{await E({input:o,threadKey:t,...f,...n})}catch(J){const ee=J;throw N(te=>te.filter(ne=>ne.id!==d)),ee}},e[23]=r,e[24]=f,e[25]=E,e[26]=t,e[27]=A):A=e[27];const U=A;let K;e[28]!==s||e[29]!==h||e[30]!==t?(K=async(o,n)=>{if(s===void 0)throw new Error("useAgentChat: cannot approve — no in-flight run (thread has no instanceId)");await h({decision:"approve",instanceId:s,threadKey:t,toolCallId:o,...n===void 0?{}:{note:n}})},e[28]=s,e[29]=h,e[30]=t,e[31]=K):K=e[31];const B=K;let S;e[32]!==s||e[33]!==h||e[34]!==t?(S=async(o,n)=>{if(s===void 0)throw new Error("useAgentChat: cannot reject — no in-flight run (thread has no instanceId)");await h({decision:"reject",instanceId:s,threadKey:t,toolCallId:o,...n===void 0?{}:{note:n}})},e[32]=s,e[33]=h,e[34]=t,e[35]=S):S=e[35];const D=S;let _;e[36]!==M||e[37]!==c||e[38]!==s||e[39]!==t?(_=async()=>{c===void 0||s===void 0||await M({instanceId:s,threadKey:t})},e[36]=M,e[37]=c,e[38]=s,e[39]=t,e[40]=_):_=e[40];const F=_;let j;return e[41]!==B||e[42]!==F||e[43]!==x||e[44]!==D||e[45]!==U||e[46]!==q||e[47]!==T?(j={approve:B,cancel:F,messages:x,reject:D,send:U,status:q,streamingText:T},e[41]=B,e[42]=F,e[43]=x,e[44]=D,e[45]=U,e[46]=q,e[47]=T,e[48]=j):j=e[48],j};function de(a){return a.role==="assistant"}function ue(a){return a.text}function fe(a){return a.role==="user"}export{ve as useAgentChat};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c}from"react/compiler-runtime";import d from"./useSubscription-CiQk8tFR.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as v}from"react/compiler-runtime";import{useStream as g}from"./useStream-CGcSWvPI.mjs";import y from"./useSubscription-CiQk8tFR.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as m}from"react/compiler-runtime";import{useSyncExternalStore as f}from"react";import{useLunora as p}from"./LunoraProvider-InsjxtOB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as i}from"react/compiler-runtime";import{useSyncExternalStore as s}from"react";import a from"./useAuth-CWkJn7i9.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useCallback as u,useSyncExternalStore as i}from"react";import{useLunora as l}from"./LunoraProvider-InsjxtOB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as a}from"react/compiler-runtime";import{useSyncExternalStore as s}from"react";import{useLunora as u}from"./LunoraProvider-InsjxtOB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as _,useRef as y,useEffect as d}from"react";import{useLunora as h}from"./LunoraProvider-InsjxtOB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useReducer as l,useRef as d,useEffect as y}from"react";import{useLunora as v}from"./LunoraProvider-InsjxtOB.mjs";import{e as x}from"./stable-key-BSG0zK_E.mjs";const g=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}},R=(r,t,o={})=>{const f=v(),[n,e]=l(g,{chunks:[],error:void 0,status:"idle"}),c=t==="skip",h=c?"skip":x(t),a=d(void 0);return y(()=>{if(c)return e({type:"reset"}),()=>{};e({type:"reset"}),e({type:"start"});let u=!0,i=!1;const p=f.httpStream(r,t,{maxBuffer:o.maxBuffer}),m=()=>{i||(i=!0,p.cancel())};return a.current=m,(async()=>{try{for await(const s of p){if(!u)return;e({chunk:s,type:"chunk"})}u&&e({type:"complete"})}catch(s){if(!u)return;const k=s instanceof Error?s:new Error(String(s));e({error:k,type:"error"})}})().catch(()=>{}),()=>{u=!1,m(),a.current=void 0}},[f,r.method,r.path,h,c,o.maxBuffer]),{cancel:()=>{a.current?.()},chunks:n.chunks,error:n.error,status:n.status}};export{R as useHttpStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-DYjRFno_.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-InsjxtOB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as g}from"react/compiler-runtime";import{B as l}from"./use-paginated-core-DYjRFno_.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useMemo as S,useState as U,useRef as f,useEffect as c,useCallback as h}from"react";import{useLunora as $}from"./LunoraProvider-InsjxtOB.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)}`},C=1e4,P=(e,s)=>{const t=$(),{heartbeat:m,intervalMs:l=C,listPresent:y,shardKey:n}=s,i=S(()=>s.sessionId??D(),[s.sessionId]),[p,v]=U(void 0),d=f(s.data),I=f({client:t,heartbeat:m,roomId:e,sessionId:i,shardKey:n});c(()=>{I.current={client:t,heartbeat:m,roomId:e,sessionId:i,shardKey:n}});const o=h(()=>{const{client:r,heartbeat:a,roomId:u,sessionId:K,shardKey:g}=I.current,R={roomId:u,sessionId:K,...d.current===void 0?{}:{data:d.current}};r.mutation(a,R,{shardKey:g}).catch(()=>{})},[]),b=h(r=>{d.current=r,o()},[o]);return c(()=>{o();const r=setInterval(o,l),a=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",a),()=>{clearInterval(r),document.removeEventListener("visibilitychange",a)}},[o,l]),c(()=>t.acquireConnectionContext({roomId:e,sessionId:i},{shardKey:n}),[t,e,i,n]),c(()=>{let r=!1;const a=t.subscribe(y,{roomId:e},u=>{r||v(u)},{shardKey:n});return()=>{r=!0,a()}},[t,y.__lunoraRef,e,n]),{present:p,sessionId:i,setData:b}};export{P as usePresence};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-odCgnNLz.mjs";import{useLunora as K}from"./LunoraProvider-InsjxtOB.mjs";import{i as T,y as _}from"./query-key-Y92N0Dci.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useReducer as l,useRef as k,useEffect as y}from"react";import{useLunora as v}from"./LunoraProvider-InsjxtOB.mjs";import{t as x}from"./wire-key-8Ju6XYoB.mjs";const g=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}},K=(r,e,u={})=>{const f=v(),[a,t]=l(g,{chunks:[],error:void 0,status:"idle"}),c=e==="skip",p=c?"skip":x(e),o=k(void 0);return y(()=>{if(c)return t({type:"reset"}),()=>{};t({type:"reset"}),t({type:"start"});let n=!0,i=!1;const h=f.stream(r,e,{maxBuffer:u.maxBuffer,shardKey:u.shardKey}),m=()=>{i||(i=!0,h.cancel())};return o.current=m,(async()=>{try{for await(const s of h){if(!n)return;t({chunk:s,type:"chunk"})}n&&t({type:"complete"})}catch(s){if(!n)return;const d=s instanceof Error?s:new Error(String(s));t({error:d,type:"error"})}})().catch(()=>{}),()=>{n=!1,m(),o.current=void 0}},[f,r.__lunoraRef,p,c,u.shardKey,u.maxBuffer]),{cancel:()=>{o.current?.()},chunks:a.chunks,error:a.error,status:a.status}};export{K as useStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-InsjxtOB.mjs";import{t as D}from"./wire-key-8Ju6XYoB.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as A,useRef as F,useCallback as w,useEffect as O}from"react";import{useLunora as H}from"./LunoraProvider-InsjxtOB.mjs";const Q=t=>{if(t.length===0)return 0;let o=0;for(const n of t)o+=n*n;return Math.sqrt(o/t.length)},X=(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)},Y=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:Q(h);if(t.onLevel(m),d)return;if(t.onAudio(X(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()}}},Z=()=>{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,j=.01,z=1200,G=.15,ee=3,te=t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,re=t=>{const o=t.__lunoraRef,n=o.startsWith("agents:")?o.slice(7):o;return n.endsWith("Voice")?n.slice(0,-5):n},ne=(t,o,n)=>{const a=te(t),l=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:n});return`${l}/_lunora/voice/${encodeURIComponent(o)}?${i.toString()}`},ae=t=>{const{createMicrophone:o=Y,createSpeaker:n=Z,createSocket:a,interruptChunks:l=ee,interruptThreshold:i=G,silenceDurationMs:c=z,silenceThreshold:g=j,threadKey:d,voice:k}=t,p=H(),[f,s]=A("idle"),[h,m]=A(!1),[T,E]=A(""),[q,M]=A(""),[L,$]=A(0),[D,U]=A(!1),[B,x]=A(void 0),u=F(void 0),C=F(!1),v=w(r=>{const e=u.current?.socket;return e?.readyState===I?(e.send(JSON.stringify(r)),!0):!1},[]),y=w(()=>{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)},[]),P=w(()=>{y()},[y]),V=w(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=w(r=>{const e=u.current;!e||e.suppressAudio||(e.speaker??=n({audioFormat:e.audioFormat}),e.speaking=!0,s("speaking"),e.speaker.enqueue(r))},[n]),J=w(async()=>{if(!(u.current||C.current)){C.current=!0,x(void 0),E(""),M("");try{const r=ne(p.url,re(k),d),e=(a??(b=>{const _=p.getWebSocketImpl();if(!_)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new _(b)}))(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=b=>{if(typeof b.data=="string"){try{V(JSON.parse(b.data))}catch{}return}W(new Uint8Array(b.data))},e.onerror=()=>{x(new Error("useVoiceAgent: voice socket error"))},e.onclose=()=>{u.current===S&&y()};const R=await o({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>u.current?.speaking??!1,onAudio:b=>{e.readyState===I&&e.send(b)},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))),y()}finally{C.current=!1}}},[p,o,a,W,V,l,i,v,c,g,y,d,k]),K=w(()=>{const r=!D;return u.current?.microphone?.setMuted(r),U(r),r},[D]),N=w(r=>{v({text:r,type:"text"})&&s("thinking")},[v]);return O(()=>y,[y]),{audioLevel:L,connected:h,endCall:P,error:B,interimTranscript:q,isMuted:D,sendText:N,startCall:J,status:f,toggleMute:K,transcript:T}};export{ae as useVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as p}from"./stable-key-BSG0zK_E.mjs";const u=n=>{let r="";for(let a=0;a<n.length;a+=32768)r+=String.fromCharCode(...n.subarray(a,a+32768));return btoa(r)},t="$lunora.wire$",l=64,i=(n,r=0)=>{if(r>l)throw new RangeError(`wire-codec: value nesting exceeds the ${l}-level limit`);if(n===void 0)return[t,"undefined"];if(n===null)return null;const a=typeof n;if(a==="bigint")return[t,"bigint",n.toString()];if(a==="number"){const e=n;return Number.isNaN(e)?[t,"nan"]:e===1/0?[t,"inf"]:e===-1/0?[t,"-inf"]:e}if(a!=="object")return n;if(n instanceof Date)return[t,"date",i(n.getTime(),r+1)];if(n instanceof Error){const e=n,o={};for(const f of Object.keys(e))e[f]!==void 0&&(o[f]=i(e[f],r+1));const s=[t,"error",e.name,e.message,o];return e.cause!==void 0&&s.push(i(e.cause,r+1)),s}if(n instanceof URL)return[t,"url",n.href];if(n instanceof Map)return[t,"map",[...n.entries()].map(([e,o])=>[i(e,r+1),i(o,r+1)])];if(n instanceof Set)return[t,"set",[...n].map(e=>i(e,r+1))];if(n instanceof ArrayBuffer)return[t,"bytes",u(new Uint8Array(n)),"ArrayBuffer"];if(ArrayBuffer.isView(n)){const e=n,o=e.constructor.name,s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return o==="Uint8Array"?[t,"bytes",u(s)]:[t,"bytes",u(s),o]}if(Array.isArray(n)){const e=n.map(o=>i(o,r+1));return e.length>0&&e[0]===t?[t,"arr",e]:e}const c=Object.getPrototypeOf(n);if(c!==null&&c!==Object.prototype){const e=n.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=n,b={};for(const e of Object.keys(y)){const o=y[e];o!==void 0&&(b[e]=i(o,r+1))}return b},m=n=>p(i(n));export{m as t};
|
package/dist/server.mjs
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
3
|
-
import { l as lunoraQueryKey } from './packem_shared/query-key-LGnArBTB.mjs';
|
|
4
|
-
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-CefbPBId.mjs';
|
|
5
|
-
export { preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
6
|
-
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
-
|
|
8
|
-
const prefetchQuery = async (queryClient, client, function_, args, options = {}) => {
|
|
9
|
-
const argsRecord = args ?? {};
|
|
10
|
-
await queryClient.prefetchQuery({
|
|
11
|
-
queryFn: () => client.query(function_, argsRecord, {
|
|
12
|
-
shardKey: options.shardKey
|
|
13
|
-
}),
|
|
14
|
-
queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
|
|
15
|
-
// Match the client hooks: Lunora is push-driven, so the seeded value is
|
|
16
|
-
// never considered stale by TanStack — the WS subscription that attaches
|
|
17
|
-
// on mount is the only freshness signal.
|
|
18
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const fetchQuery = async (options, function_, args, callOptions = {}) => createServerClient(options).query(function_, args, {
|
|
22
|
-
shardKey: callOptions.shardKey
|
|
23
|
-
});
|
|
24
|
-
const fetchMutation = async (options, function_, args, callOptions = {}) => createServerClient(options).mutation(function_, args, {
|
|
25
|
-
shardKey: callOptions.shardKey
|
|
26
|
-
});
|
|
27
|
-
const fetchAction = async (options, function_, args, callOptions = {}) => createServerClient(options).action(function_, args, {
|
|
28
|
-
shardKey: callOptions.shardKey
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
|
1
|
+
import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as m,deserializePreloaded as K,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{y as s}from"./packem_shared/query-key-Y92N0Dci.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-BhiUY9ZF.mjs";import{preloadQuery as v,preloadedQueryResult as N}from"@lunora/client";import{HydrationBoundary as T,dehydrate as z}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const d=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,d,{shardKey:y.shardKey}),queryKey:s(e,d,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},c=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),h=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),p=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,m as createServerClient,z as dehydrate,K as deserializePreloaded,p as fetchAction,h as fetchMutation,c as fetchQuery,Q as getServerSession,S as lunoraQueryOptions,u as prefetchQuery,v as preloadQuery,N as preloadedQueryResult,x as serializePreloaded};
|
package/dist/upload.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
export { useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
|
|
2
|
+
import{RestrictionError as r,UploadControl as p,UploadError as l}from"@visulima/storage-client";import{useChunkedRestUpload as t,useFileInput as u,useMultipartUpload as a,usePasteUpload as d,useTusUpload as U,useUpload as i}from"@visulima/storage-client/react";export{r as RestrictionError,p as UploadControl,l as UploadError,t as useChunkedRestUpload,u as useFileInput,a as useMultipartUpload,d as usePasteUpload,U as useTusUpload,i as useUpload};
|
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.34",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lunora/client": "1.0.0-alpha.
|
|
56
|
+
"@lunora/client": "1.0.0-alpha.30",
|
|
57
57
|
"@lunora/errors": "1.0.0-alpha.8",
|
|
58
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
58
|
+
"@lunora/ratelimit": "1.0.0-alpha.11",
|
|
59
59
|
"@visulima/storage-client": "1.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useAuthState } from './useAuthState-CyF35qZR.mjs';
|
|
3
|
-
|
|
4
|
-
const Authenticated = (t0) => {
|
|
5
|
-
const {
|
|
6
|
-
children
|
|
7
|
-
} = t0;
|
|
8
|
-
const {
|
|
9
|
-
isAuthenticated
|
|
10
|
-
} = useAuthState();
|
|
11
|
-
return isAuthenticated ? children : void 0;
|
|
12
|
-
};
|
|
13
|
-
const Unauthenticated = (t0) => {
|
|
14
|
-
const {
|
|
15
|
-
children
|
|
16
|
-
} = t0;
|
|
17
|
-
const {
|
|
18
|
-
isAuthenticated,
|
|
19
|
-
isLoading
|
|
20
|
-
} = useAuthState();
|
|
21
|
-
return !isLoading && !isAuthenticated ? children : void 0;
|
|
22
|
-
};
|
|
23
|
-
const AuthLoading = (t0) => {
|
|
24
|
-
const {
|
|
25
|
-
children
|
|
26
|
-
} = t0;
|
|
27
|
-
const {
|
|
28
|
-
isLoading
|
|
29
|
-
} = useAuthState();
|
|
30
|
-
return isLoading ? children : void 0;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { AuthLoading, Authenticated, Unauthenticated };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { c } from 'react/compiler-runtime';
|
|
3
|
-
import { useState, useCallback } from 'react';
|
|
4
|
-
import { jsxDEV } from 'react/jsx-dev-runtime';
|
|
5
|
-
|
|
6
|
-
const safeRedirectHref = (url) => {
|
|
7
|
-
const parsed = new URL(url, globalThis.location.href);
|
|
8
|
-
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
9
|
-
throw new Error(`refusing to redirect to a non-http(s) URL: ${parsed.protocol}`);
|
|
10
|
-
}
|
|
11
|
-
return parsed.href;
|
|
12
|
-
};
|
|
13
|
-
const useCheckout = (trigger) => {
|
|
14
|
-
const [pending, setPending] = useState(false);
|
|
15
|
-
const [error, setError] = useState(void 0);
|
|
16
|
-
const checkout = useCallback(async () => {
|
|
17
|
-
setPending(true);
|
|
18
|
-
setError(void 0);
|
|
19
|
-
try {
|
|
20
|
-
const target = await trigger();
|
|
21
|
-
globalThis.location.assign(safeRedirectHref(target.url));
|
|
22
|
-
} catch (error_) {
|
|
23
|
-
const normalized = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
24
|
-
setError(normalized);
|
|
25
|
-
throw normalized;
|
|
26
|
-
} finally {
|
|
27
|
-
setPending(false);
|
|
28
|
-
}
|
|
29
|
-
}, [trigger]);
|
|
30
|
-
return {
|
|
31
|
-
checkout,
|
|
32
|
-
error,
|
|
33
|
-
pending
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const RedirectButton = (t0) => {
|
|
37
|
-
const $ = c(11);
|
|
38
|
-
const {
|
|
39
|
-
"aria-label": ariaLabel,
|
|
40
|
-
children,
|
|
41
|
-
className,
|
|
42
|
-
disabled,
|
|
43
|
-
onError,
|
|
44
|
-
title,
|
|
45
|
-
trigger
|
|
46
|
-
} = t0;
|
|
47
|
-
const {
|
|
48
|
-
checkout,
|
|
49
|
-
pending
|
|
50
|
-
} = useCheckout(trigger);
|
|
51
|
-
let t1;
|
|
52
|
-
if ($[0] !== checkout || $[1] !== onError) {
|
|
53
|
-
t1 = () => {
|
|
54
|
-
checkout().catch((error) => {
|
|
55
|
-
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
56
|
-
onError?.(normalized);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
$[0] = checkout;
|
|
60
|
-
$[1] = onError;
|
|
61
|
-
$[2] = t1;
|
|
62
|
-
} else {
|
|
63
|
-
t1 = $[2];
|
|
64
|
-
}
|
|
65
|
-
const handleClick = t1;
|
|
66
|
-
const t2 = disabled === true || pending;
|
|
67
|
-
let t3;
|
|
68
|
-
if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== handleClick || $[7] !== pending || $[8] !== t2 || $[9] !== title) {
|
|
69
|
-
t3 = /* @__PURE__ */ jsxDEV("button", {
|
|
70
|
-
"aria-busy": pending,
|
|
71
|
-
"aria-label": ariaLabel,
|
|
72
|
-
className,
|
|
73
|
-
disabled: t2,
|
|
74
|
-
onClick: handleClick,
|
|
75
|
-
title,
|
|
76
|
-
type: "button",
|
|
77
|
-
children
|
|
78
|
-
}, void 0, false);
|
|
79
|
-
$[3] = ariaLabel;
|
|
80
|
-
$[4] = children;
|
|
81
|
-
$[5] = className;
|
|
82
|
-
$[6] = handleClick;
|
|
83
|
-
$[7] = pending;
|
|
84
|
-
$[8] = t2;
|
|
85
|
-
$[9] = title;
|
|
86
|
-
$[10] = t3;
|
|
87
|
-
} else {
|
|
88
|
-
t3 = $[10];
|
|
89
|
-
}
|
|
90
|
-
return t3;
|
|
91
|
-
};
|
|
92
|
-
const CheckoutButton = (t0) => {
|
|
93
|
-
const $ = c(11);
|
|
94
|
-
let onCheckout;
|
|
95
|
-
let rest;
|
|
96
|
-
if ($[0] !== t0) {
|
|
97
|
-
({
|
|
98
|
-
onCheckout,
|
|
99
|
-
...rest
|
|
100
|
-
} = t0);
|
|
101
|
-
$[0] = t0;
|
|
102
|
-
$[1] = onCheckout;
|
|
103
|
-
$[2] = rest;
|
|
104
|
-
} else {
|
|
105
|
-
onCheckout = $[1];
|
|
106
|
-
rest = $[2];
|
|
107
|
-
}
|
|
108
|
-
const {
|
|
109
|
-
"aria-label": ariaLabel,
|
|
110
|
-
children,
|
|
111
|
-
className,
|
|
112
|
-
disabled,
|
|
113
|
-
onError,
|
|
114
|
-
title
|
|
115
|
-
} = rest;
|
|
116
|
-
let t1;
|
|
117
|
-
if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onCheckout || $[8] !== onError || $[9] !== title) {
|
|
118
|
-
t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
|
|
119
|
-
"aria-label": ariaLabel,
|
|
120
|
-
className,
|
|
121
|
-
disabled,
|
|
122
|
-
onError,
|
|
123
|
-
title,
|
|
124
|
-
trigger: onCheckout,
|
|
125
|
-
children
|
|
126
|
-
}, void 0, false);
|
|
127
|
-
$[3] = ariaLabel;
|
|
128
|
-
$[4] = children;
|
|
129
|
-
$[5] = className;
|
|
130
|
-
$[6] = disabled;
|
|
131
|
-
$[7] = onCheckout;
|
|
132
|
-
$[8] = onError;
|
|
133
|
-
$[9] = title;
|
|
134
|
-
$[10] = t1;
|
|
135
|
-
} else {
|
|
136
|
-
t1 = $[10];
|
|
137
|
-
}
|
|
138
|
-
return t1;
|
|
139
|
-
};
|
|
140
|
-
const CustomerPortalButton = (t0) => {
|
|
141
|
-
const $ = c(11);
|
|
142
|
-
let onPortal;
|
|
143
|
-
let rest;
|
|
144
|
-
if ($[0] !== t0) {
|
|
145
|
-
({
|
|
146
|
-
onPortal,
|
|
147
|
-
...rest
|
|
148
|
-
} = t0);
|
|
149
|
-
$[0] = t0;
|
|
150
|
-
$[1] = onPortal;
|
|
151
|
-
$[2] = rest;
|
|
152
|
-
} else {
|
|
153
|
-
onPortal = $[1];
|
|
154
|
-
rest = $[2];
|
|
155
|
-
}
|
|
156
|
-
const {
|
|
157
|
-
"aria-label": ariaLabel,
|
|
158
|
-
children,
|
|
159
|
-
className,
|
|
160
|
-
disabled,
|
|
161
|
-
onError,
|
|
162
|
-
title
|
|
163
|
-
} = rest;
|
|
164
|
-
let t1;
|
|
165
|
-
if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onError || $[8] !== onPortal || $[9] !== title) {
|
|
166
|
-
t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
|
|
167
|
-
"aria-label": ariaLabel,
|
|
168
|
-
className,
|
|
169
|
-
disabled,
|
|
170
|
-
onError,
|
|
171
|
-
title,
|
|
172
|
-
trigger: onPortal,
|
|
173
|
-
children
|
|
174
|
-
}, void 0, false);
|
|
175
|
-
$[3] = ariaLabel;
|
|
176
|
-
$[4] = children;
|
|
177
|
-
$[5] = className;
|
|
178
|
-
$[6] = disabled;
|
|
179
|
-
$[7] = onError;
|
|
180
|
-
$[8] = onPortal;
|
|
181
|
-
$[9] = title;
|
|
182
|
-
$[10] = t1;
|
|
183
|
-
} else {
|
|
184
|
-
t1 = $[10];
|
|
185
|
-
}
|
|
186
|
-
return t1;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export { CheckoutButton, CustomerPortalButton, useCheckout };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { c } from 'react/compiler-runtime';
|
|
3
|
-
import { LunoraError } from '@lunora/errors';
|
|
4
|
-
import { QueryClientContext, QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { use, useState, createContext } from 'react';
|
|
6
|
-
import { jsxDEV } from 'react/jsx-dev-runtime';
|
|
7
|
-
|
|
8
|
-
const LunoraContext = /* @__PURE__ */ createContext(null);
|
|
9
|
-
const createDefaultQueryClient = () => new QueryClient({
|
|
10
|
-
defaultOptions: {
|
|
11
|
-
mutations: {
|
|
12
|
-
retry: 0
|
|
13
|
-
},
|
|
14
|
-
queries: {
|
|
15
|
-
gcTime: 5 * 6e4,
|
|
16
|
-
retry: 0,
|
|
17
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
const LunoraProvider = (t0) => {
|
|
22
|
-
const $ = c(9);
|
|
23
|
-
const {
|
|
24
|
-
children,
|
|
25
|
-
client,
|
|
26
|
-
queryClient
|
|
27
|
-
} = t0;
|
|
28
|
-
const parentQueryClient = use(QueryClientContext);
|
|
29
|
-
let t1;
|
|
30
|
-
if ($[0] !== parentQueryClient || $[1] !== queryClient) {
|
|
31
|
-
t1 = () => queryClient ?? parentQueryClient ?? createDefaultQueryClient();
|
|
32
|
-
$[0] = parentQueryClient;
|
|
33
|
-
$[1] = queryClient;
|
|
34
|
-
$[2] = t1;
|
|
35
|
-
} else {
|
|
36
|
-
t1 = $[2];
|
|
37
|
-
}
|
|
38
|
-
const [internalClient] = useState(t1);
|
|
39
|
-
const effectiveClient = queryClient ?? parentQueryClient ?? internalClient;
|
|
40
|
-
if (!effectiveClient) {
|
|
41
|
-
throw new LunoraError("INTERNAL", "LunoraProvider: failed to resolve a QueryClient");
|
|
42
|
-
}
|
|
43
|
-
let t2;
|
|
44
|
-
if ($[3] !== children || $[4] !== client) {
|
|
45
|
-
t2 = /* @__PURE__ */ jsxDEV(LunoraContext, {
|
|
46
|
-
value: client,
|
|
47
|
-
children
|
|
48
|
-
}, void 0, false);
|
|
49
|
-
$[3] = children;
|
|
50
|
-
$[4] = client;
|
|
51
|
-
$[5] = t2;
|
|
52
|
-
} else {
|
|
53
|
-
t2 = $[5];
|
|
54
|
-
}
|
|
55
|
-
const content = t2;
|
|
56
|
-
if (parentQueryClient === effectiveClient) {
|
|
57
|
-
return content;
|
|
58
|
-
}
|
|
59
|
-
let t3;
|
|
60
|
-
if ($[6] !== content || $[7] !== effectiveClient) {
|
|
61
|
-
t3 = /* @__PURE__ */ jsxDEV(QueryClientProvider, {
|
|
62
|
-
client: effectiveClient,
|
|
63
|
-
children: content
|
|
64
|
-
}, void 0, false);
|
|
65
|
-
$[6] = content;
|
|
66
|
-
$[7] = effectiveClient;
|
|
67
|
-
$[8] = t3;
|
|
68
|
-
} else {
|
|
69
|
-
t3 = $[8];
|
|
70
|
-
}
|
|
71
|
-
return t3;
|
|
72
|
-
};
|
|
73
|
-
const useLunora = () => {
|
|
74
|
-
const client = use(LunoraContext);
|
|
75
|
-
if (!client) {
|
|
76
|
-
throw new LunoraError("INTERNAL", "useLunora must be used inside <LunoraProvider />");
|
|
77
|
-
}
|
|
78
|
-
return client;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { LunoraProvider, useLunora };
|