@gonvex/react 0.5.2-staging.2 → 0.5.2-staging.20

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
@@ -165,13 +165,18 @@ native password session through the same path. Access tokens are short-lived,
165
165
  refresh tokens rotate across tabs, and the provider persists the active tenant.
166
166
  The host verifies tenant membership before switching with `setActiveTenant`.
167
167
 
168
- Developer mode is provider-owned. Its activation and rotating reconnect
169
- credentials stay in memory and are never returned by these methods, persisted,
170
- or added to a URL. The provider preserves and refreshes the normal account
171
- session underneath the grant, then restores it on exit, expiry, reload, or an
172
- authentication rejection. Developer mode switches the existing Gonvex
173
- connection; it does not navigate to a tenant subdomain or require a browser
174
- handoff.
168
+ Developer mode is provider-owned. Its credentials are never returned by these
169
+ methods, written to localStorage, or added to a URL. The runtime rotates a
170
+ single-use reconnect credential on every connection; the provider keeps the
171
+ newest one with the grant in `sessionStorage`, keyed by project and account,
172
+ so reloading the same tab resumes developer mode until the grant expires.
173
+ Other tabs and new browser sessions never see it. The provider preserves and
174
+ refreshes the normal account session underneath the grant, then restores it
175
+ and forgets the grant on exit, expiry, sign-out, an account switch, or an
176
+ authentication rejection. A stored grant the runtime no longer accepts after a
177
+ reload falls back to the account session without an error. Developer mode
178
+ switches the existing Gonvex connection; it does not navigate to a tenant
179
+ subdomain or require a browser handoff.
175
180
 
176
181
  Use `useCurrentTenantProfile()` for subscribed domain, timezone, description,
177
182
  and public profile fields. Use `useControlQuery(reference, args)` for an
@@ -225,3 +230,5 @@ remain Firebase's responsibility when this adapter is configured.
225
230
  ## Documentation
226
231
 
227
232
  Full docs live at https://desarso.github.io/gonvex/
233
+
234
+ [Use public tenant clients with the regular provider and query, Action, and Reducer hooks](../../docs/public-functions.md).
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type ButtonHTMLAttributes, type ReactNode } from "react";
2
- import { GonvexClient, type ConnectionState, type ControlInvitationAcceptance, type ControlInvitationListItem, type ControlToken, type FunctionReference, type GonvexExternalAuthAdapter, type LiveQueryResult, type ReplicaCollectionSubscriptionState, type ReplicaRow } from "@gonvex/client";
2
+ import { GonvexClient, type ConnectionState, type EntityIntentStatus, type LocalExecutionFallbackEvent, type OutboxIntent, type ResetLocalReplicaOptions, type ResetLocalReplicaResult, type ControlInvitationAcceptance, type ControlInvitationListItem, type ControlToken, type FunctionReference, type GonvexExternalAuthAdapter, type LiveQueryResult, type ReplicaCollectionSubscriptionState, type ReplicaRow } from "@gonvex/client";
3
3
  import type { JsonValue } from "@gonvex/protocol";
4
- export { GonvexClientError, type ConnectionState } from "@gonvex/client";
4
+ export { GonvexClientError, type ConnectionState, type EntityIntentStatus, type LocalExecutionFallbackEvent, type OutboxIntent, type ResetLocalReplicaOptions, type ResetLocalReplicaResult } from "@gonvex/client";
5
5
  export { createFirebaseAuthAdapter, type GonvexExternalAuthAdapter, type GonvexExternalIdentityHint, type GonvexFirebaseAuthAdapterOptions } from "@gonvex/client";
