@lunora/svelte 1.0.0-alpha.89 → 1.0.0-alpha.90

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
@@ -700,6 +700,8 @@ interface MutatorHandleStore<TArgs> {
700
700
  declare const mutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHandleStore<TArgs>;
701
701
  /** The args a paginated query exposes minus the framework-supplied page cursor. */
702
702
  type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
703
+ /** Paginated args, the skip sentinel, or a reactive (`Readable`) source of either. */
704
+ type ReactivePaginatedArgs<F extends FunctionReference> = "skip" | PaginatedArgs<F> | Readable<"skip" | PaginatedArgs<F>>;
703
705
  /** The element type of the `page` array a paginated query returns. */
704
706
  type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
705
707
  page: (infer T)[];
@@ -743,9 +745,13 @@ interface InfiniteQueryHandle<T> {
743
745
  *
744
746
  * Pass `client` explicitly, or omit it to resolve the ambient client from the
745
747
  * Svelte context.
748
+ *
749
+ * `args` may also be a `Readable` store: each emission tears the engine down
750
+ * and rebuilds it against the new args (pagination resets to the first page);
751
+ * a `"skip"` emission tears down without re-opening.
746
752
  */
747
- declare function paginatedQuery<F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
748
- declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
753
+ declare function paginatedQuery<F extends FunctionReference>(function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
754
+ declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
749
755
  /**
750
756
  * Open a live paginated query as Svelte stores, keeping each page as its own
751
757
  * inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
@@ -822,6 +828,8 @@ interface PresenceHandle<L extends ListPresentReference> {
822
828
  */
823
829
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
824
830
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
831
+ /** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
832
+ type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
825
833
  /** Options accepted by {@link query}. */
826
834
  interface QueryStoreOptions {
827
835
  /** Called when the underlying subscription reports an error. */
@@ -854,9 +862,15 @@ type QueryStore<F extends FunctionReference> = Readable<ReturnOf<F> | undefined>
854
862
  * Pass `client` explicitly, or omit it to resolve the ambient client published
855
863
  * by `setLunoraClient` (which must therefore be called during component init,
856
864
  * before this runs).
865
+ *
866
+ * `args` may also be a `Readable` store (wrap runes state with `toStore` or
867
+ * `derived`): each emission tears down the previous subscription and opens a
868
+ * fresh one against the new args — the Svelte counterpart of Vue's
869
+ * `MaybeRefOrGetter` args. An emission of `"skip"` tears down without
870
+ * re-opening and resets the value to `undefined`.
857
871
  */
858
- declare function query<F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: QueryStoreOptions): QueryStore<F>;
859
- declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: QueryStoreOptions): QueryStore<F>;
872
+ declare function query<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
873
+ declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
860
874
  interface RateLimitOptions {
861
875
  /** Clock injection for tests. Defaults to `Date.now`. */
862
876
  now?: () => number;
@@ -953,9 +967,13 @@ interface SubscriptionHandle<T> {
953
967
  * Passing `"skip"` as `args` keeps the stores connected but the subscription
954
968
  * dormant (`data` stays `undefined`). Pass an explicit `client` as the first
955
969
  * argument to bypass the ambient context (useful in tests).
970
+ *
971
+ * `args` may also be a `Readable` store: each emission tears down the previous
972
+ * subscription and opens a fresh one; a `"skip"` emission tears down without
973
+ * re-opening and resets `data` to `undefined`.
956
974
  */
957
- declare function subscription<F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
958
- declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
975
+ declare function subscription<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
976
+ declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
959
977
  /**
960
978
  * Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
961
979
  * capture and speaker playback implementations injected into the composable via
@@ -1110,7 +1128,7 @@ interface VoiceAgentHandle {
1110
1128
  */
1111
1129
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1112
1130
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1113
- export { type ActionHandle, type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 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,
1131
+ export { type ActionHandle, type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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,
1114
1132
  /**
1115
1133
  * Svelte adapter for Lunora (`@lunora/svelte`).
1116
1134
  *
package/dist/index.d.ts CHANGED
@@ -700,6 +700,8 @@ interface MutatorHandleStore<TArgs> {
700
700
  declare const mutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHandleStore<TArgs>;
701
701
  /** The args a paginated query exposes minus the framework-supplied page cursor. */
702
702
  type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
703
+ /** Paginated args, the skip sentinel, or a reactive (`Readable`) source of either. */
704
+ type ReactivePaginatedArgs<F extends FunctionReference> = "skip" | PaginatedArgs<F> | Readable<"skip" | PaginatedArgs<F>>;
703
705
  /** The element type of the `page` array a paginated query returns. */
704
706
  type PageItemOf<F extends FunctionReference> = ReturnOf<F> extends {
705
707
  page: (infer T)[];
@@ -743,9 +745,13 @@ interface InfiniteQueryHandle<T> {
743
745
  *
744
746
  * Pass `client` explicitly, or omit it to resolve the ambient client from the
745
747
  * Svelte context.
748
+ *
749
+ * `args` may also be a `Readable` store: each emission tears the engine down
750
+ * and rebuilds it against the new args (pagination resets to the first page);
751
+ * a `"skip"` emission tears down without re-opening.
746
752
  */
747
- declare function paginatedQuery<F extends FunctionReference>(function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
748
- declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: "skip" | PaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
753
+ declare function paginatedQuery<F extends FunctionReference>(function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
754
+ declare function paginatedQuery<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactivePaginatedArgs<F>, options: PaginatedQueryOptions): PaginatedQueryHandle<PageItemOf<F>>;
749
755
  /**
750
756
  * Open a live paginated query as Svelte stores, keeping each page as its own
751
757
  * inner array (TanStack-Query-style `fetchNextPage` / `hasNextPage` shape).
@@ -822,6 +828,8 @@ interface PresenceHandle<L extends ListPresentReference> {
822
828
  */
823
829
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
824
830
  declare function presence<H extends HeartbeatReference, L extends ListPresentReference>(client: LunoraClient, roomId: string, options: PresenceOptions<H, L>): PresenceHandle<L>;
831
+ /** Query args, the skip sentinel, or a reactive (`Readable`) source of either. */
832
+ type ReactiveArgs<F extends FunctionReference> = ArgsOf<F> | "skip" | Readable<ArgsOf<F> | "skip">;
825
833
  /** Options accepted by {@link query}. */
826
834
  interface QueryStoreOptions {
827
835
  /** Called when the underlying subscription reports an error. */
@@ -854,9 +862,15 @@ type QueryStore<F extends FunctionReference> = Readable<ReturnOf<F> | undefined>
854
862
  * Pass `client` explicitly, or omit it to resolve the ambient client published
855
863
  * by `setLunoraClient` (which must therefore be called during component init,
856
864
  * before this runs).
865
+ *
866
+ * `args` may also be a `Readable` store (wrap runes state with `toStore` or
867
+ * `derived`): each emission tears down the previous subscription and opens a
868
+ * fresh one against the new args — the Svelte counterpart of Vue's
869
+ * `MaybeRefOrGetter` args. An emission of `"skip"` tears down without
870
+ * re-opening and resets the value to `undefined`.
857
871
  */
858
- declare function query<F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: QueryStoreOptions): QueryStore<F>;
859
- declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: QueryStoreOptions): QueryStore<F>;
872
+ declare function query<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
873
+ declare function query<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: QueryStoreOptions): QueryStore<F>;
860
874
  interface RateLimitOptions {
861
875
  /** Clock injection for tests. Defaults to `Date.now`. */
862
876
  now?: () => number;
@@ -953,9 +967,13 @@ interface SubscriptionHandle<T> {
953
967
  * Passing `"skip"` as `args` keeps the stores connected but the subscription
954
968
  * dormant (`data` stays `undefined`). Pass an explicit `client` as the first
955
969
  * argument to bypass the ambient context (useful in tests).
970
+ *
971
+ * `args` may also be a `Readable` store: each emission tears down the previous
972
+ * subscription and opens a fresh one; a `"skip"` emission tears down without
973
+ * re-opening and resets `data` to `undefined`.
956
974
  */
957
- declare function subscription<F extends FunctionReference>(function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
958
- declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F> | "skip", options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
975
+ declare function subscription<F extends FunctionReference>(function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
976
+ declare function subscription<F extends FunctionReference>(client: LunoraClient, function_: F, args: ReactiveArgs<F>, options?: SubscriptionStoreOptions): SubscriptionHandle<ReturnOf<F>>;
959
977
  /**
960
978
  * Browser Web Audio subsystems for `useVoiceAgent` — the default microphone
961
979
  * capture and speaker playback implementations injected into the composable via
@@ -1110,7 +1128,7 @@ interface VoiceAgentHandle {
1110
1128
  */
1111
1129
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1112
1130
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1113
- export { type ActionHandle, type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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 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,
1131
+ export { type ActionHandle, type AgentApi, 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 FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, 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,
1114
1132
  /**
1115
1133
  * Svelte adapter for Lunora (`@lunora/svelte`).
1116
1134
  *
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as a}from"./packem_shared/agent-CFzp-ncV.mjs";import{agentChat as f}from"./packem_shared/agentChat-BhMVjqq4.mjs";import{agentState as n}from"./packem_shared/agentState-DyhOvMaV.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-B5yNPA4v.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as L,flags as v}from"./packem_shared/flag-DmEKEmb9.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as q}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as E}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as P,paginatedQuery as T}from"./packem_shared/infiniteQuery-BNglJ4ft.mjs";import{presence as k}from"./packem_shared/presence-I_W9Zbhg.mjs";import{query as z}from"./packem_shared/query-Bsh9h9vB.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as J}from"./packem_shared/subscription-MIh5Yd8c.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-odCezdLl.mjs";export{t as action,a as agent,f as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,L as flag,v as flags,h as getLunoraClient,S as hydratePreloaded,P as infiniteQuery,q as mutation,E as mutator,T as paginatedQuery,k as presence,z as query,D as rateLimit,y as setLunoraClient,H as stream,J as subscription,M as voiceAgent};
1
+ import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as a}from"./packem_shared/agent-CFzp-ncV.mjs";import{agentChat as f}from"./packem_shared/agentChat-BhMVjqq4.mjs";import{agentState as n}from"./packem_shared/agentState-at2Rg_Q9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-BrybzNXi.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as L,flags as v}from"./packem_shared/flag-DmEKEmb9.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as q}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as E}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as P,paginatedQuery as T}from"./packem_shared/infiniteQuery-S4ETxAi1.mjs";import{presence as k}from"./packem_shared/presence-I_W9Zbhg.mjs";import{query as z}from"./packem_shared/query-aWSTFtNz.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as J}from"./packem_shared/subscription-3foboeMU.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-odCezdLl.mjs";export{t as action,a as agent,f as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,L as flag,v as flags,h as getLunoraClient,S as hydratePreloaded,P as infiniteQuery,q as mutation,E as mutator,T as paginatedQuery,k as presence,z as query,D as rateLimit,y as setLunoraClient,H as stream,J as subscription,M as voiceAgent};
@@ -1 +1 @@
1
- import{derived as c}from"svelte/store";import{isClient as p}from"./agent-CFzp-ncV.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-MIh5Yd8c.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-CFzp-ncV.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-3foboeMU.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 m}from"./agent-CFzp-ncV.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-eY1eAuVw.mjs";import{subscription as h}from"./subscription-MIh5Yd8c.mjs";const k={__lunoraRef:""},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{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 K(t,l){const n=m(t),a=n?t:I(),u=n?l:t,{api:p,limit:e,stream:i,threadKey:r}=u,s=e===void 0?{key:r}:{key:r,limit:e},{data:c}=h(a,p.agents.agentMessages,s),v=N(a,i??k,i===void 0?"skip":{key:r});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(o=>q(o)??[]);for(const o of C)o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}}export{K as agentToolEvents};
1
+ import{derived as y}from"svelte/store";import{isClient as m}from"./agent-CFzp-ncV.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-eY1eAuVw.mjs";import{subscription as h}from"./subscription-3foboeMU.mjs";const k={__lunoraRef:""},q=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{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 K(t,l){const n=m(t),a=n?t:I(),u=n?l:t,{api:p,limit:e,stream:i,threadKey:r}=u,s=e===void 0?{key:r}:{key:r,limit:e},{data:c}=h(a,p.agents.agentMessages,s),v=N(a,i??k,i===void 0?"skip":{key:r});return{events:y([c,v.chunks],([f,C])=>{const d=(f??[]).flatMap(o=>q(o)??[]);for(const o of C)o.kind==="progress"&&o.threadKey===r&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}}export{K as agentToolEvents};
@@ -0,0 +1 @@
1
+ import{initialPages as U,derivePaginationStatus as J,applyLoadMore as G,rebalance as H}from"@lunora/client/pagination";import{derived as j,writable as W,readable as V,get as E}from"svelte/store";import{getLunoraClient as F}from"./getLunoraClient-DU7BmZy1.mjs";import{i as Q}from"./is-function-reference-abFdrAae.mjs";import{i as X,s as Y}from"./subscribe-reactive-args-DYKqoWhw.mjs";const Z=(e,n)=>e<n?-1:e>n?1:0,B=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>B(t)).join(",")}]`;const n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype){const t=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${t} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const a=e,u=Object.keys(a).toSorted(Z),o=[];for(const t of u){const r=a[t];r!==void 0&&o.push(`${JSON.stringify(t)}:${B(r)}`)}return`{${o.join(",")}}`},C=e=>{let n="";for(let u=0;u<e.length;u+=32768)n+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(n)},y="$lunora.wire$",D=64,v="__proto__",ee=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},h=(e,n=0)=>{if(n>D)throw new RangeError(`wire-codec: value nesting exceeds the ${D}-level limit`);if(e===void 0)return[y,"undefined"];if(e===null)return null;const a=typeof e;if(a==="bigint")return[y,"bigint",e.toString()];if(a==="number"){const t=e;return Number.isNaN(t)?[y,"nan"]:t===1/0?[y,"inf"]:t===-1/0?[y,"-inf"]:t}if(a!=="object")return e;if(e instanceof Date)return[y,"date",h(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const i of Object.keys(t))t[i]!==void 0&&(r[i]=h(t[i],n+1));const s=[y,"error",t.name,t.message,r];return t.cause!==void 0&&s.push(h(t.cause,n+1)),s}if(e instanceof URL)return[y,"url",e.href];if(e instanceof Map)return[y,"map",[...e.entries()].map(([t,r])=>[h(t,n+1),h(r,n+1)])];if(e instanceof Set)return[y,"set",[...e].map(t=>h(t,n+1))];if(e instanceof ArrayBuffer)return[y,"bytes",C(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[y,"bytes",C(s)]:[y,"bytes",C(s),r]}if(Array.isArray(e)){const t=e.map(r=>h(r,n+1));return t.length>0&&t[0]===y?[y,"arr",t]:t}if(!ee(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const u=e,o={};for(const t of Object.keys(u)){const r=u[t];if(r===void 0)continue;const s=h(r,n+1);t===v?Object.defineProperty(o,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):o[t]=s}return o},te=e=>B(h(e)),K=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),x=(e,n)=>`${e}::${te(n)}`,q=(e,n,a,u)=>{const{initialNumItems:o,shardKey:t}=u,r=W(U(o)),s=W([]),i=new Map,l=new Map,k=new Set;let f=X(a)?"skip":a;const b=()=>{if(f==="skip"){s.set([]);return}const d=f,w=E(r).map(R=>{const c=x(n.__lunoraRef,K(R,d));return i.get(c)});s.set(w)},I=(d,w)=>{if(f==="skip")return;const R=f,c=p=>x(n.__lunoraRef,K(p,R));for(const p of w){const g=c(p);if(i.has(g))continue;const N=d.find(P=>P.lower===p.lower);if(N){const P=i.get(c(N));P&&i.set(g,P)}}},S=()=>{if(f==="skip"){for(const c of l.values())c();l.clear(),s.set([]);return}const d=f,w=E(r),R=new Set;for(const c of w)R.add(x(n.__lunoraRef,K(c,d)));for(const[c,p]of l)R.has(c)||(p(),l.delete(c),k.delete(c),i.delete(c));for(const c of w){const p=K(c,d),g=x(n.__lunoraRef,p);if(l.has(g))continue;k.add(g);const N=e.subscribe(n,p,P=>{if(i.set(g,P),k.delete(g),b(),k.size===0){const M=E(r),L=H(M,E(s));L&&(I(M,L),r.set(L),O(),b())}},{shardKey:t});l.set(g,N)}};let A=!1,_=!1;const O=()=>{if(A){_=!0;return}A=!0;try{do _=!1,S();while(_)}finally{A=!1}},m=()=>{for(const d of l.values())d();l.clear(),i.clear(),k.clear()},$=V([],d=>{const w=s.subscribe(d),R=Y(a,c=>(f=c,O(),b(),()=>{m(),r.set(U(o))}));return()=>{R(),w(),s.set([])}}),z=j($,d=>J(f==="skip",d).status);return{loadMore:d=>{if(f==="skip")return;const w=E(s),{nextCursor:R,status:c}=J(!1,w);if(c!=="CanLoadMore")return;const p=E(r),g=G(p,R,d);if(!g)return;const N=p.at(-1),P=g.at(-2);if(N&&P){const M=x(n.__lunoraRef,K(N,f)),L=x(n.__lunoraRef,K(P,f));if(M!==L){const T=i.get(M);T&&(i.set(L,T),i.delete(M))}}r.set(g),O(),b()},pageResults:$,status:z}};function ae(e,n,a,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?a:n,i=o?u:a,{loadMore:l,pageResults:k,status:f}=q(t,r,s,i),b=j(k,S=>S.flatMap(A=>A?.page??[]));return{isLoading:j(f,S=>S==="LoadingFirstPage"||S==="LoadingMore"),loadMore:l,results:b,status:f}}function fe(e,n,a,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?a:n,i=o?u:a,{initialNumItems:l}=i,{loadMore:k,pageResults:f,status:b}=q(t,r,s,i),I=j(f,m=>m.flatMap($=>$?[$.page]:[])),S=j(b,m=>m==="LoadingFirstPage"),A=j(b,m=>m==="CanLoadMore"),_=j(b,m=>m==="LoadingMore");return{fetchNextPage:m=>{k(m??l)},hasNextPage:A,isFetchingNextPage:_,isLoading:S,pages:I,status:b}}export{fe as infiniteQuery,ae as paginatedQuery};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as d}from"@lunora/client/query";import{readable as u}from"svelte/store";import{getLunoraClient as b}from"./getLunoraClient-DU7BmZy1.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-DYKqoWhw.mjs";function K(r,e,t,s){const o=!y(r),a=o?r:b(),c=o?e:r,p=o?t:e,i=(o?s:t)??{};return u(void 0,n=>R(p,f=>d(a,c,f,{onData:m=>{n(m)},onError:i.onError,onReset:()=>{n(void 0)}},{shardKey:i.shardKey})))}export{K as query};
@@ -0,0 +1 @@
1
+ const c=e=>typeof e?.subscribe=="function",l=(e,n)=>{if(!c(e))return n(e);let t=()=>{},s=!1,i;const b=e.subscribe(u=>{if(s){i=[u];return}s=!0;try{let r=[u];for(;r;)t(),t=n(r[0]),r=i,i=void 0}finally{s=!1}});return()=>{b(),t()}};export{c as i,l as s};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as E}from"@lunora/client/query";import{writable as R,readable as g}from"svelte/store";import{getLunoraClient as h}from"./getLunoraClient-DU7BmZy1.mjs";import{i as w}from"./is-function-reference-abFdrAae.mjs";import{s as x}from"./subscribe-reactive-args-DYKqoWhw.mjs";function Q(e,s,n,a){const r=!w(e),p=r?e:h(),m=r?s:e,b=r?n:s,u=(r?a:n)??{},{shardKey:d,onError:f}=u,o=R();return{data:g(void 0,i=>{const v=x(b,l=>(o.set(void 0),E(p,m,l,{onData:t=>{i(t),o.set(void 0)},onError:t=>{const c=new Error(t.message);o.set(c),f?.(c)},onReset:()=>{i(void 0)}},{shardKey:d})));return()=>{v(),o.set(void 0)}}),error:{subscribe:o.subscribe}}}export{Q as subscription};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/svelte",
3
- "version": "1.0.0-alpha.89",
3
+ "version": "1.0.0-alpha.90",
4
4
  "description": "Svelte adapter for Lunora — live stores, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -57,7 +57,6 @@
57
57
  "@lunora/client": "1.0.0-alpha.56",
58
58
  "@lunora/errors": "1.0.0-alpha.22",
59
59
  "@lunora/ratelimit": "1.0.0-alpha.25",
60
- "@lunora/runtime": "1.0.0-alpha.69",
61
60
  "@visulima/storage-client": "1.0.2"
62
61
  },
63
62
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{initialPages as U,derivePaginationStatus as J,applyLoadMore as G,rebalance as H}from"@lunora/client/pagination";import{derived as j,writable as W,readable as V,get as L}from"svelte/store";import{getLunoraClient as F}from"./getLunoraClient-DU7BmZy1.mjs";import{i as Q}from"./is-function-reference-abFdrAae.mjs";const X=(e,n)=>e<n?-1:e>n?1:0,B=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>B(t)).join(",")}]`;const n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype){const t=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${t} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const f=e,u=Object.keys(f).toSorted(X),o=[];for(const t of u){const r=f[t];r!==void 0&&o.push(`${JSON.stringify(t)}:${B(r)}`)}return`{${o.join(",")}}`},C=e=>{let n="";for(let u=0;u<e.length;u+=32768)n+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(n)},y="$lunora.wire$",D=64,Y="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},R=(e,n=0)=>{if(n>D)throw new RangeError(`wire-codec: value nesting exceeds the ${D}-level limit`);if(e===void 0)return[y,"undefined"];if(e===null)return null;const f=typeof e;if(f==="bigint")return[y,"bigint",e.toString()];if(f==="number"){const t=e;return Number.isNaN(t)?[y,"nan"]:t===1/0?[y,"inf"]:t===-1/0?[y,"-inf"]:t}if(f!=="object")return e;if(e instanceof Date)return[y,"date",R(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const i of Object.keys(t))t[i]!==void 0&&(r[i]=R(t[i],n+1));const s=[y,"error",t.name,t.message,r];return t.cause!==void 0&&s.push(R(t.cause,n+1)),s}if(e instanceof URL)return[y,"url",e.href];if(e instanceof Map)return[y,"map",[...e.entries()].map(([t,r])=>[R(t,n+1),R(r,n+1)])];if(e instanceof Set)return[y,"set",[...e].map(t=>R(t,n+1))];if(e instanceof ArrayBuffer)return[y,"bytes",C(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[y,"bytes",C(s)]:[y,"bytes",C(s),r]}if(Array.isArray(e)){const t=e.map(r=>R(r,n+1));return t.length>0&&t[0]===y?[y,"arr",t]:t}if(!Z(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const u=e,o={};for(const t of Object.keys(u)){const r=u[t];if(r===void 0)continue;const s=R(r,n+1);t===Y?Object.defineProperty(o,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):o[t]=s}return o},v=e=>B(R(e)),E=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),K=(e,n)=>`${e}::${v(n)}`,q=(e,n,f,u)=>{const{initialNumItems:o,shardKey:t}=u,r=W(U(o)),s=W([]),i=new Map,d=new Map,k=new Set,a=f,g=()=>{if(a==="skip"){s.set([]);return}const l=L(r).map(m=>{const P=K(n.__lunoraRef,E(m,a));return i.get(P)});s.set(l)},$=(l,m)=>{if(a==="skip")return;const P=c=>K(n.__lunoraRef,E(c,a));for(const c of m){const w=P(c);if(i.has(w))continue;const p=l.find(h=>h.lower===c.lower);if(p){const h=i.get(P(p));h&&i.set(w,h)}}},S=()=>{if(a==="skip"){for(const c of d.values())c();d.clear(),s.set([]);return}const l=a,m=L(r),P=new Set;for(const c of m)P.add(K(n.__lunoraRef,E(c,l)));for(const[c,w]of d)P.has(c)||(w(),d.delete(c),k.delete(c),i.delete(c));for(const c of m){const w=E(c,l),p=K(n.__lunoraRef,w);if(d.has(p))continue;k.add(p);const h=e.subscribe(n,w,O=>{if(i.set(p,O),k.delete(p),g(),k.size===0){const A=L(r),M=H(A,L(s));M&&($(A,M),r.set(M),I(),g())}},{shardKey:t});d.set(p,h)}};let N=!1,x=!1;const I=()=>{if(N){x=!0;return}N=!0;try{do x=!1,S();while(x)}finally{N=!1}},b=()=>{for(const l of d.values())l();d.clear(),i.clear(),k.clear()},_=V([],l=>{const m=s.subscribe(l);return a!=="skip"&&(I(),g()),()=>{m(),b(),r.set(U(o)),s.set([])}}),z=j(_,l=>J(a==="skip",l).status);return{loadMore:l=>{if(a==="skip")return;const m=L(s),{nextCursor:P,status:c}=J(!1,m);if(c!=="CanLoadMore")return;const w=L(r),p=G(w,P,l);if(!p)return;const h=w.at(-1),O=p.at(-2);if(h&&O){const A=K(n.__lunoraRef,E(h,a)),M=K(n.__lunoraRef,E(O,a));if(A!==M){const T=i.get(A);T&&(i.set(M,T),i.delete(A))}}r.set(p),I(),g()},pageResults:_,status:z}};function oe(e,n,f,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?f:n,i=o?u:f,{loadMore:d,pageResults:k,status:a}=q(t,r,s,i),g=j(k,S=>S.flatMap(N=>N?.page??[]));return{isLoading:j(a,S=>S==="LoadingFirstPage"||S==="LoadingMore"),loadMore:d,results:g,status:a}}function ie(e,n,f,u){const o=!Q(e),t=o?e:F(),r=o?n:e,s=o?f:n,i=o?u:f,{initialNumItems:d}=i,{loadMore:k,pageResults:a,status:g}=q(t,r,s,i),$=j(a,b=>b.flatMap(_=>_?[_.page]:[])),S=j(g,b=>b==="LoadingFirstPage"),N=j(g,b=>b==="CanLoadMore"),x=j(g,b=>b==="LoadingMore");return{fetchNextPage:b=>{k(b??d)},hasNextPage:N,isFetchingNextPage:x,isLoading:S,pages:$,status:g}}export{ie as infiniteQuery,oe as paginatedQuery};
@@ -1 +0,0 @@
1
- import{createQuerySubscription as m}from"@lunora/client/query";import{readable as d}from"svelte/store";import{getLunoraClient as y}from"./getLunoraClient-DU7BmZy1.mjs";import{i as h}from"./is-function-reference-abFdrAae.mjs";function b(r,e,t,a){const o=!h(r),s=o?r:y(),c=o?e:r,f=o?t:e,i=(o?a:t)??{};return d(void 0,n=>m(s,c,f,{onData:p=>{n(p)},onError:i.onError,onReset:()=>{n(void 0)}},{shardKey:i.shardKey}))}export{b as query};
@@ -1 +0,0 @@
1
- import{createQuerySubscription as v}from"@lunora/client/query";import{writable as E,readable as R}from"svelte/store";import{getLunoraClient as h}from"./getLunoraClient-DU7BmZy1.mjs";import{i as w}from"./is-function-reference-abFdrAae.mjs";function D(e,s,n,a){const r=!w(e),b=r?e:h(),u=r?s:e,m=r?n:s,d=(r?a:n)??{},{shardKey:p,onError:f}=d,o=E();return{data:R(void 0,i=>{const l=v(b,u,m,{onData:t=>{i(t),o.set(void 0)},onError:t=>{const c=new Error(t.message);o.set(c),f?.(c)},onReset:()=>{i(void 0)}},{shardKey:p});return()=>{l(),o.set(void 0)}}),error:{subscribe:o.subscribe}}}export{D as subscription};