@lunora/svelte 1.0.0-alpha.267 → 1.0.0-alpha.269
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 +1 -1
- package/dist/index.d.mts +15 -10
- package/dist/index.d.ts +15 -10
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/liveTopic-DKHSwXiX.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/liveTopic-DiHigDnv.mjs +0 -1
package/README.md
CHANGED
|
@@ -104,7 +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 live topic
|
|
107
|
+
| `liveTopic` | `useLiveTopic` | One declared live topic — readable of `{ lastEvent, error }`, no teardown. |
|
|
108
108
|
| `paginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, `results`, and `error` stores. |
|
|
109
109
|
| `infiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `paginatedQuery`. |
|
|
110
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, LiveStreamSubscribeError,
|
|
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';
|
|
@@ -681,28 +681,33 @@ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, client?: LunoraClie
|
|
|
681
681
|
onError?: SubscriptionErrorCallback;
|
|
682
682
|
}) => Readable<T | undefined>;
|
|
683
683
|
/**
|
|
684
|
-
* `liveTopic` — follow one live topic on the connection shared by its
|
|
684
|
+
* `liveTopic` — follow one live topic on the connection shared by its stream's route.
|
|
685
685
|
*
|
|
686
686
|
* A thin lifecycle wrapper over `subscribeLiveTopic` from `@lunora/client`. The
|
|
687
687
|
* subscription opens when the store gets its first subscriber and closes when it
|
|
688
688
|
* loses its last one, so there is no `teardown()` to call. Like the other stores
|
|
689
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.
|
|
690
693
|
*/
|
|
691
694
|
/** The state a `liveTopic` store holds. */
|
|
692
|
-
interface LiveTopicState {
|
|
695
|
+
interface LiveTopicState<Payload = unknown> {
|
|
693
696
|
/** The shard's refusal of this subscription (403, 409, 429 and similar), or `undefined`. */
|
|
694
697
|
error: LiveStreamSubscribeError | undefined;
|
|
695
698
|
/** The last payload delivered on the topic, or `undefined` until the first event. */
|
|
696
|
-
lastEvent:
|
|
699
|
+
lastEvent: Payload | undefined;
|
|
697
700
|
}
|
|
698
701
|
/**
|
|
699
|
-
* Follow `
|
|
700
|
-
*
|
|
701
|
-
* `options` may
|
|
702
|
-
*
|
|
703
|
-
*
|
|
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.
|
|
704
709
|
*/
|
|
705
|
-
declare const liveTopic: (
|
|
710
|
+
declare const liveTopic: <Payload>(topic: LiveTopicRef<Payload> | Readable<LiveTopicRef<Payload>>, options?: LiveTopicOptions<Payload> | Readable<LiveTopicOptions<Payload>>) => Readable<LiveTopicState<Payload>>;
|
|
706
711
|
/**
|
|
707
712
|
* The reactive handle returned by {@link mutation} — the Svelte counterpart to
|
|
708
713
|
* React's `useMutation`, re-expressed as stores you read with `$`. The surface
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, LiveStreamSubscribeError,
|
|
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';
|
|
@@ -681,28 +681,33 @@ declare const hydratePreloaded: <T>(preloaded: Preloaded<T>, client?: LunoraClie
|
|
|
681
681
|
onError?: SubscriptionErrorCallback;
|
|
682
682
|
}) => Readable<T | undefined>;
|
|
683
683
|
/**
|
|
684
|
-
* `liveTopic` — follow one live topic on the connection shared by its
|
|
684
|
+
* `liveTopic` — follow one live topic on the connection shared by its stream's route.
|
|
685
685
|
*
|
|
686
686
|
* A thin lifecycle wrapper over `subscribeLiveTopic` from `@lunora/client`. The
|
|
687
687
|
* subscription opens when the store gets its first subscriber and closes when it
|
|
688
688
|
* loses its last one, so there is no `teardown()` to call. Like the other stores
|
|
689
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.
|
|
690
693
|
*/
|
|
691
694
|
/** The state a `liveTopic` store holds. */
|
|
692
|
-
interface LiveTopicState {
|
|
695
|
+
interface LiveTopicState<Payload = unknown> {
|
|
693
696
|
/** The shard's refusal of this subscription (403, 409, 429 and similar), or `undefined`. */
|
|
694
697
|
error: LiveStreamSubscribeError | undefined;
|
|
695
698
|
/** The last payload delivered on the topic, or `undefined` until the first event. */
|
|
696
|
-
lastEvent:
|
|
699
|
+
lastEvent: Payload | undefined;
|
|
697
700
|
}
|
|
698
701
|
/**
|
|
699
|
-
* Follow `
|
|
700
|
-
*
|
|
701
|
-
* `options` may
|
|
702
|
-
*
|
|
703
|
-
*
|
|
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.
|
|
704
709
|
*/
|
|
705
|
-
declare const liveTopic: (
|
|
710
|
+
declare const liveTopic: <Payload>(topic: LiveTopicRef<Payload> | Readable<LiveTopicRef<Payload>>, options?: LiveTopicOptions<Payload> | Readable<LiveTopicOptions<Payload>>) => Readable<LiveTopicState<Payload>>;
|
|
706
711
|
/**
|
|
707
712
|
* The reactive handle returned by {@link mutation} — the Svelte counterpart to
|
|
708
713
|
* React's `useMutation`, re-expressed as stores you read with `$`. The surface
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as m}from"./packem_shared/agent-WMVWf1Ks.mjs";import{agentChat as a}from"./packem_shared/agentChat-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-
|
|
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.
|
|
3
|
+
"version": "1.0.0-alpha.269",
|
|
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.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.230",
|
|
58
58
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.153",
|
|
60
60
|
"@lunora/wire": "1.0.0-alpha.1",
|
|
61
61
|
"@visulima/storage-client": "1.0.9"
|
|
62
62
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{subscribeLiveTopic as d}from"@lunora/client";import{readable as c,derived as m}from"svelte/store";import{i as u}from"./is-browser-BEdfLJHK.mjs";import{i as b,s as y}from"./subscribe-reactive-args-D0fSbP1k.mjs";const E=r=>({headers:r.headers,maxDelayMs:r.maxDelayMs,retryDelay:r.retryDelay,sessionKey:r.sessionKey,topic:r.topic,url:r.url,withCredentials:r.withCredentials}),w=r=>c({error:void 0,lastEvent:void 0},o=>{if(!u())return;const a=b(r)?r:c(r);let s;const n=a.subscribe(i=>{s=i}),l=i=>{let t;return o({error:void 0,lastEvent:t}),d({...i,onError:e=>{o({error:e,lastEvent:t}),s?.onError?.(e)},onEvent:e=>{t=e,o({error:void 0,lastEvent:t}),s?.onEvent?.(e)}})},v=y(m(a,E),l);return()=>{v(),n()}});export{w as liveTopic};
|