@lunora/react 0.0.0 → 1.0.0-alpha.1
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/LICENSE.md +105 -0
- package/README.md +150 -9
- package/__assets__/package-og.svg +14 -0
- package/dist/index.d.mts +499 -0
- package/dist/index.d.ts +499 -0
- package/dist/index.mjs +17 -0
- package/dist/packem_shared/Authenticated-DtKgZT2Z.mjs +33 -0
- package/dist/packem_shared/CheckoutButton-CVSry8U1.mjs +185 -0
- package/dist/packem_shared/LunoraProvider-D38Xp16l.mjs +80 -0
- package/dist/packem_shared/cache-CItk3fgN.mjs +75 -0
- package/dist/packem_shared/hydratePreloaded-BlFL9FGq.mjs +46 -0
- package/dist/packem_shared/lunoraQueryOptions-CsuWzjg1.mjs +16 -0
- package/dist/packem_shared/query-key-C5rufkEE.mjs +21 -0
- package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +38 -0
- package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +38 -0
- package/dist/packem_shared/use-paginated-core-CoOfcc-p.mjs +161 -0
- package/dist/packem_shared/useAuth-CNUKtOOp.mjs +129 -0
- package/dist/packem_shared/useAuthState-BiGhtSCs.mjs +36 -0
- package/dist/packem_shared/useConnectionStatus-DRSY9ldm.mjs +30 -0
- package/dist/packem_shared/useInfiniteQuery-MH0x4l8h.mjs +97 -0
- package/dist/packem_shared/useMutation-CrvMXRsk.mjs +67 -0
- package/dist/packem_shared/usePaginatedQuery-D3PTDRGS.mjs +46 -0
- package/dist/packem_shared/usePresence-D7jLuxj0.mjs +108 -0
- package/dist/packem_shared/useQuery-C5S0W-7K.mjs +41 -0
- package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +64 -0
- package/dist/packem_shared/useStream-BRY9nemd.mjs +125 -0
- package/dist/packem_shared/useSubscription-CHMCjyQg.mjs +139 -0
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +31 -0
- package/package.json +60 -17
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useReducer, useRef, useEffect } from 'react';
|
|
3
|
+
import { useLunora } from './LunoraProvider-D38Xp16l.mjs';
|
|
4
|
+
import { a as stableStringify } from './query-key-C5rufkEE.mjs';
|
|
5
|
+
|
|
6
|
+
const reducer = function(state, action) {
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case "chunk": {
|
|
9
|
+
return {
|
|
10
|
+
chunks: [...state.chunks, action.chunk],
|
|
11
|
+
error: void 0,
|
|
12
|
+
status: "streaming"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
case "complete": {
|
|
16
|
+
return {
|
|
17
|
+
...state,
|
|
18
|
+
status: "complete"
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
case "error": {
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
error: action.error,
|
|
25
|
+
status: "error"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
case "reset": {
|
|
29
|
+
return {
|
|
30
|
+
chunks: [],
|
|
31
|
+
error: void 0,
|
|
32
|
+
status: "idle"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case "start": {
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
status: "streaming"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
default: {
|
|
42
|
+
return state;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const useStream = (function_, args, options = {}) => {
|
|
47
|
+
const client = useLunora();
|
|
48
|
+
const [state, dispatch] = useReducer(reducer, {
|
|
49
|
+
chunks: [],
|
|
50
|
+
error: void 0,
|
|
51
|
+
status: "idle"
|
|
52
|
+
});
|
|
53
|
+
const skipped = args === "skip";
|
|
54
|
+
const serialized = skipped ? "skip" : stableStringify(args);
|
|
55
|
+
const cancelRef = useRef(void 0);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (skipped) {
|
|
58
|
+
return () => {
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
dispatch({
|
|
62
|
+
type: "reset"
|
|
63
|
+
});
|
|
64
|
+
dispatch({
|
|
65
|
+
type: "start"
|
|
66
|
+
});
|
|
67
|
+
let stillMounted = true;
|
|
68
|
+
let cancelled = false;
|
|
69
|
+
const iterable = client.stream(function_, args, {
|
|
70
|
+
maxBuffer: options.maxBuffer,
|
|
71
|
+
shardKey: options.shardKey
|
|
72
|
+
});
|
|
73
|
+
const cancel = () => {
|
|
74
|
+
if (cancelled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
cancelled = true;
|
|
78
|
+
iterable.cancel();
|
|
79
|
+
};
|
|
80
|
+
cancelRef.current = cancel;
|
|
81
|
+
(async () => {
|
|
82
|
+
try {
|
|
83
|
+
for await (const chunk of iterable) {
|
|
84
|
+
if (!stillMounted) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
dispatch({
|
|
88
|
+
chunk,
|
|
89
|
+
type: "chunk"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (stillMounted) {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: "complete"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!stillMounted) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
102
|
+
dispatch({
|
|
103
|
+
error: normalized,
|
|
104
|
+
type: "error"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
})().catch(() => {
|
|
108
|
+
});
|
|
109
|
+
return () => {
|
|
110
|
+
stillMounted = false;
|
|
111
|
+
cancel();
|
|
112
|
+
cancelRef.current = void 0;
|
|
113
|
+
};
|
|
114
|
+
}, [client, function_.__lunoraRef, serialized, skipped, options.shardKey, options.maxBuffer]);
|
|
115
|
+
return {
|
|
116
|
+
cancel: () => {
|
|
117
|
+
cancelRef.current?.();
|
|
118
|
+
},
|
|
119
|
+
chunks: state.chunks,
|
|
120
|
+
error: state.error,
|
|
121
|
+
status: state.status
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { useStream };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { c } from 'react/compiler-runtime';
|
|
3
|
+
import { createQuerySubscription } from '@lunora/client/query';
|
|
4
|
+
import { useState, useRef, useEffect } from 'react';
|
|
5
|
+
import { useLunora } from './LunoraProvider-D38Xp16l.mjs';
|
|
6
|
+
import { a as stableStringify } from './query-key-C5rufkEE.mjs';
|
|
7
|
+
|
|
8
|
+
const useSubscription = (function_, args, t0) => {
|
|
9
|
+
const $ = c(22);
|
|
10
|
+
let t1;
|
|
11
|
+
if ($[0] !== t0) {
|
|
12
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
13
|
+
$[0] = t0;
|
|
14
|
+
$[1] = t1;
|
|
15
|
+
} else {
|
|
16
|
+
t1 = $[1];
|
|
17
|
+
}
|
|
18
|
+
const options = t1;
|
|
19
|
+
const client = useLunora();
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t2 = {
|
|
23
|
+
data: void 0,
|
|
24
|
+
error: void 0
|
|
25
|
+
};
|
|
26
|
+
$[2] = t2;
|
|
27
|
+
} else {
|
|
28
|
+
t2 = $[2];
|
|
29
|
+
}
|
|
30
|
+
const [state, setState] = useState(t2);
|
|
31
|
+
const skipped = args === "skip";
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[3] !== args || $[4] !== skipped) {
|
|
34
|
+
t3 = skipped ? "skip" : stableStringify(args);
|
|
35
|
+
$[3] = args;
|
|
36
|
+
$[4] = skipped;
|
|
37
|
+
$[5] = t3;
|
|
38
|
+
} else {
|
|
39
|
+
t3 = $[5];
|
|
40
|
+
}
|
|
41
|
+
const serialized = t3;
|
|
42
|
+
let t4;
|
|
43
|
+
if ($[6] !== args || $[7] !== function_) {
|
|
44
|
+
t4 = {
|
|
45
|
+
args,
|
|
46
|
+
fn: function_
|
|
47
|
+
};
|
|
48
|
+
$[6] = args;
|
|
49
|
+
$[7] = function_;
|
|
50
|
+
$[8] = t4;
|
|
51
|
+
} else {
|
|
52
|
+
t4 = $[8];
|
|
53
|
+
}
|
|
54
|
+
const subscribeRef = useRef(t4);
|
|
55
|
+
let t5;
|
|
56
|
+
if ($[9] !== args || $[10] !== function_) {
|
|
57
|
+
t5 = () => {
|
|
58
|
+
subscribeRef.current = {
|
|
59
|
+
args,
|
|
60
|
+
fn: function_
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
$[9] = args;
|
|
64
|
+
$[10] = function_;
|
|
65
|
+
$[11] = t5;
|
|
66
|
+
} else {
|
|
67
|
+
t5 = $[11];
|
|
68
|
+
}
|
|
69
|
+
useEffect(t5);
|
|
70
|
+
let t6;
|
|
71
|
+
if ($[12] !== client || $[13] !== options.shardKey || $[14] !== skipped) {
|
|
72
|
+
t6 = () => {
|
|
73
|
+
if (skipped) {
|
|
74
|
+
setState({
|
|
75
|
+
data: void 0,
|
|
76
|
+
error: void 0
|
|
77
|
+
});
|
|
78
|
+
return _temp;
|
|
79
|
+
}
|
|
80
|
+
let cancelled = false;
|
|
81
|
+
const {
|
|
82
|
+
args: currentArgs,
|
|
83
|
+
fn: currentFunction
|
|
84
|
+
} = subscribeRef.current;
|
|
85
|
+
const unsubscribe = createQuerySubscription(client, currentFunction, currentArgs, {
|
|
86
|
+
onData: (value) => {
|
|
87
|
+
if (cancelled) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setState({
|
|
91
|
+
data: value,
|
|
92
|
+
error: void 0
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
onError: (error) => {
|
|
96
|
+
const normalized = new Error(error.message);
|
|
97
|
+
queueMicrotask(() => {
|
|
98
|
+
if (!cancelled) {
|
|
99
|
+
setState({
|
|
100
|
+
data: void 0,
|
|
101
|
+
error: normalized
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
shardKey: options.shardKey
|
|
108
|
+
});
|
|
109
|
+
return () => {
|
|
110
|
+
cancelled = true;
|
|
111
|
+
unsubscribe();
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
$[12] = client;
|
|
115
|
+
$[13] = options.shardKey;
|
|
116
|
+
$[14] = skipped;
|
|
117
|
+
$[15] = t6;
|
|
118
|
+
} else {
|
|
119
|
+
t6 = $[15];
|
|
120
|
+
}
|
|
121
|
+
let t7;
|
|
122
|
+
if ($[16] !== client || $[17] !== function_.__lunoraRef || $[18] !== options.shardKey || $[19] !== serialized || $[20] !== skipped) {
|
|
123
|
+
t7 = [client, function_.__lunoraRef, serialized, options.shardKey, skipped];
|
|
124
|
+
$[16] = client;
|
|
125
|
+
$[17] = function_.__lunoraRef;
|
|
126
|
+
$[18] = options.shardKey;
|
|
127
|
+
$[19] = serialized;
|
|
128
|
+
$[20] = skipped;
|
|
129
|
+
$[21] = t7;
|
|
130
|
+
} else {
|
|
131
|
+
t7 = $[21];
|
|
132
|
+
}
|
|
133
|
+
useEffect(t6, t7);
|
|
134
|
+
return state;
|
|
135
|
+
};
|
|
136
|
+
function _temp() {
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { useSubscription as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FunctionReference, ArgsOf, ReturnOf, LunoraClient } from '@lunora/client';
|
|
2
|
+
export { type ArgsOf, type FunctionReference, type Preloaded, type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
3
|
+
import { ServerClientOptions } from '@lunora/client/ssr';
|
|
4
|
+
export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
+
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-D4okOpO8.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* Run a query on the server and seed `queryClient` with the result under the
|
|
10
|
+
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
|
11
|
+
* `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
|
|
12
|
+
* flash, no duplicate fetch on the client.
|
|
13
|
+
*
|
|
14
|
+
* Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
|
|
15
|
+
* from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
|
|
16
|
+
* the client subtree in `HydrationBoundary`, and the client hooks pick the value
|
|
17
|
+
* up from cache. Errors propagate — wrap the call if you'd rather render a
|
|
18
|
+
* fallback than fail the server render. Drop the `await` for fire-and-forget
|
|
19
|
+
* prefetch when you don't need the data present on the very first paint.
|
|
20
|
+
*/
|
|
21
|
+
declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
|
|
22
|
+
shardKey?: string;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
/** Per-call options shared by the one-shot `fetch*` helpers. */
|
|
25
|
+
interface ServerCallOptions {
|
|
26
|
+
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
27
|
+
shardKey?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run a query once on the server and return its result — the standalone
|
|
31
|
+
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
32
|
+
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
33
|
+
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
34
|
+
*
|
|
35
|
+
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
36
|
+
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
37
|
+
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
38
|
+
* avoid rebuilding the transport each time. Errors propagate.
|
|
39
|
+
*/
|
|
40
|
+
declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
41
|
+
/**
|
|
42
|
+
* Run a mutation once on the server and return its result. Server-side calls go
|
|
43
|
+
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
44
|
+
* client-only and never engage here. Errors propagate.
|
|
45
|
+
*/
|
|
46
|
+
declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
47
|
+
/**
|
|
48
|
+
* Run an action once on the server and return its result. Errors propagate.
|
|
49
|
+
*/
|
|
50
|
+
declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
51
|
+
export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FunctionReference, ArgsOf, ReturnOf, LunoraClient } from '@lunora/client';
|
|
2
|
+
export { type ArgsOf, type FunctionReference, type Preloaded, type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
3
|
+
import { ServerClientOptions } from '@lunora/client/ssr';
|
|
4
|
+
export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
+
export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-D4okOpO8.js";
|
|
8
|
+
/**
|
|
9
|
+
* Run a query on the server and seed `queryClient` with the result under the
|
|
10
|
+
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
|
11
|
+
* `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
|
|
12
|
+
* flash, no duplicate fetch on the client.
|
|
13
|
+
*
|
|
14
|
+
* Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
|
|
15
|
+
* from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
|
|
16
|
+
* the client subtree in `HydrationBoundary`, and the client hooks pick the value
|
|
17
|
+
* up from cache. Errors propagate — wrap the call if you'd rather render a
|
|
18
|
+
* fallback than fail the server render. Drop the `await` for fire-and-forget
|
|
19
|
+
* prefetch when you don't need the data present on the very first paint.
|
|
20
|
+
*/
|
|
21
|
+
declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
|
|
22
|
+
shardKey?: string;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
/** Per-call options shared by the one-shot `fetch*` helpers. */
|
|
25
|
+
interface ServerCallOptions {
|
|
26
|
+
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
27
|
+
shardKey?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run a query once on the server and return its result — the standalone
|
|
31
|
+
* counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
|
|
32
|
+
* inline in a Server Component (e.g. to compute metadata or branch on a value)
|
|
33
|
+
* rather than seed a cache or hand a `Preloaded` to the client.
|
|
34
|
+
*
|
|
35
|
+
* Builds a fresh request-scoped client per call (see `createServerClient`), so
|
|
36
|
+
* pass `token` to run as the signed-in user. For several reads in one request,
|
|
37
|
+
* prefer holding one `createServerClient` and calling `.query()` yourself to
|
|
38
|
+
* avoid rebuilding the transport each time. Errors propagate.
|
|
39
|
+
*/
|
|
40
|
+
declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
41
|
+
/**
|
|
42
|
+
* Run a mutation once on the server and return its result. Server-side calls go
|
|
43
|
+
* straight over HTTP RPC — the offline queue and optimistic-update machinery are
|
|
44
|
+
* client-only and never engage here. Errors propagate.
|
|
45
|
+
*/
|
|
46
|
+
declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
47
|
+
/**
|
|
48
|
+
* Run an action once on the server and return its result. Errors propagate.
|
|
49
|
+
*/
|
|
50
|
+
declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
|
|
51
|
+
export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createServerClient } from '@lunora/client/ssr';
|
|
2
|
+
export { createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
3
|
+
import { l as lunoraQueryKey } from './packem_shared/query-key-C5rufkEE.mjs';
|
|
4
|
+
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-CsuWzjg1.mjs';
|
|
5
|
+
export { preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
6
|
+
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
+
|
|
8
|
+
const prefetchQuery = async (queryClient, client, function_, args, options = {}) => {
|
|
9
|
+
const argsRecord = args ?? {};
|
|
10
|
+
await queryClient.prefetchQuery({
|
|
11
|
+
queryFn: () => client.query(function_, argsRecord, {
|
|
12
|
+
shardKey: options.shardKey
|
|
13
|
+
}),
|
|
14
|
+
queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
|
|
15
|
+
// Match the client hooks: Lunora is push-driven, so the seeded value is
|
|
16
|
+
// never considered stale by TanStack — the WS subscription that attaches
|
|
17
|
+
// on mount is the only freshness signal.
|
|
18
|
+
staleTime: Number.POSITIVE_INFINITY
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const fetchQuery = async (options, function_, args, callOptions = {}) => createServerClient(options).query(function_, args, {
|
|
22
|
+
shardKey: callOptions.shardKey
|
|
23
|
+
});
|
|
24
|
+
const fetchMutation = async (options, function_, args, callOptions = {}) => createServerClient(options).mutation(function_, args, {
|
|
25
|
+
shardKey: callOptions.shardKey
|
|
26
|
+
});
|
|
27
|
+
const fetchAction = async (options, function_, args, callOptions = {}) => createServerClient(options).action(function_, args, {
|
|
28
|
+
shardKey: callOptions.shardKey
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { fetchAction, fetchMutation, fetchQuery, prefetchQuery };
|
package/package.json
CHANGED
|
@@ -1,31 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"durable-objects",
|
|
8
|
+
"hooks",
|
|
9
|
+
"lunora",
|
|
10
|
+
"react",
|
|
11
|
+
"realtime",
|
|
12
|
+
"usequery",
|
|
13
|
+
"workers"
|
|
14
|
+
],
|
|
6
15
|
"homepage": "https://lunora.sh",
|
|
16
|
+
"bugs": "https://github.com/anolilab/lunora/issues",
|
|
17
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Daniel Bannert",
|
|
20
|
+
"email": "d.bannert@anolilab.de"
|
|
21
|
+
},
|
|
7
22
|
"repository": {
|
|
8
23
|
"type": "git",
|
|
9
24
|
"url": "git+https://github.com/anolilab/lunora.git",
|
|
10
25
|
"directory": "packages/react"
|
|
11
26
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"cloudflare",
|
|
18
|
-
"workers",
|
|
19
|
-
"durable-objects",
|
|
20
|
-
"react",
|
|
21
|
-
"hooks",
|
|
22
|
-
"usequery",
|
|
23
|
-
"realtime"
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE.md",
|
|
31
|
+
"__assets__"
|
|
24
32
|
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"module": "./dist/index.mjs",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./server": {
|
|
43
|
+
"types": "./dist/server.d.ts",
|
|
44
|
+
"import": "./dist/server.mjs"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
25
48
|
"publishConfig": {
|
|
26
49
|
"access": "public"
|
|
27
50
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@lunora/client": "1.0.0-alpha.1",
|
|
53
|
+
"@lunora/ratelimit": "1.0.0-alpha.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@tanstack/react-query": "^5.101.0",
|
|
57
|
+
"react": "^19.2.7",
|
|
58
|
+
"react-dom": "^19.2.7"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@tanstack/react-query": {
|
|
62
|
+
"optional": false
|
|
63
|
+
},
|
|
64
|
+
"react": {
|
|
65
|
+
"optional": false
|
|
66
|
+
},
|
|
67
|
+
"react-dom": {
|
|
68
|
+
"optional": false
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": "^22.15.0 || >=24.11.0"
|
|
73
|
+
}
|
|
31
74
|
}
|