@lunora/react 1.0.0-alpha.75 → 1.0.0-alpha.77
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 +4 -4
- package/dist/index.d.mts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/cache-DmbajSjf.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-CcBW4phD.mjs +2 -0
- package/dist/packem_shared/use-paginated-core-CWfn4qb4.mjs +2 -0
- package/dist/packem_shared/useAgent-CNDRZNk_.mjs +2 -0
- package/dist/packem_shared/useAgentChat-CXJldvLG.mjs +2 -0
- package/dist/packem_shared/{useAgentState-CxeO0Nzo.mjs → useAgentState-BOIQjgxe.mjs} +1 -1
- package/dist/packem_shared/{useAgentToolEvents-MfR_4MA_.mjs → useAgentToolEvents-B4gy1Q5z.mjs} +1 -1
- package/dist/packem_shared/useInfiniteQuery-C7wp0W2d.mjs +2 -0
- package/dist/packem_shared/usePaginatedQuery-DJNa8KKD.mjs +2 -0
- package/dist/packem_shared/usePresence-BVjZyltT.mjs +2 -0
- package/dist/packem_shared/{useQuery-HeFPuRVz.mjs → useQuery-BUzNP_Vb.mjs} +1 -1
- package/dist/packem_shared/useSubscription-BHVICtbD.mjs +2 -0
- package/package.json +4 -4
- package/dist/packem_shared/cache-BuILe2dy.mjs +0 -1
- package/dist/packem_shared/hydratePreloaded-D_NlgGV_.mjs +0 -2
- package/dist/packem_shared/use-paginated-core-Lu50LpUb.mjs +0 -2
- package/dist/packem_shared/useAgent-BtmvbOfx.mjs +0 -2
- package/dist/packem_shared/useAgentChat-PSWHsc8L.mjs +0 -2
- package/dist/packem_shared/useInfiniteQuery-JrM8Gv4A.mjs +0 -2
- package/dist/packem_shared/usePaginatedQuery-f-GjDA-g.mjs +0 -2
- package/dist/packem_shared/usePresence-DsYEO_XX.mjs +0 -2
- package/dist/packem_shared/useSubscription-BXhI6J-f.mjs +0 -2
package/README.md
CHANGED
|
@@ -99,10 +99,10 @@ function MessageList({ room }: { room: string }) {
|
|
|
99
99
|
| `useQuery(fn, args, options?)` | `T \| undefined` | Live query; shares one WS subscription across consumers of the same key. |
|
|
100
100
|
| `useMutation(fn)` | `{ mutate, pending, data, error, reset, withOptimisticUpdate }` | Per-call `optimistic` / `optimisticUpdate` options pass through to the client. |
|
|
101
101
|
| `useSubscription(fn, args, options?)` | `{ data, error }` | No initial fetch — only server-pushed values. |
|
|
102
|
-
| `usePaginatedQuery(fn, args, { initialNumItems })`
|
|
103
|
-
| `useInfiniteQuery(fn, args, { initialNumItems })`
|
|
104
|
-
| `usePreloadedQuery(preloaded)`
|
|
105
|
-
| `usePresence({ heartbeat, listPresent,
|
|
102
|
+
| `usePaginatedQuery(fn, args, { initialNumItems, onError? })` | `{ results, status, isLoading, loadMore, error }` | Cursor-paginated feed that stays consistent under live edits. A failed tail page is dropped so `loadMore` can retry it. |
|
|
103
|
+
| `useInfiniteQuery(fn, args, { initialNumItems, onError? })` | `{ pages, status, hasNextPage, fetchNextPage, error, … }` | Page-array variant of the same paginator. |
|
|
104
|
+
| `usePreloadedQuery(preloaded, options?)` | `T` | Reads a server `Preloaded` token, then goes live. Pass `onError` to see a session expiry instead of rendering the stale SSR snapshot. |
|
|
105
|
+
| `usePresence(roomId, { heartbeat, listPresent, … })` | `{ present, sessionId, setData, error }` | Drives the `definePresence` heartbeat + list functions. `roomId` is a positional first argument, not an option. |
|
|
106
106
|
| `useFlag(key, default)` | flag value (live) | Live OpenFeature flag over the WS; reads `default` until the server answers. Evaluated under the socket's server-verified identity. |
|
|
107
107
|
| `useFlags(defaults)` | `{ [key]: value }` | Batch variant — one live value per key in the `defaults` map. |
|
|
108
108
|
| `useStream(fn, args, options?)` | `{ chunks, status, error, cancel }` | Consumes a streamed action response chunk by chunk. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
3
|
export { type ArgsOf, type AuthImpersonation, type AuthPage, type AuthSession, type AuthUser, type ClientQueryRef, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamRef, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type SubscriptionError, type SubscriptionErrorCallback, type User, createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
|
|
@@ -89,9 +89,19 @@ interface UseSubscriptionResult<T> {
|
|
|
89
89
|
interface UsePaginatedQueryOptions {
|
|
90
90
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
91
91
|
initialNumItems: number;
|
|
92
|
+
/** Called when a page subscription (or its initial fetch) fails; also surfaced on `error`. */
|
|
93
|
+
onError?: SubscriptionErrorCallback;
|
|
92
94
|
shardKey?: string;
|
|
93
95
|
}
|
|
94
96
|
interface UsePaginatedQueryResult<T> {
|
|
97
|
+
/**
|
|
98
|
+
* The last page failure, or `undefined`. A tail page that fails before its
|
|
99
|
+
* first frame is dropped so `status` returns to `"CanLoadMore"` and
|
|
100
|
+
* `loadMore` can retry it; the first page has nothing to fall back to and
|
|
101
|
+
* stays `"LoadingFirstPage"` with this set. Cleared by the next successful
|
|
102
|
+
* frame, by `loadMore`, or by an args change.
|
|
103
|
+
*/
|
|
104
|
+
error: SubscriptionError | undefined;
|
|
95
105
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
96
106
|
isLoading: boolean;
|
|
97
107
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -103,9 +113,13 @@ interface UsePaginatedQueryResult<T> {
|
|
|
103
113
|
interface UseInfiniteQueryOptions {
|
|
104
114
|
/** Page size for the first page (and the default for `fetchNextPage`). */
|
|
105
115
|
initialNumItems: number;
|
|
116
|
+
/** Called when a page subscription (or its initial fetch) fails; also surfaced on `error`. */
|
|
117
|
+
onError?: SubscriptionErrorCallback;
|
|
106
118
|
shardKey?: string;
|
|
107
119
|
}
|
|
108
120
|
interface UseInfiniteQueryResult<T> {
|
|
121
|
+
/** The last page failure, or `undefined` — see `UsePaginatedQueryResult.error`. */
|
|
122
|
+
error: SubscriptionError | undefined;
|
|
109
123
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
110
124
|
fetchNextPage: (numberItems?: number) => void;
|
|
111
125
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -364,6 +378,12 @@ interface UseAgentOptions {
|
|
|
364
378
|
* no-op.
|
|
365
379
|
*/
|
|
366
380
|
cancel?: FunctionReference<"mutation">;
|
|
381
|
+
/**
|
|
382
|
+
* Called when the live thread subscription reports an error (a session
|
|
383
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
384
|
+
* failure is invisible and `thread` / `status` freeze at their last value.
|
|
385
|
+
*/
|
|
386
|
+
onError?: SubscriptionErrorCallback;
|
|
367
387
|
/**
|
|
368
388
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
369
389
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -381,6 +401,8 @@ interface UseAgentResult {
|
|
|
381
401
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
382
402
|
*/
|
|
383
403
|
cancel: () => Promise<void>;
|
|
404
|
+
/** The live thread subscription's last error, or `undefined`. */
|
|
405
|
+
error: Error | undefined;
|
|
384
406
|
/** `true` while a `run` invocation is in flight. */
|
|
385
407
|
pending: boolean;
|
|
386
408
|
/** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
|
|
@@ -517,6 +539,13 @@ interface UseAgentChatOptions {
|
|
|
517
539
|
cancel?: FunctionReference<"mutation">;
|
|
518
540
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
519
541
|
limit?: number;
|
|
542
|
+
/**
|
|
543
|
+
* Called when the live history or thread subscription reports an error (a
|
|
544
|
+
* session expiry, an RLS denial). Without it — and without reading `error` —
|
|
545
|
+
* such a failure is invisible and `messages` / `status` freeze at their last
|
|
546
|
+
* value.
|
|
547
|
+
*/
|
|
548
|
+
onError?: SubscriptionErrorCallback;
|
|
520
549
|
/**
|
|
521
550
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
522
551
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -542,6 +571,8 @@ interface UseAgentChatResult {
|
|
|
542
571
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
543
572
|
*/
|
|
544
573
|
cancel: () => Promise<void>;
|
|
574
|
+
/** The history or thread subscription's last error, or `undefined`. */
|
|
575
|
+
error: Error | undefined;
|
|
545
576
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
546
577
|
messages: ReadonlyArray<AgentChatMessage>;
|
|
547
578
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
@@ -829,6 +860,10 @@ type PageItemOf<F> = ReturnOf<F> extends {
|
|
|
829
860
|
/**
|
|
830
861
|
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
831
862
|
*
|
|
863
|
+
* Pass `onError` (and read `error`) to see a page failure: without it the hook
|
|
864
|
+
* only reports `status`, and a first page that fails reads as an eternal
|
|
865
|
+
* `isLoading`.
|
|
866
|
+
*
|
|
832
867
|
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
833
868
|
* endCursor }` arg and return a `PaginationResult` (the shape
|
|
834
869
|
* `ctx.db.query(...).paginate` yields). Pages are tracked as an ordered list of
|
|
@@ -948,8 +983,14 @@ declare const useMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandl
|
|
|
948
983
|
* value directly. Apps that want to share a pre-populated QueryClient across
|
|
949
984
|
* many preloaded queries can pass their own `queryClient` to `LunoraProvider`
|
|
950
985
|
* and hydrate it themselves via TanStack's `hydrate(qc, dehydratedState)`.
|
|
986
|
+
*
|
|
987
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (a
|
|
988
|
+
* session expiry, an RLS denial). Without it such an error is dropped and the
|
|
989
|
+
* hook keeps rendering the SSR snapshot as if it were live.
|
|
951
990
|
*/
|
|
952
|
-
declare const usePreloadedQuery: <T>(preloaded: Preloaded<T
|
|
991
|
+
declare const usePreloadedQuery: <T>(preloaded: Preloaded<T>, options?: {
|
|
992
|
+
onError?: SubscriptionErrorCallback;
|
|
993
|
+
}) => T;
|
|
953
994
|
/**
|
|
954
995
|
* The PLAN4 §1 framework-neutral name for the preloaded-hydration handoff:
|
|
955
996
|
* `hydratePreloaded(preloaded)` seeds the SSR value on the first paint, then
|
|
@@ -961,7 +1002,9 @@ declare const usePreloadedQuery: <T>(preloaded: Preloaded<T>) => T;
|
|
|
961
1002
|
* It carries React's Rules-of-Hooks contract (it calls hooks internally), so
|
|
962
1003
|
* call it like a hook — at the top level of a component, unconditionally.
|
|
963
1004
|
*/
|
|
964
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T
|
|
1005
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1006
|
+
onError?: SubscriptionErrorCallback;
|
|
1007
|
+
}) => T;
|
|
965
1008
|
/**
|
|
966
1009
|
* `usePresence` — collaborative-awareness hook, the client half of the
|
|
967
1010
|
* `@lunora/server` `definePresence` preset (Convex `@convex-dev/presence`
|
|
@@ -1014,6 +1057,12 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
|
|
|
1014
1057
|
intervalMs?: number;
|
|
1015
1058
|
/** The `api.*` reference for the presence listPresent query. */
|
|
1016
1059
|
listPresent: L;
|
|
1060
|
+
/**
|
|
1061
|
+
* Called when the `listPresent` subscription reports an error (a session
|
|
1062
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
1063
|
+
* failure is invisible and `present` freezes at its last value.
|
|
1064
|
+
*/
|
|
1065
|
+
onError?: SubscriptionErrorCallback;
|
|
1017
1066
|
/**
|
|
1018
1067
|
* Stable id for this presence row. Defaults to a fresh per-mount id (one row
|
|
1019
1068
|
* per tab). Pass a user/connection id to control deduping.
|
|
@@ -1023,6 +1072,8 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
|
|
|
1023
1072
|
shardKey?: string;
|
|
1024
1073
|
}
|
|
1025
1074
|
interface UsePresenceResult<L extends ListPresentReference> {
|
|
1075
|
+
/** The `listPresent` subscription's last error, or `undefined`. */
|
|
1076
|
+
error: SubscriptionError | undefined;
|
|
1026
1077
|
/** The present members for the room, as `listPresent` returns them. `undefined` until the first push. */
|
|
1027
1078
|
present: ReturnOf<L> | undefined;
|
|
1028
1079
|
/** This mount's session id (generated when not supplied). */
|
|
@@ -1121,6 +1172,11 @@ declare const useStream: <F extends FunctionReference<"stream">>(function_: F, a
|
|
|
1121
1172
|
* Subscribe to a real-time stream from the server. Unlike `useQuery`, this
|
|
1122
1173
|
* hook does not issue an initial HTTP fetch — it only delivers values that
|
|
1123
1174
|
* the server pushes over the WS.
|
|
1175
|
+
*
|
|
1176
|
+
* A server-pushed error lands on `error` as a `LunoraError` carrying the
|
|
1177
|
+
* server's `code` (a bare `Error` only when the server sent no code), so
|
|
1178
|
+
* consumers can branch on the error kind; `onError` receives the raw
|
|
1179
|
+
* `SubscriptionError` in addition.
|
|
1124
1180
|
*/
|
|
1125
1181
|
declare const useSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
|
|
1126
1182
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
3
|
export { type ArgsOf, type AuthImpersonation, type AuthPage, type AuthSession, type AuthUser, type ClientQueryRef, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamRef, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type SubscriptionError, type SubscriptionErrorCallback, type User, createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
|
|
@@ -89,9 +89,19 @@ interface UseSubscriptionResult<T> {
|
|
|
89
89
|
interface UsePaginatedQueryOptions {
|
|
90
90
|
/** Page size for the first page (and the default for `loadMore`). */
|
|
91
91
|
initialNumItems: number;
|
|
92
|
+
/** Called when a page subscription (or its initial fetch) fails; also surfaced on `error`. */
|
|
93
|
+
onError?: SubscriptionErrorCallback;
|
|
92
94
|
shardKey?: string;
|
|
93
95
|
}
|
|
94
96
|
interface UsePaginatedQueryResult<T> {
|
|
97
|
+
/**
|
|
98
|
+
* The last page failure, or `undefined`. A tail page that fails before its
|
|
99
|
+
* first frame is dropped so `status` returns to `"CanLoadMore"` and
|
|
100
|
+
* `loadMore` can retry it; the first page has nothing to fall back to and
|
|
101
|
+
* stays `"LoadingFirstPage"` with this set. Cleared by the next successful
|
|
102
|
+
* frame, by `loadMore`, or by an args change.
|
|
103
|
+
*/
|
|
104
|
+
error: SubscriptionError | undefined;
|
|
95
105
|
/** `true` while the first page or a `loadMore` page is in flight. */
|
|
96
106
|
isLoading: boolean;
|
|
97
107
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
@@ -103,9 +113,13 @@ interface UsePaginatedQueryResult<T> {
|
|
|
103
113
|
interface UseInfiniteQueryOptions {
|
|
104
114
|
/** Page size for the first page (and the default for `fetchNextPage`). */
|
|
105
115
|
initialNumItems: number;
|
|
116
|
+
/** Called when a page subscription (or its initial fetch) fails; also surfaced on `error`. */
|
|
117
|
+
onError?: SubscriptionErrorCallback;
|
|
106
118
|
shardKey?: string;
|
|
107
119
|
}
|
|
108
120
|
interface UseInfiniteQueryResult<T> {
|
|
121
|
+
/** The last page failure, or `undefined` — see `UsePaginatedQueryResult.error`. */
|
|
122
|
+
error: SubscriptionError | undefined;
|
|
109
123
|
/** Request the next page. A no-op unless `status === "CanLoadMore"`. */
|
|
110
124
|
fetchNextPage: (numberItems?: number) => void;
|
|
111
125
|
/** `true` when the loaded tail reports it can load another page. */
|
|
@@ -364,6 +378,12 @@ interface UseAgentOptions {
|
|
|
364
378
|
* no-op.
|
|
365
379
|
*/
|
|
366
380
|
cancel?: FunctionReference<"mutation">;
|
|
381
|
+
/**
|
|
382
|
+
* Called when the live thread subscription reports an error (a session
|
|
383
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
384
|
+
* failure is invisible and `thread` / `status` freeze at their last value.
|
|
385
|
+
*/
|
|
386
|
+
onError?: SubscriptionErrorCallback;
|
|
367
387
|
/**
|
|
368
388
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
369
389
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -381,6 +401,8 @@ interface UseAgentResult {
|
|
|
381
401
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
382
402
|
*/
|
|
383
403
|
cancel: () => Promise<void>;
|
|
404
|
+
/** The live thread subscription's last error, or `undefined`. */
|
|
405
|
+
error: Error | undefined;
|
|
384
406
|
/** `true` while a `run` invocation is in flight. */
|
|
385
407
|
pending: boolean;
|
|
386
408
|
/** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
|
|
@@ -517,6 +539,13 @@ interface UseAgentChatOptions {
|
|
|
517
539
|
cancel?: FunctionReference<"mutation">;
|
|
518
540
|
/** History depth forwarded to `agents:agentMessages`. */
|
|
519
541
|
limit?: number;
|
|
542
|
+
/**
|
|
543
|
+
* Called when the live history or thread subscription reports an error (a
|
|
544
|
+
* session expiry, an RLS denial). Without it — and without reading `error` —
|
|
545
|
+
* such a failure is invisible and `messages` / `status` freeze at their last
|
|
546
|
+
* value.
|
|
547
|
+
*/
|
|
548
|
+
onError?: SubscriptionErrorCallback;
|
|
520
549
|
/**
|
|
521
550
|
* The app mutation that starts (or continues) a run — a thin wrapper over
|
|
522
551
|
* `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
|
|
@@ -542,6 +571,8 @@ interface UseAgentChatResult {
|
|
|
542
571
|
* no-op when no `cancel` mutation was supplied or no run is in flight.
|
|
543
572
|
*/
|
|
544
573
|
cancel: () => Promise<void>;
|
|
574
|
+
/** The history or thread subscription's last error, or `undefined`. */
|
|
575
|
+
error: Error | undefined;
|
|
545
576
|
/** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
|
|
546
577
|
messages: ReadonlyArray<AgentChatMessage>;
|
|
547
578
|
/** Reject a paused human-in-the-loop tool call (optionally with a reason). */
|
|
@@ -829,6 +860,10 @@ type PageItemOf<F> = ReturnOf<F> extends {
|
|
|
829
860
|
/**
|
|
830
861
|
* Subscribe to a reactively-paginated query and grow the feed page by page.
|
|
831
862
|
*
|
|
863
|
+
* Pass `onError` (and read `error`) to see a page failure: without it the hook
|
|
864
|
+
* only reports `status`, and a first page that fails reads as an eternal
|
|
865
|
+
* `isLoading`.
|
|
866
|
+
*
|
|
832
867
|
* The query function must accept a `paginationOpts: { numItems, cursor,
|
|
833
868
|
* endCursor }` arg and return a `PaginationResult` (the shape
|
|
834
869
|
* `ctx.db.query(...).paginate` yields). Pages are tracked as an ordered list of
|
|
@@ -948,8 +983,14 @@ declare const useMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandl
|
|
|
948
983
|
* value directly. Apps that want to share a pre-populated QueryClient across
|
|
949
984
|
* many preloaded queries can pass their own `queryClient` to `LunoraProvider`
|
|
950
985
|
* and hydrate it themselves via TanStack's `hydrate(qc, dehydratedState)`.
|
|
986
|
+
*
|
|
987
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (a
|
|
988
|
+
* session expiry, an RLS denial). Without it such an error is dropped and the
|
|
989
|
+
* hook keeps rendering the SSR snapshot as if it were live.
|
|
951
990
|
*/
|
|
952
|
-
declare const usePreloadedQuery: <T>(preloaded: Preloaded<T
|
|
991
|
+
declare const usePreloadedQuery: <T>(preloaded: Preloaded<T>, options?: {
|
|
992
|
+
onError?: SubscriptionErrorCallback;
|
|
993
|
+
}) => T;
|
|
953
994
|
/**
|
|
954
995
|
* The PLAN4 §1 framework-neutral name for the preloaded-hydration handoff:
|
|
955
996
|
* `hydratePreloaded(preloaded)` seeds the SSR value on the first paint, then
|
|
@@ -961,7 +1002,9 @@ declare const usePreloadedQuery: <T>(preloaded: Preloaded<T>) => T;
|
|
|
961
1002
|
* It carries React's Rules-of-Hooks contract (it calls hooks internally), so
|
|
962
1003
|
* call it like a hook — at the top level of a component, unconditionally.
|
|
963
1004
|
*/
|
|
964
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T
|
|
1005
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, options?: {
|
|
1006
|
+
onError?: SubscriptionErrorCallback;
|
|
1007
|
+
}) => T;
|
|
965
1008
|
/**
|
|
966
1009
|
* `usePresence` — collaborative-awareness hook, the client half of the
|
|
967
1010
|
* `@lunora/server` `definePresence` preset (Convex `@convex-dev/presence`
|
|
@@ -1014,6 +1057,12 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
|
|
|
1014
1057
|
intervalMs?: number;
|
|
1015
1058
|
/** The `api.*` reference for the presence listPresent query. */
|
|
1016
1059
|
listPresent: L;
|
|
1060
|
+
/**
|
|
1061
|
+
* Called when the `listPresent` subscription reports an error (a session
|
|
1062
|
+
* expiry, an RLS denial). Without it — and without reading `error` — such a
|
|
1063
|
+
* failure is invisible and `present` freezes at its last value.
|
|
1064
|
+
*/
|
|
1065
|
+
onError?: SubscriptionErrorCallback;
|
|
1017
1066
|
/**
|
|
1018
1067
|
* Stable id for this presence row. Defaults to a fresh per-mount id (one row
|
|
1019
1068
|
* per tab). Pass a user/connection id to control deduping.
|
|
@@ -1023,6 +1072,8 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
|
|
|
1023
1072
|
shardKey?: string;
|
|
1024
1073
|
}
|
|
1025
1074
|
interface UsePresenceResult<L extends ListPresentReference> {
|
|
1075
|
+
/** The `listPresent` subscription's last error, or `undefined`. */
|
|
1076
|
+
error: SubscriptionError | undefined;
|
|
1026
1077
|
/** The present members for the room, as `listPresent` returns them. `undefined` until the first push. */
|
|
1027
1078
|
present: ReturnOf<L> | undefined;
|
|
1028
1079
|
/** This mount's session id (generated when not supplied). */
|
|
@@ -1121,6 +1172,11 @@ declare const useStream: <F extends FunctionReference<"stream">>(function_: F, a
|
|
|
1121
1172
|
* Subscribe to a real-time stream from the server. Unlike `useQuery`, this
|
|
1122
1173
|
* hook does not issue an initial HTTP fetch — it only delivers values that
|
|
1123
1174
|
* the server pushes over the WS.
|
|
1175
|
+
*
|
|
1176
|
+
* A server-pushed error lands on `error` as a `LunoraError` carrying the
|
|
1177
|
+
* server's `code` (a bare `Error` only when the server sent no code), so
|
|
1178
|
+
* consumers can branch on the error kind; `onError` receives the raw
|
|
1179
|
+
* `SubscriptionError` in addition.
|
|
1124
1180
|
*/
|
|
1125
1181
|
declare const useSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
|
|
1126
1182
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as h,useOrganizations as c}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as y}from"./packem_shared/useAgent-
|
|
2
|
+
import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as h,useOrganizations as c}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as y}from"./packem_shared/useAgent-CNDRZNk_.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-CXJldvLG.mjs";import{useAgentState as S}from"./packem_shared/useAgentState-BOIQjgxe.mjs";import{useAgentToolEvents as L}from"./packem_shared/useAgentToolEvents-B4gy1Q5z.mjs";import{default as F}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as I}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as v}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-BDM923ke.mjs";import{useHttpStream as H}from"./packem_shared/useHttpStream-D9vum8Qx.mjs";import{default as j}from"./packem_shared/useInfiniteQuery-C7wp0W2d.mjs";import{useMutation as w}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as D}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as J}from"./packem_shared/usePaginatedQuery-DJNa8KKD.mjs";import{hydratePreloaded as N,default as W}from"./packem_shared/hydratePreloaded-CcBW4phD.mjs";import{usePresence as Y}from"./packem_shared/usePresence-BVjZyltT.mjs";import{default as _}from"./packem_shared/useQuery-BUzNP_Vb.mjs";import{useRateLimit as ee}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as oe}from"./packem_shared/useStream-CmGOT0qj.mjs";import{default as ue}from"./packem_shared/useSubscription-BHVICtbD.mjs";import{useVoiceAgent as ae}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as fe,getErrorCode as ne,getRetryAfterMs as ie,isConflictError as me,isForbiddenError as de,isRateLimitedError as xe,isUnauthorizedError as le}from"@lunora/client";import{RestrictionError as ge,UploadControl as he,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as ye,useFileInput as Ce,useMultipartUpload as Ee,usePasteUpload as Qe,useTusUpload as Se,useUpload as Pe}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,ge as RestrictionError,u as Unauthenticated,he as UploadControl,ce as UploadError,fe as createClientQuery,ne as getErrorCode,ie as getRetryAfterMs,N as hydratePreloaded,me as isConflictError,de as isForbiddenError,xe as isRateLimitedError,le as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,y as useAgent,E as useAgentChat,S as useAgentState,L as useAgentToolEvents,F as useAuth,A as useAuthSessions,a as useAuthState,g as useAuthUsers,ye as useChunkedRestUpload,I as useClientQuery,v as useConnectionStatus,Ce as useFileInput,O as useFlag,T as useFlags,H as useHttpStream,h as useImpersonate,j as useInfiniteQuery,n as useLunora,Ee as useMultipartUpload,w as useMutation,D as useMutator,c as useOrganizations,J as usePaginatedQuery,Qe as usePasteUpload,W as usePreloadedQuery,Y as usePresence,_ as useQuery,ee as useRateLimit,oe as useStream,ue as useSubscription,Se as useTusUpload,Pe as useUpload,ae as useVoiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as u}from"./query-key-C6iUhRuD.mjs";class g{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return u(e)}attach(e,c,f,b,h,k={}){const s=u(c);let r=this.entries.get(s);if(!r){r={errorCallbacks:new Set,refCount:0,unsubscribe:void 0},this.entries.set(s,r);const t=r;try{r.unsubscribe=this.client.subscribe(f,b,n=>{e.setQueryData(c,n)},{onError:n=>{for(const d of t.errorCallbacks)d(n)},shardKey:h})}catch(n){throw this.entries.delete(s),n}}r.refCount+=1;const{onError:o}=k;o&&r.errorCallbacks.add(o);let a=!1;return()=>{if(a)return;a=!0;const t=this.entries.get(s);t&&(t.refCount-=1,o&&t.errorCallbacks.delete(o),t.refCount<=0&&(t.unsubscribe?.(),this.entries.delete(s)))}}}const l=new WeakMap,C=i=>{let e=l.get(i);return e||(e=new g(i),l.set(i,e)),e};export{C as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as _}from"react/compiler-runtime";import{useQueryClient as b,useQuery as q}from"@tanstack/react-query";import{useRef as K,useEffect as Q}from"react";import{g as P}from"./cache-DmbajSjf.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-C6iUhRuD.mjs";const T=function(a,e){const r=_(9);let o;r[0]!==e?(o=e===void 0?{}:e,r[0]=e,r[1]=o):o=r[1];const n=o,t=v(),s=b(),p=K(n.onError);let i;r[2]!==n.onError?(i=()=>{p.current=n.onError},r[2]=n.onError,r[3]=i):i=r[3],Q(i);let u;r[4]===Symbol.for("react.memo_cache_sentinel")?(u=I=>{p.current?.(I)},r[4]=u):u=r[4];const E=u,{args:l,functionPath:R,shardKey:f,value:g}=a,y={__lunoraRef:R},m=N(y,l,f),{data:h}=q({initialData:g,queryFn:()=>t.query(y,l,{shardKey:f}),queryKey:m,staleTime:Number.POSITIVE_INFINITY}),d=S(m);let c;return r[5]!==t||r[6]!==s||r[7]!==d?(c=[t,s,d,E],r[5]=t,r[6]=s,r[7]=d,r[8]=c):c=r[8],Q(()=>P(t).attach(s,m,y,l,f,{onError:E}),c),h===void 0?g:h},L=function(a,e={}){return T(a,e)};export{T as default,L as hydratePreloaded};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{initialPages as x,rebalance as N,derivePaginationStatus as D,applyLoadMore as T}from"@lunora/client/pagination";import{useQueryClient as B}from"@tanstack/react-query";import{useRef as m,useReducer as G,useState as F,useEffect as y,useCallback as J}from"react";import{g as U}from"./cache-DmbajSjf.mjs";import{useLunora as V}from"./LunoraProvider-DC06S-p1.mjs";import{s as u,l as v}from"./query-key-C6iUhRuD.mjs";const W=function(i){const l=m(void 0);return l.current??=i(),l},te=function(i,l,C){const f=V(),c=B(),{initialNumItems:R,shardKey:p}=C,d=l==="skip",g=d?{}:l,[,O]=G(e=>e+1,0),[q,h]=F(()=>x(R)),[z,k]=F(void 0),w=m(C.onError);y(()=>{w.current=C.onError});const Q=`${u(v(i,g,p))}::${String(R)}`,A=m(Q);A.current!==Q&&(A.current=Q,h(x(R)),k(void 0));const K=q.map(e=>{const t={...g,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},r=v(i,t,p);return{args:t,key:r}}),P=K.map(({key:e})=>u(e)).join("|"),b=m({baseArgs:g,entries:[],fn:i,shardKey:p});y(()=>{b.current={baseArgs:g,entries:K,fn:i,shardKey:p}});const L=(e,t,r)=>{k(r),h(o=>{const s=b.current,n=o.at(-1);if(o.length<=1||!n||c.getQueryData(t)!==void 0)return o;const S={...s.baseArgs,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}};return u(v(s.fn,S,s.shardKey))===e?o.slice(0,-1):o}),w.current?.(r)},E=W(()=>new Map),M=m(f);y(()=>{const e=E.current;if(M.current!==f){for(const s of e.values())s();e.clear(),M.current=f}if(d){for(const s of e.values())s();e.clear();return}const t=b.current,r=U(f),o=new Set(t.entries.map(({key:s})=>u(s)));for(const[s,n]of e)o.has(s)||(n(),e.delete(s));for(const s of t.entries){const n=u(s.key);if(e.has(n))continue;c.fetchQuery({queryFn:()=>f.query(t.fn,s.args,{shardKey:t.shardKey}),queryKey:s.key,staleTime:0}).catch(a=>{L(n,s.key,a instanceof Error?{code:a.code,message:a.message}:{message:String(a)})}),e.set(n,r.attach(c,s.key,t.fn,s.args,t.shardKey,{onError:a=>{L(n,s.key,a)}}))}},[f,c,P,d]),y(()=>()=>{for(const e of E.current.values())e();E.current.clear()},[]),y(()=>c.getQueryCache().subscribe(r=>{if(r.type!=="updated")return;const o=u(r.query.queryKey);K.some(({key:s})=>u(s)===o)&&(k(void 0),O())}),[c,P]);const I=d?[]:K.map(({key:e})=>c.getQueryData(e));y(()=>{if(d)return;const e=N(q,I);e&&h(e)});const{status:$}=D(d,I),j=J(e=>{k(void 0),h(t=>{const r=b.current,o=t.map(a=>{const H={...r.baseArgs,paginationOpts:{cursor:a.lower,endCursor:a.upper,numItems:a.numItems}};return c.getQueryData(v(r.fn,H,r.shardKey))}),{nextCursor:s,status:n}=D(!1,o);return T(t,n==="CanLoadMore"?s:void 0,e)??t})},[c]);return{error:z,loadMore:j,pageResults:I,status:$}};export{te as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as N}from"react/compiler-runtime";import{useMutation as R}from"./useMutation-BnKec7bE.mjs";import O from"./useSubscription-BHVICtbD.mjs";const b={__lunoraRef:""},F=_=>{const t=N(20),{api:A,cancel:a,onError:d,run:I,runArgs:f,threadKey:e}=_,s=R(I),T=R(a??b);let c;t[0]!==e?(c={key:e},t[0]=e,t[1]=c):c=t[1];let r;t[2]!==d?(r={onError:d},t[2]=d,t[3]=r):r=t[3];const{data:v,error:p}=O(A.agents.agentThread,c,r),n=v,g=n?.status,o=n?.instanceId,{mutate:m}=s,{mutate:M}=T;let i;t[4]!==f||t[5]!==m||t[6]!==e?(i=async(w,E)=>{await m({input:w,threadKey:e,...f,...E})},t[4]=f,t[5]=m,t[6]=e,t[7]=i):i=t[7];const h=i;let u;t[8]!==M||t[9]!==a||t[10]!==o||t[11]!==e?(u=async()=>{a===void 0||o===void 0||await M({instanceId:o,threadKey:e})},t[8]=M,t[9]=a,t[10]=o,t[11]=e,t[12]=u):u=t[12];const y=u;let l;return t[13]!==y||t[14]!==p||t[15]!==h||t[16]!==s.pending||t[17]!==g||t[18]!==n?(l={cancel:y,error:p,pending:s.pending,run:h,status:g,thread:n},t[13]=y,t[14]=p,t[15]=h,t[16]=s.pending,t[17]=g,t[18]=n,t[19]=l):l=t[19],l};export{F as useAgent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{reconcileOptimistic as M,maxSeq as R}from"@lunora/client";import{useState as Q,useRef as S}from"react";import{useMutation as u}from"./useMutation-BnKec7bE.mjs";import{useStream as V}from"./useStream-CmGOT0qj.mjs";import A from"./useSubscription-BHVICtbD.mjs";const W={__lunoraRef:""},X={__lunoraRef:""},Z=[],it=E=>{const{api:a,cancel:m,limit:d,onError:l,send:_,sendArgs:k,stream:p,threadKey:e}=E,x=d===void 0?{key:e}:{key:e,limit:d},{data:w,error:O}=A(a.agents.agentMessages,x,{onError:l}),{data:T,error:b}=A(a.agents.agentThread,{key:e},{onError:l}),I=p===void 0?"skip":{key:e},{chunks:j}=V(p??X,I),q=u(_),C=u(m??W),D=u(a.agents.agentResolveApproval),[K,c]=Q([]),f=S(0),h=S(e);h.current!==e&&(h.current=e,c([]));const g=T,N=g?.status,o=g?.instanceId,s=w??Z,v=M(K,s),F=R(s),G=v.length===0?s:[...s,...v.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:F+1+n}))],P=s.filter(t=>t.role==="assistant").length,U=j.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=P).map(t=>t.text).join(""),{mutate:Y}=q,{mutate:$}=C,{mutate:z}=D,B=async(t,n)=>{const r=f.current;f.current+=1;const H=R(s);c(i=>[...M(i,s),{content:t,id:r,maxDurableSeqAtSend:H}]);try{await Y({input:t,threadKey:e,...k,...n})}catch(i){throw c(J=>J.filter(L=>L.id!==r)),i}},y=async(t,n,r)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await z({decision:t,instanceId:o,threadKey:e,toolCallId:n,...r===void 0?{}:{note:r}})};return{approve:(t,n)=>y("approve",t,n),cancel:async()=>{m===void 0||o===void 0||await $({instanceId:o,threadKey:e})},error:O??b,messages:G,reject:(t,n)=>y("reject",t,n),send:B,status:N,streamingText:U}};export{it as useAgentChat};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as o}from"react/compiler-runtime";import d from"./useSubscription-
|
|
2
|
+
import{c as o}from"react/compiler-runtime";import d from"./useSubscription-BHVICtbD.mjs";const l=t=>{const e=o(5);let r;e[0]!==t.threadKey?(r={key:t.threadKey},e[0]=t.threadKey,e[1]=r):r=e[1];const{data:n,error:s}=d(t.api.agents.agentState,r),c=n;let a;return e[2]!==s||e[3]!==c?(a={error:s,state:c},e[2]=s,e[3]=c,e[4]=a):a=e[4],a};export{l as useAgentState};
|
package/dist/packem_shared/{useAgentToolEvents-MfR_4MA_.mjs → useAgentToolEvents-B4gy1Q5z.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-CmGOT0qj.mjs";import N from"./useSubscription-
|
|
2
|
+
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-CmGOT0qj.mjs";import N from"./useSubscription-BHVICtbD.mjs";const E={__lunoraRef:""},_=[],k=o=>{if(o.role==="assistant"&&o.toolCalls)return o.toolCalls.map(t=>({input:t.input,seq:o.seq,toolCallId:t.id,toolName:t.name,type:"call"}));if(o.role==="tool")return o.status==="awaiting_approval"?[{seq:o.seq,type:"awaiting-approval",...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]:[{output:o.content,seq:o.seq,type:"result",...o.status==="approved"||o.status==="rejected"?{status:o.status}:{},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.toolName===void 0?{}:{toolName:o.toolName}}]},A=o=>{const t=y(12),{api:c,limit:r,stream:n,threadKey:l}=o;let a;t[0]!==r||t[1]!==l?(a=r===void 0?{key:l}:{key:l,limit:r},t[0]=r,t[1]=l,t[2]=a):a=t[2];const f=a,{data:v}=N(c.agents.agentMessages,f);let i;t[3]!==n||t[4]!==l?(i=n===void 0?"skip":{key:l},t[3]=n,t[4]=l,t[5]=i):i=t[5];const C=i,{chunks:p}=I(n??E,C),s=v??_;let e;if(t[6]!==p||t[7]!==s||t[8]!==l){e=s.flatMap(q);for(const d of p)d.kind==="progress"&&d.threadKey===l&&e.push({data:d.data,toolCallId:d.toolCallId,type:"progress"});t[6]=p,t[7]=s,t[8]=l,t[9]=e}else e=t[9];let u;return t[10]!==e?(u={events:e},t[10]=e,t[11]=u):u=t[11],u};function q(o){return k(o)??[]}export{A as useAgentToolEvents};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as M}from"react/compiler-runtime";import{useRef as R,useEffect as y}from"react";import{u as C}from"./use-paginated-core-CWfn4qb4.mjs";const v=(x,c,N)=>{const e=M(16),{initialNumItems:s}=N,{error:u,loadMore:o,pageResults:m,status:a}=C(x,c==="skip"?"skip":c,N),P=c==="skip";let t;if(e[0]!==m){t=[];for(const f of m)f&&t.push(f.page);e[0]=m,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const h=R(i);let n;e[5]!==s||e[6]!==o?(n=()=>{h.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],y(n);let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=f=>{const{defaultNumItems:k,loadMore:L}=h.current;L(f??k)},e[8]=r):r=e[8];const I=r,d=a==="CanLoadMore",p=!P&&a==="LoadingMore",g=!P&&a==="LoadingFirstPage";let l;return e[9]!==u||e[10]!==t||e[11]!==a||e[12]!==d||e[13]!==p||e[14]!==g?(l={error:u,fetchNextPage:I,hasNextPage:d,isFetchingNextPage:p,isLoading:g,pages:t,status:a},e[9]=u,e[10]=t,e[11]=a,e[12]=d,e[13]=p,e[14]=g,e[15]=l):l=e[15],l};export{v as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c}from"react/compiler-runtime";import{u as f}from"./use-paginated-core-CWfn4qb4.mjs";const L=(d,i,l)=>{const e=c(8),{error:r,loadMore:p,pageResults:n,status:t}=f(d,i==="skip"?"skip":i,l);let s;if(e[0]!==n){s=[];for(const u of n)u&&s.push(...u.page);e[0]=n,e[1]=s}else s=e[1];const a=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==r||e[3]!==p||e[4]!==s||e[5]!==t||e[6]!==a?(o={error:r,isLoading:a,loadMore:p,results:s,status:t},e[2]=r,e[3]=p,e[4]=s,e[5]=t,e[6]=a,e[7]=o):o=e[7],o};export{L as usePaginatedQuery};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useMemo as V,useState as I,useRef as f,useEffect as d,useCallback as h}from"react";import{useLunora as A}from"./LunoraProvider-DC06S-p1.mjs";const C=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},_=1e4,M=(t,n)=>{const r=A(),{heartbeat:l,intervalMs:y=_,listPresent:m,shardKey:s}=n,c=V(()=>n.sessionId??C(),[n.sessionId]),[E,R]=I(void 0),[g,b]=I(void 0),v=f(n.onError);d(()=>{v.current=n.onError});const u=f(n.data),p=f({client:r,heartbeat:l,roomId:t,sessionId:c,shardKey:s});d(()=>{p.current={client:r,heartbeat:l,roomId:t,sessionId:c,shardKey:s}});const o=h(()=>{const{client:e,heartbeat:i,roomId:a,sessionId:U,shardKey:D}=p.current,L={roomId:a,sessionId:U,...u.current===void 0?{}:{data:u.current}};e.mutation(i,L,{shardKey:D}).catch(()=>{})},[]),S=h(e=>{u.current=e,o()},[o]);return d(()=>{o();const e=setInterval(o,y),i=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),()=>{clearInterval(e),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}},[o,y]),d(()=>r.acquireConnectionContext({roomId:t,sessionId:c},{shardKey:s}),[r,t,c,s]),d(()=>{let e=!1;const i=r.subscribe(m,{roomId:t},a=>{e||(R(a),b(void 0))},{onError:a=>{e||b(a),v.current?.(a)},shardKey:s});return()=>{e=!0,i()}},[r,m.__lunoraRef,t,s]),{error:g,present:E,sessionId:c,setData:S}};export{M as usePresence};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useQueryClient as h,useQuery as E}from"@tanstack/react-query";import{useRef as b,useEffect as n,useCallback as g,useState as I}from"react";import{g as k}from"./cache-
|
|
2
|
+
import{useQueryClient as h,useQuery as E}from"@tanstack/react-query";import{useRef as b,useEffect as n,useCallback as g,useState as I}from"react";import{g as k}from"./cache-DmbajSjf.mjs";import{useLunora as q}from"./LunoraProvider-DC06S-p1.mjs";import{l as K,s as C}from"./query-key-C6iUhRuD.mjs";const F=(t,i,p={})=>{const e=q(),y=h(),{onError:c,shardKey:s}=p,d=b(c);n(()=>{d.current=c});const l=g(m=>{d.current?.(m)},[]),r=i==="skip",o=r?{}:i,a=K(t,o,s),[u,f]=I(e.isReady);n(()=>{u||e.whenReady().then(()=>{f(!0)})},[e,u]);const Q=r?void 0:e.peekHydratedQuery(t.__lunoraRef,o,s),{data:R}=E({enabled:!r&&u,initialData:Q,queryFn:()=>e.query(t,o,{shardKey:s}),queryKey:a,staleTime:Number.POSITIVE_INFINITY});return n(()=>r?()=>{}:k(e).attach(y,a,t,o,s,{onError:l}),[e,y,C(a),r,l]),r?void 0:R};export{F as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as x}from"react/compiler-runtime";import{createQuerySubscription as A}from"@lunora/client/query";import{LunoraError as D}from"@lunora/errors";import{useState as F,useRef as S,useEffect as v}from"react";import{useLunora as M}from"./LunoraProvider-DC06S-p1.mjs";import{s as Q}from"./wire-key-L5JSXhhG.mjs";const H=(o,r,a)=>{const e=x(24);let l;e[0]!==a?(l=a===void 0?{}:a,e[0]=a,e[1]=l):l=e[1];const t=l,n=M();let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={data:void 0,error:void 0},e[2]=c):c=e[2];const[k,E]=F(c),s=r==="skip";let d;e[3]!==r||e[4]!==s?(d=s?"skip":Q(r),e[3]=r,e[4]=s,e[5]=d):d=e[5];const b=d,K=S(t.onError);let f;e[6]!==t.onError?(f=()=>{K.current=t.onError},e[6]=t.onError,e[7]=f):f=e[7],v(f);let u;e[8]!==r||e[9]!==o?(u={args:r,fn:o},e[8]=r,e[9]=o,e[10]=u):u=e[10];const R=S(u);let m;e[11]!==r||e[12]!==o?(m=()=>{R.current={args:r,fn:o}},e[11]=r,e[12]=o,e[13]=m):m=e[13],v(m);let p;e[14]!==n||e[15]!==t.shardKey||e[16]!==s?(p=()=>{if(s)return E({data:void 0,error:void 0}),W;let h=!1;const{args:w,fn:z}=R.current,L=A(n,z,w,{onData:i=>{h||E({data:i,error:void 0})},onError:i=>{const q=i.code===void 0?new Error(i.message):new D(i.code,i.message);K.current?.(i),queueMicrotask(()=>{h||E({data:void 0,error:q})})}},{shardKey:t.shardKey});return()=>{h=!0,L()}},e[14]=n,e[15]=t.shardKey,e[16]=s,e[17]=p):p=e[17];let y;return e[18]!==n||e[19]!==o.__lunoraRef||e[20]!==t.shardKey||e[21]!==b||e[22]!==s?(y=[n,o.__lunoraRef,b,t.shardKey,s],e[18]=n,e[19]=o.__lunoraRef,e[20]=t.shardKey,e[21]=b,e[22]=s,e[23]=y):y=e[23],v(p,y),k};function W(){}export{H as default};
|
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.77",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@lunora/client": "1.0.0-alpha.
|
|
61
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
62
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
60
|
+
"@lunora/client": "1.0.0-alpha.72",
|
|
61
|
+
"@lunora/errors": "1.0.0-alpha.30",
|
|
62
|
+
"@lunora/ratelimit": "1.0.0-alpha.36",
|
|
63
63
|
"@visulima/storage-client": "1.0.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as u}from"./query-key-C6iUhRuD.mjs";class k{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return u(e)}attach(e,o,b,h,p,l={}){const i=u(o);let t=this.entries.get(i);if(!t){t={errorCallbacks:new Set,pollTimer:void 0,refCount:0,unsubscribe:void 0},this.entries.set(i,t);const r=t;try{t.unsubscribe=this.client.subscribe(b,h,a=>{e.setQueryData(o,a)},{onError:a=>{for(const d of r.errorCallbacks)d(a)},shardKey:p})}catch{t.pollTimer=setInterval(()=>{e.invalidateQueries({queryKey:o}).catch(()=>{})},l.pollIntervalMs??5e3)}}t.refCount+=1;const{onError:n}=l;n&&t.errorCallbacks.add(n);let c=!1;return()=>{if(c)return;c=!0;const r=this.entries.get(i);r&&(r.refCount-=1,n&&r.errorCallbacks.delete(n),r.refCount<=0&&(r.unsubscribe?.(),r.pollTimer&&clearInterval(r.pollTimer),this.entries.delete(i)))}}}const f=new WeakMap,C=s=>{let e=f.get(s);return e||(e=new k(s),f.set(s,e)),e};export{C as g};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as m}from"react/compiler-runtime";import{useQueryClient as d,useQuery as p}from"@tanstack/react-query";import{useEffect as g}from"react";import{g as I}from"./cache-BuILe2dy.mjs";import{useLunora as Q}from"./LunoraProvider-DC06S-p1.mjs";import{l as h,s as q}from"./query-key-C6iUhRuD.mjs";const K=function(n){const e=m(4),t=Q(),r=d(),{args:s,functionPath:l,shardKey:u,value:y}=n,i={__lunoraRef:l},a=h(i,s,u),{data:f}=p({initialData:y,queryFn:()=>t.query(i,s,{shardKey:u}),queryKey:a,staleTime:Number.POSITIVE_INFINITY}),c=q(a);let o;return e[0]!==t||e[1]!==r||e[2]!==c?(o=[t,r,c],e[0]=t,e[1]=r,e[2]=c,e[3]=o):o=e[3],g(()=>I(t).attach(r,a,i,s,u),o),f===void 0?y:f},C=function(n){return K(n)};export{K as default,C as hydratePreloaded};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{initialPages as M,rebalance as D,derivePaginationStatus as A,applyLoadMore as E}from"@lunora/client/pagination";import{useQueryClient as O}from"@tanstack/react-query";import{useRef as m,useReducer as _,useState as $,useEffect as d,useCallback as j}from"react";import{g as H}from"./cache-BuILe2dy.mjs";import{useLunora as N}from"./LunoraProvider-DC06S-p1.mjs";import{s as i,l as q}from"./query-key-C6iUhRuD.mjs";const T=function(o){const f=m(void 0);return f.current??=o(),f},Y=function(o,f,L){const a=N(),n=O(),{initialNumItems:g,shardKey:l}=L,c=f==="skip",p=c?{}:f,[,P]=_(e=>e+1,0),[v,K]=$(()=>M(g)),b=`${i(q(o,p,l))}::${String(g)}`,S=m(b);S.current!==b&&(S.current=b,K(M(g)));const h=v.map(e=>{const s={...p,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}},r=q(o,s,l);return{args:s,key:r}}),w=h.map(({key:e})=>i(e)).join("|"),k=m({baseArgs:p,entries:[],fn:o,shardKey:l});d(()=>{k.current={baseArgs:p,entries:h,fn:o,shardKey:l}});const C=T(()=>new Map),I=m(a);d(()=>{const e=C.current;if(I.current!==a){for(const t of e.values())t();e.clear(),I.current=a}if(c){for(const t of e.values())t();e.clear();return}const s=k.current,r=H(a),y=new Set(s.entries.map(({key:t})=>i(t)));for(const[t,u]of e)y.has(t)||(u(),e.delete(t));for(const t of s.entries){const u=i(t.key);if(e.has(u))continue;n.fetchQuery({queryFn:()=>a.query(s.fn,t.args,{shardKey:s.shardKey}),queryKey:t.key,staleTime:0}).catch(()=>{}),e.set(u,r.attach(n,t.key,s.fn,t.args,s.shardKey))}},[a,n,w,c]),d(()=>()=>{for(const e of C.current.values())e();C.current.clear()},[]),d(()=>n.getQueryCache().subscribe(r=>{if(r.type!=="updated")return;const y=i(r.query.queryKey);h.some(({key:t})=>i(t)===y)&&P()}),[n,w]);const R=c?[]:h.map(({key:e})=>n.getQueryData(e));d(()=>{if(c)return;const e=D(v,R);e&&K(e)});const{status:x}=A(c,R);return{loadMore:j(e=>{K(s=>{const r=k.current,y=s.map(Q=>{const z={...r.baseArgs,paginationOpts:{cursor:Q.lower,endCursor:Q.upper,numItems:Q.numItems}};return n.getQueryData(q(r.fn,z,r.shardKey))}),{nextCursor:t,status:u}=A(!1,y);return E(s,u==="CanLoadMore"?t:void 0,e)??s})},[n]),pageResults:R,status:x}};export{Y as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as v}from"react/compiler-runtime";import{useMutation as M}from"./useMutation-BnKec7bE.mjs";import w from"./useSubscription-BXhI6J-f.mjs";const N={__lunoraRef:""},x=h=>{const t=v(17),{api:y,cancel:a,run:R,runArgs:l,threadKey:e}=h,c=M(R),_=M(a??N);let s;t[0]!==e?(s={key:e},t[0]=e,t[1]=s):s=t[1];const{data:A}=w(y.agents.agentThread,s),n=A,d=n?.status,o=n?.instanceId,{mutate:f}=c,{mutate:p}=_;let r;t[2]!==l||t[3]!==f||t[4]!==e?(r=async(I,T)=>{await f({input:I,threadKey:e,...l,...T})},t[2]=l,t[3]=f,t[4]=e,t[5]=r):r=t[5];const g=r;let i;t[6]!==p||t[7]!==a||t[8]!==o||t[9]!==e?(i=async()=>{a===void 0||o===void 0||await p({instanceId:o,threadKey:e})},t[6]=p,t[7]=a,t[8]=o,t[9]=e,t[10]=i):i=t[10];const m=i;let u;return t[11]!==m||t[12]!==g||t[13]!==c.pending||t[14]!==d||t[15]!==n?(u={cancel:m,pending:c.pending,run:g,status:d,thread:n},t[11]=m,t[12]=g,t[13]=c.pending,t[14]=d,t[15]=n,t[16]=u):u=t[16],u};export{x as useAgent};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{reconcileOptimistic as y,maxSeq as M}from"@lunora/client";import{useState as H,useRef as R}from"react";import{useMutation as u}from"./useMutation-BnKec7bE.mjs";import{useStream as J}from"./useStream-CmGOT0qj.mjs";import S from"./useSubscription-BXhI6J-f.mjs";const L={__lunoraRef:""},Q={__lunoraRef:""},V=[],ot=A=>{const{api:r,cancel:m,limit:d,send:_,sendArgs:k,stream:l,threadKey:e}=A,x=d===void 0?{key:e}:{key:e,limit:d},{data:E}=S(r.agents.agentMessages,x),{data:w}=S(r.agents.agentThread,{key:e}),O=l===void 0?"skip":{key:e},{chunks:T}=J(l??Q,O),b=u(_),I=u(m??L),j=u(r.agents.agentResolveApproval),[q,c]=H([]),p=R(0),f=R(e);f.current!==e&&(f.current=e,c([]));const g=w,C=g?.status,o=g?.instanceId,s=E??V,h=y(q,s),D=M(s),K=h.length===0?s:[...s,...h.map((t,n)=>({content:t.content,optimistic:!0,role:"user",seq:D+1+n}))],N=s.filter(t=>t.role==="assistant").length,F=T.filter(t=>t.kind!=="progress"&&t.threadKey===e&&t.turn>=N).map(t=>t.text).join(""),{mutate:G}=b,{mutate:P}=I,{mutate:U}=j,Y=async(t,n)=>{const a=p.current;p.current+=1;const $=M(s);c(i=>[...y(i,s),{content:t,id:a,maxDurableSeqAtSend:$}]);try{await G({input:t,threadKey:e,...k,...n})}catch(i){throw c(z=>z.filter(B=>B.id!==a)),i}},v=async(t,n,a)=>{if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await U({decision:t,instanceId:o,threadKey:e,toolCallId:n,...a===void 0?{}:{note:a}})};return{approve:(t,n)=>v("approve",t,n),cancel:async()=>{m===void 0||o===void 0||await P({instanceId:o,threadKey:e})},messages:K,reject:(t,n)=>v("reject",t,n),send:Y,status:C,streamingText:F}};export{ot as useAgentChat};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as L}from"react/compiler-runtime";import{useRef as M,useEffect as R}from"react";import{u as y}from"./use-paginated-core-Lu50LpUb.mjs";const b=(h,c,g)=>{const e=L(15),{initialNumItems:s}=g,{loadMore:o,pageResults:u,status:a}=y(h,c==="skip"?"skip":c,g),N=c==="skip";let t;if(e[0]!==u){t=[];for(const f of u)f&&t.push(f.page);e[0]=u,e[1]=t}else t=e[1];let i;e[2]!==s||e[3]!==o?(i={defaultNumItems:s,loadMore:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const P=M(i);let n;e[5]!==s||e[6]!==o?(n=()=>{P.current={defaultNumItems:s,loadMore:o}},e[5]=s,e[6]=o,e[7]=n):n=e[7],R(n);let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=f=>{const{defaultNumItems:I,loadMore:k}=P.current;k(f??I)},e[8]=l):l=e[8];const x=l,m=a==="CanLoadMore",d=!N&&a==="LoadingMore",p=!N&&a==="LoadingFirstPage";let r;return e[9]!==t||e[10]!==a||e[11]!==m||e[12]!==d||e[13]!==p?(r={fetchNextPage:x,hasNextPage:m,isFetchingNextPage:d,isLoading:p,pages:t,status:a},e[9]=t,e[10]=a,e[11]=m,e[12]=d,e[13]=p,e[14]=r):r=e[14],r};export{b as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as l}from"react/compiler-runtime";import{u as c}from"./use-paginated-core-Lu50LpUb.mjs";const m=(u,i,d)=>{const e=l(7),{loadMore:p,pageResults:r,status:t}=c(u,i==="skip"?"skip":i,d);let s;if(e[0]!==r){s=[];for(const a of r)a&&s.push(...a.page);e[0]=r,e[1]=s}else s=e[1];const n=!(i==="skip")&&(t==="LoadingFirstPage"||t==="LoadingMore");let o;return e[2]!==p||e[3]!==s||e[4]!==t||e[5]!==n?(o={isLoading:n,loadMore:p,results:s,status:t},e[2]=p,e[3]=s,e[4]=t,e[5]=n,e[6]=o):o=e[6],o};export{m as usePaginatedQuery};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{useMemo as U,useState as D,useRef as b,useEffect as a,useCallback as p}from"react";import{useLunora as E}from"./LunoraProvider-DC06S-p1.mjs";const L=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}}return Date.now().toString(36)},A=1e4,C=(t,n)=>{const s=E(),{heartbeat:f,intervalMs:l=A,listPresent:y,shardKey:r}=n,c=U(()=>n.sessionId??L(),[n.sessionId]),[v,I]=D(void 0),d=b(n.data),m=b({client:s,heartbeat:f,roomId:t,sessionId:c,shardKey:r});a(()=>{m.current={client:s,heartbeat:f,roomId:t,sessionId:c,shardKey:r}});const o=p(()=>{const{client:e,heartbeat:i,roomId:u,sessionId:g,shardKey:S}=m.current,R={roomId:u,sessionId:g,...d.current===void 0?{}:{data:d.current}};e.mutation(i,R,{shardKey:S}).catch(()=>{})},[]),h=p(e=>{d.current=e,o()},[o]);return a(()=>{o();const e=setInterval(o,l),i=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),()=>{clearInterval(e),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}},[o,l]),a(()=>s.acquireConnectionContext({roomId:t,sessionId:c},{shardKey:r}),[s,t,c,r]),a(()=>{let e=!1;const i=s.subscribe(y,{roomId:t},u=>{e||I(u)},{shardKey:r});return()=>{e=!0,i()}},[s,y.__lunoraRef,t,r]),{present:v,sessionId:c,setData:h}};export{C as usePresence};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as q}from"react/compiler-runtime";import{createQuerySubscription as w}from"@lunora/client/query";import{useState as x,useRef as A,useEffect as v}from"react";import{useLunora as D}from"./LunoraProvider-DC06S-p1.mjs";import{s as F}from"./wire-key-L5JSXhhG.mjs";const j=(t,r,a)=>{const e=q(22);let l;e[0]!==a?(l=a===void 0?{}:a,e[0]=a,e[1]=l):l=e[1];const o=l,i=D();let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={data:void 0,error:void 0},e[2]=n):n=e[2];const[R,p]=x(n),s=r==="skip";let c;e[3]!==r||e[4]!==s?(c=s?"skip":F(r),e[3]=r,e[4]=s,e[5]=c):c=e[5];const y=c;let d;e[6]!==r||e[7]!==t?(d={args:r,fn:t},e[6]=r,e[7]=t,e[8]=d):d=e[8];const K=A(d);let f;e[9]!==r||e[10]!==t?(f=()=>{K.current={args:r,fn:t}},e[9]=r,e[10]=t,e[11]=f):f=e[11],v(f);let u;e[12]!==i||e[13]!==o.shardKey||e[14]!==s?(u=()=>{if(s)return p({data:void 0,error:void 0}),L;let b=!1;const{args:S,fn:k}=K.current,E=w(i,k,S,{onData:h=>{b||p({data:h,error:void 0})},onError:h=>{const z=new Error(h.message);queueMicrotask(()=>{b||p({data:void 0,error:z})})}},{shardKey:o.shardKey});return()=>{b=!0,E()}},e[12]=i,e[13]=o.shardKey,e[14]=s,e[15]=u):u=e[15];let m;return e[16]!==i||e[17]!==t.__lunoraRef||e[18]!==o.shardKey||e[19]!==y||e[20]!==s?(m=[i,t.__lunoraRef,y,o.shardKey,s],e[16]=i,e[17]=t.__lunoraRef,e[18]=o.shardKey,e[19]=y,e[20]=s,e[21]=m):m=e[21],v(u,m),R};function L(){}export{j as default};
|