@lunora/client 1.0.0-alpha.6 → 1.0.0-alpha.60

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 (88) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/auth/index.d.mts +11 -10
  3. package/dist/auth/index.d.ts +11 -10
  4. package/dist/auth/index.mjs +1 -60
  5. package/dist/index.d.mts +768 -230
  6. package/dist/index.d.ts +768 -230
  7. package/dist/index.mjs +1 -15
  8. package/dist/packem_shared/CONFLICT_ERROR_CODE-LjU7z0mB.mjs +1 -0
  9. package/dist/packem_shared/ClientServiceWorker-DXnBXeWK.mjs +1 -0
  10. package/dist/packem_shared/DEFAULT_MAX_BUFFER-D3QH2iaq.mjs +1 -0
  11. package/dist/packem_shared/LunoraClient-akyZf9CJ.mjs +1 -0
  12. package/dist/packem_shared/OfflineQueue-DG51qWl4.mjs +1 -0
  13. package/dist/packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs +1 -0
  14. package/dist/packem_shared/SKIP-d7LeP-sY.mjs +1 -0
  15. package/dist/packem_shared/SubscriptionRegistry-CdHSrDqu.mjs +1 -0
  16. package/dist/packem_shared/TabCoordinator-DVKG2RlZ.mjs +1 -0
  17. package/dist/packem_shared/anyApi-CBOws2ZA.mjs +1 -0
  18. package/dist/packem_shared/applyDelta-DGqMpi3N.mjs +1 -0
  19. package/dist/packem_shared/createAsyncStoragePersistence-CNdM5o1u.mjs +1 -0
  20. package/dist/packem_shared/createAsyncStorageQueryCache-Di-S52wy.mjs +1 -0
  21. package/dist/packem_shared/createCallRunner-Bwcrfh76.mjs +1 -0
  22. package/dist/packem_shared/createClientQuery-TKD_52cT.mjs +1 -0
  23. package/dist/packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs +1 -0
  24. package/dist/packem_shared/createInMemoryPersistence-C0qm7c47.mjs +1 -0
  25. package/dist/packem_shared/createInMemoryQueryCache-D2uNHLfM.mjs +1 -0
  26. package/dist/packem_shared/createLocalStore-CZwiN9F4.mjs +1 -0
  27. package/dist/packem_shared/createMutatorRunner-CuMRJpUx.mjs +1 -0
  28. package/dist/packem_shared/createReconnect-CjTmjJDH.mjs +1 -0
  29. package/dist/packem_shared/createReply-CwFABEJs.mjs +1 -0
  30. package/dist/packem_shared/createServerClient-DXhPwQ8T.mjs +1 -0
  31. package/dist/packem_shared/createSnapshotPrecondition-BPMQbAbk.mjs +1 -0
  32. package/dist/packem_shared/delta-merge-BoVuM-rE.mjs +1 -0
  33. package/dist/packem_shared/deserializePreloaded-CHfOFpka.mjs +1 -0
  34. package/dist/packem_shared/getServerSession-BaOoo1p6.mjs +1 -0
  35. package/dist/packem_shared/httpStream-x6q-x4yK.mjs +11 -0
  36. package/dist/packem_shared/idb-utility-C8WS390w.mjs +1 -0
  37. package/dist/packem_shared/local-store-tpI9VFpO.mjs +1 -0
  38. package/dist/packem_shared/lunora-client.d-CEJvJAXn.d.mts +2295 -0
  39. package/dist/packem_shared/lunora-client.d-CU6S8XiA.d.ts +2295 -0
  40. package/dist/packem_shared/offline-queue-CzI2lYQ8.mjs +1 -0
  41. package/dist/packem_shared/preload.d-7lAyp-Ky.d.mts +21 -0
  42. package/dist/packem_shared/preload.d-Gmmtaq2-.d.ts +21 -0
  43. package/dist/packem_shared/preloadQuery-uFy24PCR.mjs +1 -0
  44. package/dist/packem_shared/single-blob-store-DrhzObic.mjs +1 -0
  45. package/dist/packem_shared/types.d-BOB755CV.d.mts +1015 -0
  46. package/dist/packem_shared/types.d-BOB755CV.d.ts +1015 -0
  47. package/dist/packem_shared/wire-codec-D4iww4NV.mjs +1 -0
  48. package/dist/packem_shared/wire-key-BOdKmpG3.mjs +1 -0
  49. package/dist/pagination/index.d.mts +42 -42
  50. package/dist/pagination/index.d.ts +42 -42
  51. package/dist/pagination/index.mjs +1 -61
  52. package/dist/query/index.d.mts +110 -43
  53. package/dist/query/index.d.ts +110 -43
  54. package/dist/query/index.mjs +1 -1
  55. package/dist/service.d.mts +49 -0
  56. package/dist/service.d.ts +49 -0
  57. package/dist/service.mjs +1 -0
  58. package/dist/ssr/index.d.mts +100 -79
  59. package/dist/ssr/index.d.ts +100 -79
  60. package/dist/ssr/index.mjs +1 -4
  61. package/dist/upload.d.mts +35 -0
  62. package/dist/upload.d.ts +35 -0
  63. package/dist/upload.mjs +1 -0
  64. package/package.json +13 -1
  65. package/dist/packem_shared/CONFLICT_ERROR_CODE-aUdVbEDw.mjs +0 -4
  66. package/dist/packem_shared/DEFAULT_MAX_BUFFER-BDkqO5PW.mjs +0 -107
  67. package/dist/packem_shared/LunoraClient-DhwA_5Kj.mjs +0 -2502
  68. package/dist/packem_shared/OfflineQueue-D-ASeqL7.mjs +0 -131
  69. package/dist/packem_shared/SKIP-vItZChkw.mjs +0 -50
  70. package/dist/packem_shared/SubscriptionRegistry-Dn-7k7eo.mjs +0 -1
  71. package/dist/packem_shared/applyDelta-4jFGTPA3.mjs +0 -61
  72. package/dist/packem_shared/createAsyncStoragePersistence-1Z5BZ8RC.mjs +0 -45
  73. package/dist/packem_shared/createInMemoryBookmarkStorage-BoN7a7TH.mjs +0 -11
  74. package/dist/packem_shared/createInMemoryPersistence-CW82inU5.mjs +0 -105
  75. package/dist/packem_shared/createInMemoryQueryCache-B1PQ9Twl.mjs +0 -138
  76. package/dist/packem_shared/createLocalStore-DSUfoLqY.mjs +0 -36
  77. package/dist/packem_shared/createMutationRunner-BqsavzvG.mjs +0 -21
  78. package/dist/packem_shared/createMutatorRunner-BETvCd0p.mjs +0 -31
  79. package/dist/packem_shared/createReconnect-Di_-oHH7.mjs +0 -22
  80. package/dist/packem_shared/createServerClient-XahK8bPv.mjs +0 -11
  81. package/dist/packem_shared/deserializePreloaded-C0eJTY_W.mjs +0 -4
  82. package/dist/packem_shared/getServerSession-8jXewqxd.mjs +0 -13
  83. package/dist/packem_shared/lunora-client.d-DzEWBYeP.d.mts +0 -1948
  84. package/dist/packem_shared/lunora-client.d-DzEWBYeP.d.ts +0 -1948
  85. package/dist/packem_shared/preload.d-CmMMC-wm.d.ts +0 -20
  86. package/dist/packem_shared/preload.d-DuYqEQ5J.d.mts +0 -20
  87. package/dist/packem_shared/preloadQuery-lobFkD2Z.mjs +0 -13
  88. package/dist/packem_shared/subscription-C1Jy7HiF.mjs +0 -55
