@lunora/client 1.0.0-alpha.35 → 1.0.0-alpha.37
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.
- package/dist/auth/index.d.mts +2 -1
- package/dist/auth/index.d.ts +2 -1
- package/dist/index.d.mts +131 -8
- package/dist/index.d.ts +131 -8
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/LunoraClient-BzVeQ8ub.mjs +1 -0
- package/dist/packem_shared/OfflineQueue-y4mymc5n.mjs +1 -0
- package/dist/packem_shared/{SubscriptionRegistry-CdrOD7sZ.mjs → SubscriptionRegistry-Dr5H2kVT.mjs} +1 -1
- package/dist/packem_shared/TabCoordinator-CMFYQCL-.mjs +1 -0
- package/dist/packem_shared/createLocalStore-7bvzJ_xS.mjs +1 -0
- package/dist/packem_shared/{createServerClient-DX7Dk2w2.mjs → createServerClient-BMtqMeyY.mjs} +1 -1
- package/dist/packem_shared/{createSnapshotPrecondition-DOKRAJ4b.mjs → createSnapshotPrecondition-9rTzUURM.mjs} +1 -1
- package/dist/packem_shared/{local-store-C53xDvEr.mjs → local-store-Di_y1q4e.mjs} +1 -1
- package/dist/packem_shared/{lunora-client.d-DLcz4GRz.d.mts → lunora-client.d-BkfH0Zom.d.ts} +128 -947
- package/dist/packem_shared/{lunora-client.d-DLcz4GRz.d.ts → lunora-client.d-yDX6HUZv.d.mts} +128 -947
- package/dist/packem_shared/offline-queue-BeWay5u5.mjs +1 -0
- package/dist/packem_shared/{preload.d-C1M_N5mE.d.mts → preload.d--OibiIK_.d.ts} +2 -1
- package/dist/packem_shared/{preload.d-hkFC0Uno.d.ts → preload.d-DbtqnQ4C.d.mts} +2 -1
- package/dist/packem_shared/types.d-CxmbJf0E.d.mts +942 -0
- package/dist/packem_shared/types.d-CxmbJf0E.d.ts +942 -0
- package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +1 -0
- package/dist/packem_shared/wire-key-DHMKiMxD.mjs +1 -0
- package/dist/query/index.d.mts +3 -2
- package/dist/query/index.d.ts +3 -2
- package/dist/service.d.mts +49 -0
- package/dist/service.d.ts +49 -0
- package/dist/service.mjs +1 -0
- package/dist/ssr/index.d.mts +4 -3
- package/dist/ssr/index.d.ts +4 -3
- package/dist/ssr/index.mjs +1 -1
- package/package.json +6 -2
- package/dist/packem_shared/LunoraClient-DRo2LNe9.mjs +0 -1
- package/dist/packem_shared/OfflineQueue-l0_y9TmK.mjs +0 -1
- package/dist/packem_shared/TabCoordinator-ijLic02x.mjs +0 -1
- package/dist/packem_shared/createLocalStore-B3Tw_Tw1.mjs +0 -1
- package/dist/packem_shared/offline-queue-b-v6bWWd.mjs +0 -1
- package/dist/packem_shared/wire-key-D_zOxXK4.mjs +0 -1
|
@@ -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};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as LunoraClient } from "./lunora-client.d-BkfH0Zom.js";
|
|
2
|
+
import { F as FunctionReference, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./types.d-CxmbJf0E.js";
|
|
2
3
|
/**
|
|
3
4
|
* Run a query once on the server (during SSR) and capture its result in a
|
|
4
5
|
* serializable {@link Preloaded} token. Embed the token in the rendered HTML and
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as LunoraClient } from "./lunora-client.d-yDX6HUZv.mjs";
|
|
2
|
+
import { F as FunctionReference, A as ArgsOf, R as ReturnOf, P as Preloaded } from "./types.d-CxmbJf0E.mjs";
|
|
2
3
|
/**
|
|
3
4
|
* Run a query once on the server (during SSR) and capture its result in a
|
|
4
5
|
* serializable {@link Preloaded} token. Embed the token in the rendered HTML and
|