@lunora/solid 1.0.0-alpha.105 → 1.0.0-alpha.106
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/README.md +1 -1
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/AuthLoading-DKoQs-9J.mjs +1 -0
- package/dist/packem_shared/{createAgent-DuksX_2d.mjs → createAgent-4wFKlDvV.mjs} +1 -1
- package/dist/packem_shared/{createAgentChat-Ch4Hqox4.mjs → createAgentChat-BcOUF-3C.mjs} +1 -1
- package/dist/packem_shared/{createAgentState-Catc7Xux.mjs → createAgentState-KojjkWsi.mjs} +1 -1
- package/dist/packem_shared/{createAgentToolEvents-BjdgzYqX.mjs → createAgentToolEvents-DUAkn3eP.mjs} +1 -1
- package/dist/packem_shared/{createFlag-DsxOYsJW.mjs → createFlag-JN9dYhDQ.mjs} +1 -1
- package/dist/packem_shared/createInfiniteQuery-BuxNVHct.mjs +1 -0
- package/dist/packem_shared/createQuery-aadhebsp.mjs +1 -0
- package/dist/packem_shared/createSubscription-DK6JFpEA.mjs +1 -0
- package/dist/packem_shared/{createVoiceAgent-BiALuzBe.mjs → createVoiceAgent-C4uRX2Ca.mjs} +1 -1
- package/dist/packem_shared/reactive-args-DwYuo-jL.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/AuthLoading-6vueEnV0.mjs +0 -1
- package/dist/packem_shared/createInfiniteQuery-BPyo9Ktw.mjs +0 -1
- package/dist/packem_shared/createQuery-CdWTlKJM.mjs +0 -1
- package/dist/packem_shared/createSubscription-CsrywUOa.mjs +0 -1
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ render(
|
|
|
104
104
|
| `createSubscription` | `useSubscription` | Raw subscription signal — unbounded live stream. |
|
|
105
105
|
| `createPaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, `results`, and `error` signals. |
|
|
106
106
|
| `createInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `createPaginatedQuery`. |
|
|
107
|
-
| `createAuth` | `useAuth` | Reactive auth state (`token`, `user` signals + `setToken`).
|
|
107
|
+
| `createAuth` | `useAuth` | Reactive auth state (`token`, `user`, `status` signals + `setToken`). |
|
|
108
108
|
| `Authenticated` / `AuthLoading` / `Unauthenticated` | — | Auth-gate components rendering `children` per identity state. |
|
|
109
109
|
| `createPresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members signal. |
|
|
110
110
|
| `createFlag` | `useFlag` | Live OpenFeature flag accessor — returns `default` until the server answers. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, SubscriptionErrorCallback, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError, Preloaded } from '@lunora/client';
|
|
2
2
|
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, Accessor } from 'solid-js';
|
|
4
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
/**
|
|
@@ -511,6 +512,12 @@ interface SolidChildrenArray extends Array<SolidChildren> {}
|
|
|
511
512
|
type SolidElement = any;
|
|
512
513
|
interface UseAuthResult {
|
|
513
514
|
setToken: (token: string | null) => void;
|
|
515
|
+
/**
|
|
516
|
+
* The resolved auth state. Branch on this, not on `user() === null` — see the
|
|
517
|
+
* contract in `@lunora/client/auth`; `user` is `null` both when signed out
|
|
518
|
+
* and when a held credential's identity could not be resolved.
|
|
519
|
+
*/
|
|
520
|
+
status: Accessor<AuthStatus>;
|
|
514
521
|
token: Accessor<string | null>;
|
|
515
522
|
user: Accessor<User | null>;
|
|
516
523
|
}
|
|
@@ -527,18 +534,22 @@ interface AuthGateProps {
|
|
|
527
534
|
/** An auth-gate component: renders its children only while the gate's condition holds. */
|
|
528
535
|
type AuthGate = (props: AuthGateProps) => SolidElement;
|
|
529
536
|
/**
|
|
530
|
-
* Render `children`
|
|
531
|
-
*
|
|
537
|
+
* Render `children` once authentication has settled in the caller's favour — a
|
|
538
|
+
* credential is held and nothing has contradicted it.
|
|
539
|
+
*
|
|
540
|
+
* Gated on the shared `AuthStatus` contract in `@lunora/client/auth`, not on
|
|
541
|
+
* `user() !== null`: an unreachable identity endpoint leaves `user` at `null`
|
|
542
|
+
* while the credential is still perfectly valid.
|
|
532
543
|
*/
|
|
533
544
|
declare const Authenticated: AuthGate;
|
|
534
545
|
/**
|
|
535
|
-
* Render `children` while authentication is still in progress —
|
|
536
|
-
*
|
|
546
|
+
* Render `children` while authentication is still in progress — a credential is
|
|
547
|
+
* held and the first identity resolve has not come back yet.
|
|
537
548
|
*/
|
|
538
549
|
declare const AuthLoading: AuthGate;
|
|
539
550
|
/**
|
|
540
|
-
* Render `children` only when auth has settled and no
|
|
541
|
-
*
|
|
551
|
+
* Render `children` only when auth has settled and there is no session — no
|
|
552
|
+
* credential, or the server answered that the credential has none.
|
|
542
553
|
*/
|
|
543
554
|
declare const Unauthenticated: AuthGate;
|
|
544
555
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, SubscriptionErrorCallback, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError, Preloaded } from '@lunora/client';
|
|
2
2
|
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, Accessor } from 'solid-js';
|
|
4
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
/**
|
|
@@ -511,6 +512,12 @@ interface SolidChildrenArray extends Array<SolidChildren> {}
|
|
|
511
512
|
type SolidElement = any;
|
|
512
513
|
interface UseAuthResult {
|
|
513
514
|
setToken: (token: string | null) => void;
|
|
515
|
+
/**
|
|
516
|
+
* The resolved auth state. Branch on this, not on `user() === null` — see the
|
|
517
|
+
* contract in `@lunora/client/auth`; `user` is `null` both when signed out
|
|
518
|
+
* and when a held credential's identity could not be resolved.
|
|
519
|
+
*/
|
|
520
|
+
status: Accessor<AuthStatus>;
|
|
514
521
|
token: Accessor<string | null>;
|
|
515
522
|
user: Accessor<User | null>;
|
|
516
523
|
}
|
|
@@ -527,18 +534,22 @@ interface AuthGateProps {
|
|
|
527
534
|
/** An auth-gate component: renders its children only while the gate's condition holds. */
|
|
528
535
|
type AuthGate = (props: AuthGateProps) => SolidElement;
|
|
529
536
|
/**
|
|
530
|
-
* Render `children`
|
|
531
|
-
*
|
|
537
|
+
* Render `children` once authentication has settled in the caller's favour — a
|
|
538
|
+
* credential is held and nothing has contradicted it.
|
|
539
|
+
*
|
|
540
|
+
* Gated on the shared `AuthStatus` contract in `@lunora/client/auth`, not on
|
|
541
|
+
* `user() !== null`: an unreachable identity endpoint leaves `user` at `null`
|
|
542
|
+
* while the credential is still perfectly valid.
|
|
532
543
|
*/
|
|
533
544
|
declare const Authenticated: AuthGate;
|
|
534
545
|
/**
|
|
535
|
-
* Render `children` while authentication is still in progress —
|
|
536
|
-
*
|
|
546
|
+
* Render `children` while authentication is still in progress — a credential is
|
|
547
|
+
* held and the first identity resolve has not come back yet.
|
|
537
548
|
*/
|
|
538
549
|
declare const AuthLoading: AuthGate;
|
|
539
550
|
/**
|
|
540
|
-
* Render `children` only when auth has settled and no
|
|
541
|
-
*
|
|
551
|
+
* Render `children` only when auth has settled and there is no session — no
|
|
552
|
+
* credential, or the server answered that the credential has none.
|
|
542
553
|
*/
|
|
543
554
|
declare const Unauthenticated: AuthGate;
|
|
544
555
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-dPcjtn6R.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-M4s8XBXV.mjs";import{createAgent as m}from"./packem_shared/createAgent-
|
|
1
|
+
import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-dPcjtn6R.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-M4s8XBXV.mjs";import{createAgent as m}from"./packem_shared/createAgent-4wFKlDvV.mjs";import{createAgentChat as x}from"./packem_shared/createAgentChat-BcOUF-3C.mjs";import{createAgentState as u}from"./packem_shared/createAgentState-KojjkWsi.mjs";import{createAgentToolEvents as A}from"./packem_shared/createAgentToolEvents-DUAkn3eP.mjs";import{AuthLoading as l,Authenticated as s,Unauthenticated as h,createAuth as C}from"./packem_shared/AuthLoading-DKoQs-9J.mjs";import{default as y}from"./packem_shared/createConnectionStatus-BnlXYWeE.mjs";import{createFlag as P,createFlags as S}from"./packem_shared/createFlag-JN9dYhDQ.mjs";import{createMutation as Q,createMutationForClient as v}from"./packem_shared/createMutation-DcSsIbGF.mjs";import{createMutator as E}from"./packem_shared/createMutator-q9cMjGKv.mjs";import{createInfiniteQuery as R,createPaginatedQuery as T}from"./packem_shared/createInfiniteQuery-BuxNVHct.mjs";import{createPresence as V}from"./packem_shared/createPresence-Bu4loG39.mjs";import{createQuery as k}from"./packem_shared/createQuery-aadhebsp.mjs";import{createRateLimit as w}from"./packem_shared/createRateLimit-CIVWrD5H.mjs";import{createStream as B}from"./packem_shared/createStream-Dx7SnivS.mjs";import{createSubscription as G}from"./packem_shared/createSubscription-DK6JFpEA.mjs";import{createVoiceAgent as J}from"./packem_shared/createVoiceAgent-C4uRX2Ca.mjs";import{default as N}from"./packem_shared/hydratePreloaded-Bhxdstm1.mjs";import{LunoraProvider as W}from"./packem_shared/LunoraProvider-BKWckcDR.mjs";export{l as AuthLoading,s as Authenticated,r as LunoraContext,W as LunoraProvider,h as Unauthenticated,c as createAction,n as createActionForClient,m as createAgent,x as createAgentChat,u as createAgentState,A as createAgentToolEvents,C as createAuth,y as createConnectionStatus,P as createFlag,S as createFlags,R as createInfiniteQuery,Q as createMutation,v as createMutationForClient,E as createMutator,T as createPaginatedQuery,V as createPresence,k as createQuery,w as createRateLimit,B as createStream,G as createSubscription,J as createVoiceAgent,N as hydratePreloaded,o as useLunora};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getIdentityStore as d,isAuthenticatedStatus as k,isLoadingStatus as l}from"@lunora/client/auth";import{createSignal as s,onCleanup as m,createComponent as A,Show as T}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";const U=()=>{const t=p(),e=d(t),[n,r]=s(t.getAuthToken()),[a,c]=s(e.getUser()),[i,h]=s(e.getStatus()),g=t.onAuthTokenChange(o=>{r(()=>o)}),S=e.subscribe(()=>{c(()=>e.getUser()),h(()=>e.getStatus())});return m(()=>{g(),S()}),{setToken:o=>{t.setAuthToken(o)},status:i,token:n,user:a}},b=T,u=t=>e=>{const n=U();return A(b,{get children(){return e.children},get when(){return t(n)}})},x=u(({status:t})=>k(t())),y=u(({status:t})=>l(t())),G=u(({status:t})=>t()==="unauthenticated");export{y as AuthLoading,x as Authenticated,G as Unauthenticated,U as createAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DcSsIbGF.mjs";import{createSubscription as R}from"./createSubscription-
|
|
1
|
+
import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DcSsIbGF.mjs";import{createSubscription as R}from"./createSubscription-DK6JFpEA.mjs";const _={__lunoraRef:""},a=t=>typeof t=="function"?t():t,b=t=>{const{api:u,cancel:c,onError:d,run:f,runArgs:m,threadKey:n}=t,o=i(f),p=i(c??_),{data:y,error:g}=R(u.agents.agentThread,()=>({key:a(n)}),{onError:d}),r=s(()=>y()),h=s(()=>r()?.status),M=async(e,l)=>{await o.mutate({input:e,threadKey:a(n),...m,...l})};return{cancel:async()=>{const e=r()?.instanceId;c===void 0||e===void 0||await p.mutate({instanceId:e,threadKey:a(n)})},error:g,pending:o.pending,run:M,status:h,thread:r}};export{_ as NO_MUTATION_REF,b as createAgent,a as resolveMaybe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reconcileOptimistic as E,maxSeq as M}from"@lunora/client";import{createMemo as s,createSignal as B}from"solid-js";import{resolveMaybe as o,NO_MUTATION_REF as G}from"./createAgent-
|
|
1
|
+
import{reconcileOptimistic as E,maxSeq as M}from"@lunora/client";import{createMemo as s,createSignal as B}from"solid-js";import{resolveMaybe as o,NO_MUTATION_REF as G}from"./createAgent-4wFKlDvV.mjs";import{createMutation as u}from"./createMutation-DcSsIbGF.mjs";import{createStream as H}from"./createStream-Dx7SnivS.mjs";import{createSubscription as k}from"./createSubscription-DK6JFpEA.mjs";import{t as J}from"./solid-compat-ByG5HD_F.mjs";const L={__lunoraRef:""},nt=R=>{const{api:m,cancel:l,limit:h,onError:f,send:S,sendArgs:b,stream:g,threadKey:n}=R,{data:w,error:x}=k(m.agents.agentMessages,()=>{const t=o(n);return h===void 0?{key:t}:{key:t,limit:h}},{onError:f}),{data:I,error:_}=k(m.agents.agentThread,()=>({key:o(n)}),{onError:f}),K=s(()=>x()??_()),O=g===void 0?"skip":()=>({key:o(n)}),{chunks:T}=H(g??L,O),j=u(S),q=u(l??G),C=u(m.agents.agentResolveApproval),[y,d]=B([]);let v=0;J(()=>o(n),()=>{y().length>0&&d([])});const p=s(()=>I()),D=s(()=>p()?.status),i=s(()=>w()??[]),N=s(()=>{const t=i(),r=E(y(),t);if(r.length===0)return t;const e=M(t);return[...t,...r.map((a,c)=>({content:a.content,optimistic:!0,role:"user",seq:e+1+c}))]}),F=s(()=>{const t=o(n),r=i().filter(e=>e.role==="assistant").length;return T().filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=r).map(e=>e.text).join("")}),U=async(t,r)=>{const e=v;v+=1;const a=M(i());d(c=>[...E(c,i()),{content:t,id:e,maxDurableSeqAtSend:a}]);try{await j.mutate({input:t,threadKey:o(n),...b,...r})}catch(c){throw d($=>$.filter(z=>z.id!==e)),c}},A=async(t,r,e)=>{const a=p()?.instanceId;if(a===void 0)throw new Error(`createAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await C.mutate({decision:t,instanceId:a,threadKey:o(n),toolCallId:r,...e===void 0?{}:{note:e}})};return{approve:async(t,r)=>A("approve",t,r),cancel:async()=>{const t=p()?.instanceId;l===void 0||t===void 0||await q.mutate({instanceId:t,threadKey:o(n)})},error:K,messages:N,reject:async(t,r)=>A("reject",t,r),send:U,status:D,streamingText:F}};export{nt as createAgentChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-
|
|
1
|
+
import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-4wFKlDvV.mjs";import{createSubscription as c}from"./createSubscription-DK6JFpEA.mjs";const p=e=>{const{data:t,error:r}=c(e.api.agents.agentState,()=>({key:n(e.threadKey)})),a=o(()=>t());return{error:r,state:a}};export{p as createAgentState};
|
package/dist/packem_shared/{createAgentToolEvents-BjdgzYqX.mjs → createAgentToolEvents-DUAkn3eP.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-
|
|
1
|
+
import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-4wFKlDvV.mjs";import{createStream as f}from"./createStream-Dx7SnivS.mjs";import{createSubscription as y}from"./createSubscription-DK6JFpEA.mjs";const C={__lunoraRef:""},I=[],N=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},_=t=>{const{api:r,limit:a,stream:i,threadKey:e}=t,u=()=>{const l=n(e);return a===void 0?{key:l}:{key:l,limit:a}},{data:p}=y(r.agents.agentMessages,u),s=i===void 0?"skip":()=>({key:n(e)}),{chunks:c}=f(i??C,s);return{events:v(()=>{const l=n(e),d=(p()??I).flatMap(o=>N(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===l&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{_ as createAgentToolEvents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as u}from"solid-js";import{useLunora as a}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as b}from"./createAgent-
|
|
1
|
+
import{createSignal as u}from"solid-js";import{useLunora as a}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as b}from"./createAgent-4wFKlDvV.mjs";import{t as d,o as m}from"./solid-compat-ByG5HD_F.mjs";const _="__lunora_flags__:eval",p=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},y={__lunoraRef:_},f=(t,e,r)=>{try{return t.subscribe(y,{default:e.default,key:e.key,type:p(e.default)},o=>{r(o)},{onError:()=>{r(e.default)}})}catch{return()=>{}}},A=(t,e)=>{const r=a(),[o,s]=u(e);return d(()=>b(t),n=>(s(()=>e),f(r,{default:e,key:n},c=>{s(()=>c)}))),o},E=t=>{const e=a(),[r,o]=u(t);return m(()=>{const s=[];for(const[n,c]of Object.entries(t))s.push(f(e,{default:c,key:n},l=>{o(i=>({...i,[n]:l}))}));return()=>{for(const n of s)n()}}),r};export{A as createFlag,E as createFlags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{initialPages as O,derivePaginationStatus as Q,applyLoadMore as W,rebalance as j}from"@lunora/client/pagination";import{createMemo as y,createSignal as I}from"solid-js";import{t as D,s as G}from"./reactive-args-DwYuo-jL.mjs";import{useLunora as H}from"./LunoraContext-dPcjtn6R.mjs";import{t as J}from"./solid-compat-ByG5HD_F.mjs";const R=(t,n)=>({...n,paginationOpts:{cursor:t.lower,endCursor:t.upper,numItems:t.numItems}}),w=(t,n)=>`${t}::${G(n)}`,$=(t,n,M)=>{const S=H(),{initialNumItems:b,onError:v,shardKey:P}=M,i=()=>typeof n=="function"?n():n,[l,p]=I(O(b)),a=new Map,[h,x]=I([]),[E,g]=I(void 0),L=new Map,K=new Set,_=(e,r)=>{const f=e.map(s=>{const o=w(t.__lunoraRef,R(s,r));return a.get(o)});x(f)},q=(e,r,f)=>{const s=o=>w(t.__lunoraRef,R(o,f));for(const o of r){const c=s(o);if(a.has(c))continue;const k=e.find(u=>u.lower===o.lower);if(k){const u=a.get(s(k));u&&a.set(c,u)}}},z=(e,r)=>{const f=new Set;for(const s of e)f.add(w(t.__lunoraRef,R(s,r)));for(const[s,o]of L)f.has(s)||(o(),L.delete(s),K.delete(s),a.delete(s));for(const s of e){const o=R(s,r),c=w(t.__lunoraRef,o);if(L.has(c))continue;K.add(c);const k=S.subscribe(t,o,u=>{a.set(c,u),K.delete(c),g(void 0);const d=i();if(d!=="skip"&&(_(l(),d),K.size===0)){const m=l(),C=j(m,h());C&&(q(m,C,d),p(C))}},{onError:u=>{K.delete(c),g(u);const d=l(),m=d.at(-1);d.length>1&&m&&!a.has(c)&&w(t.__lunoraRef,R(m,r))===c&&p(d.slice(0,-1)),v?.(u)},shardKey:P});L.set(c,k)}};let N=!1,A=!1;const F=(e,r)=>{if(N){A=!0;return}N=!0;try{let f=e,s=r;do{A=!1,z(f,s);const o=i();if(o==="skip")break;f=l(),s=o}while(A)}finally{N=!1}},T=()=>{for(const e of L.values())e();L.clear(),a.clear(),K.clear()};D(i,e=>(T(),p(O(b)),x([]),g(void 0),e!=="skip"&&(F(l(),e),_(l(),e)),T)),J(l,e=>{const r=i();r!=="skip"&&(F(e,r),_(e,r))});const B=y(()=>{const e=i()==="skip";return Q(e,h()).status});return{error:E,loadMore:e=>{const r=i();if(r==="skip")return;const{nextCursor:f,status:s}=Q(!1,h());if(s!=="CanLoadMore")return;const o=W(l(),f,e);if(!o)return;const c=l().at(-1),k=o.at(-2);if(c&&k){const u=w(t.__lunoraRef,R(c,r)),d=w(t.__lunoraRef,R(k,r));if(u!==d){const m=a.get(u);m&&a.set(d,m)}}g(void 0),p(o)},pageResults:h,status:B}},te=(t,n,M)=>{const{error:S,loadMore:b,pageResults:v,status:P}=$(t,n,M),i=y(()=>v().flatMap(a=>a?.page??[])),l=y(()=>(typeof n=="function"?n():n)==="skip"),p=y(()=>!l()&&(P()==="LoadingFirstPage"||P()==="LoadingMore"));return{error:S,isLoading:p,loadMore:b,results:i,status:P}},se=(t,n,M)=>{const{initialNumItems:S}=M,{error:b,loadMore:v,pageResults:P,status:i}=$(t,n,M),l=y(()=>P().flatMap(g=>g?[g.page]:[])),p=y(()=>(typeof n=="function"?n():n)==="skip"),a=y(()=>!p()&&i()==="LoadingFirstPage"),h=y(()=>i()==="CanLoadMore"),x=y(()=>!p()&&i()==="LoadingMore");return{error:b,fetchNextPage:g=>{v(g??S)},hasNextPage:h,isFetchingNextPage:x,isLoading:a,pages:l,status:i}};export{se as createInfiniteQuery,te as createPaginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as m}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./reactive-args-DwYuo-jL.mjs";const E=(o,r,t={})=>{const n=p(),{onError:s,shardKey:c}=t,[i,e]=m(void 0);return l(()=>typeof r=="function"?r():r,u=>(e(()=>{}),f(n,o,u,{onData:a=>{e(()=>a)},onError:s,onReset:()=>{e(()=>{})}},{shardKey:c}))),i};export{E as createQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{createSignal as d}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{t as u}from"./reactive-args-DwYuo-jL.mjs";const A=(i,r,n={})=>{const m=p(),[s,e]=d(void 0),[c,t]=d(void 0);return u(typeof r=="function"?r:()=>r,a=>{if(e(()=>{}),t(()=>{}),a!=="skip")return v(m,i,a,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new l(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{}),n.onError?.(o)},onReset:()=>{e(()=>{})}},{shardKey:n.shardKey})}),{data:s,error:c}};export{A as createSubscription};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as y,onCleanup as J}from"solid-js";import{useLunora as G}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as X}from"./createAgent-
|
|
1
|
+
import{createSignal as y,onCleanup as J}from"solid-js";import{useLunora as G}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as X}from"./createAgent-4wFKlDvV.mjs";const D="/_lunora/ws",j="/_lunora/voice/",z=4001,F=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,Q=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},Y=(e,r)=>{if(r===void 0||r==="")return F(e);if(r.endsWith(D))return r.slice(0,-D.length);try{return new URL(r).origin}catch{return F(e)}},Z=e=>{const r=Y(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${j}${encodeURIComponent(e.agent)}?${i.toString()}`},ee=(e,r)=>{if(r?.code===z)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},te=(e,r,s)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},ne=16e3,re=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},oe=(e,r)=>{const s=r/ne,i=s>1?Math.floor(e.length/s):e.length,f=new ArrayBuffer(i*2),l=new DataView(f);for(let u=0;u<i;u+=1){const k=e[Math.floor(u*s)]??0,g=Math.max(-1,Math.min(1,k));l.setInt16(u*2,g<0?g*32768:g*32767,!0)}return new Uint8Array(f)},se=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!s||!i)throw new Error("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const f=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),l=new i,u=l.createMediaStreamSource(f),k=l.createScriptProcessor(4096,1,1);let g=!1,w=!1,c=0,p=0;return k.onaudioprocess=o=>{const h=o.inputBuffer.getChannelData(0),m=g?0:re(h);if(e.onLevel(m),g)return;if(e.onAudio(oe(h,l.sampleRate)),e.isTurnActive()){p=m>=e.interruptThreshold?p+1:0,p>=e.interruptChunks&&(p=0,e.onInterrupt());return}p=0;const b=h.length/l.sampleRate*1e3;if(m>=e.silenceThreshold){w=!0,c=0;return}w&&(c+=b,c>=e.silenceDurationMs&&(w=!1,c=0,e.onSilence()))},u.connect(k),k.connect(l.destination),{setMuted:o=>{g=o},stop:()=>{k.disconnect(),u.disconnect();for(const o of f.getTracks())o.stop();l.close()}}},ae=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let f=0,l=Promise.resolve(),u=0;const k=async(c,p)=>{if(p!==u)return;let o;try{o=await s.decodeAudioData(c.buffer)}catch{return}if(p!==u)return;const h=s.createBufferSource();h.buffer=o,h.connect(s.destination);const m=Math.max(s.currentTime,f);h.start(m),f=m+o.duration,i.add(h),h.onended=()=>{i.delete(h)}},g=c=>{const p=Uint8Array.from(c),o=u;l=l.then(()=>k(p,o))},w=()=>{u+=1;for(const c of i)try{c.stop()}catch{}i.clear(),f=s.currentTime};return{enqueue:g,interrupt:w,stop:()=>{w(),s.close()}}},V=1,ie=.01,ce=1200,ue=.15,le=3,fe=e=>{const{createMicrophone:r=se,createSpeaker:s=ae,createSocket:i,interruptChunks:f=le,interruptThreshold:l=ue,silenceDurationMs:u=ce,silenceThreshold:k=ie,threadKey:g,voice:w}=e,c=G(),[p,o]=y("idle"),[h,m]=y(!1),[b,M]=y(""),[W,v]=y(""),[N,x]=y(0),[I,U]=y(!1),[O,S]=y(void 0);let a,C=!1;const _=t=>{const n=a?.socket;return n?.readyState===V?(n.send(JSON.stringify(t)),!0):!1},T=()=>{const t=a;if(a=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}C=!1,m(!1),o("idle"),x(0)},P=T,H=t=>{const n=a;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),o("speaking"),v(R=>R+t.text);break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),v(t.text),o("listening");break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),S(new Error(t.message)),o("listening");break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),o("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),m(!0),o("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),M(t.text),v(""),o("thinking");break}}},$=t=>{const n=a;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,o("speaking"),n.speaker.enqueue(t))},B=async()=>{if(a||C)return;C=!0,S(void 0),M(""),v("");let t;try{const n=Z({agent:Q(w.__lunoraRef),httpUrl:c.url,threadKey:X(g),wsUrl:c.wsUrl}),A=(i??(d=>{const E=c.getWebSocketImpl();if(!E)throw new Error("createVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new E(d)}))(n);A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},a=t,t.unwatchIdentity=te(c,"createVoiceAgent",d=>{a===t&&(S(d),T())}),A.onmessage=d=>{if(typeof d.data=="string"){try{H(JSON.parse(d.data))}catch{}return}$(new Uint8Array(d.data))},A.onerror=()=>{S(new Error("createVoiceAgent: voice socket error"))},A.onclose=d=>{if(a!==t)return;const E=ee("createVoiceAgent",d);E&&S(E),T()};const L=await r({interruptChunks:f,interruptThreshold:l,isTurnActive:()=>(a?.speaking??!1)||(a?.awaitingTurn??!1),onAudio:d=>{A.readyState===V&&A.send(d)},onInterrupt:()=>{_({type:"interrupt"}),a?.speaker?.interrupt(),a&&(a.awaitingTurn=!1,a.speaking=!1,a.suppressAudio=!0),o("listening")},onLevel:d=>{x(d)},onSilence:()=>{_({type:"commit"}),a&&(a.awaitingTurn=!0),o("thinking")},silenceDurationMs:u,silenceThreshold:k});a===t?(t.microphone=L,U(!1),t.speaking||o("listening")):L.stop()}catch(n){a===t&&(S(n instanceof Error?n:new Error(String(n))),T())}finally{C=!1}},K=()=>{const t=!I();return a?.microphone?.setMuted(t),U(t),t},q=t=>{_({text:t,type:"text"})&&(a&&(a.awaitingTurn=!0),o("thinking"))};return J(T),{audioLevel:N,connected:h,endCall:P,error:O,interimTranscript:W,isMuted:I,sendText:q,startCall:B,status:p,toggleMute:K,transcript:b}};export{fe as createVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMemo as w}from"solid-js";import{t as O}from"./solid-compat-ByG5HD_F.mjs";const l=/["\\\u0000-\u001F\uD800-\uDFFF]/,d=r=>l.test(r)?JSON.stringify(r):`"${r}"`,b=r=>{if(r===void 0)return"null";if(typeof r=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof r=="number"){if(Number.isNaN(r))return"nan";if(r===1/0)return"inf";if(r===-1/0)return"-inf";if(Object.is(r,-0))return"-0"}if(typeof r=="string")return d(r);if(r===null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r)){let e="[";for(let i=0;i<r.length;i++)i>0&&(e+=","),e+=b(r[i]);return e+"]"}const n=Object.getPrototypeOf(r);if(n!==null&&n!==Object.prototype){const e=r.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${e} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=r,c=Object.keys(s).sort();let f="{",t=!0;for(const e of c){const i=s[e];i!==void 0&&(t?t=!1:f+=",",f+=d(e),f+=":",f+=b(i))}return f+"}"},u=r=>{let n="";for(let c=0;c<r.length;c+=32768)n+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(n)},o="$lunora.wire$",g=64,m="__proto__",S=r=>{if(r===null||typeof r!="object")return!1;const n=Object.getPrototypeOf(r);return n===null||n===Object.prototype},a=(r,n=0)=>{if(n>g)throw new RangeError(`wire-codec: value nesting exceeds the ${g}-level limit`);if(r===void 0)return[o,"undefined"];if(r===null)return null;const s=typeof r;if(s==="bigint")return[o,"bigint",r.toString()];if(s==="number"){const t=r;return Number.isNaN(t)?[o,"nan"]:t===1/0?[o,"inf"]:t===-1/0?[o,"-inf"]:t}if(s!=="object")return r;if(r instanceof Date)return[o,"date",a(r.getTime(),n+1)];if(r instanceof Error){const t=r,e={};for(const y of Object.keys(t)){if(t[y]===void 0)continue;const p=a(t[y],n+1);y===m?Object.defineProperty(e,y,{configurable:!0,enumerable:!0,value:p,writable:!0}):e[y]=p}const i=[o,"error",String(t.name),String(t.message),e];return t.cause!==void 0&&i.push(a(t.cause,n+1)),i}if(r instanceof URL)return[o,"url",r.href];if(r instanceof Map)return[o,"map",[...r.entries()].map(([t,e])=>[a(t,n+1),a(e,n+1)])];if(r instanceof Set)return[o,"set",[...r].map(t=>a(t,n+1))];if(r instanceof ArrayBuffer)return[o,"bytes",u(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const t=r,e=t.constructor.name,i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return e==="Uint8Array"?[o,"bytes",u(i)]:[o,"bytes",u(i),e]}if(Array.isArray(r)){const t=r.map(e=>a(e,n+1));return t.length>0&&t[0]===o?[o,"arr",t]:t}if(!S(r)){const t=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} 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,f={};for(const t of Object.keys(c)){const e=c[t];if(e===void 0)continue;const i=a(e,n+1);t===m?Object.defineProperty(f,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):f[t]=i}return f},j=r=>b(a(r)),A=(r,n)=>{const s=w(()=>j(r()));O(s,()=>n(r()))};export{j as s,A as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/solid",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.106",
|
|
4
4
|
"description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.102",
|
|
58
58
|
"@lunora/errors": "1.0.0-alpha.36",
|
|
59
59
|
"@lunora/ratelimit": "1.0.0-alpha.57",
|
|
60
60
|
"@visulima/storage-client": "1.0.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getIdentityStore as i}from"@lunora/client/auth";import{createSignal as r,onCleanup as g,createComponent as k,Show as m}from"solid-js";import{useLunora as T}from"./LunoraContext-dPcjtn6R.mjs";const d=()=>{const t=T(),e=i(t),[n,u]=r(t.getAuthToken()),[c,l]=r(e.getUser()),a=t.onAuthTokenChange(o=>{u(()=>o)}),h=e.subscribe(()=>{l(()=>e.getUser())});return g(()=>{a(),h()}),{setToken:o=>{t.setAuthToken(o)},token:n,user:c}},f=m,s=t=>e=>{const n=d();return k(f,{get children(){return e.children},get when(){return t(n)}})},b=s(({token:t,user:e})=>t()===null?!1:e()!==null),w=s(({token:t,user:e})=>t()===null?!1:e()===null),C=s(({token:t,user:e})=>t()===null?e()===null:!1);export{w as AuthLoading,b as Authenticated,C as Unauthenticated,d as createAuth};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{initialPages as U,derivePaginationStatus as J,applyLoadMore as Y,rebalance as Z}from"@lunora/client/pagination";import{createMemo as h,createSignal as I}from"solid-js";import{useLunora as v}from"./LunoraContext-dPcjtn6R.mjs";import{t as W}from"./solid-compat-ByG5HD_F.mjs";const ee=/["\\\u0000-\u001F\uD800-\uDFFF]/,q=e=>ee.test(e)?JSON.stringify(e):`"${e}"`,C=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(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return q(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(let o=0;o<e.length;o++)o>0&&(r+=","),r+=C(e[o]);return r+"]"}const n=Object.getPrototypeOf(e);if(n!==null&&n!==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 d=e,y=Object.keys(d).sort();let u="{",t=!0;for(const r of y){const o=d[r];o!==void 0&&(t?t=!1:u+=",",u+=q(r),u+=":",u+=C(o))}return u+"}"},T=e=>{let n="";for(let y=0;y<e.length;y+=32768)n+=String.fromCharCode(...e.subarray(y,y+32768));return btoa(n)},l="$lunora.wire$",Q=64,z="__proto__",te=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},S=(e,n=0)=>{if(n>Q)throw new RangeError(`wire-codec: value nesting exceeds the ${Q}-level limit`);if(e===void 0)return[l,"undefined"];if(e===null)return null;const d=typeof e;if(d==="bigint")return[l,"bigint",e.toString()];if(d==="number"){const t=e;return Number.isNaN(t)?[l,"nan"]:t===1/0?[l,"inf"]:t===-1/0?[l,"-inf"]:t}if(d!=="object")return e;if(e instanceof Date)return[l,"date",S(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const i of Object.keys(t)){if(t[i]===void 0)continue;const b=S(t[i],n+1);i===z?Object.defineProperty(r,i,{configurable:!0,enumerable:!0,value:b,writable:!0}):r[i]=b}const o=[l,"error",String(t.name),String(t.message),r];return t.cause!==void 0&&o.push(S(t.cause,n+1)),o}if(e instanceof URL)return[l,"url",e.href];if(e instanceof Map)return[l,"map",[...e.entries()].map(([t,r])=>[S(t,n+1),S(r,n+1)])];if(e instanceof Set)return[l,"set",[...e].map(t=>S(t,n+1))];if(e instanceof ArrayBuffer)return[l,"bytes",T(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[l,"bytes",T(o)]:[l,"bytes",T(o),r]}if(Array.isArray(e)){const t=e.map(r=>S(r,n+1));return t.length>0&&t[0]===l?[l,"arr",t]:t}if(!te(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} 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=e,u={};for(const t of Object.keys(y)){const r=y[t];if(r===void 0)continue;const o=S(r,n+1);t===z?Object.defineProperty(u,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):u[t]=o}return u},ne=e=>C(S(e)),A=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),R=(e,n)=>`${e}::${ne(n)}`,G=(e,n,d)=>{const y=v(),{initialNumItems:u,onError:t,shardKey:r}=d,o=()=>typeof n=="function"?n():n,[i,b]=I(U(u)),p=new Map,[E,L]=I([]),[$,P]=I(void 0),M=new Map,j=new Set,_=(s,f)=>{const w=s.map(c=>{const a=R(e.__lunoraRef,A(c,f));return p.get(a)});L(w)},H=(s,f,w)=>{const c=a=>R(e.__lunoraRef,A(a,w));for(const a of f){const g=c(a);if(p.has(g))continue;const N=s.find(m=>m.lower===a.lower);if(N){const m=p.get(c(N));m&&p.set(g,m)}}},V=(s,f)=>{const w=new Set;for(const c of s)w.add(R(e.__lunoraRef,A(c,f)));for(const[c,a]of M)w.has(c)||(a(),M.delete(c),j.delete(c),p.delete(c));for(const c of s){const a=A(c,f),g=R(e.__lunoraRef,a);if(M.has(g))continue;j.add(g);const N=y.subscribe(e,a,m=>{p.set(g,m),j.delete(g),P(void 0);const k=o();if(k!=="skip"&&(_(i(),k),j.size===0)){const O=i(),F=Z(O,E());F&&(H(O,F,k),b(F))}},{onError:m=>{j.delete(g),P(m);const k=i(),O=k.at(-1);k.length>1&&O&&!p.has(g)&&R(e.__lunoraRef,A(O,f))===g&&b(k.slice(0,-1)),t?.(m)},shardKey:r});M.set(g,N)}};let K=!1,x=!1;const B=(s,f)=>{if(K){x=!0;return}K=!0;try{let w=s,c=f;do{x=!1,V(w,c);const a=o();if(a==="skip")break;w=i(),c=a}while(x)}finally{K=!1}},D=()=>{for(const s of M.values())s();M.clear(),p.clear(),j.clear()};W(o,s=>(D(),b(U(u)),L([]),P(void 0),s!=="skip"&&(B(i(),s),_(i(),s)),D)),W(i,s=>{const f=o();f!=="skip"&&(B(s,f),_(s,f))});const X=h(()=>{const s=o()==="skip";return J(s,E()).status});return{error:$,loadMore:s=>{const f=o();if(f==="skip")return;const{nextCursor:w,status:c}=J(!1,E());if(c!=="CanLoadMore")return;const a=Y(i(),w,s);if(!a)return;const g=i().at(-1),N=a.at(-2);if(g&&N){const m=R(e.__lunoraRef,A(g,f)),k=R(e.__lunoraRef,A(N,f));if(m!==k){const O=p.get(m);O&&p.set(k,O)}}P(void 0),b(a)},pageResults:E,status:X}},ae=(e,n,d)=>{const{error:y,loadMore:u,pageResults:t,status:r}=G(e,n,d),o=h(()=>t().flatMap(p=>p?.page??[])),i=h(()=>(typeof n=="function"?n():n)==="skip"),b=h(()=>!i()&&(r()==="LoadingFirstPage"||r()==="LoadingMore"));return{error:y,isLoading:b,loadMore:u,results:o,status:r}},fe=(e,n,d)=>{const{initialNumItems:y}=d,{error:u,loadMore:t,pageResults:r,status:o}=G(e,n,d),i=h(()=>r().flatMap(P=>P?[P.page]:[])),b=h(()=>(typeof n=="function"?n():n)==="skip"),p=h(()=>!b()&&o()==="LoadingFirstPage"),E=h(()=>o()==="CanLoadMore"),L=h(()=>!b()&&o()==="LoadingMore");return{error:u,fetchNextPage:P=>{t(P??y)},hasNextPage:E,isFetchingNextPage:L,isLoading:p,pages:i,status:o}};export{fe as createInfiniteQuery,ae as createPaginatedQuery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as m}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const Q=(o,r,t={})=>{const n=p(),{onError:s,shardKey:c}=t,[i,e]=m(void 0);return l(()=>typeof r=="function"?r():r,u=>(e(()=>{}),f(n,o,u,{onData:a=>{e(()=>a)},onError:s,onReset:()=>{e(()=>{})}},{shardKey:c}))),i};export{Q as createQuery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{createSignal as d}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{t as u}from"./solid-compat-ByG5HD_F.mjs";const D=(i,r,n={})=>{const m=p(),[c,e]=d(void 0),[s,t]=d(void 0);return u(typeof r=="function"?r:()=>r,a=>{if(e(()=>{}),t(()=>{}),a!=="skip")return v(m,i,a,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new l(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{}),n.onError?.(o)},onReset:()=>{e(()=>{})}},{shardKey:n.shardKey})}),{data:c,error:s}};export{D as createSubscription};
|