@lunora/react 1.0.0-alpha.9 → 1.0.0-alpha.90

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.
Files changed (73) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +25 -18
  3. package/dist/index.d.mts +1157 -355
  4. package/dist/index.d.ts +1157 -355
  5. package/dist/index.mjs +1 -18
  6. package/dist/packem_shared/AuthLoading-dC08yqew.mjs +2 -0
  7. package/dist/packem_shared/LunoraProvider-DC06S-p1.mjs +2 -0
  8. package/dist/packem_shared/cache-C2UbTWee.mjs +1 -0
  9. package/dist/packem_shared/hydratePreloaded-DYvzkKqH.mjs +2 -0
  10. package/dist/packem_shared/lunoraQueryOptions-BVgQsR9d.mjs +1 -0
  11. package/dist/packem_shared/query-key-By_ZIdza.mjs +1 -0
  12. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +38 -0
  13. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +38 -0
  14. package/dist/packem_shared/stable-key-B_BlboiY.mjs +1 -0
  15. package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
  16. package/dist/packem_shared/use-paginated-core-BZaJ5Xam.mjs +2 -0
  17. package/dist/packem_shared/useAction-CUSJu4yq.mjs +2 -0
  18. package/dist/packem_shared/useAgent-DtQfMu4S.mjs +2 -0
  19. package/dist/packem_shared/useAgentChat-g4ZNMq1B.mjs +2 -0
  20. package/dist/packem_shared/useAgentState-BuMYPWb2.mjs +2 -0
  21. package/dist/packem_shared/useAgentToolEvents-B1ItKmZi.mjs +2 -0
  22. package/dist/packem_shared/useAuth-x4boOoAR.mjs +2 -0
  23. package/dist/packem_shared/useAuthSessions-gBDeNFnd.mjs +2 -0
  24. package/dist/packem_shared/useAuthState-CoOG9XdT.mjs +2 -0
  25. package/dist/packem_shared/useClientQuery-DFs7trEf.mjs +2 -0
  26. package/dist/packem_shared/useConnectionStatus-XYsYGiT6.mjs +2 -0
  27. package/dist/packem_shared/useFlag-BDM923ke.mjs +2 -0
  28. package/dist/packem_shared/useHttpStream-DWtB9sAr.mjs +2 -0
  29. package/dist/packem_shared/useInfiniteQuery-D6zw7PwB.mjs +2 -0
  30. package/dist/packem_shared/useMutation-BnKec7bE.mjs +2 -0
  31. package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
  32. package/dist/packem_shared/usePaginatedQuery-hCSqOGFy.mjs +2 -0
  33. package/dist/packem_shared/usePresence-BVjZyltT.mjs +2 -0
  34. package/dist/packem_shared/useQuery-DIu5vJyH.mjs +2 -0
  35. package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
  36. package/dist/packem_shared/useStream-Cor62Cu-.mjs +2 -0
  37. package/dist/packem_shared/useSubscription-egFPCaGE.mjs +2 -0
  38. package/dist/packem_shared/useVoiceAgent-DHdUlo0G.mjs +2 -0
  39. package/dist/packem_shared/wire-key-p_JEwJ1j.mjs +1 -0
  40. package/dist/payment.d.mts +93 -0
  41. package/dist/payment.d.ts +93 -0
  42. package/dist/payment.mjs +2 -0
  43. package/dist/server.d.mts +47 -29
  44. package/dist/server.d.ts +47 -29
  45. package/dist/server.mjs +1 -31
  46. package/dist/upload.d.mts +23 -0
  47. package/dist/upload.d.ts +23 -0
  48. package/dist/upload.mjs +2 -0
  49. package/package.json +14 -4
  50. package/dist/packem_shared/AuthLoading-DtKgZT2Z.mjs +0 -33
  51. package/dist/packem_shared/CheckoutButton-CVSry8U1.mjs +0 -185
  52. package/dist/packem_shared/LunoraProvider-D38Xp16l.mjs +0 -80
  53. package/dist/packem_shared/cache-CAp1fVNL.mjs +0 -75
  54. package/dist/packem_shared/hydratePreloaded-B6OHn0eL.mjs +0 -46
  55. package/dist/packem_shared/lunoraQueryOptions-Cij4KWBK.mjs +0 -16
  56. package/dist/packem_shared/query-key-B5eRQCbR.mjs +0 -13
  57. package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +0 -38
  58. package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +0 -38
  59. package/dist/packem_shared/stable-key-CaKZv9lp.mjs +0 -30
  60. package/dist/packem_shared/use-paginated-core-DP72UNWn.mjs +0 -176
  61. package/dist/packem_shared/useAuth-CNUKtOOp.mjs +0 -129
  62. package/dist/packem_shared/useAuthState-BiGhtSCs.mjs +0 -36
  63. package/dist/packem_shared/useConnectionStatus-DRSY9ldm.mjs +0 -30
  64. package/dist/packem_shared/useFlag-Bg5DpkGv.mjs +0 -224
  65. package/dist/packem_shared/useInfiniteQuery-BBIDFXBN.mjs +0 -97
  66. package/dist/packem_shared/useMutation-CrvMXRsk.mjs +0 -67
  67. package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
  68. package/dist/packem_shared/usePaginatedQuery-AQO3kdp1.mjs +0 -46
  69. package/dist/packem_shared/usePresence-D7jLuxj0.mjs +0 -108
  70. package/dist/packem_shared/useQuery-EB74gtBJ.mjs +0 -42
  71. package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
  72. package/dist/packem_shared/useStream-MdYnWDL_.mjs +0 -125
  73. package/dist/packem_shared/useSubscription-DSJuryrU.mjs +0 -139
