@nivaro/react 0.3.62 → 0.3.63

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.
@@ -9,7 +9,7 @@ import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../share
9
9
  import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
10
10
  import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
11
11
  import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
12
- const Ue = "nivaro-react@0.3.62", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
+ const Ue = "nivaro-react@0.3.63", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
13
13
  function Be(n) {
14
14
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
15
15
  const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
package/dist/index.d.ts CHANGED
@@ -1076,6 +1076,25 @@ export declare interface BaseMapPin {
1076
1076
  pulse?: boolean;
1077
1077
  }
1078
1078
 
1079
+ export declare interface BatchedGet<T> {
1080
+ /** The read on its own — its plain GET, with that transport's own errors. */
1081
+ alone: () => Promise<T>;
1082
+ /** The error its plain GET would have thrown for this part's refusal. */
1083
+ error: (part: BatchGetPart & {
1084
+ status: number;
1085
+ }) => unknown;
1086
+ }
1087
+
1088
+ /** One part of a `POST /batch-get` answer. */
1089
+ export declare interface BatchGetPart {
1090
+ key?: string;
1091
+ status?: number;
1092
+ /** The part's JSON body, exactly as its GET answers it (absent when it was not JSON). */
1093
+ body?: unknown;
1094
+ request_id?: string;
1095
+ retry_after?: string;
1096
+ }
1097
+
1079
1098
  /** Turns clean mode on until the returned release runs (idempotent). Nested
1080
1099
  * holders count; the mode ends when the last one releases. */
1081
1100
  export declare function beginCleanRecording(): () => void;
@@ -2079,6 +2098,13 @@ declare interface CoalescingOptions {
2079
2098
  * error they would have seen without batching. Writes never batch.
2080
2099
  */
2081
2100
  batchReads?: boolean;
2101
+ /**
2102
+ * Small configuration / side-panel GETs (lib/batch-gets.ts BATCHABLE_GET) asked within
2103
+ * BATCH_GET_WINDOW_MS ride one `POST /batch-get`, which runs each through its real route as
2104
+ * the caller. Follows `batchReads` unless set; an older server without the route is
2105
+ * detected and the loader steps aside.
2106
+ */
2107
+ batchGets?: boolean;
2082
2108
  /**
2083
2109
  * Collection metadata reads (`GET /collections/<name>`) asked for within
2084
2110
  * ~10 ms ride one `GET /collections?names=`. On by default; an older server
@@ -2380,6 +2406,21 @@ export declare function createGatedClient(client: NivaroClient, opts?: {
2380
2406
  open?: boolean;
2381
2407
  }): GatedClient;
2382
2408
 
2409
+ /**
2410
+ * A loader for any transport (the shared client, a host's own fetch helper): GETs whose path
2411
+ * isBatchableGetPath names, asked within BATCH_GET_WINDOW_MS, ride one `POST /batch-get`
2412
+ * (chunks of BATCH_GET_LIMIT). The server runs each through its own route as the caller, so a
2413
+ * caller resolves with exactly the body its GET answers, or rejects with `error(part)` — what
2414
+ * its GET would have thrown. A part the server could not answer as JSON, and every part of a
2415
+ * batch refused as a whole with a 4xx (a signed-out tab, an access-pending account, a
2416
+ * malformed body), is re-sent on its own, so a route that answers some callers without
2417
+ * signing in still does. A busy or failing server (429, 5xx, no network) fails the batch's
2418
+ * callers with that error: re-sending each alone would only add load. A server without the
2419
+ * route (404/405) switches the loader off for good. `path` is the wire path under /api with
2420
+ * its query string.
2421
+ */
2422
+ export declare function createGetBatcher(opts: GetBatcherOptions): GetLoader;
2423
+
2383
2424
  export declare function createLeaderSocket(key: string, cbs: LeaderCallbacks): LeaderSocketHandle;
2384
2425
 
2385
2426
  export declare function createLiveQueryBridge(qc: QueryClient, realtime: RealtimeAdapter, opts?: LiveQueryBridgeOptions): LiveQueryBridge;
@@ -4017,6 +4058,17 @@ export declare function getApiUpdate(): ApiVersionInfo | null;
4017
4058
 
4018
4059
  export declare function getAutofillRuns(): AutofillRun[];
4019
4060
 
4061
+ declare interface GetBatcherOptions {
4062
+ /**
4063
+ * Send `POST /api/batch-get {reads}` and resolve its parsed answer. Throw an error carrying
4064
+ * the HTTP `status` when the batch itself is refused (no status = no network).
4065
+ */
4066
+ post: (reads: Array<{
4067
+ key: string;
4068
+ path: string;
4069
+ }>) => Promise<unknown>;
4070
+ }
4071
+
4020
4072
  /** The live window, or null. An ended window is cleared here, whoever asks first. */
4021
4073
  export declare function getClientChaos(now?: number): ClientChaosState | null;
4022
4074
 
@@ -4026,6 +4078,9 @@ export declare function getFiscalStartMonth(): number;
4026
4078
 
4027
4079
  export declare function getLayoutSlot(key: string | null | undefined): LayoutSlotPlugin | null;
4028
4080
 
4081
+ /** What createGetBatcher returns: queue one GET for the next batch. */
4082
+ declare type GetLoader = <T>(path: string, read: BatchedGet<T>) => Promise<T>;
4083
+
4029
4084
  export declare function getMentionQuery(text: string, cursorPos: number): string | null;
4030
4085
 
4031
4086
  /** A copy of the rings, oldest first. */
@@ -5619,6 +5674,9 @@ declare interface IntroCard {
5619
5674
  transition?: 'fade' | 'fade_black' | 'slide' | 'zoom' | 'wipe';
5620
5675
  }
5621
5676
 
5677
+ /** Whether a GET path (under /api, no query string) may be batched. */
5678
+ export declare function isBatchableGetPath(path: string): boolean;
5679
+
5622
5680
  /** Whether this browser pinned the chat panel open — hosts read it for their
5623
5681
  * initial open state, so a pinned panel is still there after a reload. */
5624
5682
  export declare function isChatPanelPinned(): boolean;
@@ -10203,6 +10261,14 @@ export declare function setTrailLabel(label: string | null | undefined, key?: st
10203
10261
  /** True when this browser can share a socket between tabs. */
10204
10262
  export declare function sharedWorkerSupported(): boolean;
10205
10263
 
10264
+ /**
10265
+ * A host whose own fetch helper also batches small GETs (efp-new's apiFetch) hands its loader
10266
+ * here, and the shared client queues its GETs on that same loader: the reads both transports
10267
+ * ask in one moment ride ONE request instead of one per transport. The host's loader must post
10268
+ * as the very caller its shared client signs in as (same token / session). `null` takes it back.
10269
+ */
10270
+ export declare function shareGetLoader(loader: GetLoader | null): void;
10271
+
10206
10272
  /**
10207
10273
  * The pure part of opening a query sheet: which tabs it has, which tab opens
10208
10274
  * first, and the optional header strip (a query of its own, rendered above