@lunora/client 1.0.0-alpha.23 → 1.0.0-alpha.25

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 (28) hide show
  1. package/dist/auth/index.d.mts +10 -10
  2. package/dist/auth/index.d.ts +10 -10
  3. package/dist/index.d.mts +344 -357
  4. package/dist/index.d.ts +344 -357
  5. package/dist/index.mjs +5 -5
  6. package/dist/packem_shared/{LunoraClient-BBCQjjbl.mjs → LunoraClient-D3h4P7hg.mjs} +18 -4
  7. package/dist/packem_shared/{OfflineQueue-B4HUF7rt.mjs → OfflineQueue-BgarnAub.mjs} +1 -1
  8. package/dist/packem_shared/{TabCoordinator-BwRR8H06.mjs → TabCoordinator-D_5oNTTt.mjs} +48 -12
  9. package/dist/packem_shared/{createClientQuery-CQ51bWAE.mjs → createClientQuery-dJZg1ohm.mjs} +15 -6
  10. package/dist/packem_shared/{createServerClient-CTTAmvMx.mjs → createServerClient-DzeC2J3A.mjs} +1 -1
  11. package/dist/packem_shared/{httpStream-BJU-aflc.mjs → httpStream-DIdL8NEw.mjs} +33 -24
  12. package/dist/packem_shared/lunora-client.d-C4ud8bej.d.mts +2834 -0
  13. package/dist/packem_shared/lunora-client.d-C4ud8bej.d.ts +2834 -0
  14. package/dist/packem_shared/{offline-queue-CF4_Co5k.mjs → offline-queue-N-1JvYb4.mjs} +14 -2
  15. package/dist/packem_shared/preload.d-B6-lqUf2.d.ts +20 -0
  16. package/dist/packem_shared/preload.d-Dvk8zg6m.d.mts +20 -0
  17. package/dist/pagination/index.d.mts +42 -42
  18. package/dist/pagination/index.d.ts +42 -42
  19. package/dist/query/index.d.mts +42 -42
  20. package/dist/query/index.d.ts +42 -42
  21. package/dist/ssr/index.d.mts +79 -79
  22. package/dist/ssr/index.d.ts +79 -79
  23. package/dist/ssr/index.mjs +1 -1
  24. package/package.json +2 -2
  25. package/dist/packem_shared/lunora-client.d-JvtVpf8A.d.mts +0 -2824
  26. package/dist/packem_shared/lunora-client.d-JvtVpf8A.d.ts +0 -2824
  27. package/dist/packem_shared/preload.d-C4_d_l5v.d.ts +0 -20
  28. package/dist/packem_shared/preload.d-DKbjGN5O.d.mts +0 -20
@@ -79,6 +79,16 @@ class OfflineQueue {
79
79
  * gone after a reload). No-op when no persistence adapter is configured.
80
80
  * Returns the distinct shard keys of the restored writes so the caller can
81
81
  * open their sockets to trigger a flush.
82
+ *
83
+ * `hydrate()` runs post-construction (the caller awaits an async durable-store
84
+ * load), so a mutation issued while offline during that boot window is
85
+ * enqueued into `items` *before* this method's `await` resolves. Restored
86
+ * records are therefore `unshift`-ed ahead of whatever is already queued
87
+ * rather than `push`-ed to the end: the durable store's persist order is
88
+ * authoritative (a prior-session write is always older than anything from
89
+ * this session), so replaying a same-session boot-time write before an
90
+ * older restored write on the same document would let last-writer-wins
91
+ * silently clobber the newer data with the stale one.
82
92
  */
