@lunora/svelte 1.0.0-alpha.266 → 1.0.0-alpha.268

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/README.md CHANGED
@@ -104,6 +104,7 @@ All functions that require a component lifecycle (presence, rate-limit) return a
104
104
  | `query` | `useQuery` | Live readable store — updates on every server delta. |
105
105
  | `mutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset` stores). |
106
106
  | `subscription` | `useSubscription` | Raw subscription readable — unbounded live stream. |
107
+ | `liveTopic` | `useLiveTopic` | One declared live topic — readable of `{ lastEvent, error }`, no teardown. |
107
108
  | `paginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, `results`, and `error` stores. |
108
109
  | `infiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `paginatedQuery`. |
109
110
  | `auth` | `useAuth` | Reactive auth stores (`user`, `token`, `status`) plus `setToken`. |
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
1
+ import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, LiveStreamSubscribeError, LiveTopicRef, LiveTopicOptions, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
2
2
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, Preloaded, ReturnOf } from '@lunora/client';
3
3
  import { Readable } from 'svelte/store';
4
4
  import { AuthStatus } from '@lunora/client/auth';
@@ -680,6 +680,34 @@ declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient
680
680
  declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, client?: LunoraClient, options?: {
681
681
  onError?: SubscriptionErrorCallback;
682
682
  }) => Readable<T | undefined>;
683
+ /**
684
+ * `liveTopic` — follow one live topic on the connection shared by its stream's route.
685
+ *
686
+ * A thin lifecycle wrapper over `subscribeLiveTopic` from `@lunora/client`. The
687
+ * subscription opens when the store gets its first subscriber and closes when it
688
+ * loses its last one, so there is no `teardown()` to call. Like the other stores
689
+ * here, a server render subscribes and opens nothing.
690
+ *
691
+ * The `LunoraClient` is read from context when `liveTopic` is CALLED, so call it while a
692
+ * component initialises: `getContext` throws outside that window.
693
+ */
694
+ /** The state a `liveTopic` store holds. */
695
+ interface LiveTopicState<Payload = unknown> {
696
+ /** The shard's refusal of this subscription (403, 409, 429 and similar), or `undefined`. */
697
+ error: LiveStreamSubscribeError | undefined;
698
+ /** The last payload delivered on the topic, or `undefined` until the first event. */
699
+ lastEvent: Payload | undefined;
700
+ }
701
+ /**
702
+ * Follow the topic `topic` names on the shared live connection for its stream's route. Pass the
703
+ * reference `_generated/live.ts` hands out (`live.posts.post({ postId })`), or a `Readable` of one.
704
+ * `options` may be a `Readable` too, e.g. to move to a new `sessionKey` on sign-out. A new emission
705
+ * resubscribes only when the topic or the connection options (including `sessionKey`) change;
706
+ * `onEvent` and `onError` are read at call time, so a new identity never reopens the subscription.
707
+ * The route is resolved against the `LunoraClient` from context, and `lastEvent` and `onEvent` are
708
+ * typed by the payload the topic declares.
709
+ */
710
+ declare const liveTopic: <Payload>(topic: LiveTopicRef<Payload> | Readable<LiveTopicRef<Payload>>, options?: LiveTopicOptions<Payload> | Readable<LiveTopicOptions<Payload>>) => Readable<LiveTopicState<Payload>>;
683
711
  /**
684
712
  * The reactive handle returned by {@link mutation} — the Svelte counterpart to
685
713
  * React's `useMutation`, re-expressed as stores you read with `$`. The surface
@@ -1239,7 +1267,7 @@ interface VoiceAgentHandle {
1239
1267
  */
1240
1268
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1241
1269
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1242
- 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 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,
1270
+ 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 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,
1243
1271
  /**
1244
1272
  * Svelte adapter for Lunora (`@lunora/svelte`).
1245
1273
  *
@@ -1261,7 +1289,7 @@ export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHand
1261
1289
  * framework-neutral server contract) — import them there in your SvelteKit
1262
1290
  * `+page.ts` / `+layout.ts` load.
1263
1291
  */