package/dist/server.d.mts CHANGED
@@ -4,20 +4,38 @@ 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 {
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
+ * Server-side data-loading helpers for React Server Components.
10
+ *
11
+ * This module is the server half of `@lunora/react`: it carries no
12
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
13
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
14
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
15
+ * `@lunora/react`, which is a client boundary.
16
+ *
17
+ * Two flows are supported, mirroring the two common RSC patterns. First,
18
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
19
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
20
+ * the client renders with data on the first paint and a live WS subscription
21
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
22
+ * serializable `Preloaded` value you hand to a client component that calls
23
+ * `usePreloadedQuery`.
24
+ */
25
+ type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.mjs";
26
+ /**
27
+ * Run a query on the server and seed `queryClient` with the result under the
28
+ * same key the client hooks use (see `lunoraQueryKey`), so a later
29
+ * `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
30
+ * flash, no duplicate fetch on the client.
31
+ *
32
+ * Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
33
+ * from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
34
+ * the client subtree in `HydrationBoundary`, and the client hooks pick the value
35
+ * up from cache. Errors propagate — wrap the call if you'd rather render a
36
+ * fallback than fail the server render. Drop the `await` for fire-and-forget
37
+ * prefetch when you don't need the data present on the very first paint.
38
+ */
21
39
  declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
22
40
  shardKey?: string;
23
41
  }) => Promise<void>;
@@ -27,25 +45,25 @@ interface ServerCallOptions {
27
45
  shardKey?: string;
28
46
  }
29
47
  /**
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
- */
48
+ * Run a query once on the server and return its result — the standalone
49
+ * counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
50
+ * inline in a Server Component (e.g. to compute metadata or branch on a value)
51
+ * rather than seed a cache or hand a `Preloaded` to the client.
52
+ *
53
+ * Builds a fresh request-scoped client per call (see `createServerClient`), so
54
+ * pass `token` to run as the signed-in user. For several reads in one request,
55
+ * prefer holding one `createServerClient` and calling `.query()` yourself to
56
+ * avoid rebuilding the transport each time. Errors propagate.
57
+ */
40
58
  declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
41
59
  /**
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
- */
60
+ * Run a mutation once on the server and return its result. Server-side calls go
61
+ * straight over HTTP RPC — the offline queue and optimistic-update machinery are
62
+ * client-only and never engage here. Errors propagate.
63
+ */
46
64
  declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
47
65
  /**
48
- * Run an action once on the server and return its result. Errors propagate.
49
- */
66
+ * Run an action once on the server and return its result. Errors propagate.
67
+ */
50
68
  declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
51
69
  export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
