brass-runtime 1.9.6 → 1.11.0
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/chunk-Q2H2CAII.js +1 -0
- package/dist/chunk-ZXK3XM2Q.mjs +1 -0
- package/dist/http/index.d.mts +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -1
- package/dist/index.d.mts +12 -33
- package/dist/index.d.ts +12 -33
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{stream-FmXbwFl9.d.mts → stream-hTHRKq88.d.mts} +139 -12
- package/dist/{stream-FmXbwFl9.d.ts → stream-hTHRKq88.d.ts} +139 -12
- package/package.json +12 -4
- package/dist/chunk-5UEH74EX.mjs +0 -1
- package/dist/chunk-KMTKZ4PS.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function R(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function be(t,e){return R(t,n=>e(n),n=>E(n))}function b(t,e){return R(t,n=>f(e(n)),n=>E(n))}var Z=()=>E(void 0),E=t=>({_tag:"Succeed",value:t}),f=t=>({_tag:"Fail",error:t}),_=t=>({_tag:"Sync",thunk:t}),Fe=t=>_(()=>t()),p=t=>({_tag:"Async",register:t});function Q(t,e){return A(t,n=>E(e(n)))}function A(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function ke(t,e,n){return A(t,r=>(n.addFinalizer(o=>e(r,o)),E(r)))}function Ie(t){return p(t)}var _e=t=>e=>{let n=e;return n.toPromise||(n.toPromise=r=>t(e,r),n.unsafeRunPromise=()=>t(e,{})),n},we=(t,e)=>A(t,n=>E(e(n))),Oe=(t,e)=>A(t,n=>_(()=>e(n)));var F={_tag:"None"},w=t=>({_tag:"Some",value:t});var j=t=>E(t),C=t=>f(t),$=t=>_(e=>t(e)),k=(t,e)=>Q(t,e),K=(t,e)=>A(t,n=>e(n)),H=(t,e)=>b(t,e),Pe=(t,e)=>R(t,n=>e(n),n=>E(n));function q(t,e){return R(t,n=>n._tag==="Some"?f(n):e(),n=>E(n))}var Te=()=>C(F);var ie=(r=>(r[r.Ok=0]="Ok",r[r.Grew=1]="Grew",r[r.Dropped=2]="Dropped",r))(ie||{}),N=class{buf;head=0;tail=0;size_=0;maxCap;constructor(e=1024,n=e){let r=Math.max(2,this.nextPow2(e)),o=Math.max(r,this.nextPow2(n));this.buf=new Array(r),this.maxCap=o;}get length(){return this.size_}get capacity(){return this.buf.length}isEmpty(){return this.size_===0}push(e){return this.size_===this.buf.length?this.buf.length>=this.maxCap?2:(this.grow(),this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,1):(this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,0)}shift(){if(this.size_===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=this.head+1&this.buf.length-1,this.size_--,e}clear(){this.buf.fill(void 0),this.head=0,this.tail=0,this.size_=0;}grow(){let e=this.buf,n=Math.min(e.length*2,this.maxCap),r=new Array(n);for(let o=0;o<this.size_;o++)r[o]=e[this.head+o&e.length-1];this.buf=r,this.head=0,this.tail=this.size_;}nextPow2(e){let n=1;for(;n<e;)n<<=1;return n}};var X=2048,Y=4096,se=(()=>{if(typeof globalThis.setImmediate=="function")return t=>globalThis.setImmediate(t);if(typeof globalThis.MessageChannel=="function"){let t=new globalThis.MessageChannel,e=null;return t.port1.onmessage=()=>{let n=e;e=null,n?.();},n=>{e=n,t.port2.postMessage(0);}}return t=>setTimeout(t,0)})(),L=class{queue=new N(1024);flushing=false;scheduled=false;schedule(e,n="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:n,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>Y?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):se(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<X;){let n=this.queue.shift();if(!n)break;e++;try{n.task();}catch(r){console.error(`[Scheduler] task threw (tag=${n.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let n=e>=X||this.queue.length>Y?"macro":"micro";this.requestFlush(n);}}}},B=new L;var P=null,h={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},g={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},ce=1,ue=1024;function le(t){let e=t;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let n=e.first,r=e.andThen;e={_tag:"FlatMap",first:n.first,andThen:o=>({_tag:"FlatMap",first:n.andThen(o),andThen:r})};}return e}var T=class{id;runtime;closing=null;finishing=false;runState=g.RUNNING;interrupted=false;result=null;joiners=[];current;stack=[];fiberFinalizers=[];finalizersDrained=false;fiberContext;name;scopeId;constructor(e,n){this.id=ce++,this.runtime=e,this.current=n;}get env(){return this.runtime.env}get scheduler(){return this.runtime.scheduler}addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){this.runState===g.DONE||this.runState===g.QUEUED||(this.runState=g.QUEUED,this.scheduler.schedule(()=>{pe(this,()=>{if(this.runState===g.DONE)return;switch(this.runState=g.RUNNING,this.step()){case h.CONTINUE:this.schedule("continue");return;case h.SUSPEND:this.runState=g.SUSPENDED;return;case h.DONE:this.runState=g.DONE;return}});},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let n=this.fiberFinalizers.pop();try{n(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let n of this.joiners)n(e);this.joiners.length=0;}}onSuccess(e){let n=this.stack.pop();if(!n){this.notify({_tag:"Success",value:e});return}this.current=n._tag==="SuccessCont"?n.k(e):n.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let n=this.stack.pop();if(n._tag==="FoldCont"){this.current=n.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=ue;for(;e-- >0;){if(this.result!=null)return h.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),h.DONE;let n=le(this.current);switch(n._tag){case "Succeed":{this.onSuccess(n.value);break}case "Fail":{this.onFailure(n.error);break}case "Sync":{try{let r=n.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:n.andThen}),this.current=n.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:n.onFailure,onSuccess:n.onSuccess}),this.current=n.first;break}case "Async":{if(this.finishing)return this.result!=null?h.DONE:h.CONTINUE;let r=false,o=i=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=i._tag==="Success"?{_tag:"Succeed",value:i.value}:{_tag:"Fail",error:i.error},this.schedule("async-resume")));},a=n.register(this.env,o);return typeof a=="function"&&this.addFinalizer(()=>{r=true;try{a();}catch{}}),h.SUSPEND}}}return this.result!=null?h.DONE:h.CONTINUE}};function D(){return P}function pe(t,e){let n=P;P=t;try{return e()}finally{P=n;}}var ee={parent:null,patch:Object.create(null)};function te(t,e){let n=Ee(t);return {initChild(r,o){let a=o?.fiberContext,i=Ae(n,a?.trace??null);r.fiberContext={log:a?.log??ee,trace:i},r.parentFiberId=o?.id,r.name=n.childName(o?.name),e.emit({type:"fiber.start",fiberId:r.id,parentFiberId:o?.id,name:r.name},{fiberId:o?.id,traceId:a?.trace?.traceId,spanId:a?.trace?.spanId});}}}function Ee(t){let e={newTraceId:()=>crypto.randomUUID(),newSpanId:()=>crypto.randomUUID()},n=t?.brass,r=n?.tracer??e,o=n?.traceSeed,a=n?.childName??(i=>i?`${i}/child`:void 0);return {tracer:r,seed:o,childName:a}}function Ae(t,e){return e?{traceId:e.traceId,spanId:t.tracer.newSpanId(),parentSpanId:e.spanId,sampled:e.sampled}:t.seed?{...t.seed}:{traceId:t.tracer.newTraceId(),spanId:t.tracer.newSpanId(),sampled:true}}var de={emit(){}},O=class t{env;scheduler;hooks;forkPolicy;constructor(e){this.env=e.env,this.scheduler=e.scheduler??B,this.hooks=e.hooks??de,this.forkPolicy=te(this.env,this.hooks);}fork(e){let n=D(),r=new T(this,e);return this.forkPolicy.initChild(r,n),r.schedule("initial-step"),r}unsafeRunAsync(e,n){this.fork(e).join(n);}toPromise(e){return new Promise((n,r)=>{this.fork(e).join(a=>{let i=a;i._tag==="Success"?n(i.value):r(i.error);});})}log(e,n,r){this.emit({type:"log",level:e,message:n,fields:r});}withHooks(e){return new t({env:this.env,scheduler:this.scheduler,hooks:e})}emit(e){let n=D(),r={fiberId:n?.id,scopeId:n?.scope?.id,traceId:n?.fiberContext?.trace?.traceId,spanId:n?.fiberContext?.trace?.spanId};this.hooks.emit(e,r);}static make(e,n=B){return new t({env:e,scheduler:n})}};function Ye(t){return p((e,n)=>{let r=false,o=s=>{r||(r=true,n(s));},a=s=>o({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),i=s=>o({_tag:"Success",value:s});try{typeof t=="function"&&t.length>=1?t((s,c)=>s?a(s):i(c)):t().then(i,a);}catch(s){a(s);}})}function et(t,e,n=B){return new O({env:e,scheduler:n}).fork(t)}function tt(t,e,n){return new O({env:e}).unsafeRunAsync(t,n)}function nt(t,e){return new O({env:e}).toPromise(t)}function rt(t,e){return p((n,r)=>{t(n).then(o=>r({_tag:"Success",value:o})).catch(o=>r({_tag:"Failure",error:e(o)}));})}function ot(t){return p((e,n)=>{let r=false,o=a=>{r||(r=true,n(a));};try{t((a,i)=>{o(a?{_tag:"Failure",error:a}:{_tag:"Success",value:i});});}catch(a){o({_tag:"Failure",error:a instanceof Error?a:new Error(String(a))});}})}function at(t){return ye((n,r)=>t.length===1?t(r):t(n,r),n=>Re(n)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:n})}function ye(t,e){return p((n,r)=>{let o=new AbortController,a=false,i=s=>{a||(a=true,r(s));};try{(t.length===1?t(o.signal):t(n,o.signal)).then(c=>i({_tag:"Success",value:c})).catch(c=>i({_tag:"Failure",error:e(c)}));}catch(s){i({_tag:"Failure",error:e(s)});}return ()=>{a=true,o.abort();}})}var Re=t=>typeof t=="object"&&t!==null&&"name"in t&&t.name==="AbortError";function G(){let t=D();if(!t)throw new Error("No current runtime: est\xE1s llamando esto fuera de un fiber (fuera del runtime).");return t.runtime}var me=1;function fe(t){return p((e,n)=>{let r=t.length;if(r===0){n({_tag:"Success",value:void 0});return}for(let o of t)o.join(()=>{r-=1,r===0&&n({_tag:"Success",value:void 0});});})}function he(t){return R(t,()=>Z(),()=>Z())}var I=class t{constructor(e){this.runtime=e;this.id=me++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];get env(){return this.runtime.env}addFinalizer(e){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(e);}subScope(){if(this.closed)throw new Error("Scope closed");let e=new t(this.runtime);return this.subScopes.add(e),e}fork(e){if(this.closed)throw new Error("Scope closed");let n=this.runtime.fork(e);return this.children.add(n),n.join(()=>{this.children.delete(n);}),n}close(e={_tag:"Success",value:void 0}){this.runtime.fork(this.closeAsync(e));}closeAsync(e={_tag:"Success",value:void 0},n={}){return p((r,o)=>{if(this.closed){o({_tag:"Success",value:void 0});return}this.closed=true;let a=Array.from(this.children),i=Array.from(this.subScopes);this.children.clear(),this.subScopes.clear();for(let l of a)try{l.interrupt();}catch{}let s=Z();for(let l of i)s=A(s,()=>l.closeAsync(e,n));for(;this.finalizers.length>0;){let l=this.finalizers.pop();s=A(s,()=>he(l(e)));}n.awaitChildren&&(s=A(s,()=>fe(a))),this.runtime.fork(s).join(()=>o({_tag:"Success",value:void 0}));})}};function ut(t,e){let n=new I(t);try{return e(n)}finally{n.close();}}function lt(t,e){return p((n,r)=>{let o=new I(t);o.fork(e(o)).join(i=>{try{o.close(i);}catch(s){r({_tag:"Failure",error:s});return}r(i);});})}function dt(t,e,n){return p((r,o)=>{let a=n.subScope(),i=false,s=m=>{i||(i=true,a.close(m),o(m));},c=a.fork(t),l=a.fork(e);c.join(s),l.join(s);})}function yt(t,e,n){return p((r,o)=>{let a=n.subScope(),i=null,s=null,c=false,l=()=>{if(!i||!s||c)return;if(c=true,i._tag==="Success"&&s._tag==="Success"){a.close({_tag:"Success",value:void 0}),o({_tag:"Success",value:[i.value,s.value]});return}let u;if(i._tag==="Failure")u=i.error;else if(s._tag==="Failure")u=s.error;else throw new Error("zipPar: unreachable state (no Failure exit)");let v={_tag:"Failure",error:u};a.close(v),o(v);},m=a.fork(t),y=a.fork(e);m.join(u=>{i=u,l();}),y.join(u=>{s=u,l();});})}function Rt(t,e){return p((n,r)=>{let o=e.subScope(),a=new Array(t.length),i=0,s=false;t.forEach((c,l)=>{o.fork(c).join(y=>{if(!s){if(y._tag==="Failure"){s=true;let u={_tag:"Failure",error:y.error};o.close(u),r(u);return}if(a[l]=y.value,i++,i===t.length){s=true;let u={_tag:"Success",value:a};o.close({_tag:"Success",value:void 0}),r(u);}}});});})}function ne(t,e,n,r,o){return p((a,i)=>{let s=n.subScope(),c=false,l=s.fork(t),m=s.fork(e),y=u=>{s.fork(u).join(v=>{s.close(v),i(v);});};l.join(u=>{c||(c=true,y(r(u,m,s)));}),m.join(u=>{c||(c=true,y(o(u,l,s)));});})}var J=t=>t._tag==="None"?F:w(t.value),x=t=>({_tag:"FromPull",pull:t}),oe=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),Ot=t=>({_tag:"Scoped",acquire:A(t,e=>E(e.stream)),release:e=>A(t,n=>n.release(e))}),ge=(t,e,n=true)=>({_tag:"Merge",left:t,right:e,flip:n}),M=()=>({_tag:"Empty"}),ae=t=>({_tag:"Emit",value:t}),z=(t,e)=>({_tag:"Concat",left:t,right:e}),V=t=>({_tag:"Flatten",stream:t});function re(t,e,n,r,o){return (a,i,s)=>{if(a._tag,a._tag,a._tag==="Success"){let[m,y]=a.value;i.interrupt();let u=x(t==="L"?U(y,n):U(e,y));return E([m,u])}let c=a.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return f(c);let l=c;return l._tag==="None"?d(t==="L"?n:e):f(l)}}function U(t,e,n,r){return p((o,a)=>{let s=G(),c=new I(s),l=d(t),m=d(e),y=re("L",t,e),u=re("R",t,e),v=ne(l,m,c,y,u);c.fork(v).join(W=>{c.close(W),a(W);});})}function Zt(t,e){return x(U(t,e))}function d(t){switch(t._tag){case "Empty":return C(F);case "Emit":return k(H(t.value,e=>w(e)),e=>[e,M()]);case "FromPull":return t.pull;case "Concat":return q(k(d(t.left),([e,n])=>[e,z(n,t.right)]),()=>d(t.right));case "Flatten":return K(d(t.stream),([e,n])=>q(k(d(e),([r,o])=>[r,z(o,V(n))]),()=>d(V(n))));case "Merge":return U(t.left,t.right,t.flip);case "Scoped":return p((e,n)=>{let r=G(),o=new I(r);o.addFinalizer(a=>t.release(a)),o.fork(t.acquire).join(a=>{if(a._tag==="Failure"){o.close(a),n({_tag:"Failure",error:w(a.error)});return}let i=a.value;d(i)(e,c=>{o.close(c),n(c);});});})}}function Se(t,e){throw new Error(e??`Unexpected value: ${String(t)}`)}function S(t,e){switch(t._tag){case "Empty":return M();case "Emit":return ae(k(t.value,e));case "FromPull":return x(k(t.pull,([n,r])=>[e(n),S(r,e)]));case "Concat":return z(S(t.left,e),S(t.right,e));case "Flatten":{let n=S(t.stream,r=>S(r,e));return V(n)}case "Merge":return ge(S(t.left,e),S(t.right,e),t.flip);case "Scoped":return oe(k(t.acquire,n=>S(n,e)),t.release);default:return Se(t)}}function Ct(t,e){let n=r=>x(r>e?f(F):E([r,n(r+1)]));return n(t)}function xe(t,e){let n=R(b(d(t),r=>J(r)),r=>f(r),([r,o])=>R(b(d(e),a=>J(a)),a=>f(a),([a,i])=>E([[r,a],xe(o,i)])));return x(n)}function Nt(t,e){let n=r=>R(b(d(r),o=>J(o)),o=>o._tag==="None"?E(void 0):f(o),([o,a])=>A(b(e(o),i=>w(i)),()=>n(a)));return R(n(t),r=>r._tag==="None"?E(void 0):f(r.value),()=>E(void 0))}function Bt(t){let e=M();for(let n=t.length-1;n>=0;n--){let r=ae(j(t[n]));e=z(r,e);}return e}function Pt(t){let e=(n,r)=>R(d(n),o=>o._tag==="None"?j(r):C(o),([o,a])=>e(a,[...r,o]));return H(e(t,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}function ve(t,e){let n=p((r,o)=>{t.read().then(({done:a,value:i})=>{if(a){o({_tag:"Failure",error:F});return}o({_tag:"Success",value:[i,x(n)]});}).catch(a=>{o({_tag:"Failure",error:w(e(a))});});});return x(n)}function Tt(t,e){if(!t)return M();let n;return oe($(()=>(n=t.getReader(),ve(n,e))),()=>_(()=>{try{n?.cancel();}catch{}}))}exports.$=oe;exports.A=Te;exports.B=ie;exports.C=N;exports.D=L;exports.E=B;exports.F=T;exports.G=D;exports.H=pe;exports.I=O;exports.J=Ye;exports.K=et;exports.L=tt;exports.M=nt;exports.N=rt;exports.O=ot;exports.P=at;exports.Q=ye;exports.R=G;exports.S=I;exports.T=ut;exports.U=lt;exports.V=dt;exports.W=yt;exports.X=Rt;exports.Y=ne;exports.Z=J;exports._=x;exports.a=R;exports.aa=Ot;exports.b=be;exports.ba=ge;exports.c=b;exports.ca=M;exports.d=Z;exports.da=ae;exports.e=E;exports.ea=z;exports.f=f;exports.fa=V;exports.g=_;exports.ga=Zt;exports.h=Fe;exports.ha=d;exports.i=p;exports.ia=Se;exports.j=Q;exports.ja=S;exports.k=A;exports.ka=Ct;exports.l=ke;exports.la=xe;exports.m=Ie;exports.ma=Nt;exports.n=_e;exports.na=Bt;exports.o=we;exports.oa=Pt;exports.p=Oe;exports.pa=Tt;exports.q=F;exports.r=w;exports.s=j;exports.t=C;exports.u=$;exports.v=k;exports.w=K;exports.x=H;exports.y=Pe;exports.z=q;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function R(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function be(t,e){return R(t,n=>e(n),n=>E(n))}function b(t,e){return R(t,n=>f(e(n)),n=>E(n))}var Z=()=>E(void 0),E=t=>({_tag:"Succeed",value:t}),f=t=>({_tag:"Fail",error:t}),_=t=>({_tag:"Sync",thunk:t}),Fe=t=>_(()=>t()),p=t=>({_tag:"Async",register:t});function Q(t,e){return A(t,n=>E(e(n)))}function A(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function ke(t,e,n){return A(t,r=>(n.addFinalizer(o=>e(r,o)),E(r)))}function Ie(t){return p(t)}var _e=t=>e=>{let n=e;return n.toPromise||(n.toPromise=r=>t(e,r),n.unsafeRunPromise=()=>t(e,{})),n},we=(t,e)=>A(t,n=>E(e(n))),Oe=(t,e)=>A(t,n=>_(()=>e(n)));var F={_tag:"None"},w=t=>({_tag:"Some",value:t});var j=t=>E(t),C=t=>f(t),$=t=>_(e=>t(e)),k=(t,e)=>Q(t,e),K=(t,e)=>A(t,n=>e(n)),H=(t,e)=>b(t,e),Pe=(t,e)=>R(t,n=>e(n),n=>E(n));function q(t,e){return R(t,n=>n._tag==="Some"?f(n):e(),n=>E(n))}var Te=()=>C(F);var ie=(r=>(r[r.Ok=0]="Ok",r[r.Grew=1]="Grew",r[r.Dropped=2]="Dropped",r))(ie||{}),N=class{buf;head=0;tail=0;size_=0;maxCap;constructor(e=1024,n=e){let r=Math.max(2,this.nextPow2(e)),o=Math.max(r,this.nextPow2(n));this.buf=new Array(r),this.maxCap=o;}get length(){return this.size_}get capacity(){return this.buf.length}isEmpty(){return this.size_===0}push(e){return this.size_===this.buf.length?this.buf.length>=this.maxCap?2:(this.grow(),this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,1):(this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,0)}shift(){if(this.size_===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=this.head+1&this.buf.length-1,this.size_--,e}clear(){this.buf.fill(void 0),this.head=0,this.tail=0,this.size_=0;}grow(){let e=this.buf,n=Math.min(e.length*2,this.maxCap),r=new Array(n);for(let o=0;o<this.size_;o++)r[o]=e[this.head+o&e.length-1];this.buf=r,this.head=0,this.tail=this.size_;}nextPow2(e){let n=1;for(;n<e;)n<<=1;return n}};var X=2048,Y=4096,se=(()=>{if(typeof globalThis.setImmediate=="function")return t=>globalThis.setImmediate(t);if(typeof globalThis.MessageChannel=="function"){let t=new globalThis.MessageChannel,e=null;return t.port1.onmessage=()=>{let n=e;e=null,n?.();},n=>{e=n,t.port2.postMessage(0);}}return t=>setTimeout(t,0)})(),L=class{queue=new N(1024);flushing=false;scheduled=false;schedule(e,n="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:n,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>Y?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):se(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<X;){let n=this.queue.shift();if(!n)break;e++;try{n.task();}catch(r){console.error(`[Scheduler] task threw (tag=${n.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let n=e>=X||this.queue.length>Y?"macro":"micro";this.requestFlush(n);}}}},B=new L;var P=null,h={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},g={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},ce=1,ue=1024;function le(t){let e=t;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let n=e.first,r=e.andThen;e={_tag:"FlatMap",first:n.first,andThen:o=>({_tag:"FlatMap",first:n.andThen(o),andThen:r})};}return e}var T=class{id;runtime;closing=null;finishing=false;runState=g.RUNNING;interrupted=false;result=null;joiners=[];current;stack=[];fiberFinalizers=[];finalizersDrained=false;fiberContext;name;scopeId;constructor(e,n){this.id=ce++,this.runtime=e,this.current=n;}get env(){return this.runtime.env}get scheduler(){return this.runtime.scheduler}addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){this.runState===g.DONE||this.runState===g.QUEUED||(this.runState=g.QUEUED,this.scheduler.schedule(()=>{pe(this,()=>{if(this.runState===g.DONE)return;switch(this.runState=g.RUNNING,this.step()){case h.CONTINUE:this.schedule("continue");return;case h.SUSPEND:this.runState=g.SUSPENDED;return;case h.DONE:this.runState=g.DONE;return}});},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let n=this.fiberFinalizers.pop();try{n(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let n of this.joiners)n(e);this.joiners.length=0;}}onSuccess(e){let n=this.stack.pop();if(!n){this.notify({_tag:"Success",value:e});return}this.current=n._tag==="SuccessCont"?n.k(e):n.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let n=this.stack.pop();if(n._tag==="FoldCont"){this.current=n.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=ue;for(;e-- >0;){if(this.result!=null)return h.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),h.DONE;let n=le(this.current);switch(n._tag){case "Succeed":{this.onSuccess(n.value);break}case "Fail":{this.onFailure(n.error);break}case "Sync":{try{let r=n.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:n.andThen}),this.current=n.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:n.onFailure,onSuccess:n.onSuccess}),this.current=n.first;break}case "Async":{if(this.finishing)return this.result!=null?h.DONE:h.CONTINUE;let r=false,o=i=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=i._tag==="Success"?{_tag:"Succeed",value:i.value}:{_tag:"Fail",error:i.error},this.schedule("async-resume")));},a=n.register(this.env,o);return typeof a=="function"&&this.addFinalizer(()=>{r=true;try{a();}catch{}}),h.SUSPEND}}}return this.result!=null?h.DONE:h.CONTINUE}};function D(){return P}function pe(t,e){let n=P;P=t;try{return e()}finally{P=n;}}var ee={parent:null,patch:Object.create(null)};function te(t,e){let n=Ee(t);return {initChild(r,o){let a=o?.fiberContext,i=Ae(n,a?.trace??null);r.fiberContext={log:a?.log??ee,trace:i},r.parentFiberId=o?.id,r.name=n.childName(o?.name),e.emit({type:"fiber.start",fiberId:r.id,parentFiberId:o?.id,name:r.name},{fiberId:o?.id,traceId:a?.trace?.traceId,spanId:a?.trace?.spanId});}}}function Ee(t){let e={newTraceId:()=>crypto.randomUUID(),newSpanId:()=>crypto.randomUUID()},n=t?.brass,r=n?.tracer??e,o=n?.traceSeed,a=n?.childName??(i=>i?`${i}/child`:void 0);return {tracer:r,seed:o,childName:a}}function Ae(t,e){return e?{traceId:e.traceId,spanId:t.tracer.newSpanId(),parentSpanId:e.spanId,sampled:e.sampled}:t.seed?{...t.seed}:{traceId:t.tracer.newTraceId(),spanId:t.tracer.newSpanId(),sampled:true}}var de={emit(){}},O=class t{env;scheduler;hooks;forkPolicy;constructor(e){this.env=e.env,this.scheduler=e.scheduler??B,this.hooks=e.hooks??de,this.forkPolicy=te(this.env,this.hooks);}fork(e){let n=D(),r=new T(this,e);return this.forkPolicy.initChild(r,n),r.schedule("initial-step"),r}unsafeRunAsync(e,n){this.fork(e).join(n);}toPromise(e){return new Promise((n,r)=>{this.fork(e).join(a=>{let i=a;i._tag==="Success"?n(i.value):r(i.error);});})}log(e,n,r){this.emit({type:"log",level:e,message:n,fields:r});}withHooks(e){return new t({env:this.env,scheduler:this.scheduler,hooks:e})}emit(e){let n=D(),r={fiberId:n?.id,scopeId:n?.scope?.id,traceId:n?.fiberContext?.trace?.traceId,spanId:n?.fiberContext?.trace?.spanId};this.hooks.emit(e,r);}static make(e,n=B){return new t({env:e,scheduler:n})}};function Ye(t){return p((e,n)=>{let r=false,o=s=>{r||(r=true,n(s));},a=s=>o({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),i=s=>o({_tag:"Success",value:s});try{typeof t=="function"&&t.length>=1?t((s,c)=>s?a(s):i(c)):t().then(i,a);}catch(s){a(s);}})}function et(t,e,n=B){return new O({env:e,scheduler:n}).fork(t)}function tt(t,e,n){return new O({env:e}).unsafeRunAsync(t,n)}function nt(t,e){return new O({env:e}).toPromise(t)}function rt(t,e){return p((n,r)=>{t(n).then(o=>r({_tag:"Success",value:o})).catch(o=>r({_tag:"Failure",error:e(o)}));})}function ot(t){return p((e,n)=>{let r=false,o=a=>{r||(r=true,n(a));};try{t((a,i)=>{o(a?{_tag:"Failure",error:a}:{_tag:"Success",value:i});});}catch(a){o({_tag:"Failure",error:a instanceof Error?a:new Error(String(a))});}})}function at(t){return ye((n,r)=>t.length===1?t(r):t(n,r),n=>Re(n)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:n})}function ye(t,e){return p((n,r)=>{let o=new AbortController,a=false,i=s=>{a||(a=true,r(s));};try{(t.length===1?t(o.signal):t(n,o.signal)).then(c=>i({_tag:"Success",value:c})).catch(c=>i({_tag:"Failure",error:e(c)}));}catch(s){i({_tag:"Failure",error:e(s)});}return ()=>{a=true,o.abort();}})}var Re=t=>typeof t=="object"&&t!==null&&"name"in t&&t.name==="AbortError";function G(){let t=D();if(!t)throw new Error("No current runtime: est\xE1s llamando esto fuera de un fiber (fuera del runtime).");return t.runtime}var me=1;function fe(t){return p((e,n)=>{let r=t.length;if(r===0){n({_tag:"Success",value:void 0});return}for(let o of t)o.join(()=>{r-=1,r===0&&n({_tag:"Success",value:void 0});});})}function he(t){return R(t,()=>Z(),()=>Z())}var I=class t{constructor(e){this.runtime=e;this.id=me++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];get env(){return this.runtime.env}addFinalizer(e){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(e);}subScope(){if(this.closed)throw new Error("Scope closed");let e=new t(this.runtime);return this.subScopes.add(e),e}fork(e){if(this.closed)throw new Error("Scope closed");let n=this.runtime.fork(e);return this.children.add(n),n.join(()=>{this.children.delete(n);}),n}close(e={_tag:"Success",value:void 0}){this.runtime.fork(this.closeAsync(e));}closeAsync(e={_tag:"Success",value:void 0},n={}){return p((r,o)=>{if(this.closed){o({_tag:"Success",value:void 0});return}this.closed=true;let a=Array.from(this.children),i=Array.from(this.subScopes);this.children.clear(),this.subScopes.clear();for(let l of a)try{l.interrupt();}catch{}let s=Z();for(let l of i)s=A(s,()=>l.closeAsync(e,n));for(;this.finalizers.length>0;){let l=this.finalizers.pop();s=A(s,()=>he(l(e)));}n.awaitChildren&&(s=A(s,()=>fe(a))),this.runtime.fork(s).join(()=>o({_tag:"Success",value:void 0}));})}};function ut(t,e){let n=new I(t);try{return e(n)}finally{n.close();}}function lt(t,e){return p((n,r)=>{let o=new I(t);o.fork(e(o)).join(i=>{try{o.close(i);}catch(s){r({_tag:"Failure",error:s});return}r(i);});})}function dt(t,e,n){return p((r,o)=>{let a=n.subScope(),i=false,s=m=>{i||(i=true,a.close(m),o(m));},c=a.fork(t),l=a.fork(e);c.join(s),l.join(s);})}function yt(t,e,n){return p((r,o)=>{let a=n.subScope(),i=null,s=null,c=false,l=()=>{if(!i||!s||c)return;if(c=true,i._tag==="Success"&&s._tag==="Success"){a.close({_tag:"Success",value:void 0}),o({_tag:"Success",value:[i.value,s.value]});return}let u;if(i._tag==="Failure")u=i.error;else if(s._tag==="Failure")u=s.error;else throw new Error("zipPar: unreachable state (no Failure exit)");let v={_tag:"Failure",error:u};a.close(v),o(v);},m=a.fork(t),y=a.fork(e);m.join(u=>{i=u,l();}),y.join(u=>{s=u,l();});})}function Rt(t,e){return p((n,r)=>{let o=e.subScope(),a=new Array(t.length),i=0,s=false;t.forEach((c,l)=>{o.fork(c).join(y=>{if(!s){if(y._tag==="Failure"){s=true;let u={_tag:"Failure",error:y.error};o.close(u),r(u);return}if(a[l]=y.value,i++,i===t.length){s=true;let u={_tag:"Success",value:a};o.close({_tag:"Success",value:void 0}),r(u);}}});});})}function ne(t,e,n,r,o){return p((a,i)=>{let s=n.subScope(),c=false,l=s.fork(t),m=s.fork(e),y=u=>{s.fork(u).join(v=>{s.close(v),i(v);});};l.join(u=>{c||(c=true,y(r(u,m,s)));}),m.join(u=>{c||(c=true,y(o(u,l,s)));});})}var J=t=>t._tag==="None"?F:w(t.value),x=t=>({_tag:"FromPull",pull:t}),oe=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),Ot=t=>({_tag:"Scoped",acquire:A(t,e=>E(e.stream)),release:e=>A(t,n=>n.release(e))}),ge=(t,e,n=true)=>({_tag:"Merge",left:t,right:e,flip:n}),M=()=>({_tag:"Empty"}),ae=t=>({_tag:"Emit",value:t}),z=(t,e)=>({_tag:"Concat",left:t,right:e}),V=t=>({_tag:"Flatten",stream:t});function re(t,e,n,r,o){return (a,i,s)=>{if(a._tag,a._tag,a._tag==="Success"){let[m,y]=a.value;i.interrupt();let u=x(t==="L"?U(y,n):U(e,y));return E([m,u])}let c=a.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return f(c);let l=c;return l._tag==="None"?d(t==="L"?n:e):f(l)}}function U(t,e,n,r){return p((o,a)=>{let s=G(),c=new I(s),l=d(t),m=d(e),y=re("L",t,e),u=re("R",t,e),v=ne(l,m,c,y,u);c.fork(v).join(W=>{c.close(W),a(W);});})}function Zt(t,e){return x(U(t,e))}function d(t){switch(t._tag){case "Empty":return C(F);case "Emit":return k(H(t.value,e=>w(e)),e=>[e,M()]);case "FromPull":return t.pull;case "Concat":return q(k(d(t.left),([e,n])=>[e,z(n,t.right)]),()=>d(t.right));case "Flatten":return K(d(t.stream),([e,n])=>q(k(d(e),([r,o])=>[r,z(o,V(n))]),()=>d(V(n))));case "Merge":return U(t.left,t.right,t.flip);case "Scoped":return p((e,n)=>{let r=G(),o=new I(r);o.addFinalizer(a=>t.release(a)),o.fork(t.acquire).join(a=>{if(a._tag==="Failure"){o.close(a),n({_tag:"Failure",error:w(a.error)});return}let i=a.value;d(i)(e,c=>{o.close(c),n(c);});});})}}function Se(t,e){throw new Error(e??`Unexpected value: ${String(t)}`)}function S(t,e){switch(t._tag){case "Empty":return M();case "Emit":return ae(k(t.value,e));case "FromPull":return x(k(t.pull,([n,r])=>[e(n),S(r,e)]));case "Concat":return z(S(t.left,e),S(t.right,e));case "Flatten":{let n=S(t.stream,r=>S(r,e));return V(n)}case "Merge":return ge(S(t.left,e),S(t.right,e),t.flip);case "Scoped":return oe(k(t.acquire,n=>S(n,e)),t.release);default:return Se(t)}}function Ct(t,e){let n=r=>x(r>e?f(F):E([r,n(r+1)]));return n(t)}function xe(t,e){let n=R(b(d(t),r=>J(r)),r=>f(r),([r,o])=>R(b(d(e),a=>J(a)),a=>f(a),([a,i])=>E([[r,a],xe(o,i)])));return x(n)}function Nt(t,e){let n=r=>R(b(d(r),o=>J(o)),o=>o._tag==="None"?E(void 0):f(o),([o,a])=>A(b(e(o),i=>w(i)),()=>n(a)));return R(n(t),r=>r._tag==="None"?E(void 0):f(r.value),()=>E(void 0))}function Bt(t){let e=M();for(let n=t.length-1;n>=0;n--){let r=ae(j(t[n]));e=z(r,e);}return e}function Pt(t){let e=(n,r)=>R(d(n),o=>o._tag==="None"?j(r):C(o),([o,a])=>e(a,[...r,o]));return H(e(t,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}function ve(t,e){let n=p((r,o)=>{t.read().then(({done:a,value:i})=>{if(a){o({_tag:"Failure",error:F});return}o({_tag:"Success",value:[i,x(n)]});}).catch(a=>{o({_tag:"Failure",error:w(e(a))});});});return x(n)}function Tt(t,e){if(!t)return M();let n;return oe($(()=>(n=t.getReader(),ve(n,e))),()=>_(()=>{try{n?.cancel();}catch{}}))}export{oe as $,Te as A,ie as B,N as C,L as D,B as E,T as F,D as G,pe as H,O as I,Ye as J,et as K,tt as L,nt as M,rt as N,ot as O,at as P,ye as Q,G as R,I as S,ut as T,lt as U,dt as V,yt as W,Rt as X,ne as Y,J as Z,x as _,R as a,Ot as aa,be as b,ge as ba,b as c,M as ca,Z as d,ae as da,E as e,z as ea,f,V as fa,_ as g,Zt as ga,Fe as h,d as ha,p as i,Se as ia,Q as j,S as ja,A as k,Ct as ka,ke as l,xe as la,Ie as m,Nt as ma,_e as n,Bt as na,we as o,Pt as oa,Oe as p,Tt as pa,F as q,w as r,j as s,C as t,$ as u,k as v,K as w,H as x,Pe as y,q as z};
|
package/dist/http/index.d.mts
CHANGED
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkQ2H2CAII_js=require('../chunk-Q2H2CAII.js');var b={make(t,e){return {get:t,set:e}},over(t,e){return r=>t.set(e(t.get(r)))(r)},compose(t,e){return b.make(r=>t.get(e.get(r)),r=>n=>e.set(t.set(r)(e.get(n)))(n))}};var A={headers:b.make(t=>t.headers??{},t=>e=>({...e,headers:t}))};var I=t=>e=>b.over(A.headers,r=>({...r,...t}))(e),C=t=>e=>b.over(A.headers,r=>({...t,...r}))(e),g=(t,e)=>r=>b.over(A.headers,n=>n[t]?n:{...n,[t]:e})(r);var v=t=>typeof t=="object"&&t!==null&&"_tag"in t,J=t=>v(t)?t:typeof t=="object"&&t!==null&&t.name==="AbortError"?{_tag:"Abort"}:{_tag:"FetchError",message:String(t)},M=t=>chunkQ2H2CAII_js.Q(e=>new Promise((r,n)=>{if(e.aborted)return n({_tag:"Abort"});let u=setTimeout(r,t),p=()=>{clearTimeout(u),n({_tag:"Abort"});};e.addEventListener("abort",p,{once:true});}),J);var lt=t=>e=>T(t(e)),T=t=>Object.assign((e=>t(e)),{with:e=>T(e(t))}),O=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)},k=t=>{if(t){if(typeof Headers<"u"&&t instanceof Headers){let e={};return t.forEach((r,n)=>e[n]=r),e}if(Array.isArray(t))return Object.fromEntries(t);if(typeof t=="object")return {...t}}},D=t=>e=>{let r=Object.keys(t).length?C(t)(e):e,n=k(e.init?.headers);return n&&Object.keys(n).length&&(r=C(n)(r)),r};function N(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return u=>chunkQ2H2CAII_js.Q(async p=>{let y=n(u),i;try{i=new URL(y.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${y.url}`}}let a=performance.now(),s=await fetch(i,{...y.init??{},method:y.method,headers:A.headers.get(y),body:y.body,signal:p}),c={};s.headers.forEach((d,m)=>c[m]=d);let o=chunkQ2H2CAII_js.pa(s.body,O);return {status:s.status,statusText:s.statusText,headers:c,body:o,ms:Math.round(performance.now()-a)}},O)}function _(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return T(p=>chunkQ2H2CAII_js.Q(async y=>{let i=n(p),a;try{a=new URL(i.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${i.url}`}}let s=performance.now(),c=await fetch(a,{...i.init??{},method:i.method,headers:A.headers.get(i),body:i.body,signal:y}),o=await c.text(),d={};return c.headers.forEach((m,H)=>d[H]=m),{status:c.status,statusText:c.statusText,headers:d,bodyText:o,ms:Math.round(performance.now()-s)}},O))}var G=(t,e,r)=>Math.max(e,Math.min(r,t)),z=t=>t._tag==="FetchError",Z=t=>t===408||t===429||t===500||t===502||t===503||t===504,F=(t,e,r)=>{let n=e*Math.pow(2,t),u=G(n,0,r);return Math.floor(Math.random()*u)},$=t=>{let e=Object.keys(t).find(p=>p.toLowerCase()==="retry-after");if(!e)return;let r=t[e]?.trim();if(!r)return;let n=Number(r);if(Number.isFinite(n))return Math.max(0,Math.floor(n*1e3));let u=Date.parse(r);if(Number.isFinite(u))return Math.max(0,u-Date.now())},U=t=>e=>(r=>{let n=u=>chunkQ2H2CAII_js.a(e(r),p=>{if(p._tag==="Abort"||p._tag==="BadUrl")return chunkQ2H2CAII_js.f(p);if(!(u<t.maxRetries&&(t.retryOnError??z)(p)))return chunkQ2H2CAII_js.f(p);let i=F(u,t.baseDelayMs,t.maxDelayMs);return chunkQ2H2CAII_js.k(M(i),()=>n(u+1))},p=>{if(!(u<t.maxRetries&&(t.retryOnStatus??Z)(p.status)))return chunkQ2H2CAII_js.e(p);let a=$(p.headers)??F(u,t.baseDelayMs,t.maxDelayMs);return chunkQ2H2CAII_js.k(M(a),()=>n(u+1))});return n(0)});var K=["GET","HEAD","OPTIONS"],Q=t=>t===408||t===429||t===500||t===502||t===503||t===504,V=t=>t._tag==="FetchError";var X=(t,e,r)=>Math.max(e,Math.min(r,t)),L=(t,e,r)=>{let n=Math.max(0,e),u=Math.max(0,r),p=n*Math.pow(2,t),y=X(p,0,u);return Math.floor(Math.random()*y)},Y=(t,e)=>{let r=Object.keys(t).find(n=>n.toLowerCase()===e.toLowerCase());return r?t[r]:void 0},tt=t=>{let e=Y(t,"retry-after")?.trim();if(!e)return;let r=Number(e);if(Number.isFinite(r))return Math.max(0,Math.floor(r*1e3));let n=Date.parse(e);if(Number.isFinite(n))return Math.max(0,n-Date.now())},j=t=>e=>{let r=t.retryOnMethods??K,n=t.retryOnStatus??Q,u=t.retryOnError??V,p=i=>r.includes(i.method),y=(i,a)=>p(i)?chunkQ2H2CAII_js.a(e(i),s=>{if(s._tag==="Abort"||s._tag==="BadUrl")return chunkQ2H2CAII_js.f(s);if(!(a<t.maxRetries&&u(s)))return chunkQ2H2CAII_js.f(s);let o=L(a,t.baseDelayMs,t.maxDelayMs);return chunkQ2H2CAII_js.k(M(o),()=>y(i,a+1))},s=>{if(!(a<t.maxRetries&&n(s.status)))return chunkQ2H2CAII_js.e(s);let d=tt(s.headers)??L(a,t.baseDelayMs,t.maxDelayMs);return chunkQ2H2CAII_js.k(M(d),()=>y(i,a+1))}):e(i);return i=>y(i,0)};var et=(t,e)=>{try{return new URL(e,t??"").toString()}catch{return (t??"")+e}},B=(t={})=>{let e=_(t),r=a=>chunkQ2H2CAII_js.n((s,c)=>chunkQ2H2CAII_js.M(s,c))(a),n=a=>e(a),u=a=>{let{headers:s,...c}=a??{};return {headers:k(s),init:c}},p=a=>s=>a?I(a)(s):s;return {cfg:t,wire:e,withPromise:r,requestRaw:n,splitInit:u,applyInitHeaders:p,buildReq:(a,s,c,o)=>{let d=u(c),m={method:a,url:s,...o&&o.length>0?{body:o}:{},init:d.init};return p(d.headers)(m)},toResponse:(a,s)=>({status:a.status,statusText:a.statusText,headers:a.headers,body:s})}};function _t(t={}){let e=B(t),r=n=>{let u=o=>n(o),p=o=>e.withPromise(u(o));return {request:p,get:(o,d)=>p(e.buildReq("GET",o,d)),post:(o,d,m)=>p(e.buildReq("POST",o,m,d)),getText:(o,d)=>{let m=e.buildReq("GET",o,d);return e.withPromise(chunkQ2H2CAII_js.p(u(m),H=>e.toResponse(H,H.bodyText)))},getJson:(o,d)=>{let m=e.buildReq("GET",o,d),H=g("accept","application/json")(m);return e.withPromise(chunkQ2H2CAII_js.p(u(H),l=>e.toResponse(l,JSON.parse(l.bodyText))))},postJson:(o,d,m)=>{let H=e.buildReq("POST",o,m,JSON.stringify(d??{})),l=g("content-type","application/json")(g("accept","application/json")(H));return e.withPromise(chunkQ2H2CAII_js.p(u(l),P=>e.toResponse(P,JSON.parse(P.bodyText))))},with:o=>r(n.with(o)),withRetry:o=>r(n.with(j(o))),wire:n}};return r(e.wire)}function Ut(t={}){let e=B(t),r=(s,c,o)=>({request:s,urlFinal:et(e.cfg.baseUrl,s.url),startedAt:o,durationMs:c.ms}),n=s=>{let c=Date.now();return e.withPromise(chunkQ2H2CAII_js.p(e.requestRaw(s),o=>({wire:o,meta:r(s,o,c)})))};return {request:n,get:(s,c)=>{let o=e.buildReq("GET",s,c);return n(o)},getText:(s,c)=>{let o=e.buildReq("GET",s,c),d=Date.now();return e.withPromise(chunkQ2H2CAII_js.p(e.requestRaw(o),m=>({wire:m,response:e.toResponse(m,m.bodyText),meta:r(o,m,d)})))},getJson:(s,c)=>{let o=e.buildReq("GET",s,c),d=g("accept","application/json")(o),m=Date.now();return e.withPromise(chunkQ2H2CAII_js.p(e.requestRaw(d),H=>({wire:H,response:e.toResponse(H,JSON.parse(H.bodyText)),meta:r(d,H,m)})))},post:(s,c,o)=>{let d=e.buildReq("POST",s,o,c);return n(d)},postJson:(s,c,o)=>{let d=e.buildReq("POST",s,o,JSON.stringify(c??{})),m=g("content-type","application/json")(g("accept","application/json")(d)),H=Date.now();return e.withPromise(chunkQ2H2CAII_js.p(e.requestRaw(m),l=>({wire:l,response:e.toResponse(l,JSON.parse(l.bodyText)),meta:r(m,l,H)})))}}}function Lt(t={}){let e=N(t),r=n=>{let u=i=>chunkQ2H2CAII_js.n((a,s)=>chunkQ2H2CAII_js.M(a,s))(i),p=i=>u(n(i)),y=(i,a)=>{let s={method:"GET",url:i,init:a},c=g("accept","*/*")(s);return p(c)};return {request:p,getStream:y,get:y,with:i=>r(i(n)),withRetry:i=>r(U(i)(n)),wire:n}};return r(e)}exports.decorate=T;exports.httpClient=_t;exports.httpClientStream=Lt;exports.httpClientWithMeta=Ut;exports.makeHttp=_;exports.makeHttpStream=N;exports.normalizeHeadersInit=k;exports.withMiddleware=lt;exports.withRetryStream=U;
|
package/dist/http/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Q as Q$1,pa,a,p,n,f,k as k$1,e,M as M$1}from'../chunk-ZXK3XM2Q.mjs';var b={make(t,e){return {get:t,set:e}},over(t,e){return r=>t.set(e(t.get(r)))(r)},compose(t,e){return b.make(r=>t.get(e.get(r)),r=>n=>e.set(t.set(r)(e.get(n)))(n))}};var A={headers:b.make(t=>t.headers??{},t=>e=>({...e,headers:t}))};var I=t=>e=>b.over(A.headers,r=>({...r,...t}))(e),C=t=>e=>b.over(A.headers,r=>({...t,...r}))(e),g=(t,e)=>r=>b.over(A.headers,n=>n[t]?n:{...n,[t]:e})(r);var v=t=>typeof t=="object"&&t!==null&&"_tag"in t,J=t=>v(t)?t:typeof t=="object"&&t!==null&&t.name==="AbortError"?{_tag:"Abort"}:{_tag:"FetchError",message:String(t)},M=t=>Q$1(e=>new Promise((r,n)=>{if(e.aborted)return n({_tag:"Abort"});let u=setTimeout(r,t),p=()=>{clearTimeout(u),n({_tag:"Abort"});};e.addEventListener("abort",p,{once:true});}),J);var lt=t=>e=>T(t(e)),T=t=>Object.assign((e=>t(e)),{with:e=>T(e(t))}),O=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)},k=t=>{if(t){if(typeof Headers<"u"&&t instanceof Headers){let e={};return t.forEach((r,n)=>e[n]=r),e}if(Array.isArray(t))return Object.fromEntries(t);if(typeof t=="object")return {...t}}},D=t=>e=>{let r=Object.keys(t).length?C(t)(e):e,n=k(e.init?.headers);return n&&Object.keys(n).length&&(r=C(n)(r)),r};function N(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return u=>Q$1(async p=>{let y=n(u),i;try{i=new URL(y.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${y.url}`}}let a=performance.now(),s=await fetch(i,{...y.init??{},method:y.method,headers:A.headers.get(y),body:y.body,signal:p}),c={};s.headers.forEach((d,m)=>c[m]=d);let o=pa(s.body,O);return {status:s.status,statusText:s.statusText,headers:c,body:o,ms:Math.round(performance.now()-a)}},O)}function _(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return T(p=>Q$1(async y=>{let i=n(p),a;try{a=new URL(i.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${i.url}`}}let s=performance.now(),c=await fetch(a,{...i.init??{},method:i.method,headers:A.headers.get(i),body:i.body,signal:y}),o=await c.text(),d={};return c.headers.forEach((m,H)=>d[H]=m),{status:c.status,statusText:c.statusText,headers:d,bodyText:o,ms:Math.round(performance.now()-s)}},O))}var G=(t,e,r)=>Math.max(e,Math.min(r,t)),z=t=>t._tag==="FetchError",Z=t=>t===408||t===429||t===500||t===502||t===503||t===504,F=(t,e,r)=>{let n=e*Math.pow(2,t),u=G(n,0,r);return Math.floor(Math.random()*u)},$=t=>{let e=Object.keys(t).find(p=>p.toLowerCase()==="retry-after");if(!e)return;let r=t[e]?.trim();if(!r)return;let n=Number(r);if(Number.isFinite(n))return Math.max(0,Math.floor(n*1e3));let u=Date.parse(r);if(Number.isFinite(u))return Math.max(0,u-Date.now())},U=t=>e$1=>(r=>{let n=u=>a(e$1(r),p=>{if(p._tag==="Abort"||p._tag==="BadUrl")return f(p);if(!(u<t.maxRetries&&(t.retryOnError??z)(p)))return f(p);let i=F(u,t.baseDelayMs,t.maxDelayMs);return k$1(M(i),()=>n(u+1))},p=>{if(!(u<t.maxRetries&&(t.retryOnStatus??Z)(p.status)))return e(p);let a=$(p.headers)??F(u,t.baseDelayMs,t.maxDelayMs);return k$1(M(a),()=>n(u+1))});return n(0)});var K=["GET","HEAD","OPTIONS"],Q=t=>t===408||t===429||t===500||t===502||t===503||t===504,V=t=>t._tag==="FetchError";var X=(t,e,r)=>Math.max(e,Math.min(r,t)),L=(t,e,r)=>{let n=Math.max(0,e),u=Math.max(0,r),p=n*Math.pow(2,t),y=X(p,0,u);return Math.floor(Math.random()*y)},Y=(t,e)=>{let r=Object.keys(t).find(n=>n.toLowerCase()===e.toLowerCase());return r?t[r]:void 0},tt=t=>{let e=Y(t,"retry-after")?.trim();if(!e)return;let r=Number(e);if(Number.isFinite(r))return Math.max(0,Math.floor(r*1e3));let n=Date.parse(e);if(Number.isFinite(n))return Math.max(0,n-Date.now())},j=t=>e$1=>{let r=t.retryOnMethods??K,n=t.retryOnStatus??Q,u=t.retryOnError??V,p=i=>r.includes(i.method),y=(i,a$1)=>p(i)?a(e$1(i),s=>{if(s._tag==="Abort"||s._tag==="BadUrl")return f(s);if(!(a$1<t.maxRetries&&u(s)))return f(s);let o=L(a$1,t.baseDelayMs,t.maxDelayMs);return k$1(M(o),()=>y(i,a$1+1))},s=>{if(!(a$1<t.maxRetries&&n(s.status)))return e(s);let d=tt(s.headers)??L(a$1,t.baseDelayMs,t.maxDelayMs);return k$1(M(d),()=>y(i,a$1+1))}):e$1(i);return i=>y(i,0)};var et=(t,e)=>{try{return new URL(e,t??"").toString()}catch{return (t??"")+e}},B=(t={})=>{let e=_(t),r=a=>n((s,c)=>M$1(s,c))(a),n$1=a=>e(a),u=a=>{let{headers:s,...c}=a??{};return {headers:k(s),init:c}},p=a=>s=>a?I(a)(s):s;return {cfg:t,wire:e,withPromise:r,requestRaw:n$1,splitInit:u,applyInitHeaders:p,buildReq:(a,s,c,o)=>{let d=u(c),m={method:a,url:s,...o&&o.length>0?{body:o}:{},init:d.init};return p(d.headers)(m)},toResponse:(a,s)=>({status:a.status,statusText:a.statusText,headers:a.headers,body:s})}};function _t(t={}){let e=B(t),r=n=>{let u=o=>n(o),p$1=o=>e.withPromise(u(o));return {request:p$1,get:(o,d)=>p$1(e.buildReq("GET",o,d)),post:(o,d,m)=>p$1(e.buildReq("POST",o,m,d)),getText:(o,d)=>{let m=e.buildReq("GET",o,d);return e.withPromise(p(u(m),H=>e.toResponse(H,H.bodyText)))},getJson:(o,d)=>{let m=e.buildReq("GET",o,d),H=g("accept","application/json")(m);return e.withPromise(p(u(H),l=>e.toResponse(l,JSON.parse(l.bodyText))))},postJson:(o,d,m)=>{let H=e.buildReq("POST",o,m,JSON.stringify(d??{})),l=g("content-type","application/json")(g("accept","application/json")(H));return e.withPromise(p(u(l),P=>e.toResponse(P,JSON.parse(P.bodyText))))},with:o=>r(n.with(o)),withRetry:o=>r(n.with(j(o))),wire:n}};return r(e.wire)}function Ut(t={}){let e=B(t),r=(s,c,o)=>({request:s,urlFinal:et(e.cfg.baseUrl,s.url),startedAt:o,durationMs:c.ms}),n=s=>{let c=Date.now();return e.withPromise(p(e.requestRaw(s),o=>({wire:o,meta:r(s,o,c)})))};return {request:n,get:(s,c)=>{let o=e.buildReq("GET",s,c);return n(o)},getText:(s,c)=>{let o=e.buildReq("GET",s,c),d=Date.now();return e.withPromise(p(e.requestRaw(o),m=>({wire:m,response:e.toResponse(m,m.bodyText),meta:r(o,m,d)})))},getJson:(s,c)=>{let o=e.buildReq("GET",s,c),d=g("accept","application/json")(o),m=Date.now();return e.withPromise(p(e.requestRaw(d),H=>({wire:H,response:e.toResponse(H,JSON.parse(H.bodyText)),meta:r(d,H,m)})))},post:(s,c,o)=>{let d=e.buildReq("POST",s,o,c);return n(d)},postJson:(s,c,o)=>{let d=e.buildReq("POST",s,o,JSON.stringify(c??{})),m=g("content-type","application/json")(g("accept","application/json")(d)),H=Date.now();return e.withPromise(p(e.requestRaw(m),l=>({wire:l,response:e.toResponse(l,JSON.parse(l.bodyText)),meta:r(m,l,H)})))}}}function Lt(t={}){let e=N(t),r=n$1=>{let u=i=>n((a,s)=>M$1(a,s))(i),p=i=>u(n$1(i)),y=(i,a)=>{let s={method:"GET",url:i,init:a},c=g("accept","*/*")(s);return p(c)};return {request:p,getStream:y,get:y,with:i=>r(i(n$1)),withRetry:i=>r(U(i)(n$1)),wire:n$1}};return r(e)}export{T as decorate,_t as httpClient,Lt as httpClientStream,Ut as httpClientWithMeta,_ as makeHttp,N as makeHttpStream,k as normalizeHeadersInit,lt as withMiddleware,U as withRetryStream};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
5
|
-
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
6
|
-
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
7
|
-
type BrassError = {
|
|
8
|
-
_tag: "Abort";
|
|
9
|
-
} | {
|
|
10
|
-
_tag: "PromiseRejected";
|
|
11
|
-
reason: unknown;
|
|
12
|
-
};
|
|
13
|
-
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
14
|
-
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
15
|
-
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
16
|
-
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
17
|
-
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
18
|
-
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
19
|
-
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
20
|
-
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
21
|
-
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
1
|
+
import { Z as ZStream, A as Async, S as Scope, I as Interrupted, E as Exit, F as Fiber, O as Option } from './stream-hTHRKq88.mjs';
|
|
2
|
+
export { x as AsyncWithPromise, P as BrassError, J as CancelToken, H as Canceler, ac as Concat, ab as Emit, aa as Empty, $ as FiberId, a0 as FiberStatus, ad as Flatten, ae as FromPull, af as Merge, N as None, ah as Normalize, R as Runtime, a1 as RuntimeFiber, a8 as Scheduler, a4 as ScopeId, ag as Scoped, C as Some, a7 as Task, a as ZIO, v as acquireRelease, at as assertNever, q as async, i as asyncCatchAll, l as asyncFail, t as asyncFlatMap, h as asyncFold, w as asyncInterruptible, r as asyncMap, j as asyncMapError, k as asyncSucceed, n as asyncSync, p as asyncTotal, e as catchAll, az as collectStream, ap as concatStream, ao as emitStream, an as emptyStream, g as end, f as fail, c as flatMap, aq as flattenStream, ax as foreachStream, Q as fork, M as from, ay as fromArray, W as fromCallback, V as fromPromise, Y as fromPromiseAbortable, aj as fromPull, a2 as getCurrentFiber, _ as getCurrentRuntime, a9 as globalScheduler, L as linkAbortController, K as makeCancelToken, al as managedStream, m as map, z as mapAsync, d as mapError, au as mapStream, B as mapTryAsync, ar as merge, am as mergeStream, D as none, o as orElseOptional, av as rangeStream, G as some, aA as streamFromReadableStream, s as succeed, b as sync, U as toPromise, X as tryPromiseAbortable, as as uncons, u as unit, T as unsafeRunAsync, ak as unwrapScoped, ai as widenOpt, y as withAsyncPromise, a3 as withCurrentFiber, a5 as withScope, a6 as withScopeAsync, aw as zip } from './stream-hTHRKq88.mjs';
|
|
22
3
|
|
|
23
4
|
type Node<T> = {
|
|
24
5
|
value: T;
|
|
@@ -38,16 +19,22 @@ declare class LinkedQueue<T> {
|
|
|
38
19
|
private unlink;
|
|
39
20
|
}
|
|
40
21
|
|
|
22
|
+
declare const enum PushStatus {
|
|
23
|
+
Ok = 0,
|
|
24
|
+
Grew = 1,
|
|
25
|
+
Dropped = 2
|
|
26
|
+
}
|
|
41
27
|
declare class RingBuffer<T> {
|
|
42
28
|
private buf;
|
|
43
29
|
private head;
|
|
44
30
|
private tail;
|
|
45
31
|
private size_;
|
|
46
|
-
|
|
32
|
+
private readonly maxCap;
|
|
33
|
+
constructor(initialCapacity?: number, maxCapacity?: number);
|
|
47
34
|
get length(): number;
|
|
48
35
|
get capacity(): number;
|
|
49
36
|
isEmpty(): boolean;
|
|
50
|
-
push(value: T):
|
|
37
|
+
push(value: T): PushStatus;
|
|
51
38
|
shift(): T | undefined;
|
|
52
39
|
clear(): void;
|
|
53
40
|
private grow;
|
|
@@ -56,7 +43,6 @@ declare class RingBuffer<T> {
|
|
|
56
43
|
|
|
57
44
|
declare function buffer<R, E, A>(stream: ZStream<{} & R, E, A>, capacity: number, strategy?: "backpressure" | "dropping" | "sliding"): ZStream<{} & R, E, A>;
|
|
58
45
|
|
|
59
|
-
type AnyFiber<R, E, A> = ReturnType<Scope<R>["fork"]>;
|
|
60
46
|
/**
|
|
61
47
|
* race(A, B):
|
|
62
48
|
* - corre A y B en paralelo
|
|
@@ -78,7 +64,7 @@ declare function zipPar<R, E, A, B>(left: Async<R, E, A>, right: Async<R, E, B>,
|
|
|
78
64
|
* - si todos terminan bien → devuelve array de resultados
|
|
79
65
|
*/
|
|
80
66
|
declare function collectAllPar<R, E, A>(effects: ReadonlyArray<Async<R, E, A>>, parentScope: Scope<R>): Async<R, E | Interrupted, A[]>;
|
|
81
|
-
declare function raceWith<R, E, A, B, C>(left: Async<R, E, A>, right: Async<R, E, B>, parentScope: Scope<R>, onLeft: (exit: Exit<E | Interrupted, A>, rightFiber:
|
|
67
|
+
declare function raceWith<R, E, A, B, C>(left: Async<R, E, A>, right: Async<R, E, B>, parentScope: Scope<R>, onLeft: (exit: Exit<E | Interrupted, A>, rightFiber: Fiber<E | Interrupted, B>, scope: Scope<R>) => Async<R, E | Interrupted, C>, onRight: (exit: Exit<E | Interrupted, B>, leftFiber: Fiber<E | Interrupted, A>, scope: Scope<R>) => Async<R, E | Interrupted, C>): Async<R, E | Interrupted, C>;
|
|
82
68
|
|
|
83
69
|
type Strategy = "backpressure" | "dropping" | "sliding";
|
|
84
70
|
type QueueClosed = {
|
|
@@ -138,13 +124,6 @@ declare function filterMapP<A, B>(f: (a: A) => Option<B>): ZPipeline<unknown, ne
|
|
|
138
124
|
declare function takeP<A>(n: number): ZPipeline<unknown, never, A, A>;
|
|
139
125
|
/** Drop the first N elements. */
|
|
140
126
|
declare function dropP<A>(n: number): ZPipeline<unknown, never, A, A>;
|
|
141
|
-
/**
|
|
142
|
-
* Map elements with an effect (sequential).
|
|
143
|
-
*
|
|
144
|
-
* - Upstream end => end
|
|
145
|
-
* - Upstream error E => fail(E)
|
|
146
|
-
* - f(a) fails with Ep => fail(Ep)
|
|
147
|
-
*/
|
|
148
127
|
declare function mapEffectP<Rp, Ep, A, B>(f: (a: A) => Async<Rp, Ep, B>): ZPipeline<Rp, Ep, A, B>;
|
|
149
128
|
/** Tap each element with an effect, preserving the element. */
|
|
150
129
|
declare function tapEffectP<Rp, Ep, A>(f: (a: A) => Async<Rp, Ep, any>): ZPipeline<Rp, Ep, A, A>;
|
|
@@ -156,4 +135,4 @@ declare function bufferP<A>(capacity: number, strategy?: "backpressure" | "dropp
|
|
|
156
135
|
*/
|
|
157
136
|
declare function groupedP<A>(n: number): ZPipeline<unknown, never, A, A[]>;
|
|
158
137
|
|
|
159
|
-
export { Async,
|
|
138
|
+
export { Async, Exit, Fiber, type Hub, type HubClosed, type HubStrategy, Interrupted, LinkedQueue, type Node, Option, PushStatus, type Queue, type QueueClosed, RingBuffer, Scope, type Strategy, type Subscription, type ZPipeline, ZStream, andThen, bounded, broadcast, broadcastToHub, buffer, bufferP, collectAllPar, compose, dropP, filterMapP, filterP, fromHub, groupedP, identity, makeHub, mapEffectP, mapP, race, raceWith, takeP, tapEffectP, via, zipPar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
5
|
-
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
6
|
-
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
7
|
-
type BrassError = {
|
|
8
|
-
_tag: "Abort";
|
|
9
|
-
} | {
|
|
10
|
-
_tag: "PromiseRejected";
|
|
11
|
-
reason: unknown;
|
|
12
|
-
};
|
|
13
|
-
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
14
|
-
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
15
|
-
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
16
|
-
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
17
|
-
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
18
|
-
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
19
|
-
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
20
|
-
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
21
|
-
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
1
|
+
import { Z as ZStream, A as Async, S as Scope, I as Interrupted, E as Exit, F as Fiber, O as Option } from './stream-hTHRKq88.js';
|
|
2
|
+
export { x as AsyncWithPromise, P as BrassError, J as CancelToken, H as Canceler, ac as Concat, ab as Emit, aa as Empty, $ as FiberId, a0 as FiberStatus, ad as Flatten, ae as FromPull, af as Merge, N as None, ah as Normalize, R as Runtime, a1 as RuntimeFiber, a8 as Scheduler, a4 as ScopeId, ag as Scoped, C as Some, a7 as Task, a as ZIO, v as acquireRelease, at as assertNever, q as async, i as asyncCatchAll, l as asyncFail, t as asyncFlatMap, h as asyncFold, w as asyncInterruptible, r as asyncMap, j as asyncMapError, k as asyncSucceed, n as asyncSync, p as asyncTotal, e as catchAll, az as collectStream, ap as concatStream, ao as emitStream, an as emptyStream, g as end, f as fail, c as flatMap, aq as flattenStream, ax as foreachStream, Q as fork, M as from, ay as fromArray, W as fromCallback, V as fromPromise, Y as fromPromiseAbortable, aj as fromPull, a2 as getCurrentFiber, _ as getCurrentRuntime, a9 as globalScheduler, L as linkAbortController, K as makeCancelToken, al as managedStream, m as map, z as mapAsync, d as mapError, au as mapStream, B as mapTryAsync, ar as merge, am as mergeStream, D as none, o as orElseOptional, av as rangeStream, G as some, aA as streamFromReadableStream, s as succeed, b as sync, U as toPromise, X as tryPromiseAbortable, as as uncons, u as unit, T as unsafeRunAsync, ak as unwrapScoped, ai as widenOpt, y as withAsyncPromise, a3 as withCurrentFiber, a5 as withScope, a6 as withScopeAsync, aw as zip } from './stream-hTHRKq88.js';
|
|
22
3
|
|
|
23
4
|
type Node<T> = {
|
|
24
5
|
value: T;
|
|
@@ -38,16 +19,22 @@ declare class LinkedQueue<T> {
|
|
|
38
19
|
private unlink;
|
|
39
20
|
}
|
|
40
21
|
|
|
22
|
+
declare const enum PushStatus {
|
|
23
|
+
Ok = 0,
|
|
24
|
+
Grew = 1,
|
|
25
|
+
Dropped = 2
|
|
26
|
+
}
|
|
41
27
|
declare class RingBuffer<T> {
|
|
42
28
|
private buf;
|
|
43
29
|
private head;
|
|
44
30
|
private tail;
|
|
45
31
|
private size_;
|
|
46
|
-
|
|
32
|
+
private readonly maxCap;
|
|
33
|
+
constructor(initialCapacity?: number, maxCapacity?: number);
|
|
47
34
|
get length(): number;
|
|
48
35
|
get capacity(): number;
|
|
49
36
|
isEmpty(): boolean;
|
|
50
|
-
push(value: T):
|
|
37
|
+
push(value: T): PushStatus;
|
|
51
38
|
shift(): T | undefined;
|
|
52
39
|
clear(): void;
|
|
53
40
|
private grow;
|
|
@@ -56,7 +43,6 @@ declare class RingBuffer<T> {
|
|
|
56
43
|
|
|
57
44
|
declare function buffer<R, E, A>(stream: ZStream<{} & R, E, A>, capacity: number, strategy?: "backpressure" | "dropping" | "sliding"): ZStream<{} & R, E, A>;
|
|
58
45
|
|
|
59
|
-
type AnyFiber<R, E, A> = ReturnType<Scope<R>["fork"]>;
|
|
60
46
|
/**
|
|
61
47
|
* race(A, B):
|
|
62
48
|
* - corre A y B en paralelo
|
|
@@ -78,7 +64,7 @@ declare function zipPar<R, E, A, B>(left: Async<R, E, A>, right: Async<R, E, B>,
|
|
|
78
64
|
* - si todos terminan bien → devuelve array de resultados
|
|
79
65
|
*/
|
|
80
66
|
declare function collectAllPar<R, E, A>(effects: ReadonlyArray<Async<R, E, A>>, parentScope: Scope<R>): Async<R, E | Interrupted, A[]>;
|
|
81
|
-
declare function raceWith<R, E, A, B, C>(left: Async<R, E, A>, right: Async<R, E, B>, parentScope: Scope<R>, onLeft: (exit: Exit<E | Interrupted, A>, rightFiber:
|
|
67
|
+
declare function raceWith<R, E, A, B, C>(left: Async<R, E, A>, right: Async<R, E, B>, parentScope: Scope<R>, onLeft: (exit: Exit<E | Interrupted, A>, rightFiber: Fiber<E | Interrupted, B>, scope: Scope<R>) => Async<R, E | Interrupted, C>, onRight: (exit: Exit<E | Interrupted, B>, leftFiber: Fiber<E | Interrupted, A>, scope: Scope<R>) => Async<R, E | Interrupted, C>): Async<R, E | Interrupted, C>;
|
|
82
68
|
|
|
83
69
|
type Strategy = "backpressure" | "dropping" | "sliding";
|
|
84
70
|
type QueueClosed = {
|
|
@@ -138,13 +124,6 @@ declare function filterMapP<A, B>(f: (a: A) => Option<B>): ZPipeline<unknown, ne
|
|
|
138
124
|
declare function takeP<A>(n: number): ZPipeline<unknown, never, A, A>;
|
|
139
125
|
/** Drop the first N elements. */
|
|
140
126
|
declare function dropP<A>(n: number): ZPipeline<unknown, never, A, A>;
|
|
141
|
-
/**
|
|
142
|
-
* Map elements with an effect (sequential).
|
|
143
|
-
*
|
|
144
|
-
* - Upstream end => end
|
|
145
|
-
* - Upstream error E => fail(E)
|
|
146
|
-
* - f(a) fails with Ep => fail(Ep)
|
|
147
|
-
*/
|
|
148
127
|
declare function mapEffectP<Rp, Ep, A, B>(f: (a: A) => Async<Rp, Ep, B>): ZPipeline<Rp, Ep, A, B>;
|
|
149
128
|
/** Tap each element with an effect, preserving the element. */
|
|
150
129
|
declare function tapEffectP<Rp, Ep, A>(f: (a: A) => Async<Rp, Ep, any>): ZPipeline<Rp, Ep, A, A>;
|
|
@@ -156,4 +135,4 @@ declare function bufferP<A>(capacity: number, strategy?: "backpressure" | "dropp
|
|
|
156
135
|
*/
|
|
157
136
|
declare function groupedP<A>(n: number): ZPipeline<unknown, never, A, A[]>;
|
|
158
137
|
|
|
159
|
-
export { Async,
|
|
138
|
+
export { Async, Exit, Fiber, type Hub, type HubClosed, type HubStrategy, Interrupted, LinkedQueue, type Node, Option, PushStatus, type Queue, type QueueClosed, RingBuffer, Scope, type Strategy, type Subscription, type ZPipeline, ZStream, andThen, bounded, broadcast, broadcastToHub, buffer, bufferP, collectAllPar, compose, dropP, filterMapP, filterP, fromHub, groupedP, identity, makeHub, mapEffectP, mapP, race, raceWith, takeP, tapEffectP, via, zipPar };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkKMTKZ4PS_js=require('./chunk-KMTKZ4PS.js');function He(){let t=false,e=new Set;return {isCancelled:()=>t,onCancel:r=>{if(t){try{r();}catch{}return ()=>{}}return e.add(r),()=>{e.delete(r);}},cancel:()=>{t||(t=true,e.forEach(r=>r()),e.clear());}}}function Qe(t,e){return t.onCancel(()=>e.abort())}var v=class{head=null;tail=null;len=0;get length(){return this.len}isEmpty(){return this.len===0}push(e){let n={value:e,next:null,prev:this.tail,removed:false};return this.tail?this.tail.next=n:this.head=n,this.tail=n,this.len++,n}shift(){let e=this.head;if(e)return this.unlink(e),e.value}remove(e){e.removed||this.unlink(e);}unlink(e){e.removed=true;let{prev:n,next:r}=e;n?n.next=r:this.head=r,r?r.prev=n:this.tail=n,e.next=null,e.prev=null,this.len--;}};function w(t,e="backpressure"){return chunkKMTKZ4PS_js.g(()=>M(t,e))}function M(t,e){let n=new chunkKMTKZ4PS_js.B(t),r=false,s={_tag:"QueueClosed"},a=new v,o=new v,p=()=>{for(;o.length>0&&n.length>0;){let u=o.shift(),f=n.shift();u({_tag:"Success",value:f});}for(;a.length>0&&n.length<t&&o.length===0;){let u=a.shift();n.push(u.a),u.cb(true);}for(;o.length>0&&a.length>0;){let u=o.shift(),f=a.shift();f.cb(true),u({_tag:"Success",value:f.a});}};return {size:()=>n.length,shutdown:()=>{if(!r){for(r=true;o.length>0;)o.shift()({_tag:"Failure",error:s});for(;a.length>0;)a.shift().cb(false);n.clear();}},offer:u=>chunkKMTKZ4PS_js.i((f,i)=>{if(r){i({_tag:"Success",value:false});return}if(o.length>0){o.shift()({_tag:"Success",value:u}),i({_tag:"Success",value:true});return}if(n.length<t){n.push(u),i({_tag:"Success",value:true}),p();return}if(e==="dropping"){i({_tag:"Success",value:false});return}if(e==="sliding"){n.shift(),n.push(u),i({_tag:"Success",value:true}),p();return}let m=a.push({a:u,cb:A=>i({_tag:"Success",value:A})});return ()=>{a.remove(m);}}),take:()=>chunkKMTKZ4PS_js.i((u,f)=>{if(n.length>0){let A=n.shift();f({_tag:"Success",value:A}),p();return}if(a.length>0){let A=a.shift();A.cb(true),f({_tag:"Success",value:A.a});return}if(r){f({_tag:"Failure",error:s});return}let i=A=>f(A),m=o.push(i);return ()=>{o.remove(m);}})}}function F(t,e,n="backpressure"){let r=false,s=null,a=null,o=t,p=()=>chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(o),i=>chunkKMTKZ4PS_js.e(i._tag==="None"?{_tag:"End"}:{_tag:"Fail",error:i.value}),([i,m])=>chunkKMTKZ4PS_js.g(()=>(o=m,{_tag:"Elem",value:i}))),c=i=>chunkKMTKZ4PS_js.k(w(e,n),m=>{s=m;let S=()=>chunkKMTKZ4PS_js.k(p(),A=>chunkKMTKZ4PS_js.k(s.offer(A),()=>A._tag==="End"||A._tag==="Fail"?chunkKMTKZ4PS_js.e(void 0):S()));return a=chunkKMTKZ4PS_js.G(S(),i),r=true,chunkKMTKZ4PS_js.e(void 0)}),u={_tag:"Async",register:(i,m)=>{(()=>{if(!r){chunkKMTKZ4PS_js.G(c(i),i).join(()=>{f(i,m);});return}f(i,m);})();}};function f(i,m){let S=s.take();chunkKMTKZ4PS_js.G(S,i).join(A=>{if(A._tag!=="Success")return;let _=A.value;switch(_._tag){case "Elem":m({_tag:"Success",value:[_.value,chunkKMTKZ4PS_js.V(u)]});return;case "End":a?.interrupt?.(),m({_tag:"Failure",error:chunkKMTKZ4PS_js.q});return;case "Fail":a?.interrupt?.(),m({_tag:"Failure",error:chunkKMTKZ4PS_js.r(_.error)});return}});}return chunkKMTKZ4PS_js.V(u)}var I=t=>t==="BackPressure"?"backpressure":t==="Dropping"?"dropping":"sliding";function N(t,e="BackPressure"){let n=new Set,r=false,s=c=>{if(r)return chunkKMTKZ4PS_js.e(false);let u=Array.from(n),f=chunkKMTKZ4PS_js.e(true);return u.forEach(i=>{f=chunkKMTKZ4PS_js.k(f,m=>chunkKMTKZ4PS_js.k(i.offer(c),S=>chunkKMTKZ4PS_js.e(m&&S)));}),f};return {publish:s,publishAll:c=>{let u=chunkKMTKZ4PS_js.e(true),f=c[Symbol.iterator]();for(;;){let i=f.next();if(i.done)break;let m=i.value;u=chunkKMTKZ4PS_js.k(u,S=>chunkKMTKZ4PS_js.k(s(m),A=>chunkKMTKZ4PS_js.e(S&&A)));}return u},subscribe:()=>r?chunkKMTKZ4PS_js.h(()=>{throw {_tag:"HubClosed"}}):chunkKMTKZ4PS_js.k(w(t,I(e)),c=>chunkKMTKZ4PS_js.g(()=>(n.add(c),{...c,unsubscribe:()=>{n.has(c)&&(n.delete(c),c.shutdown());}}))),shutdown:()=>chunkKMTKZ4PS_js.g(()=>{r||(r=true,Array.from(n).forEach(c=>c.shutdown()),n.clear());})}}var cn=N;function pn(t,e){return chunkKMTKZ4PS_js.ga(t,n=>chunkKMTKZ4PS_js.k(e.publish(n),()=>chunkKMTKZ4PS_js.e(void 0)))}function fn(t){return chunkKMTKZ4PS_js.X(chunkKMTKZ4PS_js.k(t.subscribe(),e=>{let n=chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.k(chunkKMTKZ4PS_js.c(e.take(),r=>chunkKMTKZ4PS_js.q),r=>chunkKMTKZ4PS_js.e([r,n])));return chunkKMTKZ4PS_js.e({stream:n,release:r=>chunkKMTKZ4PS_js.g(()=>e.unsubscribe())})}))}function gn(t,e){return e(t)}function z(t,e){return(n=>e(t(n)))}function vn(t,e){return z(e,t)}function xn(){return(t=>t)}function kn(t){return(e=>{let n=r=>chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(r),s=>chunkKMTKZ4PS_js.f(s),([s,a])=>chunkKMTKZ4PS_js.e([t(s),n(a)])));return n(e)})}function Zn(t){return(e=>{let n=s=>chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(s),a=>chunkKMTKZ4PS_js.f(a),([a,o])=>t(a)?chunkKMTKZ4PS_js.e([a,r(o)]):n(o)),r=s=>chunkKMTKZ4PS_js.V(n(s));return r(e)})}function wn(t){return(e=>{let n=s=>chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(s),a=>chunkKMTKZ4PS_js.f(a),([a,o])=>{let p=t(a);return p._tag==="Some"?chunkKMTKZ4PS_js.e([p.value,r(o)]):n(o)}),r=s=>chunkKMTKZ4PS_js.V(n(s));return r(e)})}function _n(t){let e=Math.max(0,t|0);return(n=>{let r=(s,a)=>a<=0?chunkKMTKZ4PS_js.Z():chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(s),o=>chunkKMTKZ4PS_js.f(o),([o,p])=>chunkKMTKZ4PS_js.e([o,r(p,a-1)])));return r(n,e)})}function Cn(t){let e=Math.max(0,t|0);return(n=>{let r=(s,a)=>a<=0?s:chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(s),o=>chunkKMTKZ4PS_js.f(o),([o,p])=>chunkKMTKZ4PS_js.ca(r(p,a-1))));return r(n,e)})}function D(t){return(e=>{let n=r=>chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.c(chunkKMTKZ4PS_js.ca(r),s=>chunkKMTKZ4PS_js.U(s)),s=>chunkKMTKZ4PS_js.f(s),([s,a])=>chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.c(t(s),o=>chunkKMTKZ4PS_js.r(o)),o=>chunkKMTKZ4PS_js.f(o),o=>chunkKMTKZ4PS_js.e([o,n(a)]))));return n(e)})}function Pn(t){return D(e=>chunkKMTKZ4PS_js.k(t(e),()=>chunkKMTKZ4PS_js.e(e)))}function On(t,e="backpressure"){return(n=>F(n,t,e))}function Tn(t){let e=Math.max(1,t|0);return(n=>{let r=(a,o,p)=>o<=0?chunkKMTKZ4PS_js.e({chunk:p,rest:a}):chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(a),c=>c._tag==="None"?chunkKMTKZ4PS_js.e({chunk:p,rest:chunkKMTKZ4PS_js.Z()}):chunkKMTKZ4PS_js.f(c),([c,u])=>r(u,o-1,[...p,c])),s=a=>chunkKMTKZ4PS_js.V(chunkKMTKZ4PS_js.a(chunkKMTKZ4PS_js.ca(a),o=>chunkKMTKZ4PS_js.f(o),([o,p])=>chunkKMTKZ4PS_js.k(r(p,e-1,[o]),({chunk:c,rest:u})=>chunkKMTKZ4PS_js.e([c,s(u)]))));return s(n)})}Object.defineProperty(exports,"RingBuffer",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.B}});Object.defineProperty(exports,"RuntimeFiber",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.E}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.C}});Object.defineProperty(exports,"Scope",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.N}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.l}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.h}});Object.defineProperty(exports,"catchAll",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.y}});Object.defineProperty(exports,"collectAllPar",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.S}});Object.defineProperty(exports,"collectStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ia}});Object.defineProperty(exports,"concatStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.$}});Object.defineProperty(exports,"emitStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js._}});Object.defineProperty(exports,"emptyStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.Z}});Object.defineProperty(exports,"end",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.A}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.t}});Object.defineProperty(exports,"flatMap",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.w}});Object.defineProperty(exports,"flattenStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.aa}});Object.defineProperty(exports,"foreachStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ga}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.G}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.F}});Object.defineProperty(exports,"fromArray",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ha}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.K}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.J}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.M}});Object.defineProperty(exports,"fromPull",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.V}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.D}});Object.defineProperty(exports,"managedStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.X}});Object.defineProperty(exports,"map",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.v}});Object.defineProperty(exports,"mapAsync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.o}});Object.defineProperty(exports,"mapError",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.x}});Object.defineProperty(exports,"mapStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.da}});Object.defineProperty(exports,"mapTryAsync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.p}});Object.defineProperty(exports,"merge",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ba}});Object.defineProperty(exports,"mergeStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.Y}});Object.defineProperty(exports,"none",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.q}});Object.defineProperty(exports,"orElseOptional",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.z}});Object.defineProperty(exports,"race",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.Q}});Object.defineProperty(exports,"raceWith",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.T}});Object.defineProperty(exports,"rangeStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ea}});Object.defineProperty(exports,"some",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.r}});Object.defineProperty(exports,"streamFromReadableStream",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ja}});Object.defineProperty(exports,"succeed",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.s}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.u}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.I}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.L}});Object.defineProperty(exports,"uncons",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.ca}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.H}});Object.defineProperty(exports,"unwrapScoped",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.W}});Object.defineProperty(exports,"widenOpt",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.U}});Object.defineProperty(exports,"withAsyncPromise",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.n}});Object.defineProperty(exports,"withScope",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.O}});Object.defineProperty(exports,"withScopeAsync",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.P}});Object.defineProperty(exports,"zip",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.fa}});Object.defineProperty(exports,"zipPar",{enumerable:true,get:function(){return chunkKMTKZ4PS_js.R}});exports.LinkedQueue=v;exports.andThen=z;exports.bounded=w;exports.broadcast=cn;exports.broadcastToHub=pn;exports.buffer=F;exports.bufferP=On;exports.compose=vn;exports.dropP=Cn;exports.filterMapP=wn;exports.filterP=Zn;exports.fromHub=fn;exports.groupedP=Tn;exports.identity=xn;exports.linkAbortController=Qe;exports.makeCancelToken=He;exports.makeHub=N;exports.mapEffectP=D;exports.mapP=kn;exports.takeP=_n;exports.tapEffectP=Pn;exports.via=gn;
|
|
1
|
+
'use strict';var chunkQ2H2CAII_js=require('./chunk-Q2H2CAII.js');function ze(){let t=false,e=new Set;return {isCancelled:()=>t,onCancel:r=>{if(t){try{r();}catch{}return ()=>{}}return e.add(r),()=>{e.delete(r);}},cancel:()=>{t||(t=true,e.forEach(r=>r()),e.clear());}}}function De(t,e){return t.onCancel(()=>e.abort())}var v=class{head=null;tail=null;len=0;get length(){return this.len}isEmpty(){return this.len===0}push(e){let n={value:e,next:null,prev:this.tail,removed:false};return this.tail?this.tail.next=n:this.head=n,this.tail=n,this.len++,n}shift(){let e=this.head;if(e)return this.unlink(e),e.value}remove(e){e.removed||this.unlink(e);}unlink(e){e.removed=true;let{prev:n,next:r}=e;n?n.next=r:this.head=r,r?r.prev=n:this.tail=n,e.next=null,e.prev=null,this.len--;}};function w(t,e="backpressure"){return chunkQ2H2CAII_js.g(()=>M(t,e))}function M(t,e){let n=new chunkQ2H2CAII_js.C(t),r=false,s={_tag:"QueueClosed"},o=new v,a=new v,l=()=>{for(;a.length>0&&n.length>0;){let u=a.shift(),f=n.shift();u({_tag:"Success",value:f});}for(;o.length>0&&n.length<t&&a.length===0;){let u=o.shift();n.push(u.a),u.cb(true);}for(;a.length>0&&o.length>0;){let u=a.shift(),f=o.shift();f.cb(true),u({_tag:"Success",value:f.a});}};return {size:()=>n.length,shutdown:()=>{if(!r){for(r=true;a.length>0;)a.shift()({_tag:"Failure",error:s});for(;o.length>0;)o.shift().cb(false);n.clear();}},offer:u=>chunkQ2H2CAII_js.i((f,i)=>{if(r){i({_tag:"Success",value:false});return}if(a.length>0){a.shift()({_tag:"Success",value:u}),i({_tag:"Success",value:true});return}if(n.length<t){n.push(u),i({_tag:"Success",value:true}),l();return}if(e==="dropping"){i({_tag:"Success",value:false});return}if(e==="sliding"){n.shift(),n.push(u),i({_tag:"Success",value:true}),l();return}let A=o.push({a:u,cb:m=>i({_tag:"Success",value:m})});return ()=>{o.remove(A);}}),take:()=>chunkQ2H2CAII_js.i((u,f)=>{if(n.length>0){let m=n.shift();f({_tag:"Success",value:m}),l();return}if(o.length>0){let m=o.shift();m.cb(true),f({_tag:"Success",value:m.a});return}if(r){f({_tag:"Failure",error:s});return}let i=m=>f(m),A=a.push(i);return ()=>{a.remove(A);}})}}function F(t,e,n="backpressure"){let r=false,s=null,o=null,a=t,l=()=>chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(a),i=>chunkQ2H2CAII_js.e(i._tag==="None"?{_tag:"End"}:{_tag:"Fail",error:i.value}),([i,A])=>chunkQ2H2CAII_js.g(()=>(a=A,{_tag:"Elem",value:i}))),p=i=>chunkQ2H2CAII_js.k(w(e,n),A=>{s=A;let S=()=>chunkQ2H2CAII_js.k(l(),m=>chunkQ2H2CAII_js.k(s.offer(m),()=>m._tag==="End"||m._tag==="Fail"?chunkQ2H2CAII_js.e(void 0):S()));return o=chunkQ2H2CAII_js.K(S(),i),r=true,chunkQ2H2CAII_js.e(void 0)}),u={_tag:"Async",register:(i,A)=>{(()=>{if(!r){chunkQ2H2CAII_js.K(p(i),i).join(()=>{f(i,A);});return}f(i,A);})();}};function f(i,A){let S=s.take();chunkQ2H2CAII_js.K(S,i).join(m=>{if(m._tag!=="Success")return;let _=m.value;switch(_._tag){case "Elem":A({_tag:"Success",value:[_.value,chunkQ2H2CAII_js._(u)]});return;case "End":o?.interrupt?.(),A({_tag:"Failure",error:chunkQ2H2CAII_js.q});return;case "Fail":o?.interrupt?.(),A({_tag:"Failure",error:chunkQ2H2CAII_js.r(_.error)});return}});}return chunkQ2H2CAII_js._(u)}var I=t=>t==="BackPressure"?"backpressure":t==="Dropping"?"dropping":"sliding";function N(t,e="BackPressure"){let n=new Set,r=false,s=p=>{if(r)return chunkQ2H2CAII_js.e(false);let u=Array.from(n),f=chunkQ2H2CAII_js.e(true);return u.forEach(i=>{f=chunkQ2H2CAII_js.k(f,A=>chunkQ2H2CAII_js.k(i.offer(p),S=>chunkQ2H2CAII_js.e(A&&S)));}),f};return {publish:s,publishAll:p=>{let u=chunkQ2H2CAII_js.e(true),f=p[Symbol.iterator]();for(;;){let i=f.next();if(i.done)break;let A=i.value;u=chunkQ2H2CAII_js.k(u,S=>chunkQ2H2CAII_js.k(s(A),m=>chunkQ2H2CAII_js.e(S&&m)));}return u},subscribe:()=>r?chunkQ2H2CAII_js.h(()=>{throw {_tag:"HubClosed"}}):chunkQ2H2CAII_js.k(w(t,I(e)),p=>chunkQ2H2CAII_js.g(()=>(n.add(p),{...p,unsubscribe:()=>{n.has(p)&&(n.delete(p),p.shutdown());}}))),shutdown:()=>chunkQ2H2CAII_js.g(()=>{r||(r=true,Array.from(n).forEach(p=>p.shutdown()),n.clear());})}}var yn=N;function dn(t,e){return chunkQ2H2CAII_js.ma(t,n=>chunkQ2H2CAII_js.k(e.publish(n),()=>chunkQ2H2CAII_js.e(void 0)))}function Rn(t){return chunkQ2H2CAII_js.aa(chunkQ2H2CAII_js.k(t.subscribe(),e=>{let n=chunkQ2H2CAII_js._(chunkQ2H2CAII_js.k(chunkQ2H2CAII_js.c(e.take(),r=>chunkQ2H2CAII_js.q),r=>chunkQ2H2CAII_js.e([r,n])));return chunkQ2H2CAII_js.e({stream:n,release:r=>chunkQ2H2CAII_js.g(()=>e.unsubscribe())})}))}function _n(t,e){return e(t)}function z(t,e){return(n=>e(t(n)))}function Cn(t,e){return z(e,t)}function On(){return(t=>t)}function Pn(t){return(e=>{let n=r=>chunkQ2H2CAII_js._(chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(r),s=>chunkQ2H2CAII_js.f(s),([s,o])=>chunkQ2H2CAII_js.e([t(s),n(o)])));return n(e)})}function Bn(t){return(e=>{let n=s=>chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(s),o=>chunkQ2H2CAII_js.f(o),([o,a])=>t(o)?chunkQ2H2CAII_js.e([o,r(a)]):n(a)),r=s=>chunkQ2H2CAII_js._(n(s));return r(e)})}function Tn(t){return(e=>{let n=s=>chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(s),o=>chunkQ2H2CAII_js.f(o),([o,a])=>{let l=t(o);return l._tag==="Some"?chunkQ2H2CAII_js.e([l.value,r(a)]):n(a)}),r=s=>chunkQ2H2CAII_js._(n(s));return r(e)})}function Hn(t){let e=Math.max(0,t|0);return(n=>{let r=(s,o)=>o<=0?chunkQ2H2CAII_js.ca():chunkQ2H2CAII_js._(chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(s),a=>chunkQ2H2CAII_js.f(a),([a,l])=>chunkQ2H2CAII_js.e([a,r(l,o-1)])));return r(n,e)})}function Qn(t){let e=Math.max(0,t|0);return(n=>{let r=(s,o)=>o<=0?s:chunkQ2H2CAII_js._(chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(s),a=>chunkQ2H2CAII_js.f(a),([a,l])=>chunkQ2H2CAII_js.ha(r(l,o-1))));return r(n,e)})}function D(t){return(e=>{let n=s=>chunkQ2H2CAII_js.c(s,o=>chunkQ2H2CAII_js.r(o)),r=s=>chunkQ2H2CAII_js._(chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.c(chunkQ2H2CAII_js.ha(s),o=>chunkQ2H2CAII_js.Z(o)),o=>chunkQ2H2CAII_js.f(o),([o,a])=>chunkQ2H2CAII_js.a(n(t(o)),l=>chunkQ2H2CAII_js.f(l),l=>chunkQ2H2CAII_js.e([l,r(a)]))));return r(e)})}function Fn(t){return D(e=>chunkQ2H2CAII_js.k(t(e),()=>chunkQ2H2CAII_js.e(e)))}function Mn(t,e="backpressure"){return(n=>F(n,t,e))}function In(t){let e=Math.max(1,t|0);return(n=>{let r=(o,a,l)=>a<=0?chunkQ2H2CAII_js.e({chunk:l,rest:o}):chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(o),p=>p._tag==="None"?chunkQ2H2CAII_js.e({chunk:l,rest:chunkQ2H2CAII_js.ca()}):chunkQ2H2CAII_js.f(p),([p,u])=>r(u,a-1,[...l,p])),s=o=>chunkQ2H2CAII_js._(chunkQ2H2CAII_js.a(chunkQ2H2CAII_js.ha(o),a=>chunkQ2H2CAII_js.f(a),([a,l])=>chunkQ2H2CAII_js.k(r(l,e-1,[a]),({chunk:p,rest:u})=>chunkQ2H2CAII_js.e([p,s(u)]))));return s(n)})}Object.defineProperty(exports,"PushStatus",{enumerable:true,get:function(){return chunkQ2H2CAII_js.B}});Object.defineProperty(exports,"RingBuffer",{enumerable:true,get:function(){return chunkQ2H2CAII_js.C}});Object.defineProperty(exports,"Runtime",{enumerable:true,get:function(){return chunkQ2H2CAII_js.I}});Object.defineProperty(exports,"RuntimeFiber",{enumerable:true,get:function(){return chunkQ2H2CAII_js.F}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkQ2H2CAII_js.D}});Object.defineProperty(exports,"Scope",{enumerable:true,get:function(){return chunkQ2H2CAII_js.S}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkQ2H2CAII_js.l}});Object.defineProperty(exports,"assertNever",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ia}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkQ2H2CAII_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkQ2H2CAII_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkQ2H2CAII_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkQ2H2CAII_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkQ2H2CAII_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkQ2H2CAII_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkQ2H2CAII_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkQ2H2CAII_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkQ2H2CAII_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkQ2H2CAII_js.h}});Object.defineProperty(exports,"catchAll",{enumerable:true,get:function(){return chunkQ2H2CAII_js.y}});Object.defineProperty(exports,"collectAllPar",{enumerable:true,get:function(){return chunkQ2H2CAII_js.X}});Object.defineProperty(exports,"collectStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.oa}});Object.defineProperty(exports,"concatStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ea}});Object.defineProperty(exports,"emitStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.da}});Object.defineProperty(exports,"emptyStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ca}});Object.defineProperty(exports,"end",{enumerable:true,get:function(){return chunkQ2H2CAII_js.A}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkQ2H2CAII_js.t}});Object.defineProperty(exports,"flatMap",{enumerable:true,get:function(){return chunkQ2H2CAII_js.w}});Object.defineProperty(exports,"flattenStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.fa}});Object.defineProperty(exports,"foreachStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ma}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkQ2H2CAII_js.K}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkQ2H2CAII_js.J}});Object.defineProperty(exports,"fromArray",{enumerable:true,get:function(){return chunkQ2H2CAII_js.na}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkQ2H2CAII_js.O}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkQ2H2CAII_js.N}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkQ2H2CAII_js.Q}});Object.defineProperty(exports,"fromPull",{enumerable:true,get:function(){return chunkQ2H2CAII_js._}});Object.defineProperty(exports,"getCurrentFiber",{enumerable:true,get:function(){return chunkQ2H2CAII_js.G}});Object.defineProperty(exports,"getCurrentRuntime",{enumerable:true,get:function(){return chunkQ2H2CAII_js.R}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkQ2H2CAII_js.E}});Object.defineProperty(exports,"managedStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.aa}});Object.defineProperty(exports,"map",{enumerable:true,get:function(){return chunkQ2H2CAII_js.v}});Object.defineProperty(exports,"mapAsync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.o}});Object.defineProperty(exports,"mapError",{enumerable:true,get:function(){return chunkQ2H2CAII_js.x}});Object.defineProperty(exports,"mapStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ja}});Object.defineProperty(exports,"mapTryAsync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.p}});Object.defineProperty(exports,"merge",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ga}});Object.defineProperty(exports,"mergeStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ba}});Object.defineProperty(exports,"none",{enumerable:true,get:function(){return chunkQ2H2CAII_js.q}});Object.defineProperty(exports,"orElseOptional",{enumerable:true,get:function(){return chunkQ2H2CAII_js.z}});Object.defineProperty(exports,"race",{enumerable:true,get:function(){return chunkQ2H2CAII_js.V}});Object.defineProperty(exports,"raceWith",{enumerable:true,get:function(){return chunkQ2H2CAII_js.Y}});Object.defineProperty(exports,"rangeStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ka}});Object.defineProperty(exports,"some",{enumerable:true,get:function(){return chunkQ2H2CAII_js.r}});Object.defineProperty(exports,"streamFromReadableStream",{enumerable:true,get:function(){return chunkQ2H2CAII_js.pa}});Object.defineProperty(exports,"succeed",{enumerable:true,get:function(){return chunkQ2H2CAII_js.s}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.u}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkQ2H2CAII_js.M}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkQ2H2CAII_js.P}});Object.defineProperty(exports,"uncons",{enumerable:true,get:function(){return chunkQ2H2CAII_js.ha}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkQ2H2CAII_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.L}});Object.defineProperty(exports,"unwrapScoped",{enumerable:true,get:function(){return chunkQ2H2CAII_js.$}});Object.defineProperty(exports,"widenOpt",{enumerable:true,get:function(){return chunkQ2H2CAII_js.Z}});Object.defineProperty(exports,"withAsyncPromise",{enumerable:true,get:function(){return chunkQ2H2CAII_js.n}});Object.defineProperty(exports,"withCurrentFiber",{enumerable:true,get:function(){return chunkQ2H2CAII_js.H}});Object.defineProperty(exports,"withScope",{enumerable:true,get:function(){return chunkQ2H2CAII_js.T}});Object.defineProperty(exports,"withScopeAsync",{enumerable:true,get:function(){return chunkQ2H2CAII_js.U}});Object.defineProperty(exports,"zip",{enumerable:true,get:function(){return chunkQ2H2CAII_js.la}});Object.defineProperty(exports,"zipPar",{enumerable:true,get:function(){return chunkQ2H2CAII_js.W}});exports.LinkedQueue=v;exports.andThen=z;exports.bounded=w;exports.broadcast=yn;exports.broadcastToHub=dn;exports.buffer=F;exports.bufferP=Mn;exports.compose=Cn;exports.dropP=Qn;exports.filterMapP=Tn;exports.filterP=Bn;exports.fromHub=Rn;exports.groupedP=In;exports.identity=On;exports.linkAbortController=De;exports.makeCancelToken=ze;exports.makeHub=N;exports.mapEffectP=D;exports.mapP=Pn;exports.takeP=Hn;exports.tapEffectP=Fn;exports.via=_n;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {g,
|
|
1
|
+
import {g,C,i,_,h,k,e,ma,aa,c,q,ca,K,r,a,ha,f,Z}from'./chunk-ZXK3XM2Q.mjs';export{B as PushStatus,C as RingBuffer,I as Runtime,F as RuntimeFiber,D as Scheduler,S as Scope,l as acquireRelease,ia as assertNever,i as async,b as asyncCatchAll,f as asyncFail,k as asyncFlatMap,a as asyncFold,m as asyncInterruptible,j as asyncMap,c as asyncMapError,e as asyncSucceed,g as asyncSync,h as asyncTotal,y as catchAll,X as collectAllPar,oa as collectStream,ea as concatStream,da as emitStream,ca as emptyStream,A as end,t as fail,w as flatMap,fa as flattenStream,ma as foreachStream,K as fork,J as from,na as fromArray,O as fromCallback,N as fromPromise,Q as fromPromiseAbortable,_ as fromPull,G as getCurrentFiber,R as getCurrentRuntime,E as globalScheduler,aa as managedStream,v as map,o as mapAsync,x as mapError,ja as mapStream,p as mapTryAsync,ga as merge,ba as mergeStream,q as none,z as orElseOptional,V as race,Y as raceWith,ka as rangeStream,r as some,pa as streamFromReadableStream,s as succeed,u as sync,M as toPromise,P as tryPromiseAbortable,ha as uncons,d as unit,L as unsafeRunAsync,$ as unwrapScoped,Z as widenOpt,n as withAsyncPromise,H as withCurrentFiber,T as withScope,U as withScopeAsync,la as zip,W as zipPar}from'./chunk-ZXK3XM2Q.mjs';function ze(){let t=false,e=new Set;return {isCancelled:()=>t,onCancel:r=>{if(t){try{r();}catch{}return ()=>{}}return e.add(r),()=>{e.delete(r);}},cancel:()=>{t||(t=true,e.forEach(r=>r()),e.clear());}}}function De(t,e){return t.onCancel(()=>e.abort())}var v=class{head=null;tail=null;len=0;get length(){return this.len}isEmpty(){return this.len===0}push(e){let n={value:e,next:null,prev:this.tail,removed:false};return this.tail?this.tail.next=n:this.head=n,this.tail=n,this.len++,n}shift(){let e=this.head;if(e)return this.unlink(e),e.value}remove(e){e.removed||this.unlink(e);}unlink(e){e.removed=true;let{prev:n,next:r}=e;n?n.next=r:this.head=r,r?r.prev=n:this.tail=n,e.next=null,e.prev=null,this.len--;}};function w(t,e="backpressure"){return g(()=>M(t,e))}function M(t,e){let n=new C(t),r=false,s={_tag:"QueueClosed"},o=new v,a=new v,l=()=>{for(;a.length>0&&n.length>0;){let u=a.shift(),f=n.shift();u({_tag:"Success",value:f});}for(;o.length>0&&n.length<t&&a.length===0;){let u=o.shift();n.push(u.a),u.cb(true);}for(;a.length>0&&o.length>0;){let u=a.shift(),f=o.shift();f.cb(true),u({_tag:"Success",value:f.a});}};return {size:()=>n.length,shutdown:()=>{if(!r){for(r=true;a.length>0;)a.shift()({_tag:"Failure",error:s});for(;o.length>0;)o.shift().cb(false);n.clear();}},offer:u=>i((f,i)=>{if(r){i({_tag:"Success",value:false});return}if(a.length>0){a.shift()({_tag:"Success",value:u}),i({_tag:"Success",value:true});return}if(n.length<t){n.push(u),i({_tag:"Success",value:true}),l();return}if(e==="dropping"){i({_tag:"Success",value:false});return}if(e==="sliding"){n.shift(),n.push(u),i({_tag:"Success",value:true}),l();return}let A=o.push({a:u,cb:m=>i({_tag:"Success",value:m})});return ()=>{o.remove(A);}}),take:()=>i((u,f)=>{if(n.length>0){let m=n.shift();f({_tag:"Success",value:m}),l();return}if(o.length>0){let m=o.shift();m.cb(true),f({_tag:"Success",value:m.a});return}if(r){f({_tag:"Failure",error:s});return}let i=m=>f(m),A=a.push(i);return ()=>{a.remove(A);}})}}function F(t,e$1,n="backpressure"){let r$1=false,s=null,o=null,a$1=t,l=()=>a(ha(a$1),i=>e(i._tag==="None"?{_tag:"End"}:{_tag:"Fail",error:i.value}),([i,A])=>g(()=>(a$1=A,{_tag:"Elem",value:i}))),p=i=>k(w(e$1,n),A=>{s=A;let S=()=>k(l(),m=>k(s.offer(m),()=>m._tag==="End"||m._tag==="Fail"?e(void 0):S()));return o=K(S(),i),r$1=true,e(void 0)}),u={_tag:"Async",register:(i,A)=>{(()=>{if(!r$1){K(p(i),i).join(()=>{f(i,A);});return}f(i,A);})();}};function f(i,A){let S=s.take();K(S,i).join(m=>{if(m._tag!=="Success")return;let _$1=m.value;switch(_$1._tag){case "Elem":A({_tag:"Success",value:[_$1.value,_(u)]});return;case "End":o?.interrupt?.(),A({_tag:"Failure",error:q});return;case "Fail":o?.interrupt?.(),A({_tag:"Failure",error:r(_$1.error)});return}});}return _(u)}var I=t=>t==="BackPressure"?"backpressure":t==="Dropping"?"dropping":"sliding";function N(t,e$1="BackPressure"){let n=new Set,r=false,s=p=>{if(r)return e(false);let u=Array.from(n),f=e(true);return u.forEach(i=>{f=k(f,A=>k(i.offer(p),S=>e(A&&S)));}),f};return {publish:s,publishAll:p=>{let u=e(true),f=p[Symbol.iterator]();for(;;){let i=f.next();if(i.done)break;let A=i.value;u=k(u,S=>k(s(A),m=>e(S&&m)));}return u},subscribe:()=>r?h(()=>{throw {_tag:"HubClosed"}}):k(w(t,I(e$1)),p=>g(()=>(n.add(p),{...p,unsubscribe:()=>{n.has(p)&&(n.delete(p),p.shutdown());}}))),shutdown:()=>g(()=>{r||(r=true,Array.from(n).forEach(p=>p.shutdown()),n.clear());})}}var yn=N;function dn(t,e$1){return ma(t,n=>k(e$1.publish(n),()=>e(void 0)))}function Rn(t){return aa(k(t.subscribe(),e$1=>{let n=_(k(c(e$1.take(),r=>q),r=>e([r,n])));return e({stream:n,release:r=>g(()=>e$1.unsubscribe())})}))}function _n(t,e){return e(t)}function z(t,e){return(n=>e(t(n)))}function Cn(t,e){return z(e,t)}function On(){return(t=>t)}function Pn(t){return(e$1=>{let n=r=>_(a(ha(r),s=>f(s),([s,o])=>e([t(s),n(o)])));return n(e$1)})}function Bn(t){return(e$1=>{let n=s=>a(ha(s),o=>f(o),([o,a])=>t(o)?e([o,r(a)]):n(a)),r=s=>_(n(s));return r(e$1)})}function Tn(t){return(e$1=>{let n=s=>a(ha(s),o=>f(o),([o,a])=>{let l=t(o);return l._tag==="Some"?e([l.value,r(a)]):n(a)}),r=s=>_(n(s));return r(e$1)})}function Hn(t){let e$1=Math.max(0,t|0);return(n=>{let r=(s,o)=>o<=0?ca():_(a(ha(s),a=>f(a),([a,l])=>e([a,r(l,o-1)])));return r(n,e$1)})}function Qn(t){let e=Math.max(0,t|0);return(n=>{let r=(s,o)=>o<=0?s:_(a(ha(s),a=>f(a),([a,l])=>ha(r(l,o-1))));return r(n,e)})}function D(t){return(e$1=>{let n=s=>c(s,o=>r(o)),r$1=s=>_(a(c(ha(s),o=>Z(o)),o=>f(o),([o,a$1])=>a(n(t(o)),l=>f(l),l=>e([l,r$1(a$1)]))));return r$1(e$1)})}function Fn(t){return D(e$1=>k(t(e$1),()=>e(e$1)))}function Mn(t,e="backpressure"){return(n=>F(n,t,e))}function In(t){let e$1=Math.max(1,t|0);return(n=>{let r=(o,a$1,l)=>a$1<=0?e({chunk:l,rest:o}):a(ha(o),p=>p._tag==="None"?e({chunk:l,rest:ca()}):f(p),([p,u])=>r(u,a$1-1,[...l,p])),s=o=>_(a(ha(o),a=>f(a),([a,l])=>k(r(l,e$1-1,[a]),({chunk:p,rest:u})=>e([p,s(u)]))));return s(n)})}export{v as LinkedQueue,z as andThen,w as bounded,yn as broadcast,dn as broadcastToHub,F as buffer,Mn as bufferP,Cn as compose,Qn as dropP,Tn as filterMapP,Bn as filterP,Rn as fromHub,In as groupedP,On as identity,De as linkAbortController,ze as makeCancelToken,N as makeHub,D as mapEffectP,Pn as mapP,Hn as takeP,Fn as tapEffectP,_n as via};
|
|
@@ -30,6 +30,120 @@ declare class Scheduler {
|
|
|
30
30
|
}
|
|
31
31
|
declare const globalScheduler: Scheduler;
|
|
32
32
|
|
|
33
|
+
type RuntimeEvent = {
|
|
34
|
+
type: "fiber.start";
|
|
35
|
+
fiberId: number;
|
|
36
|
+
parentFiberId?: number;
|
|
37
|
+
scopeId?: number;
|
|
38
|
+
name?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "fiber.end";
|
|
41
|
+
fiberId: number;
|
|
42
|
+
status: "success" | "failure" | "interrupted";
|
|
43
|
+
error?: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
type: "fiber.suspend";
|
|
46
|
+
fiberId: number;
|
|
47
|
+
reason?: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "fiber.resume";
|
|
50
|
+
fiberId: number;
|
|
51
|
+
} | {
|
|
52
|
+
type: "scope.open";
|
|
53
|
+
scopeId: number;
|
|
54
|
+
parentScopeId?: number;
|
|
55
|
+
} | {
|
|
56
|
+
type: "scope.close";
|
|
57
|
+
scopeId: number;
|
|
58
|
+
status: "success" | "failure" | "interrupted";
|
|
59
|
+
error?: unknown;
|
|
60
|
+
} | {
|
|
61
|
+
type: "log";
|
|
62
|
+
level: "debug" | "info" | "warn" | "error";
|
|
63
|
+
message: string;
|
|
64
|
+
fields?: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
interface RuntimeHooks {
|
|
67
|
+
emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void;
|
|
68
|
+
}
|
|
69
|
+
type RuntimeEmitContext = {
|
|
70
|
+
fiberId?: number;
|
|
71
|
+
scopeId?: number;
|
|
72
|
+
traceId?: string;
|
|
73
|
+
spanId?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
77
|
+
/**
|
|
78
|
+
* --- Runtime como objeto único (ZIO-style) ---
|
|
79
|
+
* Un valor que representa "cómo" se ejecutan los efectos: scheduler + environment + hooks.
|
|
80
|
+
*/
|
|
81
|
+
declare class Runtime<R> {
|
|
82
|
+
readonly env: R;
|
|
83
|
+
readonly scheduler: Scheduler;
|
|
84
|
+
readonly hooks: RuntimeHooks;
|
|
85
|
+
readonly forkPolicy: {
|
|
86
|
+
initChild(fiber: RuntimeFiber<any, any, any> & any, parent?: (RuntimeFiber<any, any, any> & any) | null): void;
|
|
87
|
+
};
|
|
88
|
+
constructor(args: {
|
|
89
|
+
env: R;
|
|
90
|
+
scheduler?: Scheduler;
|
|
91
|
+
hooks?: RuntimeHooks;
|
|
92
|
+
});
|
|
93
|
+
fork<E, A>(effect: Async<R, E, A>): Fiber<E, A>;
|
|
94
|
+
unsafeRunAsync<E, A>(effect: Async<R, E, A>, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
95
|
+
toPromise<E, A>(effect: Async<R, E, A>): Promise<A>;
|
|
96
|
+
log(level: "debug" | "info" | "warn" | "error", message: string, fields?: Record<string, unknown>): void;
|
|
97
|
+
withHooks(hooks: RuntimeHooks): Runtime<R>;
|
|
98
|
+
emit(ev: RuntimeEvent): void;
|
|
99
|
+
static make<R>(env: R, scheduler?: Scheduler): Runtime<R>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ---------------------------------------------------------------------------
|
|
103
|
+
* Helpers existentes (los dejo igual) + wrappers que usan Runtime por debajo
|
|
104
|
+
* ---------------------------------------------------------------------------
|
|
105
|
+
*/
|
|
106
|
+
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
107
|
+
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
108
|
+
type BrassError = {
|
|
109
|
+
_tag: "Abort";
|
|
110
|
+
} | {
|
|
111
|
+
_tag: "PromiseRejected";
|
|
112
|
+
reason: unknown;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* --- Wrappers legacy (mantienen tu API actual) ---
|
|
116
|
+
* Internamente crean un Runtime ad-hoc con env + scheduler.
|
|
117
|
+
*/
|
|
118
|
+
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
119
|
+
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
120
|
+
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
121
|
+
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
122
|
+
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
123
|
+
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
124
|
+
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
125
|
+
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
126
|
+
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
127
|
+
declare function getCurrentRuntime<R>(): Runtime<R>;
|
|
128
|
+
|
|
129
|
+
type JSONValue = null | boolean | number | string | JSONValue[] | {
|
|
130
|
+
[k: string]: JSONValue;
|
|
131
|
+
};
|
|
132
|
+
type ContextNode = {
|
|
133
|
+
parent: ContextNode | null;
|
|
134
|
+
patch: Record<string, JSONValue>;
|
|
135
|
+
};
|
|
136
|
+
type TraceContext = {
|
|
137
|
+
traceId: string;
|
|
138
|
+
spanId: string;
|
|
139
|
+
parentSpanId?: string;
|
|
140
|
+
sampled?: boolean;
|
|
141
|
+
};
|
|
142
|
+
type FiberContext = {
|
|
143
|
+
log: ContextNode;
|
|
144
|
+
trace: TraceContext | null;
|
|
145
|
+
};
|
|
146
|
+
|
|
33
147
|
type FiberId = number;
|
|
34
148
|
type Interrupted = {
|
|
35
149
|
readonly _tag: "Interrupted";
|
|
@@ -44,8 +158,8 @@ type Fiber<E, A> = {
|
|
|
44
158
|
readonly addFinalizer: (f: (exit: Exit<E | Interrupted, A>) => void) => void;
|
|
45
159
|
};
|
|
46
160
|
declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
47
|
-
private readonly scheduler;
|
|
48
161
|
readonly id: FiberId;
|
|
162
|
+
readonly runtime: Runtime<R>;
|
|
49
163
|
private closing;
|
|
50
164
|
private finishing;
|
|
51
165
|
private runState;
|
|
@@ -53,11 +167,15 @@ declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
|
53
167
|
private result;
|
|
54
168
|
private readonly joiners;
|
|
55
169
|
private current;
|
|
56
|
-
private readonly env;
|
|
57
170
|
private readonly stack;
|
|
58
171
|
private readonly fiberFinalizers;
|
|
59
172
|
private finalizersDrained;
|
|
60
|
-
|
|
173
|
+
fiberContext: FiberContext;
|
|
174
|
+
name?: string;
|
|
175
|
+
scopeId?: number;
|
|
176
|
+
constructor(runtime: Runtime<R>, effect: Async<R, E, A>);
|
|
177
|
+
private get env();
|
|
178
|
+
private get scheduler();
|
|
61
179
|
addFinalizer(f: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
62
180
|
status(): FiberStatus;
|
|
63
181
|
join(cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
@@ -69,34 +187,42 @@ declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
|
69
187
|
private onFailure;
|
|
70
188
|
step(): StepDecision;
|
|
71
189
|
}
|
|
190
|
+
declare function getCurrentFiber(): RuntimeFiber<any, any, any> | null;
|
|
191
|
+
declare function withCurrentFiber<T>(fiber: RuntimeFiber<any, any, any>, f: () => T): T;
|
|
72
192
|
|
|
73
193
|
type ScopeId = number;
|
|
74
194
|
type CloseOptions = {
|
|
75
195
|
awaitChildren?: boolean;
|
|
76
196
|
};
|
|
77
197
|
declare class Scope<R> {
|
|
78
|
-
private readonly
|
|
198
|
+
private readonly runtime;
|
|
79
199
|
readonly id: ScopeId;
|
|
80
200
|
private closed;
|
|
81
201
|
private readonly children;
|
|
82
202
|
private readonly subScopes;
|
|
83
203
|
private readonly finalizers;
|
|
84
|
-
constructor(
|
|
204
|
+
constructor(runtime: Runtime<R>);
|
|
205
|
+
/** Acceso al env del runtime (conserva tu modelo actual) */
|
|
206
|
+
private get env();
|
|
85
207
|
/** registra un finalizer (LIFO) */
|
|
86
208
|
addFinalizer(f: (exit: Exit<any, any>) => Async<R, any, any>): void;
|
|
87
|
-
/** crea un sub scope */
|
|
209
|
+
/** crea un sub scope (mismo runtime) */
|
|
88
210
|
subScope(): Scope<R>;
|
|
89
211
|
/** fork en este scope */
|
|
90
|
-
fork<E, A>(eff: Async<R, E, A
|
|
212
|
+
fork<E, A>(eff: Async<R, E, A>): Fiber<E | Interrupted, A>;
|
|
213
|
+
/** close fire-and-forget (no bloquea) */
|
|
91
214
|
close(exit?: Exit<any, any>): void;
|
|
92
215
|
closeAsync(exit?: Exit<any, any>, options?: CloseOptions): Async<R, never, void>;
|
|
93
216
|
}
|
|
94
217
|
/**
|
|
95
|
-
* Ejecuta una función dentro de un scope estructurado.
|
|
96
|
-
*
|
|
218
|
+
* Ejecuta una función dentro de un scope estructurado (sync).
|
|
219
|
+
* NOTA: En sync no tenés env real; por eso recibimos Runtime explícito.
|
|
220
|
+
*/
|
|
221
|
+
declare function withScope<R, A>(runtime: Runtime<R>, body: (scope: Scope<R>) => A): A;
|
|
222
|
+
/**
|
|
223
|
+
* Versión async: crea scope, corre el efecto, cierra el scope con el Exit.
|
|
97
224
|
*/
|
|
98
|
-
declare function
|
|
99
|
-
declare function withScopeAsync<R, E, A>(use: (scope: Scope<R>) => Async<R, E, A>): Async<R, E | Interrupted, A>;
|
|
225
|
+
declare function withScopeAsync<R, E, A>(runtime: Runtime<R>, use: (scope: Scope<R>) => Async<R, E, A>): Async<R, E | Interrupted, A>;
|
|
100
226
|
|
|
101
227
|
type Async<R, E, A> = {
|
|
102
228
|
_tag: "Succeed";
|
|
@@ -217,6 +343,7 @@ declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R,
|
|
|
217
343
|
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
218
344
|
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
219
345
|
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
346
|
+
declare function assertNever(x: never, msg?: string): never;
|
|
220
347
|
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
221
348
|
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
222
349
|
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
@@ -225,4 +352,4 @@ declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
|
225
352
|
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
226
353
|
declare function streamFromReadableStream<E>(body: ReadableStream<Uint8Array> | null | undefined, normalizeError: Normalize<E>): ZStream<unknown, E, Uint8Array>;
|
|
227
354
|
|
|
228
|
-
export { type
|
|
355
|
+
export { type FiberId as $, type Async as A, mapTryAsync as B, type Some as C, none as D, type Exit as E, type Fiber as F, some as G, type Canceler as H, type Interrupted as I, type CancelToken as J, makeCancelToken as K, linkAbortController as L, from as M, type None as N, type Option as O, type BrassError as P, fork as Q, Runtime as R, Scope as S, unsafeRunAsync as T, toPromise as U, fromPromise as V, fromCallback as W, tryPromiseAbortable as X, fromPromiseAbortable as Y, type ZStream as Z, getCurrentRuntime as _, type ZIO as a, type FiberStatus as a0, RuntimeFiber as a1, getCurrentFiber as a2, withCurrentFiber as a3, type ScopeId as a4, withScope as a5, withScopeAsync as a6, type Task as a7, Scheduler as a8, globalScheduler as a9, streamFromReadableStream as aA, type Empty as aa, type Emit as ab, type Concat as ac, type Flatten as ad, type FromPull as ae, type Merge as af, type Scoped as ag, type Normalize as ah, widenOpt as ai, fromPull as aj, unwrapScoped as ak, managedStream as al, mergeStream as am, emptyStream as an, emitStream as ao, concatStream as ap, flattenStream as aq, merge as ar, uncons as as, assertNever as at, mapStream as au, rangeStream as av, zip as aw, foreachStream as ax, fromArray as ay, collectStream as az, sync as b, flatMap as c, mapError as d, catchAll as e, fail as f, end as g, asyncFold as h, asyncCatchAll as i, asyncMapError as j, asyncSucceed as k, asyncFail as l, map as m, asyncSync as n, orElseOptional as o, asyncTotal as p, async as q, asyncMap as r, succeed as s, asyncFlatMap as t, unit as u, acquireRelease as v, asyncInterruptible as w, type AsyncWithPromise as x, withAsyncPromise as y, mapAsync as z };
|
|
@@ -30,6 +30,120 @@ declare class Scheduler {
|
|
|
30
30
|
}
|
|
31
31
|
declare const globalScheduler: Scheduler;
|
|
32
32
|
|
|
33
|
+
type RuntimeEvent = {
|
|
34
|
+
type: "fiber.start";
|
|
35
|
+
fiberId: number;
|
|
36
|
+
parentFiberId?: number;
|
|
37
|
+
scopeId?: number;
|
|
38
|
+
name?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "fiber.end";
|
|
41
|
+
fiberId: number;
|
|
42
|
+
status: "success" | "failure" | "interrupted";
|
|
43
|
+
error?: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
type: "fiber.suspend";
|
|
46
|
+
fiberId: number;
|
|
47
|
+
reason?: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "fiber.resume";
|
|
50
|
+
fiberId: number;
|
|
51
|
+
} | {
|
|
52
|
+
type: "scope.open";
|
|
53
|
+
scopeId: number;
|
|
54
|
+
parentScopeId?: number;
|
|
55
|
+
} | {
|
|
56
|
+
type: "scope.close";
|
|
57
|
+
scopeId: number;
|
|
58
|
+
status: "success" | "failure" | "interrupted";
|
|
59
|
+
error?: unknown;
|
|
60
|
+
} | {
|
|
61
|
+
type: "log";
|
|
62
|
+
level: "debug" | "info" | "warn" | "error";
|
|
63
|
+
message: string;
|
|
64
|
+
fields?: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
interface RuntimeHooks {
|
|
67
|
+
emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void;
|
|
68
|
+
}
|
|
69
|
+
type RuntimeEmitContext = {
|
|
70
|
+
fiberId?: number;
|
|
71
|
+
scopeId?: number;
|
|
72
|
+
traceId?: string;
|
|
73
|
+
spanId?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
77
|
+
/**
|
|
78
|
+
* --- Runtime como objeto único (ZIO-style) ---
|
|
79
|
+
* Un valor que representa "cómo" se ejecutan los efectos: scheduler + environment + hooks.
|
|
80
|
+
*/
|
|
81
|
+
declare class Runtime<R> {
|
|
82
|
+
readonly env: R;
|
|
83
|
+
readonly scheduler: Scheduler;
|
|
84
|
+
readonly hooks: RuntimeHooks;
|
|
85
|
+
readonly forkPolicy: {
|
|
86
|
+
initChild(fiber: RuntimeFiber<any, any, any> & any, parent?: (RuntimeFiber<any, any, any> & any) | null): void;
|
|
87
|
+
};
|
|
88
|
+
constructor(args: {
|
|
89
|
+
env: R;
|
|
90
|
+
scheduler?: Scheduler;
|
|
91
|
+
hooks?: RuntimeHooks;
|
|
92
|
+
});
|
|
93
|
+
fork<E, A>(effect: Async<R, E, A>): Fiber<E, A>;
|
|
94
|
+
unsafeRunAsync<E, A>(effect: Async<R, E, A>, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
95
|
+
toPromise<E, A>(effect: Async<R, E, A>): Promise<A>;
|
|
96
|
+
log(level: "debug" | "info" | "warn" | "error", message: string, fields?: Record<string, unknown>): void;
|
|
97
|
+
withHooks(hooks: RuntimeHooks): Runtime<R>;
|
|
98
|
+
emit(ev: RuntimeEvent): void;
|
|
99
|
+
static make<R>(env: R, scheduler?: Scheduler): Runtime<R>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ---------------------------------------------------------------------------
|
|
103
|
+
* Helpers existentes (los dejo igual) + wrappers que usan Runtime por debajo
|
|
104
|
+
* ---------------------------------------------------------------------------
|
|
105
|
+
*/
|
|
106
|
+
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
107
|
+
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
108
|
+
type BrassError = {
|
|
109
|
+
_tag: "Abort";
|
|
110
|
+
} | {
|
|
111
|
+
_tag: "PromiseRejected";
|
|
112
|
+
reason: unknown;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* --- Wrappers legacy (mantienen tu API actual) ---
|
|
116
|
+
* Internamente crean un Runtime ad-hoc con env + scheduler.
|
|
117
|
+
*/
|
|
118
|
+
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
119
|
+
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
120
|
+
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
121
|
+
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
122
|
+
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
123
|
+
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
124
|
+
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
125
|
+
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
126
|
+
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
127
|
+
declare function getCurrentRuntime<R>(): Runtime<R>;
|
|
128
|
+
|
|
129
|
+
type JSONValue = null | boolean | number | string | JSONValue[] | {
|
|
130
|
+
[k: string]: JSONValue;
|
|
131
|
+
};
|
|
132
|
+
type ContextNode = {
|
|
133
|
+
parent: ContextNode | null;
|
|
134
|
+
patch: Record<string, JSONValue>;
|
|
135
|
+
};
|
|
136
|
+
type TraceContext = {
|
|
137
|
+
traceId: string;
|
|
138
|
+
spanId: string;
|
|
139
|
+
parentSpanId?: string;
|
|
140
|
+
sampled?: boolean;
|
|
141
|
+
};
|
|
142
|
+
type FiberContext = {
|
|
143
|
+
log: ContextNode;
|
|
144
|
+
trace: TraceContext | null;
|
|
145
|
+
};
|
|
146
|
+
|
|
33
147
|
type FiberId = number;
|
|
34
148
|
type Interrupted = {
|
|
35
149
|
readonly _tag: "Interrupted";
|
|
@@ -44,8 +158,8 @@ type Fiber<E, A> = {
|
|
|
44
158
|
readonly addFinalizer: (f: (exit: Exit<E | Interrupted, A>) => void) => void;
|
|
45
159
|
};
|
|
46
160
|
declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
47
|
-
private readonly scheduler;
|
|
48
161
|
readonly id: FiberId;
|
|
162
|
+
readonly runtime: Runtime<R>;
|
|
49
163
|
private closing;
|
|
50
164
|
private finishing;
|
|
51
165
|
private runState;
|
|
@@ -53,11 +167,15 @@ declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
|
53
167
|
private result;
|
|
54
168
|
private readonly joiners;
|
|
55
169
|
private current;
|
|
56
|
-
private readonly env;
|
|
57
170
|
private readonly stack;
|
|
58
171
|
private readonly fiberFinalizers;
|
|
59
172
|
private finalizersDrained;
|
|
60
|
-
|
|
173
|
+
fiberContext: FiberContext;
|
|
174
|
+
name?: string;
|
|
175
|
+
scopeId?: number;
|
|
176
|
+
constructor(runtime: Runtime<R>, effect: Async<R, E, A>);
|
|
177
|
+
private get env();
|
|
178
|
+
private get scheduler();
|
|
61
179
|
addFinalizer(f: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
62
180
|
status(): FiberStatus;
|
|
63
181
|
join(cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
@@ -69,34 +187,42 @@ declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
|
69
187
|
private onFailure;
|
|
70
188
|
step(): StepDecision;
|
|
71
189
|
}
|
|
190
|
+
declare function getCurrentFiber(): RuntimeFiber<any, any, any> | null;
|
|
191
|
+
declare function withCurrentFiber<T>(fiber: RuntimeFiber<any, any, any>, f: () => T): T;
|
|
72
192
|
|
|
73
193
|
type ScopeId = number;
|
|
74
194
|
type CloseOptions = {
|
|
75
195
|
awaitChildren?: boolean;
|
|
76
196
|
};
|
|
77
197
|
declare class Scope<R> {
|
|
78
|
-
private readonly
|
|
198
|
+
private readonly runtime;
|
|
79
199
|
readonly id: ScopeId;
|
|
80
200
|
private closed;
|
|
81
201
|
private readonly children;
|
|
82
202
|
private readonly subScopes;
|
|
83
203
|
private readonly finalizers;
|
|
84
|
-
constructor(
|
|
204
|
+
constructor(runtime: Runtime<R>);
|
|
205
|
+
/** Acceso al env del runtime (conserva tu modelo actual) */
|
|
206
|
+
private get env();
|
|
85
207
|
/** registra un finalizer (LIFO) */
|
|
86
208
|
addFinalizer(f: (exit: Exit<any, any>) => Async<R, any, any>): void;
|
|
87
|
-
/** crea un sub scope */
|
|
209
|
+
/** crea un sub scope (mismo runtime) */
|
|
88
210
|
subScope(): Scope<R>;
|
|
89
211
|
/** fork en este scope */
|
|
90
|
-
fork<E, A>(eff: Async<R, E, A
|
|
212
|
+
fork<E, A>(eff: Async<R, E, A>): Fiber<E | Interrupted, A>;
|
|
213
|
+
/** close fire-and-forget (no bloquea) */
|
|
91
214
|
close(exit?: Exit<any, any>): void;
|
|
92
215
|
closeAsync(exit?: Exit<any, any>, options?: CloseOptions): Async<R, never, void>;
|
|
93
216
|
}
|
|
94
217
|
/**
|
|
95
|
-
* Ejecuta una función dentro de un scope estructurado.
|
|
96
|
-
*
|
|
218
|
+
* Ejecuta una función dentro de un scope estructurado (sync).
|
|
219
|
+
* NOTA: En sync no tenés env real; por eso recibimos Runtime explícito.
|
|
220
|
+
*/
|
|
221
|
+
declare function withScope<R, A>(runtime: Runtime<R>, body: (scope: Scope<R>) => A): A;
|
|
222
|
+
/**
|
|
223
|
+
* Versión async: crea scope, corre el efecto, cierra el scope con el Exit.
|
|
97
224
|
*/
|
|
98
|
-
declare function
|
|
99
|
-
declare function withScopeAsync<R, E, A>(use: (scope: Scope<R>) => Async<R, E, A>): Async<R, E | Interrupted, A>;
|
|
225
|
+
declare function withScopeAsync<R, E, A>(runtime: Runtime<R>, use: (scope: Scope<R>) => Async<R, E, A>): Async<R, E | Interrupted, A>;
|
|
100
226
|
|
|
101
227
|
type Async<R, E, A> = {
|
|
102
228
|
_tag: "Succeed";
|
|
@@ -217,6 +343,7 @@ declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R,
|
|
|
217
343
|
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
218
344
|
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
219
345
|
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
346
|
+
declare function assertNever(x: never, msg?: string): never;
|
|
220
347
|
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
221
348
|
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
222
349
|
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
@@ -225,4 +352,4 @@ declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
|
225
352
|
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
226
353
|
declare function streamFromReadableStream<E>(body: ReadableStream<Uint8Array> | null | undefined, normalizeError: Normalize<E>): ZStream<unknown, E, Uint8Array>;
|
|
227
354
|
|
|
228
|
-
export { type
|
|
355
|
+
export { type FiberId as $, type Async as A, mapTryAsync as B, type Some as C, none as D, type Exit as E, type Fiber as F, some as G, type Canceler as H, type Interrupted as I, type CancelToken as J, makeCancelToken as K, linkAbortController as L, from as M, type None as N, type Option as O, type BrassError as P, fork as Q, Runtime as R, Scope as S, unsafeRunAsync as T, toPromise as U, fromPromise as V, fromCallback as W, tryPromiseAbortable as X, fromPromiseAbortable as Y, type ZStream as Z, getCurrentRuntime as _, type ZIO as a, type FiberStatus as a0, RuntimeFiber as a1, getCurrentFiber as a2, withCurrentFiber as a3, type ScopeId as a4, withScope as a5, withScopeAsync as a6, type Task as a7, Scheduler as a8, globalScheduler as a9, streamFromReadableStream as aA, type Empty as aa, type Emit as ab, type Concat as ac, type Flatten as ad, type FromPull as ae, type Merge as af, type Scoped as ag, type Normalize as ah, widenOpt as ai, fromPull as aj, unwrapScoped as ak, managedStream as al, mergeStream as am, emptyStream as an, emitStream as ao, concatStream as ap, flattenStream as aq, merge as ar, uncons as as, assertNever as at, mapStream as au, rangeStream as av, zip as aw, foreachStream as ax, fromArray as ay, collectStream as az, sync as b, flatMap as c, mapError as d, catchAll as e, fail as f, end as g, asyncFold as h, asyncCatchAll as i, asyncMapError as j, asyncSucceed as k, asyncFail as l, map as m, asyncSync as n, orElseOptional as o, asyncTotal as p, async as q, asyncMap as r, succeed as s, asyncFlatMap as t, unit as u, acquireRelease as v, asyncInterruptible as w, type AsyncWithPromise as x, withAsyncPromise as y, mapAsync as z };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brass-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Effect runtime utilities for TypeScript",
|
|
5
|
-
"license": "
|
|
6
|
-
"author": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Augusto Vivaldelli",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -66,5 +66,13 @@
|
|
|
66
66
|
"tsup": "^8.5.1",
|
|
67
67
|
"tsx": "^4.21.0",
|
|
68
68
|
"typescript": "^5.9.3"
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "git+https://github.com/BaldrVivaldelli/brass-runtime.git"
|
|
73
|
+
},
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/BaldrVivaldelli/brass-runtime/issues"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://github.com/BaldrVivaldelli/brass-runtime#readme"
|
|
70
78
|
}
|
package/dist/chunk-5UEH74EX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function R(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function Ae(t,e){return R(t,n=>e(n),n=>E(n))}function x(t,e){return R(t,n=>h(e(n)),n=>E(n))}var k=()=>E(void 0),E=t=>({_tag:"Succeed",value:t}),h=t=>({_tag:"Fail",error:t}),F=t=>({_tag:"Sync",thunk:t}),Ee=t=>F(()=>t()),A=t=>({_tag:"Async",register:t});function W(t,e){return p(t,n=>E(e(n)))}function p(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function pe(t,e,n){return p(t,r=>(n.addFinalizer(a=>e(r,a)),E(r)))}function ye(t){return A(t)}var de=t=>e=>{let n=e;return n.toPromise||(n.toPromise=r=>t(e,r),n.unsafeRunPromise=()=>t(e,{})),n},Re=(t,e)=>p(t,n=>E(e(n))),fe=(t,e)=>p(t,n=>F(()=>e(n)));var b={_tag:"None"},I=t=>({_tag:"Some",value:t});var z=t=>E(t),B=t=>h(t),H=t=>F(e=>t(e)),Z=(t,e)=>W(t,e),G=(t,e)=>p(t,n=>e(n)),M=(t,e)=>x(t,e),ve=(t,e)=>R(t,n=>e(n),n=>E(n));function U(t,e){return R(t,n=>n._tag==="Some"?h(n):e(),n=>E(n))}var xe=()=>B(b);var P=class{buf;head=0;tail=0;size_=0;constructor(e=1024){let n=Math.max(2,this.nextPow2(e));this.buf=new Array(n);}get length(){return this.size_}get capacity(){return this.buf.length}isEmpty(){return this.size_===0}push(e){this.size_===this.buf.length&&this.grow(),this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++;}shift(){if(this.size_===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=this.head+1&this.buf.length-1,this.size_--,e}clear(){this.buf.fill(void 0),this.head=0,this.tail=0,this.size_=0;}grow(){let e=this.buf,n=new Array(e.length*2);for(let r=0;r<this.size_;r++)n[r]=e[this.head+r&e.length-1];this.buf=n,this.head=0,this.tail=this.size_;}nextPow2(e){let n=1;for(;n<e;)n<<=1;return n}};var Q=2048,$=4096,Y=(()=>{if(typeof globalThis.setImmediate=="function")return t=>globalThis.setImmediate(t);if(typeof globalThis.MessageChannel=="function"){let t=new globalThis.MessageChannel,e=null;return t.port1.onmessage=()=>{let n=e;e=null,n?.();},n=>{e=n,t.port2.postMessage(0);}}return t=>setTimeout(t,0)})(),j=class{queue=new P(1024);flushing=false;scheduled=false;schedule(e,n="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:n,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>$?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):Y(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<Q;){let n=this.queue.shift();if(!n)break;e++;try{n.task();}catch(r){console.error(`[Scheduler] task threw (tag=${n.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let n=e>=Q||this.queue.length>$?"macro":"micro";this.requestFlush(n);}}}},J=new j;var m={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},g={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},ee=1,te=1024;function ne(t){let e=t;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let n=e.first,r=e.andThen;e={_tag:"FlatMap",first:n.first,andThen:a=>({_tag:"FlatMap",first:n.andThen(a),andThen:r})};}return e}var N=class{constructor(e,n,r){this.scheduler=r;this.id=ee++,this.current=e,this.env=n;}id;closing=null;finishing=false;runState=g.RUNNING;interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];finalizersDrained=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){this.runState===g.DONE||this.runState===g.QUEUED||(this.runState=g.QUEUED,this.scheduler.schedule(()=>{if(this.runState===g.DONE)return;switch(this.runState=g.RUNNING,this.step()){case m.CONTINUE:this.schedule("continue");return;case m.SUSPEND:this.runState=g.SUSPENDED;return;case m.DONE:this.runState=g.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let n=this.fiberFinalizers.pop();try{n(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let n of this.joiners)n(e);this.joiners.length=0;}}onSuccess(e){let n=this.stack.pop();if(!n){this.notify({_tag:"Success",value:e});return}this.current=n._tag==="SuccessCont"?n.k(e):n.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let n=this.stack.pop();if(n._tag==="FoldCont"){this.current=n.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=te;for(;e-- >0;){if(this.result!=null)return m.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),m.DONE;let n=ne(this.current);switch(n._tag){case "Succeed":{this.onSuccess(n.value);break}case "Fail":{this.onFailure(n.error);break}case "Sync":{try{let r=n.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:n.andThen}),this.current=n.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:n.onFailure,onSuccess:n.onSuccess}),this.current=n.first;break}case "Async":{if(this.finishing)return this.result!=null?m.DONE:m.CONTINUE;let r=false,a=i=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=i._tag==="Success"?{_tag:"Succeed",value:i.value}:{_tag:"Fail",error:i.error},this.schedule("async-resume")));},o=n.register(this.env,a);return typeof o=="function"&&this.addFinalizer(()=>{r=true;try{o();}catch{}}),m.SUSPEND}}}return this.result!=null?m.DONE:m.CONTINUE}};function De(t){return A((e,n)=>{let r=false,a=s=>{r||(r=true,n(s));},o=s=>a({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),i=s=>a({_tag:"Success",value:s});try{typeof t=="function"&&t.length>=1?t((s,c)=>s?o(s):i(c)):t().then(i,o);}catch(s){o(s);}})}function w(t,e,n=J){let r=new N(t,e,n);return r.schedule("initial-step"),r}function Te(t,e,n){w(t,e).join(n);}function ze(t,e){return new Promise((n,r)=>{w(t,e).join(o=>{let i=o;i._tag==="Success"?n(i.value):r(i.error);});})}function Me(t,e){return A((n,r)=>{t(n).then(a=>r({_tag:"Success",value:a})).catch(a=>r({_tag:"Failure",error:e(a)}));})}function Ue(t){return A((e,n)=>{let r=false,a=o=>{r||(r=true,n(o));};try{t((o,i)=>{a(o?{_tag:"Failure",error:o}:{_tag:"Success",value:i});});}catch(o){a({_tag:"Failure",error:o instanceof Error?o:new Error(String(o))});}})}function je(t){return re((n,r)=>t.length===1?t(r):t(n,r),n=>ae(n)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:n})}function re(t,e){return A((n,r)=>{let a=new AbortController,o=false,i=s=>{o||(o=true,r(s));};try{(t.length===1?t(a.signal):t(n,a.signal)).then(c=>i({_tag:"Success",value:c})).catch(c=>i({_tag:"Failure",error:e(c)}));}catch(s){i({_tag:"Failure",error:e(s)});}return ()=>{o=true,a.abort();}})}var ae=t=>typeof t=="object"&&t!==null&&"name"in t&&t.name==="AbortError";var oe=1;function se(t){return A((e,n)=>{let r=t.length;if(r===0){n({_tag:"Success",value:void 0});return}for(let a of t)a.join(()=>{r-=1,r===0&&n({_tag:"Success",value:void 0});});})}function ie(t){return R(t,()=>k(),()=>k())}var _=class t{constructor(e){this.env=e;this.id=oe++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(e){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(e);}subScope(){if(this.closed)throw new Error("Scope closed");let e=new t(this.env);return this.subScopes.add(e),e}fork(e,n){if(this.closed)throw new Error("Scope closed");let r=w(e,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(e={_tag:"Success",value:void 0}){w(this.closeAsync(e),this.env);}closeAsync(e={_tag:"Success",value:void 0},n={}){return A((r,a)=>{if(this.closed){a({_tag:"Success",value:void 0});return}this.closed=true;let o=Array.from(this.children),i=Array.from(this.subScopes);this.children.clear(),this.subScopes.clear();for(let l of o)try{l.interrupt();}catch{}let s=k();for(let l of i)s=p(s,()=>l.closeAsync(e,n));for(;this.finalizers.length>0;){let l=this.finalizers.pop();s=p(s,()=>ie(l(e)));}n.awaitChildren&&(s=p(s,()=>se(o))),w(s,this.env).join(()=>a({_tag:"Success",value:void 0}));})}};function Ge(t){let e=new _({});try{return t(e)}finally{e.close();}}function Qe(t){return A((e,n)=>{let r=new _(e);r.fork(t(r),e).join(o=>{try{r.close(o);}catch(i){n({_tag:"Failure",error:i});return}n(o);});})}function Ve(t,e,n){return A((r,a)=>{let o=n.subScope(),i=false,s=f=>{i||(i=true,o.close(f),a(f));},c=o.fork(t,r),l=o.fork(e,r);c.join(s),l.join(s);})}function Xe(t,e,n){return A((r,a)=>{let o=n.subScope(),i=null,s=null,c=false,l=()=>{if(!i||!s||c)return;if(c=true,i._tag==="Success"&&s._tag==="Success"){o.close({_tag:"Success",value:void 0}),a({_tag:"Success",value:[i.value,s.value]});return}let u;if(i._tag==="Failure")u=i.error;else if(s._tag==="Failure")u=s.error;else throw new Error("zipPar: unreachable state (no Failure exit)");let S={_tag:"Failure",error:u};o.close(S),a(S);},f=o.fork(t,r),d=o.fork(e,r);f.join(u=>{i=u,l();}),d.join(u=>{s=u,l();});})}function Ye(t,e){return A((n,r)=>{let a=e.subScope(),o=new Array(t.length),i=0,s=false;t.forEach((c,l)=>{a.fork(c,n).join(d=>{if(!s){if(d._tag==="Failure"){s=true;let u={_tag:"Failure",error:d.error};a.close(u),r(u);return}if(o[l]=d.value,i++,i===t.length){s=true;let u={_tag:"Success",value:o};a.close({_tag:"Success",value:void 0}),r(u);}}});});})}function K(t,e,n,r,a){return A((o,i)=>{let s=n.subScope(),c=false,l=s.fork(t,o),f=s.fork(e,o),d=u=>{s.fork(u,o).join(S=>{s.close(S),i(S);});};l.join(u=>{c||(c=true,d(r(u,f,s)));}),f.join(u=>{c||(c=true,d(a(u,l,s)));});})}var q=t=>t._tag==="None"?b:I(t.value),v=t=>({_tag:"FromPull",pull:t}),ce=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),At=t=>({_tag:"Scoped",acquire:p(t,e=>E(e.stream)),release:e=>p(t,n=>n.release(e))}),Et=(t,e,n=true)=>({_tag:"Merge",left:t,right:e,flip:n}),T=()=>({_tag:"Empty"}),X=t=>({_tag:"Emit",value:t}),C=(t,e)=>({_tag:"Concat",left:t,right:e}),L=t=>({_tag:"Flatten",stream:t});function V(t,e,n,r,a){return (o,i,s)=>{if(o._tag,o._tag,o._tag==="Success"){let[f,d]=o.value;i.interrupt();let u=v(t==="L"?D(d,n):D(e,d));return E([f,u])}let c=o.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return h(c);let l=c;return l._tag==="None"?y(t==="L"?n:e):h(l)}}function D(t,e,n,r){return A((a,o)=>{let s=new _(a),c=y(t),l=y(e),f=V("L",t,e),d=V("R",t,e),u=K(c,l,s,f,d);s.fork(u,a).join(S=>{s.close(S),o(S);});})}function pt(t,e){return v(D(t,e))}function y(t){switch(t._tag){case "Empty":return B(b);case "Emit":return Z(M(t.value,e=>I(e)),e=>[e,T()]);case "FromPull":return t.pull;case "Concat":return U(Z(y(t.left),([e,n])=>[e,C(n,t.right)]),()=>y(t.right));case "Flatten":return G(y(t.stream),([e,n])=>U(Z(y(e),([r,a])=>[r,C(a,L(n))]),()=>y(L(n))));case "Merge":return D(t.left,t.right,t.flip);case "Scoped":return A((e,n)=>{let r=new _(e);r.addFinalizer(a=>t.release(a)),r.fork(t.acquire,e).join(a=>{if(a._tag==="Failure"){r.close(a),n({_tag:"Failure",error:I(a.error)});return}let o=a.value;y(o)(e,s=>{r.close(s),n(s);});});})}}function O(t,e){switch(t._tag){case "Empty":return T();case "Emit":return X(Z(t.value,e));case "FromPull":return v(Z(t.pull,([n,r])=>[e(n),O(r,e)]));case "Concat":return C(O(t.left,e),O(t.right,e));case "Flatten":{let n=O(t.stream,r=>O(r,e));return L(n)}}}function yt(t,e){let n=r=>v(r>e?h(b):E([r,n(r+1)]));return n(t)}function ue(t,e){let n=R(x(y(t),r=>q(r)),r=>h(r),([r,a])=>R(x(y(e),o=>q(o)),o=>h(o),([o,i])=>E([[r,o],ue(a,i)])));return v(n)}function dt(t,e){let n=r=>R(x(y(r),a=>q(a)),a=>a._tag==="None"?E(void 0):h(a),([a,o])=>p(x(e(a),i=>I(i)),()=>n(o)));return R(n(t),r=>r._tag==="None"?E(void 0):h(r.value),()=>E(void 0))}function Rt(t){let e=T();for(let n=t.length-1;n>=0;n--){let r=X(z(t[n]));e=C(r,e);}return e}function ft(t){let e=(n,r)=>R(y(n),a=>a._tag==="None"?z(r):B(a),([a,o])=>e(o,[...r,a]));return M(e(t,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}function le(t,e){let n=A((r,a)=>{t.read().then(({done:o,value:i})=>{if(o){a({_tag:"Failure",error:b});return}a({_tag:"Success",value:[i,v(n)]});}).catch(o=>{a({_tag:"Failure",error:I(e(o))});});});return v(n)}function ht(t,e){if(!t)return T();let n;return ce(H(()=>(n=t.getReader(),le(n,e))),()=>F(()=>{try{n?.cancel();}catch{}}))}export{C as $,xe as A,P as B,j as C,J as D,N as E,De as F,w as G,Te as H,ze as I,Me as J,Ue as K,je as L,re as M,_ as N,Ge as O,Qe as P,Ve as Q,Xe as R,Ye as S,K as T,q as U,v as V,ce as W,At as X,Et as Y,T as Z,X as _,R as a,L as aa,Ae as b,pt as ba,x as c,y as ca,k as d,O as da,E as e,yt as ea,h as f,ue as fa,F as g,dt as ga,Ee as h,Rt as ha,A as i,ft as ia,W as j,ht as ja,p as k,pe as l,ye as m,de as n,Re as o,fe as p,b as q,I as r,z as s,B as t,H as u,Z as v,G as w,M as x,ve as y,U as z};
|
package/dist/chunk-KMTKZ4PS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';function R(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function Ae(t,e){return R(t,n=>e(n),n=>E(n))}function x(t,e){return R(t,n=>h(e(n)),n=>E(n))}var k=()=>E(void 0),E=t=>({_tag:"Succeed",value:t}),h=t=>({_tag:"Fail",error:t}),F=t=>({_tag:"Sync",thunk:t}),Ee=t=>F(()=>t()),A=t=>({_tag:"Async",register:t});function W(t,e){return p(t,n=>E(e(n)))}function p(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function pe(t,e,n){return p(t,r=>(n.addFinalizer(a=>e(r,a)),E(r)))}function ye(t){return A(t)}var de=t=>e=>{let n=e;return n.toPromise||(n.toPromise=r=>t(e,r),n.unsafeRunPromise=()=>t(e,{})),n},Re=(t,e)=>p(t,n=>E(e(n))),fe=(t,e)=>p(t,n=>F(()=>e(n)));var b={_tag:"None"},I=t=>({_tag:"Some",value:t});var z=t=>E(t),B=t=>h(t),H=t=>F(e=>t(e)),Z=(t,e)=>W(t,e),G=(t,e)=>p(t,n=>e(n)),M=(t,e)=>x(t,e),ve=(t,e)=>R(t,n=>e(n),n=>E(n));function U(t,e){return R(t,n=>n._tag==="Some"?h(n):e(),n=>E(n))}var xe=()=>B(b);var P=class{buf;head=0;tail=0;size_=0;constructor(e=1024){let n=Math.max(2,this.nextPow2(e));this.buf=new Array(n);}get length(){return this.size_}get capacity(){return this.buf.length}isEmpty(){return this.size_===0}push(e){this.size_===this.buf.length&&this.grow(),this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++;}shift(){if(this.size_===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=this.head+1&this.buf.length-1,this.size_--,e}clear(){this.buf.fill(void 0),this.head=0,this.tail=0,this.size_=0;}grow(){let e=this.buf,n=new Array(e.length*2);for(let r=0;r<this.size_;r++)n[r]=e[this.head+r&e.length-1];this.buf=n,this.head=0,this.tail=this.size_;}nextPow2(e){let n=1;for(;n<e;)n<<=1;return n}};var Q=2048,$=4096,Y=(()=>{if(typeof globalThis.setImmediate=="function")return t=>globalThis.setImmediate(t);if(typeof globalThis.MessageChannel=="function"){let t=new globalThis.MessageChannel,e=null;return t.port1.onmessage=()=>{let n=e;e=null,n?.();},n=>{e=n,t.port2.postMessage(0);}}return t=>setTimeout(t,0)})(),j=class{queue=new P(1024);flushing=false;scheduled=false;schedule(e,n="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:n,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>$?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):Y(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<Q;){let n=this.queue.shift();if(!n)break;e++;try{n.task();}catch(r){console.error(`[Scheduler] task threw (tag=${n.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let n=e>=Q||this.queue.length>$?"macro":"micro";this.requestFlush(n);}}}},J=new j;var m={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},g={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},ee=1,te=1024;function ne(t){let e=t;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let n=e.first,r=e.andThen;e={_tag:"FlatMap",first:n.first,andThen:a=>({_tag:"FlatMap",first:n.andThen(a),andThen:r})};}return e}var N=class{constructor(e,n,r){this.scheduler=r;this.id=ee++,this.current=e,this.env=n;}id;closing=null;finishing=false;runState=g.RUNNING;interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];finalizersDrained=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){this.runState===g.DONE||this.runState===g.QUEUED||(this.runState=g.QUEUED,this.scheduler.schedule(()=>{if(this.runState===g.DONE)return;switch(this.runState=g.RUNNING,this.step()){case m.CONTINUE:this.schedule("continue");return;case m.SUSPEND:this.runState=g.SUSPENDED;return;case m.DONE:this.runState=g.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let n=this.fiberFinalizers.pop();try{n(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let n of this.joiners)n(e);this.joiners.length=0;}}onSuccess(e){let n=this.stack.pop();if(!n){this.notify({_tag:"Success",value:e});return}this.current=n._tag==="SuccessCont"?n.k(e):n.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let n=this.stack.pop();if(n._tag==="FoldCont"){this.current=n.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=te;for(;e-- >0;){if(this.result!=null)return m.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),m.DONE;let n=ne(this.current);switch(n._tag){case "Succeed":{this.onSuccess(n.value);break}case "Fail":{this.onFailure(n.error);break}case "Sync":{try{let r=n.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:n.andThen}),this.current=n.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:n.onFailure,onSuccess:n.onSuccess}),this.current=n.first;break}case "Async":{if(this.finishing)return this.result!=null?m.DONE:m.CONTINUE;let r=false,a=i=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=i._tag==="Success"?{_tag:"Succeed",value:i.value}:{_tag:"Fail",error:i.error},this.schedule("async-resume")));},o=n.register(this.env,a);return typeof o=="function"&&this.addFinalizer(()=>{r=true;try{o();}catch{}}),m.SUSPEND}}}return this.result!=null?m.DONE:m.CONTINUE}};function De(t){return A((e,n)=>{let r=false,a=s=>{r||(r=true,n(s));},o=s=>a({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),i=s=>a({_tag:"Success",value:s});try{typeof t=="function"&&t.length>=1?t((s,c)=>s?o(s):i(c)):t().then(i,o);}catch(s){o(s);}})}function w(t,e,n=J){let r=new N(t,e,n);return r.schedule("initial-step"),r}function Te(t,e,n){w(t,e).join(n);}function ze(t,e){return new Promise((n,r)=>{w(t,e).join(o=>{let i=o;i._tag==="Success"?n(i.value):r(i.error);});})}function Me(t,e){return A((n,r)=>{t(n).then(a=>r({_tag:"Success",value:a})).catch(a=>r({_tag:"Failure",error:e(a)}));})}function Ue(t){return A((e,n)=>{let r=false,a=o=>{r||(r=true,n(o));};try{t((o,i)=>{a(o?{_tag:"Failure",error:o}:{_tag:"Success",value:i});});}catch(o){a({_tag:"Failure",error:o instanceof Error?o:new Error(String(o))});}})}function je(t){return re((n,r)=>t.length===1?t(r):t(n,r),n=>ae(n)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:n})}function re(t,e){return A((n,r)=>{let a=new AbortController,o=false,i=s=>{o||(o=true,r(s));};try{(t.length===1?t(a.signal):t(n,a.signal)).then(c=>i({_tag:"Success",value:c})).catch(c=>i({_tag:"Failure",error:e(c)}));}catch(s){i({_tag:"Failure",error:e(s)});}return ()=>{o=true,a.abort();}})}var ae=t=>typeof t=="object"&&t!==null&&"name"in t&&t.name==="AbortError";var oe=1;function se(t){return A((e,n)=>{let r=t.length;if(r===0){n({_tag:"Success",value:void 0});return}for(let a of t)a.join(()=>{r-=1,r===0&&n({_tag:"Success",value:void 0});});})}function ie(t){return R(t,()=>k(),()=>k())}var _=class t{constructor(e){this.env=e;this.id=oe++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(e){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(e);}subScope(){if(this.closed)throw new Error("Scope closed");let e=new t(this.env);return this.subScopes.add(e),e}fork(e,n){if(this.closed)throw new Error("Scope closed");let r=w(e,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(e={_tag:"Success",value:void 0}){w(this.closeAsync(e),this.env);}closeAsync(e={_tag:"Success",value:void 0},n={}){return A((r,a)=>{if(this.closed){a({_tag:"Success",value:void 0});return}this.closed=true;let o=Array.from(this.children),i=Array.from(this.subScopes);this.children.clear(),this.subScopes.clear();for(let l of o)try{l.interrupt();}catch{}let s=k();for(let l of i)s=p(s,()=>l.closeAsync(e,n));for(;this.finalizers.length>0;){let l=this.finalizers.pop();s=p(s,()=>ie(l(e)));}n.awaitChildren&&(s=p(s,()=>se(o))),w(s,this.env).join(()=>a({_tag:"Success",value:void 0}));})}};function Ge(t){let e=new _({});try{return t(e)}finally{e.close();}}function Qe(t){return A((e,n)=>{let r=new _(e);r.fork(t(r),e).join(o=>{try{r.close(o);}catch(i){n({_tag:"Failure",error:i});return}n(o);});})}function Ve(t,e,n){return A((r,a)=>{let o=n.subScope(),i=false,s=f=>{i||(i=true,o.close(f),a(f));},c=o.fork(t,r),l=o.fork(e,r);c.join(s),l.join(s);})}function Xe(t,e,n){return A((r,a)=>{let o=n.subScope(),i=null,s=null,c=false,l=()=>{if(!i||!s||c)return;if(c=true,i._tag==="Success"&&s._tag==="Success"){o.close({_tag:"Success",value:void 0}),a({_tag:"Success",value:[i.value,s.value]});return}let u;if(i._tag==="Failure")u=i.error;else if(s._tag==="Failure")u=s.error;else throw new Error("zipPar: unreachable state (no Failure exit)");let S={_tag:"Failure",error:u};o.close(S),a(S);},f=o.fork(t,r),d=o.fork(e,r);f.join(u=>{i=u,l();}),d.join(u=>{s=u,l();});})}function Ye(t,e){return A((n,r)=>{let a=e.subScope(),o=new Array(t.length),i=0,s=false;t.forEach((c,l)=>{a.fork(c,n).join(d=>{if(!s){if(d._tag==="Failure"){s=true;let u={_tag:"Failure",error:d.error};a.close(u),r(u);return}if(o[l]=d.value,i++,i===t.length){s=true;let u={_tag:"Success",value:o};a.close({_tag:"Success",value:void 0}),r(u);}}});});})}function K(t,e,n,r,a){return A((o,i)=>{let s=n.subScope(),c=false,l=s.fork(t,o),f=s.fork(e,o),d=u=>{s.fork(u,o).join(S=>{s.close(S),i(S);});};l.join(u=>{c||(c=true,d(r(u,f,s)));}),f.join(u=>{c||(c=true,d(a(u,l,s)));});})}var q=t=>t._tag==="None"?b:I(t.value),v=t=>({_tag:"FromPull",pull:t}),ce=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),At=t=>({_tag:"Scoped",acquire:p(t,e=>E(e.stream)),release:e=>p(t,n=>n.release(e))}),Et=(t,e,n=true)=>({_tag:"Merge",left:t,right:e,flip:n}),T=()=>({_tag:"Empty"}),X=t=>({_tag:"Emit",value:t}),C=(t,e)=>({_tag:"Concat",left:t,right:e}),L=t=>({_tag:"Flatten",stream:t});function V(t,e,n,r,a){return (o,i,s)=>{if(o._tag,o._tag,o._tag==="Success"){let[f,d]=o.value;i.interrupt();let u=v(t==="L"?D(d,n):D(e,d));return E([f,u])}let c=o.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return h(c);let l=c;return l._tag==="None"?y(t==="L"?n:e):h(l)}}function D(t,e,n,r){return A((a,o)=>{let s=new _(a),c=y(t),l=y(e),f=V("L",t,e),d=V("R",t,e),u=K(c,l,s,f,d);s.fork(u,a).join(S=>{s.close(S),o(S);});})}function pt(t,e){return v(D(t,e))}function y(t){switch(t._tag){case "Empty":return B(b);case "Emit":return Z(M(t.value,e=>I(e)),e=>[e,T()]);case "FromPull":return t.pull;case "Concat":return U(Z(y(t.left),([e,n])=>[e,C(n,t.right)]),()=>y(t.right));case "Flatten":return G(y(t.stream),([e,n])=>U(Z(y(e),([r,a])=>[r,C(a,L(n))]),()=>y(L(n))));case "Merge":return D(t.left,t.right,t.flip);case "Scoped":return A((e,n)=>{let r=new _(e);r.addFinalizer(a=>t.release(a)),r.fork(t.acquire,e).join(a=>{if(a._tag==="Failure"){r.close(a),n({_tag:"Failure",error:I(a.error)});return}let o=a.value;y(o)(e,s=>{r.close(s),n(s);});});})}}function O(t,e){switch(t._tag){case "Empty":return T();case "Emit":return X(Z(t.value,e));case "FromPull":return v(Z(t.pull,([n,r])=>[e(n),O(r,e)]));case "Concat":return C(O(t.left,e),O(t.right,e));case "Flatten":{let n=O(t.stream,r=>O(r,e));return L(n)}}}function yt(t,e){let n=r=>v(r>e?h(b):E([r,n(r+1)]));return n(t)}function ue(t,e){let n=R(x(y(t),r=>q(r)),r=>h(r),([r,a])=>R(x(y(e),o=>q(o)),o=>h(o),([o,i])=>E([[r,o],ue(a,i)])));return v(n)}function dt(t,e){let n=r=>R(x(y(r),a=>q(a)),a=>a._tag==="None"?E(void 0):h(a),([a,o])=>p(x(e(a),i=>I(i)),()=>n(o)));return R(n(t),r=>r._tag==="None"?E(void 0):h(r.value),()=>E(void 0))}function Rt(t){let e=T();for(let n=t.length-1;n>=0;n--){let r=X(z(t[n]));e=C(r,e);}return e}function ft(t){let e=(n,r)=>R(y(n),a=>a._tag==="None"?z(r):B(a),([a,o])=>e(o,[...r,a]));return M(e(t,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}function le(t,e){let n=A((r,a)=>{t.read().then(({done:o,value:i})=>{if(o){a({_tag:"Failure",error:b});return}a({_tag:"Success",value:[i,v(n)]});}).catch(o=>{a({_tag:"Failure",error:I(e(o))});});});return v(n)}function ht(t,e){if(!t)return T();let n;return ce(H(()=>(n=t.getReader(),le(n,e))),()=>F(()=>{try{n?.cancel();}catch{}}))}exports.$=C;exports.A=xe;exports.B=P;exports.C=j;exports.D=J;exports.E=N;exports.F=De;exports.G=w;exports.H=Te;exports.I=ze;exports.J=Me;exports.K=Ue;exports.L=je;exports.M=re;exports.N=_;exports.O=Ge;exports.P=Qe;exports.Q=Ve;exports.R=Xe;exports.S=Ye;exports.T=K;exports.U=q;exports.V=v;exports.W=ce;exports.X=At;exports.Y=Et;exports.Z=T;exports._=X;exports.a=R;exports.aa=L;exports.b=Ae;exports.ba=pt;exports.c=x;exports.ca=y;exports.d=k;exports.da=O;exports.e=E;exports.ea=yt;exports.f=h;exports.fa=ue;exports.g=F;exports.ga=dt;exports.h=Ee;exports.ha=Rt;exports.i=A;exports.ia=ft;exports.j=W;exports.ja=ht;exports.k=p;exports.l=pe;exports.m=ye;exports.n=de;exports.o=Re;exports.p=fe;exports.q=b;exports.r=I;exports.s=z;exports.t=B;exports.u=H;exports.v=Z;exports.w=G;exports.x=M;exports.y=ve;exports.z=U;
|