@lunora/svelte 1.0.0-alpha.323 → 1.0.0-alpha.324
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/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{action as t}from"./packem_shared/action-BwzMXvK2.mjs";import{agent as m}from"./packem_shared/agent-CYV_xWD9.mjs";import{agentChat as a}from"./packem_shared/agentChat-B85Roxj3.mjs";import{agentState as n}from"./packem_shared/agentState-CWX44Gk9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-CdJUiim7.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-DLryMKMY.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-Ba3Y_I18.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-CIfxHhDm.mjs";import{flag as C,flags as L}from"./packem_shared/flag-CvPhqFko.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-GIJIIvjB.mjs";import{liveTopic as b}from"./packem_shared/liveTopic-By3-Qi68.mjs";import{mutation as A}from"./packem_shared/mutation-Cvnei0Ke.mjs";import{mutator as G}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as j,paginatedQuery as k}from"./packem_shared/infiniteQuery-DOD9tEYH.mjs";import{presence as z}from"./packem_shared/presence-
|
|
1
|
+
import{action as t}from"./packem_shared/action-BwzMXvK2.mjs";import{agent as m}from"./packem_shared/agent-CYV_xWD9.mjs";import{agentChat as a}from"./packem_shared/agentChat-B85Roxj3.mjs";import{agentState as n}from"./packem_shared/agentState-CWX44Gk9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-CdJUiim7.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-DLryMKMY.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-Ba3Y_I18.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-CIfxHhDm.mjs";import{flag as C,flags as L}from"./packem_shared/flag-CvPhqFko.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-GIJIIvjB.mjs";import{liveTopic as b}from"./packem_shared/liveTopic-By3-Qi68.mjs";import{mutation as A}from"./packem_shared/mutation-Cvnei0Ke.mjs";import{mutator as G}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as j,paginatedQuery as k}from"./packem_shared/infiniteQuery-DOD9tEYH.mjs";import{presence as z}from"./packem_shared/presence-B8SjIPFV.mjs";import{query as D}from"./packem_shared/query-CxjOg_wv.mjs";import{rateLimit as H}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as J}from"./packem_shared/stream-CMEivEKF.mjs";import{subscription as M}from"./packem_shared/subscription-DFD5oYmP.mjs";import{voiceAgent as O}from"./packem_shared/voiceAgent-qByP7VDj.mjs";export{t as action,m as agent,a as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,C as flag,L as flags,h as getLunoraClient,S as hydratePreloaded,j as infiniteQuery,b as liveTopic,A as mutation,G as mutator,k as paginatedQuery,z as presence,D as query,H as rateLimit,y as setLunoraClient,J as stream,M as subscription,O as voiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onDestroy as F}from"svelte";import{writable as K,readable as N}from"svelte/store";import{i as L}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{s as M}from"./subscribe-reactive-args-ClWd3Rut.mjs";const j=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},h=async e=>{try{await e()}catch{}},D=e=>JSON.stringify([e.shardKey??"",e.roomId,e.sessionId]),W=new WeakMap,A=e=>{let o=W.get(e);return o===void 0&&(o={heartbeats:new Map,leaves:new Map},W.set(e,o)),o},_=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=r.get(s),i=d===void 0?h(t):d.then(async()=>h(t)),a=n.get(s)??new Set;a.add(i),n.set(s,a),i.then(()=>{a.delete(i),a.size===0&&n.get(s)===a&&n.delete(s)})},q=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=[...n.get(s)??[]],i=d.length===0?h(t):Promise.all(d).then(async()=>h(t));r.set(s,i),i.then(()=>{r.get(s)===i&&r.delete(s)})},k=new WeakMap,z=(e,o)=>{const t=k.get(e)??new Map,n=D(o);k.set(e,t),t.set(n,(t.get(n)??0)+1);let r=!0;return()=>{if(!r)return!1;r=!1;const s=(t.get(n)??1)-1;return s>0?(t.set(n,s),!1):(t.delete(n),!0)}},B=(e,o,t)=>{let n;return e.onShardConnectionStatus(o,r=>{const s=n!==void 0&&n!=="connected";n=r,s&&r==="connected"&&t()})},J=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},O=1e4,$=(e,o,t)=>{const{heartbeat:n,intervalMs:r=O,leave:s,listPresent:d,shardKey:i}=t;j(r);const a=t.sessionId??J();let w=t.data,m=!1,I="";const l=()=>{const c={roomId:I,sessionId:a,...w===void 0?{}:{data:w}};_(e,{roomId:I,sessionId:a,shardKey:i},async()=>e.mutation(n,c,{onlineOnly:!0,shardKey:i}))},V=c=>{w=c,m&&l()},C=()=>{typeof document<"u"&&document.visibilityState==="visible"&&l()};let E;L()&&(E=M(o,c=>{I=c,m=!0,l();const y=setInterval(l,r);typeof document<"u"&&document.addEventListener("visibilitychange",C);const v=e.acquireConnectionContext({roomId:c,sessionId:a},{shardKey:i}),g=z(e,{roomId:c,sessionId:a,shardKey:i}),S=B(e,i,l);return()=>{m=!1,clearInterval(y),typeof document<"u"&&document.removeEventListener("visibilitychange",C),S(),v(),g()&&s!==void 0&&q(e,{roomId:c,sessionId:a,shardKey:i},async()=>e.mutation(s,{roomId:c,sessionId:a},{onlineOnly:!0,shardKey:i}))}}));const p=K();let u=!1;const x=()=>u;let R;const H=N(void 0,c=>{if(!L()||u)return;const y=M(o,S=>{if(u)return()=>{};c(void 0),p.set(void 0);let f=!0;const U=e.subscribe(d,{roomId:S},b=>{f&&(c(b),p.set(void 0))},{onError:b=>{f&&(p.set(b),t.onError?.(b))},shardKey:i});return x()?(f=!1,U(),()=>{}):()=>{f=!1,U()}});let v=!1;const g=()=>{v||(v=!0,R=void 0,y())};return R=g,g}),P=()=>{u||(u=!0,m=!1,E?.(),R?.())};try{F(P)}catch{}return{error:{subscribe:p.subscribe},present:H,sessionId:a,setData:V,teardown:P}};function ee(e,o,t){const n=t!==void 0,r=n?e:T();return $(r,n?o:e,n?t:o)}export{ee as presence};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/svelte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.324",
|
|
4
4
|
"description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "^1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "^1.0.0-alpha.305",
|
|
58
58
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
59
59
|
"@lunora/ratelimit": "^1.0.0-alpha.197",
|
|
60
60
|
"@lunora/wire": "1.0.0-alpha.6",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{onDestroy as F}from"svelte";import{writable as K,readable as N}from"svelte/store";import{i as L}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{s as M}from"./subscribe-reactive-args-ClWd3Rut.mjs";const j=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},h=async e=>{try{await e()}catch{}},D=e=>JSON.stringify([e.shardKey??"",e.roomId,e.sessionId]),W=new WeakMap,A=e=>{let o=W.get(e);return o===void 0&&(o={heartbeats:new Map,leaves:new Map},W.set(e,o)),o},_=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=r.get(s),i=d===void 0?h(t):d.then(async()=>h(t)),a=n.get(s)??new Set;a.add(i),n.set(s,a),i.then(()=>{a.delete(i),a.size===0&&n.get(s)===a&&n.delete(s)})},q=(e,o,t)=>{const{heartbeats:n,leaves:r}=A(e),s=D(o),d=[...n.get(s)??[]],i=d.length===0?h(t):Promise.all(d).then(async()=>h(t));r.set(s,i),i.then(()=>{r.get(s)===i&&r.delete(s)})},k=new WeakMap,z=(e,o)=>{const t=k.get(e)??new Map,n=D(o);k.set(e,t),t.set(n,(t.get(n)??0)+1);let r=!0;return()=>{if(!r)return!1;r=!1;const s=(t.get(n)??1)-1;return s>0?(t.set(n,s),!1):(t.delete(n),!0)}},B=(e,o)=>{let t;return e.onConnectionStatus(n=>{const r=t!==void 0&&t!=="connected";t=n,r&&n==="connected"&&o()})},J=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},O=1e4,$=(e,o,t)=>{const{heartbeat:n,intervalMs:r=O,leave:s,listPresent:d,shardKey:i}=t;j(r);const a=t.sessionId??J();let w=t.data,m=!1,I="";const l=()=>{const c={roomId:I,sessionId:a,...w===void 0?{}:{data:w}};_(e,{roomId:I,sessionId:a,shardKey:i},async()=>e.mutation(n,c,{onlineOnly:!0,shardKey:i}))},V=c=>{w=c,m&&l()},C=()=>{typeof document<"u"&&document.visibilityState==="visible"&&l()};let E;L()&&(E=M(o,c=>{I=c,m=!0,l();const y=setInterval(l,r);typeof document<"u"&&document.addEventListener("visibilitychange",C);const v=e.acquireConnectionContext({roomId:c,sessionId:a},{shardKey:i}),g=z(e,{roomId:c,sessionId:a,shardKey:i}),S=B(e,l);return()=>{m=!1,clearInterval(y),typeof document<"u"&&document.removeEventListener("visibilitychange",C),S(),v(),g()&&s!==void 0&&q(e,{roomId:c,sessionId:a,shardKey:i},async()=>e.mutation(s,{roomId:c,sessionId:a},{onlineOnly:!0,shardKey:i}))}}));const p=K();let u=!1;const x=()=>u;let R;const H=N(void 0,c=>{if(!L()||u)return;const y=M(o,S=>{if(u)return()=>{};c(void 0),p.set(void 0);let f=!0;const U=e.subscribe(d,{roomId:S},b=>{f&&(c(b),p.set(void 0))},{onError:b=>{f&&(p.set(b),t.onError?.(b))},shardKey:i});return x()?(f=!1,U(),()=>{}):()=>{f=!1,U()}});let v=!1;const g=()=>{v||(v=!0,R=void 0,y())};return R=g,g}),P=()=>{u||(u=!0,m=!1,E?.(),R?.())};try{F(P)}catch{}return{error:{subscribe:p.subscribe},present:H,sessionId:a,setData:V,teardown:P}};function ee(e,o,t){const n=t!==void 0,r=n?e:T();return $(r,n?o:e,n?t:o)}export{ee as presence};
|