brass-runtime 1.7.0 → 1.7.2
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-LRGO34YG.js → chunk-M3UFQBVT.js} +1 -1
- package/dist/{chunk-7M74PYBY.mjs → chunk-MOD6OFUQ.mjs} +1 -1
- package/dist/http/index.d.mts +13 -2
- package/dist/http/index.d.ts +13 -2
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +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;
|
|
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;
|
|
@@ -1 +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};
|
|
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};
|
package/dist/http/index.d.mts
CHANGED
|
@@ -10,12 +10,13 @@ type HttpError = {
|
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
12
|
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
13
|
+
type HttpInit = Omit<RequestInit, "method" | "body" | "headers">;
|
|
13
14
|
type HttpRequest = {
|
|
14
15
|
method: HttpMethod;
|
|
15
16
|
url: string;
|
|
16
17
|
headers?: Record<string, string>;
|
|
17
18
|
body?: string;
|
|
18
|
-
init?:
|
|
19
|
+
init?: HttpInit;
|
|
19
20
|
};
|
|
20
21
|
type HttpWireResponse = {
|
|
21
22
|
status: number;
|
|
@@ -63,11 +64,21 @@ declare function httpClient(cfg?: MakeHttpConfig): {
|
|
|
63
64
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
64
65
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<string>>;
|
|
65
66
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<A>>;
|
|
67
|
+
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
68
|
+
postJson: <A>(url: string, bodyObj: A, init?: HttpInit & {
|
|
69
|
+
headers?: Record<string, string>;
|
|
70
|
+
}) => Async<unknown, HttpError, HttpWireResponse>;
|
|
66
71
|
};
|
|
67
72
|
declare function httpClientWithMeta(cfg?: MakeHttpConfig): {
|
|
68
73
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
69
74
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
70
75
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<A>>;
|
|
76
|
+
post: (url: string, body?: string, init?: HttpInit & {
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
}) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
79
|
+
postJson: <A>(url: string, bodyObj: A, init?: HttpInit & {
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
}) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
71
82
|
};
|
|
72
83
|
type HttpClientDxStream = {
|
|
73
84
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpResponseStream>;
|
|
@@ -77,4 +88,4 @@ type HttpClientDxStream = {
|
|
|
77
88
|
};
|
|
78
89
|
declare function httpClientStream(cfg?: MakeHttpConfig): HttpClientDxStream;
|
|
79
90
|
|
|
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 };
|
|
91
|
+
export { type HttpClient, type HttpClientDxStream, type HttpClientStream, type HttpError, type HttpInit, 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
|
@@ -10,12 +10,13 @@ type HttpError = {
|
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
12
|
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
13
|
+
type HttpInit = Omit<RequestInit, "method" | "body" | "headers">;
|
|
13
14
|
type HttpRequest = {
|
|
14
15
|
method: HttpMethod;
|
|
15
16
|
url: string;
|
|
16
17
|
headers?: Record<string, string>;
|
|
17
18
|
body?: string;
|
|
18
|
-
init?:
|
|
19
|
+
init?: HttpInit;
|
|
19
20
|
};
|
|
20
21
|
type HttpWireResponse = {
|
|
21
22
|
status: number;
|
|
@@ -63,11 +64,21 @@ declare function httpClient(cfg?: MakeHttpConfig): {
|
|
|
63
64
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
64
65
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<string>>;
|
|
65
66
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponse<A>>;
|
|
67
|
+
post: (url: string, body?: string, init?: Omit<RequestInit, "method" | "body">) => Async<unknown, HttpError, HttpWireResponse>;
|
|
68
|
+
postJson: <A>(url: string, bodyObj: A, init?: HttpInit & {
|
|
69
|
+
headers?: Record<string, string>;
|
|
70
|
+
}) => Async<unknown, HttpError, HttpWireResponse>;
|
|
66
71
|
};
|
|
67
72
|
declare function httpClientWithMeta(cfg?: MakeHttpConfig): {
|
|
68
73
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpWireResponse>;
|
|
69
74
|
getText: (url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
70
75
|
getJson: <A>(url: string, init?: Omit<RequestInit, "method">) => Async<unknown, HttpError, HttpResponseWithMeta<A>>;
|
|
76
|
+
post: (url: string, body?: string, init?: HttpInit & {
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
}) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
79
|
+
postJson: <A>(url: string, bodyObj: A, init?: HttpInit & {
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
}) => Async<unknown, HttpError, HttpResponseWithMeta<string>>;
|
|
71
82
|
};
|
|
72
83
|
type HttpClientDxStream = {
|
|
73
84
|
request: (req: HttpRequest) => Async<unknown, HttpError, HttpResponseStream>;
|
|
@@ -77,4 +88,4 @@ type HttpClientDxStream = {
|
|
|
77
88
|
};
|
|
78
89
|
declare function httpClientStream(cfg?: MakeHttpConfig): HttpClientDxStream;
|
|
79
90
|
|
|
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 };
|
|
91
|
+
export { type HttpClient, type HttpClientDxStream, type HttpClientStream, type HttpError, type HttpInit, 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 chunkM3UFQBVT_js=require('../chunk-M3UFQBVT.js');function f(e={}){let o=e.baseUrl??"",n=e.headers??{};return p=>chunkM3UFQBVT_js.I(async i=>{let u=new URL(p.url,o),a=performance.now(),t=await fetch(u,{...p.init??{},method:p.method,headers:{...n,...p.headers??{}},body:p.body,signal:i}),s={};t.headers.forEach((d,m)=>s[m]=d);let r=chunkM3UFQBVT_js.aa(t.body,R);return {status:t.status,statusText:t.statusText,headers:s,body:r,ms:Math.round(performance.now()-a)}},R)}var R=e=>e instanceof DOMException&&e.name==="AbortError"?{_tag:"Abort"}:typeof e=="object"&&e&&"_tag"in e?e:{_tag:"FetchError",message:String(e)};function A(e={}){let o=e.baseUrl??"",n=e.headers??{};return p=>chunkM3UFQBVT_js.I(async i=>{let u;try{u=new URL(p.url,o);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${p.url}`}}let a=performance.now(),t=await fetch(u,{...p.init??{},method:p.method,headers:{...n,...p.headers??{}},body:p.body,signal:i}),s=await t.text(),r={};return t.headers.forEach((d,m)=>r[m]=d),{status:t.status,statusText:t.statusText,headers:r,bodyText:s,ms:Math.round(performance.now()-a)}},R)}var q=(e,o)=>chunkM3UFQBVT_js.k(e,n=>chunkM3UFQBVT_js.e(o(n))),c=(e,o)=>chunkM3UFQBVT_js.k(e,n=>chunkM3UFQBVT_js.g(()=>o(n)));var S=(e,o)=>({status:e.status,headers:e.headers,body:o}),h=(e,o)=>({status:e.status,headers:e.headers,body:o,meta:{statusText:e.statusText,ms:e.ms}});function L(e={}){let o=A(e),n=(t,s,r)=>i({method:"POST",url:t,body:s&&s.length>0?s:void 0,init:r}),p=(t,s,r)=>{let{headers:d,...m}=r??{};return i({method:"POST",url:t,body:JSON.stringify(s),headers:{"content-type":"application/json",...d??{}},init:m})},i=t=>o(t);return {request:i,getText:(t,s)=>c(i({method:"GET",url:t,init:s}),r=>S(r,r.bodyText)),getJson:(t,s)=>c(i({method:"GET",url:t,init:s}),r=>S(r,JSON.parse(r.bodyText))),post:n,postJson:p}}function Z(e={}){let o=A(e),n=t=>o(t);return {request:n,getText:(t,s)=>c(n({method:"GET",url:t,init:s}),r=>h(r,r.bodyText)),getJson:(t,s)=>c(n({method:"GET",url:t,init:s}),r=>h(r,JSON.parse(r.bodyText))),post:(t,s,r)=>{let{headers:d,...m}=r??{};return c(n({method:"POST",url:t,body:s&&s.length>0?s:void 0,headers:d,init:m}),g=>h(g,g.bodyText))},postJson:(t,s,r)=>{let{headers:d,...m}=r??{};return c(n({method:"POST",url:t,body:JSON.stringify(s),headers:{"content-type":"application/json",...d??{}},init:m}),g=>h(g,g.bodyText))}}}var T=e=>({status:e.status,headers:e.headers,body:e.body});function F(e={}){let o=f(e),n=a=>c(o(a),T);return {request:n,get:(a,t)=>n({method:"GET",url:a,init:t}),post:(a,t,s)=>n({method:"POST",url:a,body:t&&t.length>0?t:void 0,init:s}),postJson:(a,t,s)=>n({method:"POST",url:a,body:JSON.stringify(t),headers:{"content-type":"application/json",...s?.headers},init:{...s??{}}})}}exports.httpClient=L;exports.httpClientStream=F;exports.httpClientWithMeta=Z;exports.makeHttp=A;exports.makeHttpStream=f;exports.mapAsync=q;exports.mapTryAsync=c;
|
package/dist/http/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {k,I,aa,e,g
|
|
1
|
+
import {k,I,aa,e,g}from'../chunk-MOD6OFUQ.mjs';function f(e={}){let o=e.baseUrl??"",n=e.headers??{};return p=>I(async i=>{let u=new URL(p.url,o),a=performance.now(),t=await fetch(u,{...p.init??{},method:p.method,headers:{...n,...p.headers??{}},body:p.body,signal:i}),s={};t.headers.forEach((d,m)=>s[m]=d);let r=aa(t.body,R);return {status:t.status,statusText:t.statusText,headers:s,body:r,ms:Math.round(performance.now()-a)}},R)}var R=e=>e instanceof DOMException&&e.name==="AbortError"?{_tag:"Abort"}:typeof e=="object"&&e&&"_tag"in e?e:{_tag:"FetchError",message:String(e)};function A(e={}){let o=e.baseUrl??"",n=e.headers??{};return p=>I(async i=>{let u;try{u=new URL(p.url,o);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${p.url}`}}let a=performance.now(),t=await fetch(u,{...p.init??{},method:p.method,headers:{...n,...p.headers??{}},body:p.body,signal:i}),s=await t.text(),r={};return t.headers.forEach((d,m)=>r[m]=d),{status:t.status,statusText:t.statusText,headers:r,bodyText:s,ms:Math.round(performance.now()-a)}},R)}var q=(e$1,o)=>k(e$1,n=>e(o(n))),c=(e,o)=>k(e,n=>g(()=>o(n)));var S=(e,o)=>({status:e.status,headers:e.headers,body:o}),h=(e,o)=>({status:e.status,headers:e.headers,body:o,meta:{statusText:e.statusText,ms:e.ms}});function L(e={}){let o=A(e),n=(t,s,r)=>i({method:"POST",url:t,body:s&&s.length>0?s:void 0,init:r}),p=(t,s,r)=>{let{headers:d,...m}=r??{};return i({method:"POST",url:t,body:JSON.stringify(s),headers:{"content-type":"application/json",...d??{}},init:m})},i=t=>o(t);return {request:i,getText:(t,s)=>c(i({method:"GET",url:t,init:s}),r=>S(r,r.bodyText)),getJson:(t,s)=>c(i({method:"GET",url:t,init:s}),r=>S(r,JSON.parse(r.bodyText))),post:n,postJson:p}}function Z(e={}){let o=A(e),n=t=>o(t);return {request:n,getText:(t,s)=>c(n({method:"GET",url:t,init:s}),r=>h(r,r.bodyText)),getJson:(t,s)=>c(n({method:"GET",url:t,init:s}),r=>h(r,JSON.parse(r.bodyText))),post:(t,s,r)=>{let{headers:d,...m}=r??{};return c(n({method:"POST",url:t,body:s&&s.length>0?s:void 0,headers:d,init:m}),g=>h(g,g.bodyText))},postJson:(t,s,r)=>{let{headers:d,...m}=r??{};return c(n({method:"POST",url:t,body:JSON.stringify(s),headers:{"content-type":"application/json",...d??{}},init:m}),g=>h(g,g.bodyText))}}}var T=e=>({status:e.status,headers:e.headers,body:e.body});function F(e={}){let o=f(e),n=a=>c(o(a),T);return {request:n,get:(a,t)=>n({method:"GET",url:a,init:t}),post:(a,t,s)=>n({method:"POST",url:a,body:t&&t.length>0?t:void 0,init:s}),postJson:(a,t,s)=>n({method:"POST",url:a,body:JSON.stringify(t),headers:{"content-type":"application/json",...s?.headers},init:{...s??{}}})}}export{L as httpClient,F as httpClientStream,Z as httpClientWithMeta,A as makeHttp,f as makeHttpStream,q as mapAsync,c as mapTryAsync};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkM3UFQBVT_js=require('./chunk-M3UFQBVT.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 chunkM3UFQBVT_js.A}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkM3UFQBVT_js.y}});Object.defineProperty(exports,"Scope",{enumerable:true,get:function(){return chunkM3UFQBVT_js.J}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkM3UFQBVT_js.l}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkM3UFQBVT_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkM3UFQBVT_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkM3UFQBVT_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkM3UFQBVT_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkM3UFQBVT_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkM3UFQBVT_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkM3UFQBVT_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkM3UFQBVT_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkM3UFQBVT_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkM3UFQBVT_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkM3UFQBVT_js.h}});Object.defineProperty(exports,"catchAll",{enumerable:true,get:function(){return chunkM3UFQBVT_js.v}});Object.defineProperty(exports,"collectStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.$}});Object.defineProperty(exports,"concatStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.S}});Object.defineProperty(exports,"emitStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.R}});Object.defineProperty(exports,"emptyStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.Q}});Object.defineProperty(exports,"end",{enumerable:true,get:function(){return chunkM3UFQBVT_js.x}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkM3UFQBVT_js.q}});Object.defineProperty(exports,"flatMap",{enumerable:true,get:function(){return chunkM3UFQBVT_js.t}});Object.defineProperty(exports,"flattenStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.T}});Object.defineProperty(exports,"foreachStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.Z}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkM3UFQBVT_js.C}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkM3UFQBVT_js.B}});Object.defineProperty(exports,"fromArray",{enumerable:true,get:function(){return chunkM3UFQBVT_js._}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkM3UFQBVT_js.G}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkM3UFQBVT_js.F}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkM3UFQBVT_js.I}});Object.defineProperty(exports,"fromPull",{enumerable:true,get:function(){return chunkM3UFQBVT_js.M}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkM3UFQBVT_js.z}});Object.defineProperty(exports,"managedStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.O}});Object.defineProperty(exports,"map",{enumerable:true,get:function(){return chunkM3UFQBVT_js.s}});Object.defineProperty(exports,"mapError",{enumerable:true,get:function(){return chunkM3UFQBVT_js.u}});Object.defineProperty(exports,"mapStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.W}});Object.defineProperty(exports,"merge",{enumerable:true,get:function(){return chunkM3UFQBVT_js.U}});Object.defineProperty(exports,"mergeStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.P}});Object.defineProperty(exports,"none",{enumerable:true,get:function(){return chunkM3UFQBVT_js.n}});Object.defineProperty(exports,"orElseOptional",{enumerable:true,get:function(){return chunkM3UFQBVT_js.w}});Object.defineProperty(exports,"rangeStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.X}});Object.defineProperty(exports,"some",{enumerable:true,get:function(){return chunkM3UFQBVT_js.o}});Object.defineProperty(exports,"streamFromReadableStream",{enumerable:true,get:function(){return chunkM3UFQBVT_js.aa}});Object.defineProperty(exports,"succeed",{enumerable:true,get:function(){return chunkM3UFQBVT_js.p}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkM3UFQBVT_js.r}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkM3UFQBVT_js.E}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkM3UFQBVT_js.H}});Object.defineProperty(exports,"uncons",{enumerable:true,get:function(){return chunkM3UFQBVT_js.V}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkM3UFQBVT_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkM3UFQBVT_js.D}});Object.defineProperty(exports,"unwrapScoped",{enumerable:true,get:function(){return chunkM3UFQBVT_js.N}});Object.defineProperty(exports,"widenOpt",{enumerable:true,get:function(){return chunkM3UFQBVT_js.L}});Object.defineProperty(exports,"withScope",{enumerable:true,get:function(){return chunkM3UFQBVT_js.K}});Object.defineProperty(exports,"zip",{enumerable:true,get:function(){return chunkM3UFQBVT_js.Y}});exports.linkAbortController=ce;exports.makeCancelToken=te;
|
package/dist/index.mjs
CHANGED
|
@@ -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-
|
|
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-MOD6OFUQ.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};
|