@lunora/react 1.0.0-alpha.241 → 1.0.0-alpha.243

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 CHANGED
@@ -103,7 +103,7 @@ function MessageList({ room }: { room: string }) {
103
103
  | `useInfiniteQuery(fn, args, { initialNumItems, onError? })` | `{ pages, status, hasNextPage, fetchNextPage, error, … }` | Page-array variant of the same paginator. |
104
104
  | `usePreloadedQuery(preloaded, options?)` | `T \| undefined` | Reads a server `Preloaded` token, then goes live. Pass `onError` to see a session expiry instead of rendering the stale SSR snapshot. |
105
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
- | `useLiveTopic(options)` | `{ lastEvent, error }` | Follows one topic of a `defineLiveStream` over an SSE connection shared by URL. See the note below the table. |
106
+ | `useLiveTopic(topic, options?)` | `{ lastEvent, error }` | Follows one declared live topic over an SSE connection shared by stream route. See the note below the table. |
107
107
  | `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. |
108
108
  | `useFlags(defaults)` | `{ [key]: value }` | Batch variant — one live value per key in the `defaults` map. |
109
109
  | `useStream(fn, args, options?)` | `{ chunks, status, error, cancel }` | Consumes a streamed action response chunk by chunk. |
@@ -119,7 +119,7 @@ function MessageList({ room }: { room: string }) {
119
119
 
120
120
  The payment kit — `CheckoutButton`, `CustomerPortalButton`, and `useCheckout`, which wrap `@lunora/payment` flows — ships from the `@lunora/react/payment` subpath, not the package root: it renders a DOM `<button>` and navigates via `globalThis.location`, so it is the one part of this package that is browser-only (the root barrel stays renderer-agnostic, which is what lets `@lunora/react-native` re-export it wholesale).
121
121
 
122
- `useLiveTopic(options)` follows one topic of a `defineLiveStream` route. The SSE connection is shared by `url`: every live-topic hook on the page rides one stream, and it closes after the last one unmounts. `lastEvent` is the last payload delivered on the topic, and `error` is set when the shard refuses the subscription. Changing `onEvent` or `onError` does not resubscribe. It opens nothing during SSR.
122
+ `useLiveTopic(topic, options?)` follows one topic a `defineLiveStream` declares. Pass the reference `_generated/live.ts` hands out, e.g. `useLiveTopic(live.posts.post({ postId }), { onEvent })`: the stream's route is resolved against the `LunoraClient` from `<LunoraProvider>`, so there is no URL or topic string to write, and `lastEvent` and `onEvent` are typed by the payload the topic declares. The SSE connection is shared by stream route and connection options: hooks with the same route, `shardKey`, `sessionKey`, credentials, headers and retry tuning ride one stream, and it closes after the last one unmounts. `lastEvent` is the last payload delivered on the topic, and `error` is set when the shard refuses the subscription. Options are `onEvent`, `onError`, `shardKey` (follow a `.shardBy` shard, and publish to the same one), `sessionKey` (partitions the shared connection: a changed value opens a new one and closes the old, for example on sign-out; it is never sent to the server), and the transport tuning `headers`, `withCredentials`, `retryDelay`, `maxDelayMs`. Changing `onEvent` or `onError` does not resubscribe. It opens nothing during SSR.
123
123
 
124
124
  `useVoiceAgent` opens nothing until you call `startCall()` — that is what requests the microphone, so it has to run from a user gesture; `endCall()` releases the socket, the mic tracks and the Web Audio graph, and also runs on unmount. See the [voice-agent docs](https://lunora.sh/docs/packages/react#voice-agents--usevoiceagentoptions) for the silence/barge-in thresholds.
125
125
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, SubscribeLiveTopicOptions, LiveStreamSubscribeError, MutatorHandle, Preloaded } from '@lunora/client';
2
+ import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, 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";
@@ -953,29 +953,33 @@ declare const usePaginatedQuery: <F extends FunctionReference>(function_: F, arg
953
953
  * keyset implementation.
954
954
  */
955
955
  declare const useInfiniteQuery: <F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: UseInfiniteQueryOptions) => UseInfiniteQueryResult<PageItemOf<F>>;
956
- /** Options for {@link useLiveTopic}: the `subscribeLiveTopic` options, with the callbacks read through a ref. */
957
- type UseLiveTopicOptions = SubscribeLiveTopicOptions;
958
- interface UseLiveTopicResult {
956
+ /** Options for {@link useLiveTopic}: the transport tuning and callbacks, with the callbacks read through a ref. */
957
+ type UseLiveTopicOptions<Payload = unknown> = LiveTopicOptions<Payload>;
958
+ interface UseLiveTopicResult<Payload = unknown> {
959
959
  /** Set when the shard refuses the subscription (403, 409, 429 and similar). */
960
960
  error: LiveStreamSubscribeError | undefined;
961
961
  /** The last payload delivered on the topic, or `undefined` until the first event. */
962
- lastEvent: unknown;
962
+ lastEvent: Payload | undefined;
963
963
  }
964
964
  /**
965
965
  * `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
966
- * the component.
966
+ * the component. Pass the reference `_generated/live.ts` hands out
967
+ * (`live.posts.post({ postId })`): the stream's route is resolved against the
968
+ * `LunoraClient` from the nearest `<LunoraProvider>`, and `lastEvent` and `onEvent`
969
+ * are typed by the payload the topic declares.
967
970
  *
968
971
  * It is a lifecycle wrapper over `subscribeLiveTopic`: the connection itself is
969
972
  * shared by URL, so mounting this hook ten times still opens one stream. It
970
973
  * subscribes on mount, unsubscribes on unmount, and resubscribes only when the
971
- * connection inputs (`url`, `topic`, credentials, headers, retry tuning) change.
972
- * Changing `onEvent` or `onError` identity does not resubscribe — the latest
973
- * callback is read through a ref.
974
+ * connection inputs (topic, shard, credentials, headers, retry tuning) change.
975
+ * Building the reference inline on every render is fine, since only its content
976
+ * counts. Changing `onEvent` or `onError` identity does not resubscribe — the
977
+ * latest callback is read through a ref.
974
978
  *
975
979
  * It is a no-op during SSR: effects do not run on the server, so the hook returns
976
980
  * its initial values there.
977
981
  */
978
- declare const useLiveTopic: (options: UseLiveTopicOptions) => UseLiveTopicResult;
982
+ declare function useLiveTopic<Payload>(topic: LiveTopicRef<Payload>, options?: UseLiveTopicOptions<Payload>): UseLiveTopicResult<Payload>;
979
983
  type CallOptions<F extends FunctionReference> = UseMutationCallOptions<unknown, unknown, ArgsOf<F>>;
980
984
  interface MutationHook<F extends FunctionReference> {
981
985
  /** The latest invocation's resolved value, or `undefined` before the first success. */
@@ -1274,6 +1278,22 @@ declare const useStream: <F extends FunctionReference<"stream">>(function_: F, a
1274
1278
  * `SubscriptionError` in addition.
1275
1279
  */
1276
1280
  declare const useSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
1281
+ /**
1282
+ * Subscribe to a server query inside a `<Suspense>` boundary.
1283
+ *
1284
+ * Unlike `useQuery` the value is never `undefined`: the component suspends
1285
+ * until the query's first value lands (the durable read cache when it already
1286
+ * holds one, otherwise the server's snapshot) and renders only with data. A
1287
+ * failed first fetch throws to the nearest error boundary.
1288
+ *
1289
+ * It shares `useQuery`'s TanStack cache entry and WebSocket subscription —
1290
+ * same query key, same registry — so mixing the two on one query costs one
1291
+ * subscription, and pushes keep the value current once it has rendered.
1292
+ *
1293
+ * There is no `"skip"`: a query that may not run is `useQuery`'s job, since a
1294
+ * suspending hook has no value to return for it.
1295
+ */
1296
+ declare const useSuspenseQuery: <F extends FunctionReference>(function_: F, args: ArgsOf<F>, options?: UseQueryOptions) => ReturnOf<F>;
1277
1297
  /**
1278
1298
  * Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
1279
1299
  * capture and speaker playback implementations injected into the hook via its
@@ -1436,4 +1456,4 @@ interface UseVoiceAgentResult {
1436
1456
  * `createSocket`) so the hook is drivable outside a browser.
1437
1457
  */
1438
1458
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1439
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useVoiceAgent };
1459
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, useVoiceAgent };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, SubscribeLiveTopicOptions, LiveStreamSubscribeError, MutatorHandle, Preloaded } from '@lunora/client';
2
+ import { LunoraClient, OptimisticUpdate, User, SubscriptionErrorCallback, SubscriptionError, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, 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";
@@ -953,29 +953,33 @@ declare const usePaginatedQuery: <F extends FunctionReference>(function_: F, arg
953
953
  * keyset implementation.
954
954
  */
955
955
  declare const useInfiniteQuery: <F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: UseInfiniteQueryOptions) => UseInfiniteQueryResult<PageItemOf<F>>;
956
- /** Options for {@link useLiveTopic}: the `subscribeLiveTopic` options, with the callbacks read through a ref. */
957
- type UseLiveTopicOptions = SubscribeLiveTopicOptions;
958
- interface UseLiveTopicResult {
956
+ /** Options for {@link useLiveTopic}: the transport tuning and callbacks, with the callbacks read through a ref. */
957
+ type UseLiveTopicOptions<Payload = unknown> = LiveTopicOptions<Payload>;
958
+ interface UseLiveTopicResult<Payload = unknown> {
959
959
  /** Set when the shard refuses the subscription (403, 409, 429 and similar). */
960
960
  error: LiveStreamSubscribeError | undefined;
961
961
  /** The last payload delivered on the topic, or `undefined` until the first event. */
962
- lastEvent: unknown;
962
+ lastEvent: Payload | undefined;
963
963
  }
964
964
  /**
965
965
  * `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
966
- * the component.
966
+ * the component. Pass the reference `_generated/live.ts` hands out
967
+ * (`live.posts.post({ postId })`): the stream's route is resolved against the
968
+ * `LunoraClient` from the nearest `<LunoraProvider>`, and `lastEvent` and `onEvent`
969
+ * are typed by the payload the topic declares.
967
970
  *
968
971
  * It is a lifecycle wrapper over `subscribeLiveTopic`: the connection itself is
969
972
  * shared by URL, so mounting this hook ten times still opens one stream. It
970
973
  * subscribes on mount, unsubscribes on unmount, and resubscribes only when the
971
- * connection inputs (`url`, `topic`, credentials, headers, retry tuning) change.
972
- * Changing `onEvent` or `onError` identity does not resubscribe — the latest
973
- * callback is read through a ref.
974
+ * connection inputs (topic, shard, credentials, headers, retry tuning) change.
975
+ * Building the reference inline on every render is fine, since only its content
976
+ * counts. Changing `onEvent` or `onError` identity does not resubscribe — the
977
+ * latest callback is read through a ref.
974
978
  *
975
979
  * It is a no-op during SSR: effects do not run on the server, so the hook returns
976
980
  * its initial values there.
977
981
  */
978
- declare const useLiveTopic: (options: UseLiveTopicOptions) => UseLiveTopicResult;
982
+ declare function useLiveTopic<Payload>(topic: LiveTopicRef<Payload>, options?: UseLiveTopicOptions<Payload>): UseLiveTopicResult<Payload>;
979
983
  type CallOptions<F extends FunctionReference> = UseMutationCallOptions<unknown, unknown, ArgsOf<F>>;
980
984
  interface MutationHook<F extends FunctionReference> {
981
985
  /** The latest invocation's resolved value, or `undefined` before the first success. */
@@ -1274,6 +1278,22 @@ declare const useStream: <F extends FunctionReference<"stream">>(function_: F, a
1274
1278
  * `SubscriptionError` in addition.
1275
1279
  */
1276
1280
  declare const useSubscription: <F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
1281
+ /**
1282
+ * Subscribe to a server query inside a `<Suspense>` boundary.
1283
+ *
1284
+ * Unlike `useQuery` the value is never `undefined`: the component suspends
1285
+ * until the query's first value lands (the durable read cache when it already
1286
+ * holds one, otherwise the server's snapshot) and renders only with data. A
1287
+ * failed first fetch throws to the nearest error boundary.
1288
+ *
1289
+ * It shares `useQuery`'s TanStack cache entry and WebSocket subscription —
1290
+ * same query key, same registry — so mixing the two on one query costs one
1291
+ * subscription, and pushes keep the value current once it has rendered.
1292
+ *
1293
+ * There is no `"skip"`: a query that may not run is `useQuery`'s job, since a
1294
+ * suspending hook has no value to return for it.
1295
+ */
1296
+ declare const useSuspenseQuery: <F extends FunctionReference>(function_: F, args: ArgsOf<F>, options?: UseQueryOptions) => ReturnOf<F>;
1277
1297
  /**
1278
1298
  * Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
1279
1299
  * capture and speaker playback implementations injected into the hook via its
@@ -1436,4 +1456,4 @@ interface UseVoiceAgentResult {
1436
1456
  * `createSocket`) so the hook is drivable outside a browser.
1437
1457
  */
1438
1458
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1439
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useVoiceAgent };
1459
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSignUpInvitationsOptions, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLiveTopic, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useSignUpInvitations, useStream, useSubscription, useSuspenseQuery, useVoiceAgent };
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-024-XH0I.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CqN1F2FM.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-_WqSuvf9.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-IJB_aFzi.mjs";import{useAction as x}from"./packem_shared/useAction-jJl4KPEw.mjs";import{useAuthSessions as g,useAuthUsers as A,useImpersonate as c,useOrganizations as h,useSignUpInvitations as U}from"./packem_shared/useAuthSessions-jJWdw8Zw.mjs";import{useAgent as C}from"./packem_shared/useAgent-C2jMXz2-.mjs";import{useAgentChat as S}from"./packem_shared/useAgentChat-DiBCl0Rr.mjs";import{useAgentState as Q}from"./packem_shared/useAgentState-CDAO3aLL.mjs";import{useAgentToolEvents as R}from"./packem_shared/useAgentToolEvents-Bb94yV7R.mjs";import{default as F}from"./packem_shared/useAuth-CpGKVRsv.mjs";import{default as M}from"./packem_shared/useClientQuery-DUEUAqPh.mjs";import{default as b}from"./packem_shared/useConnectionStatus-Dtx_OWez.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-A7XPHExt.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-CzryjxVH.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-D_AG59dX.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-C6a6nMn0.mjs";import{useMutation as G}from"./packem_shared/useMutation-Bz9uwvGf.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-DhQAsxgX.mjs";import{hydratePreloaded as Y,default as Z}from"./packem_shared/hydratePreloaded-qs8nspKB.mjs";import{usePresence as $}from"./packem_shared/usePresence-X5Ax04Cf.mjs";import{default as re}from"./packem_shared/useQuery-CETQat99.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-D8GB__4j.mjs";import{default as pe}from"./packem_shared/useSubscription-CwZgOrE4.mjs";import{useVoiceAgent as ne}from"./packem_shared/useVoiceAgent-DAh27XxD.mjs";import{createClientQuery as me,getErrorCode as de,getRetryAfterMs as xe,isConflictError as le,isForbiddenError as ge,isRateLimitedError as Ae,isUnauthorizedError as ce}from"@lunora/client";import{RestrictionError as Ue,UploadControl as ye,UploadError as Ce}from"@visulima/storage-client";import{useChunkedRestUpload as Se,useFileInput as Le,useMultipartUpload as Qe,usePasteUpload as Pe,useTusUpload as Re,useUpload as ve}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Ue as RestrictionError,u as Unauthenticated,ye as UploadControl,Ce as UploadError,me as createClientQuery,de as getErrorCode,xe as getRetryAfterMs,Y as hydratePreloaded,le as isConflictError,ge as isForbiddenError,Ae as isRateLimitedError,ce as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,C as useAgent,S as useAgentChat,Q as useAgentState,R as useAgentToolEvents,F as useAuth,g as useAuthSessions,a as useAuthState,A as useAuthUsers,Se as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Le as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,c as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Qe as useMultipartUpload,G as useMutation,K as useMutator,h as useOrganizations,W as usePaginatedQuery,Pe as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,U as useSignUpInvitations,se as useStream,pe as useSubscription,Re as useTusUpload,ve as useUpload,ne as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-024-XH0I.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CqN1F2FM.mjs";import{L as f,u as n}from"./packem_shared/lunora-provider-_WqSuvf9.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-IJB_aFzi.mjs";import{useAction as x}from"./packem_shared/useAction-jJl4KPEw.mjs";import{useAuthSessions as g,useAuthUsers as A,useImpersonate as c,useOrganizations as h,useSignUpInvitations as U}from"./packem_shared/useAuthSessions-jJWdw8Zw.mjs";import{useAgent as S}from"./packem_shared/useAgent-C2jMXz2-.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-DiBCl0Rr.mjs";import{useAgentState as L}from"./packem_shared/useAgentState-CDAO3aLL.mjs";import{useAgentToolEvents as R}from"./packem_shared/useAgentToolEvents-Bb94yV7R.mjs";import{default as F}from"./packem_shared/useAuth-CpGKVRsv.mjs";import{default as M}from"./packem_shared/useClientQuery-DUEUAqPh.mjs";import{default as b}from"./packem_shared/useConnectionStatus-Dtx_OWez.mjs";import{useFlag as O,useFlags as k}from"./packem_shared/useFlag-A7XPHExt.mjs";import{useHttpStream as V}from"./packem_shared/useHttpStream-CzryjxVH.mjs";import{default as q}from"./packem_shared/useInfiniteQuery-D_AG59dX.mjs";import{useLiveTopic as B}from"./packem_shared/useLiveTopic-UYAE2s4R.mjs";import{useMutation as G}from"./packem_shared/useMutation-Bz9uwvGf.mjs";import{useMutator as K}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as W}from"./packem_shared/usePaginatedQuery-DhQAsxgX.mjs";import{hydratePreloaded as Y,default as Z}from"./packem_shared/hydratePreloaded-qs8nspKB.mjs";import{usePresence as $}from"./packem_shared/usePresence-X5Ax04Cf.mjs";import{default as re}from"./packem_shared/useQuery-Cek_oF7t.mjs";import{useRateLimit as te}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as se}from"./packem_shared/useStream-D8GB__4j.mjs";import{default as pe}from"./packem_shared/useSubscription-CwZgOrE4.mjs";import{default as ne}from"./packem_shared/useSuspenseQuery-CZTk7Kch.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-DAh27XxD.mjs";import{createClientQuery as xe,getErrorCode as le,getRetryAfterMs as ge,isConflictError as Ae,isForbiddenError as ce,isRateLimitedError as he,isUnauthorizedError as Ue}from"@lunora/client";import{RestrictionError as Se,UploadControl as Ce,UploadError as Ee}from"@visulima/storage-client";import{useChunkedRestUpload as Le,useFileInput as Pe,useMultipartUpload as Re,usePasteUpload as ve,useTusUpload as Fe,useUpload as Ie}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,Se as RestrictionError,u as Unauthenticated,Ce as UploadControl,Ee as UploadError,xe as createClientQuery,le as getErrorCode,ge as getRetryAfterMs,Y as hydratePreloaded,Ae as isConflictError,ce as isForbiddenError,he as isRateLimitedError,Ue as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,S as useAgent,E as useAgentChat,L as useAgentState,R as useAgentToolEvents,F as useAuth,g as useAuthSessions,a as useAuthState,A as useAuthUsers,Le as useChunkedRestUpload,M as useClientQuery,b as useConnectionStatus,Pe as useFileInput,O as useFlag,k as useFlags,V as useHttpStream,c as useImpersonate,q as useInfiniteQuery,B as useLiveTopic,n as useLunora,Re as useMultipartUpload,G as useMutation,K as useMutator,h as useOrganizations,W as usePaginatedQuery,ve as usePasteUpload,Z as usePreloadedQuery,$ as usePresence,re as useQuery,te as useRateLimit,U as useSignUpInvitations,se as useStream,pe as useSubscription,ne as useSuspenseQuery,Fe as useTusUpload,Ie as useUpload,me as useVoiceAgent};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as R}from"react/compiler-runtime";import{useRef as $,useEffect as _}from"react";import{g as b}from"./lunora-provider-_WqSuvf9.mjs";const k=i=>{const e=R(16),{args:a,argsKey:y,client:t,function_:s,onError:o,queryClient:r,queryKey:n,shardKey:u,skipped:c}=i,h=`${s.__lunoraRef}\0${y}\0${u??""}`,S=$(o);let f;e[0]!==o?(f=()=>{S.current=o},e[0]=o,e[1]=f):f=e[1],_(f);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=E=>{S.current?.(E)},e[2]=p):p=e[2];const g=p;let l;e[3]!==a||e[4]!==t||e[5]!==s||e[6]!==r||e[7]!==n||e[8]!==u||e[9]!==c?(l=()=>c?K:b(t).attach(r,n,s,a,u,{onError:g}),e[3]=a,e[4]=t,e[5]=s,e[6]=r,e[7]=n,e[8]=u,e[9]=c,e[10]=l):l=e[10];let m;e[11]!==t||e[12]!==r||e[13]!==c||e[14]!==h?(m=[t,r,h,c,g],e[11]=t,e[12]=r,e[13]=c,e[14]=h,e[15]=m):m=e[15],_(l,m)},w=async(i,e,a,y,t,s)=>{const o=b(i),r=o.openSnapshotSample(s),n=await i.query(a,y,{shardKey:t});return o.closeSnapshotSample(r)?n:e.getQueryData(s)??n};function K(){}export{w as f,k as u};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as D}from"react/compiler-runtime";import{liveTopicSubscription as R,subscribeLiveTopic as C}from"@lunora/client";import{stableWireKey as M}from"@lunora/wire";import{useState as W,useRef as $,useEffect as y}from"react";import{u as g}from"./lunora-provider-_WqSuvf9.mjs";function F(b,f){const t=D(8),d=f===void 0?{}:f,o=R(g(),b,d),{headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}=o,e=M({headers:k,maxDelayMs:T,retryDelay:K,sessionKey:L,topic:S,url:h,withCredentials:w}),[p,l]=W(),m=p?.key===e?p:void 0,s=$(o);let n;t[0]!==o?(n=()=>{s.current=o},t[0]=o,t[1]=n):n=t[1],y(n);let i,c;t[2]!==e?(i=()=>{const x=C({...s.current,onError:r=>{l(E=>({error:r,key:e,lastEvent:E?.key===e?E.lastEvent:void 0})),s.current.onError?.(r)},onEvent:r=>{l({error:void 0,key:e,lastEvent:r}),s.current.onEvent?.(r)}});return()=>{x(),l(void 0)}},c=[e],t[2]=e,t[3]=i,t[4]=c):(i=t[3],c=t[4]),y(i,c);const a=m?.error,v=m?.lastEvent;let u;return t[5]!==a||t[6]!==v?(u={error:a,lastEvent:v},t[5]=a,t[6]=v,t[7]=u):u=t[7],u}export{F as useLiveTopic};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as g}from"react/compiler-runtime";import{useQueryClient as k,useQuery as q}from"@tanstack/react-query";import{useState as v,useEffect as E}from"react";import{u as F}from"./lunora-provider-_WqSuvf9.mjs";import{u as N,f as T}from"./query-core-DRzrn3qJ.mjs";import{a as C}from"./query-key-BysXrewF.mjs";import{stableWireKey as D}from"@lunora/wire";const O=(s,K,I)=>{const e=g(26),R=I===void 0?{}:I,t=F(),u=k(),{onError:f,shardKey:o}=R,a=K==="skip",y=a?{}:K,l=D(y),r=C(s.__lunoraRef,l,o),[d,b]=v(t.isReady);let n,m;e[0]!==t||e[1]!==d?(n=()=>{d||t.whenReady().then(()=>{b(!0)})},m=[t,d],e[0]=t,e[1]=d,e[2]=n,e[3]=m):(n=e[2],m=e[3]),E(n,m);const Q=a?void 0:t.peekHydratedQueryByKey(s.__lunoraRef,l,o),h=!a&&d;let i;e[4]!==y||e[5]!==t||e[6]!==s||e[7]!==u||e[8]!==r||e[9]!==o?(i=async()=>T(t,u,s,y,o,r),e[4]=y,e[5]=t,e[6]=s,e[7]=u,e[8]=r,e[9]=o,e[10]=i):i=e[10];let c;e[11]!==Q||e[12]!==r||e[13]!==h||e[14]!==i?(c={enabled:h,initialData:Q,queryFn:i,queryKey:r,staleTime:Number.POSITIVE_INFINITY},e[11]=Q,e[12]=r,e[13]=h,e[14]=i,e[15]=c):c=e[15];const{data:S}=q(c);let p;return e[16]!==l||e[17]!==y||e[18]!==t||e[19]!==s||e[20]!==f||e[21]!==u||e[22]!==r||e[23]!==o||e[24]!==a?(p={args:y,argsKey:l,client:t,function_:s,onError:f,queryClient:u,queryKey:r,shardKey:o,skipped:a},e[16]=l,e[17]=y,e[18]=t,e[19]=s,e[20]=f,e[21]=u,e[22]=r,e[23]=o,e[24]=a,e[25]=p):p=e[25],N(p),a?void 0:S};export{O as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{c as K}from"react/compiler-runtime";import{useQueryClient as h,useSuspenseQuery as R}from"@tanstack/react-query";import{u as S}from"./lunora-provider-_WqSuvf9.mjs";import{u as I,f as g}from"./query-core-DRzrn3qJ.mjs";import{a as b}from"./query-key-BysXrewF.mjs";import{stableWireKey as k}from"@lunora/wire";const C=(s,c,m)=>{const e=K(21),Q=m===void 0?{}:m,r=S(),u=h(),{onError:n,shardKey:a}=Q,y=c,o=k(y),t=b(s.__lunoraRef,o,a),p=r.isReady?r.peekHydratedQueryByKey(s.__lunoraRef,o,a):void 0;let d;e[0]!==o||e[1]!==y||e[2]!==r||e[3]!==s||e[4]!==u||e[5]!==t||e[6]!==a?(d=async()=>(await r.whenReady(),r.peekHydratedQueryByKey(s.__lunoraRef,o,a)??g(r,u,s,y,a,t)),e[0]=o,e[1]=y,e[2]=r,e[3]=s,e[4]=u,e[5]=t,e[6]=a,e[7]=d):d=e[7];let l;e[8]!==p||e[9]!==t||e[10]!==d?(l={initialData:p,queryFn:d,queryKey:t,staleTime:Number.POSITIVE_INFINITY},e[8]=p,e[9]=t,e[10]=d,e[11]=l):l=e[11];const{data:f}=R(l);let i;return e[12]!==o||e[13]!==y||e[14]!==r||e[15]!==s||e[16]!==n||e[17]!==u||e[18]!==t||e[19]!==a?(i={args:y,argsKey:o,client:r,function_:s,onError:n,queryClient:u,queryKey:t,shardKey:a,skipped:!1},e[12]=o,e[13]=y,e[14]=r,e[15]=s,e[16]=n,e[17]=u,e[18]=t,e[19]=a,e[20]=i):i=e[20],I(i),f};export{C as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.241",
3
+ "version": "1.0.0-alpha.243",
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.228",
60
+ "@lunora/client": "1.0.0-alpha.230",
61
61
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
62
- "@lunora/ratelimit": "1.0.0-alpha.151",
62
+ "@lunora/ratelimit": "1.0.0-alpha.153",
63
63
  "@lunora/wire": "1.0.0-alpha.1",
64
64
  "@visulima/storage-client": "1.0.9"
65
65
  },
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{c as R}from"react/compiler-runtime";import{subscribeLiveTopic as S}from"@lunora/client";import{stableWireKey as T}from"@lunora/wire";import{useState as w,useRef as C,useEffect as D}from"react";const j=r=>{const e=R(16),{headers:a,maxDelayMs:f,retryDelay:v,sessionKey:E,topic:m,url:y,withCredentials:b}=r;let n;e[0]!==a||e[1]!==f||e[2]!==v||e[3]!==E||e[4]!==m||e[5]!==y||e[6]!==b?(n=T({headers:a,maxDelayMs:f,retryDelay:v,sessionKey:E,topic:m,url:y,withCredentials:b}),e[0]=a,e[1]=f,e[2]=v,e[3]=E,e[4]=m,e[5]=y,e[6]=b,e[7]=n):n=e[7];const t=n,[h,d]=w(),p=h?.key===t?h:void 0,o=C(r);let c;e[8]!==r?(c=()=>{o.current=r},e[8]=r,e[9]=c):c=e[9],D(c);let i,l;e[10]!==t?(i=()=>{const L=S({...o.current,onError:s=>{d(x=>({error:s,key:t,lastEvent:x?.key===t?x.lastEvent:void 0})),o.current.onError?.(s)},onEvent:s=>{d({error:void 0,key:t,lastEvent:s}),o.current.onEvent?.(s)}});return()=>{L(),d(void 0)}},l=[t],e[10]=t,e[11]=i,e[12]=l):(i=e[11],l=e[12]),D(i,l);const k=p?.error,K=p?.lastEvent;let u;return e[13]!==k||e[14]!==K?(u={error:k,lastEvent:K},e[13]=k,e[14]=K,e[15]=u):u=e[15],u};export{j as useLiveTopic};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{useQueryClient as E,useQuery as I}from"@tanstack/react-query";import{useRef as _,useEffect as l,useCallback as k,useState as q}from"react";import{u as $,g}from"./lunora-provider-_WqSuvf9.mjs";import{a as C}from"./query-key-BysXrewF.mjs";import{stableWireKey as D}from"@lunora/wire";const H=(t,p,h={})=>{const e=$(),n=E(),{onError:d,shardKey:s}=h,u=_(d);l(()=>{u.current=d});const m=k(o=>{u.current?.(o)},[u]),r=p==="skip",y=r?{}:p,c=D(y),a=C(t.__lunoraRef,c,s),R=`${t.__lunoraRef}\0${c}\0${s??""}`,[i,K]=q(e.isReady);l(()=>{i||e.whenReady().then(()=>{K(!0)})},[e,i]);const b=r?void 0:e.peekHydratedQueryByKey(t.__lunoraRef,c,s),{data:Q}=I({enabled:!r&&i,initialData:b,queryFn:async()=>{const o=g(e),S=o.openSnapshotSample(a),f=await e.query(t,y,{shardKey:s});return o.closeSnapshotSample(S)?f:n.getQueryData(a)??f},queryKey:a,staleTime:Number.POSITIVE_INFINITY});return l(()=>r?()=>{}:g(e).attach(n,a,t,y,s,{onError:m}),[e,n,R,r,m]),r?void 0:Q};export{H as default};