@lunora/svelte 1.0.0-alpha.136 → 1.0.0-alpha.137
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 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{agentState-CS3hHD6A.mjs → agentState-BfiH58gs.mjs} +1 -1
- package/dist/packem_shared/{agentToolEvents-DlVpngzv.mjs → agentToolEvents-DhC7lunJ.mjs} +1 -1
- package/dist/packem_shared/auth-Z0G_aZYz.mjs +1 -0
- package/dist/packem_shared/infiniteQuery-DGTn4Zbx.mjs +1 -0
- package/dist/packem_shared/{query-VzaOi1pv.mjs → query-DONZ7jtA.mjs} +1 -1
- package/dist/packem_shared/subscribe-reactive-args-BAIhVhJk.mjs +1 -0
- package/dist/packem_shared/{subscription-NVRm3LD-.mjs → subscription-b5R8BAAh.mjs} +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/auth-BrLyP-oa.mjs +0 -1
- package/dist/packem_shared/infiniteQuery-CSXXv5DY.mjs +0 -1
- package/dist/packem_shared/subscribe-reactive-args-DYKqoWhw.mjs +0 -1
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ All functions that require a component lifecycle (presence, rate-limit) return a
|
|
|
106
106
|
| `subscription` | `useSubscription` | Raw subscription readable — unbounded live stream. |
|
|
107
107
|
| `paginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, `results`, and `error` stores. |
|
|
108
108
|
| `infiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `paginatedQuery`. |
|
|
109
|
-
| `auth` | `useAuth` | Reactive auth stores (`user`, `token`) plus `setToken`.
|
|
109
|
+
| `auth` | `useAuth` | Reactive auth stores (`user`, `token`, `status`) plus `setToken`. |
|
|
110
110
|
| `presence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members readable + `teardown`. |
|
|
111
111
|
| `flag` | `useFlag` | Live OpenFeature flag readable store — holds `default` until the server answers. |
|
|
112
112
|
| `flags` | `useFlags` | Batch variant — a readable store of one value per key in the defaults map. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, 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
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
/**
|
|
@@ -519,6 +520,13 @@ declare const getLunoraClient: () => LunoraClient;
|
|
|
519
520
|
interface AuthStore {
|
|
520
521
|
/** Set the auth token on the underlying `LunoraClient`. */
|
|
521
522
|
setToken: (token: string | null) => void;
|
|
523
|
+
/**
|
|
524
|
+
* Readable store of the resolved auth state. Branch on this, not on
|
|
525
|
+
* `$user === null` — see the contract in `@lunora/client/auth`; `user` is
|
|
526
|
+
* `null` both when signed out and when a held credential's identity could
|
|
527
|
+
* not be resolved.
|
|
528
|
+
*/
|
|
529
|
+
status: Readable<AuthStatus>;
|
|
522
530
|
/** Readable store of the auth token (`null` when signed out). */
|
|
523
531
|
token: Readable<string | null>;
|
|
524
532
|
/** Readable store of the resolved user (`null` when signed out or still loading). */
|
|
@@ -543,18 +551,20 @@ interface AuthStore {
|
|
|
543
551
|
declare const auth: (explicitClient?: ReturnType<typeof getLunoraClient>) => AuthStore;
|
|
544
552
|
/** Derived auth-gate stores for template gating (`{#if $isAuthenticated}`), built on {@link auth}. */
|
|
545
553
|
interface AuthGateStore {
|
|
546
|
-
/** Readable store, `true` once a
|
|
554
|
+
/** Readable store, `true` once a credential is held and nothing has contradicted it. */
|
|
547
555
|
isAuthenticated: Readable<boolean>;
|
|
548
|
-
/** Readable store, `true` while a
|
|
556
|
+
/** Readable store, `true` while a credential's first identity resolve is in flight. */
|
|
549
557
|
isLoading: Readable<boolean>;
|
|
550
558
|
}
|
|
551
559
|
/**
|
|
552
560
|
* Derived auth-gate stores built on {@link auth}. Svelte has no JSX-style
|
|
553
561
|
* `Authenticated` slot component the way React/Vue/Solid do (this package is
|
|
554
562
|
* plain `.ts` over stores — no `.svelte` component compiler required), so this
|
|
555
|
-
* exposes the same three-state logic as two boolean stores instead
|
|
556
|
-
*
|
|
557
|
-
*
|
|
563
|
+
* exposes the same three-state logic as two boolean stores instead, mapped from
|
|
564
|
+
* the shared `AuthStatus` contract in `@lunora/client/auth`: a credential whose
|
|
565
|
+
* first identity resolve is in flight is `isLoading`; a credential nothing has
|
|
566
|
+
* contradicted — including one whose identity endpoint is unreachable — is
|
|
567
|
+
* `isAuthenticated`; no session is neither (the signed-out state a template
|
|
558
568
|
* checks for with a plain `{:else}`).
|
|
559
569
|
*
|
|
560
570
|
* ```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, LunoraClient, SubscriptionErrorCallback, User, ConnectionStatus, Preloaded, 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
|
+
import { AuthStatus } from '@lunora/client/auth';
|
|
4
5
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
6
7
|
/**
|
|
@@ -519,6 +520,13 @@ declare const getLunoraClient: () => LunoraClient;
|
|
|
519
520
|
interface AuthStore {
|
|
520
521
|
/** Set the auth token on the underlying `LunoraClient`. */
|
|
521
522
|
setToken: (token: string | null) => void;
|
|
523
|
+
/**
|
|
524
|
+
* Readable store of the resolved auth state. Branch on this, not on
|
|
525
|
+
* `$user === null` — see the contract in `@lunora/client/auth`; `user` is
|
|
526
|
+
* `null` both when signed out and when a held credential's identity could
|
|
527
|
+
* not be resolved.
|
|
528
|
+
*/
|
|
529
|
+
status: Readable<AuthStatus>;
|
|
522
530
|
/** Readable store of the auth token (`null` when signed out). */
|
|
523
531
|
token: Readable<string | null>;
|
|
524
532
|
/** Readable store of the resolved user (`null` when signed out or still loading). */
|
|
@@ -543,18 +551,20 @@ interface AuthStore {
|
|
|
543
551
|
declare const auth: (explicitClient?: ReturnType<typeof getLunoraClient>) => AuthStore;
|
|
544
552
|
/** Derived auth-gate stores for template gating (`{#if $isAuthenticated}`), built on {@link auth}. */
|
|
545
553
|
interface AuthGateStore {
|
|
546
|
-
/** Readable store, `true` once a
|
|
554
|
+
/** Readable store, `true` once a credential is held and nothing has contradicted it. */
|
|
547
555
|
isAuthenticated: Readable<boolean>;
|
|
548
|
-
/** Readable store, `true` while a
|
|
556
|
+
/** Readable store, `true` while a credential's first identity resolve is in flight. */
|
|
549
557
|
isLoading: Readable<boolean>;
|
|
550
558
|
}
|
|
551
559
|
/**
|
|
552
560
|
* Derived auth-gate stores built on {@link auth}. Svelte has no JSX-style
|
|
553
561
|
* `Authenticated` slot component the way React/Vue/Solid do (this package is
|
|
554
562
|
* plain `.ts` over stores — no `.svelte` component compiler required), so this
|
|
555
|
-
* exposes the same three-state logic as two boolean stores instead
|
|
556
|
-
*
|
|
557
|
-
*
|
|
563
|
+
* exposes the same three-state logic as two boolean stores instead, mapped from
|
|
564
|
+
* the shared `AuthStatus` contract in `@lunora/client/auth`: a credential whose
|
|
565
|
+
* first identity resolve is in flight is `isLoading`; a credential nothing has
|
|
566
|
+
* contradicted — including one whose identity endpoint is unreachable — is
|
|
567
|
+
* `isAuthenticated`; no session is neither (the signed-out state a template
|
|
558
568
|
* checks for with a plain `{:else}`).
|
|
559
569
|
*
|
|
560
570
|
* ```ts
|
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-
|
|
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-BfiH58gs.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-DhC7lunJ.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-BiEJ5Jt2.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-DGTn4Zbx.mjs";import{presence as k}from"./packem_shared/presence-Ybhe8so-.mjs";import{query as z}from"./packem_shared/query-DONZ7jtA.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-b5R8BAAh.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 +1 @@
|
|
|
1
|
-
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-
|
|
1
|
+
import{derived as c}from"svelte/store";import{isClient as p}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";import{subscription as d}from"./subscription-b5R8BAAh.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-WMVWf1Ks.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-Cxl8guzh.mjs";import{subscription as h}from"./subscription-
|
|
1
|
+
import{derived as y}from"svelte/store";import{isClient as m}from"./agent-WMVWf1Ks.mjs";import{getLunoraClient as I}from"./getLunoraClient-DU7BmZy1.mjs";import{stream as N}from"./stream-Cxl8guzh.mjs";import{subscription as h}from"./subscription-b5R8BAAh.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{getIdentityStore as h,isLoadingStatus as d,isAuthenticatedStatus as m}from"@lunora/client/auth";import{readable as o,derived as a}from"svelte/store";import{i as u}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as f}from"./getLunoraClient-DU7BmZy1.mjs";const k=s=>{const r=s??f(),t=h(r),i=o(r.getAuthToken(),e=>(e(r.getAuthToken()),u()?r.onAuthTokenChange(g=>{e(g)}):()=>{})),n=o(t.getUser(),e=>(e(t.getUser()),u()?t.subscribe(()=>{e(t.getUser())}):()=>{})),c=o(t.getStatus(),e=>(e(t.getStatus()),u()?t.subscribe(()=>{e(t.getStatus())}):()=>{}));return{setToken:e=>{r.setAuthToken(e)},status:c,token:i,user:n}},l=s=>{const{status:r}=k(s),t=a(r,n=>d(n));return{isAuthenticated:a(r,n=>m(n)),isLoading:t}};export{k as auth,l as authGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{initialPages as q,derivePaginationStatus as z,applyLoadMore as H,rebalance as J}from"@lunora/client/pagination";import{derived as L,writable as Q,readable as U,get as K}from"svelte/store";import{i as V}from"./is-browser-BEdfLJHK.mjs";import{i as X,s as Y,a as Z}from"./subscribe-reactive-args-BAIhVhJk.mjs";import{getLunoraClient as F}from"./getLunoraClient-DU7BmZy1.mjs";import{i as T}from"./is-function-reference-abFdrAae.mjs";const S=(o,s)=>({...s,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}}),C=(o,s)=>`${o}::${Z(s)}`,W=(o,s,k,_)=>{const{initialNumItems:i,onError:I,shardKey:N}=_,c=Q(q(i)),b=Q(),g=Q([]),n=new Map,l=new Map,R=new Set;let t=X(k)?"skip":k;const u=()=>{if(t==="skip"){g.set([]);return}const r=t,P=K(c).map(m=>{const e=C(s.__lunoraRef,S(m,r));return n.get(e)});g.set(P)},A=(r,P)=>{if(t==="skip")return;const m=t,e=d=>C(s.__lunoraRef,S(d,m));for(const d of P){const a=e(d);if(n.has(a))continue;const v=r.find(f=>f.lower===d.lower);if(v){const f=n.get(e(v));f&&n.set(a,f)}}},x=()=>{if(t==="skip"){for(const e of l.values())e();l.clear(),g.set([]);return}const r=t,P=K(c),m=new Set;for(const e of P)m.add(C(s.__lunoraRef,S(e,r)));for(const[e,d]of l)m.has(e)||(d(),l.delete(e),R.delete(e),n.delete(e));for(const e of P){const d=S(e,r),a=C(s.__lunoraRef,d);if(l.has(a))continue;R.add(a);const v=o.subscribe(s,d,f=>{if(n.set(a,f),R.delete(a),b.set(void 0),u(),R.size===0){const w=K(c),M=J(w,K(g));M&&(A(w,M),c.set(M),B(),u())}},{onError:f=>{R.delete(a),b.set(f);const w=K(c),M=w.at(-1);w.length>1&&M&&!n.has(a)&&C(s.__lunoraRef,S(M,r))===a&&(c.set(w.slice(0,-1)),B(),u()),I?.(f)},shardKey:N});l.set(a,v)}};let h=!1,E=!1;const B=()=>{if(h){E=!0;return}h=!0;try{do E=!1,x();while(E)}finally{h=!1}},p=()=>{for(const r of l.values())r();l.clear(),n.clear(),R.clear()},y=U([],r=>{if(!V())return()=>{};const P=g.subscribe(r),m=Y(k,e=>(t=e,B(),u(),()=>{p(),c.set(q(i)),b.set(void 0)}));return()=>{m(),P(),g.set([])}}),j=L(y,r=>z(t==="skip",r).status),D=L(y,()=>t==="skip"),G=r=>{if(t==="skip")return;const P=K(g),{nextCursor:m,status:e}=z(!1,P);if(e!=="CanLoadMore")return;const d=K(c),a=H(d,m,r);if(!a)return;const v=d.at(-1),f=a.at(-2);if(v&&f){const w=C(s.__lunoraRef,S(v,t)),M=C(s.__lunoraRef,S(f,t));if(w!==M){const $=n.get(w);$&&(n.set(M,$),n.delete(w))}}b.set(void 0),c.set(a),B(),u()};return{error:{subscribe:b.subscribe},loadMore:G,pageResults:y,skipped:D,status:j}};function re(o,s,k,_){const i=!T(o),I=i?o:F(),N=i?s:o,c=i?k:s,b=i?_:k,{error:g,loadMore:n,pageResults:l,skipped:R,status:t}=W(I,N,c,b),u=L(l,x=>x.flatMap(h=>h?.page??[])),A=L([t,R],([x,h])=>!h&&(x==="LoadingFirstPage"||x==="LoadingMore"));return{error:g,isLoading:A,loadMore:n,results:u,status:t}}function ae(o,s,k,_){const i=!T(o),I=i?o:F(),N=i?s:o,c=i?k:s,b=i?_:k,{initialNumItems:g}=b,{error:n,loadMore:l,pageResults:R,skipped:t,status:u}=W(I,N,c,b),A=L(R,p=>p.flatMap(y=>y?[y.page]:[])),x=L([u,t],([p,y])=>!y&&p==="LoadingFirstPage"),h=L(u,p=>p==="CanLoadMore"),E=L([u,t],([p,y])=>!y&&p==="LoadingMore");return{error:n,fetchNextPage:p=>{l(p??g)},hasNextPage:h,isFetchingNextPage:E,isLoading:x,pages:A,status:u}}export{ae as infiniteQuery,re as paginatedQuery};
|
|
@@ -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-DU7BmZy1.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-DU7BmZy1.mjs";import{i as y}from"./is-function-reference-abFdrAae.mjs";import{s as R}from"./subscribe-reactive-args-BAIhVhJk.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
|
+
const l=/["\\\u0000-\u001F\uD800-\uDFFF]/,d=r=>l.test(r)?JSON.stringify(r):`"${r}"`,p=r=>{if(r===void 0)return"null";if(typeof r=="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 r=="number"){if(Number.isNaN(r))return"nan";if(r===1/0)return"inf";if(r===-1/0)return"-inf";if(Object.is(r,-0))return"-0"}if(typeof r=="string")return d(r);if(r===null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r)){let e="[";for(let i=0;i<r.length;i++)i>0&&(e+=","),e+=p(r[i]);return e+"]"}const n=Object.getPrototypeOf(r);if(n!==null&&n!==Object.prototype){const e=r.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${e} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const f=r,s=Object.keys(f).sort();let c="{",t=!0;for(const e of s){const i=f[e];i!==void 0&&(t?t=!1:c+=",",c+=d(e),c+=":",c+=p(i))}return c+"}"},b=r=>{let n="";for(let s=0;s<r.length;s+=32768)n+=String.fromCharCode(...r.subarray(s,s+32768));return btoa(n)},o="$lunora.wire$";const g="__proto__",m=r=>{if(r===null||typeof r!="object")return!1;const n=Object.getPrototypeOf(r);return n===null||n===Object.prototype},a=(r,n=0)=>{if(n>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(r===void 0)return[o,"undefined"];if(r===null)return null;const f=typeof r;if(f==="bigint")return[o,"bigint",r.toString()];if(f==="number"){const t=r;return Number.isNaN(t)?[o,"nan"]:t===1/0?[o,"inf"]:t===-1/0?[o,"-inf"]:t}if(f!=="object")return r;if(r instanceof Date)return[o,"date",a(r.getTime(),n+1)];if(r instanceof Error){const t=r,e={};for(const y of Object.keys(t)){if(t[y]===void 0)continue;const u=a(t[y],n+1);y===g?Object.defineProperty(e,y,{configurable:!0,enumerable:!0,value:u,writable:!0}):e[y]=u}const i=[o,"error",String(t.name),String(t.message),e];return t.cause!==void 0&&i.push(a(t.cause,n+1)),i}if(r instanceof URL)return[o,"url",r.href];if(r instanceof Map)return[o,"map",[...r.entries()].map(([t,e])=>[a(t,n+1),a(e,n+1)])];if(r instanceof Set)return[o,"set",[...r].map(t=>a(t,n+1))];if(r instanceof ArrayBuffer)return[o,"bytes",b(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const t=r,e=t.constructor.name,i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return e==="Uint8Array"?[o,"bytes",b(i)]:[o,"bytes",b(i),e]}if(Array.isArray(r)){const t=r.map(e=>a(e,n+1));return t.length>0&&t[0]===o?[o,"arr",t]:t}if(!m(r)){const t=r.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 s=r,c={};for(const t of Object.keys(s)){const e=s[t];if(e===void 0)continue;const i=a(e,n+1);t===g?Object.defineProperty(c,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):c[t]=i}return c},w=r=>p(a(r)),A=r=>typeof r?.subscribe=="function",O=(r,n)=>{if(!A(r))return n(r);let f=()=>{},s=!1,c,t;const e=r.subscribe(i=>{if(s){c=[i];return}s=!0;try{let y=[i];for(;y;){const u=w(y[0]);u!==t&&(t=u,f(),f=n(y[0])),y=c,c=void 0}}finally{s=!1}});return()=>{e(),f()}};export{w as a,A as i,O as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createQuerySubscription as l}from"@lunora/client/query";import{LunoraError as w}from"@lunora/errors";import{writable as R,readable as h}from"svelte/store";import{i as x}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as y}from"./getLunoraClient-DU7BmZy1.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as E}from"./subscribe-reactive-args-
|
|
1
|
+
import{createQuerySubscription as l}from"@lunora/client/query";import{LunoraError as w}from"@lunora/errors";import{writable as R,readable as h}from"svelte/store";import{i as x}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as y}from"./getLunoraClient-DU7BmZy1.mjs";import{i as C}from"./is-function-reference-abFdrAae.mjs";import{s as E}from"./subscribe-reactive-args-BAIhVhJk.mjs";function q(t,n,i,c){const e=!C(t),m=e?t:y(),d=e?n:t,f=e?i:n,p=(e?c:i)??{},{shardKey:u,onError:v}=p,r=R();return{data:h(void 0,s=>{if(!x())return()=>{};const b=E(f,g=>(s(void 0),r.set(void 0),l(m,d,g,{onData:o=>{s(o),r.set(void 0)},onError:o=>{const a=o.code===void 0?new Error(o.message):new w(o.code,o.message);r.set(a),v?.(a)},onReset:()=>{s(void 0)}},{shardKey:u})));return()=>{b(),r.set(void 0)}}),error:{subscribe:r.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.
|
|
3
|
+
"version": "1.0.0-alpha.137",
|
|
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.102",
|
|
58
58
|
"@lunora/errors": "1.0.0-alpha.36",
|
|
59
59
|
"@lunora/ratelimit": "1.0.0-alpha.57",
|
|
60
60
|
"@visulima/storage-client": "1.0.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getIdentityStore as g}from"@lunora/client/auth";import{readable as i,derived as c}from"svelte/store";import{i as a}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as h}from"./getLunoraClient-DU7BmZy1.mjs";const k=o=>{const e=o??h(),n=g(e),s=i(e.getAuthToken(),t=>(t(e.getAuthToken()),a()?e.onAuthTokenChange(l=>{t(l)}):()=>{})),u=i(n.getUser(),t=>(t(n.getUser()),a()?n.subscribe(()=>{t(n.getUser())}):()=>{}));return{setToken:t=>{e.setAuthToken(t)},token:s,user:u}},T=o=>{const{token:e,user:n}=k(o),s=c([e,n],([r,t])=>r!==null&&t===null);return{isAuthenticated:c([e,n],([r,t])=>r!==null&&t!==null),isLoading:s}};export{k as auth,T as authGate};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{initialPages as J,derivePaginationStatus as W,applyLoadMore as v,rebalance as ee}from"@lunora/client/pagination";import{derived as _,writable as T,readable as te,get as x}from"svelte/store";import{i as re}from"./is-browser-BEdfLJHK.mjs";import{getLunoraClient as G}from"./getLunoraClient-DU7BmZy1.mjs";import{i as H}from"./is-function-reference-abFdrAae.mjs";import{i as ne,s as se}from"./subscribe-reactive-args-DYKqoWhw.mjs";const oe=/["\\\u0000-\u001F\uD800-\uDFFF]/,q=e=>oe.test(e)?JSON.stringify(e):`"${e}"`,F=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(typeof e=="string")return q(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let s="[";for(let n=0;n<e.length;n++)n>0&&(s+=","),s+=F(e[n]);return s+"]"}const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const s=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${s} 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).sort();let o="{",t=!0;for(const s of u){const n=a[s];n!==void 0&&(t?t=!1:o+=",",o+=q(s),o+=":",o+=F(n))}return o+"}"},D=e=>{let r="";for(let u=0;u<e.length;u+=32768)r+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(r)},p="$lunora.wire$",Q=64,z="__proto__",ie=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},M=(e,r=0)=>{if(r>Q)throw new RangeError(`wire-codec: value nesting exceeds the ${Q}-level limit`);if(e===void 0)return[p,"undefined"];if(e===null)return null;const a=typeof e;if(a==="bigint")return[p,"bigint",e.toString()];if(a==="number"){const t=e;return Number.isNaN(t)?[p,"nan"]:t===1/0?[p,"inf"]:t===-1/0?[p,"-inf"]:t}if(a!=="object")return e;if(e instanceof Date)return[p,"date",M(e.getTime(),r+1)];if(e instanceof Error){const t=e,s={};for(const f of Object.keys(t)){if(t[f]===void 0)continue;const g=M(t[f],r+1);f===z?Object.defineProperty(s,f,{configurable:!0,enumerable:!0,value:g,writable:!0}):s[f]=g}const n=[p,"error",String(t.name),String(t.message),s];return t.cause!==void 0&&n.push(M(t.cause,r+1)),n}if(e instanceof URL)return[p,"url",e.href];if(e instanceof Map)return[p,"map",[...e.entries()].map(([t,s])=>[M(t,r+1),M(s,r+1)])];if(e instanceof Set)return[p,"set",[...e].map(t=>M(t,r+1))];if(e instanceof ArrayBuffer)return[p,"bytes",D(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,s=t.constructor.name,n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return s==="Uint8Array"?[p,"bytes",D(n)]:[p,"bytes",D(n),s]}if(Array.isArray(e)){const t=e.map(s=>M(s,r+1));return t.length>0&&t[0]===p?[p,"arr",t]:t}if(!ie(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 s=u[t];if(s===void 0)continue;const n=M(s,r+1);t===z?Object.defineProperty(o,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):o[t]=n}return o},ce=e=>F(M(e)),O=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),C=(e,r)=>`${e}::${ce(r)}`,V=(e,r,a,u)=>{const{initialNumItems:o,onError:t,shardKey:s}=u,n=T(J(o)),f=T(),g=T([]),l=new Map,b=new Map,P=new Set;let c=ne(a)?"skip":a;const m=()=>{if(c==="skip"){g.set([]);return}const d=c,h=x(n).map(A=>{const i=C(r.__lunoraRef,O(A,d));return l.get(i)});g.set(h)},I=(d,h)=>{if(c==="skip")return;const A=c,i=w=>C(r.__lunoraRef,O(w,A));for(const w of h){const y=i(w);if(l.has(y))continue;const K=d.find(k=>k.lower===w.lower);if(K){const k=l.get(i(K));k&&l.set(y,k)}}},L=()=>{if(c==="skip"){for(const i of b.values())i();b.clear(),g.set([]);return}const d=c,h=x(n),A=new Set;for(const i of h)A.add(C(r.__lunoraRef,O(i,d)));for(const[i,w]of b)A.has(i)||(w(),b.delete(i),P.delete(i),l.delete(i));for(const i of h){const w=O(i,d),y=C(r.__lunoraRef,w);if(b.has(y))continue;P.add(y);const K=e.subscribe(r,w,k=>{if(l.set(y,k),P.delete(y),f.set(void 0),m(),P.size===0){const N=x(n),j=ee(N,x(g));j&&(I(N,j),n.set(j),$(),m())}},{onError:k=>{P.delete(y),f.set(k);const N=x(n),j=N.at(-1);N.length>1&&j&&!l.has(y)&&C(r.__lunoraRef,O(j,d))===y&&(n.set(N.slice(0,-1)),$(),m()),t?.(k)},shardKey:s});b.set(y,K)}};let E=!1,B=!1;const $=()=>{if(E){B=!0;return}E=!0;try{do B=!1,L();while(B)}finally{E=!1}},R=()=>{for(const d of b.values())d();b.clear(),l.clear(),P.clear()},S=te([],d=>{if(!re())return()=>{};const h=g.subscribe(d),A=se(a,i=>(c=i,$(),m(),()=>{R(),n.set(J(o)),f.set(void 0)}));return()=>{A(),h(),g.set([])}}),X=_(S,d=>W(c==="skip",d).status),Y=_(S,()=>c==="skip"),Z=d=>{if(c==="skip")return;const h=x(g),{nextCursor:A,status:i}=W(!1,h);if(i!=="CanLoadMore")return;const w=x(n),y=v(w,A,d);if(!y)return;const K=w.at(-1),k=y.at(-2);if(K&&k){const N=C(r.__lunoraRef,O(K,c)),j=C(r.__lunoraRef,O(k,c));if(N!==j){const U=l.get(N);U&&(l.set(j,U),l.delete(N))}}f.set(void 0),n.set(y),$(),m()};return{error:{subscribe:f.subscribe},loadMore:Z,pageResults:S,skipped:Y,status:X}};function pe(e,r,a,u){const o=!H(e),t=o?e:G(),s=o?r:e,n=o?a:r,f=o?u:a,{error:g,loadMore:l,pageResults:b,skipped:P,status:c}=V(t,s,n,f),m=_(b,L=>L.flatMap(E=>E?.page??[])),I=_([c,P],([L,E])=>!E&&(L==="LoadingFirstPage"||L==="LoadingMore"));return{error:g,isLoading:I,loadMore:l,results:m,status:c}}function ge(e,r,a,u){const o=!H(e),t=o?e:G(),s=o?r:e,n=o?a:r,f=o?u:a,{initialNumItems:g}=f,{error:l,loadMore:b,pageResults:P,skipped:c,status:m}=V(t,s,n,f),I=_(P,R=>R.flatMap(S=>S?[S.page]:[])),L=_([m,c],([R,S])=>!S&&R==="LoadingFirstPage"),E=_(m,R=>R==="CanLoadMore"),B=_([m,c],([R,S])=>!S&&R==="LoadingMore");return{error:l,fetchNextPage:R=>{b(R??g)},hasNextPage:E,isFetchingNextPage:B,isLoading:L,pages:I,status:m}}export{ge as infiniteQuery,pe as paginatedQuery};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|