@lunora/client 1.0.0-alpha.243 → 1.0.0-alpha.244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{RETIRE_AFTER_DURABLE_SEQ_ADVANCE as o,maxSeq as t,reconcileOptimistic as a}from"./packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs";import{createAsyncStoragePersistence as i}from"./packem_shared/createAsyncStoragePersistence-6FCvqc6C.mjs";import{createAsyncStorageQueryCache as n}from"./packem_shared/createAsyncStorageQueryCache-COqH5_SV.mjs";import{default as s}from"./packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs";import{createCallRunner as x}from"./packem_shared/createCallRunner-Bwcrfh76.mjs";import{createClientQuery as l}from"./packem_shared/createClientQuery-B8Nfj-7o.mjs";import{TabCoordinator as d}from"./packem_shared/TabCoordinator-DBuR7Dwv.mjs";import{a as R,i as C}from"./packem_shared/delta-merge-Ls3DED4g.mjs";import{CONFLICT_ERROR_CODE as A,TransportError as b,getErrorCode as h,getRetryAfterMs as D,isAuthReplayFailure as L,isConflictError as Q,isForbiddenError as T,isRateLimitedError as _,isUnauthorizedError as F}from"./packem_shared/CONFLICT_ERROR_CODE-B7qNZMMk.mjs";import{httpStream as M}from"./packem_shared/httpStream-B9iENFKq.mjs";import{c as O}from"./packem_shared/live-stream-Dil9byXF.mjs";import{liveTopicSubscription as U,subscribeLiveTopic as v}from"./packem_shared/liveTopicSubscription-gOmRbuhH.mjs";import{c as k}from"./packem_shared/local-store-fqWV2n_Z.mjs";import{LunoraClient as N}from"./packem_shared/LunoraClient-CUXLD5xx.mjs";import{createMutatorRunner as K}from"./packem_shared/createMutatorRunner-CuMRJpUx.mjs";import{O as X}from"./packem_shared/offline-queue-Dt_um8sR.mjs";import{createInMemoryPersistence as w,createIndexedDbPersistence as G}from"./packem_shared/createInMemoryPersistence-BfgXApi_.mjs";import{preloadQuery as J,preloadedQueryResult as W}from"./packem_shared/preloadQuery-uFy24PCR.mjs";import{createInMemoryQueryCache as Z,createIndexedDbQueryCache as $,queryCacheKey as ee}from"./packem_shared/createInMemoryQueryCache-B5wX-gTy.mjs";import{createReconnect as oe}from"./packem_shared/createReconnect-CjTmjJDH.mjs";import{default as ae}from"./packem_shared/createSnapshotPrecondition-CLkxVeN1.mjs";import{DEFAULT_MAX_BUFFER as ie,createStream as pe}from"./packem_shared/DEFAULT_MAX_BUFFER-Bd-_iyiV.mjs";import{SubscriptionRegistry as me}from"./packem_shared/SubscriptionRegistry-DKIXE7M7.mjs";export{A as CONFLICT_ERROR_CODE,ie as DEFAULT_MAX_BUFFER,N as LunoraClient,X as OfflineQueue,o as RETIRE_AFTER_DURABLE_SEQ_ADVANCE,me as SubscriptionRegistry,d as TabCoordinator,b as TransportError,R as applyDelta,O as connectLiveStream,i as createAsyncStoragePersistence,n as createAsyncStorageQueryCache,x as createCallRunner,l as createClientQuery,s as createInMemoryBookmarkStorage,w as createInMemoryPersistence,Z as createInMemoryQueryCache,G as createIndexedDbPersistence,$ as createIndexedDbQueryCache,k as createLocalStore,K as createMutatorRunner,oe as createReconnect,ae as createSnapshotPrecondition,pe as createStream,h as getErrorCode,D as getRetryAfterMs,M as httpStream,L as isAuthReplayFailure,Q as isConflictError,T as isForbiddenError,C as isMutationDelta,_ as isRateLimitedError,F as isUnauthorizedError,U as liveTopicSubscription,t as maxSeq,J as preloadQuery,W as preloadedQueryResult,ee as queryCacheKey,a as reconcileOptimistic,v as subscribeLiveTopic};
1
+ import{RETIRE_AFTER_DURABLE_SEQ_ADVANCE as o,maxSeq as t,reconcileOptimistic as a}from"./packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs";import{createAsyncStoragePersistence as i}from"./packem_shared/createAsyncStoragePersistence-6FCvqc6C.mjs";import{createAsyncStorageQueryCache as n}from"./packem_shared/createAsyncStorageQueryCache-COqH5_SV.mjs";import{default as s}from"./packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs";import{createCallRunner as x}from"./packem_shared/createCallRunner-Bwcrfh76.mjs";import{createClientQuery as l}from"./packem_shared/createClientQuery-B8Nfj-7o.mjs";import{TabCoordinator as d}from"./packem_shared/TabCoordinator-DBuR7Dwv.mjs";import{a as R,i as C}from"./packem_shared/delta-merge-Ls3DED4g.mjs";import{CONFLICT_ERROR_CODE as A,TransportError as b,getErrorCode as h,getRetryAfterMs as D,isAuthReplayFailure as L,isConflictError as Q,isForbiddenError as T,isRateLimitedError as _,isUnauthorizedError as F}from"./packem_shared/CONFLICT_ERROR_CODE-B7qNZMMk.mjs";import{httpStream as M}from"./packem_shared/httpStream-B9iENFKq.mjs";import{c as O}from"./packem_shared/live-stream-DBKgZlnb.mjs";import{liveTopicSubscription as U,subscribeLiveTopic as v}from"./packem_shared/liveTopicSubscription-DQtKMFKw.mjs";import{c as k}from"./packem_shared/local-store-fqWV2n_Z.mjs";import{LunoraClient as N}from"./packem_shared/LunoraClient-CUXLD5xx.mjs";import{createMutatorRunner as K}from"./packem_shared/createMutatorRunner-CuMRJpUx.mjs";import{O as X}from"./packem_shared/offline-queue-Dt_um8sR.mjs";import{createInMemoryPersistence as w,createIndexedDbPersistence as G}from"./packem_shared/createInMemoryPersistence-BfgXApi_.mjs";import{preloadQuery as J,preloadedQueryResult as W}from"./packem_shared/preloadQuery-uFy24PCR.mjs";import{createInMemoryQueryCache as Z,createIndexedDbQueryCache as $,queryCacheKey as ee}from"./packem_shared/createInMemoryQueryCache-B5wX-gTy.mjs";import{createReconnect as oe}from"./packem_shared/createReconnect-CjTmjJDH.mjs";import{default as ae}from"./packem_shared/createSnapshotPrecondition-CLkxVeN1.mjs";import{DEFAULT_MAX_BUFFER as ie,createStream as pe}from"./packem_shared/DEFAULT_MAX_BUFFER-Bd-_iyiV.mjs";import{SubscriptionRegistry as me}from"./packem_shared/SubscriptionRegistry-DKIXE7M7.mjs";export{A as CONFLICT_ERROR_CODE,ie as DEFAULT_MAX_BUFFER,N as LunoraClient,X as OfflineQueue,o as RETIRE_AFTER_DURABLE_SEQ_ADVANCE,me as SubscriptionRegistry,d as TabCoordinator,b as TransportError,R as applyDelta,O as connectLiveStream,i as createAsyncStoragePersistence,n as createAsyncStorageQueryCache,x as createCallRunner,l as createClientQuery,s as createInMemoryBookmarkStorage,w as createInMemoryPersistence,Z as createInMemoryQueryCache,G as createIndexedDbPersistence,$ as createIndexedDbQueryCache,k as createLocalStore,K as createMutatorRunner,oe as createReconnect,ae as createSnapshotPrecondition,pe as createStream,h as getErrorCode,D as getRetryAfterMs,M as httpStream,L as isAuthReplayFailure,Q as isConflictError,T as isForbiddenError,C as isMutationDelta,_ as isRateLimitedError,F as isUnauthorizedError,U as liveTopicSubscription,t as maxSeq,J as preloadQuery,W as preloadedQueryResult,ee as queryCacheKey,a as reconcileOptimistic,v as subscribeLiveTopic};
@@ -1 +1 @@
1
- import{c as i}from"./live-stream-Dil9byXF.mjs";import"./client-tuning-C10B2KCO.mjs";import"./createReconnect-CjTmjJDH.mjs";import"./stream-idle-C7CsIT_m.mjs";export{i as connectLiveStream};
1
+ import{c as i}from"./live-stream-DBKgZlnb.mjs";import"./client-tuning-C10B2KCO.mjs";import"./createReconnect-CjTmjJDH.mjs";import"./stream-idle-C7CsIT_m.mjs";export{i as connectLiveStream};
@@ -0,0 +1,10 @@
1
+ import{decodeWire as J}from"@lunora/wire";import{S as K,R as F}from"./client-tuning-C10B2KCO.mjs";import{createReconnect as Y}from"./createReconnect-CjTmjJDH.mjs";import{r as z}from"./stream-idle-C7CsIT_m.mjs";const Q="x-lunora-live-connection",X="live",ae=i=>`/live/${i}/connect`,D=i=>i===void 0?void 0:(...a)=>{i(...a)},Z=/^ /u,ee=1e4,te=i=>{const a=i.indexOf("?"),m=a===-1?i:i.slice(0,a);if(!m.endsWith("/connect"))throw new Error(`connectLiveStream: expected a connect URL ending in "/connect", got "${i}"`);return`${m.slice(0,-8)}/control${a===-1?"":i.slice(a)}`},ne=i=>{let a="message";const m=[];for(const b of i.split(`
2
+ `))b.startsWith("event:")?a=b.slice(6).trim():b.startsWith("data:")&&m.push(b.slice(5).replace(Z,""));return m.length===0?void 0:{data:m.join(`
3
+ `),event:a}},de=(i,a={})=>{const m=a.fetch??fetch,b=te(i),U=a.maxDelayMs??3e4,k=a.idleTimeoutMs??75e3,L=Y({initialDelayMs:a.retryDelay??1e3,maxDelayMs:U}),R=a.withCredentials===!0?"include":"same-origin",M=new URL(i,"https://lunora.invalid").searchParams.get("shard")??void 0,f=new Map,g=new Set;let h,w,_,x=!1,I=0;const B=()=>{let e;do I+=1,e=`live-${String(I)}`;while(f.has(e));return e},A=()=>x;let E,S;const N=new Promise((e,t)=>{E=e,S=t});N.catch(()=>{});const P={...a.headers},T=new Map,C=new Set,W=async e=>{const t=new AbortController,n=setTimeout(()=>{t.abort()},ee);C.add(t);try{const r=await m(b,{body:JSON.stringify(M===void 0?e:{...e,shardKey:M}),credentials:R,headers:{"content-type":"application/json",...P},method:"POST",signal:t.signal});return await r.text(),r.status}catch{return}finally{clearTimeout(n),C.delete(t)}},O=(e,t)=>{const r=(T.get(e)??Promise.resolve()).then(()=>A()?void 0:W(t)),c=r.then(()=>{},()=>{});return T.set(e,c),c.then(()=>{T.get(e)===c&&T.delete(e)}).catch(()=>{}),r},j=(e,t)=>{for(const n of f.values())if(n.topic===e)for(const r of n.handlers)try{r(t)}catch{}for(const n of g)try{n({payload:t,topic:e})}catch{}},V=e=>{const t=ne(e);if(t?.event===X)try{const n=JSON.parse(t.data);j(n.topic,J(n.data))}catch{}},$=(e,t,n)=>{if(f.get(e)===t){f.delete(e);for(const r of t.errors)try{r({status:n,subscriptionId:e,topic:t.topic})}catch{}}},H=async()=>{const e=h,t=w,n=[...f],r=n.map(()=>{}),c=n.entries(),d=async()=>{for(const[o,[s,v]]of c){if(h!==e)return;if(f.get(s)===v){const l=await O(s,{action:"subscribe",connectionId:e,subscriptionId:s,topic:v.topic});r[o]={entry:v,id:s,status:l}}}};if(await Promise.all(Array.from({length:Math.min(F,n.length)},d)),h!==e)return!1;for(const o of r){if(o===void 0)continue;const{entry:s,id:v,status:l}=o;if(l===void 0||l>=500||l===404||l===401)return t?.abort(),!1;l>=400&&$(v,s,l)}return!0},q=async e=>{h=e.headers.get(Q)??void 0,_=setTimeout(()=>{L.reset()},K);const n=(async()=>{let s;try{s=await H()}catch{w?.abort();return}s&&(E?.(),E=void 0,S=void 0)})(),r=e.body?.getReader();if(r===void 0){h=void 0,n.catch(()=>{});return}const c=new TextDecoder;let d="",o=!1;for(;;){let s;try{s=await z(r,k)}catch(G){throw r.cancel().catch(()=>{}),w?.abort(),G}const{done:v,value:l}=s;if(v)break;const p=c.decode(l,{stream:!0}),y=o?`\r${p}`:p;o=y.endsWith("\r"),d+=(o?y.slice(0,-1):y).replaceAll(`\r
4
+ `,`
5
+ `).replaceAll("\r",`
6
+ `);let u=d.indexOf(`
7
+
8
+ `);for(;u!==-1;)V(d.slice(0,u)),d=d.slice(u+2),u=d.indexOf(`
9
+
10
+ `)}h=void 0,n.catch(()=>{})};return(async()=>{for(;!A();){w=new AbortController;try{const t=await m(i,{credentials:R,headers:{accept:"text/event-stream",...P},signal:w.signal});if(!t.ok)throw new Error(`live stream connect failed: HTTP ${String(t.status)}`);await q(t)}catch{}if(clearTimeout(_),h=void 0,A())return;const e=L.next();await new Promise(t=>{setTimeout(t,e)})}})().catch(()=>{}),{close:()=>{x=!0,w?.abort();for(const e of C)e.abort();C.clear(),f.clear(),g.clear(),S?.(new Error("connectLiveStream: closed before the first connection")),E=void 0,S=void 0},get connectionId(){return h},onEvent:e=>(g.add(e),()=>g.delete(e)),ready:N,subscribe:({id:e,onError:t,onEvent:n,topic:r})=>{if(x)throw new Error("connectLiveStream: subscribe on a closed stream");const c=e??B(),d=f.get(c);if(d!==void 0&&d.topic!==r)throw new Error(`connectLiveStream: subscription id "${c}" already follows "${d.topic}"; unsubscribe it first`);const o=d??{errors:new Set,handlers:new Set,refs:0,topic:r},s=D(n),v=D(t);if(o.refs+=1,s!==void 0&&o.handlers.add(s),v!==void 0&&o.errors.add(v),d===void 0&&(f.set(c,o),h!==void 0)){const p=h,y=w;O(c,{action:"subscribe",connectionId:p,subscriptionId:c,topic:r}).then(u=>{if(u===void 0||u===401||u===404||u>=500){p===h&&f.get(c)===o&&y?.abort();return}u>=400&&$(c,o,u)}).catch(()=>{})}let l=!1;return()=>{l||(l=!0,s!==void 0&&o.handlers.delete(s),v!==void 0&&o.errors.delete(v),o.refs-=1,!(o.refs>0||f.get(c)!==o)&&(f.delete(c),O(c,{action:"unsubscribe",connectionId:h,subscriptionId:c,topic:r}).catch(()=>{})))}}}};export{de as c,ae as l};
@@ -1 +1 @@
1
- import{c as u,l as d}from"./live-stream-Dil9byXF.mjs";import{j as y,w as f}from"./client-urls-BHLUjjcG.mjs";const o=new Map,v=e=>JSON.stringify([e.url,e.sessionKey,e.withCredentials===!0,e.retryDelay,e.maxDelayMs,Object.entries(e.headers??{}).toSorted(([t],[r])=>t.localeCompare(r))]),T=e=>{const t=v(e);let r=o.get(t);if(r===void 0){const{headers:i,maxDelayMs:l,retryDelay:n,withCredentials:m}=e;r={closeTimer:void 0,refs:0,stream:u(e.url,{headers:i,maxDelayMs:l,retryDelay:n,withCredentials:m})},o.set(t,r)}clearTimeout(r.closeTimer),r.closeTimer=void 0,r.refs+=1;const s=r,a=s.stream.subscribe({id:e.topic,onError:e.onError,onEvent:e.onEvent,topic:e.topic});let c=!1;return()=>{c||(c=!0,a(),s.refs-=1,s.refs===0&&(s.closeTimer=setTimeout(()=>{o.delete(t),s.stream.close()},0)))}},w=(e,t,r={})=>{const{onEvent:s,shardKey:a,...c}=r,{__lunoraLive:i,topic:l}=t;return{...c,onEvent:s,topic:l,url:y(e.url,f(d(i),{shard:a}))}};export{w as liveTopicSubscription,T as subscribeLiveTopic};
1
+ import{c as u,l as d}from"./live-stream-DBKgZlnb.mjs";import{j as y,w as f}from"./client-urls-BHLUjjcG.mjs";const o=new Map,v=e=>JSON.stringify([e.url,e.sessionKey,e.withCredentials===!0,e.retryDelay,e.maxDelayMs,Object.entries(e.headers??{}).toSorted(([t],[r])=>t.localeCompare(r))]),T=e=>{const t=v(e);let r=o.get(t);if(r===void 0){const{headers:i,maxDelayMs:l,retryDelay:n,withCredentials:m}=e;r={closeTimer:void 0,refs:0,stream:u(e.url,{headers:i,maxDelayMs:l,retryDelay:n,withCredentials:m})},o.set(t,r)}clearTimeout(r.closeTimer),r.closeTimer=void 0,r.refs+=1;const s=r,a=s.stream.subscribe({id:e.topic,onError:e.onError,onEvent:e.onEvent,topic:e.topic});let c=!1;return()=>{c||(c=!0,a(),s.refs-=1,s.refs===0&&(s.closeTimer=setTimeout(()=>{o.delete(t),s.stream.close()},0)))}},w=(e,t,r={})=>{const{onEvent:s,shardKey:a,...c}=r,{__lunoraLive:i,topic:l}=t;return{...c,onEvent:s,topic:l,url:y(e.url,f(d(i),{shard:a}))}};export{w as liveTopicSubscription,T as subscribeLiveTopic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/client",
3
- "version": "1.0.0-alpha.243",
3
+ "version": "1.0.0-alpha.244",
4
4
  "description": "Lunora browser SDK: WebSocket transport, optimistic updates, and an offline mutation queue",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -1,10 +0,0 @@
1
- import{decodeWire as K}from"@lunora/wire";import{S as q}from"./client-tuning-C10B2KCO.mjs";import{createReconnect as F}from"./createReconnect-CjTmjJDH.mjs";import{r as z}from"./stream-idle-C7CsIT_m.mjs";const Q="x-lunora-live-connection",X="live",ie=c=>`/live/${c}/connect`,D=c=>c===void 0?void 0:(...s)=>{c(...s)},Y=/^ /u,Z=1e4,ee=c=>{const s=c.indexOf("?"),f=s===-1?c:c.slice(0,s);if(!f.endsWith("/connect"))throw new Error(`connectLiveStream: expected a connect URL ending in "/connect", got "${c}"`);return`${f.slice(0,-8)}/control${s===-1?"":c.slice(s)}`},te=c=>{let s="message";const f=[];for(const m of c.split(`
2
- `))m.startsWith("event:")?s=m.slice(6).trim():m.startsWith("data:")&&f.push(m.slice(5).replace(Y,""));return f.length===0?void 0:{data:f.join(`
3
- `),event:s}},ae=(c,s={})=>{const f=s.fetch??fetch,m=ee(c),k=s.maxDelayMs??3e4,U=s.idleTimeoutMs??75e3,O=F({initialDelayMs:s.retryDelay??1e3,maxDelayMs:k}),M=s.withCredentials===!0?"include":"same-origin",_=new URL(c,"https://lunora.invalid").searchParams.get("shard")??void 0,l=new Map,y=new Set;let h,v,I,C=!1,N=0;const W=()=>{let e;do N+=1,e=`live-${String(N)}`;while(l.has(e));return e},L=()=>C;let g,E;const P=new Promise((e,t)=>{g=e,E=t});P.catch(()=>{});const R={...s.headers},S=new Map,T=new Set,j=async e=>{const t=new AbortController,r=setTimeout(()=>{t.abort()},Z);T.add(t);try{const n=await f(m,{body:JSON.stringify(_===void 0?e:{...e,shardKey:_}),credentials:M,headers:{"content-type":"application/json",...R},method:"POST",signal:t.signal});return await n.text(),n.status}catch{return}finally{clearTimeout(r),T.delete(t)}},A=(e,t)=>{const n=(S.get(e)??Promise.resolve()).then(()=>L()?void 0:j(t)),o=n.then(()=>{},()=>{});return S.set(e,o),o.then(()=>{S.get(e)===o&&S.delete(e)}).catch(()=>{}),n},V=(e,t)=>{for(const r of l.values())if(r.topic===e)for(const n of r.handlers)try{n(t)}catch{}for(const r of y)try{r({payload:t,topic:e})}catch{}},B=e=>{const t=te(e);if(t?.event===X)try{const r=JSON.parse(t.data);V(r.topic,K(r.data))}catch{}},$=(e,t,r)=>{if(l.get(e)===t){l.delete(e);for(const n of t.errors)try{n({status:r,subscriptionId:e,topic:t.topic})}catch{}}},H=async()=>{const e=await Promise.all([...l].map(async([t,r])=>{const n=await A(t,{action:"subscribe",connectionId:h,subscriptionId:t,topic:r.topic});return{entry:r,id:t,status:n}}));for(const{entry:t,id:r,status:n}of e){if(n===void 0||n>=500||n===404||n===401){v?.abort();return}n>=400&&$(r,t,n)}},G=async e=>{h=e.headers.get(Q)??void 0,I=setTimeout(()=>{O.reset()},q);const r=(async()=>{try{await H()}catch{v?.abort();return}g?.(),g=void 0,E=void 0})(),n=e.body?.getReader();if(n===void 0){await r;return}const o=new TextDecoder;let a="",i=!1;for(;;){let u;try{u=await z(n,U)}catch(J){throw n.cancel().catch(()=>{}),v?.abort(),J}const{done:w,value:x}=u;if(w)break;const b=o.decode(x,{stream:!0}),p=i?`\r${b}`:b;i=p.endsWith("\r"),a+=(i?p.slice(0,-1):p).replaceAll(`\r
4
- `,`
5
- `).replaceAll("\r",`
6
- `);let d=a.indexOf(`
7
-
8
- `);for(;d!==-1;)B(a.slice(0,d)),a=a.slice(d+2),d=a.indexOf(`
9
-
10
- `)}await r};return(async()=>{for(;!L();){v=new AbortController;try{const t=await f(c,{credentials:M,headers:{accept:"text/event-stream",...R},signal:v.signal});if(!t.ok)throw new Error(`live stream connect failed: HTTP ${String(t.status)}`);await G(t)}catch{}if(clearTimeout(I),h=void 0,L())return;const e=O.next();await new Promise(t=>{setTimeout(t,e)})}})().catch(()=>{}),{close:()=>{C=!0,v?.abort();for(const e of T)e.abort();T.clear(),l.clear(),y.clear(),E?.(new Error("connectLiveStream: closed before the first connection")),g=void 0,E=void 0},get connectionId(){return h},onEvent:e=>(y.add(e),()=>y.delete(e)),ready:P,subscribe:({id:e,onError:t,onEvent:r,topic:n})=>{if(C)throw new Error("connectLiveStream: subscribe on a closed stream");const o=e??W(),a=l.get(o);if(a!==void 0&&a.topic!==n)throw new Error(`connectLiveStream: subscription id "${o}" already follows "${a.topic}"; unsubscribe it first`);const i=a??{errors:new Set,handlers:new Set,refs:0,topic:n},u=D(r),w=D(t);if(i.refs+=1,u!==void 0&&i.handlers.add(u),w!==void 0&&i.errors.add(w),a===void 0&&(l.set(o,i),h!==void 0)){const b=h,p=v;A(o,{action:"subscribe",connectionId:b,subscriptionId:o,topic:n}).then(d=>{if(d===void 0||d===401||d===404||d>=500){b===h&&l.get(o)===i&&p?.abort();return}d>=400&&$(o,i,d)}).catch(()=>{})}let x=!1;return()=>{x||(x=!0,u!==void 0&&i.handlers.delete(u),w!==void 0&&i.errors.delete(w),i.refs-=1,!(i.refs>0||l.get(o)!==i)&&(l.delete(o),A(o,{action:"unsubscribe",connectionId:h,subscriptionId:o,topic:n}).catch(()=>{})))}}}};export{ae as c,ie as l};