@lunora/client 1.0.0-alpha.22 → 1.0.0-alpha.24

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 (29) hide show
  1. package/dist/auth/index.d.mts +1 -1
  2. package/dist/auth/index.d.ts +1 -1
  3. package/dist/index.d.mts +66 -4
  4. package/dist/index.d.ts +66 -4
  5. package/dist/index.mjs +8 -7
  6. package/dist/packem_shared/{LunoraClient-Clb118SU.mjs → LunoraClient-D3h4P7hg.mjs} +143 -247
  7. package/dist/packem_shared/{OfflineQueue-B4HUF7rt.mjs → OfflineQueue-BgarnAub.mjs} +1 -1
  8. package/dist/packem_shared/{SubscriptionRegistry-D4jfIzZu.mjs → SubscriptionRegistry-CxS_Inha.mjs} +2 -2
  9. package/dist/packem_shared/{TabCoordinator-BwRR8H06.mjs → TabCoordinator-D_5oNTTt.mjs} +48 -12
  10. package/dist/packem_shared/{createClientQuery-CQ51bWAE.mjs → createClientQuery-dJZg1ohm.mjs} +15 -6
  11. package/dist/packem_shared/createLocalStore-BtqUmOQA.mjs +2 -0
  12. package/dist/packem_shared/{createServerClient-Dxemst5C.mjs → createServerClient-DzeC2J3A.mjs} +1 -1
  13. package/dist/packem_shared/{createSnapshotPrecondition-CBwnVz6r.mjs → createSnapshotPrecondition-CxQ1T4ZP.mjs} +3 -3
  14. package/dist/packem_shared/httpStream-DIdL8NEw.mjs +168 -0
  15. package/dist/packem_shared/{local-store-DtcIW4c0.mjs → local-store-DIq-UWfD.mjs} +1 -1
  16. package/dist/packem_shared/{lunora-client.d-pw-9sLl0.d.mts → lunora-client.d-B8bdwHLr.d.mts} +132 -18
  17. package/dist/packem_shared/{lunora-client.d-pw-9sLl0.d.ts → lunora-client.d-B8bdwHLr.d.ts} +132 -18
  18. package/dist/packem_shared/{offline-queue-CF4_Co5k.mjs → offline-queue-N-1JvYb4.mjs} +14 -2
  19. package/dist/packem_shared/{preload.d-BkQr-3Vh.d.ts → preload.d-BPy9qajK.d.ts} +1 -1
  20. package/dist/packem_shared/{preload.d-6ME5ubgq.d.mts → preload.d-Ccrgw2z0.d.mts} +1 -1
  21. package/dist/packem_shared/wire-key-Djie6aaR.mjs +266 -0
  22. package/dist/query/index.d.mts +2 -2
  23. package/dist/query/index.d.ts +2 -2
  24. package/dist/ssr/index.d.mts +3 -3
  25. package/dist/ssr/index.d.ts +3 -3
  26. package/dist/ssr/index.mjs +1 -1
  27. package/package.json +2 -2
  28. package/dist/packem_shared/createLocalStore-BDbbkoXw.mjs +0 -2
  29. package/dist/packem_shared/stable-key-wv6eP48B.mjs +0 -40
@@ -1,4 +1,4 @@
1
- import { U as User, L as LunoraClient } from "../packem_shared/lunora-client.d-pw-9sLl0.mjs";
1
+ import { U as User, L as LunoraClient } from "../packem_shared/lunora-client.d-B8bdwHLr.mjs";
2
2
  import '@lunora/runtime';
