@lunora/react 1.0.0-alpha.25 → 1.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ConnectionStatus, ReturnOf, ArgsOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
|
-
export { type ArgsOf, type FunctionReference, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type User, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ClientQueryRef, ConnectionStatus, ReturnOf, ArgsOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
|
+
export { type ArgsOf, type ClientQueryRef, type FunctionReference, 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-D4okOpO8.mjs";
|
|
6
6
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
@@ -615,6 +615,31 @@ declare const useAgentToolEvents: (options: UseAgentToolEventsOptions) => UseAge
|
|
|
615
615
|
* hook with the freshly-resolved user.
|
|
616
616
|
*/
|
|
617
617
|
declare const useAuth: () => UseAuthResult;
|
|
618
|
+
type Setter<T> = (value: T) => void;
|
|
619
|
+
/**
|
|
620
|
+
* Subscribe to a local-only {@link ClientQueryRef} and re-render when its
|
|
621
|
+
* value changes. Unlike `useQuery`, this never touches the network — the
|
|
622
|
+
* value lives in a reactive store on the `LunoraClient` instance and is shared
|
|
623
|
+
* across every consumer of the same ref.
|
|
624
|
+
*
|
|
625
|
+
* The initial render reads the store synchronously (via
|
|
626
|
+
* `useSyncExternalStore`), so there is never an "undefined flash" — the value
|
|
627
|
+
* is either the one most recently set or `ref.defaultValue`.
|
|
628
|
+
*
|
|
629
|
+
* Returns a `[value, setter]` tuple, matching the `useState` convention.
|
|
630
|
+
* @example
|
|
631
|
+
* ```tsx
|
|
632
|
+
* import { useClientQuery, createClientQuery } from "@lunora/react";
|
|
633
|
+
*
|
|
634
|
+
* const sidebarOpen = createClientQuery("sidebarOpen", true);
|
|
635
|
+
*
|
|
636
|
+
* function Sidebar() {
|
|
637
|
+
* const [open, setOpen] = useClientQuery(sidebarOpen);
|
|
638
|
+
* return <aside data-open={open}>…</aside>;
|
|
639
|
+
* }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
declare const useClientQuery: <T extends unknown>(ref: ClientQueryRef<T>) => [T, Setter<T>];
|
|
618
643
|
/**
|
|
619
644
|
* Reactive view of the client's aggregate live-socket status across all shard
|
|
620
645
|
* connections. Re-renders on every transition (`idle` → `connecting` →
|
|
@@ -871,6 +896,12 @@ declare const usePresence: <H extends HeartbeatReference, L extends ListPresentR
|
|
|
871
896
|
* Returns `undefined` until the first response lands. Pass `"skip"` for
|
|
872
897
|
* `args` to short-circuit the query (no network call, no subscription).
|
|
873
898
|
*
|
|
899
|
+
* When the `LunoraClient` was created with `hydrateOnStart: true` and a
|
|
900
|
+
* `queryCache` adapter, the first **enabled** render waits for the durable
|
|
901
|
+
* read cache to finish loading. If a cached value exists for this query it
|
|
902
|
+
* is fed as `initialData` so the user sees it immediately — no undefined
|
|
903
|
+
* flash before the socket round-trip.
|
|
904
|
+
*
|
|
874
905
|
* Internally this routes through TanStack Query: the queryKey is
|
|
875
906
|
* `["lunora", fn.__lunoraRef, args, shardKey]` (TanStack hashes structurally
|
|
876
907
|
* so an args object built in a different key order still dedupes). The
|
|
@@ -1089,4 +1120,4 @@ interface UseVoiceAgentResult {
|
|
|
1089
1120
|
* `createSocket`) so the hook is drivable outside a browser.
|
|
1090
1121
|
*/
|
|
1091
1122
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1092
|
-
export { 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 UseCheckoutResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, 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, useAuthState, useCheckout, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
|
1123
|
+
export { 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 UseCheckoutResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, 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, useAuthState, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ConnectionStatus, ReturnOf, ArgsOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
|
-
export { type ArgsOf, type FunctionReference, type LunoraClient, type LunoraErrorCode, type MutatorHandle, type MutatorTransaction, type OptimisticLocalStore, type OptimisticUpdate, type Preloaded, type ReturnOf, type User, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
2
|
+
import { LunoraClient, OptimisticUpdate, User, FunctionReference, ClientQueryRef, ConnectionStatus, ReturnOf, ArgsOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
3
|
+
export { type ArgsOf, type ClientQueryRef, type FunctionReference, 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-D4okOpO8.js";
|
|
6
6
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
@@ -615,6 +615,31 @@ declare const useAgentToolEvents: (options: UseAgentToolEventsOptions) => UseAge
|
|
|
615
615
|
* hook with the freshly-resolved user.
|
|
616
616
|
*/
|
|
617
617
|
declare const useAuth: () => UseAuthResult;
|
|
618
|
+
type Setter<T> = (value: T) => void;
|
|
619
|
+
/**
|
|
620
|
+
* Subscribe to a local-only {@link ClientQueryRef} and re-render when its
|
|
621
|
+
* value changes. Unlike `useQuery`, this never touches the network — the
|
|
622
|
+
* value lives in a reactive store on the `LunoraClient` instance and is shared
|
|
623
|
+
* across every consumer of the same ref.
|
|
624
|
+
*
|
|
625
|
+
* The initial render reads the store synchronously (via
|
|
626
|
+
* `useSyncExternalStore`), so there is never an "undefined flash" — the value
|
|
627
|
+
* is either the one most recently set or `ref.defaultValue`.
|
|
628
|
+
*
|
|
629
|
+
* Returns a `[value, setter]` tuple, matching the `useState` convention.
|
|
630
|
+
* @example
|
|
631
|
+
* ```tsx
|
|
632
|
+
* import { useClientQuery, createClientQuery } from "@lunora/react";
|
|
633
|
+
*
|
|
634
|
+
* const sidebarOpen = createClientQuery("sidebarOpen", true);
|
|
635
|
+
*
|
|
636
|
+
* function Sidebar() {
|
|
637
|
+
* const [open, setOpen] = useClientQuery(sidebarOpen);
|
|
638
|
+
* return <aside data-open={open}>…</aside>;
|
|
639
|
+
* }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
declare const useClientQuery: <T extends unknown>(ref: ClientQueryRef<T>) => [T, Setter<T>];
|
|
618
643
|
/**
|
|
619
644
|
* Reactive view of the client's aggregate live-socket status across all shard
|
|
620
645
|
* connections. Re-renders on every transition (`idle` → `connecting` →
|
|
@@ -871,6 +896,12 @@ declare const usePresence: <H extends HeartbeatReference, L extends ListPresentR
|
|
|
871
896
|
* Returns `undefined` until the first response lands. Pass `"skip"` for
|
|
872
897
|
* `args` to short-circuit the query (no network call, no subscription).
|
|
873
898
|
*
|
|
899
|
+
* When the `LunoraClient` was created with `hydrateOnStart: true` and a
|
|
900
|
+
* `queryCache` adapter, the first **enabled** render waits for the durable
|
|
901
|
+
* read cache to finish loading. If a cached value exists for this query it
|
|
902
|
+
* is fed as `initialData` so the user sees it immediately — no undefined
|
|
903
|
+
* flash before the socket round-trip.
|
|
904
|
+
*
|
|
874
905
|
* Internally this routes through TanStack Query: the queryKey is
|
|
875
906
|
* `["lunora", fn.__lunoraRef, args, shardKey]` (TanStack hashes structurally
|
|
876
907
|
* so an args object built in a different key order still dedupes). The
|
|
@@ -1089,4 +1120,4 @@ interface UseVoiceAgentResult {
|
|
|
1089
1120
|
* `createSocket`) so the hook is drivable outside a browser.
|
|
1090
1121
|
*/
|
|
1091
1122
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1092
|
-
export { 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 UseCheckoutResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, 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, useAuthState, useCheckout, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
|
1123
|
+
export { 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 UseCheckoutResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, 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, useAuthState, useCheckout, useClientQuery, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ export { useAgentChat } from './packem_shared/useAgentChat-WPm5iHgR.mjs';
|
|
|
9
9
|
export { useAgentState } from './packem_shared/useAgentState-Cikdlomg.mjs';
|
|
10
10
|
export { useAgentToolEvents } from './packem_shared/useAgentToolEvents-BM7ERo00.mjs';
|
|
11
11
|
export { default as useAuth } from './packem_shared/useAuth-BSutjJaa.mjs';
|
|
12
|
+
export { default as useClientQuery } from './packem_shared/useClientQuery-CN1sC3cP.mjs';
|
|
12
13
|
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-PJ7vyCHy.mjs';
|
|
13
14
|
export { useFlag, useFlags } from './packem_shared/useFlag-C2Pkghli.mjs';
|
|
14
15
|
export { default as useInfiniteQuery } from './packem_shared/useInfiniteQuery-BeaehE9f.mjs';
|
|
@@ -17,9 +18,9 @@ export { useMutator } from './packem_shared/useMutator-IIrLtDiM.mjs';
|
|
|
17
18
|
export { usePaginatedQuery } from './packem_shared/usePaginatedQuery-_6ETVUmf.mjs';
|
|
18
19
|
export { hydratePreloaded, default as usePreloadedQuery } from './packem_shared/hydratePreloaded-uMDH_xA9.mjs';
|
|
19
20
|
export { usePresence } from './packem_shared/usePresence-Rnx1Fznc.mjs';
|
|
20
|
-
export { default as useQuery } from './packem_shared/useQuery-
|
|
21
|
+
export { default as useQuery } from './packem_shared/useQuery-C-hDzP-t.mjs';
|
|
21
22
|
export { useRateLimit } from './packem_shared/useRateLimit-DTEffQEi.mjs';
|
|
22
23
|
export { useStream } from './packem_shared/useStream-CGC26afa.mjs';
|
|
23
24
|
export { default as useSubscription } from './packem_shared/useSubscription-D38Jdyr8.mjs';
|
|
24
25
|
export { useVoiceAgent } from './packem_shared/useVoiceAgent-sC5_ADB8.mjs';
|
|
25
|
-
export { getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
26
|
+
export { createClientQuery, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from '@lunora/client';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { c } from 'react/compiler-runtime';
|
|
3
|
+
import { useSyncExternalStore } from 'react';
|
|
4
|
+
import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
|
|
5
|
+
|
|
6
|
+
const useClientQuery = (ref) => {
|
|
7
|
+
const $ = c(11);
|
|
8
|
+
const client = useLunora();
|
|
9
|
+
let t0;
|
|
10
|
+
let t1;
|
|
11
|
+
let t2;
|
|
12
|
+
if ($[0] !== client || $[1] !== ref) {
|
|
13
|
+
t0 = (onStoreChange) => {
|
|
14
|
+
const unsubscribe = client.subscribeClientQuery(ref, () => {
|
|
15
|
+
onStoreChange();
|
|
16
|
+
});
|
|
17
|
+
return unsubscribe;
|
|
18
|
+
};
|
|
19
|
+
t1 = () => client.getClientQuery(ref);
|
|
20
|
+
t2 = () => client.getClientQuery(ref);
|
|
21
|
+
$[0] = client;
|
|
22
|
+
$[1] = ref;
|
|
23
|
+
$[2] = t0;
|
|
24
|
+
$[3] = t1;
|
|
25
|
+
$[4] = t2;
|
|
26
|
+
} else {
|
|
27
|
+
t0 = $[2];
|
|
28
|
+
t1 = $[3];
|
|
29
|
+
t2 = $[4];
|
|
30
|
+
}
|
|
31
|
+
const value = useSyncExternalStore(t0, t1, t2);
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[5] !== client || $[6] !== ref) {
|
|
34
|
+
t3 = (next) => {
|
|
35
|
+
client.setClientQuery(ref, next);
|
|
36
|
+
};
|
|
37
|
+
$[5] = client;
|
|
38
|
+
$[6] = ref;
|
|
39
|
+
$[7] = t3;
|
|
40
|
+
} else {
|
|
41
|
+
t3 = $[7];
|
|
42
|
+
}
|
|
43
|
+
const setter = t3;
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[8] !== setter || $[9] !== value) {
|
|
46
|
+
t4 = [value, setter];
|
|
47
|
+
$[8] = setter;
|
|
48
|
+
$[9] = value;
|
|
49
|
+
$[10] = t4;
|
|
50
|
+
} else {
|
|
51
|
+
t4 = $[10];
|
|
52
|
+
}
|
|
53
|
+
return t4;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { useClientQuery as default };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { c } from 'react/compiler-runtime';
|
|
3
3
|
import { useQueryClient, useQuery as useQuery$1 } from '@tanstack/react-query';
|
|
4
|
-
import { useEffect } from 'react';
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
5
|
import { g as getSubscriptionRegistry } from './cache-D1O_xfAe.mjs';
|
|
6
6
|
import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
|
|
7
7
|
import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-BmCbgidV.mjs';
|
|
8
8
|
|
|
9
9
|
const useQuery = (function_, args, t0) => {
|
|
10
|
-
const $ = c(
|
|
10
|
+
const $ = c(9);
|
|
11
11
|
const options = t0 === void 0 ? {} : t0;
|
|
12
12
|
const client = useLunora();
|
|
13
13
|
const queryClient = useQueryClient();
|
|
@@ -17,27 +17,50 @@ const useQuery = (function_, args, t0) => {
|
|
|
17
17
|
const skipped = args === "skip";
|
|
18
18
|
const argsRecord = skipped ? {} : args;
|
|
19
19
|
const queryKey = lunoraQueryKey(function_, argsRecord, shardKey);
|
|
20
|
+
const [hydrated, setHydrated] = useState(client.isReady);
|
|
21
|
+
let t1;
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[0] !== client || $[1] !== hydrated) {
|
|
24
|
+
t1 = () => {
|
|
25
|
+
if (!hydrated) {
|
|
26
|
+
client.whenReady().then(() => {
|
|
27
|
+
setHydrated(true);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
t2 = [client, hydrated];
|
|
32
|
+
$[0] = client;
|
|
33
|
+
$[1] = hydrated;
|
|
34
|
+
$[2] = t1;
|
|
35
|
+
$[3] = t2;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[2];
|
|
38
|
+
t2 = $[3];
|
|
39
|
+
}
|
|
40
|
+
useEffect(t1, t2);
|
|
41
|
+
const cachedData = skipped ? void 0 : client.peekHydratedQuery(function_.__lunoraRef, argsRecord, shardKey);
|
|
20
42
|
const {
|
|
21
43
|
data
|
|
22
44
|
} = useQuery$1({
|
|
23
|
-
enabled: !skipped,
|
|
45
|
+
enabled: !skipped && hydrated,
|
|
46
|
+
initialData: cachedData,
|
|
24
47
|
queryFn: () => client.query(function_, argsRecord, {
|
|
25
48
|
shardKey
|
|
26
49
|
}),
|
|
27
50
|
queryKey,
|
|
28
51
|
staleTime: Number.POSITIVE_INFINITY
|
|
29
52
|
});
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
if ($[
|
|
33
|
-
|
|
34
|
-
$[
|
|
35
|
-
$[
|
|
36
|
-
$[
|
|
37
|
-
$[
|
|
38
|
-
$[
|
|
53
|
+
const t3 = serializeQueryKey(queryKey);
|
|
54
|
+
let t4;
|
|
55
|
+
if ($[4] !== client || $[5] !== queryClient || $[6] !== skipped || $[7] !== t3) {
|
|
56
|
+
t4 = [client, queryClient, t3, skipped];
|
|
57
|
+
$[4] = client;
|
|
58
|
+
$[5] = queryClient;
|
|
59
|
+
$[6] = skipped;
|
|
60
|
+
$[7] = t3;
|
|
61
|
+
$[8] = t4;
|
|
39
62
|
} else {
|
|
40
|
-
|
|
63
|
+
t4 = $[8];
|
|
41
64
|
}
|
|
42
65
|
useEffect(() => {
|
|
43
66
|
if (skipped) {
|
|
@@ -45,7 +68,7 @@ const useQuery = (function_, args, t0) => {
|
|
|
45
68
|
}
|
|
46
69
|
const registry = getSubscriptionRegistry(client);
|
|
47
70
|
return registry.attach(queryClient, queryKey, function_, argsRecord, shardKey);
|
|
48
|
-
},
|
|
71
|
+
}, t4);
|
|
49
72
|
return skipped ? void 0 : data;
|
|
50
73
|
};
|
|
51
74
|
function _temp() {
|
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.26",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@lunora/client": "1.0.0-alpha.
|
|
52
|
+
"@lunora/client": "1.0.0-alpha.22",
|
|
53
53
|
"@lunora/errors": "1.0.0-alpha.4",
|
|
54
54
|
"@lunora/ratelimit": "1.0.0-alpha.7"
|
|
55
55
|
},
|