@lunora/client 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (85) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +2 -0
  3. package/dist/auth/index.d.mts +11 -10
  4. package/dist/auth/index.d.ts +11 -10
  5. package/dist/auth/index.mjs +1 -60
  6. package/dist/index.d.mts +736 -172
  7. package/dist/index.d.ts +736 -172
  8. package/dist/index.mjs +1 -14
  9. package/dist/packem_shared/CONFLICT_ERROR_CODE-B2SU0CaJ.mjs +1 -0
  10. package/dist/packem_shared/ClientServiceWorker-CRQ5yl7-.mjs +1 -0
  11. package/dist/packem_shared/DEFAULT_MAX_BUFFER-TBn2s7Rz.mjs +1 -0
  12. package/dist/packem_shared/LunoraClient-CB5y0HME.mjs +1 -0
  13. package/dist/packem_shared/OfflineQueue-y4mymc5n.mjs +1 -0
  14. package/dist/packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-D96iRJDY.mjs +1 -0
  15. package/dist/packem_shared/SKIP-CArzT3Vl.mjs +1 -0
  16. package/dist/packem_shared/SubscriptionRegistry-C72rCp44.mjs +1 -0
  17. package/dist/packem_shared/TabCoordinator-CMFYQCL-.mjs +1 -0
  18. package/dist/packem_shared/anyApi-BD4dgvDY.mjs +1 -0
  19. package/dist/packem_shared/applyDelta-DXqQORbM.mjs +1 -0
  20. package/dist/packem_shared/createAsyncStoragePersistence-BRLqeXsC.mjs +1 -0
  21. package/dist/packem_shared/createClientQuery-CrdRoicO.mjs +1 -0
  22. package/dist/packem_shared/createInMemoryBookmarkStorage-DCd5Ej-t.mjs +1 -0
  23. package/dist/packem_shared/createInMemoryPersistence-CQYXy8UP.mjs +1 -0
  24. package/dist/packem_shared/createInMemoryQueryCache-DjCKrLjk.mjs +1 -0
  25. package/dist/packem_shared/createLocalStore-CwuKPK9x.mjs +1 -0
  26. package/dist/packem_shared/createMutationRunner-lQXH8Amk.mjs +1 -0
  27. package/dist/packem_shared/createMutatorRunner-BVzo0FBZ.mjs +1 -0
  28. package/dist/packem_shared/createReconnect-CFT7YRSR.mjs +1 -0
  29. package/dist/packem_shared/createReply-DF0jRsv-.mjs +1 -0
  30. package/dist/packem_shared/createServerClient-C1At_rrh.mjs +1 -0
  31. package/dist/packem_shared/createSnapshotPrecondition-CKvCNKyD.mjs +1 -0
  32. package/dist/packem_shared/deserializePreloaded-CHfOFpka.mjs +1 -0
  33. package/dist/packem_shared/getServerSession-CGjgRBAE.mjs +1 -0
  34. package/dist/packem_shared/httpStream-Cz4_QyjV.mjs +11 -0
  35. package/dist/packem_shared/idb-utility-C-DR8nG1.mjs +1 -0
  36. package/dist/packem_shared/local-store-DFMSEM2j.mjs +1 -0
  37. package/dist/packem_shared/lunora-client.d-D_WLwpn0.d.mts +2175 -0
  38. package/dist/packem_shared/lunora-client.d-cFPjoyDb.d.ts +2175 -0
  39. package/dist/packem_shared/offline-queue-BeWay5u5.mjs +1 -0
  40. package/dist/packem_shared/preload.d-BkbCVtZe.d.ts +21 -0
  41. package/dist/packem_shared/preload.d-DNxm6niZ.d.mts +21 -0
  42. package/dist/packem_shared/preloadQuery-DjwSjFwt.mjs +1 -0
  43. package/dist/packem_shared/types.d-CA7ZeJm9.d.mts +942 -0
  44. package/dist/packem_shared/types.d-CA7ZeJm9.d.ts +942 -0
  45. package/dist/packem_shared/wire-codec-D_fiax9d.mjs +1 -0
  46. package/dist/packem_shared/wire-key-j8BZ65HQ.mjs +1 -0
  47. package/dist/pagination/index.d.mts +42 -42
  48. package/dist/pagination/index.d.ts +42 -42
  49. package/dist/pagination/index.mjs +1 -61
  50. package/dist/query/index.d.mts +43 -42
  51. package/dist/query/index.d.ts +43 -42
  52. package/dist/query/index.mjs +1 -1
  53. package/dist/service.d.mts +49 -0
  54. package/dist/service.d.ts +49 -0
  55. package/dist/service.mjs +1 -0
  56. package/dist/ssr/index.d.mts +80 -79
  57. package/dist/ssr/index.d.ts +80 -79
  58. package/dist/ssr/index.mjs +1 -4
  59. package/dist/upload.d.mts +35 -0
  60. package/dist/upload.d.ts +35 -0
  61. package/dist/upload.mjs +1 -0
  62. package/package.json +13 -1
  63. package/dist/packem_shared/CONFLICT_ERROR_CODE-aUdVbEDw.mjs +0 -4
  64. package/dist/packem_shared/DEFAULT_MAX_BUFFER-BDkqO5PW.mjs +0 -107
  65. package/dist/packem_shared/LunoraClient-DHMV-94j.mjs +0 -2198
  66. package/dist/packem_shared/OfflineQueue-D5p_QgF_.mjs +0 -127
  67. package/dist/packem_shared/SKIP-vItZChkw.mjs +0 -50
  68. package/dist/packem_shared/SubscriptionRegistry-Dn-7k7eo.mjs +0 -1
  69. package/dist/packem_shared/applyDelta-4jFGTPA3.mjs +0 -61
  70. package/dist/packem_shared/createAsyncStoragePersistence-1Z5BZ8RC.mjs +0 -45
  71. package/dist/packem_shared/createInMemoryBookmarkStorage-BoN7a7TH.mjs +0 -11
  72. package/dist/packem_shared/createInMemoryPersistence-CW82inU5.mjs +0 -105
  73. package/dist/packem_shared/createInMemoryQueryCache-B1PQ9Twl.mjs +0 -138
  74. package/dist/packem_shared/createLocalStore-DSUfoLqY.mjs +0 -36
  75. package/dist/packem_shared/createMutationRunner-BqsavzvG.mjs +0 -21
  76. package/dist/packem_shared/createReconnect-Di_-oHH7.mjs +0 -22
  77. package/dist/packem_shared/createServerClient-DMh-2UDv.mjs +0 -11
  78. package/dist/packem_shared/deserializePreloaded-C0eJTY_W.mjs +0 -4
  79. package/dist/packem_shared/getServerSession-8jXewqxd.mjs +0 -13
  80. package/dist/packem_shared/lunora-client.d-CbnxmuqG.d.mts +0 -1623
  81. package/dist/packem_shared/lunora-client.d-CbnxmuqG.d.ts +0 -1623
  82. package/dist/packem_shared/preload.d-Bhq6DBSe.d.mts +0 -20
  83. package/dist/packem_shared/preload.d-C73DT6bL.d.ts +0 -20
  84. package/dist/packem_shared/preloadQuery-lobFkD2Z.mjs +0 -13
  85. package/dist/packem_shared/subscription-C1Jy7HiF.mjs +0 -55