@@ -0,0 +1 @@
1
+ const A=e=>{let t="";for(let o=0;o<e.length;o+=32768)t+=String.fromCharCode(...e.subarray(o,o+32768));return btoa(t)},E=e=>{const t=atob(e),f=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)f[o]=t.codePointAt(o)??0;return f},i="$lunora.wire$";const d="__proto__",m={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},w={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},p=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},u=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===void 0)return[i,"undefined"];if(e===null)return null;const f=typeof e;if(f==="bigint")return[i,"bigint",e.toString()];if(f==="number"){const r=e;return Number.isNaN(r)?[i,"nan"]:r===1/0?[i,"inf"]:r===-1/0?[i,"-inf"]:r}if(f!=="object")return e;if(e instanceof Date)return[i,"date",u(e.getTime(),t+1)];if(e instanceof Error){const r=e,n={};for(const a of Object.keys(r))r[a]!==void 0&&(n[a]=u(r[a],t+1));const c=[i,"error",r.name,r.message,n];return r.cause!==void 0&&c.push(u(r.cause,t+1)),c}if(e instanceof URL)return[i,"url",e.href];if(e instanceof Map)return[i,"map",[...e.entries()].map(([r,n])=>[u(r,t+1),u(n,t+1)])];if(e instanceof Set)return[i,"set",[...e].map(r=>u(r,t+1))];if(e instanceof ArrayBuffer)return[i,"bytes",A(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const r=e,n=r.constructor.name,c=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return n==="Uint8Array"?[i,"bytes",A(c)]:[i,"bytes",A(c),n]}if(Array.isArray(e)){const r=e.map(n=>u(n,t+1));return r.length>0&&r[0]===i?[i,"arr",r]:r}if(!p(e)){const r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const o=e,s={};for(const r of Object.keys(o)){const n=o[r];if(n===void 0)continue;const c=u(n,t+1);r===d?Object.defineProperty(s,r,{configurable:!0,enumerable:!0,value:c,writable:!0}):s[r]=c}return s},y=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===i)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>y(r,t+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>1024||!/^-?\d+$/.test(r))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(r)}case"date":return new Date(y(e[2],t+1));case"map":return new Map(e[2].map(([r,n])=>[y(r,t+1),y(n,t+1)]));case"set":return new Set(e[2].map(r=>y(r,t+1)));case"url":return new URL(e[2]);case"error":{const r=e[2],n=e[3],c=(Object.hasOwn(w,r)?w[r]:void 0)??Error,a=new c(n);a.name!==r&&Object.defineProperty(a,"name",{configurable:!0,value:r,writable:!0});const g=y(e[4],t+1);for(const b of Object.keys(g))b===d?Object.defineProperty(a,b,{configurable:!0,enumerable:!0,value:g[b],writable:!0}):a[b]=g[b];return e.length>5&&Object.defineProperty(a,"cause",{configurable:!0,value:y(e[5],t+1),writable:!0}),a}case"bytes":{const r=E(e[2]),n=e[3]??"Uint8Array";if(n==="ArrayBuffer")return r.buffer.byteLength===r.byteLength?r.buffer:r.slice().buffer;const c=Object.hasOwn(m,n)?m[n]:void 0;return c?new c(r.slice().buffer):r}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>y(r,t+1))}return e.map(s=>y(s,t+1))}const f=e,o={};for(const s of Object.keys(f)){const r=y(f[s],t+1);s===d?Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):o[s]=r}return o};export{y as d,u as e,p as i};
@@ -0,0 +1 @@
1
+ import{e as a}from"./wire-codec-D4iww4NV.mjs";const b=/["\\\u0000-\u001F\uD800-\uDFFF]/,y=t=>b.test(t)?JSON.stringify(t):`"${t}"`,i=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(typeof t=="string")return y(t);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t)){let r="[";for(let e=0;e<t.length;e++)e>0&&(r+=","),r+=i(t[e]);return r+"]"}const o=Object.getPrototypeOf(t);if(o!==null&&o!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=t,c=Object.keys(s).sort();let n="{",f=!0;for(const r of c){const e=s[r];e!==void 0&&(f?f=!1:n+=",",n+=y(r),n+=":",n+=i(e))}return n+"}"},u=t=>i(a(t));export{u as s};
@@ -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,61 +1 @@
1
- const SPLIT_FACTOR = 2;
2
- const JOIN_FACTOR = 0.5;
3
- const initialPages = (numberItems) => [
4
- // eslint-disable-next-line unicorn/no-null -- `lower: null` is the feed head, `upper: null` the open-ended tail — both are wire-shape cursors.
5
- { lower: null, numItems: numberItems, upper: null }
6
- ];
7
- const rebalance = (pages, results) => {
8
- for (const [index, page] of pages.entries()) {
9
- if (page.upper === null) {
10
- continue;
11
- }
12
- const result = results[index];
13
- if (!result) {
14
- continue;
15
- }
16
- const size = result.page.length;
17
- if (size > SPLIT_FACTOR * page.numItems && result.splitCursor) {
18
- const split = result.splitCursor;
19
- const next = [...pages];
20
- next.splice(index, 1, { lower: page.lower, numItems: page.numItems, upper: split }, { lower: split, numItems: page.numItems, upper: page.upper });
21
- return next;
22
- }
23
- if (size < JOIN_FACTOR * page.numItems && index + 1 < pages.length) {
24
- const neighbour = pages[index + 1];
25
- if (!neighbour) {
26
- continue;
27
- }
28
- const next = [...pages];
29
- next.splice(index, 2, { lower: page.lower, numItems: page.numItems, upper: neighbour.upper });
30
- return next;
31
- }
32
- }
33
- return void 0;
34
- };
35
- const derivePaginationStatus = (skipped, pageResults) => {
36
- if (skipped || !pageResults[0]) {
37
- return { nextCursor: void 0, status: "LoadingFirstPage" };
38
- }
39
- const tail = pageResults.at(-1);
40
- if (!tail) {
41
- return { nextCursor: void 0, status: "LoadingMore" };
42
- }
43
- if (tail.isDone || tail.continueCursor === null) {
44
- return { nextCursor: void 0, status: "Exhausted" };
45
- }
46
- return { nextCursor: tail.continueCursor, status: "CanLoadMore" };
47
- };
48
- const applyLoadMore = (pages, cursor, numberItems) => {
49
- if (cursor === void 0 || cursor === null) {
50
- return void 0;
51
- }
52
- const next = [...pages];
53
- const tail = next.at(-1);
54
- if (tail) {
55
- next[next.length - 1] = { lower: tail.lower, numItems: tail.numItems, upper: cursor };
56
- }
57
- next.push({ lower: cursor, numItems: numberItems, upper: null });
58
- return next;
59
- };
60
-
61
- export { JOIN_FACTOR, SPLIT_FACTOR, applyLoadMore, derivePaginationStatus, initialPages, rebalance };
1
+ const l=2,m=.5,p=e=>[{lower:null,numItems:e,upper:null}],c=(e,r)=>{for(const[n,t]of e.entries()){if(t.upper===null)continue;const o=r[n];if(!o)continue;const i=o.page.length;if(i>2*t.numItems&&o.splitCursor){const u=o.splitCursor,s=[...e];return s.splice(n,1,{lower:t.lower,numItems:t.numItems,upper:u},{lower:u,numItems:t.numItems,upper:t.upper}),s}if(i<.5*t.numItems&&n+1<e.length){const u=e[n+1];if(!u)continue;const s=[...e];return s.splice(n,2,{lower:t.lower,numItems:t.numItems,upper:u.upper}),s}}},a=(e,r)=>{if(e||!r[0])return{nextCursor:void 0,status:"LoadingFirstPage"};const n=r.at(-1);return n?n.isDone||n.continueCursor===null?{nextCursor:void 0,status:"Exhausted"}:{nextCursor:n.continueCursor,status:"CanLoadMore"}:{nextCursor:void 0,status:"LoadingMore"}},I=(e,r,n)=>{if(r==null)return;const t=[...e],o=t.at(-1);return o&&(t[t.length-1]={lower:o.lower,numItems:o.numItems,upper:r}),t.push({lower:r,numItems:n,upper:null}),t};export{m as JOIN_FACTOR,l as SPLIT_FACTOR,I as applyLoadMore,a as derivePaginationStatus,p as initialPages,c as rebalance};
@@ -1,26 +1,38 @@
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-DzEWBYeP.mjs";
2
- export type { b as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-DzEWBYeP.mjs";
1
+ import { S as SubscriptionError, L as LunoraClient } from "../packem_shared/lunora-client.d-CEJvJAXn.mjs";
2
+ export type {
3
+ /**
4
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
5
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
6
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
7
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
8
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
9
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
10
+ * framework — each adapter supplies thin sinks that write into its own ref /
11
+ * store / signal / cache.
12
+ */
13
+ a as SubscriptionErrorCallback } from "../packem_shared/lunora-client.d-CEJvJAXn.mjs";
14
+ import { F as FunctionReference, A as ArgsOf, R as ReturnOf, a as Unsubscribe } from "../packem_shared/types.d-BOB755CV.mjs";
3
15
  import '@lunora/runtime';
4
16
  /**
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
- */
17
+ * The sentinel a framework adapter resolves its reactive args to when it wants
18
+ * to short-circuit a query — no network call, no socket.
19
+ */
8
20
  declare const SKIP: "skip";
9
21
  /** Args after a framework has resolved its reactivity primitive, or the skip sentinel. */
10
22
  type ResolvedArgs<F extends FunctionReference> = ArgsOf<F> | typeof SKIP;
11
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
+ * The framework-neutral sinks a {@link createQuerySubscription} call drives. A
25
+ * framework adapter supplies these, wiring each into its own reactivity
26
+ * primitive (a TanStack cache write, a Vue `ref`, a Svelte store `set`, a Solid
27
+ * signal setter).
28
+ *
29
+ * `onData` fires when a fresh server value lands (the initial frame or a delta).
30
+ * `onError` fires when the subscription attach threw, or the server pushed a
31
+ * subscription-scoped error — it is optional, and when omitted an attach throw
32
+ * propagates to the caller (preserving the "no error channel" behaviour of
33
+ * adapters like Solid/Vue that never had one) rather than being swallowed.
34
+ * `onReset` fires when the resolved args are `"skip"`: clear any prior value.
35
+ */
24
36
  interface QuerySubscriptionSinks<T> {
25
37
  onData: (value: T) => void;
26
38
  onError?: (error: SubscriptionError) => void;
@@ -33,30 +45,85 @@ interface QuerySubscriptionOptions {
33
45
  /** Normalise an unknown thrown value into the client's {@link SubscriptionError} shape. */
34
46
  declare const toSubscriptionError: (error: unknown) => SubscriptionError;
35
47
  /**
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
- */
48
+ * The subscribe → snapshot → error/reset → cleanup state machine shared by
49
+ * every Lunora framework adapter's live-query hook.
50
+ *
51
+ * Given a `client`, a function reference, the already-resolved `args` (a
52
+ * framework reads its own reactive source first, then hands the plain value in),
53
+ * and a set of {@link QuerySubscriptionSinks}, this opens one `client.subscribe`
54
+ * registration and returns the {@link Unsubscribe} to tear it down. Each
55
+ * framework owns *when* to call this (a React effect, a Vue `watch`, a Svelte
56
+ * store start callback, a Solid `createEffect(on(...))`) and *where* to stash
57
+ * the value — this owns the lifecycle in between, so the skip-handling, the
58
+ * value/error fan-out, the attach-throw normalisation, and the
59
+ * cancellation-guarded teardown live in exactly one place.
60
+ *
61
+ * Behaviour. When `args === "skip"` it calls `sinks.onReset?.()` and returns a
62
+ * no-op teardown; no `client.subscribe` is issued. Otherwise it opens
63
+ * `client.subscribe(fn, args, …, { shardKey, onError })`: server pushes route to
64
+ * `sinks.onData`, and the client's own `onError` channel (a server-rejected
65
+ * subscription) routes to `sinks.onError` when present. The attach is wrapped —
66
+ * if `client.subscribe` itself throws, the error is normalised to a
67
+ * {@link SubscriptionError} and delivered to `sinks.onError` when present; with
68
+ * no `onError` sink the throw is rethrown so adapters without an error channel
69
+ * behave exactly as before. The returned teardown is idempotent and
70
+ * cancellation-guarded: once it runs, no further `onData`/`onError` from an
71
+ * in-flight push reaches the sinks.
72
+ */
61
73
  declare const createQuerySubscription: <F extends FunctionReference, T = ReturnOf<F>>(client: LunoraClient, function_: F, args: ResolvedArgs<F>, sinks: QuerySubscriptionSinks<T>, options?: QuerySubscriptionOptions) => Unsubscribe;
62
- export { type ArgsOf, type FunctionReference, type QuerySubscriptionOptions, type QuerySubscriptionSinks, type ResolvedArgs, type ReturnOf, SKIP, type SubscriptionError, type Unsubscribe, createQuerySubscription, toSubscriptionError };
74
+ export {
75
+ /**
76
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
77
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
78
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
79
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
80
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
81
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
82
+ * framework — each adapter supplies thin sinks that write into its own ref /
83
+ * store / signal / cache.
84
+ */
85
+ type ArgsOf,
86
+ /**
87
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
88
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
89
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
90
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
91
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
92
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
93
+ * framework — each adapter supplies thin sinks that write into its own ref /
94
+ * store / signal / cache.
95
+ */
96
+ type FunctionReference, type QuerySubscriptionOptions, type QuerySubscriptionSinks, type ResolvedArgs,
97
+ /**
98
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
99
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
100
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
101
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
102
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
103
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
104
+ * framework — each adapter supplies thin sinks that write into its own ref /
105
+ * store / signal / cache.
106
+ */
107
+ type ReturnOf, SKIP,
108
+ /**
109
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
110
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
111
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
112
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
113
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
114
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
115
+ * framework — each adapter supplies thin sinks that write into its own ref /
116
+ * store / signal / cache.
117
+ */
118
+ type SubscriptionError,
119
+ /**
120
+ * `@lunora/client/query` — the framework-neutral live-query state machine shared
121
+ * by every Lunora UI adapter (React, Vue, Svelte, Solid). It owns the seam
122
+ * between a `LunoraClient` subscription and a framework's reactivity primitive:
123
+ * the subscribe → snapshot → error/reset → cleanup lifecycle, with the
124
+ * skip-handling, value/error fan-out, attach-throw normalisation, and
125
+ * cancellation-guarded teardown all in one place. Nothing here imports a UI
126
+ * framework — each adapter supplies thin sinks that write into its own ref /
127
+ * store / signal / cache.
128
+ */
129
+ type Unsubscribe, createQuerySubscription, toSubscriptionError };