@lunora/svelte 1.0.0-alpha.322 → 1.0.0-alpha.323
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 +21 -4
- package/dist/index.d.ts +21 -4
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{agentState-DUcWVYXr.mjs → agentState-CWX44Gk9.mjs} +1 -1
- package/dist/packem_shared/{agentToolEvents-CDt_CXlT.mjs → agentToolEvents-CdJUiim7.mjs} +1 -1
- package/dist/packem_shared/{infiniteQuery-D91H-yvI.mjs → infiniteQuery-DOD9tEYH.mjs} +1 -1
- package/dist/packem_shared/{liveTopic-zWCoweI3.mjs → liveTopic-By3-Qi68.mjs} +1 -1
- package/dist/packem_shared/presence-C_vLicqT.mjs +1 -0
- package/dist/packem_shared/{query-DpzFJQyT.mjs → query-CxjOg_wv.mjs} +1 -1
- package/dist/packem_shared/subscribe-reactive-args-ClWd3Rut.mjs +1 -0
- package/dist/packem_shared/{subscription-DSyycrP7.mjs → subscription-DFD5oYmP.mjs} +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/presence-DYgABtvC.mjs +0 -1
- package/dist/packem_shared/subscribe-reactive-args-D0fSbP1k.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -932,7 +932,10 @@ declare function infiniteQuery<F extends FunctionReference>(client: LunoraClient
|
|
|
932
932
|
* `@lunora/server` `definePresence` preset.
|
|
933
933
|
*
|
|
934
934
|
* Drives the heartbeat mutation (on call, interval, and tab re-focus) and
|
|
935
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
935
|
+
* subscribes to the live `listPresent` query for the given room. `roomId` may
|
|
936
|
+
* be a `Readable<string>`; a change stops the old room's heartbeats and
|
|
937
|
+
* subscription and joins the new one. Pass `leave` to drop the old room's row
|
|
938
|
+
* at once; without it the server keeps that row until it ages out (`ttlMs`).
|
|
936
939
|
*
|
|
937
940
|
* Pass `client` explicitly, or omit it to resolve the ambient client from the
|
|
938
941
|
* Svelte context.
|
|
@@ -952,6 +955,13 @@ type HeartbeatReference = FunctionReference<"mutation", {
|
|
|
952
955
|
type ListPresentReference = FunctionReference<"query", {
|
|
953
956
|
roomId: string;
|
|
954
957
|
}>;
|
|
958
|
+
/**
|
|
959
|
+
* The presence `leave` mutation: `definePresence(...).functions.leave`.
|
|
960
|
+
*/
|
|
961
|
+
type LeaveReference = FunctionReference<"mutation", {
|
|
962
|
+
roomId: string;
|
|
963
|
+
sessionId: string;
|
|
964
|
+
}>;
|
|
955
965
|
interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentReference> {
|
|
956
966
|
/** Awareness blob for the first heartbeat (selection, cursor, name, color…). */
|
|
957
967
|
data?: Record<string, unknown>;
|
|
@@ -959,6 +969,13 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
959
969
|
heartbeat: H;
|
|
960
970
|
/** Heartbeat cadence in ms. Defaults to 10s. */
|
|
961
971
|
intervalMs?: number;
|
|
972
|
+
/**
|
|
973
|
+
* The `api.*` reference for the presence `leave` mutation. When given, leaving a room (a room
|
|
974
|
+
* change, or teardown) removes this session's row there at once, unless another view on the same
|
|
975
|
+
* client still shows that session in that room; without it the old room lists the session until
|
|
976
|
+
* its last heartbeat ages out (`ttlMs`).
|
|
977
|
+
*/
|
|
978
|
+
leave?: LeaveReference;
|
|
962
979
|
/** The `api.*` reference for the presence listPresent query. */
|
|
963
980
|
listPresent: L;
|
|
964
981
|
/**
|
|
@@ -1000,8 +1017,8 @@ interface PresenceHandle<L extends ListPresentReference> {
|
|
|
1000
1017
|
* `handle.teardown()` yourself. `teardown()` is idempotent, so an explicit
|
|
1001
1018
|
* `onDestroy(handle.teardown)` on top of the auto-wiring is safe.
|
|
1002
1019
|
*/
|
|
1003
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1004
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1020
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1021
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1005
1022
|
/** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
|
|
1006
1023
|
type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
|
|
1007
1024
|
/** Options accepted by {@link query}. */
|
|
@@ -1334,7 +1351,7 @@ interface VoiceAgentHandle {
|
|
|
1334
1351
|
*/
|
|
1335
1352
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1336
1353
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1337
|
-
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1354
|
+
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type LeaveReference, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1338
1355
|
/**
|
|
1339
1356
|
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1340
1357
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -932,7 +932,10 @@ declare function infiniteQuery<F extends FunctionReference>(client: LunoraClient
|
|
|
932
932
|
* `@lunora/server` `definePresence` preset.
|
|
933
933
|
*
|
|
934
934
|
* Drives the heartbeat mutation (on call, interval, and tab re-focus) and
|
|
935
|
-
* subscribes to the live `listPresent` query for the given room.
|
|
935
|
+
* subscribes to the live `listPresent` query for the given room. `roomId` may
|
|
936
|
+
* be a `Readable<string>`; a change stops the old room's heartbeats and
|
|
937
|
+
* subscription and joins the new one. Pass `leave` to drop the old room's row
|
|
938
|
+
* at once; without it the server keeps that row until it ages out (`ttlMs`).
|
|
936
939
|
*
|
|
937
940
|
* Pass `client` explicitly, or omit it to resolve the ambient client from the
|
|
938
941
|
* Svelte context.
|
|
@@ -952,6 +955,13 @@ type HeartbeatReference = FunctionReference<"mutation", {
|
|
|
952
955
|
type ListPresentReference = FunctionReference<"query", {
|
|
953
956
|
roomId: string;
|
|
954
957
|
}>;
|
|
958
|
+
/**
|
|
959
|
+
* The presence `leave` mutation: `definePresence(...).functions.leave`.
|
|
960
|
+
*/
|
|
961
|
+
type LeaveReference = FunctionReference<"mutation", {
|
|
962
|
+
roomId: string;
|
|
963
|
+
sessionId: string;
|
|
964
|
+
}>;
|
|
955
965
|
interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentReference> {
|
|
956
966
|
/** Awareness blob for the first heartbeat (selection, cursor, name, color…). */
|
|
957
967
|
data?: Record<string, unknown>;
|
|
@@ -959,6 +969,13 @@ interface PresenceOptions<H extends HeartbeatReference, L extends ListPresentRef
|
|
|
959
969
|
heartbeat: H;
|
|
960
970
|
/** Heartbeat cadence in ms. Defaults to 10s. */
|
|
961
971
|
intervalMs?: number;
|
|
972
|
+
/**
|
|
973
|
+
* The `api.*` reference for the presence `leave` mutation. When given, leaving a room (a room
|
|
974
|
+
* change, or teardown) removes this session's row there at once, unless another view on the same
|
|
975
|
+
* client still shows that session in that room; without it the old room lists the session until
|
|
976
|
+
* its last heartbeat ages out (`ttlMs`).
|
|
977
|
+
*/
|
|
978
|
+
leave?: LeaveReference;
|
|
962
979
|
/** The `api.*` reference for the presence listPresent query. */
|
|
963
980
|
listPresent: L;
|
|
964
981
|
/**
|
|
@@ -1000,8 +1017,8 @@ interface PresenceHandle<L extends ListPresentReference> {
|
|
|
1000
1017
|
* `handle.teardown()` yourself. `teardown()` is idempotent, so an explicit
|
|
1001
1018
|
* `onDestroy(handle.teardown)` on top of the auto-wiring is safe.
|
|
1002
1019
|
*/
|
|
1003
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1004
|
-
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1020
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1021
|
+
declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: Readable<string> | string, options: PresenceOptions<H, L>): PresenceHandle<L>;
|
|
1005
1022
|
/** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
|
|
1006
1023
|
type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
|
|
1007
1024
|
/** Options accepted by {@link query}. */
|
|
@@ -1334,7 +1351,7 @@ interface VoiceAgentHandle {
|
|
|
1334
1351
|
*/
|
|
1335
1352
|
declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1336
1353
|
declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
|
|
1337
|
-
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1354
|
+
export { type ActionHandle, type AgentApi, type AgentApprovalGrant, type AgentApprovalTarget, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type LeaveReference, type ListPresentReference, type LiveTopicState, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
|
|
1338
1355
|
/**
|
|
1339
1356
|
* Svelte adapter for Lunora (`@lunora/svelte`).
|
|
1340
1357
|
*
|
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-
|
|
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-C_vLicqT.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as f}from"./getLunoraClient-CIfxHhDm.mjs";import{subscription as d}from"./subscription-
|
|
1
|
+
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as f}from"./getLunoraClient-CIfxHhDm.mjs";import{subscription as d}from"./subscription-DFD5oYmP.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-CYV_xWD9.mjs";import{getLunoraClient as I}from"./getLunoraClient-CIfxHhDm.mjs";import{stream as N}from"./stream-CMEivEKF.mjs";import{subscription as _}from"./subscription-
|
|
1
|
+
import{derived as y}from"svelte/store";import{isClient as E}from"./agent-CYV_xWD9.mjs";import{getLunoraClient as I}from"./getLunoraClient-CIfxHhDm.mjs";import{stream as N}from"./stream-CMEivEKF.mjs";import{subscription as _}from"./subscription-DFD5oYmP.mjs";const h={__lunoraRef:""},k={awaiting_approval:"awaiting-approval",awaiting_secret:"awaiting-secret"},m=t=>{const o=t.status===void 0?void 0:k[t.status];if(o!==void 0)return{seq:t.seq,type:o,...t.approvalSlot===void 0?{}:{approvalSlot:t.approvalSlot},...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=m(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(),p=r?o:t,{api:u,limit:i,stream:e,threadKey:n}=p,s=i===void 0?{key:n}:{key:n,limit:i},{data:c}=_(a,u.agents.agentMessages,s),v=N(a,e??h,e===void 0?"skip":{key:n});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(l=>q(l)??[]);for(const l of C)l.kind==="progress"&&l.threadKey===n&&d.push({data:l.data,toolCallId:l.toolCallId,type:"progress"});return d})}}export{x as agentToolEvents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initialPages as F,derivePaginationStatus as H,applyLoadMore as Y,isHeadPage as Z,rebalance as _,classifyPageFailure as O,headPage as ee}from"@lunora/client/pagination";import{stableWireKey as se}from"@lunora/wire";import{derived as L,writable as Q,readable as te,get as K}from"svelte/store";import{i as oe}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{i as j}from"./is-function-reference-abFdrAae.mjs";import{i as ne,s as re}from"./subscribe-reactive-args-
|
|
1
|
+
import{initialPages as F,derivePaginationStatus as H,applyLoadMore as Y,isHeadPage as Z,rebalance as _,classifyPageFailure as O,headPage as ee}from"@lunora/client/pagination";import{stableWireKey as se}from"@lunora/wire";import{derived as L,writable as Q,readable as te,get as K}from"svelte/store";import{i as oe}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as T}from"./getLunoraClient-CIfxHhDm.mjs";import{i as j}from"./is-function-reference-abFdrAae.mjs";import{i as ne,s as re}from"./subscribe-reactive-args-ClWd3Rut.mjs";const $=(n,u)=>({...u,paginationOpts:{cursor:n.lower,endCursor:n.upper,numItems:n.numItems}}),ae=(n,u)=>`${n}::${se(u)}`,D=(n,u,M,I)=>{const{initialNumItems:l,onError:N,shardKey:C}=I,r=Q(F(l)),m=Q();let v=!1;const w=Q([]),i=new Map,g=new Map,p=new Set;let t=ne(M)?"skip":M,x=new WeakMap;const a=(e,b)=>{let c=x.get(e);return c===void 0&&(c=ae(u.__lunoraRef,$(e,b)),x.set(e,c)),c},y=()=>{if(t==="skip"){w.set([]);return}const e=t,b=K(r).map(c=>{const s=a(c,e);return i.get(s)});w.set(b)},E=(e,b)=>{if(t==="skip")return;const c=t,s=R=>a(R,c);for(const R of b){const o=s(R);if(i.has(o))continue;const S=e.find(d=>d.lower===R.lower);if(S){const d=i.get(s(S));d&&i.set(o,d)}}},q=()=>{if(t==="skip"){for(const s of g.values())s();g.clear(),w.set([]);return}const e=t,b=K(r),c=new Set;for(const s of b)c.add(a(s,e));for(const[s,R]of g)c.has(s)||(R(),g.delete(s),p.delete(s),i.delete(s));for(const s of b){const R=$(s,e),o=a(s,e);if(g.has(o))continue;p.add(o);const S=n.subscribe(u,R,d=>{if(i.set(o,d),v&&K(r).some(P=>!Z(P)&&a(P,e)===o)&&(v=!1),p.delete(o),m.set(void 0),y(),p.size===0){const P=K(r),h=_(P,K(w));h&&(E(P,h),r.set(h),A(),y())}},{onError:d=>{p.delete(o);const P=O(K(r),X=>a(X,e)===o,d,v);if(P==="restart"&&(n.resnapshot(u,$(ee(l),e),{shardKey:C}),G(),v=!0),P!=="surface")return;m.set(d);const h=K(r),B=h.at(-1);h.length>1&&B&&!i.has(o)&&a(B,e)===o&&(r.set(h.slice(0,-1)),A(),y()),N?.(d)},shardKey:C});g.set(o,S)}};let f=!1,k=!1;const A=()=>{if(f){k=!0;return}f=!0;try{do k=!1,q();while(k)}finally{f=!1}},z=()=>{for(const e of g.values())e();g.clear(),i.clear(),p.clear(),x=new WeakMap},G=()=>{z(),r.set(F(l)),m.set(void 0),A(),y()},W=te([],e=>{if(!oe())return()=>{};const b=w.subscribe(e),c=re(M,s=>(t=s,A(),y(),()=>{z(),r.set(F(l)),m.set(void 0),v=!1}));return()=>{c(),b(),w.set([])}}),J=L(W,e=>H(t==="skip",e).status),U=L(W,()=>t==="skip"),V=e=>{if(t==="skip")return;const b=K(w),{nextCursor:c,status:s}=H(!1,b);if(s!=="CanLoadMore")return;const R=K(r),o=Y(R,c,e);if(!o)return;const S=R.at(-1),d=o.at(-2);if(S&&d){const P=a(S,t),h=a(d,t);if(P!==h){const B=i.get(P);B&&(i.set(h,B),i.delete(P))}}m.set(void 0),r.set(o),A(),y()};return{error:{subscribe:m.subscribe},loadMore:V,pageResults:W,skipped:U,status:J}};function pe(n,u,M,I){const l=!j(n),N=l?n:T(),C=l?u:n,r=l?M:u,m=l?I:M,{error:v,loadMore:w,pageResults:i,skipped:g,status:p}=D(N,C,r,m),t=L(i,a=>a.flatMap(y=>y?.page??[])),x=L([p,g],([a,y])=>!y&&(a==="LoadingFirstPage"||a==="LoadingMore"));return{error:v,isLoading:x,loadMore:w,results:t,status:p}}function ye(n,u,M,I){const l=!j(n),N=l?n:T(),C=l?u:n,r=l?M:u,m=l?I:M,{initialNumItems:v}=m,{error:w,loadMore:i,pageResults:g,skipped:p,status:t}=D(N,C,r,m),x=L(g,f=>f.flatMap(k=>k?[k.page]:[])),a=L([t,p],([f,k])=>!k&&f==="LoadingFirstPage"),y=L(t,f=>f==="CanLoadMore"),E=L([t,p],([f,k])=>!k&&f==="LoadingMore");return{error:w,fetchNextPage:f=>{i(f??v)},hasNextPage:y,isFetchingNextPage:E,isLoading:a,pages:x,status:t}}export{ye as infiniteQuery,pe as paginatedQuery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{liveTopicSubscription as p,subscribeLiveTopic as y}from"@lunora/client";import{readable as c,derived as f}from"svelte/store";import{i as E}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as h}from"./getLunoraClient-CIfxHhDm.mjs";import{i as l,s as D}from"./subscribe-reactive-args-
|
|
1
|
+
import{liveTopicSubscription as p,subscribeLiveTopic as y}from"@lunora/client";import{readable as c,derived as f}from"svelte/store";import{i as E}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as h}from"./getLunoraClient-CIfxHhDm.mjs";import{i as l,s as D}from"./subscribe-reactive-args-ClWd3Rut.mjs";const S=r=>({headers:r.headers,maxDelayMs:r.maxDelayMs,retryDelay:r.retryDelay,sessionKey:r.sessionKey,topic:r.topic,url:r.url,withCredentials:r.withCredentials}),g=(r,i={})=>{const v=h();return c({error:void 0,lastEvent:void 0},s=>{if(!E())return;const u=l(r)?r:c(r),a=l(i)?i:c(i);let n={};const d=a.subscribe(t=>{n=t}),m=t=>{let e;return s({error:void 0,lastEvent:e}),y({...t,onError:o=>{s({error:o,lastEvent:e}),n.onError?.(o)},onEvent:o=>{e=o,s({error:void 0,lastEvent:e}),n.onEvent?.(o)}})},b=D(f([u,a],([t,e])=>S(p(v,t,e))),m);return()=>{b(),d()}})};export{g as liveTopic};
|
|
@@ -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)=>{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as u}from"@lunora/client/query";import{readable as d}from"svelte/store";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as v}from"./getLunoraClient-CIfxHhDm.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-
|
|
1
|
+
import{createQuerySubscription as u}from"@lunora/client/query";import{readable as d}from"svelte/store";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as v}from"./getLunoraClient-CIfxHhDm.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-ClWd3Rut.mjs";function q(o,i,t,s){const r=!y(o),a=r?o:v(),c=r?i:o,p=r?t:i,n=(r?s:t)??{};return d(void 0,e=>b()?R(p,f=>(e(void 0),u(a,c,f,{onData:m=>{e(m)},onError:n.onError,onReset:()=>{e(void 0)}},{shardKey:n.shardKey}))):()=>{})}export{q as query};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stableWireKey as a}from"@lunora/wire";const y=t=>typeof t?.subscribe=="function",h=(t,o)=>{if(!y(t))return o(t);let r=()=>{},i=!1,s,l,u=!0,n;const c=t.subscribe(b=>{if(i){s=[b];return}i=!0;try{let e=[b];for(;e;){const f=a(e[0]);f!==l&&(l=f,r(),r=o(e[0])),e=s,s=void 0}}catch(e){if(!u)throw e;n=[e]}finally{i=!1}});if(u=!1,n!==void 0)throw c(),r(),n[0];return()=>{c(),r()}};export{y as i,h as s};
|
|
@@ -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-CIfxHhDm.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-
|
|
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-CIfxHhDm.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as L}from"./subscribe-reactive-args-ClWd3Rut.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.
|
|
3
|
+
"version": "1.0.0-alpha.323",
|
|
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.303",
|
|
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 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-CIfxHhDm.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 +0,0 @@
|
|
|
1
|
-
import{stableWireKey as c}from"@lunora/wire";const f=e=>typeof e?.subscribe=="function",y=(e,n)=>{if(!f(e))return n(e);let s=()=>{},i=!1,r,o;const b=e.subscribe(u=>{if(i){r=[u];return}i=!0;try{let t=[u];for(;t;){const l=c(t[0]);l!==o&&(o=l,s(),s=n(t[0])),t=r,r=void 0}}finally{i=!1}});return()=>{b(),s()}};export{f as i,y as s};
|