@@ -0,0 +1 @@
1
+ let c=0;const a=()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();c+=1;const r=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?Array.from(crypto.getRandomValues(new Uint8Array(8)),t=>t.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`id_${Date.now().toString(36)}_${c.toString(36)}_${r}`},f=(r,t)=>r!==void 0&&t!==r,d=a,h=(r,t,e,i)=>{if(r){r({error:e,mutationId:i,operation:t});return}console.warn(`[lunora] offline-queue persistence ${t} failed`,e)};class u{queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(t={},e={}){this.maxItems=t.maxItems??1e3,this.queueBeforeFirstConnect=t.queueBeforeFirstConnect??!1,this.onPersistenceError=t.onPersistenceError,this.persistence=e.persistence,this.onEvict=e.onEvict,this.onSizeChange=e.onSizeChange,this.version=e.version}get size(){return this.items.length}enqueue(t){const e=t;e.id??=d(),this.items.push(e),this.persistence?.append({args:e.args,functionPath:e.functionPath,id:e.id,identity:e.identity,shardKey:e.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(i=>{h(this.onPersistenceError,"append",i,e.id)}),this.evictOverflow(),this.notifySize()}async hydrate(){if(!this.persistence)return[];let t;try{t=await this.persistence.load()}catch(s){throw h(this.onPersistenceError,"load",s),s}const e=[];for(const s of t)if(!(this.items.some(o=>o.id===s.id)||e.some(o=>o.id===s.id))){if(f(this.version,s.version)){this.persistence.remove(s.id).catch(o=>{h(this.onPersistenceError,"remove",o,s.id)});continue}e.push({args:s.args,functionPath:s.functionPath,id:s.id,identity:s.identity,reject:()=>{},resolve:()=>{},shardKey:s.shardKey})}this.items.unshift(...e),this.evictOverflow(),this.notifySize();const i=new Set(this.items),n=new Set;for(const s of e)i.has(s)&&n.add(s.shardKey);return[...n]}drain(t){if(!t){const n=[...this.items];return this.items.length=0,this.notifySize(),n}const e=[],i=[];for(const n of this.items)(t(n)?e:i).push(n);return this.items.length=0,this.items.push(...i),this.notifySize(),e}requeue(t){t.length!==0&&(this.items.unshift(...t),this.notifySize())}drainConflict(){const t=[],e=[];for(const i of this.items)if(i.precondition!==void 0&&!i.precondition()){const n=new Error("offline mutation skipped: precondition failed before replay");n.code="OFFLINE_PRECONDITION_FAILED",i.reject(n),t.push(i)}else e.push(i);return t.length>0&&(this.items.length=0,this.items.push(...e),this.notifySize()),t}clear(){for(const t of this.items){const e=new Error("CLIENT_CLOSED");e.code="CLIENT_CLOSED",t.reject(e)}this.items.length=0,this.notifySize()}evictOverflow(){for(;this.items.length>this.maxItems;){const t=this.items.shift();if(t){t.id&&this.persistence?.remove(t.id).catch(i=>{h(this.onPersistenceError,"remove",i,t.id)});const e=new Error("offline queue overflow");e.code="OFFLINE_QUEUE_OVERFLOW",t.reject(e),this.onEvict?.(t,e)}}}notifySize(){this.onSizeChange?.(this.items.length)}}export{f as d,u as h,h as s,d as u};
@@ -0,0 +1,21 @@
1
+ import { L as LunoraClient } from "./lunora-client.d-cFPjoyDb.js";
2
+ import { F as FunctionReference, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./types.d-CA7ZeJm9.js";
3
+ /**
4
+ * Run a query once on the server (during SSR) and capture its result in a
5
+ * serializable {@link Preloaded} token. Embed the token in the rendered HTML and
6
+ * pass it to `usePreloadedQuery` on the client: the first client render shows
7
+ * the server value with no loading flash, then a live subscription takes over.
8
+ *
9
+ * The query is executed through the supplied {@link LunoraClient} over the same
10
+ * HTTP RPC path the browser uses, so the SSR client only needs a `fetch`
11
+ * implementation that can reach the worker — no in-process Durable Object access.
12
+ */
13
+ declare const preloadQuery: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
14
+ shardKey?: string;
15
+ }) => Promise<Preloaded<ReturnOf<F>>>;
16
+ /**
17
+ * Read the captured value out of a {@link Preloaded} token without subscribing.
18
+ * Useful on the server (or in tests) when you only need the data, not a live feed.
19
+ */
20
+ declare const preloadedQueryResult: <T>(preloaded: Preloaded<T>) => T;
21
+ export { preloadedQueryResult as a, preloadQuery as p };
@@ -0,0 +1,21 @@
1
+ import { L as LunoraClient } from "./lunora-client.d-D_WLwpn0.mjs";
2
+ import { F as FunctionReference, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./types.d-CA7ZeJm9.mjs";
3
+ /**
4
+ * Run a query once on the server (during SSR) and capture its result in a
5
+ * serializable {@link Preloaded} token. Embed the token in the rendered HTML and
6
+ * pass it to `usePreloadedQuery` on the client: the first client render shows
7
+ * the server value with no loading flash, then a live subscription takes over.
8
+ *
9
+ * The query is executed through the supplied {@link LunoraClient} over the same
10
+ * HTTP RPC path the browser uses, so the SSR client only needs a `fetch`
11
+ * implementation that can reach the worker — no in-process Durable Object access.
12
+ */
13
+ declare const preloadQuery: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
14
+ shardKey?: string;
15
+ }) => Promise<Preloaded<ReturnOf<F>>>;
16
+ /**
17
+ * Read the captured value out of a {@link Preloaded} token without subscribing.
18
+ * Useful on the server (or in tests) when you only need the data, not a live feed.
19
+ */
20
+ declare const preloadedQueryResult: <T>(preloaded: Preloaded<T>) => T;
21
+ export { preloadedQueryResult as a, preloadQuery as p };
@@ -0,0 +1 @@
1
+ const l=async(e,a,r,u={})=>{const o=await e.query(a,r,u);return{__lunoraPreloaded:!0,args:r??{},functionPath:a.__lunoraRef,shardKey:u.shardKey,value:o}},t=e=>e.value;export{l as preloadQuery,t as preloadedQueryResult};