83
93
  async hydrate() {
84
94
  if (!this.persistence) {
@@ -92,8 +102,9 @@ class OfflineQueue {
92
102
  throw error;
93
103
  }
94
104
  const shardKeys = /* @__PURE__ */ new Set();
105
+ const restored = [];
95
106
  for (const mutation of persisted) {
96
- if (this.items.some((item) => item.id === mutation.id)) {
107
+ if (this.items.some((item) => item.id === mutation.id) || restored.some((item) => item.id === mutation.id)) {
97
108
  continue;
98
109
  }
99
110
  if (isStaleVersion(this.version, mutation.version)) {
@@ -102,7 +113,7 @@ class OfflineQueue {
102
113
  });
103
114
  continue;
104
115
  }
105
- this.items.push({
116
+ restored.push({
106
117
  args: mutation.args,
107
118
  functionPath: mutation.functionPath,
108
119
  id: mutation.id,
@@ -113,6 +124,7 @@ class OfflineQueue {
113
124
  });
114
125
  shardKeys.add(mutation.shardKey);
115
126
  }
127
+ this.items.unshift(...restored);
116
128
  this.notifySize();
117
129
  return [...shardKeys];
118
130
  }
@@ -0,0 +1,20 @@
1
+ import { F as FunctionReference, L as LunoraClient, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./lunora-client.d-C4ud8bej.js";
2
+ /**
3
+ * Run a query once on the server (during SSR) and capture its result in a
4
+ * serializable {@link Preloaded} token. Embed the token in the rendered HTML and
5
+ * pass it to `usePreloadedQuery` on the client: the first client render shows
6
+ * the server value with no loading flash, then a live subscription takes over.
7
+ *
8
+ * The query is executed through the supplied {@link LunoraClient} over the same
9
+ * HTTP RPC path the browser uses, so the SSR client only needs a `fetch`
10
+ * implementation that can reach the worker — no in-process Durable Object access.
11
+ */
12
+ declare const preloadQuery: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
13
+ shardKey?: string;
14
+ }) => Promise<Preloaded<ReturnOf<F>>>;
15
+ /**
16
+ * Read the captured value out of a {@link Preloaded} token without subscribing.
17
+ * Useful on the server (or in tests) when you only need the data, not a live feed.
18
+ */
19
+ declare const preloadedQueryResult: <T>(preloaded: Preloaded<T>) => T;
20
+ export { preloadedQueryResult as a, preloadQuery as p };
@@ -0,0 +1,20 @@
1
+ import { F as FunctionReference, L as LunoraClient, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./lunora-client.d-C4ud8bej.mjs";
2
+ /**
3
+ * Run a query once on the server (during SSR) and capture its result in a
4
+ * serializable {@link Preloaded} token. Embed the token in the rendered HTML and
5
+ * pass it to `usePreloadedQuery` on the client: the first client render shows
6
+ * the server value with no loading flash, then a live subscription takes over.
7
+ *
8
+ * The query is executed through the supplied {@link LunoraClient} over the same
9
+ * HTTP RPC path the browser uses, so the SSR client only needs a `fetch`
10
+ * implementation that can reach the worker — no in-process Durable Object access.
11
+ */
12
+ declare const preloadQuery: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
13
+ shardKey?: string;
14
+ }) => Promise<Preloaded<ReturnOf<F>>>;
15
+ /**
16
+ * Read the captured value out of a {@link Preloaded} token without subscribing.
17
+ * Useful on the server (or in tests) when you only need the data, not a live feed.
18
+ */
19
+ declare const preloadedQueryResult: <T>(preloaded: Preloaded<T>) => T;
20
+ export { preloadedQueryResult as a, preloadQuery as p };
@@ -1,13 +1,13 @@
1
1
  /**
2
- * `@lunora/client/pagination` — the framework-agnostic pagination state machine
3
- * shared by every Lunora UI adapter (React, Vue, Svelte, Solid).
4
- *
5
- * Owns cursor tracking, page-size rebalancing (split/join), `initialPages`,
6
- * `rebalance`, and the shared types (`Page`, `PaginationResult`,
7
- * `PaginationStatus`, `PaginatedCoreResult`). Nothing here imports a UI
8
- * framework — each adapter wires the pure functions into its own reactive
9
- * primitives.
10
- */
2
+ * `@lunora/client/pagination` — the framework-agnostic pagination state machine
3
+ * shared by every Lunora UI adapter (React, Vue, Svelte, Solid).
4
+ *
5
+ * Owns cursor tracking, page-size rebalancing (split/join), `initialPages`,
6
+ * `rebalance`, and the shared types (`Page`, `PaginationResult`,
7
+ * `PaginationStatus`, `PaginatedCoreResult`). Nothing here imports a UI
8
+ * framework — each adapter wires the pure functions into its own reactive
9
+ * primitives.
10
+ */
11
11
  /** Grow factor: a bounded page is split when it exceeds this multiple of its target size. */
12
12
  declare const SPLIT_FACTOR = 2;
13
13
  /** Shrink factor: a bounded page with a neighbour is joined when it falls below this multiple of its target size. */
@@ -24,20 +24,20 @@ interface PaginationResult<T = unknown> {
24
24
  isDone: boolean;
25
25
  page: T[];
26
26
  /**
27
- * Reactive-pagination only: the midpoint cursor of a bounded
28
- * `(cursor, endCursor]` page, used to split an over-grown page into two
29
- * adjacent ranges. Absent on legacy (open-ended) pages.
30
- */
27
+ * Reactive-pagination only: the midpoint cursor of a bounded
28
+ * `(cursor, endCursor]` page, used to split an over-grown page into two
29
+ * adjacent ranges. Absent on legacy (open-ended) pages.
30
+ */
31
31
  splitCursor?: null | string;
32
32
  }
33
33
  /**
34
- * Lifecycle of a `usePaginatedQuery` feed.
35
- *
36
- * - `LoadingFirstPage` — the first page is in flight; `results` is empty.
37
- * - `CanLoadMore` — the loaded tail has a cursor; calling `loadMore` fetches the next page.
38
- * - `LoadingMore` — a `loadMore` page is in flight; earlier results stay visible.
39
- * - `Exhausted` — every page has loaded and the server reported `isDone`.
40
- */
34
+ * Lifecycle of a `usePaginatedQuery` feed.
35
+ *
36
+ * - `LoadingFirstPage` — the first page is in flight; `results` is empty.
37
+ * - `CanLoadMore` — the loaded tail has a cursor; calling `loadMore` fetches the next page.
38
+ * - `LoadingMore` — a `loadMore` page is in flight; earlier results stay visible.
39
+ * - `Exhausted` — every page has loaded and the server reported `isDone`.
40
+ */
41
41
  type PaginationStatus = "CanLoadMore" | "Exhausted" | "LoadingFirstPage" | "LoadingMore";
42
42
  interface PaginatedCoreResult<T> {
43
43
  /** Request another page off the open-ended tail. A no-op unless `status === "CanLoadMore"`. */
@@ -49,34 +49,34 @@ interface PaginatedCoreResult<T> {
49
49
  /** First-page seed: a single open-ended range starting at the feed head. */
50
50
  declare const initialPages: (numberItems: number) => Page[];
51
51
  /**
52
- * Run the SPLIT/JOIN maintenance pass over the current page list given freshly
53
- * resolved results. Returns a new page list when a boundary changed, or
54
- * `undefined` when the layout is already balanced (so the caller can skip a
55
- * setState).
56
- *
57
- * Only ONE structural edit is applied per pass (the first split or join found),
58
- * letting the subsequent re-render's resolved results drive the next pass — this
59
- * keeps each transition observable and avoids reasoning about several
60
- * simultaneous boundary moves.
61
- */
52
+ * Run the SPLIT/JOIN maintenance pass over the current page list given freshly
53
+ * resolved results. Returns a new page list when a boundary changed, or
54
+ * `undefined` when the layout is already balanced (so the caller can skip a
55
+ * setState).
56
+ *
57
+ * Only ONE structural edit is applied per pass (the first split or join found),
58
+ * letting the subsequent re-render's resolved results drive the next pass — this
59
+ * keeps each transition observable and avoids reasoning about several
60
+ * simultaneous boundary moves.
61
+ */
62
62
  declare const rebalance: (pages: Page[], results: (PaginationResult | undefined)[]) => Page[] | undefined;
63
63
  /**
64
- * Derive the feed `status` and the next-page cursor from the current page list
65
- * and resolved page results. Framework adapters call this each render/effect to
66
- * compute what to expose to callers.
67
- */
64
+ * Derive the feed `status` and the next-page cursor from the current page list
65
+ * and resolved page results. Framework adapters call this each render/effect to
66
+ * compute what to expose to callers.
67
+ */
68
68
  declare const derivePaginationStatus: <T>(skipped: boolean, pageResults: (PaginationResult<T> | undefined)[]) => {
69
69
  nextCursor: null | string | undefined;
70
70
  status: PaginationStatus;
71
71
  };
72
72
  /**
73
- * Apply a `loadMore` to the current page list. Pins the open-ended tail at
74
- * `cursor` (making it a fixed bounded range) and appends a fresh open-ended
75
- * page starting at `cursor`. The shared boundary keeps the feed gap- and
76
- * dup-free.
77
- *
78
- * Returns the new page list, or `undefined` when the given `cursor` is not
79
- * valid (null or undefined — caller should no-op).
80
- */
73
+ * Apply a `loadMore` to the current page list. Pins the open-ended tail at
74
+ * `cursor` (making it a fixed bounded range) and appends a fresh open-ended
75
+ * page starting at `cursor`. The shared boundary keeps the feed gap- and
76
+ * dup-free.
77
+ *
78
+ * Returns the new page list, or `undefined` when the given `cursor` is not
79
+ * valid (null or undefined — caller should no-op).
80
+ */
81
81
  declare const applyLoadMore: (pages: Page[], cursor: null | string | undefined, numberItems: number) => Page[] | undefined;
82
82
  export { JOIN_FACTOR, type Page, type PaginatedCoreResult, type PaginationResult, type PaginationStatus, SPLIT_FACTOR, applyLoadMore, derivePaginationStatus, initialPages, rebalance };
@@ -1,13 +1,13 @@
1
1
  /**
2
- * `@lunora/client/pagination` — the framework-agnostic pagination state machine
3
- * shared by every Lunora UI adapter (React, Vue, Svelte, Solid).
4
- *
5
- * Owns cursor tracking, page-size rebalancing (split/join), `initialPages`,
6
- * `rebalance`, and the shared types (`Page`, `PaginationResult`,
7
- * `PaginationStatus`, `PaginatedCoreResult`). Nothing here imports a UI
8
- * framework — each adapter wires the pure functions into its own reactive
9
- * primitives.
10
- */
2
+ * `@lunora/client/pagination` — the framework-agnostic pagination state machine
3
+ * shared by every Lunora UI adapter (React, Vue, Svelte, Solid).
4
+ *
5
+ * Owns cursor tracking, page-size rebalancing (split/join), `initialPages`,
6
+ * `rebalance`, and the shared types (`Page`, `PaginationResult`,
7
+ * `PaginationStatus`, `PaginatedCoreResult`). Nothing here imports a UI
8
+ * framework — each adapter wires the pure functions into its own reactive
9
+ * primitives.
10
+ */
11
11
  /** Grow factor: a bounded page is split when it exceeds this multiple of its target size. */
12
12
  declare const SPLIT_FACTOR = 2;
13
13
  /** Shrink factor: a bounded page with a neighbour is joined when it falls below this multiple of its target size. */
@@ -24,20 +24,20 @@ interface PaginationResult<T = unknown> {
24
24
  isDone: boolean;
25
25
  page: T[];
26
26
  /**
27
- * Reactive-pagination only: the midpoint cursor of a bounded
28
- * `(cursor, endCursor]` page, used to split an over-grown page into two
29
- * adjacent ranges. Absent on legacy (open-ended) pages.
30
- */
27
+ * Reactive-pagination only: the midpoint cursor of a bounded
28
+ * `(cursor, endCursor]` page, used to split an over-grown page into two
29
+ * adjacent ranges. Absent on legacy (open-ended) pages.
30
+ */
31
31
  splitCursor?: null | string;
32
32
  }
33
33
  /**
34
- * Lifecycle of a `usePaginatedQuery` feed.
35
- *
36
- * - `LoadingFirstPage` — the first page is in flight; `results` is empty.
37
- * - `CanLoadMore` — the loaded tail has a cursor; calling `loadMore` fetches the next page.
38
- * - `LoadingMore` — a `loadMore` page is in flight; earlier results stay visible.
39
- * - `Exhausted` — every page has loaded and the server reported `isDone`.
40
- */
34
+ * Lifecycle of a `usePaginatedQuery` feed.
35
+ *
36
+ * - `LoadingFirstPage` — the first page is in flight; `results` is empty.
37
+ * - `CanLoadMore` — the loaded tail has a cursor; calling `loadMore` fetches the next page.
38
+ * - `LoadingMore` — a `loadMore` page is in flight; earlier results stay visible.
39
+ * - `Exhausted` — every page has loaded and the server reported `isDone`.
40
+ */
41
41
  type PaginationStatus = "CanLoadMore" | "Exhausted" | "LoadingFirstPage" | "LoadingMore";
42
42
  interface PaginatedCoreResult<T> {
43
43
  /** Request another page off the open-ended tail. A no-op unless `status === "CanLoadMore"`. */
@@ -49,34 +49,34 @@ interface PaginatedCoreResult<T> {
49
49
  /** First-page seed: a single open-ended range starting at the feed head. */
50
50
  declare const initialPages: (numberItems: number) => Page[];
51
51
  /**
52
- * Run the SPLIT/JOIN maintenance pass over the current page list given freshly
53
- * resolved results. Returns a new page list when a boundary changed, or
54
- * `undefined` when the layout is already balanced (so the caller can skip a
55
- * setState).
56
- *
57
- * Only ONE structural edit is applied per pass (the first split or join found),
58
- * letting the subsequent re-render's resolved results drive the next pass — this
59
- * keeps each transition observable and avoids reasoning about several
60
- * simultaneous boundary moves.
61
- */
52
+ * Run the SPLIT/JOIN maintenance pass over the current page list given freshly
53
+ * resolved results. Returns a new page list when a boundary changed, or
54
+ * `undefined` when the layout is already balanced (so the caller can skip a
55
+ * setState).
56
+ *
57
+ * Only ONE structural edit is applied per pass (the first split or join found),
58
+ * letting the subsequent re-render's resolved results drive the next pass — this
59
+ * keeps each transition observable and avoids reasoning about several
60
+ * simultaneous boundary moves.
61
+ */
62
62
  declare const rebalance: (pages: Page[], results: (PaginationResult | undefined)[]) => Page[] | undefined;
63
63
  /**
64
- * Derive the feed `status` and the next-page cursor from the current page list
65
- * and resolved page results. Framework adapters call this each render/effect to
66
- * compute what to expose to callers.
67
- */
64
+ * Derive the feed `status` and the next-page cursor from the current page list
65
+ * and resolved page results. Framework adapters call this each render/effect to
66
+ * compute what to expose to callers.
67
+ */
68
68
  declare const derivePaginationStatus: <T>(skipped: boolean, pageResults: (PaginationResult<T> | undefined)[]) => {
69
69
  nextCursor: null | string | undefined;
70
70
  status: PaginationStatus;
71
71
  };
72
72
  /**
73
- * Apply a `loadMore` to the current page list. Pins the open-ended tail at
74
- * `cursor` (making it a fixed bounded range) and appends a fresh open-ended
75
- * page starting at `cursor`. The shared boundary keeps the feed gap- and
76
- * dup-free.
77
- *
78
- * Returns the new page list, or `undefined` when the given `cursor` is not
79
- * valid (null or undefined — caller should no-op).
80
- */
73
+ * Apply a `loadMore` to the current page list. Pins the open-ended tail at
74
+ * `cursor` (making it a fixed bounded range) and appends a fresh open-ended
75
+ * page starting at `cursor`. The shared boundary keeps the feed gap- and
76
+ * dup-free.
77
+ *
78
+ * Returns the new page list, or `undefined` when the given `cursor` is not
79
+ * valid (null or undefined — caller should no-op).
80
+ */
81
81
  declare const applyLoadMore: (pages: Page[], cursor: null | string | undefined, numberItems: number) => Page[] | undefined;
82
82
  export { JOIN_FACTOR, type Page, type PaginatedCoreResult, type PaginationResult, type PaginationStatus, SPLIT_FACTOR, applyLoadMore, derivePaginationStatus, initialPages, rebalance };
@@ -1,26 +1,26 @@
1
- import { S as SubscriptionError, F as FunctionReference, A as ArgsOf, R as ReturnOf, L as LunoraClient, a as Unsubscribe } from "../packem_shared/lunora-client.d-JvtVpf8A.mjs";
2
- export type { b as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-JvtVpf8A.mjs";
1
+ import { S as SubscriptionError, F as FunctionReference, A as ArgsOf, R as ReturnOf, L as LunoraClient, a as Unsubscribe } from "../packem_shared/lunora-client.d-C4ud8bej.mjs";
2
+ export type { b as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-C4ud8bej.mjs";
3
3
  import '@lunora/runtime';
4
4
  /**
5
- * The sentinel a framework adapter resolves its reactive args to when it wants
6
- * to short-circuit a query — no network call, no socket.
7
- */
5
+ * The sentinel a framework adapter resolves its reactive args to when it wants
6
+ * to short-circuit a query — no network call, no socket.
7
+ */
8
8
  declare const SKIP: "skip";
9
9
  /** Args after a framework has resolved its reactivity primitive, or the skip sentinel. */
10
10
  type ResolvedArgs<F extends FunctionReference> = ArgsOf<F> | typeof SKIP;
11
11
  /**
12
- * The framework-neutral sinks a {@link createQuerySubscription} call drives. A
13
- * framework adapter supplies these, wiring each into its own reactivity
14
- * primitive (a TanStack cache write, a Vue `ref`, a Svelte store `set`, a Solid
15
- * signal setter).
16
- *
17
- * `onData` fires when a fresh server value lands (the initial frame or a delta).
18
- * `onError` fires when the subscription attach threw, or the server pushed a
19
- * subscription-scoped error — it is optional, and when omitted an attach throw
20
- * propagates to the caller (preserving the "no error channel" behaviour of
21
- * adapters like Solid/Vue that never had one) rather than being swallowed.
22
- * `onReset` fires when the resolved args are `"skip"`: clear any prior value.
23
- */
12
+ * The framework-neutral sinks a {@link createQuerySubscription} call drives. A
13
+ * framework adapter supplies these, wiring each into its own reactivity
14
+ * primitive (a TanStack cache write, a Vue `ref`, a Svelte store `set`, a Solid
15
+ * signal setter).
16
+ *
17
+ * `onData` fires when a fresh server value lands (the initial frame or a delta).
18
+ * `onError` fires when the subscription attach threw, or the server pushed a
19
+ * subscription-scoped error — it is optional, and when omitted an attach throw
20
+ * propagates to the caller (preserving the "no error channel" behaviour of
21
+ * adapters like Solid/Vue that never had one) rather than being swallowed.
22
+ * `onReset` fires when the resolved args are `"skip"`: clear any prior value.
23
+ */
24
24
  interface QuerySubscriptionSinks<T> {
25
25
  onData: (value: T) => void;
26
26
  onError?: (error: SubscriptionError) => void;
@@ -33,30 +33,30 @@ interface QuerySubscriptionOptions {
33
33
  /** Normalise an unknown thrown value into the client's {@link SubscriptionError} shape. */
34
34
  declare const toSubscriptionError: (error: unknown) => SubscriptionError;
35
35
  /**
36
- * The subscribe → snapshot → error/reset → cleanup state machine shared by
37
- * every Lunora framework adapter's live-query hook.
38
- *
39
- * Given a `client`, a function reference, the already-resolved `args` (a
40
- * framework reads its own reactive source first, then hands the plain value in),
41
- * and a set of {@link QuerySubscriptionSinks}, this opens one `client.subscribe`
42
- * registration and returns the {@link Unsubscribe} to tear it down. Each
43
- * framework owns *when* to call this (a React effect, a Vue `watch`, a Svelte
44
- * store start callback, a Solid `createEffect(on(...))`) and *where* to stash
45
- * the value — this owns the lifecycle in between, so the skip-handling, the
46
- * value/error fan-out, the attach-throw normalisation, and the
47
- * cancellation-guarded teardown live in exactly one place.
48
- *
49
- * Behaviour. When `args === "skip"` it calls `sinks.onReset?.()` and returns a
50
- * no-op teardown; no `client.subscribe` is issued. Otherwise it opens
51
- * `client.subscribe(fn, args, …, { shardKey, onError })`: server pushes route to
52
- * `sinks.onData`, and the client's own `onError` channel (a server-rejected
53
- * subscription) routes to `sinks.onError` when present. The attach is wrapped —
54
- * if `client.subscribe` itself throws, the error is normalised to a
55
- * {@link SubscriptionError} and delivered to `sinks.onError` when present; with
56
- * no `onError` sink the throw is rethrown so adapters without an error channel
57
- * behave exactly as before. The returned teardown is idempotent and
58
- * cancellation-guarded: once it runs, no further `onData`/`onError` from an
59
- * in-flight push reaches the sinks.
60
- */
36
+ * The subscribe → snapshot → error/reset → cleanup state machine shared by
37
+ * every Lunora framework adapter's live-query hook.
38
+ *
39
+ * Given a `client`, a function reference, the already-resolved `args` (a
40
+ * framework reads its own reactive source first, then hands the plain value in),
41
+ * and a set of {@link QuerySubscriptionSinks}, this opens one `client.subscribe`
42
+ * registration and returns the {@link Unsubscribe} to tear it down. Each
43
+ * framework owns *when* to call this (a React effect, a Vue `watch`, a Svelte
44
+ * store start callback, a Solid `createEffect(on(...))`) and *where* to stash
45
+ * the value — this owns the lifecycle in between, so the skip-handling, the
46
+ * value/error fan-out, the attach-throw normalisation, and the
47
+ * cancellation-guarded teardown live in exactly one place.
48
+ *
49
+ * Behaviour. When `args === "skip"` it calls `sinks.onReset?.()` and returns a
50
+ * no-op teardown; no `client.subscribe` is issued. Otherwise it opens
51
+ * `client.subscribe(fn, args, …, { shardKey, onError })`: server pushes route to
52
+ * `sinks.onData`, and the client's own `onError` channel (a server-rejected
53
+ * subscription) routes to `sinks.onError` when present. The attach is wrapped —
54
+ * if `client.subscribe` itself throws, the error is normalised to a
55
+ * {@link SubscriptionError} and delivered to `sinks.onError` when present; with
56
+ * no `onError` sink the throw is rethrown so adapters without an error channel
57
+ * behave exactly as before. The returned teardown is idempotent and
58
+ * cancellation-guarded: once it runs, no further `onData`/`onError` from an
59
+ * in-flight push reaches the sinks.
60
+ */
61
61
  declare const createQuerySubscription: <F extends FunctionReference, T = ReturnOf<F>>(client: LunoraClient, function_: F, args: ResolvedArgs<F>, sinks: QuerySubscriptionSinks<T>, options?: QuerySubscriptionOptions) => Unsubscribe;
62
62
  export { type ArgsOf, type FunctionReference, type QuerySubscriptionOptions, type QuerySubscriptionSinks, type ResolvedArgs, type ReturnOf, SKIP, type SubscriptionError, type Unsubscribe, createQuerySubscription, toSubscriptionError };
@@ -1,26 +1,26 @@
1
- import { S as SubscriptionError, F as FunctionReference, A as ArgsOf, R as ReturnOf, L as LunoraClient, a as Unsubscribe } from "../packem_shared/lunora-client.d-JvtVpf8A.js";
2
- export type { b as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-JvtVpf8A.js";
1
+ import { S as SubscriptionError, F as FunctionReference, A as ArgsOf, R as ReturnOf, L as LunoraClient, a as Unsubscribe } from "../packem_shared/lunora-client.d-C4ud8bej.js";
2
+ export type { b as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-C4ud8bej.js";
3
3
  import '@lunora/runtime';
4
4
  /**
5
- * The sentinel a framework adapter resolves its reactive args to when it wants
6
- * to short-circuit a query — no network call, no socket.
7
- */
5
+ * The sentinel a framework adapter resolves its reactive args to when it wants
6
+ * to short-circuit a query — no network call, no socket.
7
+ */
8
8
  declare const SKIP: "skip";
9
9
  /** Args after a framework has resolved its reactivity primitive, or the skip sentinel. */
10
10
  type ResolvedArgs<F extends FunctionReference> = ArgsOf<F> | typeof SKIP;
11
11
  /**
12
- * The framework-neutral sinks a {@link createQuerySubscription} call drives. A
13
- * framework adapter supplies these, wiring each into its own reactivity
14
- * primitive (a TanStack cache write, a Vue `ref`, a Svelte store `set`, a Solid
15
- * signal setter).
16
- *
17
- * `onData` fires when a fresh server value lands (the initial frame or a delta).
18
- * `onError` fires when the subscription attach threw, or the server pushed a
19
- * subscription-scoped error — it is optional, and when omitted an attach throw
20
- * propagates to the caller (preserving the "no error channel" behaviour of
21
- * adapters like Solid/Vue that never had one) rather than being swallowed.
22
- * `onReset` fires when the resolved args are `"skip"`: clear any prior value.
23
- */
12
+ * The framework-neutral sinks a {@link createQuerySubscription} call drives. A
13
+ * framework adapter supplies these, wiring each into its own reactivity
14
+ * primitive (a TanStack cache write, a Vue `ref`, a Svelte store `set`, a Solid
15
+ * signal setter).
16
+ *
17
+ * `onData` fires when a fresh server value lands (the initial frame or a delta).
18
+ * `onError` fires when the subscription attach threw, or the server pushed a
19
+ * subscription-scoped error — it is optional, and when omitted an attach throw
20
+ * propagates to the caller (preserving the "no error channel" behaviour of
21
+ * adapters like Solid/Vue that never had one) rather than being swallowed.
22
+ * `onReset` fires when the resolved args are `"skip"`: clear any prior value.
23
+ */
24
24
  interface QuerySubscriptionSinks<T> {
25
25
  onData: (value: T) => void;
26
26
  onError?: (error: SubscriptionError) => void;
@@ -33,30 +33,30 @@ interface QuerySubscriptionOptions {
33
33
  /** Normalise an unknown thrown value into the client's {@link SubscriptionError} shape. */
34
34
  declare const toSubscriptionError: (error: unknown) => SubscriptionError;
35
35
  /**
36
- * The subscribe → snapshot → error/reset → cleanup state machine shared by
37
- * every Lunora framework adapter's live-query hook.
38
- *
39
- * Given a `client`, a function reference, the already-resolved `args` (a
40
- * framework reads its own reactive source first, then hands the plain value in),
41
- * and a set of {@link QuerySubscriptionSinks}, this opens one `client.subscribe`
42
- * registration and returns the {@link Unsubscribe} to tear it down. Each
43
- * framework owns *when* to call this (a React effect, a Vue `watch`, a Svelte
44
- * store start callback, a Solid `createEffect(on(...))`) and *where* to stash
45
- * the value — this owns the lifecycle in between, so the skip-handling, the
46
- * value/error fan-out, the attach-throw normalisation, and the
47
- * cancellation-guarded teardown live in exactly one place.
48
- *
49
- * Behaviour. When `args === "skip"` it calls `sinks.onReset?.()` and returns a
50
- * no-op teardown; no `client.subscribe` is issued. Otherwise it opens
51
- * `client.subscribe(fn, args, …, { shardKey, onError })`: server pushes route to
52
- * `sinks.onData`, and the client's own `onError` channel (a server-rejected
53
- * subscription) routes to `sinks.onError` when present. The attach is wrapped —
54
- * if `client.subscribe` itself throws, the error is normalised to a
55
- * {@link SubscriptionError} and delivered to `sinks.onError` when present; with
56
- * no `onError` sink the throw is rethrown so adapters without an error channel
57
- * behave exactly as before. The returned teardown is idempotent and
58
- * cancellation-guarded: once it runs, no further `onData`/`onError` from an
59
- * in-flight push reaches the sinks.
60
- */
36
+ * The subscribe → snapshot → error/reset → cleanup state machine shared by
37
+ * every Lunora framework adapter's live-query hook.
38
+ *
39
+ * Given a `client`, a function reference, the already-resolved `args` (a
40
+ * framework reads its own reactive source first, then hands the plain value in),
41
+ * and a set of {@link QuerySubscriptionSinks}, this opens one `client.subscribe`
42
+ * registration and returns the {@link Unsubscribe} to tear it down. Each
43
+ * framework owns *when* to call this (a React effect, a Vue `watch`, a Svelte
44
+ * store start callback, a Solid `createEffect(on(...))`) and *where* to stash
45
+ * the value — this owns the lifecycle in between, so the skip-handling, the
46
+ * value/error fan-out, the attach-throw normalisation, and the
47
+ * cancellation-guarded teardown live in exactly one place.
48
+ *
49
+ * Behaviour. When `args === "skip"` it calls `sinks.onReset?.()` and returns a
50
+ * no-op teardown; no `client.subscribe` is issued. Otherwise it opens
51
+ * `client.subscribe(fn, args, …, { shardKey, onError })`: server pushes route to
52
+ * `sinks.onData`, and the client's own `onError` channel (a server-rejected
53
+ * subscription) routes to `sinks.onError` when present. The attach is wrapped —
54
+ * if `client.subscribe` itself throws, the error is normalised to a
55
+ * {@link SubscriptionError} and delivered to `sinks.onError` when present; with
56
+ * no `onError` sink the throw is rethrown so adapters without an error channel
57
+ * behave exactly as before. The returned teardown is idempotent and
58
+ * cancellation-guarded: once it runs, no further `onData`/`onError` from an
59
+ * in-flight push reaches the sinks.
60
+ */
61
61
  declare const createQuerySubscription: <F extends FunctionReference, T = ReturnOf<F>>(client: LunoraClient, function_: F, args: ResolvedArgs<F>, sinks: QuerySubscriptionSinks<T>, options?: QuerySubscriptionOptions) => Unsubscribe;
62
62
  export { type ArgsOf, type FunctionReference, type QuerySubscriptionOptions, type QuerySubscriptionSinks, type ResolvedArgs, type ReturnOf, SKIP, type SubscriptionError, type Unsubscribe, createQuerySubscription, toSubscriptionError };