package/dist/server.d.ts CHANGED
@@ -4,20 +4,38 @@ 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 {
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
+ * Server-side data-loading helpers for React Server Components.
10
+ *
11
+ * This module is the server half of `@lunora/react`: it carries no
12
+ * `"use client"` directive, opens no WebSocket, and touches no browser globals,
13
+ * so it is safe to import from an RSC / Next.js Server Component. The browser
14
+ * hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
15
+ * `@lunora/react`, which is a client boundary.
16
+ *
17
+ * Two flows are supported, mirroring the two common RSC patterns. First,
18
+ * hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
19
+ * seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
20
+ * the client renders with data on the first paint and a live WS subscription
21
+ * attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
22
+ * serializable `Preloaded` value you hand to a client component that calls
23
+ * `usePreloadedQuery`.
24
+ */
25
+ type L as LunoraQueryOptions, l as lunoraQueryOptions } from "./packem_shared/query-options.d-CdgGQ9s4.js";
26
+ /**
27
+ * Run a query on the server and seed `queryClient` with the result under the
28
+ * same key the client hooks use (see `lunoraQueryKey`), so a later
29
+ * `useQuery(fn, args)` reads it straight from the hydrated cache — no loading
30
+ * flash, no duplicate fetch on the client.
31
+ *
32
+ * Pair it with TanStack's `dehydrate` + `HydrationBoundary` (both re-exported
33
+ * from this module): prefetch into a fresh `QueryClient`, `dehydrate` it, wrap
34
+ * the client subtree in `HydrationBoundary`, and the client hooks pick the value
35
+ * up from cache. Errors propagate — wrap the call if you'd rather render a
36
+ * fallback than fail the server render. Drop the `await` for fire-and-forget
37
+ * prefetch when you don't need the data present on the very first paint.
38
+ */
21
39
  declare const prefetchQuery: <F extends FunctionReference>(queryClient: QueryClient, client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
22
40
  shardKey?: string;
23
41
  }) => Promise<void>;
@@ -27,25 +45,25 @@ interface ServerCallOptions {
27
45
  shardKey?: string;
28
46
  }
29
47
  /**
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
- */
48
+ * Run a query once on the server and return its result — the standalone
49
+ * counterpart to `prefetchQuery`/`preloadQuery` for when you just want the data
50
+ * inline in a Server Component (e.g. to compute metadata or branch on a value)
51
+ * rather than seed a cache or hand a `Preloaded` to the client.
52
+ *
53
+ * Builds a fresh request-scoped client per call (see `createServerClient`), so
54
+ * pass `token` to run as the signed-in user. For several reads in one request,
55
+ * prefer holding one `createServerClient` and calling `.query()` yourself to
56
+ * avoid rebuilding the transport each time. Errors propagate.
57
+ */
40
58
  declare const fetchQuery: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
41
59
  /**
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
- */
60
+ * Run a mutation once on the server and return its result. Server-side calls go
61
+ * straight over HTTP RPC — the offline queue and optimistic-update machinery are
62
+ * client-only and never engage here. Errors propagate.
63
+ */
46
64
  declare const fetchMutation: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
47
65
  /**
48
- * Run an action once on the server and return its result. Errors propagate.
49
- */
66
+ * Run an action once on the server and return its result. Errors propagate.
67
+ */
50
68
  declare const fetchAction: <F extends FunctionReference>(options: ServerClientOptions, function_: F, args: ArgsOf<F>, callOptions?: ServerCallOptions) => Promise<ReturnOf<F>>;
51
69
  export { ServerCallOptions, fetchAction, fetchMutation, fetchQuery, prefetchQuery };
