brass-runtime 1.6.2 → 1.7.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/README.md +1 -1
- package/dist/chunk-7M74PYBY.mjs +1 -0
- package/dist/chunk-LRGO34YG.js +1 -0
- package/dist/http/index.d.mts +26 -41
- package/dist/http/index.d.ts +26 -41
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -1
- package/dist/index.d.mts +3 -55
- package/dist/index.d.ts +3 -55
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{effect-BTR2nIXd.d.mts → stream-wtsKMh6j.d.mts} +56 -1
- package/dist/{effect-BTR2nIXd.d.ts → stream-wtsKMh6j.d.ts} +56 -1
- package/package.json +1 -1
- package/dist/chunk-BQ3I6L5Z.js +0 -1
- package/dist/chunk-SMCQ6GGV.mjs +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function p(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function Ee(t,e){return p(t,n=>e(n),n=>u(n))}function S(t,e){return p(t,n=>y(e(n)),n=>u(n))}var w=()=>u(void 0),u=t=>({_tag:"Succeed",value:t}),y=t=>({_tag:"Fail",error:t}),O=t=>({_tag:"Sync",thunk:t}),Ae=t=>O(()=>t()),l=t=>({_tag:"Async",register:t});function H(t,e){return d(t,n=>u(e(n)))}function d(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function pe(t,e,n){return d(t,r=>(n.addFinalizer(a=>e(r,a)),u(r)))}function ye(t){return l(t)}var v={_tag:"None"},b=t=>({_tag:"Some",value:t});var z=t=>u(t),B=t=>y(t),G=t=>O(e=>t(e)),_=(t,e)=>H(t,e),Q=(t,e)=>d(t,n=>e(n)),M=(t,e)=>S(t,e),me=(t,e)=>p(t,n=>e(n),n=>u(n));function U(t,e){return p(t,n=>n._tag==="Some"?y(n):e(),n=>u(n))}var ge=()=>B(v);var N=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 W=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 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>$?"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<W;){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>=W||this.queue.length>$?"macro":"micro";this.requestFlush(n);}}}},J=new j;var R={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},h={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 P=class{constructor(e,n,r){this.scheduler=r;this.id=ee++,this.current=e,this.env=n;}id;closing=null;finishing=false;runState=h.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===h.DONE||this.runState===h.QUEUED||(this.runState=h.QUEUED,this.scheduler.schedule(()=>{if(this.runState===h.DONE)return;switch(this.runState=h.RUNNING,this.step()){case R.CONTINUE:this.schedule("continue");return;case R.SUSPEND:this.runState=h.SUSPENDED;return;case R.DONE:this.runState=h.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 R.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),R.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?R.DONE:R.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{}}),R.SUSPEND}}}return this.result!=null?R.DONE:R.CONTINUE}};function Ne(t){return l((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 F(t,e,n=J){let r=new P(t,e,n);return r.schedule("initial-step"),r}function Pe(t,e,n){F(t,e).join(n);}function Ce(t,e){return new Promise((n,r)=>{F(t,e).join(o=>{let i=o;i._tag==="Success"?n(i.value):r(i.error);});})}function De(t,e){return l((n,r)=>{t(n).then(a=>r({_tag:"Success",value:a})).catch(a=>r({_tag:"Failure",error:e(a)}));})}function Te(t){return l((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 ze(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 l((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 l((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 p(t,()=>w,()=>w)}var I=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=F(e,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(e={_tag:"Success",value:void 0}){F(this.closeAsync(e),this.env);}closeAsync(e={_tag:"Success",value:void 0},n={}){return l((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 A of o)try{A.interrupt();}catch{}let s=w();for(let A of i)s=d(s,()=>A.closeAsync(e,n));for(;this.finalizers.length>0;){let A=this.finalizers.pop();s=d(s,()=>ie(A(e)));}n.awaitChildren&&(s=d(s,()=>se(o))),F(s,this.env).join(()=>a({_tag:"Success",value:void 0}));})}};function Le(t){let e=new I({});try{return t(e)}finally{e.close();}}function K(t,e,n,r,a){return l((o,i)=>{let s=n.subScope(),c=false,A=s.fork(t,o),x=s.fork(e,o),g=f=>{s.fork(f,o).join(Z=>{s.close(Z),i(Z);});};A.join(f=>{c||(c=true,g(r(f,x,s)));}),x.join(f=>{c||(c=true,g(a(f,A,s)));});})}var q=t=>t._tag==="None"?v:b(t.value),m=t=>({_tag:"FromPull",pull:t}),ce=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),at=t=>({_tag:"Scoped",acquire:d(t,e=>u(e.stream)),release:e=>d(t,n=>n.release(e))}),ot=(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[x,g]=o.value;i.interrupt();let f=m(t==="L"?D(g,n):D(e,g));return u([x,f])}let c=o.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return y(c);let A=c;return A._tag==="None"?E(t==="L"?n:e):y(A)}}function D(t,e,n,r){return l((a,o)=>{let s=new I(a),c=E(t),A=E(e),x=V("L",t,e),g=V("R",t,e),f=K(c,A,s,x,g);s.fork(f,a).join(Z=>{s.close(Z),o(Z);});})}function st(t,e){return m(D(t,e))}function E(t){switch(t._tag){case "Empty":return B(v);case "Emit":return _(M(t.value,e=>b(e)),e=>[e,T()]);case "FromPull":return t.pull;case "Concat":return U(_(E(t.left),([e,n])=>[e,C(n,t.right)]),()=>E(t.right));case "Flatten":return Q(E(t.stream),([e,n])=>U(_(E(e),([r,a])=>[r,C(a,L(n))]),()=>E(L(n))));case "Merge":return D(t.left,t.right,t.flip);case "Scoped":return l((e,n)=>{let r=new I(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:b(a.error)});return}let o=a.value;E(o)(e,s=>{r.close(s),n(s);});});})}}function k(t,e){switch(t._tag){case "Empty":return T();case "Emit":return X(_(t.value,e));case "FromPull":return m(_(t.pull,([n,r])=>[e(n),k(r,e)]));case "Concat":return C(k(t.left,e),k(t.right,e));case "Flatten":{let n=k(t.stream,r=>k(r,e));return L(n)}}}function it(t,e){let n=r=>m(r>e?y(v):u([r,n(r+1)]));return n(t)}function ue(t,e){let n=p(S(E(t),r=>q(r)),r=>y(r),([r,a])=>p(S(E(e),o=>q(o)),o=>y(o),([o,i])=>u([[r,o],ue(a,i)])));return m(n)}function ct(t,e){let n=r=>p(S(E(r),a=>q(a)),a=>a._tag==="None"?u(void 0):y(a),([a,o])=>d(S(e(a),i=>b(i)),()=>n(o)));return p(n(t),r=>r._tag==="None"?u(void 0):y(r.value),()=>u(void 0))}function ut(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 lt(t){let e=(n,r)=>p(E(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=l((r,a)=>{t.read().then(({done:o,value:i})=>{if(o){a({_tag:"Failure",error:v});return}a({_tag:"Success",value:[i,m(n)]});}).catch(o=>{a({_tag:"Failure",error:b(e(o))});});});return m(n)}function Et(t,e){if(!t)return T();let n;return ce(G(()=>(n=t.getReader(),le(n,e))),()=>O(()=>{try{n?.cancel();}catch{}}))}export{lt as $,P as A,Ne as B,F as C,Pe as D,Ce as E,De as F,Te as G,ze as H,re as I,I as J,Le as K,q as L,m as M,ce as N,at as O,ot as P,T as Q,X as R,C as S,L as T,st as U,E as V,k as W,it as X,ue as Y,ct as Z,ut as _,p as a,Et as aa,Ee as b,S as c,w as d,u as e,y as f,O as g,Ae as h,l as i,H as j,d as k,pe as l,ye as m,v as n,b as o,z as p,B as q,G as r,_ as s,Q as t,M as u,me as v,U as w,ge as x,j as y,J as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function p(t,e,n){return {_tag:"Fold",first:t,onFailure:e,onSuccess:n}}function Ee(t,e){return p(t,n=>e(n),n=>u(n))}function S(t,e){return p(t,n=>y(e(n)),n=>u(n))}var w=()=>u(void 0),u=t=>({_tag:"Succeed",value:t}),y=t=>({_tag:"Fail",error:t}),O=t=>({_tag:"Sync",thunk:t}),Ae=t=>O(()=>t()),l=t=>({_tag:"Async",register:t});function H(t,e){return d(t,n=>u(e(n)))}function d(t,e){return {_tag:"FlatMap",first:t,andThen:e}}function pe(t,e,n){return d(t,r=>(n.addFinalizer(a=>e(r,a)),u(r)))}function ye(t){return l(t)}var v={_tag:"None"},b=t=>({_tag:"Some",value:t});var z=t=>u(t),B=t=>y(t),G=t=>O(e=>t(e)),_=(t,e)=>H(t,e),Q=(t,e)=>d(t,n=>e(n)),M=(t,e)=>S(t,e),me=(t,e)=>p(t,n=>e(n),n=>u(n));function U(t,e){return p(t,n=>n._tag==="Some"?y(n):e(),n=>u(n))}var ge=()=>B(v);var N=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 W=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 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>$?"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<W;){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>=W||this.queue.length>$?"macro":"micro";this.requestFlush(n);}}}},J=new j;var R={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},h={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 P=class{constructor(e,n,r){this.scheduler=r;this.id=ee++,this.current=e,this.env=n;}id;closing=null;finishing=false;runState=h.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===h.DONE||this.runState===h.QUEUED||(this.runState=h.QUEUED,this.scheduler.schedule(()=>{if(this.runState===h.DONE)return;switch(this.runState=h.RUNNING,this.step()){case R.CONTINUE:this.schedule("continue");return;case R.SUSPEND:this.runState=h.SUSPENDED;return;case R.DONE:this.runState=h.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 R.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),R.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?R.DONE:R.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{}}),R.SUSPEND}}}return this.result!=null?R.DONE:R.CONTINUE}};function Ne(t){return l((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 F(t,e,n=J){let r=new P(t,e,n);return r.schedule("initial-step"),r}function Pe(t,e,n){F(t,e).join(n);}function Ce(t,e){return new Promise((n,r)=>{F(t,e).join(o=>{let i=o;i._tag==="Success"?n(i.value):r(i.error);});})}function De(t,e){return l((n,r)=>{t(n).then(a=>r({_tag:"Success",value:a})).catch(a=>r({_tag:"Failure",error:e(a)}));})}function Te(t){return l((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 ze(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 l((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 l((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 p(t,()=>w,()=>w)}var I=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=F(e,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(e={_tag:"Success",value:void 0}){F(this.closeAsync(e),this.env);}closeAsync(e={_tag:"Success",value:void 0},n={}){return l((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 A of o)try{A.interrupt();}catch{}let s=w();for(let A of i)s=d(s,()=>A.closeAsync(e,n));for(;this.finalizers.length>0;){let A=this.finalizers.pop();s=d(s,()=>ie(A(e)));}n.awaitChildren&&(s=d(s,()=>se(o))),F(s,this.env).join(()=>a({_tag:"Success",value:void 0}));})}};function Le(t){let e=new I({});try{return t(e)}finally{e.close();}}function K(t,e,n,r,a){return l((o,i)=>{let s=n.subScope(),c=false,A=s.fork(t,o),x=s.fork(e,o),g=f=>{s.fork(f,o).join(Z=>{s.close(Z),i(Z);});};A.join(f=>{c||(c=true,g(r(f,x,s)));}),x.join(f=>{c||(c=true,g(a(f,A,s)));});})}var q=t=>t._tag==="None"?v:b(t.value),m=t=>({_tag:"FromPull",pull:t}),ce=(t,e)=>({_tag:"Scoped",acquire:t,release:e}),at=t=>({_tag:"Scoped",acquire:d(t,e=>u(e.stream)),release:e=>d(t,n=>n.release(e))}),ot=(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[x,g]=o.value;i.interrupt();let f=m(t==="L"?D(g,n):D(e,g));return u([x,f])}let c=o.error;if(typeof c=="object"&&c!==null&&c._tag==="Interrupted")return y(c);let A=c;return A._tag==="None"?E(t==="L"?n:e):y(A)}}function D(t,e,n,r){return l((a,o)=>{let s=new I(a),c=E(t),A=E(e),x=V("L",t,e),g=V("R",t,e),f=K(c,A,s,x,g);s.fork(f,a).join(Z=>{s.close(Z),o(Z);});})}function st(t,e){return m(D(t,e))}function E(t){switch(t._tag){case "Empty":return B(v);case "Emit":return _(M(t.value,e=>b(e)),e=>[e,T()]);case "FromPull":return t.pull;case "Concat":return U(_(E(t.left),([e,n])=>[e,C(n,t.right)]),()=>E(t.right));case "Flatten":return Q(E(t.stream),([e,n])=>U(_(E(e),([r,a])=>[r,C(a,L(n))]),()=>E(L(n))));case "Merge":return D(t.left,t.right,t.flip);case "Scoped":return l((e,n)=>{let r=new I(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:b(a.error)});return}let o=a.value;E(o)(e,s=>{r.close(s),n(s);});});})}}function k(t,e){switch(t._tag){case "Empty":return T();case "Emit":return X(_(t.value,e));case "FromPull":return m(_(t.pull,([n,r])=>[e(n),k(r,e)]));case "Concat":return C(k(t.left,e),k(t.right,e));case "Flatten":{let n=k(t.stream,r=>k(r,e));return L(n)}}}function it(t,e){let n=r=>m(r>e?y(v):u([r,n(r+1)]));return n(t)}function ue(t,e){let n=p(S(E(t),r=>q(r)),r=>y(r),([r,a])=>p(S(E(e),o=>q(o)),o=>y(o),([o,i])=>u([[r,o],ue(a,i)])));return m(n)}function ct(t,e){let n=r=>p(S(E(r),a=>q(a)),a=>a._tag==="None"?u(void 0):y(a),([a,o])=>d(S(e(a),i=>b(i)),()=>n(o)));return p(n(t),r=>r._tag==="None"?u(void 0):y(r.value),()=>u(void 0))}function ut(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 lt(t){let e=(n,r)=>p(E(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=l((r,a)=>{t.read().then(({done:o,value:i})=>{if(o){a({_tag:"Failure",error:v});return}a({_tag:"Success",value:[i,m(n)]});}).catch(o=>{a({_tag:"Failure",error:b(e(o))});});});return m(n)}function Et(t,e){if(!t)return T();let n;return ce(G(()=>(n=t.getReader(),le(n,e))),()=>O(()=>{try{n?.cancel();}catch{}}))}exports.$=lt;exports.A=P;exports.B=Ne;exports.C=F;exports.D=Pe;exports.E=Ce;exports.F=De;exports.G=Te;exports.H=ze;exports.I=re;exports.J=I;exports.K=Le;exports.L=q;exports.M=m;exports.N=ce;exports.O=at;exports.P=ot;exports.Q=T;exports.R=X;exports.S=C;exports.T=L;exports.U=st;exports.V=E;exports.W=k;exports.X=it;exports.Y=ue;exports.Z=ct;exports._=ut;exports.a=p;exports.aa=Et;exports.b=Ee;exports.c=S;exports.d=w;exports.e=u;exports.f=y;exports.g=O;exports.h=Ae;exports.i=l;exports.j=H;exports.k=d;exports.l=pe;exports.m=ye;exports.n=v;exports.o=b;exports.p=z;exports.q=B;exports.r=G;exports.s=_;exports.t=Q;exports.u=M;exports.v=me;exports.w=U;exports.x=ge;exports.y=j;exports.z=J;
|
package/dist/http/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Async } from '../
|
|
1
|
+
import { Q as ZStream, A as Async } from '../stream-wtsKMh6j.mjs';
|
|
2
2
|
|
|
3
3
|
type HttpError = {
|
|
4
4
|
_tag: "Abort";
|
|
@@ -28,68 +28,53 @@ type MakeHttpConfig = {
|
|
|
28
28
|
baseUrl?: string;
|
|
29
29
|
headers?: Record<string, string>;
|
|
30
30
|
};
|
|
31
|
+
type HttpWireResponseStream = {
|
|
32
|
+
status: number;
|
|
33
|
+
statusText: string;
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
body: ZStream<unknown, HttpError, Uint8Array>;
|
|
36
|
+
ms: number;
|
|
37
|
+
};
|
|
38
|
+
type HttpClientStream = (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponseStream>;
|
|
31
39
|
type HttpClient = (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
40
|
+
declare function makeHttpStream(cfg?: MakeHttpConfig): HttpClientStream;
|
|
32
41
|
declare function makeHttp(cfg?: MakeHttpConfig): HttpClient;
|
|
33
42
|
declare const mapAsync: <R, E, A, B>(fa: Async<R, E, A>, f: (a: A) => B) => Async<R, E, B>;
|
|
34
43
|
declare const mapTryAsync: <R, E, A, B>(fa: Async<R, E, A>, f: (a: A) => B) => Async<R, E, B>;
|
|
35
44
|
|
|
36
|
-
/**
|
|
37
|
-
* “Contenido” (sin meta). Esto es lo que querés que sea el default.
|
|
38
|
-
*/
|
|
39
45
|
type HttpResponse<A> = {
|
|
40
46
|
status: number;
|
|
41
47
|
headers: Record<string, string>;
|
|
42
48
|
body: A;
|
|
43
49
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Meta (opcional / inyectable por middleware).
|
|
46
|
-
*/
|
|
47
50
|
type HttpMeta = {
|
|
48
51
|
statusText: string;
|
|
49
52
|
ms: number;
|
|
50
53
|
};
|
|
51
|
-
/**
|
|
52
|
-
* “Contenido + meta” (resultado de aplicar withMeta).
|
|
53
|
-
*/
|
|
54
54
|
type HttpResponseWithMeta<A> = HttpResponse<A> & {
|
|
55
55
|
meta: HttpMeta;
|
|
56
56
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
type HttpResponseStream = {
|
|
58
|
+
status: number;
|
|
59
|
+
headers: Record<string, string>;
|
|
60
|
+
body: ZStream<unknown, HttpError, Uint8Array>;
|
|
61
|
+
};
|
|
62
|
+
declare function httpClient(cfg?: MakeHttpConfig): {
|
|
63
63
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
64
|
-
get: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
65
|
-
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
66
|
-
postJson: <A extends object>(url: string, body: A, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
67
64
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<string>>;
|
|
68
65
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<A>>;
|
|
69
66
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* misma API, pero getText/getJson devuelven HttpResponseWithMeta.
|
|
73
|
-
*/
|
|
74
|
-
type HttpClientDxWithMeta = Omit<HttpClientDx, "getText" | "getJson"> & {
|
|
67
|
+
declare function httpClientWithMeta(cfg?: MakeHttpConfig): {
|
|
68
|
+
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
75
69
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
76
70
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<A>>;
|
|
77
71
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* Nota: NO toca el wire; sólo cambia cómo “renderizás” contenido.
|
|
86
|
-
*/
|
|
87
|
-
declare function withMeta(client: HttpClientDx): HttpClientDxWithMeta;
|
|
88
|
-
/**
|
|
89
|
-
* Convenience: “todo transparente”
|
|
90
|
-
* - crea el client base
|
|
91
|
-
* - le aplica withMeta
|
|
92
|
-
*/
|
|
93
|
-
declare function httpClientWithMeta(cfg?: MakeHttpConfig): HttpClientDxWithMeta;
|
|
72
|
+
type HttpClientDxStream = {
|
|
73
|
+
request: (req: HttpRequest) => Async<unknown, HttpError, HttpResponseStream>;
|
|
74
|
+
get: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
75
|
+
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
76
|
+
postJson: <A extends object>(url: string, body: A, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
77
|
+
};
|
|
78
|
+
declare function httpClientStream(cfg?: MakeHttpConfig): HttpClientDxStream;
|
|
94
79
|
|
|
95
|
-
export { type HttpClient, type
|
|
80
|
+
export { type HttpClient, type HttpClientDxStream, type HttpClientStream, type HttpError, type HttpMeta, type HttpMethod, type HttpRequest, type HttpResponse, type HttpResponseStream, type HttpResponseWithMeta, type HttpWireResponse, type HttpWireResponseStream, type MakeHttpConfig, httpClient, httpClientStream, httpClientWithMeta, makeHttp, makeHttpStream, mapAsync, mapTryAsync };
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Async } from '../
|
|
1
|
+
import { Q as ZStream, A as Async } from '../stream-wtsKMh6j.js';
|
|
2
2
|
|
|
3
3
|
type HttpError = {
|
|
4
4
|
_tag: "Abort";
|
|
@@ -28,68 +28,53 @@ type MakeHttpConfig = {
|
|
|
28
28
|
baseUrl?: string;
|
|
29
29
|
headers?: Record<string, string>;
|
|
30
30
|
};
|
|
31
|
+
type HttpWireResponseStream = {
|
|
32
|
+
status: number;
|
|
33
|
+
statusText: string;
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
body: ZStream<unknown, HttpError, Uint8Array>;
|
|
36
|
+
ms: number;
|
|
37
|
+
};
|
|
38
|
+
type HttpClientStream = (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponseStream>;
|
|
31
39
|
type HttpClient = (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
40
|
+
declare function makeHttpStream(cfg?: MakeHttpConfig): HttpClientStream;
|
|
32
41
|
declare function makeHttp(cfg?: MakeHttpConfig): HttpClient;
|
|
33
42
|
declare const mapAsync: <R, E, A, B>(fa: Async<R, E, A>, f: (a: A) => B) => Async<R, E, B>;
|
|
34
43
|
declare const mapTryAsync: <R, E, A, B>(fa: Async<R, E, A>, f: (a: A) => B) => Async<R, E, B>;
|
|
35
44
|
|
|
36
|
-
/**
|
|
37
|
-
* “Contenido” (sin meta). Esto es lo que querés que sea el default.
|
|
38
|
-
*/
|
|
39
45
|
type HttpResponse<A> = {
|
|
40
46
|
status: number;
|
|
41
47
|
headers: Record<string, string>;
|
|
42
48
|
body: A;
|
|
43
49
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Meta (opcional / inyectable por middleware).
|
|
46
|
-
*/
|
|
47
50
|
type HttpMeta = {
|
|
48
51
|
statusText: string;
|
|
49
52
|
ms: number;
|
|
50
53
|
};
|
|
51
|
-
/**
|
|
52
|
-
* “Contenido + meta” (resultado de aplicar withMeta).
|
|
53
|
-
*/
|
|
54
54
|
type HttpResponseWithMeta<A> = HttpResponse<A> & {
|
|
55
55
|
meta: HttpMeta;
|
|
56
56
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
type HttpResponseStream = {
|
|
58
|
+
status: number;
|
|
59
|
+
headers: Record<string, string>;
|
|
60
|
+
body: ZStream<unknown, HttpError, Uint8Array>;
|
|
61
|
+
};
|
|
62
|
+
declare function httpClient(cfg?: MakeHttpConfig): {
|
|
63
63
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
64
|
-
get: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
65
|
-
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
66
|
-
postJson: <A extends object>(url: string, body: A, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
67
64
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<string>>;
|
|
68
65
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<A>>;
|
|
69
66
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* misma API, pero getText/getJson devuelven HttpResponseWithMeta.
|
|
73
|
-
*/
|
|
74
|
-
type HttpClientDxWithMeta = Omit<HttpClientDx, "getText" | "getJson"> & {
|
|
67
|
+
declare function httpClientWithMeta(cfg?: MakeHttpConfig): {
|
|
68
|
+
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
75
69
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
76
70
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<A>>;
|
|
77
71
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* Nota: NO toca el wire; sólo cambia cómo “renderizás” contenido.
|
|
86
|
-
*/
|
|
87
|
-
declare function withMeta(client: HttpClientDx): HttpClientDxWithMeta;
|
|
88
|
-
/**
|
|
89
|
-
* Convenience: “todo transparente”
|
|
90
|
-
* - crea el client base
|
|
91
|
-
* - le aplica withMeta
|
|
92
|
-
*/
|
|
93
|
-
declare function httpClientWithMeta(cfg?: MakeHttpConfig): HttpClientDxWithMeta;
|
|
72
|
+
type HttpClientDxStream = {
|
|
73
|
+
request: (req: HttpRequest) => Async<unknown, HttpError, HttpResponseStream>;
|
|
74
|
+
get: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
75
|
+
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
76
|
+
postJson: <A extends object>(url: string, body: A, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpResponseStream>;
|
|
77
|
+
};
|
|
78
|
+
declare function httpClientStream(cfg?: MakeHttpConfig): HttpClientDxStream;
|
|
94
79
|
|
|
95
|
-
export { type HttpClient, type
|
|
80
|
+
export { type HttpClient, type HttpClientDxStream, type HttpClientStream, type HttpError, type HttpMeta, type HttpMethod, type HttpRequest, type HttpResponse, type HttpResponseStream, type HttpResponseWithMeta, type HttpWireResponse, type HttpWireResponseStream, type MakeHttpConfig, httpClient, httpClientStream, httpClientWithMeta, makeHttp, makeHttpStream, mapAsync, mapTryAsync };
|
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkLRGO34YG_js=require('../chunk-LRGO34YG.js');function b(t={}){let n=t.baseUrl??"",s=t.headers??{};return a=>chunkLRGO34YG_js.I(async i=>{let o=new URL(a.url,n),r=performance.now(),e=await fetch(o,{...a.init??{},method:a.method,headers:{...s,...a.headers??{}},body:a.body,signal:i}),p={};e.headers.forEach((u,c)=>p[c]=u);let d=chunkLRGO34YG_js.aa(e.body,h);return {status:e.status,statusText:e.statusText,headers:p,body:d,ms:Math.round(performance.now()-r)}},h)}var h=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)};function g(t={}){let n=t.baseUrl??"",s=t.headers??{};return a=>chunkLRGO34YG_js.I(async i=>{let o;try{o=new URL(a.url,n);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${a.url}`}}let r=performance.now(),e=await fetch(o,{...a.init??{},method:a.method,headers:{...s,...a.headers??{}},body:a.body,signal:i}),p=await e.text(),d={};return e.headers.forEach((u,c)=>d[c]=u),{status:e.status,statusText:e.statusText,headers:d,bodyText:p,ms:Math.round(performance.now()-r)}},h)}var q=(t,n)=>chunkLRGO34YG_js.k(t,s=>chunkLRGO34YG_js.e(n(s))),m=(t,n)=>chunkLRGO34YG_js.k(t,s=>chunkLRGO34YG_js.g(()=>n(s)));var l=(t,n)=>({status:t.status,headers:t.headers,body:n}),f=(t,n)=>({status:t.status,headers:t.headers,body:n,meta:{statusText:t.statusText,ms:t.ms}});function L(t={}){let n=g(t),s=o=>n(o);return {request:s,getText:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>l(e,e.bodyText)),getJson:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>l(e,JSON.parse(e.bodyText)))}}function Z(t={}){let n=g(t),s=o=>n(o);return {request:s,getText:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>f(e,e.bodyText)),getJson:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>f(e,JSON.parse(e.bodyText)))}}var E=t=>({status:t.status,headers:t.headers,body:t.body});function j(t={}){let n=b(t),s=r=>m(n(r),E);return {request:s,get:(r,e)=>s({method:"GET",url:r,init:e}),post:(r,e,p)=>s({method:"POST",url:r,body:e&&e.length>0?e:void 0,init:p}),postJson:(r,e,p)=>s({method:"POST",url:r,body:JSON.stringify(e),headers:{"content-type":"application/json",...p?.headers},init:{...p??{}}})}}exports.httpClient=L;exports.httpClientStream=j;exports.httpClientWithMeta=Z;exports.makeHttp=g;exports.makeHttpStream=b;exports.mapAsync=q;exports.mapTryAsync=m;
|
package/dist/http/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {k,
|
|
1
|
+
import {k,I,aa,e,g as g$1}from'../chunk-7M74PYBY.mjs';function b(t={}){let n=t.baseUrl??"",s=t.headers??{};return a=>I(async i=>{let o=new URL(a.url,n),r=performance.now(),e=await fetch(o,{...a.init??{},method:a.method,headers:{...s,...a.headers??{}},body:a.body,signal:i}),p={};e.headers.forEach((u,c)=>p[c]=u);let d=aa(e.body,h);return {status:e.status,statusText:e.statusText,headers:p,body:d,ms:Math.round(performance.now()-r)}},h)}var h=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)};function g(t={}){let n=t.baseUrl??"",s=t.headers??{};return a=>I(async i=>{let o;try{o=new URL(a.url,n);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${a.url}`}}let r=performance.now(),e=await fetch(o,{...a.init??{},method:a.method,headers:{...s,...a.headers??{}},body:a.body,signal:i}),p=await e.text(),d={};return e.headers.forEach((u,c)=>d[c]=u),{status:e.status,statusText:e.statusText,headers:d,bodyText:p,ms:Math.round(performance.now()-r)}},h)}var q=(t,n)=>k(t,s=>e(n(s))),m=(t,n)=>k(t,s=>g$1(()=>n(s)));var l=(t,n)=>({status:t.status,headers:t.headers,body:n}),f=(t,n)=>({status:t.status,headers:t.headers,body:n,meta:{statusText:t.statusText,ms:t.ms}});function L(t={}){let n=g(t),s=o=>n(o);return {request:s,getText:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>l(e,e.bodyText)),getJson:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>l(e,JSON.parse(e.bodyText)))}}function Z(t={}){let n=g(t),s=o=>n(o);return {request:s,getText:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>f(e,e.bodyText)),getJson:(o,r)=>m(s({method:"GET",url:o,init:r}),e=>f(e,JSON.parse(e.bodyText)))}}var E=t=>({status:t.status,headers:t.headers,body:t.body});function j(t={}){let n=b(t),s=r=>m(n(r),E);return {request:s,get:(r,e)=>s({method:"GET",url:r,init:e}),post:(r,e,p)=>s({method:"POST",url:r,body:e&&e.length>0?e:void 0,init:p}),postJson:(r,e,p)=>s({method:"POST",url:r,body:JSON.stringify(e),headers:{"content-type":"application/json",...p?.headers},init:{...p??{}}})}}export{L as httpClient,j as httpClientStream,Z as httpClientWithMeta,g as makeHttp,b as makeHttpStream,q as mapAsync,m as mapTryAsync};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,57 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { z as CancelToken, C as Canceler, G as FiberId,
|
|
3
|
-
|
|
4
|
-
type Empty<R, E, A> = {
|
|
5
|
-
readonly _tag: "Empty";
|
|
6
|
-
};
|
|
7
|
-
type Emit<R, E, A> = {
|
|
8
|
-
readonly _tag: "Emit";
|
|
9
|
-
readonly value: ZIO<R, E, A>;
|
|
10
|
-
};
|
|
11
|
-
type Concat<R, E, A> = {
|
|
12
|
-
readonly _tag: "Concat";
|
|
13
|
-
readonly left: ZStream<R, E, A>;
|
|
14
|
-
readonly right: ZStream<R, E, A>;
|
|
15
|
-
};
|
|
16
|
-
type Flatten<R, E, A> = {
|
|
17
|
-
readonly _tag: "Flatten";
|
|
18
|
-
readonly stream: ZStream<R, E, ZStream<R, E, A>>;
|
|
19
|
-
};
|
|
20
|
-
type FromPull<R, E, A> = {
|
|
21
|
-
readonly _tag: "FromPull";
|
|
22
|
-
readonly pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
23
|
-
};
|
|
24
|
-
type Merge<R, E, A> = {
|
|
25
|
-
readonly _tag: "Merge";
|
|
26
|
-
readonly left: ZStream<R, E, A>;
|
|
27
|
-
readonly right: ZStream<R, E, A>;
|
|
28
|
-
readonly flip: boolean;
|
|
29
|
-
};
|
|
30
|
-
type Scoped<R, E, A> = {
|
|
31
|
-
readonly _tag: "Scoped";
|
|
32
|
-
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
33
|
-
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
34
|
-
};
|
|
35
|
-
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
36
|
-
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
37
|
-
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
38
|
-
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
39
|
-
stream: ZStream<R, E, A>;
|
|
40
|
-
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
41
|
-
}>) => ZStream<R, E, A>;
|
|
42
|
-
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
43
|
-
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
44
|
-
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
45
|
-
declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>) => ZStream<R, E, A>;
|
|
46
|
-
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
47
|
-
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
48
|
-
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
49
|
-
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
50
|
-
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
51
|
-
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
52
|
-
declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a: A) => Async<R2, E2, void>): Async<R & R2, E | E2, void>;
|
|
53
|
-
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
54
|
-
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
1
|
+
import { A as Async, S as Scheduler, F as Fiber, E as Exit, I as Interrupted } from './stream-wtsKMh6j.mjs';
|
|
2
|
+
export { z as CancelToken, C as Canceler, J as Concat, H as Emit, G as Empty, aa as FiberId, ab as FiberStatus, K as Flatten, L as FromPull, M as Merge, N as None, R as Normalize, O as Option, ac as RuntimeFiber, ae as Scope, ad as ScopeId, P as Scoped, w as Some, ag as Task, Z as ZIO, Q as ZStream, t as acquireRelease, p as async, h as asyncCatchAll, k as asyncFail, r as asyncFlatMap, g as asyncFold, v as asyncInterruptible, q as asyncMap, i as asyncMapError, j as asyncSucceed, l as asyncSync, n as asyncTotal, d as catchAll, a8 as collectStream, $ as concatStream, _ as emitStream, Y as emptyStream, e as end, f as fail, b as flatMap, a0 as flattenStream, a6 as foreachStream, a7 as fromArray, U as fromPull, ah as globalScheduler, D as linkAbortController, B as makeCancelToken, W as managedStream, m as map, c as mapError, a3 as mapStream, a1 as merge, X as mergeStream, x as none, o as orElseOptional, a4 as rangeStream, y as some, a9 as streamFromReadableStream, s as succeed, a as sync, a2 as uncons, u as unit, V as unwrapScoped, T as widenOpt, af as withScope, a5 as zip } from './stream-wtsKMh6j.mjs';
|
|
55
3
|
|
|
56
4
|
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
57
5
|
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
@@ -72,4 +20,4 @@ declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal)
|
|
|
72
20
|
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
73
21
|
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
74
22
|
|
|
75
|
-
export { Async, type BrassError,
|
|
23
|
+
export { Async, type BrassError, Exit, Fiber, Interrupted, Scheduler, fork, from, fromCallback, fromPromise, fromPromiseAbortable, toPromise, tryPromiseAbortable, unsafeRunAsync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,57 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { z as CancelToken, C as Canceler, G as FiberId,
|
|
3
|
-
|
|
4
|
-
type Empty<R, E, A> = {
|
|
5
|
-
readonly _tag: "Empty";
|
|
6
|
-
};
|
|
7
|
-
type Emit<R, E, A> = {
|
|
8
|
-
readonly _tag: "Emit";
|
|
9
|
-
readonly value: ZIO<R, E, A>;
|
|
10
|
-
};
|
|
11
|
-
type Concat<R, E, A> = {
|
|
12
|
-
readonly _tag: "Concat";
|
|
13
|
-
readonly left: ZStream<R, E, A>;
|
|
14
|
-
readonly right: ZStream<R, E, A>;
|
|
15
|
-
};
|
|
16
|
-
type Flatten<R, E, A> = {
|
|
17
|
-
readonly _tag: "Flatten";
|
|
18
|
-
readonly stream: ZStream<R, E, ZStream<R, E, A>>;
|
|
19
|
-
};
|
|
20
|
-
type FromPull<R, E, A> = {
|
|
21
|
-
readonly _tag: "FromPull";
|
|
22
|
-
readonly pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
23
|
-
};
|
|
24
|
-
type Merge<R, E, A> = {
|
|
25
|
-
readonly _tag: "Merge";
|
|
26
|
-
readonly left: ZStream<R, E, A>;
|
|
27
|
-
readonly right: ZStream<R, E, A>;
|
|
28
|
-
readonly flip: boolean;
|
|
29
|
-
};
|
|
30
|
-
type Scoped<R, E, A> = {
|
|
31
|
-
readonly _tag: "Scoped";
|
|
32
|
-
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
33
|
-
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
34
|
-
};
|
|
35
|
-
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
36
|
-
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
37
|
-
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
38
|
-
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
39
|
-
stream: ZStream<R, E, A>;
|
|
40
|
-
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
41
|
-
}>) => ZStream<R, E, A>;
|
|
42
|
-
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
43
|
-
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
44
|
-
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
45
|
-
declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>) => ZStream<R, E, A>;
|
|
46
|
-
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
47
|
-
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
48
|
-
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
49
|
-
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
50
|
-
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
51
|
-
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
52
|
-
declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a: A) => Async<R2, E2, void>): Async<R & R2, E | E2, void>;
|
|
53
|
-
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
54
|
-
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
1
|
+
import { A as Async, S as Scheduler, F as Fiber, E as Exit, I as Interrupted } from './stream-wtsKMh6j.js';
|
|
2
|
+
export { z as CancelToken, C as Canceler, J as Concat, H as Emit, G as Empty, aa as FiberId, ab as FiberStatus, K as Flatten, L as FromPull, M as Merge, N as None, R as Normalize, O as Option, ac as RuntimeFiber, ae as Scope, ad as ScopeId, P as Scoped, w as Some, ag as Task, Z as ZIO, Q as ZStream, t as acquireRelease, p as async, h as asyncCatchAll, k as asyncFail, r as asyncFlatMap, g as asyncFold, v as asyncInterruptible, q as asyncMap, i as asyncMapError, j as asyncSucceed, l as asyncSync, n as asyncTotal, d as catchAll, a8 as collectStream, $ as concatStream, _ as emitStream, Y as emptyStream, e as end, f as fail, b as flatMap, a0 as flattenStream, a6 as foreachStream, a7 as fromArray, U as fromPull, ah as globalScheduler, D as linkAbortController, B as makeCancelToken, W as managedStream, m as map, c as mapError, a3 as mapStream, a1 as merge, X as mergeStream, x as none, o as orElseOptional, a4 as rangeStream, y as some, a9 as streamFromReadableStream, s as succeed, a as sync, a2 as uncons, u as unit, V as unwrapScoped, T as widenOpt, af as withScope, a5 as zip } from './stream-wtsKMh6j.js';
|
|
55
3
|
|
|
56
4
|
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
57
5
|
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
@@ -72,4 +20,4 @@ declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal)
|
|
|
72
20
|
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
73
21
|
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
74
22
|
|
|
75
|
-
export { Async, type BrassError,
|
|
23
|
+
export { Async, type BrassError, Exit, Fiber, Interrupted, Scheduler, fork, from, fromCallback, fromPromise, fromPromiseAbortable, toPromise, tryPromiseAbortable, unsafeRunAsync };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkLRGO34YG_js=require('./chunk-LRGO34YG.js');function te(){let e=false,r=new Set;return {isCancelled:()=>e,onCancel:n=>{if(e){try{n();}catch{}return ()=>{}}return r.add(n),()=>{r.delete(n);}},cancel:()=>{e||(e=true,r.forEach(n=>n()),r.clear());}}}function ce(e,r){return e.onCancel(()=>r.abort())}Object.defineProperty(exports,"RuntimeFiber",{enumerable:true,get:function(){return chunkLRGO34YG_js.A}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkLRGO34YG_js.y}});Object.defineProperty(exports,"Scope",{enumerable:true,get:function(){return chunkLRGO34YG_js.J}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkLRGO34YG_js.l}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkLRGO34YG_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkLRGO34YG_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkLRGO34YG_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkLRGO34YG_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkLRGO34YG_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkLRGO34YG_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkLRGO34YG_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkLRGO34YG_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkLRGO34YG_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkLRGO34YG_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkLRGO34YG_js.h}});Object.defineProperty(exports,"catchAll",{enumerable:true,get:function(){return chunkLRGO34YG_js.v}});Object.defineProperty(exports,"collectStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.$}});Object.defineProperty(exports,"concatStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.S}});Object.defineProperty(exports,"emitStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.R}});Object.defineProperty(exports,"emptyStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.Q}});Object.defineProperty(exports,"end",{enumerable:true,get:function(){return chunkLRGO34YG_js.x}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkLRGO34YG_js.q}});Object.defineProperty(exports,"flatMap",{enumerable:true,get:function(){return chunkLRGO34YG_js.t}});Object.defineProperty(exports,"flattenStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.T}});Object.defineProperty(exports,"foreachStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.Z}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkLRGO34YG_js.C}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkLRGO34YG_js.B}});Object.defineProperty(exports,"fromArray",{enumerable:true,get:function(){return chunkLRGO34YG_js._}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkLRGO34YG_js.G}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkLRGO34YG_js.F}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkLRGO34YG_js.I}});Object.defineProperty(exports,"fromPull",{enumerable:true,get:function(){return chunkLRGO34YG_js.M}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkLRGO34YG_js.z}});Object.defineProperty(exports,"managedStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.O}});Object.defineProperty(exports,"map",{enumerable:true,get:function(){return chunkLRGO34YG_js.s}});Object.defineProperty(exports,"mapError",{enumerable:true,get:function(){return chunkLRGO34YG_js.u}});Object.defineProperty(exports,"mapStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.W}});Object.defineProperty(exports,"merge",{enumerable:true,get:function(){return chunkLRGO34YG_js.U}});Object.defineProperty(exports,"mergeStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.P}});Object.defineProperty(exports,"none",{enumerable:true,get:function(){return chunkLRGO34YG_js.n}});Object.defineProperty(exports,"orElseOptional",{enumerable:true,get:function(){return chunkLRGO34YG_js.w}});Object.defineProperty(exports,"rangeStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.X}});Object.defineProperty(exports,"some",{enumerable:true,get:function(){return chunkLRGO34YG_js.o}});Object.defineProperty(exports,"streamFromReadableStream",{enumerable:true,get:function(){return chunkLRGO34YG_js.aa}});Object.defineProperty(exports,"succeed",{enumerable:true,get:function(){return chunkLRGO34YG_js.p}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkLRGO34YG_js.r}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkLRGO34YG_js.E}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkLRGO34YG_js.H}});Object.defineProperty(exports,"uncons",{enumerable:true,get:function(){return chunkLRGO34YG_js.V}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkLRGO34YG_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkLRGO34YG_js.D}});Object.defineProperty(exports,"unwrapScoped",{enumerable:true,get:function(){return chunkLRGO34YG_js.N}});Object.defineProperty(exports,"widenOpt",{enumerable:true,get:function(){return chunkLRGO34YG_js.L}});Object.defineProperty(exports,"withScope",{enumerable:true,get:function(){return chunkLRGO34YG_js.K}});Object.defineProperty(exports,"zip",{enumerable:true,get:function(){return chunkLRGO34YG_js.Y}});exports.linkAbortController=ce;exports.makeCancelToken=te;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{A as RuntimeFiber,y as Scheduler,J as Scope,l as acquireRelease,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,v as catchAll,$ as collectStream,S as concatStream,R as emitStream,Q as emptyStream,x as end,q as fail,t as flatMap,T as flattenStream,Z as foreachStream,C as fork,B as from,_ as fromArray,G as fromCallback,F as fromPromise,I as fromPromiseAbortable,M as fromPull,z as globalScheduler,O as managedStream,s as map,u as mapError,W as mapStream,U as merge,P as mergeStream,n as none,w as orElseOptional,X as rangeStream,o as some,aa as streamFromReadableStream,p as succeed,r as sync,E as toPromise,H as tryPromiseAbortable,V as uncons,d as unit,D as unsafeRunAsync,N as unwrapScoped,L as widenOpt,K as withScope,Y as zip}from'./chunk-7M74PYBY.mjs';function te(){let e=false,r=new Set;return {isCancelled:()=>e,onCancel:n=>{if(e){try{n();}catch{}return ()=>{}}return r.add(n),()=>{r.delete(n);}},cancel:()=>{e||(e=true,r.forEach(n=>n()),r.clear());}}}function ce(e,r){return e.onCancel(()=>r.abort())}export{ce as linkAbortController,te as makeCancelToken};
|
|
@@ -162,4 +162,59 @@ declare const catchAll: <R, E, A, R2, E2, B>(fa: ZIO<R, E, A>, handler: (e: E) =
|
|
|
162
162
|
declare function orElseOptional<R, E, A, R2, A2>(fa: ZIO<R, Option<E>, A>, that: () => ZIO<R2, Option<E>, A2>): ZIO<R & R2, Option<E>, A | A2>;
|
|
163
163
|
declare const end: <E>() => ZIO<unknown, Option<E>, never>;
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
type Empty<R, E, A> = {
|
|
166
|
+
readonly _tag: "Empty";
|
|
167
|
+
};
|
|
168
|
+
type Emit<R, E, A> = {
|
|
169
|
+
readonly _tag: "Emit";
|
|
170
|
+
readonly value: ZIO<R, E, A>;
|
|
171
|
+
};
|
|
172
|
+
type Concat<R, E, A> = {
|
|
173
|
+
readonly _tag: "Concat";
|
|
174
|
+
readonly left: ZStream<R, E, A>;
|
|
175
|
+
readonly right: ZStream<R, E, A>;
|
|
176
|
+
};
|
|
177
|
+
type Flatten<R, E, A> = {
|
|
178
|
+
readonly _tag: "Flatten";
|
|
179
|
+
readonly stream: ZStream<R, E, ZStream<R, E, A>>;
|
|
180
|
+
};
|
|
181
|
+
type FromPull<R, E, A> = {
|
|
182
|
+
readonly _tag: "FromPull";
|
|
183
|
+
readonly pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
184
|
+
};
|
|
185
|
+
type Merge<R, E, A> = {
|
|
186
|
+
readonly _tag: "Merge";
|
|
187
|
+
readonly left: ZStream<R, E, A>;
|
|
188
|
+
readonly right: ZStream<R, E, A>;
|
|
189
|
+
readonly flip: boolean;
|
|
190
|
+
};
|
|
191
|
+
type Scoped<R, E, A> = {
|
|
192
|
+
readonly _tag: "Scoped";
|
|
193
|
+
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
194
|
+
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
195
|
+
};
|
|
196
|
+
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
197
|
+
type Normalize<E> = (u: unknown) => E;
|
|
198
|
+
declare const widenOpt: <E1, E2>(opt: Option<E1>) => Option<E1 | E2>;
|
|
199
|
+
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
200
|
+
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
201
|
+
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
202
|
+
stream: ZStream<R, E, A>;
|
|
203
|
+
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
204
|
+
}>) => ZStream<R, E, A>;
|
|
205
|
+
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
206
|
+
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
207
|
+
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
208
|
+
declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>) => ZStream<R, E, A>;
|
|
209
|
+
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
210
|
+
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
211
|
+
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
212
|
+
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
213
|
+
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
214
|
+
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
215
|
+
declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a: A) => Async<R2, E2, void>): Async<R & R2, E | E2, void>;
|
|
216
|
+
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
217
|
+
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
218
|
+
declare function streamFromReadableStream<E>(body: ReadableStream<Uint8Array> | null | undefined, normalizeError: Normalize<E>): ZStream<unknown, E, Uint8Array>;
|
|
219
|
+
|
|
220
|
+
export { concatStream as $, type Async as A, makeCancelToken as B, type Canceler as C, linkAbortController as D, type Exit as E, type Fiber as F, type Empty as G, type Emit as H, type Interrupted as I, type Concat as J, type Flatten as K, type FromPull as L, type Merge as M, type None as N, type Option as O, type Scoped as P, type ZStream as Q, type Normalize as R, Scheduler as S, widenOpt as T, fromPull as U, unwrapScoped as V, managedStream as W, mergeStream as X, emptyStream as Y, type ZIO as Z, emitStream as _, sync as a, flattenStream as a0, merge as a1, uncons as a2, mapStream as a3, rangeStream as a4, zip as a5, foreachStream as a6, fromArray as a7, collectStream as a8, streamFromReadableStream as a9, type FiberId as aa, type FiberStatus as ab, RuntimeFiber as ac, type ScopeId as ad, Scope as ae, withScope as af, type Task as ag, globalScheduler as ah, flatMap as b, mapError as c, catchAll as d, end as e, fail as f, asyncFold as g, asyncCatchAll as h, asyncMapError as i, asyncSucceed as j, asyncFail as k, asyncSync as l, map as m, asyncTotal as n, orElseOptional as o, async as p, asyncMap as q, asyncFlatMap as r, succeed as s, acquireRelease as t, unit as u, asyncInterruptible as v, type Some as w, none as x, some as y, type CancelToken as z };
|
|
@@ -162,4 +162,59 @@ declare const catchAll: <R, E, A, R2, E2, B>(fa: ZIO<R, E, A>, handler: (e: E) =
|
|
|
162
162
|
declare function orElseOptional<R, E, A, R2, A2>(fa: ZIO<R, Option<E>, A>, that: () => ZIO<R2, Option<E>, A2>): ZIO<R & R2, Option<E>, A | A2>;
|
|
163
163
|
declare const end: <E>() => ZIO<unknown, Option<E>, never>;
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
type Empty<R, E, A> = {
|
|
166
|
+
readonly _tag: "Empty";
|
|
167
|
+
};
|
|
168
|
+
type Emit<R, E, A> = {
|
|
169
|
+
readonly _tag: "Emit";
|
|
170
|
+
readonly value: ZIO<R, E, A>;
|
|
171
|
+
};
|
|
172
|
+
type Concat<R, E, A> = {
|
|
173
|
+
readonly _tag: "Concat";
|
|
174
|
+
readonly left: ZStream<R, E, A>;
|
|
175
|
+
readonly right: ZStream<R, E, A>;
|
|
176
|
+
};
|
|
177
|
+
type Flatten<R, E, A> = {
|
|
178
|
+
readonly _tag: "Flatten";
|
|
179
|
+
readonly stream: ZStream<R, E, ZStream<R, E, A>>;
|
|
180
|
+
};
|
|
181
|
+
type FromPull<R, E, A> = {
|
|
182
|
+
readonly _tag: "FromPull";
|
|
183
|
+
readonly pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
184
|
+
};
|
|
185
|
+
type Merge<R, E, A> = {
|
|
186
|
+
readonly _tag: "Merge";
|
|
187
|
+
readonly left: ZStream<R, E, A>;
|
|
188
|
+
readonly right: ZStream<R, E, A>;
|
|
189
|
+
readonly flip: boolean;
|
|
190
|
+
};
|
|
191
|
+
type Scoped<R, E, A> = {
|
|
192
|
+
readonly _tag: "Scoped";
|
|
193
|
+
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
194
|
+
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
195
|
+
};
|
|
196
|
+
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
197
|
+
type Normalize<E> = (u: unknown) => E;
|
|
198
|
+
declare const widenOpt: <E1, E2>(opt: Option<E1>) => Option<E1 | E2>;
|
|
199
|
+
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
200
|
+
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
201
|
+
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
202
|
+
stream: ZStream<R, E, A>;
|
|
203
|
+
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
204
|
+
}>) => ZStream<R, E, A>;
|
|
205
|
+
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
206
|
+
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
207
|
+
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
208
|
+
declare const concatStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>) => ZStream<R, E, A>;
|
|
209
|
+
declare const flattenStream: <R, E, A>(stream: ZStream<R, E, ZStream<R, E, A>>) => ZStream<R, E, A>;
|
|
210
|
+
declare function merge<R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>): ZStream<R, E, A>;
|
|
211
|
+
declare function uncons<R, E, A>(self: ZStream<R, E, A>): ZIO<R, Option<E>, [A, ZStream<R, E, A>]>;
|
|
212
|
+
declare function mapStream<R, E, A, B>(self: ZStream<R, E, A>, f: (a: A) => B): ZStream<R, E, B>;
|
|
213
|
+
declare function rangeStream(start: number, end: number): ZStream<unknown, never, number>;
|
|
214
|
+
declare function zip<R, E1, A, E2, B>(left: ZStream<R, E1, A>, right: ZStream<R, E2, B>): ZStream<R, E1 | E2, [A, B]>;
|
|
215
|
+
declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a: A) => Async<R2, E2, void>): Async<R & R2, E | E2, void>;
|
|
216
|
+
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
217
|
+
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
218
|
+
declare function streamFromReadableStream<E>(body: ReadableStream<Uint8Array> | null | undefined, normalizeError: Normalize<E>): ZStream<unknown, E, Uint8Array>;
|
|
219
|
+
|
|
220
|
+
export { concatStream as $, type Async as A, makeCancelToken as B, type Canceler as C, linkAbortController as D, type Exit as E, type Fiber as F, type Empty as G, type Emit as H, type Interrupted as I, type Concat as J, type Flatten as K, type FromPull as L, type Merge as M, type None as N, type Option as O, type Scoped as P, type ZStream as Q, type Normalize as R, Scheduler as S, widenOpt as T, fromPull as U, unwrapScoped as V, managedStream as W, mergeStream as X, emptyStream as Y, type ZIO as Z, emitStream as _, sync as a, flattenStream as a0, merge as a1, uncons as a2, mapStream as a3, rangeStream as a4, zip as a5, foreachStream as a6, fromArray as a7, collectStream as a8, streamFromReadableStream as a9, type FiberId as aa, type FiberStatus as ab, RuntimeFiber as ac, type ScopeId as ad, Scope as ae, withScope as af, type Task as ag, globalScheduler as ah, flatMap as b, mapError as c, catchAll as d, end as e, fail as f, asyncFold as g, asyncCatchAll as h, asyncMapError as i, asyncSucceed as j, asyncFail as k, asyncSync as l, map as m, asyncTotal as n, orElseOptional as o, async as p, asyncMap as q, asyncFlatMap as r, succeed as s, acquireRelease as t, unit as u, asyncInterruptible as v, type Some as w, none as x, some as y, type CancelToken as z };
|
package/package.json
CHANGED
package/dist/chunk-BQ3I6L5Z.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';function E(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function D(n,e){return E(n,t=>e(t),t=>A(t))}function P(n,e){return E(n,t=>m(e(t)),t=>A(t))}var T=()=>A(void 0),A=n=>({_tag:"Succeed",value:n}),m=n=>({_tag:"Fail",error:n}),S=n=>({_tag:"Sync",thunk:n}),I=n=>S(()=>n()),l=n=>({_tag:"Async",register:n});function C(n,e){return p(n,t=>A(e(t)))}function p(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function z(n,e,t){return p(n,r=>(t.addFinalizer(i=>e(r,i)),A(r)))}function U(n){return l(n)}var d=class{buf;head=0;tail=0;size_=0;constructor(e=1024){let t=Math.max(2,this.nextPow2(e));this.buf=new Array(t);}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,t=new Array(e.length*2);for(let r=0;r<this.size_;r++)t[r]=e[this.head+r&e.length-1];this.buf=t,this.head=0,this.tail=this.size_;}nextPow2(e){let t=1;for(;t<e;)t<<=1;return t}};var g=2048,R=4096,x=(()=>{if(typeof globalThis.setImmediate=="function")return n=>globalThis.setImmediate(n);if(typeof globalThis.MessageChannel=="function"){let n=new globalThis.MessageChannel,e=null;return n.port1.onmessage=()=>{let t=e;e=null,t?.();},t=>{e=t,n.port2.postMessage(0);}}return n=>setTimeout(n,0)})(),y=class{queue=new d(1024);flushing=false;scheduled=false;schedule(e,t="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:t,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>R?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):x(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<g;){let t=this.queue.shift();if(!t)break;e++;try{t.task();}catch(r){console.error(`[Scheduler] task threw (tag=${t.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let t=e>=g||this.queue.length>R?"macro":"micro";this.requestFlush(t);}}}},b=new y;var u={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},c={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},F=1,_=1024;function k(n){let e=n;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let t=e.first,r=e.andThen;e={_tag:"FlatMap",first:t.first,andThen:i=>({_tag:"FlatMap",first:t.andThen(i),andThen:r})};}return e}var f=class{constructor(e,t,r){this.scheduler=r;this.id=F++,this.current=e,this.env=t;}id;closing=null;finishing=false;runState=c.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===c.DONE||this.runState===c.QUEUED||(this.runState=c.QUEUED,this.scheduler.schedule(()=>{if(this.runState===c.DONE)return;switch(this.runState=c.RUNNING,this.step()){case u.CONTINUE:this.schedule("continue");return;case u.SUSPEND:this.runState=c.SUSPENDED;return;case u.DONE:this.runState=c.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let t=this.fiberFinalizers.pop();try{t(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 t of this.joiners)t(e);this.joiners.length=0;}}onSuccess(e){let t=this.stack.pop();if(!t){this.notify({_tag:"Success",value:e});return}this.current=t._tag==="SuccessCont"?t.k(e):t.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let t=this.stack.pop();if(t._tag==="FoldCont"){this.current=t.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=_;for(;e-- >0;){if(this.result!=null)return u.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),u.DONE;let t=k(this.current);switch(t._tag){case "Succeed":{this.onSuccess(t.value);break}case "Fail":{this.onFailure(t.error);break}case "Sync":{try{let r=t.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:t.andThen}),this.current=t.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:t.onFailure,onSuccess:t.onSuccess}),this.current=t.first;break}case "Async":{if(this.finishing)return this.result!=null?u.DONE:u.CONTINUE;let r=false,i=o=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=o._tag==="Success"?{_tag:"Succeed",value:o.value}:{_tag:"Fail",error:o.error},this.schedule("async-resume")));},s=t.register(this.env,i);return typeof s=="function"&&this.addFinalizer(()=>{r=true;try{s();}catch{}}),u.SUSPEND}}}return this.result!=null?u.DONE:u.CONTINUE}};function V(n){return l((e,t)=>{let r=false,i=a=>{r||(r=true,t(a));},s=a=>i({_tag:"Failure",error:a instanceof Error?a:new Error(String(a))}),o=a=>i({_tag:"Success",value:a});try{typeof n=="function"&&n.length>=1?n((a,h)=>a?s(a):o(h)):n().then(o,s);}catch(a){s(a);}})}function v(n,e,t=b){let r=new f(n,e,t);return r.schedule("initial-step"),r}function W(n,e,t){v(n,e).join(t);}function X(n,e){return new Promise((t,r)=>{v(n,e).join(s=>{let o=s;o._tag==="Success"?t(o.value):r(o.error);});})}function Y(n,e){return l((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function Z(n){return l((e,t)=>{let r=false,i=s=>{r||(r=true,t(s));};try{n((s,o)=>{i(s?{_tag:"Failure",error:s}:{_tag:"Success",value:o});});}catch(s){i({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))});}})}function ee(n){return w((t,r)=>n.length===1?n(r):n(t,r),t=>N(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function w(n,e){return l((t,r)=>{let i=new AbortController,s=false,o=a=>{s||(s=true,r(a));};try{(n.length===1?n(i.signal):n(t,i.signal)).then(h=>o({_tag:"Success",value:h})).catch(h=>o({_tag:"Failure",error:e(h)}));}catch(a){o({_tag:"Failure",error:e(a)});}return ()=>{s=true,i.abort();}})}var N=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";exports.a=E;exports.b=D;exports.c=P;exports.d=T;exports.e=A;exports.f=m;exports.g=S;exports.h=I;exports.i=l;exports.j=C;exports.k=p;exports.l=z;exports.m=U;exports.n=y;exports.o=b;exports.p=f;exports.q=V;exports.r=v;exports.s=W;exports.t=X;exports.u=Y;exports.v=Z;exports.w=ee;exports.x=w;
|
package/dist/chunk-SMCQ6GGV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function E(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function D(n,e){return E(n,t=>e(t),t=>A(t))}function P(n,e){return E(n,t=>m(e(t)),t=>A(t))}var T=()=>A(void 0),A=n=>({_tag:"Succeed",value:n}),m=n=>({_tag:"Fail",error:n}),S=n=>({_tag:"Sync",thunk:n}),I=n=>S(()=>n()),l=n=>({_tag:"Async",register:n});function C(n,e){return p(n,t=>A(e(t)))}function p(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function z(n,e,t){return p(n,r=>(t.addFinalizer(i=>e(r,i)),A(r)))}function U(n){return l(n)}var d=class{buf;head=0;tail=0;size_=0;constructor(e=1024){let t=Math.max(2,this.nextPow2(e));this.buf=new Array(t);}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,t=new Array(e.length*2);for(let r=0;r<this.size_;r++)t[r]=e[this.head+r&e.length-1];this.buf=t,this.head=0,this.tail=this.size_;}nextPow2(e){let t=1;for(;t<e;)t<<=1;return t}};var g=2048,R=4096,x=(()=>{if(typeof globalThis.setImmediate=="function")return n=>globalThis.setImmediate(n);if(typeof globalThis.MessageChannel=="function"){let n=new globalThis.MessageChannel,e=null;return n.port1.onmessage=()=>{let t=e;e=null,t?.();},t=>{e=t,n.port2.postMessage(0);}}return n=>setTimeout(n,0)})(),y=class{queue=new d(1024);flushing=false;scheduled=false;schedule(e,t="anonymous"){if(typeof e=="function"&&(this.queue.push({tag:t,task:e}),!this.flushing&&!this.scheduled)){this.scheduled=true;let r=this.queue.length>R?"macro":"micro";this.requestFlush(r);}}requestFlush(e){e==="micro"?queueMicrotask(()=>this.flush()):x(()=>this.flush());}flush(){if(this.flushing)return;this.flushing=true,this.scheduled=false;let e=0;try{for(;e<g;){let t=this.queue.shift();if(!t)break;e++;try{t.task();}catch(r){console.error(`[Scheduler] task threw (tag=${t.tag})`,r);}}}finally{if(this.flushing=false,this.queue.length>0&&!this.scheduled){this.scheduled=true;let t=e>=g||this.queue.length>R?"macro":"micro";this.requestFlush(t);}}}},b=new y;var u={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},c={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},F=1,_=1024;function k(n){let e=n;for(;e._tag==="FlatMap"&&e.first._tag==="FlatMap";){let t=e.first,r=e.andThen;e={_tag:"FlatMap",first:t.first,andThen:i=>({_tag:"FlatMap",first:t.andThen(i),andThen:r})};}return e}var f=class{constructor(e,t,r){this.scheduler=r;this.id=F++,this.current=e,this.env=t;}id;closing=null;finishing=false;runState=c.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===c.DONE||this.runState===c.QUEUED||(this.runState=c.QUEUED,this.scheduler.schedule(()=>{if(this.runState===c.DONE)return;switch(this.runState=c.RUNNING,this.step()){case u.CONTINUE:this.schedule("continue");return;case u.SUSPEND:this.runState=c.SUSPENDED;return;case u.DONE:this.runState=c.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let t=this.fiberFinalizers.pop();try{t(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 t of this.joiners)t(e);this.joiners.length=0;}}onSuccess(e){let t=this.stack.pop();if(!t){this.notify({_tag:"Success",value:e});return}this.current=t._tag==="SuccessCont"?t.k(e):t.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let t=this.stack.pop();if(t._tag==="FoldCont"){this.current=t.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){let e=_;for(;e-- >0;){if(this.result!=null)return u.DONE;if(this.interrupted&&this.closing==null)return this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),u.DONE;let t=k(this.current);switch(t._tag){case "Succeed":{this.onSuccess(t.value);break}case "Fail":{this.onFailure(t.error);break}case "Sync":{try{let r=t.thunk(this.env);this.onSuccess(r);}catch(r){this.onFailure(r);}break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:t.andThen}),this.current=t.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:t.onFailure,onSuccess:t.onSuccess}),this.current=t.first;break}case "Async":{if(this.finishing)return this.result!=null?u.DONE:u.CONTINUE;let r=false,i=o=>{r||(r=true,!(this.result!=null||this.closing!=null)&&(this.current=o._tag==="Success"?{_tag:"Succeed",value:o.value}:{_tag:"Fail",error:o.error},this.schedule("async-resume")));},s=t.register(this.env,i);return typeof s=="function"&&this.addFinalizer(()=>{r=true;try{s();}catch{}}),u.SUSPEND}}}return this.result!=null?u.DONE:u.CONTINUE}};function V(n){return l((e,t)=>{let r=false,i=a=>{r||(r=true,t(a));},s=a=>i({_tag:"Failure",error:a instanceof Error?a:new Error(String(a))}),o=a=>i({_tag:"Success",value:a});try{typeof n=="function"&&n.length>=1?n((a,h)=>a?s(a):o(h)):n().then(o,s);}catch(a){s(a);}})}function v(n,e,t=b){let r=new f(n,e,t);return r.schedule("initial-step"),r}function W(n,e,t){v(n,e).join(t);}function X(n,e){return new Promise((t,r)=>{v(n,e).join(s=>{let o=s;o._tag==="Success"?t(o.value):r(o.error);});})}function Y(n,e){return l((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function Z(n){return l((e,t)=>{let r=false,i=s=>{r||(r=true,t(s));};try{n((s,o)=>{i(s?{_tag:"Failure",error:s}:{_tag:"Success",value:o});});}catch(s){i({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))});}})}function ee(n){return w((t,r)=>n.length===1?n(r):n(t,r),t=>N(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function w(n,e){return l((t,r)=>{let i=new AbortController,s=false,o=a=>{s||(s=true,r(a));};try{(n.length===1?n(i.signal):n(t,i.signal)).then(h=>o({_tag:"Success",value:h})).catch(h=>o({_tag:"Failure",error:e(h)}));}catch(a){o({_tag:"Failure",error:e(a)});}return ()=>{s=true,i.abort();}})}var N=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";export{E as a,D as b,P as c,T as d,A as e,m as f,S as g,I as h,l as i,C as j,p as k,z as l,U as m,y as n,b as o,f as p,V as q,v as r,W as s,X as t,Y as u,Z as v,ee as w,w as x};
|