@lunora/react 1.0.0-alpha.31 → 1.0.0-alpha.33
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.mjs +1 -28
- package/dist/packem_shared/AuthLoading-eLWn4Z7G.mjs +2 -0
- package/dist/packem_shared/CheckoutButton-DS_DKgNf.mjs +2 -0
- package/dist/packem_shared/LunoraProvider-InsjxtOB.mjs +2 -0
- package/dist/packem_shared/cache-odCgnNLz.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-DltXxPnp.mjs +2 -0
- package/dist/packem_shared/lunoraQueryOptions-BhiUY9ZF.mjs +1 -0
- package/dist/packem_shared/query-key-Y92N0Dci.mjs +1 -0
- package/dist/packem_shared/stable-key-BSG0zK_E.mjs +1 -0
- package/dist/packem_shared/use-paginated-core-DYjRFno_.mjs +2 -0
- package/dist/packem_shared/useAgent-DNKxqQ9F.mjs +2 -0
- package/dist/packem_shared/useAgentChat-BmYXshp0.mjs +2 -0
- package/dist/packem_shared/useAgentState-DO0yz6OU.mjs +2 -0
- package/dist/packem_shared/useAgentToolEvents-DTWZCIfd.mjs +2 -0
- package/dist/packem_shared/useAuth-CWkJn7i9.mjs +2 -0
- package/dist/packem_shared/useAuthState-jnCMkIwt.mjs +2 -0
- package/dist/packem_shared/useClientQuery-EPo__hzu.mjs +2 -0
- package/dist/packem_shared/useConnectionStatus-PL5D-S7t.mjs +2 -0
- package/dist/packem_shared/useFlag-Dh7bXXPx.mjs +2 -0
- package/dist/packem_shared/useHttpStream-DFswZrRk.mjs +2 -0
- package/dist/packem_shared/useInfiniteQuery-DyExohf2.mjs +2 -0
- package/dist/packem_shared/useMutation-B4uL3Rde.mjs +2 -0
- package/dist/packem_shared/useMutator-D3CGrk5-.mjs +2 -0
- package/dist/packem_shared/usePaginatedQuery-Roo_jyC9.mjs +2 -0
- package/dist/packem_shared/usePresence-SJBy81um.mjs +2 -0
- package/dist/packem_shared/useQuery-m-trnMUV.mjs +2 -0
- package/dist/packem_shared/useRateLimit-DqikMrX9.mjs +2 -0
- package/dist/packem_shared/useStream-CGcSWvPI.mjs +2 -0
- package/dist/packem_shared/useSubscription-CiQk8tFR.mjs +2 -0
- package/dist/packem_shared/useVoiceAgent-4gj2W2jc.mjs +2 -0
- package/dist/packem_shared/wire-key-8Ju6XYoB.mjs +1 -0
- package/dist/server.mjs +1 -31
- package/dist/upload.mjs +1 -2
- package/package.json +4 -4
- package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
- package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
- package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
- package/dist/packem_shared/cache-JeuDAXfE.mjs +0 -80
- package/dist/packem_shared/hydratePreloaded-2omLtadR.mjs +0 -54
- package/dist/packem_shared/lunoraQueryOptions-CefbPBId.mjs +0 -16
- package/dist/packem_shared/query-key-LGnArBTB.mjs +0 -13
- package/dist/packem_shared/stable-key-DePnevIy.mjs +0 -38
- package/dist/packem_shared/use-paginated-core-xxvd1YA0.mjs +0 -179
- package/dist/packem_shared/useAgent-BNLlIYHz.mjs +0 -101
- package/dist/packem_shared/useAgentChat-0cebQe7-.mjs +0 -304
- package/dist/packem_shared/useAgentState-Cqyd3Dfy.mjs +0 -37
- package/dist/packem_shared/useAgentToolEvents-gF7U4_KY.mjs +0 -129
- package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
- package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
- package/dist/packem_shared/useClientQuery-DIkNT4QA.mjs +0 -17
- package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
- package/dist/packem_shared/useFlag-Beyeiq2b.mjs +0 -128
- package/dist/packem_shared/useHttpStream-oc4s1pMy.mjs +0 -127
- package/dist/packem_shared/useInfiniteQuery-CJNw1XaZ.mjs +0 -97
- package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
- package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
- package/dist/packem_shared/usePaginatedQuery-DWzydaVR.mjs +0 -46
- package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
- package/dist/packem_shared/useQuery-CE8_QUgh.mjs +0 -77
- package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
- package/dist/packem_shared/useStream-GYNgc9J5.mjs +0 -128
- package/dist/packem_shared/useSubscription-DcDlvVuI.mjs +0 -139
- package/dist/packem_shared/useVoiceAgent-w7fzAMSB.mjs +0 -422
- package/dist/packem_shared/wire-key-Bg8BJ8YM.mjs +0 -101
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { k as keyHash } from './query-key-LGnArBTB.mjs';
|
|
2
|
-
|
|
3
|
-
class LunoraSubscriptionRegistry {
|
|
4
|
-
constructor(client) {
|
|
5
|
-
this.client = client;
|
|
6
|
-
}
|
|
7
|
-
client;
|
|
8
|
-
entries = /* @__PURE__ */ new Map();
|
|
9
|
-
/**
|
|
10
|
-
* Hash a TanStack `queryKey` to the internal registry index. Exposed so a
|
|
11
|
-
* hook can look up the registry without re-implementing the hash.
|
|
12
|
-
*/
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this -- instance method by design: callers reach the hash through a registry handle rather than importing the module-level helper.
|
|
14
|
-
keyOf(queryKey) {
|
|
15
|
-
return keyHash(queryKey);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Attach a consumer to the live subscription for `queryKey`. The first
|
|
19
|
-
* attach opens the underlying WS subscription; subsequent attaches reuse
|
|
20
|
-
* it (refcount-bumped). Returns the detach function — call it exactly once
|
|
21
|
-
* per attach.
|
|
22
|
-
*/
|
|
23
|
-
attach(queryClient, queryKey, function_, args, shardKey, options = {}) {
|
|
24
|
-
const key = keyHash(queryKey);
|
|
25
|
-
let entry = this.entries.get(key);
|
|
26
|
-
if (!entry) {
|
|
27
|
-
entry = {
|
|
28
|
-
pollTimer: void 0,
|
|
29
|
-
refCount: 0,
|
|
30
|
-
unsubscribe: void 0
|
|
31
|
-
};
|
|
32
|
-
this.entries.set(key, entry);
|
|
33
|
-
try {
|
|
34
|
-
entry.unsubscribe = this.client.subscribe(function_, args, (value) => {
|
|
35
|
-
queryClient.setQueryData(queryKey, value);
|
|
36
|
-
}, {
|
|
37
|
-
shardKey
|
|
38
|
-
});
|
|
39
|
-
} catch {
|
|
40
|
-
entry.pollTimer = setInterval(() => {
|
|
41
|
-
queryClient.invalidateQueries({
|
|
42
|
-
queryKey
|
|
43
|
-
}).catch(() => {
|
|
44
|
-
});
|
|
45
|
-
}, options.pollIntervalMs ?? 5e3);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
entry.refCount += 1;
|
|
49
|
-
let detached = false;
|
|
50
|
-
return () => {
|
|
51
|
-
if (detached) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
detached = true;
|
|
55
|
-
const current = this.entries.get(key);
|
|
56
|
-
if (!current) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
current.refCount -= 1;
|
|
60
|
-
if (current.refCount <= 0) {
|
|
61
|
-
current.unsubscribe?.();
|
|
62
|
-
if (current.pollTimer) {
|
|
63
|
-
clearInterval(current.pollTimer);
|
|
64
|
-
}
|
|
65
|
-
this.entries.delete(key);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const registryByClient = /* @__PURE__ */ new WeakMap();
|
|
71
|
-
const getSubscriptionRegistry = (client) => {
|
|
72
|
-
let registry = registryByClient.get(client);
|
|
73
|
-
if (!registry) {
|
|
74
|
-
registry = new LunoraSubscriptionRegistry(client);
|
|
75
|
-
registryByClient.set(client, registry);
|
|
76
|
-
}
|
|
77
|
-
return registry;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export { getSubscriptionRegistry as g };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { c } from 'react/compiler-runtime';
|
|
3
|
-
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
import { g as getSubscriptionRegistry } from './cache-JeuDAXfE.mjs';
|
|
6
|
-
import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
|
|
7
|
-
import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-LGnArBTB.mjs';
|
|
8
|
-
|
|
9
|
-
const usePreloadedQuery = function(preloaded) {
|
|
10
|
-
const $ = c(4);
|
|
11
|
-
const client = useLunora();
|
|
12
|
-
const queryClient = useQueryClient();
|
|
13
|
-
const {
|
|
14
|
-
args,
|
|
15
|
-
functionPath,
|
|
16
|
-
shardKey,
|
|
17
|
-
value
|
|
18
|
-
} = preloaded;
|
|
19
|
-
const functionRef = {
|
|
20
|
-
__lunoraRef: functionPath
|
|
21
|
-
};
|
|
22
|
-
const queryKey = lunoraQueryKey(functionRef, args, shardKey);
|
|
23
|
-
const {
|
|
24
|
-
data
|
|
25
|
-
} = useQuery({
|
|
26
|
-
initialData: value,
|
|
27
|
-
queryFn: () => client.query(functionRef, args, {
|
|
28
|
-
shardKey
|
|
29
|
-
}),
|
|
30
|
-
queryKey,
|
|
31
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
32
|
-
});
|
|
33
|
-
const t0 = serializeQueryKey(queryKey);
|
|
34
|
-
let t1;
|
|
35
|
-
if ($[0] !== client || $[1] !== queryClient || $[2] !== t0) {
|
|
36
|
-
t1 = [client, queryClient, t0];
|
|
37
|
-
$[0] = client;
|
|
38
|
-
$[1] = queryClient;
|
|
39
|
-
$[2] = t0;
|
|
40
|
-
$[3] = t1;
|
|
41
|
-
} else {
|
|
42
|
-
t1 = $[3];
|
|
43
|
-
}
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const registry = getSubscriptionRegistry(client);
|
|
46
|
-
return registry.attach(queryClient, queryKey, functionRef, args, shardKey);
|
|
47
|
-
}, t1);
|
|
48
|
-
return data === void 0 ? value : data;
|
|
49
|
-
};
|
|
50
|
-
const hydratePreloaded = function(preloaded) {
|
|
51
|
-
return usePreloadedQuery(preloaded);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { usePreloadedQuery as default, hydratePreloaded };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { l as lunoraQueryKey } from './query-key-LGnArBTB.mjs';
|
|
2
|
-
|
|
3
|
-
const lunoraQueryOptions = (client, function_, args, options = {}) => {
|
|
4
|
-
const argsRecord = args ?? {};
|
|
5
|
-
return {
|
|
6
|
-
queryFn: () => client.query(function_, argsRecord, {
|
|
7
|
-
shardKey: options.shardKey
|
|
8
|
-
}),
|
|
9
|
-
queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
|
|
10
|
-
// Lunora is push-driven: the value never goes stale on a timer. For
|
|
11
|
-
// reactivity use `useQuery`; this adapter is a one-shot/suspense read.
|
|
12
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { lunoraQueryOptions };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { s as stableWireKey } from './wire-key-Bg8BJ8YM.mjs';
|
|
2
|
-
|
|
3
|
-
const keyHash = (queryKey) => stableWireKey(queryKey);
|
|
4
|
-
const lunoraQueryKey = (function_, args, shardKey) => [
|
|
5
|
-
"lunora",
|
|
6
|
-
function_.__lunoraRef,
|
|
7
|
-
args,
|
|
8
|
-
// eslint-disable-next-line unicorn/no-null -- this literal is part of the JSON-serialized query key TanStack hashes for dedup; `null` keeps a stable, distinct slot from an absent shardKey across renders.
|
|
9
|
-
shardKey ?? null
|
|
10
|
-
];
|
|
11
|
-
const serializeQueryKey = (queryKey) => keyHash(queryKey);
|
|
12
|
-
|
|
13
|
-
export { keyHash as k, lunoraQueryKey as l, serializeQueryKey as s };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const compareKeys = (a, b) => {
|
|
2
|
-
if (a < b) {
|
|
3
|
-
return -1;
|
|
4
|
-
}
|
|
5
|
-
return a > b ? 1 : 0;
|
|
6
|
-
};
|
|
7
|
-
const stableStringify = (value) => {
|
|
8
|
-
if (value === void 0) {
|
|
9
|
-
return "null";
|
|
10
|
-
}
|
|
11
|
-
if (typeof value === "bigint") {
|
|
12
|
-
throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");
|
|
13
|
-
}
|
|
14
|
-
if (value === null || typeof value !== "object") {
|
|
15
|
-
return JSON.stringify(value);
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
19
|
-
}
|
|
20
|
-
const proto = Object.getPrototypeOf(value);
|
|
21
|
-
if (proto !== null && proto !== Object.prototype) {
|
|
22
|
-
const name = value.constructor?.name ?? "value";
|
|
23
|
-
throw new TypeError(`stableStringify: cannot use a ${name} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`);
|
|
24
|
-
}
|
|
25
|
-
const record = value;
|
|
26
|
-
const keys = Object.keys(record).toSorted(compareKeys);
|
|
27
|
-
const parts = [];
|
|
28
|
-
for (const key of keys) {
|
|
29
|
-
const raw = record[key];
|
|
30
|
-
if (raw === void 0) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
|
|
34
|
-
}
|
|
35
|
-
return `{${parts.join(",")}}`;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { stableStringify as s };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { initialPages, rebalance, derivePaginationStatus, applyLoadMore } from '@lunora/client/pagination';
|
|
3
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { useRef, useReducer, useState, useEffect, useCallback } from 'react';
|
|
5
|
-
import { g as getSubscriptionRegistry } from './cache-JeuDAXfE.mjs';
|
|
6
|
-
import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
|
|
7
|
-
import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-LGnArBTB.mjs';
|
|
8
|
-
|
|
9
|
-
const useLazyRef = function(create) {
|
|
10
|
-
const reference = useRef(void 0);
|
|
11
|
-
reference.current ??= create();
|
|
12
|
-
return reference;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const usePaginatedCore = function(function_, args, options) {
|
|
16
|
-
const client = useLunora();
|
|
17
|
-
const queryClient = useQueryClient();
|
|
18
|
-
const {
|
|
19
|
-
initialNumItems,
|
|
20
|
-
shardKey
|
|
21
|
-
} = options;
|
|
22
|
-
const skipped = args === "skip";
|
|
23
|
-
const baseArgs = skipped ? {} : args;
|
|
24
|
-
const [, forceRender] = useReducer((tick) => tick + 1, 0);
|
|
25
|
-
const [pages, setPages] = useState(() => initialPages(initialNumItems));
|
|
26
|
-
const resetKey = `${serializeQueryKey(lunoraQueryKey(function_, baseArgs, shardKey))}::${String(initialNumItems)}`;
|
|
27
|
-
const resetKeyRef = useRef(resetKey);
|
|
28
|
-
if (resetKeyRef.current !== resetKey) {
|
|
29
|
-
resetKeyRef.current = resetKey;
|
|
30
|
-
setPages(initialPages(initialNumItems));
|
|
31
|
-
}
|
|
32
|
-
const pageEntries = pages.map((page) => {
|
|
33
|
-
const pageArgs = {
|
|
34
|
-
...baseArgs,
|
|
35
|
-
paginationOpts: {
|
|
36
|
-
cursor: page.lower,
|
|
37
|
-
endCursor: page.upper,
|
|
38
|
-
numItems: page.numItems
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const key = lunoraQueryKey(function_, pageArgs, shardKey);
|
|
42
|
-
return {
|
|
43
|
-
args: pageArgs,
|
|
44
|
-
key
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
const pageKeysHash = pageEntries.map(({
|
|
48
|
-
key: key_0
|
|
49
|
-
}) => serializeQueryKey(key_0)).join("|");
|
|
50
|
-
const desiredRef = useRef({
|
|
51
|
-
baseArgs,
|
|
52
|
-
entries: [],
|
|
53
|
-
fn: function_,
|
|
54
|
-
shardKey
|
|
55
|
-
});
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
desiredRef.current = {
|
|
58
|
-
baseArgs,
|
|
59
|
-
entries: pageEntries,
|
|
60
|
-
fn: function_,
|
|
61
|
-
shardKey
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
const detachesRef = useLazyRef(() => /* @__PURE__ */ new Map());
|
|
65
|
-
const detachClientRef = useRef(client);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
const detaches = detachesRef.current;
|
|
68
|
-
if (detachClientRef.current !== client) {
|
|
69
|
-
for (const detach of detaches.values()) {
|
|
70
|
-
detach();
|
|
71
|
-
}
|
|
72
|
-
detaches.clear();
|
|
73
|
-
detachClientRef.current = client;
|
|
74
|
-
}
|
|
75
|
-
if (skipped) {
|
|
76
|
-
for (const detach_0 of detaches.values()) {
|
|
77
|
-
detach_0();
|
|
78
|
-
}
|
|
79
|
-
detaches.clear();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const desired = desiredRef.current;
|
|
83
|
-
const registry = getSubscriptionRegistry(client);
|
|
84
|
-
const wanted = new Set(desired.entries.map(({
|
|
85
|
-
key: key_1
|
|
86
|
-
}) => serializeQueryKey(key_1)));
|
|
87
|
-
for (const [hash, detach_1] of detaches) {
|
|
88
|
-
if (!wanted.has(hash)) {
|
|
89
|
-
detach_1();
|
|
90
|
-
detaches.delete(hash);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
for (const entry of desired.entries) {
|
|
94
|
-
const hash_0 = serializeQueryKey(entry.key);
|
|
95
|
-
if (detaches.has(hash_0)) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const initialFetch = queryClient.fetchQuery({
|
|
99
|
-
queryFn: () => client.query(desired.fn, entry.args, {
|
|
100
|
-
shardKey: desired.shardKey
|
|
101
|
-
}),
|
|
102
|
-
queryKey: entry.key,
|
|
103
|
-
staleTime: 0
|
|
104
|
-
});
|
|
105
|
-
initialFetch.catch(() => {
|
|
106
|
-
});
|
|
107
|
-
detaches.set(hash_0, registry.attach(queryClient, entry.key, desired.fn, entry.args, desired.shardKey));
|
|
108
|
-
}
|
|
109
|
-
}, [client, queryClient, pageKeysHash, skipped]);
|
|
110
|
-
useEffect(
|
|
111
|
-
() => () => {
|
|
112
|
-
for (const detach_2 of detachesRef.current.values()) {
|
|
113
|
-
detach_2();
|
|
114
|
-
}
|
|
115
|
-
detachesRef.current.clear();
|
|
116
|
-
},
|
|
117
|
-
// react-doctor-disable-next-line react-doctor/exhaustive-deps -- intentional: unmount-only cleanup. `detachesRef` is a stable ref, so the empty dep array is correct — the teardown must run once on unmount, not every render.
|
|
118
|
-
[]
|
|
119
|
-
);
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
const cache = queryClient.getQueryCache();
|
|
122
|
-
const unsubscribe = cache.subscribe((event) => {
|
|
123
|
-
if (event.type !== "updated") {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const hash_1 = serializeQueryKey(event.query.queryKey);
|
|
127
|
-
if (pageEntries.some(({
|
|
128
|
-
key: key_2
|
|
129
|
-
}) => serializeQueryKey(key_2) === hash_1)) {
|
|
130
|
-
forceRender();
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return unsubscribe;
|
|
134
|
-
}, [queryClient, pageKeysHash]);
|
|
135
|
-
const pageResults = skipped ? [] : pageEntries.map(({
|
|
136
|
-
key: key_3
|
|
137
|
-
}) => queryClient.getQueryData(key_3));
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (skipped) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const next = rebalance(pages, pageResults);
|
|
143
|
-
if (next) {
|
|
144
|
-
setPages(next);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
const {
|
|
148
|
-
status
|
|
149
|
-
} = derivePaginationStatus(skipped, pageResults);
|
|
150
|
-
const loadMore = useCallback((numberItems) => {
|
|
151
|
-
setPages((current) => {
|
|
152
|
-
const desired_0 = desiredRef.current;
|
|
153
|
-
const results = current.map((page_0) => {
|
|
154
|
-
const pageArgs_0 = {
|
|
155
|
-
...desired_0.baseArgs,
|
|
156
|
-
paginationOpts: {
|
|
157
|
-
cursor: page_0.lower,
|
|
158
|
-
endCursor: page_0.upper,
|
|
159
|
-
numItems: page_0.numItems
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
return queryClient.getQueryData(lunoraQueryKey(desired_0.fn, pageArgs_0, desired_0.shardKey));
|
|
163
|
-
});
|
|
164
|
-
const {
|
|
165
|
-
nextCursor,
|
|
166
|
-
status: liveStatus
|
|
167
|
-
} = derivePaginationStatus(false, results);
|
|
168
|
-
const cursor = liveStatus === "CanLoadMore" ? nextCursor : void 0;
|
|
169
|
-
return applyLoadMore(current, cursor, numberItems) ?? current;
|
|
170
|
-
});
|
|
171
|
-
}, [queryClient]);
|
|
172
|
-
return {
|
|
173
|
-
loadMore,
|
|
174
|
-
pageResults,
|
|
175
|
-
status
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export { usePaginatedCore as u };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { c } from 'react/compiler-runtime';
|
|
3
|
-
import { useMutation } from './useMutation-BeqeIjTr.mjs';
|
|
4
|
-
import useSubscription from './useSubscription-DcDlvVuI.mjs';
|
|
5
|
-
|
|
6
|
-
const NO_MUTATION_REF = {
|
|
7
|
-
__lunoraRef: ""
|
|
8
|
-
};
|
|
9
|
-
const useAgent = (options) => {
|
|
10
|
-
const $ = c(17);
|
|
11
|
-
const {
|
|
12
|
-
api,
|
|
13
|
-
cancel: cancelReference,
|
|
14
|
-
run: runReference,
|
|
15
|
-
runArgs,
|
|
16
|
-
threadKey
|
|
17
|
-
} = options;
|
|
18
|
-
const runMutation = useMutation(runReference);
|
|
19
|
-
const cancelMutation = useMutation(cancelReference ?? NO_MUTATION_REF);
|
|
20
|
-
let t0;
|
|
21
|
-
if ($[0] !== threadKey) {
|
|
22
|
-
t0 = {
|
|
23
|
-
key: threadKey
|
|
24
|
-
};
|
|
25
|
-
$[0] = threadKey;
|
|
26
|
-
$[1] = t0;
|
|
27
|
-
} else {
|
|
28
|
-
t0 = $[1];
|
|
29
|
-
}
|
|
30
|
-
const {
|
|
31
|
-
data: threadData
|
|
32
|
-
} = useSubscription(api.agents.agentThread, t0);
|
|
33
|
-
const thread = threadData;
|
|
34
|
-
const status = thread?.status;
|
|
35
|
-
const instanceId = thread?.instanceId;
|
|
36
|
-
const {
|
|
37
|
-
mutate: runMutate
|
|
38
|
-
} = runMutation;
|
|
39
|
-
const {
|
|
40
|
-
mutate: cancelMutate
|
|
41
|
-
} = cancelMutation;
|
|
42
|
-
let t1;
|
|
43
|
-
if ($[2] !== runArgs || $[3] !== runMutate || $[4] !== threadKey) {
|
|
44
|
-
t1 = async (input, args) => {
|
|
45
|
-
await runMutate({
|
|
46
|
-
input,
|
|
47
|
-
threadKey,
|
|
48
|
-
...runArgs,
|
|
49
|
-
...args
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
$[2] = runArgs;
|
|
53
|
-
$[3] = runMutate;
|
|
54
|
-
$[4] = threadKey;
|
|
55
|
-
$[5] = t1;
|
|
56
|
-
} else {
|
|
57
|
-
t1 = $[5];
|
|
58
|
-
}
|
|
59
|
-
const run = t1;
|
|
60
|
-
let t2;
|
|
61
|
-
if ($[6] !== cancelMutate || $[7] !== cancelReference || $[8] !== instanceId || $[9] !== threadKey) {
|
|
62
|
-
t2 = async () => {
|
|
63
|
-
if (cancelReference === void 0 || instanceId === void 0) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
await cancelMutate({
|
|
67
|
-
instanceId,
|
|
68
|
-
threadKey
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
$[6] = cancelMutate;
|
|
72
|
-
$[7] = cancelReference;
|
|
73
|
-
$[8] = instanceId;
|
|
74
|
-
$[9] = threadKey;
|
|
75
|
-
$[10] = t2;
|
|
76
|
-
} else {
|
|
77
|
-
t2 = $[10];
|
|
78
|
-
}
|
|
79
|
-
const cancel = t2;
|
|
80
|
-
let t3;
|
|
81
|
-
if ($[11] !== cancel || $[12] !== run || $[13] !== runMutation.pending || $[14] !== status || $[15] !== thread) {
|
|
82
|
-
t3 = {
|
|
83
|
-
cancel,
|
|
84
|
-
pending: runMutation.pending,
|
|
85
|
-
run,
|
|
86
|
-
status,
|
|
87
|
-
thread
|
|
88
|
-
};
|
|
89
|
-
$[11] = cancel;
|
|
90
|
-
$[12] = run;
|
|
91
|
-
$[13] = runMutation.pending;
|
|
92
|
-
$[14] = status;
|
|
93
|
-
$[15] = thread;
|
|
94
|
-
$[16] = t3;
|
|
95
|
-
} else {
|
|
96
|
-
t3 = $[16];
|
|
97
|
-
}
|
|
98
|
-
return t3;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export { useAgent };
|