@lunora/vue 1.0.0-alpha.65 → 1.0.0-alpha.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -117,14 +117,14 @@ interface UseAgentOptions {
117
117
  api: UseAgentApi;
118
118
  /**
119
119
  * Optional app mutation over the agent's cancel path
120
- * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
120
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
121
121
  * When omitted (or no run is in flight) {@link UseAgentResult.cancel} is a
122
122
  * no-op.
123
123
  */
124
124
  cancel?: FunctionReference<"mutation">;
125
125
  /**
126
126
  * The app mutation that starts (or continues) a run — a thin wrapper over
127
- * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
127
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
128
128
  * {@link UseAgentOptions.runArgs} and the per-call args.
129
129
  */
130
130
  run: FunctionReference<"mutation">;
@@ -156,7 +156,7 @@ interface UseAgentResult {
156
156
  * (durable history + streaming + approvals) use `useAgentChat`.
157
157
  *
158
158
  * `run` and `cancel` stay generic over the app-defined mutations that wrap
159
- * `ctx.agents.&lt;name>.run` / `.cancel`, so the composable hard-codes no function
159
+ * `ctx.agents.<name>.run` / `.cancel`, so the composable hard-codes no function
160
160
  * names beyond the `agents:*` surface. `threadKey` may be reactive — a changing
161
161
  * key re-subscribes to the new thread.
162
162
  */
@@ -270,7 +270,7 @@ interface UseAgentChatOptions {
270
270
  api: UseAgentChatApi;
271
271
  /**
272
272
  * Optional app mutation over the agent's cancel path
273
- * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
273
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
274
274
  * When omitted (or no run is in flight) {@link UseAgentChatResult.cancel} is a
275
275
  * no-op.
276
276
  */
@@ -279,7 +279,7 @@ interface UseAgentChatOptions {
279
279
  limit?: number;
280
280
  /**
281
281
  * The app mutation that starts (or continues) a run — a thin wrapper over
282
- * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
282
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
283
283
  * {@link UseAgentChatOptions.sendArgs} and the per-call args.
284
284
  */
285
285
  send: FunctionReference<"mutation">;
@@ -894,9 +894,9 @@ type CreateSpeaker = (config: {
894
894
  audioFormat: VoiceAudioFormat;
895
895
  }) => VoiceSpeaker;
896
896
  /**
897
- * The `agents.&lt;name>Voice` reference codegen emits for a voice-enabled agent — a
897
+ * The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
898
898
  * live, WS-backed session keyed by `threadKey`. A structural subset of the
899
- * generated member, so passing `api.agents.&lt;name>Voice` type-checks.
899
+ * generated member, so passing `api.agents.<name>Voice` type-checks.
900
900
  */
901
901
  type VoiceReference = FunctionReference<"stream", {
902
902
  threadKey: string;
@@ -938,7 +938,7 @@ interface UseVoiceAgentOptions {
938
938
  silenceThreshold?: number;
939
939
  /** The thread to converse on — shared with the agent's text turns. May be a plain value, `ref`, or getter (resolved when the call opens). */
940
940
  threadKey: MaybeRefOrGetter<string>;
941
- /** The generated `api.agents.&lt;name>Voice` reference — identifies the voice DO endpoint. */
941
+ /** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
942
942
  voice: VoiceReference;
943
943
  }
944
944
  interface UseVoiceAgentResult {
@@ -970,7 +970,7 @@ interface UseVoiceAgentResult {
970
970
  * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
971
971
  * streams the agent's synthesized speech back through the browser's audio output,
972
972
  * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
973
- * `audioLevel`) to Vue refs. Pass the generated `api.agents.&lt;name>Voice`
973
+ * `audioLevel`) to Vue refs. Pass the generated `api.agents.<name>Voice`
974
974
  * reference (never a string), matching `useAgentChat`'s reference-passing style.
975
975
  * The Vue counterpart to React's `useVoiceAgent`, re-expressed with refs; the
976
976
  * per-call connection lives in a closure variable (a composable runs once per
package/dist/index.d.ts CHANGED
@@ -117,14 +117,14 @@ interface UseAgentOptions {
117
117
  api: UseAgentApi;
118
118
  /**
119
119
  * Optional app mutation over the agent's cancel path
120
- * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
120
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
121
121
  * When omitted (or no run is in flight) {@link UseAgentResult.cancel} is a
122
122
  * no-op.
123
123
  */
124
124
  cancel?: FunctionReference<"mutation">;
125
125
  /**
126
126
  * The app mutation that starts (or continues) a run — a thin wrapper over
127
- * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
127
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
128
128
  * {@link UseAgentOptions.runArgs} and the per-call args.
129
129
  */
130
130
  run: FunctionReference<"mutation">;
@@ -156,7 +156,7 @@ interface UseAgentResult {
156
156
  * (durable history + streaming + approvals) use `useAgentChat`.
157
157
  *
158
158
  * `run` and `cancel` stay generic over the app-defined mutations that wrap
159
- * `ctx.agents.&lt;name>.run` / `.cancel`, so the composable hard-codes no function
159
+ * `ctx.agents.<name>.run` / `.cancel`, so the composable hard-codes no function
160
160
  * names beyond the `agents:*` surface. `threadKey` may be reactive — a changing
161
161
  * key re-subscribes to the new thread.
162
162
  */
@@ -270,7 +270,7 @@ interface UseAgentChatOptions {
270
270
  api: UseAgentChatApi;
271
271
  /**
272
272
  * Optional app mutation over the agent's cancel path
273
- * (`ctx.agents.&lt;name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
273
+ * (`ctx.agents.<name>.cancel(id)`). Called with `{ instanceId, threadKey }`.
274
274
  * When omitted (or no run is in flight) {@link UseAgentChatResult.cancel} is a
275
275
  * no-op.
276
276
  */
@@ -279,7 +279,7 @@ interface UseAgentChatOptions {
279
279
  limit?: number;
280
280
  /**
281
281
  * The app mutation that starts (or continues) a run — a thin wrapper over
282
- * `ctx.agents.&lt;name>.run(...)`. Called with `{ threadKey, input }` merged with
282
+ * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
283
283
  * {@link UseAgentChatOptions.sendArgs} and the per-call args.
284
284
  */
285
285
  send: FunctionReference<"mutation">;
@@ -894,9 +894,9 @@ type CreateSpeaker = (config: {
894
894
  audioFormat: VoiceAudioFormat;
895
895
  }) => VoiceSpeaker;
896
896
  /**
897
- * The `agents.&lt;name>Voice` reference codegen emits for a voice-enabled agent — a
897
+ * The `agents.<name>Voice` reference codegen emits for a voice-enabled agent — a
898
898
  * live, WS-backed session keyed by `threadKey`. A structural subset of the
899
- * generated member, so passing `api.agents.&lt;name>Voice` type-checks.
899
+ * generated member, so passing `api.agents.<name>Voice` type-checks.
900
900
  */
901
901
  type VoiceReference = FunctionReference<"stream", {
902
902
  threadKey: string;
@@ -938,7 +938,7 @@ interface UseVoiceAgentOptions {
938
938
  silenceThreshold?: number;
939
939
  /** The thread to converse on — shared with the agent's text turns. May be a plain value, `ref`, or getter (resolved when the call opens). */
940
940
  threadKey: MaybeRefOrGetter<string>;
941
- /** The generated `api.agents.&lt;name>Voice` reference — identifies the voice DO endpoint. */
941
+ /** The generated `api.agents.<name>Voice` reference — identifies the voice DO endpoint. */
942
942
  voice: VoiceReference;
943
943
  }
944
944
  interface UseVoiceAgentResult {
@@ -970,7 +970,7 @@ interface UseVoiceAgentResult {
970
970
  * WebSocket to the agent's `VoiceSessionDO`, captures mic audio as 16 kHz PCM,
971
971
  * streams the agent's synthesized speech back through the browser's audio output,
972
972
  * and mirrors the call lifecycle (`status`, `transcript`, `interimTranscript`,
973
- * `audioLevel`) to Vue refs. Pass the generated `api.agents.&lt;name>Voice`
973
+ * `audioLevel`) to Vue refs. Pass the generated `api.agents.<name>Voice`
974
974
  * reference (never a string), matching `useAgentChat`'s reference-passing style.
975
975
  * The Vue counterpart to React's `useVoiceAgent`, re-expressed with refs; the
976
976
  * per-call connection lives in a closure variable (a composable runs once per
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-CST_mkXL.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-MzAWyyJQ.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-CswQb5zb.mjs";import{useAgent as d}from"./packem_shared/useAgent-CeAYhGZA.mjs";import{useAgentChat as A}from"./packem_shared/useAgentChat-D59p-Qf3.mjs";import{useAgentState as h}from"./packem_shared/useAgentState-Cs1VcKQj.mjs";import{useAgentToolEvents as l}from"./packem_shared/useAgentToolEvents-BhjZrNSJ.mjs";import{useAuth as Q}from"./packem_shared/useAuth-DwDFjvto.mjs";import{default as b}from"./packem_shared/useConnectionStatus-BwLyL_L_.mjs";import{useFlag as E,useFlags as I}from"./packem_shared/useFlag-Bxoq8mH9.mjs";import{useMutation as P}from"./packem_shared/useMutation-MdgW9pRE.mjs";import{useMutator as v}from"./packem_shared/useMutator-DRVDOhcj.mjs";import{useInfiniteQuery as M,usePaginatedQuery as O}from"./packem_shared/useInfiniteQuery-5kXLWchu.mjs";import{usePresence as U}from"./packem_shared/usePresence-CfBwepyW.mjs";import{subscribeToQuery as J,useQuery as K}from"./packem_shared/subscribeToQuery-Db5cXvHm.mjs";import{useRateLimit as Y}from"./packem_shared/useRateLimit-z8EUFuYJ.mjs";import{useStream as k}from"./packem_shared/useStream-CYkKEcDf.mjs";import{useSubscription as w}from"./packem_shared/useSubscription-3X8pNJ6P.mjs";import{useVoiceAgent as B}from"./packem_shared/useVoiceAgent-Ba0SIP06.mjs";export{o as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,J as subscribeToQuery,d as useAgent,A as useAgentChat,h as useAgentState,l as useAgentToolEvents,Q as useAuth,b as useConnectionStatus,E as useFlag,I as useFlags,M as useInfiniteQuery,x as useLunora,P as useMutation,v as useMutator,O as usePaginatedQuery,U as usePresence,K as useQuery,Y as useRateLimit,k as useStream,w as useSubscription,B as useVoiceAgent};
1
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-CST_mkXL.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-MzAWyyJQ.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-CswQb5zb.mjs";import{useAgent as d}from"./packem_shared/useAgent-CeAYhGZA.mjs";import{useAgentChat as A}from"./packem_shared/useAgentChat-D59p-Qf3.mjs";import{useAgentState as h}from"./packem_shared/useAgentState-Cs1VcKQj.mjs";import{useAgentToolEvents as l}from"./packem_shared/useAgentToolEvents-BhjZrNSJ.mjs";import{useAuth as Q}from"./packem_shared/useAuth-DwDFjvto.mjs";import{default as b}from"./packem_shared/useConnectionStatus-BwLyL_L_.mjs";import{useFlag as E,useFlags as I}from"./packem_shared/useFlag-Bxoq8mH9.mjs";import{useMutation as P}from"./packem_shared/useMutation-MdgW9pRE.mjs";import{useMutator as v}from"./packem_shared/useMutator-DRVDOhcj.mjs";import{useInfiniteQuery as M,usePaginatedQuery as O}from"./packem_shared/useInfiniteQuery-DAHD8KKk.mjs";import{usePresence as U}from"./packem_shared/usePresence-CfBwepyW.mjs";import{subscribeToQuery as J,useQuery as K}from"./packem_shared/subscribeToQuery-Db5cXvHm.mjs";import{useRateLimit as Y}from"./packem_shared/useRateLimit-z8EUFuYJ.mjs";import{useStream as k}from"./packem_shared/useStream-CYkKEcDf.mjs";import{useSubscription as w}from"./packem_shared/useSubscription-3X8pNJ6P.mjs";import{useVoiceAgent as B}from"./packem_shared/useVoiceAgent-Ba0SIP06.mjs";export{o as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,J as subscribeToQuery,d as useAgent,A as useAgentChat,h as useAgentState,l as useAgentToolEvents,Q as useAuth,b as useConnectionStatus,E as useFlag,I as useFlags,M as useInfiniteQuery,x as useLunora,P as useMutation,v as useMutator,O as usePaginatedQuery,U as usePresence,K as useQuery,Y as useRateLimit,k as useStream,w as useSubscription,B as useVoiceAgent};
@@ -0,0 +1 @@
1
+ import{shallowRef as N,watch as $,toValue as P,onScopeDispose as z,computed as A}from"vue";import{initialPages as U,derivePaginationStatus as E,applyLoadMore as Q,rebalance as q}from"@lunora/client/pagination";import{i as G}from"./is-browser-BEdfLJHK.mjs";import{e as H}from"./stable-key-BSG0zK_E.mjs";import{useLunora as J}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const k=e=>{let r="";for(let i=0;i<e.length;i+=32768)r+=String.fromCharCode(...e.subarray(i,i+32768));return btoa(r)},f="$lunora.wire$",F=64,W="__proto__",X=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},h=(e,r=0)=>{if(r>F)throw new RangeError(`wire-codec: value nesting exceeds the ${F}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const i=typeof e;if(i==="bigint")return[f,"bigint",e.toString()];if(i==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(i!=="object")return e;if(e instanceof Date)return[f,"date",h(e.getTime(),r+1)];if(e instanceof Error){const t=e,o={};for(const d of Object.keys(t))t[d]!==void 0&&(o[d]=h(t[d],r+1));const n=[f,"error",t.name,t.message,o];return t.cause!==void 0&&n.push(h(t.cause,r+1)),n}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,o])=>[h(t,r+1),h(o,r+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>h(t,r+1))];if(e instanceof ArrayBuffer)return[f,"bytes",k(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,o=t.constructor.name,n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return o==="Uint8Array"?[f,"bytes",k(n)]:[f,"bytes",k(n),o]}if(Array.isArray(e)){const t=e.map(o=>h(o,r+1));return t.length>0&&t[0]===f?[f,"arr",t]:t}if(!X(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 _=e,m={};for(const t of Object.keys(_)){const o=_[t];if(o===void 0)continue;const n=h(o,r+1);t===W?Object.defineProperty(m,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):m[t]=n}return m},D=e=>H(h(e)),R=(e,r)=>`${e}::${D(r)}`,K=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),T=(e,r,i)=>{const _=J(),{initialNumItems:m,shardKey:t}=i,o=N(U(m)),n=N([]);let d;const g=new Map,p=new Map,v=new Set,L=(a,s)=>{n.value=a.map(b=>{const w=R(e.__lunoraRef,K(b,s));return p.get(w)})},V=(a,s,b)=>{const w=u=>R(e.__lunoraRef,K(u,b));for(const u of s){const l=w(u);if(p.has(l))continue;const y=a.find(c=>c.lower===u.lower);if(y){const c=p.get(w(y));c&&p.set(l,c)}}},x=(a,s)=>{const b=new Set;for(const u of a)b.add(R(e.__lunoraRef,K(u,s)));for(const[u,l]of g)b.has(l.currentKey)||(l.unsub(),g.delete(u),p.delete(l.currentKey),v.delete(l.currentKey));const w=new Set([...g.values()].map(u=>u.currentKey));for(const u of a){const l=K(u,s),y=R(e.__lunoraRef,l);if(w.has(y))continue;const c={currentKey:y,unsub:void 0};v.add(y);const M=_.subscribe(e,l,O=>{p.set(c.currentKey,O),v.delete(c.currentKey);const S=P(r);if(L(o.value,S),v.size===0){const I=o.value,j=q(I,n.value);j&&(V(I,j,S),o.value=j)}},{shardKey:t});c.unsub=M,g.set(y,c),w.add(y)}},C=()=>{for(const a of g.values())a.unsub();g.clear(),p.clear(),v.clear()};$(()=>D(P(r)),()=>{if(!G())return;const a=P(r);C(),o.value=U(m),n.value=[],d=void 0,a!=="skip"&&(x(o.value,a),L(o.value,a))},{immediate:!0}),$(()=>o.value,a=>{const s=P(r);s!=="skip"&&(x(a,s),L(a,s))}),z(C);const B=N("LoadingFirstPage");return $([()=>P(r),n],([a,s])=>{B.value=E(a==="skip",s).status},{immediate:!0}),{loadMore:a=>{const s=P(r);if(s==="skip")return;const{nextCursor:b,status:w}=E(!1,n.value);if(w!=="CanLoadMore"||b===d)return;const u=Q(o.value,b,a);if(!u)return;d=b;const l=o.value.at(-1),y=u.at(-2);if(l&&y){const c=R(e.__lunoraRef,K(l,s)),M=R(e.__lunoraRef,K(y,s)),O=g.get(c);if(O&&c!==M){O.currentKey=M,g.set(M,O),g.delete(c);const S=p.get(c);S&&(p.set(M,S),p.delete(c))}}o.value=u},pageResults:n,status:B}},oe=(e,r,i)=>{const{loadMore:_,pageResults:m,status:t}=T(e,r,i),o=A(()=>{const n=[];for(const d of m.value)d&&n.push(...d.page);return n});return{isLoading:A(()=>t.value==="LoadingFirstPage"||t.value==="LoadingMore"),loadMore:_,results:o,status:t}},ne=(e,r,i)=>{const{initialNumItems:_}=i,{loadMore:m,pageResults:t,status:o}=T(e,r,i),n=A(()=>{const v=[];for(const L of t.value)L&&v.push(L.page);return v}),d=A(()=>o.value==="LoadingFirstPage"),g=A(()=>o.value==="CanLoadMore"),p=A(()=>o.value==="LoadingMore");return{fetchNextPage:v=>{m(v??_)},hasNextPage:g,isFetchingNextPage:p,isLoading:d,pages:n,status:o}};export{ne as useInfiniteQuery,oe as usePaginatedQuery};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vue",
3
- "version": "1.0.0-alpha.65",
3
+ "version": "1.0.0-alpha.67",
4
4
  "description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -58,10 +58,10 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@lunora/client": "1.0.0-alpha.38",
62
- "@lunora/errors": "1.0.0-alpha.13",
63
- "@lunora/ratelimit": "1.0.0-alpha.16",
64
- "@lunora/runtime": "1.0.0-alpha.52",
61
+ "@lunora/client": "1.0.0-alpha.40",
62
+ "@lunora/errors": "1.0.0-alpha.14",
63
+ "@lunora/ratelimit": "1.0.0-alpha.17",
64
+ "@lunora/runtime": "1.0.0-alpha.53",
65
65
  "@visulima/storage-client": "1.0.0"
66
66
  },
67
67
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{shallowRef as $,watch as j,toValue as P,onScopeDispose as z,computed as A}from"vue";import{initialPages as U,derivePaginationStatus as E,applyLoadMore as Q,rebalance as q}from"@lunora/client/pagination";import{i as G}from"./is-browser-BEdfLJHK.mjs";import{e as H}from"./stable-key-BSG0zK_E.mjs";import{useLunora as J}from"./LUNORA_INJECTION_KEY-CswQb5zb.mjs";const k=e=>{let r="";for(let i=0;i<e.length;i+=32768)r+=String.fromCharCode(...e.subarray(i,i+32768));return btoa(r)},f="$lunora.wire$",F=64,W=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},w=(e,r=0)=>{if(r>F)throw new RangeError(`wire-codec: value nesting exceeds the ${F}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const i=typeof e;if(i==="bigint")return[f,"bigint",e.toString()];if(i==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(i!=="object")return e;if(e instanceof Date)return[f,"date",w(e.getTime(),r+1)];if(e instanceof Error){const t=e,o={};for(const d of Object.keys(t))t[d]!==void 0&&(o[d]=w(t[d],r+1));const a=[f,"error",t.name,t.message,o];return t.cause!==void 0&&a.push(w(t.cause,r+1)),a}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,o])=>[w(t,r+1),w(o,r+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>w(t,r+1))];if(e instanceof ArrayBuffer)return[f,"bytes",k(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,o=t.constructor.name,a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return o==="Uint8Array"?[f,"bytes",k(a)]:[f,"bytes",k(a),o]}if(Array.isArray(e)){const t=e.map(o=>w(o,r+1));return t.length>0&&t[0]===f?[f,"arr",t]:t}if(!W(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 L=e,b={};for(const t of Object.keys(L)){const o=L[t];o!==void 0&&(b[t]=w(o,r+1))}return b},D=e=>H(w(e)),_=(e,r)=>`${e}::${D(r)}`,K=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),T=(e,r,i)=>{const L=J(),{initialNumItems:b,shardKey:t}=i,o=$(U(b)),a=$([]);let d;const g=new Map,p=new Map,m=new Set,M=(n,s)=>{a.value=n.map(v=>{const h=_(e.__lunoraRef,K(v,s));return p.get(h)})},V=(n,s,v)=>{const h=u=>_(e.__lunoraRef,K(u,v));for(const u of s){const l=h(u);if(p.has(l))continue;const y=n.find(c=>c.lower===u.lower);if(y){const c=p.get(h(y));c&&p.set(l,c)}}},x=(n,s)=>{const v=new Set;for(const u of n)v.add(_(e.__lunoraRef,K(u,s)));for(const[u,l]of g)v.has(l.currentKey)||(l.unsub(),g.delete(u),p.delete(l.currentKey),m.delete(l.currentKey));const h=new Set([...g.values()].map(u=>u.currentKey));for(const u of n){const l=K(u,s),y=_(e.__lunoraRef,l);if(h.has(y))continue;const c={currentKey:y,unsub:void 0};m.add(y);const R=L.subscribe(e,l,S=>{p.set(c.currentKey,S),m.delete(c.currentKey);const N=P(r);if(M(o.value,N),m.size===0){const I=o.value,O=q(I,a.value);O&&(V(I,O,N),o.value=O)}},{shardKey:t});c.unsub=R,g.set(y,c),h.add(y)}},C=()=>{for(const n of g.values())n.unsub();g.clear(),p.clear(),m.clear()};j(()=>D(P(r)),()=>{if(!G())return;const n=P(r);C(),o.value=U(b),a.value=[],d=void 0,n!=="skip"&&(x(o.value,n),M(o.value,n))},{immediate:!0}),j(()=>o.value,n=>{const s=P(r);s!=="skip"&&(x(n,s),M(n,s))}),z(C);const B=$("LoadingFirstPage");return j([()=>P(r),a],([n,s])=>{B.value=E(n==="skip",s).status},{immediate:!0}),{loadMore:n=>{const s=P(r);if(s==="skip")return;const{nextCursor:v,status:h}=E(!1,a.value);if(h!=="CanLoadMore"||v===d)return;const u=Q(o.value,v,n);if(!u)return;d=v;const l=o.value.at(-1),y=u.at(-2);if(l&&y){const c=_(e.__lunoraRef,K(l,s)),R=_(e.__lunoraRef,K(y,s)),S=g.get(c);if(S&&c!==R){S.currentKey=R,g.set(R,S),g.delete(c);const N=p.get(c);N&&(p.set(R,N),p.delete(c))}}o.value=u},pageResults:a,status:B}},re=(e,r,i)=>{const{loadMore:L,pageResults:b,status:t}=T(e,r,i),o=A(()=>{const a=[];for(const d of b.value)d&&a.push(...d.page);return a});return{isLoading:A(()=>t.value==="LoadingFirstPage"||t.value==="LoadingMore"),loadMore:L,results:o,status:t}},oe=(e,r,i)=>{const{initialNumItems:L}=i,{loadMore:b,pageResults:t,status:o}=T(e,r,i),a=A(()=>{const m=[];for(const M of t.value)M&&m.push(M.page);return m}),d=A(()=>o.value==="LoadingFirstPage"),g=A(()=>o.value==="CanLoadMore"),p=A(()=>o.value==="LoadingMore");return{fetchNextPage:m=>{b(m??L)},hasNextPage:g,isFetchingNextPage:p,isLoading:d,pages:a,status:o}};export{oe as useInfiniteQuery,re as usePaginatedQuery};