3
3
  interface IdentityStore {
4
4
  /** Read the current resolved user, or `null` when signed out / not yet resolved. */
@@ -1,4 +1,4 @@
1
- import { U as User, L as LunoraClient } from "../packem_shared/lunora-client.d-pw-9sLl0.js";
1
+ import { U as User, L as LunoraClient } from "../packem_shared/lunora-client.d-B8bdwHLr.js";
2
2
  import '@lunora/runtime';
3
3
  interface IdentityStore {
4
4
  /** Read the current resolved user, or `null` when signed out / not yet resolved. */
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { c as PersistenceAdapter, B as BookmarkStorage, S as SubscriptionError, F as FunctionReference, A as ArgsOf, M as MutationCallOptions, R as ReturnOf, O as OfflineQueueOptions, Q as QueryCacheAdapter, d as ReconnectOptions, L as LunoraClient } from "./packem_shared/lunora-client.d-pw-9sLl0.mjs";
2
- export { type e as BatchSlot, C as CONFLICT_ERROR_CODE, type f as CachedQuery, type g as ClientMessage, type h as ClientQueryRef, type i as ClientShapeSubscribeMessage, type j as ClientShapeUnsubscribeMessage, type k as ConnectionStatus, D as DEFAULT_MAX_BUFFER, type l as FunctionArgumentDescriptor, type m as FunctionDescriptor, type G as GlobalFacetResult, type n as GlobalFacetValue, type o as GlobalFilterClause, type p as GlobalTableInfo, type q as GlobalTablePage, type r as LunoraClientError, type s as LunoraClientOptions, type t as LunoraErrorCode, type u as MutationSettledEvent, type v as OptimisticLocalStore, type w as OptimisticUpdate, type x as OutboxMutation, type y as OutboxSink, type z as PersistedMutation, type P as Preloaded, type E as RowOp, type H as RpcEnvelope, type I as RpcResponseBody, type J as ScheduleRecord, type K as SchedulerPoolStatus, type N as SchedulerStatus, type T as ServerMessage, type V as ServerPokeEndMessage, type W as ServerPokePartMessage, type X as ServerPokeStartMessage, type Y as ShardTrafficEntry, type Z as ShardTrafficResult, type _ as StorageListPage, type $ as StorageObject, type a0 as StreamHandle, type a1 as StreamIterable, type a2 as SubscriptionCallback, type b as SubscriptionErrorCallback, a3 as SubscriptionRegistry, type a4 as SubscriptionState, type a5 as SyncWatermark, type a as Unsubscribe, type U as User, type a6 as WorkflowInstanceAction, type a7 as WorkflowInstanceDetail, type a8 as WorkflowInstancePage, type a9 as WorkflowInstanceStatus, type aa as WorkflowInstanceSummary, type ab as WorkflowStepDetail, ac as createClientQuery, ad as createLocalStore, ae as createStream, af as getErrorCode, ag as getRetryAfterMs, ah as isConflictError, ai as isForbiddenError, aj as isRateLimitedError, ak as isUnauthorizedError } from "./packem_shared/lunora-client.d-pw-9sLl0.mjs";
3
- export { p as preloadQuery, a as preloadedQueryResult } from "./packem_shared/preload.d-6ME5ubgq.mjs";
1
+ import { c as PersistenceAdapter, B as BookmarkStorage, S as SubscriptionError, H as HttpStreamRef, d as HttpStreamArgsOf, e as HttpStreamChunkOf, f as StreamIterable, F as FunctionReference, A as ArgsOf, M as MutationCallOptions, R as ReturnOf, O as OfflineQueueOptions, Q as QueryCacheAdapter, g as ReconnectOptions, L as LunoraClient } from "./packem_shared/lunora-client.d-B8bdwHLr.mjs";
2
+ export { type h as BatchSlot, C as CONFLICT_ERROR_CODE, type i as CachedQuery, type j as ClientMessage, type k as ClientQueryRef, type l as ClientShapeSubscribeMessage, type m as ClientShapeUnsubscribeMessage, type n as ConnectionStatus, D as DEFAULT_MAX_BUFFER, type o as FunctionArgumentDescriptor, type p as FunctionDescriptor, type G as GlobalFacetResult, type q as GlobalFacetValue, type r as GlobalFilterClause, type s as GlobalTableInfo, type t as GlobalTablePage, type u as HttpStreamCallArgs, type v as LunoraClientError, type w as LunoraClientOptions, type x as LunoraErrorCode, type y as MutationSettledEvent, type z as OptimisticLocalStore, type E as OptimisticUpdate, type I as OutboxMutation, type J as OutboxSink, type K as PersistedMutation, type P as Preloaded, type N as RowOp, type T as RpcEnvelope, type V as RpcResponseBody, type W as ScheduleRecord, type X as SchedulerPoolStatus, type Y as SchedulerStatus, type Z as ServerMessage, type _ as ServerPokeEndMessage, type $ as ServerPokePartMessage, type a0 as ServerPokeStartMessage, type a1 as ShardTrafficEntry, type a2 as ShardTrafficResult, type a3 as StorageListPage, type a4 as StorageObject, type a5 as StreamHandle, type a6 as SubscriptionCallback, type b as SubscriptionErrorCallback, a7 as SubscriptionRegistry, type a8 as SubscriptionState, type a9 as SyncWatermark, type a as Unsubscribe, type U as User, type aa as WorkflowInstanceAction, type ab as WorkflowInstanceDetail, type ac as WorkflowInstancePage, type ad as WorkflowInstanceStatus, type ae as WorkflowInstanceSummary, type af as WorkflowStepDetail, type ag as WsTokenProvider, ah as createClientQuery, ai as createLocalStore, aj as createStream, ak as getErrorCode, al as getRetryAfterMs, am as isConflictError, an as isForbiddenError, ao as isRateLimitedError, ap as isUnauthorizedError } from "./packem_shared/lunora-client.d-B8bdwHLr.mjs";
3
+ export { p as preloadQuery, a as preloadedQueryResult } from "./packem_shared/preload.d-Ccrgw2z0.mjs";
4
4
  export type { AuthCapabilities, AuthConfigInfo, AuthImpersonation, AuthPage, AuthSession, AuthUser, AuthUserFieldSpec, CronJobInfo, KvKeyEntry, KvKeyListResult, KvNamespaceSummary, KvValueResult, VectorIndexSummary, VectorQueryMatch } from '@lunora/runtime';
5
5
  /**
6
6
  * The slice of React Native's `AsyncStorage` (or any async key/value store —
@@ -115,6 +115,21 @@ declare class TabCoordinator {
115
115
  broadcastSubscriptionError(key: string, error: SubscriptionError): void;
116
116
  private broadcast;
117
117
  private handleMessage;
118
+ private handleClaimLeadership;
119
+ private handleHeartbeat;
120
+ /**
121
+ * Resolve two leaders existing at once — e.g. this tab was backgrounded
122
+ * and its heartbeat/health timers were throttled while a foreground
123
+ * follower's were not, so the follower's `checkLeaderHealth` timed out
124
+ * the (still-alive) leader and self-promoted. `BroadcastChannel` message
125
+ * delivery isn't subject to the same timer-throttling clamp, so even a
126
+ * backgrounded leader eventually observes the pretender's heartbeat here
127
+ * — resolve the split-brain deterministically with the same
128
+ * lexicographically-smaller-tabId rule used at claim-adoption. If the
129
+ * other tab wins, step down; if we win, reassert immediately so the
130
+ * pretender demotes itself the moment it processes our heartbeat.
131
+ */
132
+ private resolveLeaderVsLeaderTieBreak;
118
133
  private becomeLeader;
119
134
  private sendHeartbeat;
120
135
  private checkLeaderHealth;
@@ -181,6 +196,43 @@ declare const isMutationDelta: (value: unknown) => value is MutationDelta;
181
196
  * when an `insert`/`update` delta carries no `row` to splice in.
182
197
  */
183
198
  declare const applyDelta: (current: unknown, delta: MutationDelta) => undefined | unknown[];
199
+ /**
200
+ * Options accepted by {@link httpStream}.
201
+ * @experimental Part of the HTTP-SSE stream surface.
202
+ */
203
+ interface HttpStreamOptions {
204
+ /**
205
+ * Origin (or origin + prefix) the route path is appended to, e.g.
206
+ * `https://my-app.example.com`. Defaults to `""` — a relative URL, which
207
+ * resolves against the page origin in a browser.
208
+ */
209
+ baseUrl?: string;
210
+ /** `fetch` implementation override; defaults to the global `fetch`. */
211
+ fetch?: typeof fetch;
212
+ /** Extra request headers (e.g. `authorization`). `accept: text/event-stream` is always sent. */
213
+ headers?: Record<string, string>;
214
+ /** Caps the in-flight chunk buffer (see `createStream`); exceeding it fails the stream. */
215
+ maxBuffer?: number;
216
+ /** External abort signal — aborting it cancels the fetch (→ the server handler's `signal`). */
217
+ signal?: AbortSignal;
218
+ }
219
+ /**
220
+ * Open a typed HTTP-SSE stream route and iterate its chunks:
221
+ *
222
+ * ```ts
223
+ * const stream = httpStream(httpStreams.http.tokens, { searchParams: { prompt } }, { baseUrl });
224
+ * for await (const token of stream) {
225
+ * render(token); // typed as the route handler's yielded chunk
226
+ * }
227
+ * ```
228
+ *
229
+ * The returned iterable terminates when the server writes `event: complete`;
230
+ * an `event: error` frame (or a transport failure) surfaces as a coded
231
+ * rejection on the next `next()`. `.cancel()` — or aborting `options.signal` —
232
+ * aborts the underlying fetch, which the server observes via `request.signal`.
233
+ * @experimental Reconnect/POST-body/wire-fidelity design questions are still open, so the shape may change.
234
+ */
235
+ declare const httpStream: <Ref extends HttpStreamRef>(route: Ref, args?: HttpStreamArgsOf<Ref>, options?: HttpStreamOptions) => StreamIterable<HttpStreamChunkOf<Ref>>;
184
236
  /** The single transport method a mutation runner needs — narrowed so adapters can test against a stub. */
185
237
  interface MutationCapableClient<F extends FunctionReference> {
186
238
  mutation: (function_: F, args: ArgsOf<F>, options?: MutationCallOptions<unknown, unknown, ArgsOf<F>>) => Promise<ReturnOf<F>>;
@@ -366,6 +418,16 @@ declare class OfflineQueue {
366
418
  * gone after a reload). No-op when no persistence adapter is configured.
367
419
  * Returns the distinct shard keys of the restored writes so the caller can
368
420
  * open their sockets to trigger a flush.
421
+ *
422
+ * `hydrate()` runs post-construction (the caller awaits an async durable-store
423
+ * load), so a mutation issued while offline during that boot window is
424
+ * enqueued into `items` *before* this method's `await` resolves. Restored
425
+ * records are therefore `unshift`-ed ahead of whatever is already queued
426
+ * rather than `push`-ed to the end: the durable store's persist order is
427
+ * authoritative (a prior-session write is always older than anything from
428
+ * this session), so replaying a same-session boot-time write before an
429
+ * older restored write on the same document would let last-writer-wins
430
+ * silently clobber the newer data with the stale one.
369
431
  */
370
432
  hydrate(): Promise<(string | undefined)[]>;
371
433
  /**
@@ -606,4 +668,4 @@ declare const sendToSw: (sw: ServiceWorker | null, message: ClientToSwMessage, e
606
668
  * Create a reply for a client message (call from inside the SW).
607
669
  */
608
670
  declare const createReply: (original: ClientToSwMessage, payload?: unknown) => SwToClientMessage;
609
- export { type ArgsOf, type AsyncStorageLike, type AsyncStoragePersistenceOptions, type BookmarkStorage, ClientServiceWorker, type ClientSwOptions, type ClientToSwMessage, type FunctionReference, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, LunoraClient, type MutationCallOptions, type MutationDelta, type MutationRunnerSinks, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, type ReconnectCalculator, type ReconnectOptions, type ReturnOf, type ServiceWorkerStatus, type SubscriptionError, type SwToClientMessage, TabCoordinator, applyDelta, createAsyncStoragePersistence, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutationRunner, createMutatorRunner, createReconnect, createReply, createSnapshotPrecondition, isMutationDelta, queryCacheKey, sendToSw };
671
+ export { type ArgsOf, type AsyncStorageLike, type AsyncStoragePersistenceOptions, type BookmarkStorage, ClientServiceWorker, type ClientSwOptions, type ClientToSwMessage, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, LunoraClient, type MutationCallOptions, type MutationDelta, type MutationRunnerSinks, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, type ReconnectCalculator, type ReconnectOptions, type ReturnOf, type ServiceWorkerStatus, type StreamIterable, type SubscriptionError, type SwToClientMessage, TabCoordinator, applyDelta, createAsyncStoragePersistence, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutationRunner, createMutatorRunner, createReconnect, createReply, createSnapshotPrecondition, httpStream, isMutationDelta, queryCacheKey, sendToSw };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { c as PersistenceAdapter, B as BookmarkStorage, S as SubscriptionError, F as FunctionReference, A as ArgsOf, M as MutationCallOptions, R as ReturnOf, O as OfflineQueueOptions, Q as QueryCacheAdapter, d as ReconnectOptions, L as LunoraClient } from "./packem_shared/lunora-client.d-pw-9sLl0.js";
2
- export { type e as BatchSlot, C as CONFLICT_ERROR_CODE, type f as CachedQuery, type g as ClientMessage, type h as ClientQueryRef, type i as ClientShapeSubscribeMessage, type j as ClientShapeUnsubscribeMessage, type k as ConnectionStatus, D as DEFAULT_MAX_BUFFER, type l as FunctionArgumentDescriptor, type m as FunctionDescriptor, type G as GlobalFacetResult, type n as GlobalFacetValue, type o as GlobalFilterClause, type p as GlobalTableInfo, type q as GlobalTablePage, type r as LunoraClientError, type s as LunoraClientOptions, type t as LunoraErrorCode, type u as MutationSettledEvent, type v as OptimisticLocalStore, type w as OptimisticUpdate, type x as OutboxMutation, type y as OutboxSink, type z as PersistedMutation, type P as Preloaded, type E as RowOp, type H as RpcEnvelope, type I as RpcResponseBody, type J as ScheduleRecord, type K as SchedulerPoolStatus, type N as SchedulerStatus, type T as ServerMessage, type V as ServerPokeEndMessage, type W as ServerPokePartMessage, type X as ServerPokeStartMessage, type Y as ShardTrafficEntry, type Z as ShardTrafficResult, type _ as StorageListPage, type $ as StorageObject, type a0 as StreamHandle, type a1 as StreamIterable, type a2 as SubscriptionCallback, type b as SubscriptionErrorCallback, a3 as SubscriptionRegistry, type a4 as SubscriptionState, type a5 as SyncWatermark, type a as Unsubscribe, type U as User, type a6 as WorkflowInstanceAction, type a7 as WorkflowInstanceDetail, type a8 as WorkflowInstancePage, type a9 as WorkflowInstanceStatus, type aa as WorkflowInstanceSummary, type ab as WorkflowStepDetail, ac as createClientQuery, ad as createLocalStore, ae as createStream, af as getErrorCode, ag as getRetryAfterMs, ah as isConflictError, ai as isForbiddenError, aj as isRateLimitedError, ak as isUnauthorizedError } from "./packem_shared/lunora-client.d-pw-9sLl0.js";
3
- export { p as preloadQuery, a as preloadedQueryResult } from "./packem_shared/preload.d-BkQr-3Vh.js";
1
+ import { c as PersistenceAdapter, B as BookmarkStorage, S as SubscriptionError, H as HttpStreamRef, d as HttpStreamArgsOf, e as HttpStreamChunkOf, f as StreamIterable, F as FunctionReference, A as ArgsOf, M as MutationCallOptions, R as ReturnOf, O as OfflineQueueOptions, Q as QueryCacheAdapter, g as ReconnectOptions, L as LunoraClient } from "./packem_shared/lunora-client.d-B8bdwHLr.js";
2
+ export { type h as BatchSlot, C as CONFLICT_ERROR_CODE, type i as CachedQuery, type j as ClientMessage, type k as ClientQueryRef, type l as ClientShapeSubscribeMessage, type m as ClientShapeUnsubscribeMessage, type n as ConnectionStatus, D as DEFAULT_MAX_BUFFER, type o as FunctionArgumentDescriptor, type p as FunctionDescriptor, type G as GlobalFacetResult, type q as GlobalFacetValue, type r as GlobalFilterClause, type s as GlobalTableInfo, type t as GlobalTablePage, type u as HttpStreamCallArgs, type v as LunoraClientError, type w as LunoraClientOptions, type x as LunoraErrorCode, type y as MutationSettledEvent, type z as OptimisticLocalStore, type E as OptimisticUpdate, type I as OutboxMutation, type J as OutboxSink, type K as PersistedMutation, type P as Preloaded, type N as RowOp, type T as RpcEnvelope, type V as RpcResponseBody, type W as ScheduleRecord, type X as SchedulerPoolStatus, type Y as SchedulerStatus, type Z as ServerMessage, type _ as ServerPokeEndMessage, type $ as ServerPokePartMessage, type a0 as ServerPokeStartMessage, type a1 as ShardTrafficEntry, type a2 as ShardTrafficResult, type a3 as StorageListPage, type a4 as StorageObject, type a5 as StreamHandle, type a6 as SubscriptionCallback, type b as SubscriptionErrorCallback, a7 as SubscriptionRegistry, type a8 as SubscriptionState, type a9 as SyncWatermark, type a as Unsubscribe, type U as User, type aa as WorkflowInstanceAction, type ab as WorkflowInstanceDetail, type ac as WorkflowInstancePage, type ad as WorkflowInstanceStatus, type ae as WorkflowInstanceSummary, type af as WorkflowStepDetail, type ag as WsTokenProvider, ah as createClientQuery, ai as createLocalStore, aj as createStream, ak as getErrorCode, al as getRetryAfterMs, am as isConflictError, an as isForbiddenError, ao as isRateLimitedError, ap as isUnauthorizedError } from "./packem_shared/lunora-client.d-B8bdwHLr.js";
3
+ export { p as preloadQuery, a as preloadedQueryResult } from "./packem_shared/preload.d-BPy9qajK.js";
4
4
  export type { AuthCapabilities, AuthConfigInfo, AuthImpersonation, AuthPage, AuthSession, AuthUser, AuthUserFieldSpec, CronJobInfo, KvKeyEntry, KvKeyListResult, KvNamespaceSummary, KvValueResult, VectorIndexSummary, VectorQueryMatch } from '@lunora/runtime';
5
5
  /**
6
6
  * The slice of React Native's `AsyncStorage` (or any async key/value store —
@@ -115,6 +115,21 @@ declare class TabCoordinator {
115
115
  broadcastSubscriptionError(key: string, error: SubscriptionError): void;
116
116
  private broadcast;
117
117
  private handleMessage;
118
+ private handleClaimLeadership;
119
+ private handleHeartbeat;
120
+ /**
121
+ * Resolve two leaders existing at once — e.g. this tab was backgrounded
122
+ * and its heartbeat/health timers were throttled while a foreground
123
+ * follower's were not, so the follower's `checkLeaderHealth` timed out
124
+ * the (still-alive) leader and self-promoted. `BroadcastChannel` message
125
+ * delivery isn't subject to the same timer-throttling clamp, so even a
126
+ * backgrounded leader eventually observes the pretender's heartbeat here
127
+ * — resolve the split-brain deterministically with the same
128
+ * lexicographically-smaller-tabId rule used at claim-adoption. If the
129
+ * other tab wins, step down; if we win, reassert immediately so the
130
+ * pretender demotes itself the moment it processes our heartbeat.
131
+ */
132
+ private resolveLeaderVsLeaderTieBreak;
118
133
  private becomeLeader;
119
134
  private sendHeartbeat;
120
135
  private checkLeaderHealth;
@@ -181,6 +196,43 @@ declare const isMutationDelta: (value: unknown) => value is MutationDelta;
181
196
  * when an `insert`/`update` delta carries no `row` to splice in.
182
197
  */
183
198
  declare const applyDelta: (current: unknown, delta: MutationDelta) => undefined | unknown[];
199
+ /**
200
+ * Options accepted by {@link httpStream}.
201
+ * @experimental Part of the HTTP-SSE stream surface.
202
+ */
203
+ interface HttpStreamOptions {
204
+ /**
205
+ * Origin (or origin + prefix) the route path is appended to, e.g.
206
+ * `https://my-app.example.com`. Defaults to `""` — a relative URL, which
207
+ * resolves against the page origin in a browser.
208
+ */
209
+ baseUrl?: string;
210
+ /** `fetch` implementation override; defaults to the global `fetch`. */
211
+ fetch?: typeof fetch;
212
+ /** Extra request headers (e.g. `authorization`). `accept: text/event-stream` is always sent. */
213
+ headers?: Record<string, string>;
214
+ /** Caps the in-flight chunk buffer (see `createStream`); exceeding it fails the stream. */
215
+ maxBuffer?: number;
216
+ /** External abort signal — aborting it cancels the fetch (→ the server handler's `signal`). */
217
+ signal?: AbortSignal;
218
+ }
219
+ /**
220
+ * Open a typed HTTP-SSE stream route and iterate its chunks:
221
+ *
222
+ * ```ts
223
+ * const stream = httpStream(httpStreams.http.tokens, { searchParams: { prompt } }, { baseUrl });
224
+ * for await (const token of stream) {
225
+ * render(token); // typed as the route handler's yielded chunk
226
+ * }
227
+ * ```
228
+ *
229
+ * The returned iterable terminates when the server writes `event: complete`;
230
+ * an `event: error` frame (or a transport failure) surfaces as a coded
231
+ * rejection on the next `next()`. `.cancel()` — or aborting `options.signal` —
232
+ * aborts the underlying fetch, which the server observes via `request.signal`.
233
+ * @experimental Reconnect/POST-body/wire-fidelity design questions are still open, so the shape may change.
234
+ */
235
+ declare const httpStream: <Ref extends HttpStreamRef>(route: Ref, args?: HttpStreamArgsOf<Ref>, options?: HttpStreamOptions) => StreamIterable<HttpStreamChunkOf<Ref>>;
184
236
  /** The single transport method a mutation runner needs — narrowed so adapters can test against a stub. */
185
237
  interface MutationCapableClient<F extends FunctionReference> {
186
238
  mutation: (function_: F, args: ArgsOf<F>, options?: MutationCallOptions<unknown, unknown, ArgsOf<F>>) => Promise<ReturnOf<F>>;
@@ -366,6 +418,16 @@ declare class OfflineQueue {
366
418
  * gone after a reload). No-op when no persistence adapter is configured.
367
419
  * Returns the distinct shard keys of the restored writes so the caller can
368
420
  * open their sockets to trigger a flush.
421
+ *
422
+ * `hydrate()` runs post-construction (the caller awaits an async durable-store
423
+ * load), so a mutation issued while offline during that boot window is
424
+ * enqueued into `items` *before* this method's `await` resolves. Restored
425
+ * records are therefore `unshift`-ed ahead of whatever is already queued
426
+ * rather than `push`-ed to the end: the durable store's persist order is
427
+ * authoritative (a prior-session write is always older than anything from
428
+ * this session), so replaying a same-session boot-time write before an
429
+ * older restored write on the same document would let last-writer-wins
430
+ * silently clobber the newer data with the stale one.
369
431
  */
370
432
  hydrate(): Promise<(string | undefined)[]>;
371
433
  /**
@@ -606,4 +668,4 @@ declare const sendToSw: (sw: ServiceWorker | null, message: ClientToSwMessage, e
606
668
  * Create a reply for a client message (call from inside the SW).
607
669
  */
608
670
  declare const createReply: (original: ClientToSwMessage, payload?: unknown) => SwToClientMessage;
609
- export { type ArgsOf, type AsyncStorageLike, type AsyncStoragePersistenceOptions, type BookmarkStorage, ClientServiceWorker, type ClientSwOptions, type ClientToSwMessage, type FunctionReference, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, LunoraClient, type MutationCallOptions, type MutationDelta, type MutationRunnerSinks, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, type ReconnectCalculator, type ReconnectOptions, type ReturnOf, type ServiceWorkerStatus, type SubscriptionError, type SwToClientMessage, TabCoordinator, applyDelta, createAsyncStoragePersistence, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutationRunner, createMutatorRunner, createReconnect, createReply, createSnapshotPrecondition, isMutationDelta, queryCacheKey, sendToSw };
671
+ export { type ArgsOf, type AsyncStorageLike, type AsyncStoragePersistenceOptions, type BookmarkStorage, ClientServiceWorker, type ClientSwOptions, type ClientToSwMessage, type FunctionReference, type HttpStreamArgsOf, type HttpStreamChunkOf, type HttpStreamOptions, type HttpStreamRef, type IndexedDbPersistenceOptions, type IndexedDbQueryCacheOptions, LunoraClient, type MutationCallOptions, type MutationDelta, type MutationRunnerSinks, type MutatorHandle, type MutatorRunnerSinks, type MutatorTransaction, OfflineQueue, type OfflineQueueOptions, type PersistenceAdapter, type QueryCacheAdapter, type QueuedMutation, type ReconnectCalculator, type ReconnectOptions, type ReturnOf, type ServiceWorkerStatus, type StreamIterable, type SubscriptionError, type SwToClientMessage, TabCoordinator, applyDelta, createAsyncStoragePersistence, createInMemoryBookmarkStorage, createInMemoryPersistence, createInMemoryQueryCache, createIndexedDbPersistence, createIndexedDbQueryCache, createMutationRunner, createMutatorRunner, createReconnect, createReply, createSnapshotPrecondition, httpStream, isMutationDelta, queryCacheKey, sendToSw };
package/dist/index.mjs CHANGED
@@ -1,20 +1,21 @@
1
1
  export { createAsyncStoragePersistence } from './packem_shared/createAsyncStoragePersistence-1Z5BZ8RC.mjs';
2
2
  export { default as createInMemoryBookmarkStorage } from './packem_shared/createInMemoryBookmarkStorage-BoN7a7TH.mjs';
3
- export { createClientQuery } from './packem_shared/createClientQuery-CQ51bWAE.mjs';
4
- export { TabCoordinator } from './packem_shared/TabCoordinator-BwRR8H06.mjs';
3
+ export { createClientQuery } from './packem_shared/createClientQuery-dJZg1ohm.mjs';
4
+ export { TabCoordinator } from './packem_shared/TabCoordinator-D_5oNTTt.mjs';
5
5
  export { applyDelta, isMutationDelta } from './packem_shared/applyDelta-CRKZ1PBt.mjs';
6
6
  export { CONFLICT_ERROR_CODE, getErrorCode, getRetryAfterMs, isConflictError, isForbiddenError, isRateLimitedError, isUnauthorizedError } from './packem_shared/CONFLICT_ERROR_CODE-B8gQ8tyU.mjs';
7
- export { c as createLocalStore } from './packem_shared/local-store-DtcIW4c0.mjs';
8
- export { LunoraClient } from './packem_shared/LunoraClient-Clb118SU.mjs';
7
+ export { httpStream } from './packem_shared/httpStream-DIdL8NEw.mjs';
8
+ export { c as createLocalStore } from './packem_shared/local-store-DIq-UWfD.mjs';
9
+ export { LunoraClient } from './packem_shared/LunoraClient-D3h4P7hg.mjs';
9
10
  export { createMutationRunner } from './packem_shared/createMutationRunner-BqsavzvG.mjs';
10
11
  export { createMutatorRunner } from './packem_shared/createMutatorRunner-BETvCd0p.mjs';
11
- export { O as OfflineQueue } from './packem_shared/offline-queue-CF4_Co5k.mjs';
12
+ export { O as OfflineQueue } from './packem_shared/offline-queue-N-1JvYb4.mjs';
12
13
  export { createInMemoryPersistence, createIndexedDbPersistence } from './packem_shared/createInMemoryPersistence-DZ2VHWgm.mjs';
13
14
  export { preloadQuery, preloadedQueryResult } from './packem_shared/preloadQuery-lobFkD2Z.mjs';
14
15
  export { createInMemoryQueryCache, createIndexedDbQueryCache, queryCacheKey } from './packem_shared/createInMemoryQueryCache-DiaGZkA2.mjs';
15
16
  export { createReconnect } from './packem_shared/createReconnect-Di_-oHH7.mjs';
16
- export { default as createSnapshotPrecondition } from './packem_shared/createSnapshotPrecondition-CBwnVz6r.mjs';
17
+ export { default as createSnapshotPrecondition } from './packem_shared/createSnapshotPrecondition-CxQ1T4ZP.mjs';
17
18
  export { DEFAULT_MAX_BUFFER, createStream } from './packem_shared/DEFAULT_MAX_BUFFER-7hFnzNk9.mjs';
18
- export { SubscriptionRegistry } from './packem_shared/SubscriptionRegistry-D4jfIzZu.mjs';
19
+ export { SubscriptionRegistry } from './packem_shared/SubscriptionRegistry-CxS_Inha.mjs';
19
20
  export { ClientServiceWorker } from './packem_shared/ClientServiceWorker-C3PAFwy0.mjs';
20
21
  export { createReply, sendToSw } from './packem_shared/createReply-lI4tVS2w.mjs';