@lunora/react 1.0.0-alpha.19 → 1.0.0-alpha.190

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 (71) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +25 -18
  3. package/dist/index.d.mts +1221 -358
  4. package/dist/index.d.ts +1221 -358
  5. package/dist/index.mjs +1 -19
  6. package/dist/packem_shared/AuthLoading-BZD1whno.mjs +2 -0
  7. package/dist/packem_shared/LunoraProvider-4XBOJ6Vx.mjs +1 -0
  8. package/dist/packem_shared/hydratePreloaded-Dw5X4aQP.mjs +2 -0
  9. package/dist/packem_shared/lunora-provider-DsXARssD.mjs +2 -0
  10. package/dist/packem_shared/lunoraQueryOptions-BuCFB9h1.mjs +1 -0
  11. package/dist/packem_shared/query-key-QcTqsWNc.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/stream-state-abygFxmy.mjs +1 -0
  15. package/dist/packem_shared/use-paginated-core-BFErPUQG.mjs +2 -0
  16. package/dist/packem_shared/useAction-CfzLxuvQ.mjs +2 -0
  17. package/dist/packem_shared/useAgent-fHMUCenH.mjs +2 -0
  18. package/dist/packem_shared/useAgentChat-BAN74BAJ.mjs +2 -0
  19. package/dist/packem_shared/useAgentState-BNuCb9iH.mjs +2 -0
  20. package/dist/packem_shared/useAgentToolEvents-BC-hiuYS.mjs +2 -0
  21. package/dist/packem_shared/useAuth-BPg3-tum.mjs +2 -0
  22. package/dist/packem_shared/useAuthSessions-DumEKLKj.mjs +2 -0
  23. package/dist/packem_shared/useAuthState-DUqteFyj.mjs +2 -0
  24. package/dist/packem_shared/useClientQuery-CSO7y12f.mjs +2 -0
  25. package/dist/packem_shared/useConnectionStatus-CcEKji7W.mjs +2 -0
  26. package/dist/packem_shared/useFlag-QOEvZAyV.mjs +2 -0
  27. package/dist/packem_shared/useHttpStream-CODrgO1l.mjs +2 -0
  28. package/dist/packem_shared/useInfiniteQuery-Ct_w49zB.mjs +2 -0
  29. package/dist/packem_shared/useMutation-BaDjKEXu.mjs +2 -0
  30. package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
  31. package/dist/packem_shared/usePaginatedQuery-Dswd-75x.mjs +2 -0
  32. package/dist/packem_shared/usePresence-C-yVPG30.mjs +2 -0
  33. package/dist/packem_shared/useQuery-YIz-Busa.mjs +2 -0
  34. package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
  35. package/dist/packem_shared/useStream-3ejjJfiS.mjs +2 -0
  36. package/dist/packem_shared/useSubscription-CnMN0IUI.mjs +2 -0
  37. package/dist/packem_shared/useVoiceAgent-B6iU4lhc.mjs +2 -0
  38. package/dist/payment.d.mts +103 -0
  39. package/dist/payment.d.ts +103 -0
  40. package/dist/payment.mjs +2 -0
  41. package/dist/server.d.mts +47 -29
  42. package/dist/server.d.ts +47 -29
  43. package/dist/server.mjs +1 -31
  44. package/dist/upload.d.mts +24 -0
  45. package/dist/upload.d.ts +24 -0
  46. package/dist/upload.mjs +2 -0
  47. package/package.json +14 -5
  48. package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
  49. package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
  50. package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
  51. package/dist/packem_shared/cache-BFlsXmup.mjs +0 -75
  52. package/dist/packem_shared/hydratePreloaded-Dsf9YuII.mjs +0 -54
  53. package/dist/packem_shared/lunoraQueryOptions-C3uwOTMW.mjs +0 -16
  54. package/dist/packem_shared/query-key-BmCbgidV.mjs +0 -13
  55. package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +0 -38
  56. package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +0 -38
  57. package/dist/packem_shared/stable-key-CGp4e2Ux.mjs +0 -38
  58. package/dist/packem_shared/use-paginated-core-CWSzk1J1.mjs +0 -180
  59. package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
  60. package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
  61. package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
  62. package/dist/packem_shared/useFlag-hhoN_xYA.mjs +0 -224
  63. package/dist/packem_shared/useInfiniteQuery-Dy42_srs.mjs +0 -97
  64. package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
  65. package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
  66. package/dist/packem_shared/usePaginatedQuery-Tx-B3mAP.mjs +0 -46
  67. package/dist/packem_shared/usePresence-DC8VIyLB.mjs +0 -108
  68. package/dist/packem_shared/useQuery-_fTR6DCQ.mjs +0 -54
  69. package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
  70. package/dist/packem_shared/useStream-DFuryaIC.mjs +0 -125
  71. package/dist/packem_shared/useSubscription-D38Jdyr8.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-BmCbgidV.mjs';
