@lunora/react 1.0.0-alpha.28 → 1.0.0-alpha.29

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.
@@ -0,0 +1,38 @@
1
+ import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
+ import { QueryKey } from '@tanstack/react-query';
3
+ /**
4
+ * Pure, transport-free adapter between a Lunora function reference and a
5
+ * TanStack Query options object. No `"use client"` directive and only a
6
+ * type-level `@lunora/client` import, so it is safe to use on either side of an
7
+ * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
+ *
9
+ * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
+ * `useSuspenseQuery`, `useQueries`, or the server-side
11
+ * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
+ * `useQuery` from `@lunora/react`.
13
+ */
14
+ /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
+ interface LunoraQueryOptions<F extends FunctionReference> {
16
+ queryFn: () => Promise<ReturnOf<F>>;
17
+ queryKey: QueryKey;
18
+ staleTime: number;
19
+ }
20
+ /**
21
+ * Build a TanStack Query options object for a Lunora query, keyed identically
22
+ * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
+ * this adapter shares cache identity with anything `useQuery` /
24
+ * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
+ *
26
+ * ```ts
27
+ * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
+ * ```
29
+ *
30
+ * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
+ * TanStack never refetches on its own. It does not open a WebSocket — for live
32
+ * updates that re-render on every server push, use `useQuery` from
33
+ * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
+ */
35
+ declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
+ shardKey?: string;
37
+ }) => LunoraQueryOptions<F>;
38
+ export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -0,0 +1,38 @@
1
+ import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
+ import { QueryKey } from '@tanstack/react-query';
3
+ /**
4
+ * Pure, transport-free adapter between a Lunora function reference and a
5
+ * TanStack Query options object. No `"use client"` directive and only a
6
+ * type-level `@lunora/client` import, so it is safe to use on either side of an
7
+ * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
+ *
9
+ * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
+ * `useSuspenseQuery`, `useQueries`, or the server-side
11
+ * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
+ * `useQuery` from `@lunora/react`.
13
+ */
14
+ /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
+ interface LunoraQueryOptions<F extends FunctionReference> {
16
+ queryFn: () => Promise<ReturnOf<F>>;
17
+ queryKey: QueryKey;
18
+ staleTime: number;
19
+ }
20
+ /**
21
+ * Build a TanStack Query options object for a Lunora query, keyed identically
22
+ * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
+ * this adapter shares cache identity with anything `useQuery` /
24
+ * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
+ *
26
+ * ```ts
27
+ * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
+ * ```
29
+ *
30
+ * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
+ * TanStack never refetches on its own. It does not open a WebSocket — for live
32
+ * updates that re-render on every server push, use `useQuery` from
33
+ * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
+ */
35
+ declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
+ shardKey?: string;
37
+ }) => LunoraQueryOptions<F>;
38
+ export { LunoraQueryOptions as L, lunoraQueryOptions as l };
package/dist/server.d.mts CHANGED
@@ -4,20 +4,20 @@ import { ServerClientOptions } from '@lunora/client/ssr';
4
4
  export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
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";
7
+ export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
8
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
- */
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
21
  declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
22
22
  shardKey?: string;
23
23
  }) => Promise<void>;
@@ -27,25 +27,25 @@ interface ServerCallOptions {
27
27
  shardKey?: string;
28
28
  }
29
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
- */
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
40
  declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
41
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
- */
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
46
  declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
47
47
  /**
48
- * Run an action once on the server and return its result. Errors propagate.
49
- */
48
+ * Run an action once on the server and return its result. Errors propagate.
49
+ */
50
50
  declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
51
51
  export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
package/dist/server.d.ts CHANGED
@@ -4,20 +4,20 @@ import { ServerClientOptions } from '@lunora/client/ssr';
4
4
  export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
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";
7
+ export { type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
8
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
- */
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
21
  declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
22
22
  shardKey?: string;
23
23
  }) => Promise<void>;
@@ -27,25 +27,25 @@ interface ServerCallOptions {
27
27
  shardKey?: string;
28
28
  }
29
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
- */
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
40
  declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
41
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
- */
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
46
  declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
47
47
  /**
48
- * Run an action once on the server and return its result. Errors propagate.
49
- */
48
+ * Run an action once on the server and return its result. Errors propagate.
49
+ */
50
50
  declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
51
51
  export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.28",
3
+ "version": "1.0.0-alpha.29",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -49,9 +49,9 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@lunora/client": "1.0.0-alpha.24",
53
- "@lunora/errors": "1.0.0-alpha.5",
54
- "@lunora/ratelimit": "1.0.0-alpha.8"
52
+ "@lunora/client": "1.0.0-alpha.25",
53
+ "@lunora/errors": "1.0.0-alpha.6",
54
+ "@lunora/ratelimit": "1.0.0-alpha.9"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@tanstack/react-query": "^5.101.0",
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };