@lunora/client 1.0.0-alpha.2 → 1.0.0-alpha.200

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 (86) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +18 -3
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/auth/index.d.mts +43 -12
  5. package/dist/auth/index.d.ts +43 -12
  6. package/dist/auth/index.mjs +1 -60
  7. package/dist/index.d.mts +851 -190
  8. package/dist/index.d.ts +851 -190
  9. package/dist/index.mjs +1 -14
  10. package/dist/packem_shared/CONFLICT_ERROR_CODE-B7qNZMMk.mjs +1 -0
  11. package/dist/packem_shared/DEFAULT_MAX_BUFFER-D3QH2iaq.mjs +1 -0
  12. package/dist/packem_shared/LunoraClient-DljhwSYY.mjs +1 -0
  13. package/dist/packem_shared/OfflineQueue-BWamzR6p.mjs +1 -0
  14. package/dist/packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs +1 -0
  15. package/dist/packem_shared/SKIP-d7LeP-sY.mjs +1 -0
  16. package/dist/packem_shared/SubscriptionRegistry-5CHmk3d8.mjs +1 -0
  17. package/dist/packem_shared/TabCoordinator-CXD7vulJ.mjs +1 -0
  18. package/dist/packem_shared/applyDelta-UuKQOPo1.mjs +1 -0
  19. package/dist/packem_shared/createAsyncStoragePersistence-DXlhLrFv.mjs +1 -0
  20. package/dist/packem_shared/createAsyncStorageQueryCache-CAPNYhcK.mjs +1 -0
  21. package/dist/packem_shared/createCallRunner-Bwcrfh76.mjs +1 -0
  22. package/dist/packem_shared/createClientQuery-B8Nfj-7o.mjs +1 -0
  23. package/dist/packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs +1 -0
  24. package/dist/packem_shared/createInMemoryPersistence-Cz2W6XVj.mjs +1 -0
  25. package/dist/packem_shared/createInMemoryQueryCache-D2uNHLfM.mjs +1 -0
  26. package/dist/packem_shared/createLocalStore-CriEK0Fm.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/createServerClient-pcVZisrR.mjs +1 -0
  30. package/dist/packem_shared/createSnapshotPrecondition-D-WkMTIs.mjs +1 -0
  31. package/dist/packem_shared/delta-merge-CDCNlktH.mjs +1 -0
  32. package/dist/packem_shared/deserializePreloaded-CEQci6cB.mjs +1 -0
  33. package/dist/packem_shared/function-reference.d-Br_hsKje.d.mts +45 -0
  34. package/dist/packem_shared/function-reference.d-Br_hsKje.d.ts +45 -0
  35. package/dist/packem_shared/getServerSession-BaOoo1p6.mjs +1 -0
  36. package/dist/packem_shared/httpStream-B5J3zeB8.mjs +9 -0
  37. package/dist/packem_shared/idb-utility-C8WS390w.mjs +1 -0
  38. package/dist/packem_shared/local-store-CtP_1rJj.mjs +1 -0
  39. package/dist/packem_shared/lunora-client.d-BZq8UjLD.d.mts +4642 -0
  40. package/dist/packem_shared/lunora-client.d-DEWqB37M.d.ts +4642 -0
  41. package/dist/packem_shared/offline-queue-D_fr-uQ3.mjs +1 -0
  42. package/dist/packem_shared/preload.d-CcbcPzGc.d.mts +21 -0
  43. package/dist/packem_shared/preload.d-CrPi7Ft1.d.ts +21 -0
  44. package/dist/packem_shared/preloadQuery-uFy24PCR.mjs +1 -0
  45. package/dist/packem_shared/single-blob-store-D7kYfN1I.mjs +1 -0
  46. package/dist/packem_shared/wire-codec-3Mj5UgNj.mjs +1 -0
  47. package/dist/packem_shared/wire-errors-CYMmnEcW.mjs +1 -0
  48. package/dist/packem_shared/wire-key-3XBGlnux.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 +111 -43
  53. package/dist/query/index.d.ts +111 -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 +109 -79
  59. package/dist/ssr/index.d.ts +109 -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 +17 -2
  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-UiULzH_1.mjs +0 -2165
  68. package/dist/packem_shared/OfflineQueue-D5p_QgF_.mjs +0 -127
  69. package/dist/packem_shared/SKIP-vItZChkw.mjs +0 -50
  70. package/dist/packem_shared/SubscriptionRegistry-B-Qx_Gux.mjs +0 -26
  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/createReconnect-Di_-oHH7.mjs +0 -22
  79. package/dist/packem_shared/createServerClient-BjZc3gD8.mjs +0 -11
  80. package/dist/packem_shared/deserializePreloaded-C0eJTY_W.mjs +0 -4
  81. package/dist/packem_shared/getServerSession-8jXewqxd.mjs +0 -13
  82. package/dist/packem_shared/lunora-client.d-DGvyuJ_p.d.mts +0 -1597
  83. package/dist/packem_shared/lunora-client.d-DGvyuJ_p.d.ts +0 -1597
  84. package/dist/packem_shared/preload.d-BoDmFqSG.d.ts +0 -20
  85. package/dist/packem_shared/preload.d-dSaRMuhL.d.mts +0 -20
  86. package/dist/packem_shared/preloadQuery-lobFkD2Z.mjs +0 -13
package/LICENSE.md CHANGED
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
  ---
36
36
 
37
- The framework-agnostic browser/edge SDK for Lunora. It runs RPC over HTTP and real-time deltas over a single multiplexed WebSocket, with optimistic updates, an offline mutation queue, and decorrelated-jitter reconnect built in. It is the lowest-level user-facing entry point that every framework adapter (React, Vue, Svelte, Solid) layers on top of.
37
+ The framework-agnostic browser/edge SDK for Lunora. It runs RPC over HTTP and real-time deltas over a single multiplexed WebSocket, with optimistic updates, an offline mutation queue, and exponential-backoff-with-jitter reconnect built in. It is the lowest-level user-facing entry point that every framework adapter (React, Vue, Svelte, Solid) layers on top of.
38
38
 
39
39
  Part of the [Lunora](https://github.com/anolilab/lunora) framework — a type-safe, real-time backend on Cloudflare Workers + Durable Objects with a Vite-first DX.
40
40
 
@@ -63,8 +63,21 @@ const client = new LunoraClient({ url: "https://app.acme.test" });
63
63
  // One-shot query (HTTP, carries the D1 bookmark for read-your-writes).
64
64
  const messages = await client.query(api.messages.list, { room: "general" });
65
65
 
66
- // Mutation with an optimistic update applied to matching subscribers.
67
- await client.mutation(api.messages.send, { body: "hi" }, { optimistic: (current = []) => [...current, { body: "hi", pending: true }] });
66
+ // Mutation with an optimistic update. `optimisticUpdate` names the query it
67
+ // patches — a write and the queries it affects are different functions, and only
68
+ // you know which. (The per-call `optimistic` shortcut patches the subscription
69
+ // registered under the mutation's OWN reference and args, nothing else.)
70
+ await client.mutation(
71
+ api.messages.send,
72
+ { room: "general", body: "hi" },
73
+ {
74
+ optimisticUpdate: (store, args) => {
75
+ const current = store.getQuery(api.messages.list, { room: args.room }) ?? [];
76
+
77
+ store.setQuery(api.messages.list, { room: args.room }, [...current, { body: args.body, pending: true }]);
78
+ },
79
+ },
80
+ );
68
81
 
69
82
  // Live subscription over WS — returns an unsubscribe function.
70
83
  const unsubscribe = client.subscribe(api.messages.list, { room: "general" }, (next) => {
@@ -74,6 +87,8 @@ const unsubscribe = client.subscribe(api.messages.list, { room: "general" }, (ne
74
87
  client.close();
75
88
  ```
76
89
 
90
+ `client.subscribeShape({ name, args }, cb)` is the [local-first sync engine](https://lunora.sh/docs/concepts/local-first)'s parallel to `subscribe`: it replicates a **partial view** of a table (a server-defined shape) over the poke diff protocol instead of re-running a query. Most apps consume it through [`@lunora/db`](https://www.npmjs.com/package/@lunora/db)'s `lunoraCollectionOptions({ shape })` rather than directly.
91
+
77
92
  > This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/api/client)**.
78
93
 
79
94
  ## Related