@lunora/react 1.0.0-alpha.30 → 1.0.0-alpha.301
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 +201 -104
- package/README.md +31 -21
- package/dist/index.d.mts +603 -170
- package/dist/index.d.ts +603 -170
- package/dist/index.mjs +1 -26
- package/dist/packem_shared/AuthLoading-DgQHaQD5.mjs +2 -0
- package/dist/packem_shared/LunoraProvider-0PzN8244.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-DbwkdExV.mjs +2 -0
- package/dist/packem_shared/lunora-provider-BMJTPKMP.mjs +2 -0
- package/dist/packem_shared/query-core-C9_ReCKt.mjs +2 -0
- package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
- package/dist/packem_shared/use-paginated-core-BjpWBr46.mjs +2 -0
- package/dist/packem_shared/useAction-BGTQyx5l.mjs +2 -0
- package/dist/packem_shared/useAgent-BW4uKe79.mjs +2 -0
- package/dist/packem_shared/useAgentApprovals-VbOnL2Lx.mjs +2 -0
- package/dist/packem_shared/useAgentChat-DjLC2W3L.mjs +2 -0
- package/dist/packem_shared/useAgentState-CNZ5F4mc.mjs +2 -0
- package/dist/packem_shared/useAgentToolEvents-dndcx99y.mjs +2 -0
- package/dist/packem_shared/useAuth-C1_ruDmE.mjs +2 -0
- package/dist/packem_shared/useAuthSessions-Cv3RRW_S.mjs +2 -0
- package/dist/packem_shared/useAuthState-DZhCIjSA.mjs +2 -0
- package/dist/packem_shared/useClientQuery-D-c8YM6Q.mjs +2 -0
- package/dist/packem_shared/useConnectionStatus-CAmQqRpD.mjs +2 -0
- package/dist/packem_shared/useFlag-CWjaNeAp.mjs +2 -0
- package/dist/packem_shared/useHttpStream-C-VR6P1E.mjs +2 -0
- package/dist/packem_shared/useInfiniteQuery-BIkpHK0e.mjs +2 -0
- package/dist/packem_shared/useLiveTopic-Cp5b1ncm.mjs +2 -0
- package/dist/packem_shared/useMutation-D6p61C2U.mjs +2 -0
- package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
- package/dist/packem_shared/usePaginatedQuery-B7tBY2XC.mjs +2 -0
- package/dist/packem_shared/usePresence-dgOxESVW.mjs +2 -0
- package/dist/packem_shared/useQuery-DMSZbdFz.mjs +2 -0
- package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
- package/dist/packem_shared/useStream-B_XzhM-6.mjs +2 -0
- package/dist/packem_shared/useSubscription-CRqptgB_.mjs +2 -0
- package/dist/packem_shared/useSuspenseQuery-B9DrM8Kw.mjs +2 -0
- package/dist/packem_shared/useVoiceAgent-BHkPJWuv.mjs +2 -0
- package/dist/payment.d.mts +107 -0
- package/dist/payment.d.ts +107 -0
- package/dist/payment.mjs +2 -0
- package/dist/server.d.mts +74 -2
- package/dist/server.d.ts +74 -2
- package/dist/server.mjs +1 -31
- package/dist/upload.d.mts +24 -0
- package/dist/upload.d.ts +24 -0
- package/dist/upload.mjs +2 -0
- package/package.json +15 -5
- package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
- package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
- package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
- package/dist/packem_shared/cache-JeuDAXfE.mjs +0 -80
- package/dist/packem_shared/hydratePreloaded-2omLtadR.mjs +0 -54
- package/dist/packem_shared/lunoraQueryOptions-CefbPBId.mjs +0 -16
- package/dist/packem_shared/query-key-LGnArBTB.mjs +0 -13
- package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +0 -38
- package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +0 -38
- package/dist/packem_shared/stable-key-DePnevIy.mjs +0 -38
- package/dist/packem_shared/use-paginated-core-xxvd1YA0.mjs +0 -179
- package/dist/packem_shared/useAgent-BNLlIYHz.mjs +0 -101
- package/dist/packem_shared/useAgentChat-0cebQe7-.mjs +0 -304
- package/dist/packem_shared/useAgentState-Cqyd3Dfy.mjs +0 -37
- package/dist/packem_shared/useAgentToolEvents-gF7U4_KY.mjs +0 -129
- package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
- package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
- package/dist/packem_shared/useClientQuery-DIkNT4QA.mjs +0 -17
- package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
- package/dist/packem_shared/useFlag-Beyeiq2b.mjs +0 -128
- package/dist/packem_shared/useHttpStream-oc4s1pMy.mjs +0 -127
- package/dist/packem_shared/useInfiniteQuery-CJNw1XaZ.mjs +0 -97
- package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
- package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
- package/dist/packem_shared/usePaginatedQuery-DWzydaVR.mjs +0 -46
- package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
- package/dist/packem_shared/useQuery-CE8_QUgh.mjs +0 -77
- package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
- package/dist/packem_shared/useStream-GYNgc9J5.mjs +0 -128
- package/dist/packem_shared/useSubscription-DcDlvVuI.mjs +0 -139
- package/dist/packem_shared/useVoiceAgent-w7fzAMSB.mjs +0 -422
- package/dist/packem_shared/wire-key-Bg8BJ8YM.mjs +0 -101
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,82 @@
|
|
|
1
1
|
import { FunctionReference, ArgsOf, ReturnOf, LunoraClient } from '@lunora/client';
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
/**
|
|
4
|
+
* Server-side data-loading helpers for React Server Components.
|
|
5
|
+
*
|
|
6
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
7
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
8
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
9
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
10
|
+
* `@lunora/react`, which is a client boundary.
|
|
11
|
+
*
|
|
12
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
13
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
14
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
15
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
16
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
17
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
18
|
+
* `usePreloadedQuery`.
|
|
19
|
+
*/
|
|
20
|
+
type ArgsOf,
|
|
21
|
+
/**
|
|
22
|
+
* Server-side data-loading helpers for React Server Components.
|
|
23
|
+
*
|
|
24
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
25
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
26
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
27
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
28
|
+
* `@lunora/react`, which is a client boundary.
|
|
29
|
+
*
|
|
30
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
31
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
32
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
33
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
34
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
35
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
36
|
+
* `usePreloadedQuery`.
|
|
37
|
+
*/
|
|
38
|
+
type FunctionReference,
|
|
39
|
+
/**
|
|
40
|
+
* Server-side data-loading helpers for React Server Components.
|
|
41
|
+
*
|
|
42
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
43
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
44
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
45
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
46
|
+
* `@lunora/react`, which is a client boundary.
|
|
47
|
+
*
|
|
48
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
49
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
50
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
51
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
52
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
53
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
54
|
+
* `usePreloadedQuery`.
|
|
55
|
+
*/
|
|
56
|
+
type Preloaded,
|
|
57
|
+
/**
|
|
58
|
+
* Server-side data-loading helpers for React Server Components.
|
|
59
|
+
*
|
|
60
|
+
* This module is the server half of `@lunora/react`: it carries no
|
|
61
|
+
* `"use client"` directive, opens no WebSocket, and touches no browser globals,
|
|
62
|
+
* so it is safe to import from an RSC / Next.js Server Component. The browser
|
|
63
|
+
* hooks (`useQuery`, `usePreloadedQuery`, …) live in the package root,
|
|
64
|
+
* `@lunora/react`, which is a client boundary.
|
|
65
|
+
*
|
|
66
|
+
* Two flows are supported, mirroring the two common RSC patterns. First,
|
|
67
|
+
* hydrating the TanStack cache: `prefetchQuery` runs the query on the server and
|
|
68
|
+
* seeds a `QueryClient` under the exact key the client `useQuery` reads back, so
|
|
69
|
+
* the client renders with data on the first paint and a live WS subscription
|
|
70
|
+
* attaches on mount. Second, the explicit-token flow: `preloadQuery` returns a
|
|
71
|
+
* serializable `Preloaded` value you hand to a client component that calls
|
|
72
|
+
* `usePreloadedQuery`.
|
|
73
|
+
*/
|
|
74
|
+
type ReturnOf, preloadQuery, preloadedQueryResult } from '@lunora/client';
|
|
3
75
|
import { ServerClientOptions } from '@lunora/client/ssr';
|
|
4
76
|
export { type AuthLike, type HeadersSource, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
5
77
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
78
|
export { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
|
7
|
-
export { type
|
|
79
|
+
export { type LunoraQueryOptions, lunoraQueryOptions } from '@lunora/client/query';
|
|
8
80
|
/**
|
|
9
81
|
* Run a query on the server and seed `queryClient` with the result under the
|
|
10
82
|
* same key the client hooks use (see `lunoraQueryKey`), so a later
|
package/dist/server.mjs
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { createServerClient, deserializePreloaded, getServerSession, serializePreloaded } from '@lunora/client/ssr';
|
|
3
|
-
import { l as lunoraQueryKey } from './packem_shared/query-key-LGnArBTB.mjs';
|
|
4
|
-
export { lunoraQueryOptions } from './packem_shared/lunoraQueryOptions-CefbPBId.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{preloadQuery as S,preloadedQueryResult as q}from"@lunora/client";import{lunoraQueryKey as d}from"@lunora/client/query";import{lunoraQueryOptions as N}from"@lunora/client/query";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,N as lunoraQueryOptions,u as prefetchQuery,S as preloadQuery,q 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';
|
package/dist/upload.d.ts
ADDED
|
@@ -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';
|
package/dist/upload.mjs
ADDED
|
@@ -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.
|
|
3
|
+
"version": "1.0.0-alpha.301",
|
|
4
4
|
"description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"homepage": "https://lunora.sh",
|
|
16
16
|
"bugs": "https://github.com/anolilab/lunora/issues",
|
|
17
|
-
"license": "
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
18
|
"author": {
|
|
19
19
|
"name": "Daniel Bannert",
|
|
20
20
|
"email": "d.bannert@anolilab.de"
|
|
@@ -39,19 +39,29 @@
|
|
|
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/
|
|
53
|
-
"@lunora/
|
|
54
|
-
"@lunora/
|
|
60
|
+
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
61
|
+
"@lunora/ratelimit": "1.0.0-alpha.196",
|
|
62
|
+
"@lunora/wire": "1.0.0-alpha.6",
|
|
63
|
+
"@visulima/storage-client": "1.0.9",
|
|
64
|
+
"@lunora/client": "1.0.0-alpha.291"
|
|
55
65
|
},
|
|
56
66
|
"peerDependencies": {
|
|
57
67
|
"@tanstack/react-query": "^5.101.0",
|
|
@@ -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 };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { k as keyHash } from './query-key-LGnArBTB.mjs';
|
|
2
|
-
|
|
3
|
-
class LunoraSubscriptionRegistry {
|
|
4
|
-
constructor(client) {
|
|
5
|
-
this.client = client;
|
|
6
|
-
}
|
|
7
|
-
client;
|
|
8
|
-
entries = /* @__PURE__ */ new Map();
|
|
9
|
-
/**
|
|
10
|
-
* Hash a TanStack `queryKey` to the internal registry index. Exposed so a
|
|
11
|
-
* hook can look up the registry without re-implementing the hash.
|
|
12
|
-
*/
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this -- instance method by design: callers reach the hash through a registry handle rather than importing the module-level helper.
|
|
14
|
-
keyOf(queryKey) {
|
|
15
|
-
return keyHash(queryKey);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Attach a consumer to the live subscription for `queryKey`. The first
|
|
19
|
-
* attach opens the underlying WS subscription; subsequent attaches reuse
|
|
20
|
-
* it (refcount-bumped). Returns the detach function — call it exactly once
|
|
21
|
-
* per attach.
|
|
22
|
-
*/
|
|
23
|
-
attach(queryClient, queryKey, function_, args, shardKey, options = {}) {
|
|
24
|
-
const key = keyHash(queryKey);
|
|
25
|
-
let entry = this.entries.get(key);
|
|
26
|
-
if (!entry) {
|
|
27
|
-
entry = {
|
|
28
|
-
pollTimer: void 0,
|
|
29
|
-
refCount: 0,
|
|
30
|
-
unsubscribe: void 0
|
|
31
|
-
};
|
|
32
|
-
this.entries.set(key, entry);
|
|
33
|
-
try {
|
|
34
|
-
entry.unsubscribe = this.client.subscribe(function_, args, (value) => {
|
|
35
|
-
queryClient.setQueryData(queryKey, value);
|
|
36
|
-
}, {
|
|
37
|
-
shardKey
|
|
38
|
-
});
|
|
39
|
-
} catch {
|
|
40
|
-
entry.pollTimer = setInterval(() => {
|
|
41
|
-
queryClient.invalidateQueries({
|
|
42
|
-
queryKey
|
|
43
|
-
}).catch(() => {
|
|
44
|
-
});
|
|
45
|
-
}, options.pollIntervalMs ?? 5e3);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
entry.refCount += 1;
|
|
49
|
-
let detached = false;
|
|
50
|
-
return () => {
|
|
51
|
-
if (detached) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
detached = true;
|
|
55
|
-
const current = this.entries.get(key);
|
|
56
|
-
if (!current) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
current.refCount -= 1;
|
|
60
|
-
if (current.refCount <= 0) {
|
|
61
|
-
current.unsubscribe?.();
|
|
62
|
-
if (current.pollTimer) {
|
|
63
|
-
clearInterval(current.pollTimer);
|
|
64
|
-
}
|
|
65
|
-
this.entries.delete(key);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const registryByClient = /* @__PURE__ */ new WeakMap();
|
|
71
|
-
const getSubscriptionRegistry = (client) => {
|
|
72
|
-
let registry = registryByClient.get(client);
|
|
73
|
-
if (!registry) {
|
|
74
|
-
registry = new LunoraSubscriptionRegistry(client);
|
|
75
|
-
registryByClient.set(client, registry);
|
|
76
|
-
}
|
|
77
|
-
return registry;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export { getSubscriptionRegistry as g };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { c } from 'react/compiler-runtime';
|
|
3
|
-
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
import { g as getSubscriptionRegistry } from './cache-JeuDAXfE.mjs';
|
|
6
|
-
import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
|
|
7
|
-
import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-LGnArBTB.mjs';
|
|
8
|
-
|
|
9
|
-
const usePreloadedQuery = function(preloaded) {
|
|
10
|
-
const $ = c(4);
|
|
11
|
-
const client = useLunora();
|
|
12
|
-
const queryClient = useQueryClient();
|
|
13
|
-
const {
|
|
14
|
-
args,
|
|
15
|
-
functionPath,
|
|
16
|
-
shardKey,
|
|
17
|
-
value
|
|
18
|
-
} = preloaded;
|
|
19
|
-
const functionRef = {
|
|
20
|
-
__lunoraRef: functionPath
|
|
21
|
-
};
|
|
22
|
-
const queryKey = lunoraQueryKey(functionRef, args, shardKey);
|
|
23
|
-
const {
|
|
24
|
-
data
|
|
25
|
-
} = useQuery({
|
|
26
|
-
initialData: value,
|
|
27
|
-
queryFn: () => client.query(functionRef, args, {
|
|
28
|
-
shardKey
|
|
29
|
-
}),
|
|
30
|
-
queryKey,
|
|
31
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
32
|
-
});
|
|
33
|
-
const t0 = serializeQueryKey(queryKey);
|
|
34
|
-
let t1;
|
|
35
|
-
if ($[0] !== client || $[1] !== queryClient || $[2] !== t0) {
|
|
36
|
-
t1 = [client, queryClient, t0];
|
|
37
|
-
$[0] = client;
|
|
38
|
-
$[1] = queryClient;
|
|
39
|
-
$[2] = t0;
|
|
40
|
-
$[3] = t1;
|
|
41
|
-
} else {
|
|
42
|
-
t1 = $[3];
|
|
43
|
-
}
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const registry = getSubscriptionRegistry(client);
|
|
46
|
-
return registry.attach(queryClient, queryKey, functionRef, args, shardKey);
|
|
47
|
-
}, t1);
|
|
48
|
-
return data === void 0 ? value : data;
|
|
49
|
-
};
|
|
50
|
-
const hydratePreloaded = function(preloaded) {
|
|
51
|
-
return usePreloadedQuery(preloaded);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { usePreloadedQuery as default, hydratePreloaded };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { l as lunoraQueryKey } from './query-key-LGnArBTB.mjs';
|
|
2
|
-
|
|
3
|
-
const lunoraQueryOptions = (client, function_, args, options = {}) => {
|
|
4
|
-
const argsRecord = args ?? {};
|
|
5
|
-
return {
|
|
6
|
-
queryFn: () => client.query(function_, argsRecord, {
|
|
7
|
-
shardKey: options.shardKey
|
|
8
|
-
}),
|
|
9
|
-
queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
|
|
10
|
-
// Lunora is push-driven: the value never goes stale on a timer. For
|
|
11
|
-
// reactivity use `useQuery`; this adapter is a one-shot/suspense read.
|
|
12
|
-
staleTime: Number.POSITIVE_INFINITY
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { lunoraQueryOptions };
|