package/dist/server.mjs CHANGED
@@ -1,31 +1 @@
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-B5eRQCbR.mjs';
4
- export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-Cij4KWBK.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 };
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-By_ZIdza.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-BVgQsR9d.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};
@@ -0,0 +1,23 @@
1
+ export { RestrictionError, UploadControl, UploadError,
2
+ /**
3
+ * `@lunora/react/upload` — end-user file-upload hooks.
4
+ *
5
+ * A thin re-export of `@visulima/storage-client`'s React upload hooks (Lunora
6
+ * does not hand-roll the uploader). `useUpload` auto-selects TUS / chunked-REST /
7
+ * multipart by file size; the TUS path gives live progress, pause/resume and
8
+ * resume-after-a-dropped-connection. Point the hook's endpoint at a route backed
9
+ * by `@lunora/storage/upload`'s RLS-gated handler — end-user uploads gated by
10
+ * _your_ per-user policy, not an `adminToken`.
11
+ *
12
+ * ### TanStack Query
13
+ *
14
+ * The upload hooks re-exported here (`useUpload`, `useMultipartUpload`,
15
+ * `useTusUpload`, `useChunkedRestUpload`, `useFileInput`, `usePasteUpload`) hold
16
+ * their own state and need no `QueryClientProvider`. `@visulima/storage-client`'s
17
+ * _data_ hooks (`useGetFileList` etc.) do use TanStack Query — and `LunoraProvider`
18
+ * already mounts a `QueryClient`, so they work inside a Lunora app without extra
19
+ * wiring. That is the reconciliation: Lunora's own `useQuery` and the visulima
20
+ * upload hooks coexist because the upload hooks never touch the query cache.
21
+ */
22
+ type UploadRestrictions } from '@visulima/storage-client';
23
+ export { type UploadMethod, type UploadResult, type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
@@ -0,0 +1,23 @@
1
+ export { RestrictionError, UploadControl, UploadError,
2
+ /**
3
+ * `@lunora/react/upload` — end-user file-upload hooks.
4
+ *
5
+ * A thin re-export of `@visulima/storage-client`'s React upload hooks (Lunora
6
+ * does not hand-roll the uploader). `useUpload` auto-selects TUS / chunked-REST /
7
+ * multipart by file size; the TUS path gives live progress, pause/resume and
8
+ * resume-after-a-dropped-connection. Point the hook's endpoint at a route backed
9
+ * by `@lunora/storage/upload`'s RLS-gated handler — end-user uploads gated by
10
+ * _your_ per-user policy, not an `adminToken`.
11
+ *
12
+ * ### TanStack Query
13
+ *
14
+ * The upload hooks re-exported here (`useUpload`, `useMultipartUpload`,
15
+ * `useTusUpload`, `useChunkedRestUpload`, `useFileInput`, `usePasteUpload`) hold
16
+ * their own state and need no `QueryClientProvider`. `@visulima/storage-client`'s
17
+ * _data_ hooks (`useGetFileList` etc.) do use TanStack Query — and `LunoraProvider`
18
+ * already mounts a `QueryClient`, so they work inside a Lunora app without extra
19
+ * wiring. That is the reconciliation: Lunora's own `useQuery` and the visulima
20
+ * upload hooks coexist because the upload hooks never touch the query cache.
21
+ */
22
+ type UploadRestrictions } from '@visulima/storage-client';
23
+ export { type UploadMethod, type UploadResult, type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/react';
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{RestrictionError as r,UploadControl as p,UploadError as l}from"@visulima/storage-client";import{useChunkedRestUpload as t,useFileInput as u,useMultipartUpload as a,usePasteUpload as d,useTusUpload as U,useUpload as i}from"@visulima/storage-client/react";export{r as RestrictionError,p as UploadControl,l as UploadError,t as useChunkedRestUpload,u as useFileInput,a as useMultipartUpload,d as usePasteUpload,U as useTusUpload,i as useUpload};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-alpha.90",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -39,18 +39,28 @@
39
39
  "types": "./dist/index.d.ts",
40
40
  "import": "./dist/index.mjs"
41
41
  },
42
+ "./payment": {
43
+ "types": "./dist/payment.d.ts",
44
+ "import": "./dist/payment.mjs"
45
+ },
42
46
  "./server": {
43
47
  "types": "./dist/server.d.ts",
44
48
  "import": "./dist/server.mjs"
45
49
  },
50
+ "./upload": {
51
+ "types": "./dist/upload.d.ts",
52
+ "import": "./dist/upload.mjs"
53
+ },
46
54
  "./package.json": "./package.json"
47
55
  },
48
56
  "publishConfig": {
49
57
  "access": "public"
50
58
  },
51
59
  "dependencies": {
52
- "@lunora/client": "1.0.0-alpha.7",
53
- "@lunora/ratelimit": "1.0.0-alpha.3"
60
+ "@lunora/client": "1.0.0-alpha.85",
61
+ "@lunora/errors": "1.0.0-alpha.34",
62
+ "@lunora/ratelimit": "1.0.0-alpha.43",
63
+ "@visulima/storage-client": "1.0.2"
54
64
  },
55
65
  "peerDependencies": {
56
66
  "@tanstack/react-query": "^5.101.0",
@@ -65,7 +75,7 @@
65
75
  "optional": false
66
76
  },
67
77
  "react-dom": {
68
- "optional": false
78
+ "optional": true
69
79
  }
70
80
  },