1264
- getLunoraClient, hydratePreloaded, infiniteQuery, mutation, mutator, paginatedQuery, presence, query, rateLimit,
1292
+ getLunoraClient, hydratePreloaded, infiniteQuery, liveTopic, mutation, mutator, paginatedQuery, presence, query, rateLimit,
1265
1293
  /**
1266
1294
  * Svelte adapter for Lunora (`@lunora/svelte`).
1267
1295
  *
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
1
+ import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, LiveStreamSubscribeError, LiveTopicRef, LiveTopicOptions, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
2
2
  export type { ArgsOf, ConnectionStatus, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, Preloaded, ReturnOf } from '@lunora/client';
3
3
  import { Readable } from 'svelte/store';
4
4
  import { AuthStatus } from '@lunora/client/auth';
@@ -680,6 +680,34 @@ declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient
680
680
  declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, client?: LunoraClient, options?: {
681
681
  onError?: SubscriptionErrorCallback;
682
682
  }) => Readable<T | undefined>;
683
+ /**
684
+ * `liveTopic` — follow one live topic on the connection shared by its stream's route.
685
+ *
686
+ * A thin lifecycle wrapper over `subscribeLiveTopic` from `@lunora/client`. The
687
+ * subscription opens when the store gets its first subscriber and closes when it
688
+ * loses its last one, so there is no `teardown()` to call. Like the other stores
689
+ * here, a server render subscribes and opens nothing.
690
+ *
691
+ * The `LunoraClient` is read from context when `liveTopic` is CALLED, so call it while a
692
+ * component initialises: `getContext` throws outside that window.
693
+ */
694
+ /** The state a `liveTopic` store holds. */
695
+ interface LiveTopicState<Payload = unknown> {
696
+ /** The shard's refusal of this subscription (403, 409, 429 and similar), or `undefined`. */
697
+ error: LiveStreamSubscribeError | undefined;
698
+ /** The last payload delivered on the topic, or `undefined` until the first event. */
699
+ lastEvent: Payload | undefined;
700
+ }
701
+ /**
702
+ * Follow the topic `topic` names on the shared live connection for its stream's route. Pass the
703
+ * reference `_generated/live.ts` hands out (`live.posts.post({ postId })`), or a `Readable` of one.
704
+ * `options` may be a `Readable` too, e.g. to move to a new `sessionKey` on sign-out. A new emission
705
+ * resubscribes only when the topic or the connection options (including `sessionKey`) change;
706
+ * `onEvent` and `onError` are read at call time, so a new identity never reopens the subscription.
707
+ * The route is resolved against the `LunoraClient` from context, and `lastEvent` and `onEvent` are
708
+ * typed by the payload the topic declares.
709
+ */
710
+ declare const liveTopic: <Payload>(topic: LiveTopicRef<Payload> | Readable<LiveTopicRef<Payload>>, options?: LiveTopicOptions<Payload> | Readable<LiveTopicOptions<Payload>>) => Readable<LiveTopicState<Payload>>;
683
711
  /**
684
712
  * The reactive handle returned by {@link mutation} — the Svelte counterpart to
685
713
  * React's `useMutation`, re-expressed as stores you read with `$`. The surface
@@ -1239,7 +1267,7 @@ interface VoiceAgentHandle {
1239
1267
  */
1240
1268
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1241
1269
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1242
- 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 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,
1270
+ 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 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,
1243
1271
  /**
1244
1272
  * Svelte adapter for Lunora (`@lunora/svelte`).
1245
1273
  *
@@ -1261,7 +1289,7 @@ export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHand
1261
1289
  * framework-neutral server contract) — import them there in your SvelteKit
1262
1290
  * `+page.ts` / `+layout.ts` load.
1263
1291
  */
1264
- getLunoraClient, hydratePreloaded, infiniteQuery, mutation, mutator, paginatedQuery, presence, query, rateLimit,
1292
+ getLunoraClient, hydratePreloaded, infiniteQuery, liveTopic, mutation, mutator, paginatedQuery, presence, query, rateLimit,
1265
1293
  /**
1266
1294
  * Svelte adapter for Lunora (`@lunora/svelte`).
1267
1295
  *
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-WMVWf1Ks.mjs";import{agentChat as f}from"./packem_shared/agentChat-CX6dTMoY.mjs";import{agentState as n}from"./packem_shared/agentState-DQC-OIi6.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-BD98xaGH.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 L,flags as v}from"./packem_shared/flag-Csh9LBiO.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CNm2-Rha.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-B6dobUkL.mjs";import{presence as k}from"./packem_shared/presence-C4ZgfGfr.mjs";import{query as z}from"./packem_shared/query-C6B__ZRN.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-Cxl8guzh.mjs";import{subscription as J}from"./packem_shared/subscription-BKRHURpA.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-KSChAXsW.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 m}from"./packem_shared/agent-WMVWf1Ks.mjs";import{agentChat as a}from"./packem_shared/agentChat-CX6dTMoY.mjs";import{agentState as n}from"./packem_shared/agentState-DQC-OIi6.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-BD98xaGH.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-BKRHURpA.mjs";import{voiceAgent as O}from"./packem_shared/voiceAgent-KSChAXsW.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{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-DU7BmZy1.mjs";import{i as l,s as D}from"./subscribe-reactive-args-D0fSbP1k.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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/svelte",
3
- "version": "1.0.0-alpha.266",
3
+ "version": "1.0.0-alpha.268",
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.227",
57
+ "@lunora/client": "1.0.0-alpha.229",
58
58
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
59
- "@lunora/ratelimit": "1.0.0-alpha.150",
59
+ "@lunora/ratelimit": "1.0.0-alpha.152",
60
60
  "@lunora/wire": "1.0.0-alpha.1",
61
61
  "@visulima/storage-client": "1.0.9"
62
62
  },