4
- export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-C3uwOTMW.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-QcTqsWNc.mjs";import{lunoraQueryOptions as S}from"./packem_shared/lunoraQueryOptions-BuCFB9h1.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,24 @@
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`, so Lunora's own `useQuery`
17
+ * and the visulima upload hooks coexist: the upload hooks never touch the query
18
+ * cache. `@visulima/storage-client`'s _data_ hooks (`useGetFileList` etc.) are
19
+ * not re-exported: they read files over `GET` on the upload route, which
20
+ * `@lunora/storage/upload` refuses (`405`). Read stored files through
21
+ * `ctx.storage` or a signed URL.
22
+ */
23
+ type UploadRestrictions } from '@visulima/storage-client';
24
+ 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,24 @@
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`, so Lunora's own `useQuery`
17
+ * and the visulima upload hooks coexist: the upload hooks never touch the query
18
+ * cache. `@visulima/storage-client`'s _data_ hooks (`useGetFileList` etc.) are
19
+ * not re-exported: they read files over `GET` on the upload route, which
20
+ * `@lunora/storage/upload` refuses (`405`). Read stored files through
21
+ * `ctx.storage` or a signed URL.
22
+ */
23
+ type UploadRestrictions } from '@visulima/storage-client';
24
+ 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.19",
3
+ "version": "1.0.0-alpha.190",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -39,19 +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.17",
53
- "@lunora/errors": "1.0.0-alpha.1",
54
- "@lunora/ratelimit": "1.0.0-alpha.4"
60
+ "@lunora/client": "1.0.0-alpha.178",
61
+ "@lunora/errors": "1.0.0-alpha.50",
62
+ "@lunora/ratelimit": "1.0.0-alpha.110",
63
+ "@visulima/storage-client": "1.0.5"
55
64
  },
56
65
  "peerDependencies": {
57
66
  "@tanstack/react-query": "^5.101.0",
@@ -66,7 +75,7 @@
66
75
  "optional": false
67
76
  },
68
77
  "react-dom": {
69
- "optional": false
78
+ "optional": true
70
79
  }
71
80
  },
