@lunora/angular 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +2 -0
- package/dist/index.d.mts +1305 -112
- package/dist/index.d.ts +1305 -112
- package/dist/index.mjs +1 -5
- package/dist/packem_shared/LUNORA_CLIENT-B0pGE0Tv.mjs +1 -0
- package/dist/packem_shared/agent-C-GavfBl.mjs +1 -0
- package/dist/packem_shared/agentChat-Bay8gA8i.mjs +1 -0
- package/dist/packem_shared/agentState-BAfa0QuC.mjs +1 -0
- package/dist/packem_shared/agentToolEvents-CBTZ_DsO.mjs +1 -0
- package/dist/packem_shared/auth-BTEtMnGG.mjs +1 -0
- package/dist/packem_shared/connectionStatus-C53UhkPi.mjs +1 -0
- package/dist/packem_shared/flag-BYFWoQTg.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-BKHgpXzQ.mjs +1 -0
- package/dist/packem_shared/infiniteQuery-C-T8hD7-.mjs +1 -0
- package/dist/packem_shared/liveQuery-DEIqmTPj.mjs +1 -0
- package/dist/packem_shared/mutate-DR8Uo8Hs.mjs +1 -0
- package/dist/packem_shared/mutator-Cw6jpG06.mjs +1 -0
- package/dist/packem_shared/platform-BGZypnc9.mjs +1 -0
- package/dist/packem_shared/presence-BMrTlOCF.mjs +1 -0
- package/dist/packem_shared/rateLimit-CQazDrPJ.mjs +1 -0
- package/dist/packem_shared/stream-CcvHiJf2.mjs +1 -0
- package/dist/packem_shared/subscription-DJeoGEDR.mjs +1 -0
- package/dist/packem_shared/voiceAgent-CwlzrEjH.mjs +1 -0
- package/dist/upload.d.mts +57 -0
- package/dist/upload.d.ts +57 -0
- package/dist/upload.mjs +1 -0
- package/package.json +9 -3
- package/dist/packem_shared/LUNORA_CLIENT-DHUfNu9x.mjs +0 -23
- package/dist/packem_shared/connectionStatus-BlLodleK.mjs +0 -15
- package/dist/packem_shared/liveQuery-D5VQBOgf.mjs +0 -28
- package/dist/packem_shared/mutate-D3rEHwbb.mjs +0 -8
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { connectionStatus } from './packem_shared/connectionStatus-BlLodleK.mjs';
|
|
3
|
-
export { liveQuery } from './packem_shared/liveQuery-D5VQBOgf.mjs';
|
|
4
|
-
export { mutate } from './packem_shared/mutate-D3rEHwbb.mjs';
|
|
5
|
-
export { SKIP } from '@lunora/client/query';
|
|
1
|
+
import{agent as e}from"./packem_shared/agent-C-GavfBl.mjs";import{agentChat as m}from"./packem_shared/agentChat-Bay8gA8i.mjs";import{agentState as a}from"./packem_shared/agentState-BAfa0QuC.mjs";import{agentToolEvents as x}from"./packem_shared/agentToolEvents-CBTZ_DsO.mjs";import{auth as i,authGate as u}from"./packem_shared/auth-BTEtMnGG.mjs";import{LUNORA_CLIENT as s,injectLunoraClient as c,provideLunora as l}from"./packem_shared/LUNORA_CLIENT-B0pGE0Tv.mjs";import{connectionStatus as L}from"./packem_shared/connectionStatus-C53UhkPi.mjs";import{flag as v,flags as y}from"./packem_shared/flag-BYFWoQTg.mjs";import{hydratePreloaded as Q}from"./packem_shared/hydratePreloaded-BKHgpXzQ.mjs";import{liveQuery as A}from"./packem_shared/liveQuery-DEIqmTPj.mjs";import{mutate as I}from"./packem_shared/mutate-DR8Uo8Hs.mjs";import{mutator as P}from"./packem_shared/mutator-Cw6jpG06.mjs";import{infiniteQuery as b,paginatedQuery as j}from"./packem_shared/infiniteQuery-C-T8hD7-.mjs";import{presence as K}from"./packem_shared/presence-BMrTlOCF.mjs";import{rateLimit as R}from"./packem_shared/rateLimit-CQazDrPJ.mjs";import{stream as _}from"./packem_shared/stream-CcvHiJf2.mjs";import{subscription as q}from"./packem_shared/subscription-DJeoGEDR.mjs";import{voiceAgent as z}from"./packem_shared/voiceAgent-CwlzrEjH.mjs";import{SKIP as D}from"@lunora/client/query";export{s as LUNORA_CLIENT,D as SKIP,e as agent,m as agentChat,a as agentState,x as agentToolEvents,i as auth,u as authGate,L as connectionStatus,v as flag,y as flags,Q as hydratePreloaded,b as infiniteQuery,c as injectLunoraClient,A as liveQuery,I as mutate,P as mutator,j as paginatedQuery,K as presence,l as provideLunora,R as rateLimit,_ as stream,q as subscription,z as voiceAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InjectionToken as i,makeEnvironmentProviders as t,inject as l}from"@angular/core";import{LunoraClient as r}from"@lunora/client";const n=()=>globalThis.location?.origin??"",e=new i("lunora.client",{factory:()=>new r({url:n()}),providedIn:"root"}),s=(o={})=>t([{provide:e,useFactory:()=>o instanceof r?o:new r({...o,url:o.url??n()})}]),a=()=>l(e),m=o=>o??a();export{e as LUNORA_CLIENT,a as injectLunoraClient,s as provideLunora,m as resolveLunoraClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as g,DestroyRef as h,computed as o,signal as v}from"@angular/core";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{subscription as K}from"./subscription-DJeoGEDR.mjs";const b=e=>{const{api:c,cancel:i,run:d,runArgs:u,threadKey:a}=e,n=R(e.client),l=e.destroyRef??g(h),{data:y}=K(c.agents.agentThread,{key:a},{client:n,destroyRef:l}),r=o(()=>y()),f=o(()=>r()?.status),s=v(!1),m=async(t,p)=>{s.set(!0);try{await n.mutation(d,{input:t,threadKey:a,...u,...p})}finally{s.set(!1)}};return{cancel:async()=>{const t=r()?.instanceId;i===void 0||t===void 0||await n.mutation(i,{instanceId:t,threadKey:a})},pending:s.asReadonly(),run:m,status:f,thread:r}};export{b as agent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as D,DestroyRef as E,signal as L,computed as s}from"@angular/core";import{reconcileOptimistic as v,maxSeq as I}from"@lunora/client";import{resolveLunoraClient as M}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{stream as _}from"./stream-CcvHiJf2.mjs";import{subscription as w}from"./subscription-DJeoGEDR.mjs";const O={__lunoraRef:""},J=l=>{const{api:i,cancel:u,limit:g,send:R,sendArgs:k,stream:f,threadKey:a}=l,o=M(l.client),m=l.destroyRef??D(E),C=g===void 0?{key:a}:{key:a,limit:g},{data:K}=w(i.agents.agentMessages,C,{client:o,destroyRef:m}),{data:j}=w(i.agents.agentThread,{key:a},{client:o,destroyRef:m}),x=f===void 0?"skip":{key:a},{chunks:A}=_(f??O,x,{client:o,destroyRef:m}),r=L([]);let y=0;const c=s(()=>j()),S=s(()=>c()?.status),d=s(()=>K()??[]),b=s(()=>{const e=d(),t=v(r(),e);if(t.length===0)return e;const n=I(e);return[...e,...t.map((p,h)=>({content:p.content,optimistic:!0,role:"user",seq:n+1+h}))]}),q=s(()=>{const e=d().filter(t=>t.role==="assistant").length;return A().filter(t=>t.kind!=="progress"&&t.threadKey===a&&t.turn>=e).map(t=>t.text).join("")});return{approve:async(e,t)=>{const n=c()?.instanceId;if(n===void 0)throw new Error("agentChat: cannot approve — no in-flight run (thread has no instanceId)");await o.mutation(i.agents.agentResolveApproval,{decision:"approve",instanceId:n,threadKey:a,toolCallId:e,...t===void 0?{}:{note:t}})},cancel:async()=>{const e=c()?.instanceId;u===void 0||e===void 0||await o.mutation(u,{instanceId:e,threadKey:a})},messages:b,reject:async(e,t)=>{const n=c()?.instanceId;if(n===void 0)throw new Error("agentChat: cannot reject — no in-flight run (thread has no instanceId)");await o.mutation(i.agents.agentResolveApproval,{decision:"reject",instanceId:n,threadKey:a,toolCallId:e,...t===void 0?{}:{note:t}})},send:async(e,t)=>{const n=y;y+=1;const p=I(d());r.set([...v(r(),d()),{content:e,id:n,maxDurableSeqAtSend:p}]);try{await o.mutation(R,{input:e,threadKey:a,...k,...t})}catch(h){throw r.set(r().filter(T=>T.id!==n)),h}},status:S,streamingText:q}};export{J as agentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as a}from"@angular/core";import{subscription as n}from"./subscription-DJeoGEDR.mjs";const c=t=>{const{data:r,error:e}=n(t.api.agents.agentState,{key:t.threadKey},{client:t.client,destroyRef:t.destroyRef}),o=a(()=>r());return{error:e,state:o}};export{c as agentState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as c,DestroyRef as f,computed as y}from"@angular/core";import{resolveLunoraClient as C}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{stream as v}from"./stream-CcvHiJf2.mjs";import{subscription as g}from"./subscription-DJeoGEDR.mjs";const I={__lunoraRef:""},N=[],k=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}}]},j=t=>{const{api:l,limit:s,stream:e,threadKey:a}=t,r=C(t.client),i=t.destroyRef??c(f),d=s===void 0?{key:a}:{key:a,limit:s},{data:p}=g(l.agents.agentMessages,d,{client:r,destroyRef:i}),m=e===void 0?"skip":{key:a},{chunks:u}=v(e??I,m,{client:r,destroyRef:i});return{events:y(()=>{const n=(p()??N).flatMap(o=>k(o)??[]);for(const o of u())o.kind==="progress"&&o.threadKey===a&&n.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return n})}};export{j as agentToolEvents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as g,DestroyRef as h,signal as u,computed as i}from"@angular/core";import{getIdentityStore as d}from"@lunora/client/auth";import{resolveLunoraClient as k}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const m=(o={})=>{const e=k(o.client),n=o.destroyRef??g(h),t=d(e),r=u(e.getAuthToken()),s=u(t.getUser()),l=e.onAuthTokenChange(()=>{r.set(e.getAuthToken())}),a=t.subscribe(()=>{s.set(t.getUser())});return n.onDestroy(()=>{l(),a()}),{setToken:c=>{e.setAuthToken(c)},token:r.asReadonly(),user:s.asReadonly()}},A=(o={})=>{const{token:e,user:n}=m(o),t=i(()=>e()!==null&&n()===null);return{isAuthenticated:i(()=>e()!==null&&n()!==null),isLoading:t}};export{m as auth,A as authGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as c,DestroyRef as i,signal as a}from"@angular/core";import{resolveLunoraClient as l}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const m=(o={})=>{const n=l(o.client),e=o.destroyRef??c(i),t=a(n.connectionStatus()),s=n.onConnectionStatus(r=>{t.set(r)});return e.onDestroy(s),t.asReadonly()};export{m as connectionStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as f,DestroyRef as y,signal as u}from"@angular/core";import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const d="__lunora_flags__:eval",b=r=>{const t=typeof r;return t==="boolean"||t==="number"||t==="string"?t:"object"},p={__lunoraRef:d},m=(r,t,s={})=>{const l=i(s.client),e=s.destroyRef??f(y),c=b(t),o=u(t);let n;try{n=l.subscribe(p,{context:s.context,default:t,key:r,type:c},a=>{o.set(a)},{onError:()=>{o.set(t)}})}catch{}return n&&e.onDestroy(n),o.asReadonly()},x=(r,t={})=>{const s=i(t.client),l=t.destroyRef??f(y),e=u({...r}),c=[];for(const[o,n]of Object.entries(r))try{const a=s.subscribe(p,{context:t.context,default:n,key:o,type:b(n)},_=>{e.set({...e(),[o]:_})},{onError:()=>{e.set({...e(),[o]:n})}});c.push(a)}catch{}return l.onDestroy(()=>{for(const o of c)o()}),e.asReadonly()};export{m as flag,x as flags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as m,DestroyRef as R,signal as t}from"@angular/core";import{resolveLunoraClient as h}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{s as v}from"./platform-BGZypnc9.mjs";const K=(a,o={})=>{const n=h(o.client),i=o.destroyRef===void 0,d=o.destroyRef??m(R),{args:l,functionPath:f,shardKey:y,value:c}=a,s=t(c),r=t(void 0),u={__lunoraRef:f};if(v(i)){const p=n.subscribe(u,l,e=>{s.set(e),r.set(void 0)},{onError:e=>{r.set(e)},shardKey:y});d.onDestroy(p)}return{data:s.asReadonly(),error:r.asReadonly()}};export{K as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as j,inject as W,DestroyRef as _,signal as C}from"@angular/core";import{initialPages as q,derivePaginationStatus as T,applyLoadMore as z,rebalance as V}from"@lunora/client/pagination";import{resolveLunoraClient as G}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{s as H}from"./platform-BGZypnc9.mjs";const X=(e,n)=>e<n?-1:e>n?1:0,I=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(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(s=>I(s)).join(",")}]`;const n=Object.getPrototypeOf(e);if(n!==null&&n!==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 r=e,y=Object.keys(r).toSorted(X),a=[];for(const s of y){const t=r[s];t!==void 0&&a.push(`${JSON.stringify(s)}:${I(t)}`)}return`{${a.join(",")}}`},F=e=>{let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)},f="$lunora.wire$",U=64,v=(e,n=0)=>{if(n>U)throw new RangeError(`wire-codec: value nesting exceeds the ${U}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const r=typeof e;if(r==="bigint")return[f,"bigint",e.toString()];if(r==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(r!=="object")return e;if(e instanceof Date)return[f,"date",v(e.getTime(),n+1)];if(e instanceof Error){const t=e,i={};for(const c of Object.keys(t))t[c]!==void 0&&(i[c]=v(t[c],n+1));const l=[f,"error",t.name,t.message,i];return t.cause!==void 0&&l.push(v(t.cause,n+1)),l}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,i])=>[v(t,n+1),v(i,n+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>v(t,n+1))];if(e instanceof ArrayBuffer)return[f,"bytes",F(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,i=t.constructor.name,l=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return i==="Uint8Array"?[f,"bytes",F(l)]:[f,"bytes",F(l),i]}if(Array.isArray(e)){const t=e.map(i=>v(i,n+1));return t.length>0&&t[0]===f?[f,"arr",t]:t}const y=Object.getPrototypeOf(e);if(y!==null&&y!==Object.prototype){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 a=e,s={};for(const t of Object.keys(a)){const i=a[t];i!==void 0&&(s[t]=v(i,n+1))}return s},Y=e=>I(v(e)),S=(e,n)=>`${e}::${Y(n)}`,L=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),B=(e,n,r)=>{const y=G(r.client),a=r.destroyRef===void 0,s=r.destroyRef??W(_),{initialNumItems:t,shardKey:i}=r,l=e.__lunoraRef,c=n==="skip"?{}:n,d=C(q(t)),$=C([]),J=C("LoadingFirstPage"),O=new Map,h=new Map,k=new Set,M=()=>{const p=d().map(w=>{const o=S(l,L(w,c));return h.get(o)});$.set(p);const{status:b}=T(n==="skip",p);J.set(b)},D=(p,b)=>{const w=o=>S(l,L(o,c));for(const o of b){const g=w(o);if(h.has(g))continue;const m=p.find(u=>u.lower===o.lower);if(m){const u=h.get(w(m));u&&h.set(g,u)}}},Q=p=>{const b=new Set;for(const o of p)b.add(S(l,L(o,c)));for(const[o,g]of O)b.has(g.currentKey)||(g.unsub(),O.delete(o),h.delete(g.currentKey));const w=new Set([...O.values()].map(o=>o.currentKey));for(const o of p){const g=L(o,c),m=S(l,g);if(w.has(m))continue;const u={currentKey:m,unsub:void 0};k.add(m);const A=y.subscribe(e,g,K=>{if(h.set(u.currentKey,K),k.delete(u.currentKey),M(),k.size===0){const N=d(),R=V(N,$());R&&(D(N,R),d.set(R),x(R),M())}},{onError:()=>{k.delete(u.currentKey),M()},shardKey:i});u.unsub=A,O.set(m,u),w.add(m)}};let P=!1,E=!1;const x=p=>{if(P){E=!0;return}P=!0;try{let b=p;do E=!1,Q(b),b=d();while(E)}finally{P=!1}};return n!=="skip"&&H(a)&&x(d()),M(),s.onDestroy(()=>{for(const p of O.values())p.unsub();O.clear(),h.clear()}),{loadMore:p=>{if(n==="skip")return;const{nextCursor:b,status:w}=T(!1,$());if(w!=="CanLoadMore")return;const o=z(d(),b,p);if(!o)return;const g=d().at(-1),m=o.at(-2);if(g&&m){const u=S(l,L(g,c)),A=S(l,L(m,c)),K=O.get(u);if(K&&u!==A){const N=h.get(u);N&&h.set(A,N),K.unsub(),O.delete(u),h.delete(u)}}d.set(o),x(d()),M()},pageResults:$,status:J}},re=(e,n,r)=>{const y=B(e,n,r),a=j(()=>{const s=[];for(const t of y.pageResults())t&&s.push(...t.page);return s});return{isLoading:j(()=>{const s=y.status();return s==="LoadingFirstPage"||s==="LoadingMore"}),loadMore:y.loadMore,results:a,status:y.status}},se=(e,n,r)=>{const{initialNumItems:y}=r,a=B(e,n,r),s=j(()=>{const c=[];for(const d of a.pageResults())d&&c.push(d.page);return c}),t=j(()=>a.status()==="LoadingFirstPage"),i=j(()=>a.status()==="CanLoadMore"),l=j(()=>a.status()==="LoadingMore");return{fetchNextPage:c=>{a.loadMore(c??y)},hasNextPage:i,isFetchingNextPage:l,isLoading:t,pages:s,status:a.status}};export{se as infiniteQuery,re as paginatedQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as y,DestroyRef as c,signal as f}from"@angular/core";import{createQuerySubscription as m}from"@lunora/client/query";import{resolveLunoraClient as p}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{s as u}from"./platform-BGZypnc9.mjs";const D=(t,e,o={})=>{const s=p(o.client),i=o.destroyRef===void 0,n=o.destroyRef??y(c),r=f(void 0);if(u(i)){const a=m(s,t,e,{onData:d=>{r.set(d)},onError:o.onError,onReset:()=>{r.set(void 0)}},{shardKey:o.shardKey});n.onDestroy(a)}return r.asReadonly()};export{D as liveQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveLunoraClient as i}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const u=(t,o,r={})=>{const{client:e,...n}=r;return i(e).mutation(t,o,n)};export{u as mutate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{signal as o,computed as m}from"@angular/core";import{createMutatorRunner as d}from"@lunora/client";const c=s=>{const r=o(void 0),t=o(!1),n=m(()=>r()!==void 0),{mutate:a,reset:i}=d(s,{setError:e=>{r.set(e)},setPending:e=>{t.set(e)}});return{error:r.asReadonly(),isError:n,mutate:a,pending:t.asReadonly(),reset:i}};export{c as mutator};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as n,PLATFORM_ID as o,NgZone as u}from"@angular/core";const i=r=>r?n(o,{optional:!0})!=="server":!0,a=(r,t)=>{const e=r?n(u,{optional:!0}):void 0;return e?e.runOutsideAngular(t):t()};export{a as r,i as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as h,DestroyRef as R,signal as D}from"@angular/core";import{resolveLunoraClient as S}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{s as $,r as U}from"./platform-BGZypnc9.mjs";const w=(e="sess")=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return`${e}-${Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}`}}return`${e}-${Date.now().toString(36)}`},A=1e4,E=(e,t)=>{const n=S(t.client),d=t.destroyRef===void 0,y=t.destroyRef??h(R),{heartbeat:p,listPresent:f,shardKey:i}=t,r=t.intervalMs??A,a=t.sessionId??w(),u=D(void 0);if(!Number.isFinite(r)||r<=0)throw new RangeError(`presence intervalMs must be a positive number, got ${String(r)}`);let c=t.data;const s=()=>{const o={roomId:e,sessionId:a};c!==void 0&&(o.data=c),n.mutation(p,o,{shardKey:i}).catch(()=>{})},l=o=>{c=o,s()};if($(d)){const o=n.acquireConnectionContext({roomId:e,sessionId:a},{shardKey:i});s();const m=()=>{typeof document<"u"&&document.visibilityState==="visible"&&s()},v=U(d,()=>(typeof document<"u"&&document.addEventListener("visibilitychange",m),setInterval(s,r))),g={roomId:e},b=n.subscribe(f,g,I=>{u.set(I)},{shardKey:i});y.onDestroy(()=>{clearInterval(v),typeof document<"u"&&document.removeEventListener("visibilitychange",m),o(),b()})}return{present:u.asReadonly(),sessionId:a,setData:l}};export{E as presence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as w,DestroyRef as y,signal as p,computed as i}from"@angular/core";import{evaluate as v}from"@lunora/ratelimit";const A=(s,r={})=>{const m=r.destroyRef??w(y),n=r.now??Date.now,k=r.tickMs??1e3;let t;const f=()=>v(s,t,{consume:!1,count:1,now:n(),reserve:!1}).status,e=p(f()),a=()=>{e.set(f())};let o;const c=()=>{o!==void 0&&(clearInterval(o),o=void 0)},d=()=>{e().ok||o!==void 0||(o=setInterval(()=>{a(),e().ok&&c()},k))};return d(),m.onDestroy(()=>{c()}),{check:(u=1)=>v(s,t,{consume:!1,count:u,now:n(),reserve:!1}).status.ok,consume:(u=1)=>{const l=v(s,t,{consume:!0,count:u,now:n(),reserve:!1});return l.value!==void 0&&(t=l.value),a(),d(),l.status},disabled:i(()=>!e().ok),ok:i(()=>e().ok),reset:()=>{t=void 0,c(),a()},retryAfter:i(()=>e().retryAfter)}};export{A as rateLimit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as p,DestroyRef as h,signal as n}from"@angular/core";import{resolveLunoraClient as R}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const k=(m,o,t={})=>{const u=R(t.client),d=t.destroyRef??p(h),a=n([]),c=n(void 0),r=n("idle");let s=!0,i;const f=()=>{s=!1,i?.()};if(o!=="skip"){r.set("streaming");const l=u.stream(m,o,{maxBuffer:t.maxBuffer,shardKey:t.shardKey});i=()=>{l.cancel()},(async()=>{try{for await(const e of l){if(!s)return;a.update(y=>[...y,e])}s&&r.set("complete")}catch(e){if(!s)return;c.set(e instanceof Error?e:new Error(String(e))),r.set("error")}})().catch(()=>{})}return d.onDestroy(f),{cancel:f,chunks:a.asReadonly(),error:c.asReadonly(),status:r.asReadonly()}};export{k as stream};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as y,DestroyRef as m,signal as i}from"@angular/core";import{createQuerySubscription as u}from"@lunora/client/query";import{resolveLunoraClient as l}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";import{s as v}from"./platform-BGZypnc9.mjs";const E=(n,e,o={})=>{const a=l(o.client),d=o.destroyRef===void 0,c=o.destroyRef??y(m),r=i(void 0),s=i(void 0);if(e!=="skip"&&v(d)){const p=o.onError,f=u(a,n,e,{onData:t=>{r.set(t),s.set(void 0)},onError:t=>{s.set(t),r.set(void 0),p?.(t)},onReset:()=>{r.set(void 0)}},{shardKey:o.shardKey});c.onDestroy(f)}return{data:r.asReadonly(),error:s.asReadonly()}};export{E as subscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as L,DestroyRef as W,signal as v}from"@angular/core";import{resolveLunoraClient as I}from"./LUNORA_CLIENT-B0pGE0Tv.mjs";const B=e=>{if(e.length===0)return 0;let o=0;for(const n of e)o+=n*n;return Math.sqrt(o/e.length)},J=(e,o)=>{const n=o/16e3,a=n>1?Math.floor(e.length/n):e.length,d=new ArrayBuffer(a*2),i=new DataView(d);for(let l=0;l<a;l+=1){const g=e[Math.floor(l*n)]??0,h=Math.max(-1,Math.min(1,g));i.setInt16(l*2,h<0?h*32768:h*32767,!0)}return new Uint8Array(d)},K=async e=>{const o=globalThis,n=o.navigator?.mediaDevices?.getUserMedia.bind(o.navigator.mediaDevices),a=o.AudioContext??o.webkitAudioContext;if(!n||!a)throw new Error("voiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const d=await n({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,l=i.createMediaStreamSource(d),g=i.createScriptProcessor(4096,1,1);let h=!1,m=!1,p=0,f=0;return g.onaudioprocess=r=>{const u=r.inputBuffer.getChannelData(0),k=h?0:B(u);if(e.onLevel(k),h)return;if(e.onAudio(J(u,i.sampleRate)),e.isSpeaking()){f=k>=e.interruptThreshold?f+1:0,f>=e.interruptChunks&&(f=0,e.onInterrupt());return}f=0;const w=u.length/i.sampleRate*1e3;if(k>=e.silenceThreshold){m=!0,p=0;return}m&&(p+=w,p>=e.silenceDurationMs&&(m=!1,p=0,e.onSilence()))},l.connect(g),g.connect(i.destination),{setMuted:r=>{h=r},stop:()=>{g.disconnect(),l.disconnect();for(const r of d.getTracks())r.stop();i.close()}}},N=()=>{const e=globalThis,o=e.AudioContext??e.webkitAudioContext;if(!o)throw new Error("voiceAgent: audio playback requires AudioContext (no browser audio available)");const n=new o,a=new Set;let d=0,i=Promise.resolve(),l=0;const g=async(p,f)=>{if(f!==l)return;let r;try{r=await n.decodeAudioData(p.buffer)}catch{return}if(f!==l)return;const u=n.createBufferSource();u.buffer=r,u.connect(n.destination);const k=Math.max(n.currentTime,d);u.start(k),d=k+r.duration,a.add(u),u.onended=()=>{a.delete(u)}},h=p=>{const f=Uint8Array.from(p),r=l;i=i.then(()=>g(f,r))},m=()=>{l+=1;for(const p of a)try{p.stop()}catch{}a.clear(),d=n.currentTime};return{enqueue:h,interrupt:m,stop:()=>{m(),n.close()}}},D=1,P=.01,V=1200,j=.15,O=3,z=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,G=e=>{const o=e.__lunoraRef,n=o.startsWith("agents:")?o.slice(7):o;return n.endsWith("Voice")?n.slice(0,-5):n},H=(e,o,n)=>{const a=z(e),d=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:n});return`${d}/_lunora/voice/${encodeURIComponent(o)}?${i.toString()}`},Y=e=>{const{createMicrophone:o=K,createSpeaker:n=N,createSocket:a,interruptChunks:d=O,interruptThreshold:i=j,silenceDurationMs:l=V,silenceThreshold:g=P,threadKey:h,voice:m}=e,p=I(e.client),f=e.destroyRef??L(W),r=v("idle"),u=v(!1),k=v(""),w=v(""),x=v(0),S=v(!1),b=v(void 0);let c,M=!1;const T=s=>{const t=c?.socket;return t?.readyState===D?(t.send(JSON.stringify(s)),!0):!1},C=()=>{const s=c;if(c=void 0,s){s.microphone?.stop(),s.speaker?.stop();try{s.socket.close()}catch{}}M=!1,u.set(!1),r.set("idle"),x.set(0)},U=()=>{C()},$=s=>{const t=c;switch(s.type){case"assistant_delta":{t&&(t.speaking=!0),r.set("speaking"),w.update(A=>A+s.text);break}case"assistant_done":{t&&(t.speaking=!1),w.set(s.text),r.set("listening");break}case"error":{t&&(t.speaking=!1),b.set(new Error(s.message)),r.set("listening");break}case"interrupted":{t&&(t.speaking=!1,t.suppressAudio=!1),t?.speaker?.interrupt(),r.set("listening");break}case"ready":{t&&(t.audioFormat=s.audioFormat,t.suppressAudio=!1),u.set(!0),r.set("listening");break}case"user_transcript":{t&&(t.suppressAudio=!1),k.set(s.text),w.set(""),r.set("thinking");break}}},E=s=>{const t=c;!t||t.suppressAudio||(t.speaker??=n({audioFormat:t.audioFormat}),t.speaking=!0,r.set("speaking"),t.speaker.enqueue(s))},_=async()=>{if(!(c||M)){M=!0,b.set(void 0),k.set(""),w.set("");try{const s=H(p.url,G(m),h),t=(a??(y=>new globalThis.WebSocket(y)))(s);t.binaryType="arraybuffer";const A={audioFormat:"mp3",microphone:void 0,socket:t,speaker:void 0,speaking:!1,suppressAudio:!1};c=A,t.onmessage=y=>{if(typeof y.data=="string"){try{$(JSON.parse(y.data))}catch{}return}E(new Uint8Array(y.data))},t.onerror=()=>{b.set(new Error("voiceAgent: voice socket error"))},t.onclose=()=>{c===A&&C()};const R=await o({interruptChunks:d,interruptThreshold:i,isSpeaking:()=>c?.speaking??!1,onAudio:y=>{t.readyState===D&&t.send(y)},onInterrupt:()=>{T({type:"interrupt"}),c?.speaker?.interrupt(),c&&(c.speaking=!1,c.suppressAudio=!0),r.set("listening")},onLevel:y=>{x.set(y)},onSilence:()=>{T({type:"commit"}),r.set("thinking")},silenceDurationMs:l,silenceThreshold:g});c===A?(A.microphone=R,S.set(!1),r.set("listening")):R.stop()}catch(s){b.set(s instanceof Error?s:new Error(String(s))),C()}finally{M=!1}}},q=()=>{const s=!S();return c?.microphone?.setMuted(s),S.set(s),s},F=s=>{T({text:s,type:"text"})&&r.set("thinking")};return f.onDestroy(C),{audioLevel:x.asReadonly(),connected:u.asReadonly(),endCall:U,error:b.asReadonly(),interimTranscript:w.asReadonly(),isMuted:S.asReadonly(),sendText:F,startCall:_,status:r.asReadonly(),toggleMute:q,transcript:k.asReadonly()}};export{Y as voiceAgent};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Signal, DestroyRef } from '@angular/core';
|
|
2
|
+
import { UploadResult, CreateUploadOptions, UploadProtocol } from '@lunora/client/upload';
|
|
3
|
+
export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadAdapter, UploadError, type UploadRestrictions, type UploadResult, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, createUpload } from '@lunora/client/upload';
|
|
4
|
+
export { UploadControl } from '@visulima/storage-client';
|
|
5
|
+
/** The lifecycle of an {@link upload} primitive. */
|
|
6
|
+
type UploadStatus = "error" | "idle" | "paused" | "success" | "uploading";
|
|
7
|
+
/**
|
|
8
|
+
* `UploadOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
interface UploadOptions extends Omit<CreateUploadOptions, "protocol"> {
|
|
12
|
+
/** `DestroyRef` whose `onDestroy` aborts any upload still in flight. Defaults to `inject(DestroyRef)`. */
|
|
13
|
+
destroyRef?: DestroyRef;
|
|
14
|
+
/** Which resumable protocol to speak. Default `"tus"`. Multipart isn't wrapped here — call `createMultipartAdapter` directly. */
|
|
15
|
+
protocol?: Exclude<UploadProtocol, "multipart">;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `UploadApi` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
21
|
+
interface UploadApi {
|
|
22
|
+
/** Abort the in-flight upload. Safe to call at any point, including after success. */
|
|
23
|
+
abort: () => void;
|
|
24
|
+
/** The upload error, or `undefined`. */
|
|
25
|
+
error: Signal<Error | undefined>;
|
|
26
|
+
/** Whether the upload is currently paused. */
|
|
27
|
+
isPaused: Signal<boolean>;
|
|
28
|
+
/** Pause the in-flight upload (TUS / chunked-REST only support this mid-upload). A no-op unless `status() === "uploading"`. */
|
|
29
|
+
pause: () => void;
|
|
30
|
+
/** Upload progress, as the adapter reports it (0–100). */
|
|
31
|
+
progress: Signal<number>;
|
|
32
|
+
/** The resolved upload result, or `undefined` before it finishes. */
|
|
33
|
+
result: Signal<UploadResult | undefined>;
|
|
34
|
+
/** Resume a paused upload. A no-op unless `status() === "paused"`. */
|
|
35
|
+
resume: () => void;
|
|
36
|
+
/** Start (or restart) the upload for `file`. Also resolves/rejects with the same result the `result`/`error` signals settle to. */
|
|
37
|
+
start: (file: File) => Promise<UploadResult>;
|
|
38
|
+
/** The upload lifecycle. */
|
|
39
|
+
status: Signal<UploadStatus>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Drive a resumable (TUS / chunked-REST) upload as Angular signals: `progress`,
|
|
43
|
+
* `status`, `result` and `error`, plus `start` / `pause` / `resume` / `abort`
|
|
44
|
+
* actions. Defaults to TUS — the resumable path that survives pause/resume and
|
|
45
|
+
* a dropped connection.
|
|
46
|
+
*
|
|
47
|
+
* Call from an injection context (component/service field or constructor):
|
|
48
|
+
* ```ts
|
|
49
|
+
* protected readonly upload = upload({ endpoint: "/api/upload" });
|
|
50
|
+
* onFileSelected(file: File) {
|
|
51
|
+
* this.upload.start(file).catch(() => undefined); // errors also land in `error`
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
* @experimental
|
|
55
|
+
*/
|
|
56
|
+
declare const upload: (options: UploadOptions) => UploadApi;
|
|
57
|
+
export { UploadApi, UploadOptions, UploadStatus, upload };
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Signal, DestroyRef } from '@angular/core';
|
|
2
|
+
import { UploadResult, CreateUploadOptions, UploadProtocol } from '@lunora/client/upload';
|
|
3
|
+
export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadAdapter, UploadError, type UploadRestrictions, type UploadResult, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, createUpload } from '@lunora/client/upload';
|
|
4
|
+
export { UploadControl } from '@visulima/storage-client';
|
|
5
|
+
/** The lifecycle of an {@link upload} primitive. */
|
|
6
|
+
type UploadStatus = "error" | "idle" | "paused" | "success" | "uploading";
|
|
7
|
+
/**
|
|
8
|
+
* `UploadOptions` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
interface UploadOptions extends Omit<CreateUploadOptions, "protocol"> {
|
|
12
|
+
/** `DestroyRef` whose `onDestroy` aborts any upload still in flight. Defaults to `inject(DestroyRef)`. */
|
|
13
|
+
destroyRef?: DestroyRef;
|
|
14
|
+
/** Which resumable protocol to speak. Default `"tus"`. Multipart isn't wrapped here — call `createMultipartAdapter` directly. */
|
|
15
|
+
protocol?: Exclude<UploadProtocol, "multipart">;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `UploadApi` is part of the experimental `@lunora/angular` API and may change without a major version bump.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
21
|
+
interface UploadApi {
|
|
22
|
+
/** Abort the in-flight upload. Safe to call at any point, including after success. */
|
|
23
|
+
abort: () => void;
|
|
24
|
+
/** The upload error, or `undefined`. */
|
|
25
|
+
error: Signal<Error | undefined>;
|
|
26
|
+
/** Whether the upload is currently paused. */
|
|
27
|
+
isPaused: Signal<boolean>;
|
|
28
|
+
/** Pause the in-flight upload (TUS / chunked-REST only support this mid-upload). A no-op unless `status() === "uploading"`. */
|
|
29
|
+
pause: () => void;
|
|
30
|
+
/** Upload progress, as the adapter reports it (0–100). */
|
|
31
|
+
progress: Signal<number>;
|
|
32
|
+
/** The resolved upload result, or `undefined` before it finishes. */
|
|
33
|
+
result: Signal<UploadResult | undefined>;
|
|
34
|
+
/** Resume a paused upload. A no-op unless `status() === "paused"`. */
|
|
35
|
+
resume: () => void;
|
|
36
|
+
/** Start (or restart) the upload for `file`. Also resolves/rejects with the same result the `result`/`error` signals settle to. */
|
|
37
|
+
start: (file: File) => Promise<UploadResult>;
|
|
38
|
+
/** The upload lifecycle. */
|
|
39
|
+
status: Signal<UploadStatus>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Drive a resumable (TUS / chunked-REST) upload as Angular signals: `progress`,
|
|
43
|
+
* `status`, `result` and `error`, plus `start` / `pause` / `resume` / `abort`
|
|
44
|
+
* actions. Defaults to TUS — the resumable path that survives pause/resume and
|
|
45
|
+
* a dropped connection.
|
|
46
|
+
*
|
|
47
|
+
* Call from an injection context (component/service field or constructor):
|
|
48
|
+
* ```ts
|
|
49
|
+
* protected readonly upload = upload({ endpoint: "/api/upload" });
|
|
50
|
+
* onFileSelected(file: File) {
|
|
51
|
+
* this.upload.start(file).catch(() => undefined); // errors also land in `error`
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
* @experimental
|
|
55
|
+
*/
|
|
56
|
+
declare const upload: (options: UploadOptions) => UploadApi;
|
|
57
|
+
export { UploadApi, UploadOptions, UploadStatus, upload };
|
package/dist/upload.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inject as m,DestroyRef as y,signal as s}from"@angular/core";import{createUpload as E}from"@lunora/client/upload";import{RestrictionError as A,UploadError as b,createChunkedRestAdapter as C,createMultipartAdapter as D,createTusAdapter as P,createUpload as S}from"@lunora/client/upload";import{UploadControl as k}from"@visulima/storage-client";const v=l=>{const{destroyRef:i,...u}=l,c=i??m(y),r=E(u),n=s(0),t=s("idle"),d=s(void 0),o=s(void 0),a=s(!1);r.setOnStart(()=>{t.set("uploading")}),r.setOnProgress(e=>{n.set(e)}),r.setOnFinish(e=>{d.set(e),t.set("success")}),r.setOnError(e=>{o.set(e),t.set("error")});const f=e=>(o.set(void 0),d.set(void 0),n.set(0),a.set(!1),t.set("uploading"),r.upload(e)),R=()=>{t()==="uploading"&&(r.pause(),a.set(!0),t.set("paused"))},g=()=>{t()==="paused"&&r.resume().then(()=>{a.set(!1),t.set("uploading")}).catch(e=>{o.set(e instanceof Error?e:new Error(String(e))),t.set("error")})},p=()=>{r.abort()};return c.onDestroy(p),{abort:p,error:o.asReadonly(),isPaused:a.asReadonly(),pause:R,progress:n.asReadonly(),result:d.asReadonly(),resume:g,start:f,status:t.asReadonly()}};export{A as RestrictionError,k as UploadControl,b as UploadError,C as createChunkedRestAdapter,D as createMultipartAdapter,P as createTusAdapter,S as createUpload,v as upload};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/angular",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "Angular reactive adapter for Lunora — signal-based live queries and mutations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -39,16 +39,22 @@
|
|
|
39
39
|
"types": "./dist/index.d.ts",
|
|
40
40
|
"import": "./dist/index.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./upload": {
|
|
43
|
+
"types": "./dist/upload.d.ts",
|
|
44
|
+
"import": "./dist/upload.mjs"
|
|
45
|
+
},
|
|
42
46
|
"./package.json": "./package.json"
|
|
43
47
|
},
|
|
44
48
|
"publishConfig": {
|
|
45
49
|
"access": "public"
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
|
-
"@lunora/client": "1.0.0-alpha.
|
|
52
|
+
"@lunora/client": "1.0.0-alpha.36",
|
|
53
|
+
"@lunora/ratelimit": "1.0.0-alpha.15",
|
|
54
|
+
"@visulima/storage-client": "1.0.0"
|
|
49
55
|
},
|
|
50
56
|
"peerDependencies": {
|
|
51
|
-
"@angular/core": "^19.2.0 || ^20.0.0"
|
|
57
|
+
"@angular/core": "^19.2.0 || ^20.0.0 || ^21.0.0 || ^22.0.0"
|
|
52
58
|
},
|
|
53
59
|
"peerDependenciesMeta": {
|
|
54
60
|
"@angular/core": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { InjectionToken, makeEnvironmentProviders, inject } from '@angular/core';
|
|
2
|
-
import { LunoraClient } from '@lunora/client';
|
|
3
|
-
|
|
4
|
-
const sameOriginUrl = () => globalThis.location?.origin ?? "";
|
|
5
|
-
const LUNORA_CLIENT = new InjectionToken("lunora.client", {
|
|
6
|
-
factory: () => new LunoraClient({ url: sameOriginUrl() }),
|
|
7
|
-
providedIn: "root"
|
|
8
|
-
});
|
|
9
|
-
const provideLunora = (optionsOrClient = {}) => makeEnvironmentProviders([
|
|
10
|
-
{
|
|
11
|
-
provide: LUNORA_CLIENT,
|
|
12
|
-
useFactory: () => {
|
|
13
|
-
if (optionsOrClient instanceof LunoraClient) {
|
|
14
|
-
return optionsOrClient;
|
|
15
|
-
}
|
|
16
|
-
return new LunoraClient({ ...optionsOrClient, url: optionsOrClient.url ?? sameOriginUrl() });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
]);
|
|
20
|
-
const injectLunoraClient = () => inject(LUNORA_CLIENT);
|
|
21
|
-
const resolveLunoraClient = (client) => client ?? injectLunoraClient();
|
|
22
|
-
|
|
23
|
-
export { LUNORA_CLIENT, injectLunoraClient, provideLunora, resolveLunoraClient };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { inject, DestroyRef, signal } from '@angular/core';
|
|
2
|
-
import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
|
|
3
|
-
|
|
4
|
-
const connectionStatus = (options = {}) => {
|
|
5
|
-
const client = resolveLunoraClient(options.client);
|
|
6
|
-
const destroyRef = options.destroyRef ?? inject(DestroyRef);
|
|
7
|
-
const status = signal(client.connectionStatus());
|
|
8
|
-
const unsubscribe = client.onConnectionStatus((next) => {
|
|
9
|
-
status.set(next);
|
|
10
|
-
});
|
|
11
|
-
destroyRef.onDestroy(unsubscribe);
|
|
12
|
-
return status.asReadonly();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { connectionStatus };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { inject, DestroyRef, signal } from '@angular/core';
|
|
2
|
-
import { createQuerySubscription } from '@lunora/client/query';
|
|
3
|
-
import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
|
|
4
|
-
|
|
5
|
-
const liveQuery = (reference, args, options = {}) => {
|
|
6
|
-
const client = resolveLunoraClient(options.client);
|
|
7
|
-
const destroyRef = options.destroyRef ?? inject(DestroyRef);
|
|
8
|
-
const value = signal(void 0);
|
|
9
|
-
const unsubscribe = createQuerySubscription(
|
|
10
|
-
client,
|
|
11
|
-
reference,
|
|
12
|
-
args,
|
|
13
|
-
{
|
|
14
|
-
onData: (next) => {
|
|
15
|
-
value.set(next);
|
|
16
|
-
},
|
|
17
|
-
onError: options.onError,
|
|
18
|
-
onReset: () => {
|
|
19
|
-
value.set(void 0);
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{ shardKey: options.shardKey }
|
|
23
|
-
);
|
|
24
|
-
destroyRef.onDestroy(unsubscribe);
|
|
25
|
-
return value.asReadonly();
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { liveQuery };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { resolveLunoraClient } from './LUNORA_CLIENT-DHUfNu9x.mjs';
|
|
2
|
-
|
|
3
|
-
const mutate = (reference, args, options = {}) => {
|
|
4
|
-
const { client, ...callOptions } = options;
|
|
5
|
-
return resolveLunoraClient(client).mutation(reference, args, callOptions);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { mutate };
|