@lunora/svelte 1.0.0-alpha.284 → 1.0.0-alpha.285

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.d.mts CHANGED
@@ -1124,7 +1124,7 @@ interface StreamHandle<T> {
1124
1124
  declare function stream<F extends FunctionReference<"stream">>(function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
1125
1125
  declare function stream<F extends FunctionReference<"stream">>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
1126
1126
  interface SubscriptionStoreOptions {
1127
- onError?: (error: Error) => void;
1127
+ onError?: SubscriptionErrorCallback;
1128
1128
  shardKey?: string;
1129
1129
  }
1130
1130
  interface SubscriptionHandle<T> {
package/dist/index.d.ts CHANGED
@@ -1124,7 +1124,7 @@ interface StreamHandle<T> {
1124
1124
  declare function stream<F extends FunctionReference<"stream">>(function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
1125
1125
  declare function stream<F extends FunctionReference<"stream">>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: StreamStoreOptions): StreamHandle<ReturnOf<F>>;
1126
1126
  interface SubscriptionStoreOptions {
1127
- onError?: (error: Error) => void;
1127
+ onError?: SubscriptionErrorCallback;
1128
1128
  shardKey?: string;
1129
1129
  }
1130
1130
  interface SubscriptionHandle<T> {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as m}from"./packem_shared/agent-WMVWf1Ks.mjs";import{agentChat as a}from"./packem_shared/agentChat-COq1hXPF.mjs";import{agentState as n}from"./packem_shared/agentState-BCWHx7mX.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-DV3zjAh0.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Z0G_aZYz.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-DMx3BE5Q.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as C,flags as L}from"./packem_shared/flag-Csh9LBiO.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CNm2-Rha.mjs";import{liveTopic as b}from"./packem_shared/liveTopic-DKHSwXiX.mjs";import{mutation as A}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as G}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as j,paginatedQuery as k}from"./packem_shared/infiniteQuery-B6dobUkL.mjs";import{presence as z}from"./packem_shared/presence-C4ZgfGfr.mjs";import{query as D}from"./packem_shared/query-C6B__ZRN.mjs";import{rateLimit as H}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as J}from"./packem_shared/stream-Cxl8guzh.mjs";import{subscription as M}from"./packem_shared/subscription-BQC3Asdx.mjs";import{voiceAgent as O}from"./packem_shared/voiceAgent-B7AkAkB_.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};
1
+ import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as m}from"./packem_shared/agent-WMVWf1Ks.mjs";import{agentChat as a}from"./packem_shared/agentChat-COq1hXPF.mjs";import{agentState as n}from"./packem_shared/agentState-Bb7y6sQO.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-ClR1HAg8.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Z0G_aZYz.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-DMx3BE5Q.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as C,flags as L}from"./packem_shared/flag-Csh9LBiO.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CNm2-Rha.mjs";import{liveTopic as b}from"./packem_shared/liveTopic-DKHSwXiX.mjs";import{mutation as A}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as G}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as j,paginatedQuery as k}from"./packem_shared/infiniteQuery-B6dobUkL.mjs";import{presence as z}from"./packem_shared/presence-BCd6RN33.mjs";import{query as D}from"./packem_shared/query-C6B__ZRN.mjs";import{rateLimit as H}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as J}from"./packem_shared/stream-Cxl8guzh.mjs";import{subscription as M}from"./packem_shared/subscription-CTzqm298.mjs";import{voiceAgent as O}from"./packem_shared/voiceAgent-B7AkAkB_.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};
@@ -1 +1 @@
1
- import{derived as c}from"svelte/store";import{isClient as p}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-BQC3Asdx.mjs";function h(t,r){const o=p(t),n=o?t:f(),e=o?r:t,{data:i,error:a}=d(n,e.api.agents.agentState,{key:e.threadKey}),s=c(i,m=>m);return{error:a,state:s}}export{h as agentState};
1
+ import{derived as c}from"svelte/store";import{isClient as p}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-CTzqm298.mjs";function h(t,r){const o=p(t),n=o?t:f(),e=o?r:t,{data:i,error:a}=d(n,e.api.agents.agentState,{key:e.threadKey}),s=c(i,m=>m);return{error:a,state:s}}export{h as agentState};
@@ -1 +1 @@
1
- import{derived as y}from"svelte/store";import{isClient as E}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-Cxl8guzh.mjs";import{subscription as m}from"./subscription-BQC3Asdx.mjs";const _={__lunoraRef:""},h={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=t=>{const o=t.status===void 0?void 0:h[t.status];if(o!==void 0)return{seq:t.seq,type:o,...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role!=="tool")return;const o=k(t);return o!==void 0?[o]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]};function x(t,o){const r=E(t),a=r?t:I(),s=r?o:t,{api:u,limit:e,stream:i,threadKey:l}=s,p=e===void 0?{key:l}:{key:l,limit:e},{data:c}=m(a,u.agents.agentMessages,p),v=N(a,i??_,i===void 0?"skip":{key:l});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(n=>q(n)??[]);for(const n of C)n.kind==="progress"&&n.threadKey===l&&d.push({data:n.data,toolCallId:n.toolCallId,type:"progress"});return d})}}export{x as agentToolEvents};
1
+ import{derived as y}from"svelte/store";import{isClient as E}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-Cxl8guzh.mjs";import{subscription as m}from"./subscription-CTzqm298.mjs";const _={__lunoraRef:""},h={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},k=t=>{const o=t.status===void 0?void 0:h[t.status];if(o!==void 0)return{seq:t.seq,type:o,...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role!=="tool")return;const o=k(t);return o!==void 0?[o]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]};function x(t,o){const r=E(t),a=r?t:I(),s=r?o:t,{api:u,limit:e,stream:i,threadKey:l}=s,p=e===void 0?{key:l}:{key:l,limit:e},{data:c}=m(a,u.agents.agentMessages,p),v=N(a,i??_,i===void 0?"skip":{key:l});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(n=>q(n)??[]);for(const n of C)n.kind==="progress"&&n.threadKey===l&&d.push({data:n.data,toolCallId:n.toolCallId,type:"progress"});return d})}}export{x as agentToolEvents};
@@ -0,0 +1 @@
1
+ import{onDestroy as I}from"svelte";import{writable as S,readable as U}from"svelte/store";import{i as h}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as C}from"./getLunoraClient-DU7BmZy1.mjs";const D=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(e)}`)},L=()=>{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,t=>t.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},V=1e4,x=(e,t,n)=>{const{heartbeat:r,intervalMs:s=V,listPresent:y,shardKey:i}=n;D(s);const d=n.sessionId??L();let f=n.data,u=!1;const a=()=>{const o={roomId:t,sessionId:d,...f===void 0?{}:{data:f}};e.mutation(r,o,{shardKey:i}).catch(()=>{})},w=o=>{f=o,u&&a()},p=()=>{typeof document<"u"&&document.visibilityState==="visible"&&a()};let l,b;h()&&(u=!0,a(),l=setInterval(a,s),typeof document<"u"&&document.addEventListener("visibilitychange",p),b=e.acquireConnectionContext({roomId:t,sessionId:d},{shardKey:i}));const m=S(),E=U(void 0,o=>{if(h())return e.subscribe(y,{roomId:t},c=>{o(c),m.set(void 0)},{onError:c=>{m.set(c),n.onError?.(c)},shardKey:i})});let v=!1;const g=()=>{v||(v=!0,u=!1,l!==void 0&&clearInterval(l),typeof document<"u"&&document.removeEventListener("visibilitychange",p),b?.())};try{I(g)}catch{}return{error:{subscribe:m.subscribe},present:E,sessionId:d,setData:w,teardown:g}};function F(e,t,n){const r=typeof e!="string",s=r?e:C();return x(s,r?t:e,r?n:t)}export{F as presence};
@@ -1 +1 @@
1
- import{createQuerySubscription as g}from"@lunora/client/query";import{LunoraError as h}from"@lunora/errors";import{writable as y,readable as l}from"svelte/store";import{i as R}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as x}from"./getLunoraClient-DU7BmZy1.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-D0fSbP1k.mjs";function z(t,n,i,c){const r=!C(t),m=r?t:x(),d=r?n:t,f=r?i:n,p=(r?c:i)??{},{shardKey:v,onError:u}=p,e=y();return{data:l(void 0,s=>{if(!R())return()=>{};const w=L(f,b=>(s(void 0),e.set(void 0),g(m,d,b,{onData:o=>{s(o),e.set(void 0)},onError:o=>{const a=Object.assign(o.code===void 0?new Error(o.message):new h(o.code,o.message),o.why===void 0?{}:{why:o.why});e.set(a),u?.(a)},onReset:()=>{s(void 0)}},{shardKey:v})));return()=>{w(),e.set(void 0)}}),error:{subscribe:e.subscribe}}}export{z as subscription};
1
+ import{createQuerySubscription as g}from"@lunora/client/query";import{LunoraError as h}from"@lunora/errors";import{writable as y,readable as l}from"svelte/store";import{i as R}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as x}from"./getLunoraClient-DU7BmZy1.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-D0fSbP1k.mjs";function z(r,n,a,i){const t=!C(r),c=t?r:x(),m=t?n:r,d=t?a:n,f=(t?i:a)??{},{shardKey:v,onError:p}=f,e=y();return{data:l(void 0,s=>{if(!R())return()=>{};const w=L(d,u=>(s(void 0),e.set(void 0),g(c,m,u,{onData:o=>{s(o),e.set(void 0)},onError:o=>{const b=Object.assign(o.code===void 0?new Error(o.message):new h(o.code,o.message),o.why===void 0?{}:{why:o.why});e.set(b),p?.(o)},onReset:()=>{s(void 0)}},{shardKey:v})));return()=>{w(),e.set(void 0)}}),error:{subscribe:e.subscribe}}}export{z as subscription};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/svelte",
3
- "version": "1.0.0-alpha.284",
3
+ "version": "1.0.0-alpha.285",
4
4
  "description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,9 +54,9 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.246",
57
+ "@lunora/client": "1.0.0-alpha.247",
58
58
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
59
- "@lunora/ratelimit": "1.0.0-alpha.166",
59
+ "@lunora/ratelimit": "1.0.0-alpha.167",
60
60
  "@lunora/wire": "1.0.0-alpha.2",
61
61
  "@visulima/storage-client": "1.0.9"
62
62
  },
@@ -1 +0,0 @@
1
- import{onDestroy as C}from"svelte";import{writable as D,readable as E}from"svelte/store";import{i as h}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";const S=()=>{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,t=>t.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},L=1e4,V=(e,t,n)=>{const{heartbeat:o,intervalMs:c=L,listPresent:m,shardKey:s}=n,d=n.sessionId??S();let f=n.data,u=!1;const i=()=>{const r={roomId:t,sessionId:d,...f===void 0?{}:{data:f}};e.mutation(o,r,{shardKey:s}).catch(()=>{})},U=r=>{f=r,u&&i()},p=()=>{typeof document<"u"&&document.visibilityState==="visible"&&i()};let l,v;h()&&(u=!0,i(),l=setInterval(i,c),typeof document<"u"&&document.addEventListener("visibilitychange",p),v=e.acquireConnectionContext({roomId:t,sessionId:d},{shardKey:s}));const y=D(),w=E(void 0,r=>{if(h())return e.subscribe(m,{roomId:t},a=>{r(a),y.set(void 0)},{onError:a=>{y.set(a),n.onError?.(a)},shardKey:s})});let b=!1;const g=()=>{b||(b=!0,u=!1,l!==void 0&&clearInterval(l),typeof document<"u"&&document.removeEventListener("visibilitychange",p),v?.())};try{C(g)}catch{}return{error:{subscribe:y.subscribe},present:w,sessionId:d,setData:U,teardown:g}};function P(e,t,n){const o=typeof e!="string",c=o?e:I();return V(c,o?t:e,o?n:t)}export{P as presence};