@lunora/react 1.0.0-alpha.55 → 1.0.0-alpha.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +64 -2
- package/dist/index.d.ts +64 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{cache-D_rXos5T.mjs → cache-CTiPqpnJ.mjs} +1 -1
- package/dist/packem_shared/{hydratePreloaded-CfPk_sQ5.mjs → hydratePreloaded-BPpDZCHN.mjs} +1 -1
- package/dist/packem_shared/{lunoraQueryOptions-BtQVkawu.mjs → lunoraQueryOptions-DD7WJ_yD.mjs} +1 -1
- package/dist/packem_shared/{query-key-moRe2f9b.mjs → query-key-ClQy24bz.mjs} +1 -1
- package/dist/packem_shared/stable-key-ITGZkfuz.mjs +1 -0
- package/dist/packem_shared/{use-paginated-core-K_o1A7Jq.mjs → use-paginated-core-h9Wli0Mz.mjs} +1 -1
- package/dist/packem_shared/useAction-CUSJu4yq.mjs +2 -0
- package/dist/packem_shared/{useAgent-CDYDXIho.mjs → useAgent-CS_LwSOE.mjs} +1 -1
- package/dist/packem_shared/{useAgentChat-BosdEevp.mjs → useAgentChat-DkJWSaoP.mjs} +1 -1
- package/dist/packem_shared/{useAgentState-DybEIPYC.mjs → useAgentState-IDjPrM2M.mjs} +1 -1
- package/dist/packem_shared/{useAgentToolEvents-BiKsdLnM.mjs → useAgentToolEvents-BkmO_ier.mjs} +1 -1
- package/dist/packem_shared/{useFlag-CmYP4Qo-.mjs → useFlag-D1_5nm0u.mjs} +1 -1
- package/dist/packem_shared/{useHttpStream-ByeMRVTu.mjs → useHttpStream-G6MZua0D.mjs} +1 -1
- package/dist/packem_shared/{useInfiniteQuery-TifTSFTs.mjs → useInfiniteQuery-vjMIP0oP.mjs} +1 -1
- package/dist/packem_shared/{usePaginatedQuery-4-0SLkx7.mjs → usePaginatedQuery-CmjjsHpF.mjs} +1 -1
- package/dist/packem_shared/usePresence-DsYEO_XX.mjs +2 -0
- package/dist/packem_shared/{useQuery-CBd7O0N9.mjs → useQuery-DF5z4yjg.mjs} +1 -1
- package/dist/packem_shared/{useStream-OBLaiEg1.mjs → useStream-CHFc-JdW.mjs} +1 -1
- package/dist/packem_shared/{useSubscription-BkLhTX0w.mjs → useSubscription-CgncCiE2.mjs} +1 -1
- package/dist/packem_shared/{wire-key-Cd5pGxbN.mjs → wire-key-D-_PTDGR.mjs} +1 -1
- package/dist/server.mjs +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/stable-key-BrNca3-v.mjs +0 -1
- package/dist/packem_shared/usePresence-D5NOA_TJ.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, AuthImpersonation, AuthSession, AuthUser,
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
3
|
export { type ArgsOf, 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 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";
|
|
@@ -199,6 +199,68 @@ interface UseAuthResult {
|
|
|
199
199
|
token: string | null;
|
|
200
200
|
user: User | null;
|
|
201
201
|
}
|
|
202
|
+
interface ActionHook<F extends FunctionReference> {
|
|
203
|
+
/**
|
|
204
|
+
* Invoke the action. Awaitable, and rejects on failure — the same contract
|
|
205
|
+
* as `useMutation`'s `mutate`.
|
|
206
|
+
*/
|
|
207
|
+
call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
|
|
208
|
+
/** The latest invocation's resolved value, or `undefined` before the first success. */
|
|
209
|
+
data: ReturnOf<F> | undefined;
|
|
210
|
+
/** The latest invocation's error, or `undefined`. */
|
|
211
|
+
error: Error | undefined;
|
|
212
|
+
/** `true` while ANY invocation from this hook is in flight (ref-counted, so overlapping calls compose). */
|
|
213
|
+
pending: boolean;
|
|
214
|
+
/** Clear the latest `data`/`error` back to idle. */
|
|
215
|
+
reset: () => void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns `{ call, pending, data, error, reset }` for the given action reference.
|
|
219
|
+
* Prefer destructuring at the call site so the React linter can track
|
|
220
|
+
* dependencies on each field independently.
|
|
221
|
+
*
|
|
222
|
+
* Actions were the one procedure kind with no hook: `useQuery` and `useMutation`
|
|
223
|
+
* shipped, so every app that called an action reached for `useLunora()` and
|
|
224
|
+
* re-derived the same pending/error wrapper by hand. This is that wrapper, once.
|
|
225
|
+
*
|
|
226
|
+
* The request state machine is the shared `createCallRunner` from
|
|
227
|
+
* `@lunora/client` — the same one Vue, Solid and Svelte bind to their own
|
|
228
|
+
* primitives — so `pending`, error normalization and latest-invocation ordering
|
|
229
|
+
* behave identically in every adapter. Only the `useState` cells are React's.
|
|
230
|
+
* TanStack's mutation cache still carries the call so it shows up in Query
|
|
231
|
+
* Devtools alongside `useQuery`/`useMutation`.
|
|
232
|
+
*
|
|
233
|
+
* **Lifecycle contract** (identical across the adapters): `data` and `error`
|
|
234
|
+
* both track the LATEST invocation, not the last to settle — a double-click
|
|
235
|
+
* whose first call resolves after the second cannot overwrite the second's
|
|
236
|
+
* outcome. A success clears `error`; a failure leaves the previous `data` in
|
|
237
|
+
* place, so a transient error does not blank the view. `reset()` clears both,
|
|
238
|
+
* but does NOT cancel an in-flight call, whose result still lands.
|
|
239
|
+
*
|
|
240
|
+
* **Why the two TanStack defaults are overridden.** `networkMode` is `"always"`
|
|
241
|
+
* because the default `"online"` pauses the retryer *after* the call is already
|
|
242
|
+
* marked pending: offline, the promise would never settle, the spinner would
|
|
243
|
+
* stick, and the action would silently fire minutes later on reconnect. `retry`
|
|
244
|
+
* is pinned to `0` — not inherited from an app-supplied QueryClient — because
|
|
245
|
+
* `client.action` sends no idempotency key, so a retry after a 502 on an action
|
|
246
|
+
* that already ran server-side would run it a second time. A mutation may pause
|
|
247
|
+
* and retry safely; it carries a `mutationId` and an offline queue. An action
|
|
248
|
+
* carries neither.
|
|
249
|
+
*
|
|
250
|
+
* **What it deliberately does not carry.** There is no `optimistic` /
|
|
251
|
+
* `optimisticUpdate` and no `withOptimisticUpdate`, which `useMutation` has. An
|
|
252
|
+
* optimistic update patches the subscription cache on the assumption the write
|
|
253
|
+
* will land; an action is not a write — it runs in the Worker, may call a third
|
|
254
|
+
* party, and has no declared effect on any query. Offering the option would
|
|
255
|
+
* imply a rollback guarantee nothing can honour.
|
|
256
|
+
*
|
|
257
|
+
* ```tsx
|
|
258
|
+
* const { call: runCommand, pending } = useAction(api.commands.run);
|
|
259
|
+
*
|
|
260
|
+
* await runCommand({ command: "lunora", args: ["verify"] });
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
declare const useAction: <F extends FunctionReference>(function_: F) => ActionHook<F>;
|
|
202
264
|
/** The shape every list hook in this file returns. */
|
|
203
265
|
interface AdminAuthListResult<T> {
|
|
204
266
|
/** Rows loaded so far (the full current window, not just the latest page). `undefined` before the first response. */
|
|
@@ -1272,4 +1334,4 @@ interface UseVoiceAgentResult {
|
|
|
1272
1334
|
* `createSocket`) so the hook is drivable outside a browser.
|
|
1273
1335
|
*/
|
|
1274
1336
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1275
|
-
export { type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, type RedirectTarget, type RedirectTrigger, type Subscription, 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 UseCheckoutResult, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
|
1337
|
+
export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, type RedirectTarget, type RedirectTrigger, type Subscription, 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 UseCheckoutResult, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, 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, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, AuthImpersonation, AuthSession, AuthUser,
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, AuthImpersonation, AuthSession, AuthUser, ClientQueryRef, ConnectionStatus, HttpStreamRef, HttpStreamArgsOf, HttpStreamChunkOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
3
|
export { type ArgsOf, 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 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";
|
|
@@ -199,6 +199,68 @@ interface UseAuthResult {
|
|
|
199
199
|
token: string | null;
|
|
200
200
|
user: User | null;
|
|
201
201
|
}
|
|
202
|
+
interface ActionHook<F extends FunctionReference> {
|
|
203
|
+
/**
|
|
204
|
+
* Invoke the action. Awaitable, and rejects on failure — the same contract
|
|
205
|
+
* as `useMutation`'s `mutate`.
|
|
206
|
+
*/
|
|
207
|
+
call: (args: ArgsOf<F>, options?: ActionCallOptions) => Promise<ReturnOf<F>>;
|
|
208
|
+
/** The latest invocation's resolved value, or `undefined` before the first success. */
|
|
209
|
+
data: ReturnOf<F> | undefined;
|
|
210
|
+
/** The latest invocation's error, or `undefined`. */
|
|
211
|
+
error: Error | undefined;
|
|
212
|
+
/** `true` while ANY invocation from this hook is in flight (ref-counted, so overlapping calls compose). */
|
|
213
|
+
pending: boolean;
|
|
214
|
+
/** Clear the latest `data`/`error` back to idle. */
|
|
215
|
+
reset: () => void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns `{ call, pending, data, error, reset }` for the given action reference.
|
|
219
|
+
* Prefer destructuring at the call site so the React linter can track
|
|
220
|
+
* dependencies on each field independently.
|
|
221
|
+
*
|
|
222
|
+
* Actions were the one procedure kind with no hook: `useQuery` and `useMutation`
|
|
223
|
+
* shipped, so every app that called an action reached for `useLunora()` and
|
|
224
|
+
* re-derived the same pending/error wrapper by hand. This is that wrapper, once.
|
|
225
|
+
*
|
|
226
|
+
* The request state machine is the shared `createCallRunner` from
|
|
227
|
+
* `@lunora/client` — the same one Vue, Solid and Svelte bind to their own
|
|
228
|
+
* primitives — so `pending`, error normalization and latest-invocation ordering
|
|
229
|
+
* behave identically in every adapter. Only the `useState` cells are React's.
|
|
230
|
+
* TanStack's mutation cache still carries the call so it shows up in Query
|
|
231
|
+
* Devtools alongside `useQuery`/`useMutation`.
|
|
232
|
+
*
|
|
233
|
+
* **Lifecycle contract** (identical across the adapters): `data` and `error`
|
|
234
|
+
* both track the LATEST invocation, not the last to settle — a double-click
|
|
235
|
+
* whose first call resolves after the second cannot overwrite the second's
|
|
236
|
+
* outcome. A success clears `error`; a failure leaves the previous `data` in
|
|
237
|
+
* place, so a transient error does not blank the view. `reset()` clears both,
|
|
238
|
+
* but does NOT cancel an in-flight call, whose result still lands.
|
|
239
|
+
*
|
|
240
|
+
* **Why the two TanStack defaults are overridden.** `networkMode` is `"always"`
|
|
241
|
+
* because the default `"online"` pauses the retryer *after* the call is already
|
|
242
|
+
* marked pending: offline, the promise would never settle, the spinner would
|
|
243
|
+
* stick, and the action would silently fire minutes later on reconnect. `retry`
|
|
244
|
+
* is pinned to `0` — not inherited from an app-supplied QueryClient — because
|
|
245
|
+
* `client.action` sends no idempotency key, so a retry after a 502 on an action
|
|
246
|
+
* that already ran server-side would run it a second time. A mutation may pause
|
|
247
|
+
* and retry safely; it carries a `mutationId` and an offline queue. An action
|
|
248
|
+
* carries neither.
|
|
249
|
+
*
|
|
250
|
+
* **What it deliberately does not carry.** There is no `optimistic` /
|
|
251
|
+
* `optimisticUpdate` and no `withOptimisticUpdate`, which `useMutation` has. An
|
|
252
|
+
* optimistic update patches the subscription cache on the assumption the write
|
|
253
|
+
* will land; an action is not a write — it runs in the Worker, may call a third
|
|
254
|
+
* party, and has no declared effect on any query. Offering the option would
|
|
255
|
+
* imply a rollback guarantee nothing can honour.
|
|
256
|
+
*
|
|
257
|
+
* ```tsx
|
|
258
|
+
* const { call: runCommand, pending } = useAction(api.commands.run);
|
|
259
|
+
*
|
|
260
|
+
* await runCommand({ command: "lunora", args: ["verify"] });
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
declare const useAction: <F extends FunctionReference>(function_: F) => ActionHook<F>;
|
|
202
264
|
/** The shape every list hook in this file returns. */
|
|
203
265
|
interface AdminAuthListResult<T> {
|
|
204
266
|
/** Rows loaded so far (the full current window, not just the latest page). `undefined` before the first response. */
|
|
@@ -1272,4 +1334,4 @@ interface UseVoiceAgentResult {
|
|
|
1272
1334
|
* `createSocket`) so the hook is drivable outside a browser.
|
|
1273
1335
|
*/
|
|
1274
1336
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1275
|
-
export { type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, type RedirectTarget, type RedirectTrigger, type Subscription, 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 UseCheckoutResult, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
|
1337
|
+
export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, type RedirectTarget, type RedirectTrigger, type Subscription, 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 UseCheckoutResult, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, 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, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{AuthLoading as
|
|
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{CheckoutButton as i,CustomerPortalButton as d,useCheckout as x}from"./packem_shared/CheckoutButton-D8MutXhg.mjs";import{lunoraQueryOptions as h}from"./packem_shared/lunoraQueryOptions-DD7WJ_yD.mjs";import{useAction as c}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as C,useAuthUsers as U,useImpersonate as y,useOrganizations as E}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as Q}from"./packem_shared/useAgent-CS_LwSOE.mjs";import{useAgentChat as L}from"./packem_shared/useAgentChat-DkJWSaoP.mjs";import{useAgentState as F}from"./packem_shared/useAgentState-IDjPrM2M.mjs";import{useAgentToolEvents as k}from"./packem_shared/useAgentToolEvents-BkmO_ier.mjs";import{default as b}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as z}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as O}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as H,useFlags as V}from"./packem_shared/useFlag-D1_5nm0u.mjs";import{useHttpStream as q}from"./packem_shared/useHttpStream-G6MZua0D.mjs";import{default as D}from"./packem_shared/useInfiniteQuery-vjMIP0oP.mjs";import{useMutation as J}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as N}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as X}from"./packem_shared/usePaginatedQuery-CmjjsHpF.mjs";import{hydratePreloaded as Z,default as _}from"./packem_shared/hydratePreloaded-BPpDZCHN.mjs";import{usePresence as ee}from"./packem_shared/usePresence-DsYEO_XX.mjs";import{default as oe}from"./packem_shared/useQuery-DF5z4yjg.mjs";import{useRateLimit as ue}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as ae}from"./packem_shared/useStream-CHFc-JdW.mjs";import{default as fe}from"./packem_shared/useSubscription-CgncCiE2.mjs";import{useVoiceAgent as me}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as de,getErrorCode as xe,getRetryAfterMs as le,isConflictError as he,isForbiddenError as Ae,isRateLimitedError as ce,isUnauthorizedError as ge}from"@lunora/client";import{RestrictionError as Ue,UploadControl as ye,UploadError as Ee}from"@visulima/storage-client";import{useChunkedRestUpload as Qe,useFileInput as Se,useMultipartUpload as Le,usePasteUpload as Re,useTusUpload as Fe,useUpload as Me}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,i as CheckoutButton,d as CustomerPortalButton,f as LunoraProvider,Ue as RestrictionError,u as Unauthenticated,ye as UploadControl,Ee as UploadError,de as createClientQuery,xe as getErrorCode,le as getRetryAfterMs,Z as hydratePreloaded,he as isConflictError,Ae as isForbiddenError,ce as isRateLimitedError,ge as isUnauthorizedError,h as lunoraQueryOptions,c as useAction,Q as useAgent,L as useAgentChat,F as useAgentState,k as useAgentToolEvents,b as useAuth,C as useAuthSessions,a as useAuthState,U as useAuthUsers,x as useCheckout,Qe as useChunkedRestUpload,z as useClientQuery,O as useConnectionStatus,Se as useFileInput,H as useFlag,V as useFlags,q as useHttpStream,y as useImpersonate,D as useInfiniteQuery,n as useLunora,Le as useMultipartUpload,J as useMutation,N as useMutator,E as useOrganizations,X as usePaginatedQuery,Re as usePasteUpload,_ as usePreloadedQuery,ee as usePresence,oe as useQuery,ue as useRateLimit,ae as useStream,fe as useSubscription,Fe as useTusUpload,Me as useUpload,me as useVoiceAgent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as a}from"./query-key-
|
|
1
|
+
import{k as a}from"./query-key-ClQy24bz.mjs";class p{constructor(e){this.client=e}client;entries=new Map;keyOf(e){return a(e)}attach(e,n,l,u,f,h={}){const i=a(n);let r=this.entries.get(i);if(!r){r={pollTimer:void 0,refCount:0,unsubscribe:void 0},this.entries.set(i,r);try{r.unsubscribe=this.client.subscribe(l,u,t=>{e.setQueryData(n,t)},{shardKey:f})}catch{r.pollTimer=setInterval(()=>{e.invalidateQueries({queryKey:n}).catch(()=>{})},h.pollIntervalMs??5e3)}}r.refCount+=1;let o=!1;return()=>{if(o)return;o=!0;const t=this.entries.get(i);t&&(t.refCount-=1,t.refCount<=0&&(t.unsubscribe?.(),t.pollTimer&&clearInterval(t.pollTimer),this.entries.delete(i)))}}}const c=new WeakMap,g=s=>{let e=c.get(s);return e||(e=new p(s),c.set(s,e)),e};export{g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-CTiPqpnJ.mjs";import{useLunora as Q}from"./LunoraProvider-DC06S-p1.mjs";import{l as h,s as q}from"./query-key-ClQy24bz.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};
|
package/dist/packem_shared/{lunoraQueryOptions-BtQVkawu.mjs → lunoraQueryOptions-DD7WJ_yD.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as u}from"./query-key-
|
|
1
|
+
import{l as u}from"./query-key-ClQy24bz.mjs";const t=(a,r,s,e={})=>{const y=s??{};return{queryFn:()=>a.query(r,y,{shardKey:e.shardKey}),queryKey:u(r,y,e.shardKey),staleTime:Number.POSITIVE_INFINITY}};export{t as lunoraQueryOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as r}from"./wire-key-
|
|
1
|
+
import{s as r}from"./wire-key-D-_PTDGR.mjs";const o=e=>r(e),n=(e,s,a)=>["lunora",e.__lunoraRef,s,a??null],t=e=>o(e);export{o as k,n as l,t as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const f=(t,n)=>t<n?-1:t>n?1:0,s=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(r=>s(r)).join(",")}]`;const n=Object.getPrototypeOf(t);if(n!==null&&n!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const i=t,y=Object.keys(i).toSorted(f),e=[];for(const r of y){const o=i[r];o!==void 0&&e.push(`${JSON.stringify(r)}:${s(o)}`)}return`{${e.join(",")}}`};export{s};
|
package/dist/packem_shared/{use-paginated-core-K_o1A7Jq.mjs → use-paginated-core-h9Wli0Mz.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-CTiPqpnJ.mjs";import{useLunora as N}from"./LunoraProvider-DC06S-p1.mjs";import{s as i,l as q}from"./query-key-ClQy24bz.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as R}from"react/compiler-runtime";import{createCallRunner as k}from"@lunora/client";import{useMutation as x}from"@tanstack/react-query";import{useState as n}from"react";import{useLunora as C}from"./LunoraProvider-DC06S-p1.mjs";const S=a=>{const t=R(12),i=C(),[c,g]=n(void 0),[l,m]=n(void 0),[u,M]=n(!1);let o;t[0]!==i||t[1]!==a?(o={mutationFn:async e=>{const{args:y,options:A}=e;return i.action(a,y,A)},networkMode:"always",retry:0},t[0]=i,t[1]=a,t[2]=o):o=t[2];const{mutateAsync:d,reset:p}=x(o);let s;t[3]!==d||t[4]!==p?(s=()=>({call:k(async(e,y)=>d({args:e,options:y}),{setError:m,setPending:M,setResult:e=>{g(()=>e),m(void 0)}}),reset:()=>{g(void 0),m(void 0),p()}}),t[3]=d,t[4]=p,t[5]=s):s=t[5];const[w]=n(s),{call:f,reset:v}=w;let r;return t[6]!==f||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==v?(r={call:f,data:c,error:l,pending:u,reset:v},t[6]=f,t[7]=c,t[8]=l,t[9]=u,t[10]=v,t[11]=r):r=t[11],r};export{S as useAction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as v}from"react/compiler-runtime";import{useMutation as M}from"./useMutation-BnKec7bE.mjs";import w from"./useSubscription-
|
|
2
|
+
import{c as v}from"react/compiler-runtime";import{useMutation as M}from"./useMutation-BnKec7bE.mjs";import w from"./useSubscription-CgncCiE2.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 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as H,maxSeq as J}from"@lunora/client";import{useState as ct,useRef as it}from"react";import{useMutation as Y}from"./useMutation-BnKec7bE.mjs";import{useStream as lt}from"./useStream-
|
|
2
|
+
import{c as rt}from"react/compiler-runtime";import{reconcileOptimistic as H,maxSeq as J}from"@lunora/client";import{useState as ct,useRef as it}from"react";import{useMutation as Y}from"./useMutation-BnKec7bE.mjs";import{useStream as lt}from"./useStream-CHFc-JdW.mjs";import L from"./useSubscription-CgncCiE2.mjs";const ut={__lunoraRef:""},mt={__lunoraRef:""},ft=[],St=i=>{const t=rt(47),{api:E,cancel:u,limit:m,send:Q,sendArgs:b,stream:f,threadKey:e}=i;let d;t[0]!==m||t[1]!==e?(d=m===void 0?{key:e}:{key:e,limit:m},t[0]=m,t[1]=e,t[2]=d):d=t[2];const V=d,{data:W}=L(E.agents.agentMessages,V);let p;t[3]!==e?(p={key:e},t[3]=e,t[4]=p):p=t[4];const{data:X}=L(E.agents.agentThread,p);let g;t[5]!==f||t[6]!==e?(g=f===void 0?"skip":{key:e},t[5]=f,t[6]=e,t[7]=g):g=t[7];const Z=g,{chunks:w}=lt(f??mt,Z),tt=Y(Q),et=Y(u??ut),st=Y(E.agents.agentResolveApproval);let h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=[],t[8]=h):h=t[8];const[O,z]=ct(h),T=it(0),B=X,I=B?.status,a=B?.instanceId,n=W??ft;let _;if(t[9]!==n||t[10]!==O){const s=H(O,n),o=J(n);_=s.length===0?n:[...n,...s.map((r,P)=>({content:r.content,optimistic:!0,role:"user",seq:o+1+P}))],t[9]=n,t[10]=O,t[11]=_}else _=t[11];const q=_;let v;t[12]!==n?(v=n.filter(dt),t[12]=n,t[13]=v):v=t[13];const l=v.length;let y;if(t[14]!==l||t[15]!==w||t[16]!==e){let s;t[18]!==l||t[19]!==e?(s=o=>o.kind!=="progress"&&o.threadKey===e&&o.turn>=l,t[18]=l,t[19]=e,t[20]=s):s=t[20],y=w.filter(s).map(pt).join(""),t[14]=l,t[15]=w,t[16]=e,t[17]=y}else y=t[17];const j=y,{mutate:C}=tt,{mutate:D}=et,{mutate:N}=st;let M;t[21]!==n||t[22]!==b||t[23]!==C||t[24]!==e?(M=async(s,o)=>{const r=T.current;T.current=T.current+1;const P=J(n);z(U=>[...H(U,n),{content:s,id:r,maxDurableSeqAtSend:P}]);try{await C({input:s,threadKey:e,...b,...o})}catch(U){const nt=U;throw z(ot=>ot.filter(at=>at.id!==r)),nt}},t[21]=n,t[22]=b,t[23]=C,t[24]=e,t[25]=M):M=t[25];const F=M;let S;t[26]!==a||t[27]!==N||t[28]!==e?(S=async(s,o,r)=>{if(a===void 0)throw new Error(`useAgentChat: cannot ${s} — no in-flight run (thread has no instanceId)`);await N({decision:s,instanceId:a,threadKey:e,toolCallId:o,...r===void 0?{}:{note:r}})},t[26]=a,t[27]=N,t[28]=e,t[29]=S):S=t[29];const c=S;let R;t[30]!==c?(R=(s,o)=>c("approve",s,o),t[30]=c,t[31]=R):R=t[31];const K=R;let A;t[32]!==c?(A=(s,o)=>c("reject",s,o),t[32]=c,t[33]=A):A=t[33];const $=A;let k;t[34]!==D||t[35]!==u||t[36]!==a||t[37]!==e?(k=async()=>{u===void 0||a===void 0||await D({instanceId:a,threadKey:e})},t[34]=D,t[35]=u,t[36]=a,t[37]=e,t[38]=k):k=t[38];const G=k;let x;return t[39]!==K||t[40]!==G||t[41]!==q||t[42]!==$||t[43]!==F||t[44]!==I||t[45]!==j?(x={approve:K,cancel:G,messages:q,reject:$,send:F,status:I,streamingText:j},t[39]=K,t[40]=G,t[41]=q,t[42]=$,t[43]=F,t[44]=I,t[45]=j,t[46]=x):x=t[46],x};function dt(i){return i.role==="assistant"}function pt(i){return i.text}export{St 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-CgncCiE2.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-BiKsdLnM.mjs → useAgentToolEvents-BkmO_ier.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-
|
|
2
|
+
import{c as y}from"react/compiler-runtime";import{useStream as I}from"./useStream-CHFc-JdW.mjs";import N from"./useSubscription-CgncCiE2.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useState as v,useRef as d,useEffect as m}from"react";import{useLunora as K}from"./LunoraProvider-DC06S-p1.mjs";import{s as g}from"./stable-key-
|
|
2
|
+
import{useState as v,useRef as d,useEffect as m}from"react";import{useLunora as K}from"./LunoraProvider-DC06S-p1.mjs";import{s as g}from"./stable-key-ITGZkfuz.mjs";const h="__lunora_flags__:eval",R=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},$={__lunoraRef:h},S=(t,e,r)=>{const p=K(),[i,s]=v(e),c=R(e),o=r===void 0?"":g(r),u=`${t}::${c}::${o}`,l=d(u);l.current!==u&&(l.current=u,s(e));const a=d({context:r,defaultValue:e});return m(()=>{a.current={context:r,defaultValue:e}}),m(()=>{let f=!1;const{context:y,defaultValue:b}=a.current;s(b);let n;try{n=p.subscribe($,{context:y,default:b,key:t,type:c},_=>{f||s(_)})}catch{return()=>{f=!0}}return()=>{f=!0,n()}},[p,t,c,o]),i},j=(t,e)=>{const r=K(),[p,i]=v(t),s=g(t),c=e===void 0?"":g(e),o=`${s}::${c}`,u=d(o);u.current!==o&&(u.current=o,i(t));const l=d({context:e,flags:t});return m(()=>{l.current={context:e,flags:t}}),m(()=>{let a=!1;const{context:f,flags:y}=l.current;i(y);const b=[];for(const[n,_]of Object.entries(y))try{b.push(r.subscribe($,{context:f,default:_,key:n,type:R(_)},C=>{a||i(F=>({...F,[n]:C}))}))}catch{}return()=>{a=!0;for(const n of b)n()}},[r,s,c]),p};export{S as useFlag,j as useFlags};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{useLunora as b}from"./LunoraProvider-DC06S-p1.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./stable-key-
|
|
2
|
+
import{c as S}from"react/compiler-runtime";import{useReducer as _,useRef as v,useEffect as R}from"react";import{useLunora as b}from"./LunoraProvider-DC06S-p1.mjs";import{s as z,c as E}from"./stream-state-abygFxmy.mjs";import{s as H}from"./stable-key-ITGZkfuz.mjs";const C=(t,c,o)=>{const e=S(24);let m;e[0]!==o?(m=o===void 0?{}:o,e[0]=o,e[1]=m):m=e[1];const f=m,n=b();let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={chunks:[],error:void 0,status:"idle"},e[2]=i):i=e[2];const[s,a]=_(z,i),r=c==="skip";let l;e[3]!==c||e[4]!==r?(l=r?"skip":H(c),e[3]=c,e[4]=r,e[5]=l):l=e[5];const k=l,x=v(void 0);let u;e[6]!==c||e[7]!==n||e[8]!==f.maxBuffer||e[9]!==t||e[10]!==r?(u=()=>{if(r)return a({type:"reset"}),L;a({type:"reset"}),a({type:"start"});const{cancel:B,cleanup:y}=E(n.httpStream(t,c,{maxBuffer:f.maxBuffer}),a);return x.current=B,()=>{y(),x.current=void 0}},e[6]=c,e[7]=n,e[8]=f.maxBuffer,e[9]=t,e[10]=r,e[11]=u):u=e[11];let p;e[12]!==n||e[13]!==f.maxBuffer||e[14]!==t.method||e[15]!==t.path||e[16]!==k||e[17]!==r?(p=[n,t.method,t.path,k,r,f.maxBuffer],e[12]=n,e[13]=f.maxBuffer,e[14]=t.method,e[15]=t.path,e[16]=k,e[17]=r,e[18]=p):p=e[18],R(u,p);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{x.current?.()},e[19]=h):h=e[19];let d;return e[20]!==s.chunks||e[21]!==s.error||e[22]!==s.status?(d={cancel:h,chunks:s.chunks,error:s.error,status:s.status},e[20]=s.chunks,e[21]=s.error,e[22]=s.status,e[23]=d):d=e[23],d};function L(){}export{C as useHttpStream};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-h9Wli0Mz.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};
|
package/dist/packem_shared/{usePaginatedQuery-4-0SLkx7.mjs → usePaginatedQuery-CmjjsHpF.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as l}from"react/compiler-runtime";import{u as c}from"./use-paginated-core-
|
|
2
|
+
import{c as l}from"react/compiler-runtime";import{u as c}from"./use-paginated-core-h9Wli0Mz.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as R}from"react/compiler-runtime";import{useQueryClient as q,useQuery as K}from"@tanstack/react-query";import{useState as b,useEffect as f}from"react";import{g as k}from"./cache-
|
|
2
|
+
import{c as R}from"react/compiler-runtime";import{useQueryClient as q,useQuery as K}from"@tanstack/react-query";import{useState as b,useEffect as f}from"react";import{g as k}from"./cache-CTiPqpnJ.mjs";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{l as N,s as S}from"./query-key-ClQy24bz.mjs";const x=(o,m,p)=>{const e=R(9),Q=p===void 0?{}:p,t=v(),a=q(),{shardKey:i}=Q,r=m==="skip",n=r?{}:m,d=N(o,n,i),[s,h]=b(t.isReady);let u,y;e[0]!==t||e[1]!==s?(u=()=>{s||t.whenReady().then(()=>{h(!0)})},y=[t,s],e[0]=t,e[1]=s,e[2]=u,e[3]=y):(u=e[2],y=e[3]),f(u,y);const g=r?void 0:t.peekHydratedQuery(o.__lunoraRef,n,i),{data:I}=K({enabled:!r&&s,initialData:g,queryFn:()=>t.query(o,n,{shardKey:i}),queryKey:d,staleTime:Number.POSITIVE_INFINITY}),l=S(d);let c;return e[4]!==t||e[5]!==a||e[6]!==r||e[7]!==l?(c=[t,a,l,r],e[4]=t,e[5]=a,e[6]=r,e[7]=l,e[8]=c):c=e[8],f(()=>r?T:k(t).attach(a,d,o,n,i),c),r?void 0:I};function T(){}export{x as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./wire-key-
|
|
2
|
+
import{c as K}from"react/compiler-runtime";import{useReducer as B,useRef as R,useEffect as _}from"react";import{useLunora as v}from"./LunoraProvider-DC06S-p1.mjs";import{s as S,c as z}from"./stream-state-abygFxmy.mjs";import{s as E}from"./wire-key-D-_PTDGR.mjs";const A=(u,a,l)=>{const e=K(27);let c;e[0]!==l?(c=l===void 0?{}:l,e[0]=l,e[1]=c):c=e[1];const r=c,o=v();let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={chunks:[],error:void 0,status:"idle"},e[2]=f):f=e[2];const[t,m]=B(S,f),s=a==="skip";let n;e[3]!==a||e[4]!==s?(n=s?"skip":E(a),e[3]=a,e[4]=s,e[5]=n):n=e[5];const y=n,b=R(void 0);let i;e[6]!==a||e[7]!==o||e[8]!==u||e[9]!==r.durable||e[10]!==r.maxBuffer||e[11]!==r.shardKey||e[12]!==s?(i=()=>{if(s)return m({type:"reset"}),L;m({type:"reset"}),m({type:"start"});const{cancel:k,cleanup:x}=z(o.stream(u,a,{durable:r.durable,maxBuffer:r.maxBuffer,shardKey:r.shardKey}),m);return b.current=k,()=>{x(),b.current=void 0}},e[6]=a,e[7]=o,e[8]=u,e[9]=r.durable,e[10]=r.maxBuffer,e[11]=r.shardKey,e[12]=s,e[13]=i):i=e[13];let d;e[14]!==o||e[15]!==u.__lunoraRef||e[16]!==r.durable||e[17]!==r.maxBuffer||e[18]!==r.shardKey||e[19]!==y||e[20]!==s?(d=[o,u.__lunoraRef,y,s,r.shardKey,r.maxBuffer,r.durable],e[14]=o,e[15]=u.__lunoraRef,e[16]=r.durable,e[17]=r.maxBuffer,e[18]=r.shardKey,e[19]=y,e[20]=s,e[21]=d):d=e[21],_(i,d);let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b.current?.()},e[22]=p):p=e[22];let h;return e[23]!==t.chunks||e[24]!==t.error||e[25]!==t.status?(h={cancel:p,chunks:t.chunks,error:t.error,status:t.status},e[23]=t.chunks,e[24]=t.error,e[25]=t.status,e[26]=h):h=e[26],h};function L(){}export{A as useStream};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
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-D-_PTDGR.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as d}from"./stable-key-
|
|
1
|
+
import{s as d}from"./stable-key-ITGZkfuz.mjs";const u=r=>{let t="";for(let c=0;c<r.length;c+=32768)t+=String.fromCharCode(...r.subarray(c,c+32768));return btoa(t)},e="$lunora.wire$",b=64,m="__proto__",p=r=>{if(r===null||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);return t===null||t===Object.prototype},i=(r,t=0)=>{if(t>b)throw new RangeError(`wire-codec: value nesting exceeds the ${b}-level limit`);if(r===void 0)return[e,"undefined"];if(r===null)return null;const f=typeof r;if(f==="bigint")return[e,"bigint",r.toString()];if(f==="number"){const n=r;return Number.isNaN(n)?[e,"nan"]:n===1/0?[e,"inf"]:n===-1/0?[e,"-inf"]:n}if(f!=="object")return r;if(r instanceof Date)return[e,"date",i(r.getTime(),t+1)];if(r instanceof Error){const n=r,o={};for(const y of Object.keys(n))n[y]!==void 0&&(o[y]=i(n[y],t+1));const s=[e,"error",n.name,n.message,o];return n.cause!==void 0&&s.push(i(n.cause,t+1)),s}if(r instanceof URL)return[e,"url",r.href];if(r instanceof Map)return[e,"map",[...r.entries()].map(([n,o])=>[i(n,t+1),i(o,t+1)])];if(r instanceof Set)return[e,"set",[...r].map(n=>i(n,t+1))];if(r instanceof ArrayBuffer)return[e,"bytes",u(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const n=r,o=n.constructor.name,s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return o==="Uint8Array"?[e,"bytes",u(s)]:[e,"bytes",u(s),o]}if(Array.isArray(r)){const n=r.map(o=>i(o,t+1));return n.length>0&&n[0]===e?[e,"arr",n]:n}if(!p(r)){const n=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${n} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const c=r,a={};for(const n of Object.keys(c)){const o=c[n];if(o===void 0)continue;const s=i(o,t+1);n===m?Object.defineProperty(a,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):a[n]=s}return a},w=r=>d(i(r));export{w as s};
|
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{l as d}from"./packem_shared/query-key-
|
|
1
|
+
import{createServerClient as o}from"@lunora/client/ssr";import{createServerClient as K,deserializePreloaded as f,getServerSession as Q,serializePreloaded as x}from"@lunora/client/ssr";import{l as d}from"./packem_shared/query-key-ClQy24bz.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-DD7WJ_yD.mjs";import{preloadQuery as v,preloadedQueryResult as N}from"@lunora/client";import{HydrationBoundary as T,dehydrate as g}from"@tanstack/react-query";const u=async(r,a,e,t,y={})=>{const s=t??{};await r.prefetchQuery({queryFn:()=>a.query(e,s,{shardKey:y.shardKey}),queryKey:d(e,s,y.shardKey),staleTime:Number.POSITIVE_INFINITY})},h=async(r,a,e,t={})=>o(r).query(a,e,{shardKey:t.shardKey}),i=async(r,a,e,t={})=>o(r).mutation(a,e,{shardKey:t.shardKey}),l=async(r,a,e,t={})=>o(r).action(a,e,{shardKey:t.shardKey});export{T as HydrationBoundary,K as createServerClient,g as dehydrate,f as deserializePreloaded,l as fetchAction,i as fetchMutation,h as fetchQuery,Q as getServerSession,S as lunoraQueryOptions,u as prefetchQuery,v as preloadQuery,N as preloadedQueryResult,x as serializePreloaded};
|
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.57",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lunora/client": "1.0.0-alpha.
|
|
56
|
+
"@lunora/client": "1.0.0-alpha.53",
|
|
57
57
|
"@lunora/errors": "1.0.0-alpha.22",
|
|
58
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
58
|
+
"@lunora/ratelimit": "1.0.0-alpha.24",
|
|
59
59
|
"@visulima/storage-client": "1.0.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const c=(t,e)=>t<e?-1:t>e?1:0,s=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(r=>s(r)).join(",")}]`;const e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const n=t,a=Object.keys(n).toSorted(c),o=[];for(const r of a){const i=n[r];i!==void 0&&o.push(`${JSON.stringify(r)}:${s(i)}`)}return`{${o.join(",")}}`};export{s};
|
|
@@ -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=(e="sess")=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const s=crypto.getRandomValues(new Uint8Array(16));return`${e}-${Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}`}}return`${e}-${Date.now().toString(36)}`},A=1e4,$=(e,s)=>{const n=E(),{heartbeat:f,intervalMs:l=A,listPresent:y,shardKey:r}=s,c=U(()=>s.sessionId??L(),[s.sessionId]),[v,I]=D(void 0),d=b(s.data),m=b({client:n,heartbeat:f,roomId:e,sessionId:c,shardKey:r});a(()=>{m.current={client:n,heartbeat:f,roomId:e,sessionId:c,shardKey:r}});const o=p(()=>{const{client:t,heartbeat:i,roomId:u,sessionId:g,shardKey:S}=m.current,R={roomId:u,sessionId:g,...d.current===void 0?{}:{data:d.current}};t.mutation(i,R,{shardKey:S}).catch(()=>{})},[]),h=p(t=>{d.current=t,o()},[o]);return a(()=>{o();const t=setInterval(o,l),i=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),()=>{clearInterval(t),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}},[o,l]),a(()=>n.acquireConnectionContext({roomId:e,sessionId:c},{shardKey:r}),[n,e,c,r]),a(()=>{let t=!1;const i=n.subscribe(y,{roomId:e},u=>{t||I(u)},{shardKey:r});return()=>{t=!0,i()}},[n,y.__lunoraRef,e,r]),{present:v,sessionId:c,setData:h}};export{$ as usePresence};
|