71
81
  "engines": {
@@ -1,33 +0,0 @@
1
- 'use client';
2
- import { useAuthState } from './useAuthState-BiGhtSCs.mjs';
3
-
4
- const Authenticated = (t0) => {
5
- const {
6
- children
7
- } = t0;
8
- const {
9
- isAuthenticated
10
- } = useAuthState();
11
- return isAuthenticated ? children : void 0;
12
- };
13
- const Unauthenticated = (t0) => {
14
- const {
15
- children
16
- } = t0;
17
- const {
18
- isAuthenticated,
19
- isLoading
20
- } = useAuthState();
21
- return !isLoading && !isAuthenticated ? children : void 0;
22
- };
23
- const AuthLoading = (t0) => {
24
- const {
25
- children
26
- } = t0;
27
- const {
28
- isLoading
29
- } = useAuthState();
30
- return isLoading ? children : void 0;
31
- };
32
-
33
- export { AuthLoading, Authenticated, Unauthenticated };
@@ -1,185 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useState, useCallback } from 'react';
4
- import { jsxDEV } from 'react/jsx-dev-runtime';
5
-
6
- const useCheckout = (trigger) => {
7
- const [pending, setPending] = useState(false);
8
- const [error, setError] = useState(void 0);
9
- const checkout = useCallback(async () => {
10
- setPending(true);
11
- setError(void 0);
12
- try {
13
- const target = await trigger();
14
- const {
15
- url
16
- } = target;
17
- globalThis.location.assign(url);
18
- } catch (error_) {
19
- const normalized = error_ instanceof Error ? error_ : new Error(String(error_));
20
- setError(normalized);
21
- throw normalized;
22
- } finally {
23
- setPending(false);
24
- }
25
- }, [trigger]);
26
- return {
27
- checkout,
28
- error,
29
- pending
30
- };
31
- };
32
- const RedirectButton = (t0) => {
33
- const $ = c(11);
34
- const {
35
- "aria-label": ariaLabel,
36
- children,
37
- className,
38
- disabled,
39
- onError,
40
- title,
41
- trigger
42
- } = t0;
43
- const {
44
- checkout,
45
- pending
46
- } = useCheckout(trigger);
47
- let t1;
48
- if ($[0] !== checkout || $[1] !== onError) {
49
- t1 = () => {
50
- checkout().catch((error) => {
51
- const normalized = error instanceof Error ? error : new Error(String(error));
52
- onError?.(normalized);
53
- });
54
- };
55
- $[0] = checkout;
56
- $[1] = onError;
57
- $[2] = t1;
58
- } else {
59
- t1 = $[2];
60
- }
61
- const handleClick = t1;
62
- const t2 = disabled === true || pending;
63
- let t3;
64
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== handleClick || $[7] !== pending || $[8] !== t2 || $[9] !== title) {
65
- t3 = /* @__PURE__ */ jsxDEV("button", {
66
- "aria-busy": pending,
67
- "aria-label": ariaLabel,
68
- className,
69
- disabled: t2,
70
- onClick: handleClick,
71
- title,
72
- type: "button",
73
- children
74
- }, void 0, false);
75
- $[3] = ariaLabel;
76
- $[4] = children;
77
- $[5] = className;
78
- $[6] = handleClick;
79
- $[7] = pending;
80
- $[8] = t2;
81
- $[9] = title;
82
- $[10] = t3;
83
- } else {
84
- t3 = $[10];
85
- }
86
- return t3;
87
- };
88
- const CheckoutButton = (t0) => {
89
- const $ = c(11);
90
- let onCheckout;
91
- let rest;
92
- if ($[0] !== t0) {
93
- ({
94
- onCheckout,
95
- ...rest
96
- } = t0);
97
- $[0] = t0;
98
- $[1] = onCheckout;
99
- $[2] = rest;
100
- } else {
101
- onCheckout = $[1];
102
- rest = $[2];
103
- }
104
- const {
105
- "aria-label": ariaLabel,
106
- children,
107
- className,
108
- disabled,
109
- onError,
110
- title
111
- } = rest;
112
- let t1;
113
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onCheckout || $[8] !== onError || $[9] !== title) {
114
- t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
115
- "aria-label": ariaLabel,
116
- className,
117
- disabled,
118
- onError,
119
- title,
120
- trigger: onCheckout,
121
- children
122
- }, void 0, false);
123
- $[3] = ariaLabel;
124
- $[4] = children;
125
- $[5] = className;
126
- $[6] = disabled;
127
- $[7] = onCheckout;
128
- $[8] = onError;
129
- $[9] = title;
130
- $[10] = t1;
131
- } else {
132
- t1 = $[10];
133
- }
134
- return t1;
135
- };
136
- const CustomerPortalButton = (t0) => {
137
- const $ = c(11);
138
- let onPortal;
139
- let rest;
140
- if ($[0] !== t0) {
141
- ({
142
- onPortal,
143
- ...rest
144
- } = t0);
145
- $[0] = t0;
146
- $[1] = onPortal;
147
- $[2] = rest;
148
- } else {
149
- onPortal = $[1];
150
- rest = $[2];
151
- }
152
- const {
153
- "aria-label": ariaLabel,
154
- children,
155
- className,
156
- disabled,
157
- onError,
158
- title
159
- } = rest;
160
- let t1;
161
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onError || $[8] !== onPortal || $[9] !== title) {
162
- t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
163
- "aria-label": ariaLabel,
164
- className,
165
- disabled,
166
- onError,
167
- title,
168
- trigger: onPortal,
169
- children
170
- }, void 0, false);
171
- $[3] = ariaLabel;
172
- $[4] = children;
173
- $[5] = className;
174
- $[6] = disabled;
175
- $[7] = onError;
176
- $[8] = onPortal;
177
- $[9] = title;
178
- $[10] = t1;
179
- } else {
180
- t1 = $[10];
181
- }
182
- return t1;
183
- };
184
-
185
- export { CheckoutButton, CustomerPortalButton, useCheckout };
@@ -1,80 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { QueryClientContext, QueryClientProvider, QueryClient } from '@tanstack/react-query';
4
- import { use, useState, createContext } from 'react';
5
- import { jsxDEV } from 'react/jsx-dev-runtime';
6
-
7
- const LunoraContext = /* @__PURE__ */ createContext(null);
8
- const createDefaultQueryClient = () => new QueryClient({
9
- defaultOptions: {
10
- mutations: {
11
- retry: 0
12
- },
13
- queries: {
14
- gcTime: 5 * 6e4,
15
- retry: 0,
16
- staleTime: Number.POSITIVE_INFINITY
17
- }
18
- }
19
- });
20
- const LunoraProvider = (t0) => {
21
- const $ = c(9);
22
- const {
23
- children,
24
- client,
25
- queryClient
26
- } = t0;
27
- const parentQueryClient = use(QueryClientContext);
28
- let t1;
29
- if ($[0] !== parentQueryClient || $[1] !== queryClient) {
30
- t1 = () => queryClient ?? parentQueryClient ?? createDefaultQueryClient();
31
- $[0] = parentQueryClient;
32
- $[1] = queryClient;
33
- $[2] = t1;
34
- } else {
35
- t1 = $[2];
36
- }
37
- const [internalClient] = useState(t1);
38
- const effectiveClient = queryClient ?? parentQueryClient ?? internalClient;
39
- if (!effectiveClient) {
40
- throw new Error("LunoraProvider: failed to resolve a QueryClient");
41
- }
42
- let t2;
43
- if ($[3] !== children || $[4] !== client) {
44
- t2 = /* @__PURE__ */ jsxDEV(LunoraContext, {
45
- value: client,
46
- children
47
- }, void 0, false);
48
- $[3] = children;
49
- $[4] = client;
50
- $[5] = t2;
51
- } else {
52
- t2 = $[5];
53
- }
54
- const content = t2;
55
- if (parentQueryClient === effectiveClient) {
56
- return content;
57
- }
58
- let t3;
59
- if ($[6] !== content || $[7] !== effectiveClient) {
60
- t3 = /* @__PURE__ */ jsxDEV(QueryClientProvider, {
61
- client: effectiveClient,
62
- children: content
63
- }, void 0, false);
64
- $[6] = content;
65
- $[7] = effectiveClient;
66
- $[8] = t3;
67
- } else {
68
- t3 = $[8];
69
- }
70
- return t3;
71
- };
72
- const useLunora = () => {
73
- const client = use(LunoraContext);
74
- if (!client) {
75
- throw new Error("useLunora must be used inside <LunoraProvider />");
76
- }
77
- return client;
78
- };
79
-
80
- export { LunoraProvider, useLunora };