@lunora/react 1.0.0-alpha.72 → 1.0.0-alpha.74

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/README.md CHANGED
@@ -94,25 +94,25 @@ function MessageList({ room }: { room: string }) {
94
94
 
95
95
  ## Hooks
96
96
 
97
- | Hook | Returns | Notes |
98
- | -------------------------------------------------------------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------- |
99
- | `useQuery(fn, args, options?)` | `T \| undefined` | Live query; shares one WS subscription across consumers of the same key. |
100
- | `useMutation(fn)` | `{ mutate, pending, data, error, reset, withOptimisticUpdate }` | Per-call `optimistic` / `optimisticUpdate` options pass through to the client. |
101
- | `useSubscription(fn, args, options?)` | `{ data, error }` | No initial fetch — only server-pushed values. |
102
- | `usePaginatedQuery(fn, args, { initialNumItems })` | `{ results, status, isLoading, loadMore }` | Cursor-paginated feed that stays consistent under live edits. |
103
- | `useInfiniteQuery(fn, args, { initialNumItems })` | `{ pages, status, hasNextPage, fetchNextPage, … }` | Page-array variant of the same paginator. |
104
- | `usePreloadedQuery(preloaded)` | `T` | Reads a server `Preloaded` token, then goes live. |
105
- | `usePresence({ heartbeat, listPresent, roomId, … })` | present members | Drives the `definePresence` heartbeat + list functions. |
106
- | `useFlag(key, default, context?)` | flag value (live) | Live OpenFeature flag over the WS; reads `default` until the server answers. |
107
- | `useFlags(defaults, context?)` | `{ [key]: value }` | Batch variant — one live value per key in the `defaults` map. |
108
- | `useStream(fn, args, options?)` | `{ chunks, status, error, cancel }` | Consumes a streamed action response chunk by chunk. |
109
- | `useRateLimit(config, options?)` | `{ ok, disabled, retryAfter, check, consume, reset }` | Client-side mirror of a `@lunora/ratelimit` budget for instant UX. |
110
- | `useConnectionStatus()` | `ConnectionStatus` | `idle` / `connecting` / `connected` / `offline`. |
111
- | `useAuth()` | `{ user, token, setToken }` | Call `setToken(jwt)` after sign-in; RPC then carries the token. |
112
- | `useAuthState()` | `{ isAuthenticated, isLoading }` | Hydration-safe three-state gate. |
113
- | `useAgentToolEvents({ api, threadKey, … })` | `{ events }` | One agent thread's tool lifecycle: call / result / awaiting-approval / progress. |
114
- | `useVoiceAgent({ voice, threadKey, … })` | `{ status, transcript, startCall, endCall, … }` | Full-duplex voice call: mic capture, playback, live transcripts, barge-in. |
115
- | `useAuthUsers` / `useAuthSessions` / `useOrganizations` / `useImpersonate` | `{ data, error, loading, refresh }` (+ `impersonate`/`stop`) | Admin-plane auth reads for a console UI; each needs an admin-capable token. |
97
+ | Hook | Returns | Notes |
98
+ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
99
+ | `useQuery(fn, args, options?)` | `T \| undefined` | Live query; shares one WS subscription across consumers of the same key. |
100
+ | `useMutation(fn)` | `{ mutate, pending, data, error, reset, withOptimisticUpdate }` | Per-call `optimistic` / `optimisticUpdate` options pass through to the client. |
101
+ | `useSubscription(fn, args, options?)` | `{ data, error }` | No initial fetch — only server-pushed values. |
102
+ | `usePaginatedQuery(fn, args, { initialNumItems })` | `{ results, status, isLoading, loadMore }` | Cursor-paginated feed that stays consistent under live edits. |
103
+ | `useInfiniteQuery(fn, args, { initialNumItems })` | `{ pages, status, hasNextPage, fetchNextPage, … }` | Page-array variant of the same paginator. |
104
+ | `usePreloadedQuery(preloaded)` | `T` | Reads a server `Preloaded` token, then goes live. |
105
+ | `usePresence({ heartbeat, listPresent, roomId, … })` | present members | Drives the `definePresence` heartbeat + list functions. |
106
+ | `useFlag(key, default)` | flag value (live) | Live OpenFeature flag over the WS; reads `default` until the server answers. Evaluated under the socket's server-verified identity. |
107
+ | `useFlags(defaults)` | `{ [key]: value }` | Batch variant — one live value per key in the `defaults` map. |
108
+ | `useStream(fn, args, options?)` | `{ chunks, status, error, cancel }` | Consumes a streamed action response chunk by chunk. |
109
+ | `useRateLimit(config, options?)` | `{ ok, disabled, retryAfter, check, consume, reset }` | Client-side mirror of a `@lunora/ratelimit` budget for instant UX. |
110
+ | `useConnectionStatus()` | `ConnectionStatus` | `idle` / `connecting` / `connected` / `offline`. |
111
+ | `useAuth()` | `{ user, token, setToken }` | Call `setToken(jwt)` after sign-in; RPC then carries the token. |
112
+ | `useAuthState()` | `{ isAuthenticated, isLoading }` | Hydration-safe three-state gate. |
113
+ | `useAgentToolEvents({ api, threadKey, … })` | `{ events }` | One agent thread's tool lifecycle: call / result / awaiting-approval / progress. |
114
+ | `useVoiceAgent({ voice, threadKey, … })` | `{ status, transcript, startCall, endCall, … }` | Full-duplex voice call: mic capture, playback, live transcripts, barge-in. |
115
+ | `useAuthUsers` / `useAuthSessions` / `useOrganizations` / `useImpersonate` | `{ data, error, loading, hasMore, total, loadMore, refetch }` (`useImpersonate`: `{ data, error, pending, impersonate, reset }`) | Admin-plane auth reads for a console UI; each needs an admin-capable token. HTTP-only, so `refetch()` rather than a live subscription. |
116
116
 
117
117
  `Authenticated`, `Unauthenticated`, and `AuthLoading` are gate components built on `useAuthState`.
118
118
 
package/dist/index.d.mts CHANGED
@@ -749,8 +749,6 @@ declare const useClientQuery: <T extends unknown>(ref: ClientQueryRef<T>) => [T,
749
749
  * operator can tell a healthy live channel from a silently-dropped socket.
750
750
  */
751
751
  declare const useConnectionStatus: () => ConnectionStatus;
752
- /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
753
- type FlagContext = Record<string, unknown>;
754
752
  /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
755
753
  type FlagValue = boolean | number | string | {
756
754
  [key: string]: unknown;
@@ -762,25 +760,30 @@ type FlagValue = boolean | number | string | {
762
760
  * resolved value — re-pushed whenever the provider re-evaluates (e.g. a flag is
763
761
  * toggled in Cloudflare Flagship). The flag's kind is inferred from
764
762
  * `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean and
765
- * `useFlag("hero", "control")` a string. `context` supplies a per-call targeting
766
- * context merged on top of the app's default `identify` targeting key.
763
+ * `useFlag("hero", "control")` a string.
764
+ *
765
+ * The reactive channel is public, so the server evaluates every flag under the
766
+ * socket's own verified identity — the targeting key your `defineFlags({
767
+ * identify })` derives — and accepts no client-supplied targeting context. For
768
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
769
+ * mutation, or action and return the resolved value.
767
770
  *
768
771
  * Evaluation runs through whatever OpenFeature provider the app wired in
769
772
  * `lunora/flags.ts`; the read never throws — a provider error resolves the
770
773
  * default (the same fail-open contract as server-side `ctx.flags`).
771
774
  */
772
- declare const useFlag: <T extends FlagValue>(key: string, defaultValue: T, context?: FlagContext) => T;
775
+ declare const useFlag: <T extends FlagValue>(key: string, defaultValue: T) => T;
773
776
  /**
774
777
  * Subscribe to several feature flags at once, live over Lunora's WebSocket.
775
778
  *
776
779
  * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
777
780
  * default, and the result is the same-shaped record with resolved values (the
778
- * defaults until each evaluation lands). A single `context` applies to every
779
- * flag. This is the batched form of {@link useFlag} — one effect manages one
780
- * subscription per key, so it stays rules-of-hooks-safe even as the flag set
781
- * changes between renders.
781
+ * defaults until each evaluation lands). This is the batched form of
782
+ * {@link useFlag} — one effect manages one subscription per key, so it stays
783
+ * rules-of-hooks-safe even as the flag set changes between renders. Like
784
+ * {@link useFlag} it evaluates under the socket's server-verified identity only.
782
785
  */
783
- declare const useFlags: <T extends Record<string, FlagValue>>(flags: T, context?: FlagContext) => T;
786
+ declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => T;
784
787
  /** The lifecycle of a stream the hook is observing. */
785
788
  type UseStreamStatus = "complete" | "error" | "idle" | "streaming";
786
789
  /**
@@ -1262,4 +1265,4 @@ interface UseVoiceAgentResult {
1262
1265
  * `createSocket`) so the hook is drivable outside a browser.
1263
1266
  */
1264
1267
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1265
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
1268
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
package/dist/index.d.ts CHANGED
@@ -749,8 +749,6 @@ declare const useClientQuery: <T extends unknown>(ref: ClientQueryRef<T>) => [T,
749
749
  * operator can tell a healthy live channel from a silently-dropped socket.
750
750
  */
751
751
  declare const useConnectionStatus: () => ConnectionStatus;
752
- /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
753
- type FlagContext = Record<string, unknown>;
754
752
  /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
755
753
  type FlagValue = boolean | number | string | {
756
754
  [key: string]: unknown;
@@ -762,25 +760,30 @@ type FlagValue = boolean | number | string | {
762
760
  * resolved value — re-pushed whenever the provider re-evaluates (e.g. a flag is
763
761
  * toggled in Cloudflare Flagship). The flag's kind is inferred from
764
762
  * `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean and
765
- * `useFlag("hero", "control")` a string. `context` supplies a per-call targeting
766
- * context merged on top of the app's default `identify` targeting key.
763
+ * `useFlag("hero", "control")` a string.
764
+ *
765
+ * The reactive channel is public, so the server evaluates every flag under the
766
+ * socket's own verified identity — the targeting key your `defineFlags({
767
+ * identify })` derives — and accepts no client-supplied targeting context. For
768
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
769
+ * mutation, or action and return the resolved value.
767
770
  *
768
771
  * Evaluation runs through whatever OpenFeature provider the app wired in
769
772
  * `lunora/flags.ts`; the read never throws — a provider error resolves the
770
773
  * default (the same fail-open contract as server-side `ctx.flags`).
771
774
  */
772
- declare const useFlag: <T extends FlagValue>(key: string, defaultValue: T, context?: FlagContext) => T;
775
+ declare const useFlag: <T extends FlagValue>(key: string, defaultValue: T) => T;
773
776
  /**
774
777
  * Subscribe to several feature flags at once, live over Lunora's WebSocket.
775
778
  *
776
779
  * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
777
780
  * default, and the result is the same-shaped record with resolved values (the
778
- * defaults until each evaluation lands). A single `context` applies to every
779
- * flag. This is the batched form of {@link useFlag} — one effect manages one
780
- * subscription per key, so it stays rules-of-hooks-safe even as the flag set
781
- * changes between renders.
781
+ * defaults until each evaluation lands). This is the batched form of
782
+ * {@link useFlag} — one effect manages one subscription per key, so it stays
783
+ * rules-of-hooks-safe even as the flag set changes between renders. Like
784
+ * {@link useFlag} it evaluates under the socket's server-verified identity only.
782
785
  */
783
- declare const useFlags: <T extends Record<string, FlagValue>>(flags: T, context?: FlagContext) => T;
786
+ declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => T;
784
787
  /** The lifecycle of a stream the hook is observing. */
785
788
  type UseStreamStatus = "complete" | "error" | "idle" | "streaming";
786
789
  /**
@@ -1262,4 +1265,4 @@ interface UseVoiceAgentResult {
1262
1265
  * `createSocket`) so the hook is drivable outside a browser.
1263
1266
  */
1264
1267
  declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
1265
- export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
1268
+ export { type ActionHook, type AdminAuthListResult, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, type AuthState, Authenticated, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraProvider, type LunoraProviderProps, type MutationHook, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseAuthSessionsOptions, type UseAuthUsersOptions, type UseHttpStreamOptions, type UseHttpStreamResult, type UseImpersonateResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationCallOptions, type UseOrganizationsOptions, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, hydratePreloaded, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useAuthSessions, useAuthState, useAuthUsers, useClientQuery, useConnectionStatus, useFlag, useFlags, useHttpStream, useImpersonate, useInfiniteQuery, useLunora, useMutation, useMutator, useOrganizations, usePaginatedQuery, usePreloadedQuery, usePresence, useQuery, useRateLimit, useStream, useSubscription, useVoiceAgent };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as h,useOrganizations as c}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as y}from"./packem_shared/useAgent-BtmvbOfx.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-PSWHsc8L.mjs";import{useAgentState as S}from"./packem_shared/useAgentState-CxeO0Nzo.mjs";import{useAgentToolEvents as L}from"./packem_shared/useAgentToolEvents-MfR_4MA_.mjs";import{default as F}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as I}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as v}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-BFNfCLq3.mjs";import{useHttpStream as H}from"./packem_shared/useHttpStream-D9vum8Qx.mjs";import{default as j}from"./packem_shared/useInfiniteQuery-JrM8Gv4A.mjs";import{useMutation as w}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as D}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as J}from"./packem_shared/usePaginatedQuery-f-GjDA-g.mjs";import{hydratePreloaded as N,default as W}from"./packem_shared/hydratePreloaded-D_NlgGV_.mjs";import{usePresence as Y}from"./packem_shared/usePresence-DsYEO_XX.mjs";import{default as _}from"./packem_shared/useQuery-HeFPuRVz.mjs";import{useRateLimit as ee}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as oe}from"./packem_shared/useStream-CmGOT0qj.mjs";import{default as ue}from"./packem_shared/useSubscription-BXhI6J-f.mjs";import{useVoiceAgent as ae}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as fe,getErrorCode as ne,getRetryAfterMs as ie,isConflictError as me,isForbiddenError as de,isRateLimitedError as xe,isUnauthorizedError as le}from"@lunora/client";import{RestrictionError as ge,UploadControl as he,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as ye,useFileInput as Ce,useMultipartUpload as Ee,usePasteUpload as Qe,useTusUpload as Se,useUpload as Pe}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,ge as RestrictionError,u as Unauthenticated,he as UploadControl,ce as UploadError,fe as createClientQuery,ne as getErrorCode,ie as getRetryAfterMs,N as hydratePreloaded,me as isConflictError,de as isForbiddenError,xe as isRateLimitedError,le as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,y as useAgent,E as useAgentChat,S as useAgentState,L as useAgentToolEvents,F as useAuth,A as useAuthSessions,a as useAuthState,g as useAuthUsers,ye as useChunkedRestUpload,I as useClientQuery,v as useConnectionStatus,Ce as useFileInput,O as useFlag,T as useFlags,H as useHttpStream,h as useImpersonate,j as useInfiniteQuery,n as useLunora,Ee as useMultipartUpload,w as useMutation,D as useMutator,c as useOrganizations,J as usePaginatedQuery,Qe as usePasteUpload,W as usePreloadedQuery,Y as usePresence,_ as useQuery,ee as useRateLimit,oe as useStream,ue as useSubscription,Se as useTusUpload,Pe as useUpload,ae as useVoiceAgent};
2
+ import{AuthLoading as o,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-dC08yqew.mjs";import{useAuthState as a}from"./packem_shared/useAuthState-CoOG9XdT.mjs";import{LunoraProvider as f,useLunora as n}from"./packem_shared/LunoraProvider-DC06S-p1.mjs";import{lunoraQueryOptions as m}from"./packem_shared/lunoraQueryOptions-B5PEocLy.mjs";import{useAction as x}from"./packem_shared/useAction-CUSJu4yq.mjs";import{useAuthSessions as A,useAuthUsers as g,useImpersonate as h,useOrganizations as c}from"./packem_shared/useAuthSessions-Bq4-f3g-.mjs";import{useAgent as y}from"./packem_shared/useAgent-BtmvbOfx.mjs";import{useAgentChat as E}from"./packem_shared/useAgentChat-PSWHsc8L.mjs";import{useAgentState as S}from"./packem_shared/useAgentState-CxeO0Nzo.mjs";import{useAgentToolEvents as L}from"./packem_shared/useAgentToolEvents-MfR_4MA_.mjs";import{default as F}from"./packem_shared/useAuth-x4boOoAR.mjs";import{default as I}from"./packem_shared/useClientQuery-DFs7trEf.mjs";import{default as v}from"./packem_shared/useConnectionStatus-XYsYGiT6.mjs";import{useFlag as O,useFlags as T}from"./packem_shared/useFlag-BDM923ke.mjs";import{useHttpStream as H}from"./packem_shared/useHttpStream-D9vum8Qx.mjs";import{default as j}from"./packem_shared/useInfiniteQuery-JrM8Gv4A.mjs";import{useMutation as w}from"./packem_shared/useMutation-BnKec7bE.mjs";import{useMutator as D}from"./packem_shared/useMutator-BtUd-xEA.mjs";import{usePaginatedQuery as J}from"./packem_shared/usePaginatedQuery-f-GjDA-g.mjs";import{hydratePreloaded as N,default as W}from"./packem_shared/hydratePreloaded-D_NlgGV_.mjs";import{usePresence as Y}from"./packem_shared/usePresence-DsYEO_XX.mjs";import{default as _}from"./packem_shared/useQuery-HeFPuRVz.mjs";import{useRateLimit as ee}from"./packem_shared/useRateLimit-Cckxi8m9.mjs";import{useStream as oe}from"./packem_shared/useStream-CmGOT0qj.mjs";import{default as ue}from"./packem_shared/useSubscription-BXhI6J-f.mjs";import{useVoiceAgent as ae}from"./packem_shared/useVoiceAgent-BziH3D-1.mjs";import{createClientQuery as fe,getErrorCode as ne,getRetryAfterMs as ie,isConflictError as me,isForbiddenError as de,isRateLimitedError as xe,isUnauthorizedError as le}from"@lunora/client";import{RestrictionError as ge,UploadControl as he,UploadError as ce}from"@visulima/storage-client";import{useChunkedRestUpload as ye,useFileInput as Ce,useMultipartUpload as Ee,usePasteUpload as Qe,useTusUpload as Se,useUpload as Pe}from"@visulima/storage-client/react";export{o as AuthLoading,t as Authenticated,f as LunoraProvider,ge as RestrictionError,u as Unauthenticated,he as UploadControl,ce as UploadError,fe as createClientQuery,ne as getErrorCode,ie as getRetryAfterMs,N as hydratePreloaded,me as isConflictError,de as isForbiddenError,xe as isRateLimitedError,le as isUnauthorizedError,m as lunoraQueryOptions,x as useAction,y as useAgent,E as useAgentChat,S as useAgentState,L as useAgentToolEvents,F as useAuth,A as useAuthSessions,a as useAuthState,g as useAuthUsers,ye as useChunkedRestUpload,I as useClientQuery,v as useConnectionStatus,Ce as useFileInput,O as useFlag,T as useFlags,H as useHttpStream,h as useImpersonate,j as useInfiniteQuery,n as useLunora,Ee as useMultipartUpload,w as useMutation,D as useMutator,c as useOrganizations,J as usePaginatedQuery,Qe as usePasteUpload,W as usePreloadedQuery,Y as usePresence,_ as useQuery,ee as useRateLimit,oe as useStream,ue as useSubscription,Se as useTusUpload,Pe as useUpload,ae as useVoiceAgent};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{useState as _,useRef as i,useEffect as b}from"react";import{useLunora as d}from"./LunoraProvider-DC06S-p1.mjs";import{s as K}from"./stable-key-B_BlboiY.mjs";const g="__lunora_flags__:eval",m=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:g},F=(t,e,n)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:m(e.default)},s=>{n(s)},{onError:()=>{n(e.default)}})}catch{return()=>{}}},S=(t,e)=>{const n=d(),[s,r]=_(e),o=m(e),u=`${t}::${o}`,f=i(u);f.current!==u&&(f.current=u,r(e));const l=i(e);return b(()=>{l.current=e}),b(()=>{let a=!1;const c=l.current;r(c);const p=F(n,{default:c,key:t},y=>{a||r(y)});return()=>{a=!0,p()}},[n,t,o]),s},h=t=>{const e=d(),[n,s]=_(t),r=K(t),o=i(r);o.current!==r&&(o.current=r,s(t));const u=i(t);return b(()=>{u.current=t}),b(()=>{let f=!1;const l=u.current;s(l);const a=[];for(const[c,p]of Object.entries(l))a.push(F(e,{default:p,key:c},y=>{f||s(R=>({...R,[c]:y}))}));return()=>{f=!0;for(const c of a)c()}},[e,r]),n};export{S as useFlag,h as useFlags};
@@ -1,17 +1,26 @@
1
1
  import { ReactNode } from 'react';
2
+ /**
3
+ * Stable provider identifier. Mirror of `@lunora/payment`'s `ProviderId` — the
4
+ * value is persisted verbatim, so an app branching on it must see every provider
5
+ * that has an adapter, not just the two that shipped first.
6
+ */
7
+ type ProviderId = "autumn" | "creem" | "dodopayments" | "polar" | "stripe";
2
8
  /**
3
9
  * Client-safe mirror of `@lunora/payment`'s `Subscription`. Re-declared here
4
10
  * (rather than imported) so this React entry never pulls in the server-only
5
- * `@lunora/payment` module graph — the kit stays React + DOM only. Keep this in
6
- * sync with `packages/payment/src/types.ts`.
11
+ * `@lunora/payment` module graph — the kit stays React + DOM only.
12
+ * `__tests__/payment-mirror.test.ts` fails when this drifts from
13
+ * `packages/payment/src/types.ts`.
7
14
  */
8
15
  interface Subscription {
9
16
  readonly cancelAtPeriodEnd: boolean;
10
17
  readonly createdAt: number;
11
18
  readonly currentPeriodEnd?: number;
19
+ /** Start of the current billing period — the window metered usage is summed over. */
20
+ readonly currentPeriodStart?: number;
12
21
  readonly id: string;
13
22
  readonly priceId: string;
14
- readonly provider: "polar" | "stripe";
23
+ readonly provider: ProviderId;
15
24
  readonly quantity: number;
16
25
  readonly referenceId: string;
17
26
  readonly state: "active" | "canceled" | "past_due" | "paused" | "trialing";
@@ -81,4 +90,4 @@ declare const CheckoutButton: ({ onCheckout, ...rest }: CheckoutButtonProps) =>
81
90
  * returned URL, disabling itself while the request is in flight.
82
91
  */
83
92
  declare const CustomerPortalButton: ({ onPortal, ...rest }: CustomerPortalButtonProps) => ReactNode;
84
- export { CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type RedirectTarget, type RedirectTrigger, type Subscription, type UseCheckoutResult, useCheckout };
93
+ export { CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type ProviderId, type RedirectTarget, type RedirectTrigger, type Subscription, type UseCheckoutResult, useCheckout };
package/dist/payment.d.ts CHANGED
@@ -1,17 +1,26 @@
1
1
  import { ReactNode } from 'react';
2
+ /**
3
+ * Stable provider identifier. Mirror of `@lunora/payment`'s `ProviderId` — the
4
+ * value is persisted verbatim, so an app branching on it must see every provider
5
+ * that has an adapter, not just the two that shipped first.
6
+ */
7
+ type ProviderId = "autumn" | "creem" | "dodopayments" | "polar" | "stripe";
2
8
  /**
3
9
  * Client-safe mirror of `@lunora/payment`'s `Subscription`. Re-declared here
4
10
  * (rather than imported) so this React entry never pulls in the server-only
5
- * `@lunora/payment` module graph — the kit stays React + DOM only. Keep this in
6
- * sync with `packages/payment/src/types.ts`.
11
+ * `@lunora/payment` module graph — the kit stays React + DOM only.
12
+ * `__tests__/payment-mirror.test.ts` fails when this drifts from
13
+ * `packages/payment/src/types.ts`.
7
14
  */
8
15
  interface Subscription {
9
16
  readonly cancelAtPeriodEnd: boolean;
10
17
  readonly createdAt: number;
11
18
  readonly currentPeriodEnd?: number;
19
+ /** Start of the current billing period — the window metered usage is summed over. */
20
+ readonly currentPeriodStart?: number;
12
21
  readonly id: string;
13
22
  readonly priceId: string;
14
- readonly provider: "polar" | "stripe";
23
+ readonly provider: ProviderId;
15
24
  readonly quantity: number;
16
25
  readonly referenceId: string;
17
26
  readonly state: "active" | "canceled" | "past_due" | "paused" | "trialing";
@@ -81,4 +90,4 @@ declare const CheckoutButton: ({ onCheckout, ...rest }: CheckoutButtonProps) =>
81
90
  * returned URL, disabling itself while the request is in flight.
82
91
  */
83
92
  declare const CustomerPortalButton: ({ onPortal, ...rest }: CustomerPortalButtonProps) => ReactNode;
84
- export { CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type RedirectTarget, type RedirectTrigger, type Subscription, type UseCheckoutResult, useCheckout };
93
+ export { CheckoutButton, type CheckoutButtonProps, CustomerPortalButton, type CustomerPortalButtonProps, type ProviderId, type RedirectTarget, type RedirectTrigger, type Subscription, type UseCheckoutResult, useCheckout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/react",
3
- "version": "1.0.0-alpha.72",
3
+ "version": "1.0.0-alpha.74",
4
4
  "description": "React hooks for Lunora: useQuery, useMutation, useSubscription, and useAuth",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -57,9 +57,9 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@lunora/client": "1.0.0-alpha.67",
61
- "@lunora/errors": "1.0.0-alpha.26",
62
- "@lunora/ratelimit": "1.0.0-alpha.31",
60
+ "@lunora/client": "1.0.0-alpha.69",
61
+ "@lunora/errors": "1.0.0-alpha.27",
62
+ "@lunora/ratelimit": "1.0.0-alpha.33",
63
63
  "@visulima/storage-client": "1.0.2"
64
64
  },
65
65
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{useState as x,useRef as p,useEffect as _}from"react";import{useLunora as F}from"./LunoraProvider-DC06S-p1.mjs";import{s as v}from"./stable-key-B_BlboiY.mjs";const A="__lunora_flags__:eval",K=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},E={__lunoraRef:A},R=(t,e,r)=>{try{return t.subscribe(E,{context:e.context,default:e.default,key:e.key,type:K(e.default)},n=>{r(n)},{onError:()=>{r(e.default)}})}catch{return()=>{}}},h=(t,e,r)=>{const n=F(),[l,s]=x(e),f=K(e),c=r===void 0?"":v(r),o=`${t}::${f}::${c}`,i=p(o);i.current!==o&&(i.current=o,s(e));const a=p({context:r,defaultValue:e});return _(()=>{a.current={context:r,defaultValue:e}}),_(()=>{let d=!1;const{context:y,defaultValue:b}=a.current;s(b);const u=R(n,{context:y,default:b,key:t},m=>{d||s(m)});return()=>{d=!0,u()}},[n,t,f,c]),l},j=(t,e)=>{const r=F(),[n,l]=x(t),s=v(t),f=e===void 0?"":v(e),c=`${s}::${f}`,o=p(c);o.current!==c&&(o.current=c,l(t));const i=p({context:e,flags:t});return _(()=>{i.current={context:e,flags:t}}),_(()=>{let a=!1;const{context:d,flags:y}=i.current;l(y);const b=[];for(const[u,m]of Object.entries(y))b.push(R(r,{context:d,default:m,key:u},$=>{a||l(C=>({...C,[u]:$}))}));return()=>{a=!0;for(const u of b)u()}},[r,s,f]),n};export{h as useFlag,j as useFlags};