6
6
  export declare function GonvexProvider(props: {
7
7
  client: GonvexClient;
@@ -78,14 +78,27 @@ export type GonvexAuthConfig = {
78
78
  runtimeUrl: string;
79
79
  projectId: string;
80
80
  callbackPath?: string;
81
- /** Tenant routing hint used for the first authentication exchange. */
82
- initialTenantId?: string;
81
+ /**
82
+ * Tenant routing scope for the first authentication exchange. Pass `null`
83
+ * to explicitly select account/landlord scope; omit it to restore the
84
+ * persisted active tenant when possible.
85
+ */
86
+ initialTenantId?: string | null;
87
+ /** Visible content while the external identity provider initializes. */
88
+ loadingFallback?: ReactNode;
83
89
  /** Trusted identity adapter such as createFirebaseAuthAdapter(). */
84
90
  externalAuth?: GonvexExternalAuthAdapter;
85
91
  /** Secure browser-to-browser handoff for apps routed across sibling subdomains. */
86
92
  crossOriginHandoff?: {
87
93
  allowedOriginSuffix: string;
88
94
  receiverPath?: string;
95
+ /**
96
+ * Load the receiver with POST when a service worker may serve a stale
97
+ * cached application shell for GET navigations. The POST body is empty;
98
+ * the canonical session still travels only through the origin-checked
99
+ * postMessage exchange.
100
+ */
101
+ receiverMethod?: "get" | "post";
89
102
  timeoutMs?: number;
90
103
  };
91
104
  };
@@ -161,6 +174,13 @@ export declare function useQuery<T extends JsonValue = JsonValue>(ref: FunctionR
161
174
  export declare function useReplicaCollection<T extends JsonValue = JsonValue>(ref: FunctionReference, args?: JsonValue | "skip"): T[] | undefined;
162
175
  /** Replica rows plus exact per-collection authority, completeness, truncation, and freshness. */
163
176
  export declare function useReplicaCollectionState<T extends ReplicaRow = ReplicaRow>(ref: FunctionReference, args?: JsonValue | "skip"): ReplicaCollectionSubscriptionState<T> | undefined;
177
+ /** Subscribe to a bounded, dynamic set of slices of the same Replica Collection.
178
+ * Results borrow normalized SDK snapshots; there is no second entity cache.
179
+ * Deferred watches only start when React commits the subscription.
180
+ */
181
+ export declare function useReplicaCollectionStates<T extends ReplicaRow = ReplicaRow>(ref: FunctionReference, args: readonly JsonValue[]): ReadonlyArray<ReplicaCollectionSubscriptionState<T> | undefined>;
182
+ /** Select rows and authority metadata without rerendering for unused watermarks. */
183
+ export declare function useReplicaCollectionStateSelector<T extends ReplicaRow, Selected>(ref: FunctionReference, args: JsonValue | "skip", selector: (state: ReplicaCollectionSubscriptionState<T>) => Selected, isEqual?: (left: Selected, right: Selected) => boolean): Selected | undefined;
164
184
  export declare function useReplicaSelector<T extends JsonValue = JsonValue, Selected = unknown>(ref: FunctionReference, args: JsonValue | "skip", selector: (rows: T[]) => Selected, isEqual?: (left: Selected, right: Selected) => boolean): Selected | undefined;
165
185
  export type UseReducerOptions = {
166
186
  /** Per-call timeout override forwarded to the client. `0` disables. */
@@ -169,5 +189,35 @@ export type UseReducerOptions = {
169
189
  export declare function useReducer(ref: FunctionReference, options?: UseReducerOptions): (args?: JsonValue) => Promise<JsonValue>;
170
190
  export declare function useAction(ref: FunctionReference, options?: UseReducerOptions): (args?: JsonValue) => Promise<JsonValue>;
171
191
  export declare function useGonvexConnectionState(): ConnectionState;
192
+ /**
193
+ * Every durable reducer intent of the signed-in identity, oldest first:
194
+ * pending and inflight intents, intents parked as `failed` after exhausting
195
+ * their retry budget, and server-`rejected` intents awaiting dismissal.
196
+ * Use `client.retryIntent(id)` / `client.discardIntent(id)` to act on them.
197
+ */
198
+ export declare function useOutboxIntents(): readonly OutboxIntent[];
199
+ /**
200
+ * Delivery status of one row: `failed` or `rejected` when an intent that
201
+ * touched it needs attention, `syncing` while one is still queued, and
202
+ * undefined once everything touching it has been acknowledged.
203
+ */
204
+ export declare function useEntityIntentStatus(entity: string, id: string | null | undefined): EntityIntentStatus | undefined;
205
+ /**
206
+ * Observe locally executing Reducers that fell back to a queued-only intent
207
+ * (no local result), for logging. The latest listener is always called; it
208
+ * does not need to be memoized.
209
+ */
210
+ export declare function useLocalExecutionFallback(listener: (event: LocalExecutionFallbackEvent) => void): void;
211
+ export type LocalReplicaReset = {
212
+ /** Rejects with `code: "disconnected"` while offline; nothing is cleared then. */
213
+ reset: (options?: ResetLocalReplicaOptions) => Promise<ResetLocalReplicaResult>;
214
+ isResetting: boolean;
215
+ error: Error | undefined;
216
+ };
217
+ /**
218
+ * Drive a "Clear cache" control: discards the persisted Local Replica and
219
+ * rehydrates it from the server, keeping queued intents unless asked.
220
+ */
221
+ export declare function useResetLocalReplica(): LocalReplicaReset;
172
222
  export declare function useGonvexClient(): GonvexClient;
173
223
  export { useSignalValue } from "./useSignal.js";