72
81
  "engines": {
@@ -1,33 +0,0 @@
1
- 'use client';
2
- import { useAuthState } from './useAuthState-CyF35qZR.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,189 +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 safeRedirectHref = (url) => {
7
- const parsed = new URL(url, globalThis.location.href);
8
- if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
9
- throw new Error(`refusing to redirect to a non-http(s) URL: ${parsed.protocol}`);
10
- }
11
- return parsed.href;
12
- };
13
- const useCheckout = (trigger) => {
14
- const [pending, setPending] = useState(false);
15
- const [error, setError] = useState(void 0);
16
- const checkout = useCallback(async () => {
17
- setPending(true);
18
- setError(void 0);
19
- try {
20
- const target = await trigger();
21
- globalThis.location.assign(safeRedirectHref(target.url));
22
- } catch (error_) {
23
- const normalized = error_ instanceof Error ? error_ : new Error(String(error_));
24
- setError(normalized);
25
- throw normalized;
26
- } finally {
27
- setPending(false);
28
- }
29
- }, [trigger]);
30
- return {
31
- checkout,
32
- error,
33
- pending
34
- };
35
- };
36
- const RedirectButton = (t0) => {
37
- const $ = c(11);
38
- const {
39
- "aria-label": ariaLabel,
40
- children,
41
- className,
42
- disabled,
43
- onError,
44
- title,
45
- trigger
46
- } = t0;
47
- const {
48
- checkout,
49
- pending
50
- } = useCheckout(trigger);
51
- let t1;
52
- if ($[0] !== checkout || $[1] !== onError) {
53
- t1 = () => {
54
- checkout().catch((error) => {
55
- const normalized = error instanceof Error ? error : new Error(String(error));
56
- onError?.(normalized);
57
- });
58
- };
59
- $[0] = checkout;
60
- $[1] = onError;
61
- $[2] = t1;
62
- } else {
63
- t1 = $[2];
64
- }
65
- const handleClick = t1;
66
- const t2 = disabled === true || pending;
67
- let t3;
68
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== handleClick || $[7] !== pending || $[8] !== t2 || $[9] !== title) {
69
- t3 = /* @__PURE__ */ jsxDEV("button", {
70
- "aria-busy": pending,
71
- "aria-label": ariaLabel,
72
- className,
73
- disabled: t2,
74
- onClick: handleClick,
75
- title,
76
- type: "button",
77
- children
78
- }, void 0, false);
79
- $[3] = ariaLabel;
80
- $[4] = children;
81
- $[5] = className;
82
- $[6] = handleClick;
83
- $[7] = pending;
84
- $[8] = t2;
85
- $[9] = title;
86
- $[10] = t3;
87
- } else {
88
- t3 = $[10];
89
- }
90
- return t3;
91
- };
92
- const CheckoutButton = (t0) => {
93
- const $ = c(11);
94
- let onCheckout;
95
- let rest;
96
- if ($[0] !== t0) {
97
- ({
98
- onCheckout,
99
- ...rest
100
- } = t0);
101
- $[0] = t0;
102
- $[1] = onCheckout;
103
- $[2] = rest;
104
- } else {
105
- onCheckout = $[1];
106
- rest = $[2];
107
- }
108
- const {
109
- "aria-label": ariaLabel,
110
- children,
111
- className,
112
- disabled,
113
- onError,
114
- title
115
- } = rest;
116
- let t1;
117
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onCheckout || $[8] !== onError || $[9] !== title) {
118
- t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
119
- "aria-label": ariaLabel,
120
- className,
121
- disabled,
122
- onError,
123
- title,
124
- trigger: onCheckout,
125
- children
126
- }, void 0, false);
127
- $[3] = ariaLabel;
128
- $[4] = children;
129
- $[5] = className;
130
- $[6] = disabled;
131
- $[7] = onCheckout;
132
- $[8] = onError;
133
- $[9] = title;
134
- $[10] = t1;
135
- } else {
136
- t1 = $[10];
137
- }
138
- return t1;
139
- };
140
- const CustomerPortalButton = (t0) => {
141
- const $ = c(11);
142
- let onPortal;
143
- let rest;
144
- if ($[0] !== t0) {
145
- ({
146
- onPortal,
147
- ...rest
148
- } = t0);
149
- $[0] = t0;
150
- $[1] = onPortal;
151
- $[2] = rest;
152
- } else {
153
- onPortal = $[1];
154
- rest = $[2];
155
- }
156
- const {
157
- "aria-label": ariaLabel,
158
- children,
159
- className,
160
- disabled,
161
- onError,
162
- title
163
- } = rest;
164
- let t1;
165
- if ($[3] !== ariaLabel || $[4] !== children || $[5] !== className || $[6] !== disabled || $[7] !== onError || $[8] !== onPortal || $[9] !== title) {
166
- t1 = /* @__PURE__ */ jsxDEV(RedirectButton, {
167
- "aria-label": ariaLabel,
168
- className,
169
- disabled,
170
- onError,
171
- title,
172
- trigger: onPortal,
173
- children
174
- }, void 0, false);
175
- $[3] = ariaLabel;
176
- $[4] = children;
177
- $[5] = className;
178
- $[6] = disabled;
179
- $[7] = onError;
180
- $[8] = onPortal;
181
- $[9] = title;
182
- $[10] = t1;
183
- } else {
184
- t1 = $[10];
185
- }
186
- return t1;
187
- };
188
-
189
- export { CheckoutButton, CustomerPortalButton, useCheckout };
@@ -1,81 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { LunoraError } from '@lunora/errors';
4
- import { QueryClientContext, QueryClientProvider, QueryClient } from '@tanstack/react-query';
5
- import { use, useState, createContext } from 'react';
6
- import { jsxDEV } from 'react/jsx-dev-runtime';
7
-
8
- const LunoraContext = /* @__PURE__ */ createContext(null);
9
- const createDefaultQueryClient = () => new QueryClient({
10
- defaultOptions: {
11
- mutations: {
12
- retry: 0
13
- },
14
- queries: {
15
- gcTime: 5 * 6e4,
16
- retry: 0,
17
- staleTime: Number.POSITIVE_INFINITY
18
- }
19
- }
20
- });
21
- const LunoraProvider = (t0) => {
22
- const $ = c(9);
23
- const {
24
- children,
25
- client,
26
- queryClient
27
- } = t0;
28
- const parentQueryClient = use(QueryClientContext);
29
- let t1;
30
- if ($[0] !== parentQueryClient || $[1] !== queryClient) {
31
- t1 = () => queryClient ?? parentQueryClient ?? createDefaultQueryClient();
32
- $[0] = parentQueryClient;
33
- $[1] = queryClient;
34
- $[2] = t1;
35
- } else {
36
- t1 = $[2];
37
- }
38
- const [internalClient] = useState(t1);
39
- const effectiveClient = queryClient ?? parentQueryClient ?? internalClient;
40
- if (!effectiveClient) {
41
- throw new LunoraError("INTERNAL", "LunoraProvider: failed to resolve a QueryClient");
42
- }
43
- let t2;
44
- if ($[3] !== children || $[4] !== client) {
45
- t2 = /* @__PURE__ */ jsxDEV(LunoraContext, {
46
- value: client,
47
- children
48
- }, void 0, false);
49
- $[3] = children;
50
- $[4] = client;
51
- $[5] = t2;
52
- } else {
53
- t2 = $[5];
54
- }
55
- const content = t2;
56
- if (parentQueryClient === effectiveClient) {
57
- return content;
58
- }
59
- let t3;
60
- if ($[6] !== content || $[7] !== effectiveClient) {
61
- t3 = /* @__PURE__ */ jsxDEV(QueryClientProvider, {
62
- client: effectiveClient,
63
- children: content
64
- }, void 0, false);
65
- $[6] = content;
66
- $[7] = effectiveClient;
67
- $[8] = t3;
68
- } else {
69
- t3 = $[8];
70
- }
71
- return t3;
72
- };
73
- const useLunora = () => {
74
- const client = use(LunoraContext);
75
- if (!client) {
76
- throw new LunoraError("INTERNAL", "useLunora must be used inside <LunoraProvider />");
77
- }
78
- return client;
79
- };
80
-
81
- export { LunoraProvider, useLunora };