brass-runtime 1.4.0 → 1.4.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-77P3VCG2.js +1 -0
- package/dist/chunk-EZTDSZ4Y.mjs +1 -0
- package/dist/http/{index.d.cts → index.d.mts} +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -0
- package/dist/{index.d.cts → index.d.mts} +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/package.json +11 -12
- package/dist/chunk-ABGJNLHY.js +0 -1
- package/dist/chunk-C6HOJTND.cjs +0 -1
- package/dist/http/index.cjs +0 -1
- package/dist/index.cjs +0 -1
- /package/dist/{effect-D4h--Rys.d.cts → effect-D4h--Rys.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var h=class{queue=[];flushing=false;requested=false;schedule(e,t="anonymous"){if(console.log("[Scheduler.schedule] typeof task =",typeof e,"tag=",t),typeof e!="function"){console.error("[Scheduler.schedule] NON-FUNCTION TASK!",{tag:t,task:e});return}this.queue.push({tag:t,task:e}),this.requestFlush(),console.log("SCHEDULER",{flushing:this.flushing,q:this.queue.length,next:this.queue[0]?.tag,head:this.queue.slice(0,5).map(r=>r.tag)});}requestFlush(){console.log("requestFlush",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),!this.flushing&&(this.requested||(this.requested=true,queueMicrotask(()=>{console.log(">> microtask fired",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),this.flush();})));}flush(){if(console.log("FLUSH enter",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),!this.flushing){this.flushing=true,this.requested=false;try{for(;this.queue.length>0;){let e=this.queue.shift();console.log("[flush] dequeued",{tag:e.tag,typeofTask:typeof e.task});try{console.log("TASK typeof",typeof e.task),e.task();}catch(t){console.error("[flush] task threw",t);}}}finally{this.flushing=false,console.log("FLUSH exit",{requested:this.requested,q:this.queue.length}),this.queue.length>0&&this.requestFlush();}}}},d=new h;var E=1,A=class{constructor(e,t,r){this.scheduler=r;this.id=E++,this.current=e,this.env=t;}id;closing=null;finishing=false;statusValue="Running";interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];scheduled=false;finalizersDrained=false;blockedOnAsync=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.statusValue}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.blockedOnAsync=false,this.schedule("interrupt-step")));}schedule(e="step"){console.log("[fiber.schedule]",{fiber:this.id,tag:e,schedulerCtor:this.scheduler?.constructor?.name,schedulerScheduleType:typeof this.scheduler?.schedule}),this.result==null&&(this.scheduled||(this.scheduled=true,this.scheduler.schedule(()=>{console.log("[fiber.task] running",this.id),this.scheduled=false,this.step();},`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.statusValue=this.interrupted?"Interrupted":"Done",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(){if(console.log("[fiber.step] enter",{fiber:this.id,current:this.current?._tag,result:this.result!=null,blockedOnAsync:this.blockedOnAsync,interrupted:this.interrupted,closing:this.closing!=null,finishing:this.finishing,stack:this.stack.length}),this.result!=null){console.log("[fiber.step] early-exit: already has result",{fiber:this.id});return}if(this.blockedOnAsync){console.log("[fiber.step] early-exit: blockedOnAsync",{fiber:this.id});return}if(this.interrupted&&this.closing==null){console.log("[fiber.step] interrupted: failing now",{fiber:this.id}),this.notify({_tag:"Failure",error:{_tag:"Interrupted"}});return}let e=this.current;switch(e._tag){case "Succeed":{console.log("[fiber.step] Succeed",{fiber:this.id}),this.onSuccess(e.value);return}case "Fail":{console.log("[fiber.step] Fail",{fiber:this.id}),this.onFailure(e.error);return}case "Sync":{console.log("[fiber.step] Sync",{fiber:this.id});try{let t=e.thunk(this.env);console.log("[fiber.step] Sync success",{fiber:this.id}),this.onSuccess(t);}catch(t){console.log("[fiber.step] Sync threw",{fiber:this.id,e:t}),this.onFailure(t);}return}case "FlatMap":{console.log("[fiber.step] FlatMap push cont",{fiber:this.id}),this.stack.push({_tag:"SuccessCont",k:e.andThen}),this.current=e.first;return}case "Fold":{console.log("[fiber.step] Fold push cont",{fiber:this.id}),this.stack.push({_tag:"FoldCont",onFailure:e.onFailure,onSuccess:e.onSuccess}),this.current=e.first;return}case "Async":{if(this.finishing)return;this.blockedOnAsync=true;let t=false,r=o=>{if(this.blockedOnAsync=false,!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}o._tag==="Success"?this.onSuccess(o.value):this.onFailure(o.error),this.schedule("async-resume");}},i=o=>{t||(t=true,this.scheduler.schedule(()=>r(o),`fiber#${this.id}.async-resume`));},s=e.register(this.env,i);typeof s=="function"&&this.addFinalizer(()=>{t=true;try{s();}catch{}});return}}}};function f(n,e,t=d){let r=new A(n,e,t);return r.schedule("initial-step"),r}function y(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function q(n,e){return y(n,t=>e(t),t=>l(t))}function w(n,e){return y(n,t=>b(e(t)),t=>l(t))}function P(n){return c((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,u)=>a?s(a):o(u)):n().then(o,s);}catch(a){s(a);}})}function I(){return p(()=>{})}var l=n=>({_tag:"Succeed",value:n}),b=n=>({_tag:"Fail",error:n}),p=n=>({_tag:"Sync",thunk:n}),C=n=>p(()=>n()),c=n=>({_tag:"Async",register:n});function B(n,e){return g(n,t=>l(e(t)))}function g(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function T(n,e){return new Promise((t,r)=>{f(n,e).join(s=>{let o=s;o._tag==="Success"?t(o.value):r(o.error);});})}function z(n,e){return c((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function j(n){return c((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))});}})}var v=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";function O(n){return R((t,r)=>n.length===1?n(r):n(t,r),t=>v(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function R(n,e){return c((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(u=>o({_tag:"Success",value:u})).catch(u=>o({_tag:"Failure",error:e(u)}));}catch(a){o({_tag:"Failure",error:e(a)});}return ()=>{s=true,i.abort();}})}function M(n,e,t){return g(n,r=>(t.addFinalizer(i=>e(r,i)),l(r)))}function N(n){return c(n)}exports.a=h;exports.b=d;exports.c=f;exports.d=y;exports.e=q;exports.f=w;exports.g=P;exports.h=I;exports.i=l;exports.j=b;exports.k=p;exports.l=C;exports.m=c;exports.n=B;exports.o=g;exports.p=T;exports.q=z;exports.r=j;exports.s=O;exports.t=R;exports.u=M;exports.v=N;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=class{queue=[];flushing=false;requested=false;schedule(e,t="anonymous"){if(console.log("[Scheduler.schedule] typeof task =",typeof e,"tag=",t),typeof e!="function"){console.error("[Scheduler.schedule] NON-FUNCTION TASK!",{tag:t,task:e});return}this.queue.push({tag:t,task:e}),this.requestFlush(),console.log("SCHEDULER",{flushing:this.flushing,q:this.queue.length,next:this.queue[0]?.tag,head:this.queue.slice(0,5).map(r=>r.tag)});}requestFlush(){console.log("requestFlush",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),!this.flushing&&(this.requested||(this.requested=true,queueMicrotask(()=>{console.log(">> microtask fired",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),this.flush();})));}flush(){if(console.log("FLUSH enter",{flushing:this.flushing,requested:this.requested,q:this.queue.length}),!this.flushing){this.flushing=true,this.requested=false;try{for(;this.queue.length>0;){let e=this.queue.shift();console.log("[flush] dequeued",{tag:e.tag,typeofTask:typeof e.task});try{console.log("TASK typeof",typeof e.task),e.task();}catch(t){console.error("[flush] task threw",t);}}}finally{this.flushing=false,console.log("FLUSH exit",{requested:this.requested,q:this.queue.length}),this.queue.length>0&&this.requestFlush();}}}},d=new h;var E=1,A=class{constructor(e,t,r){this.scheduler=r;this.id=E++,this.current=e,this.env=t;}id;closing=null;finishing=false;statusValue="Running";interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];scheduled=false;finalizersDrained=false;blockedOnAsync=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.statusValue}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.blockedOnAsync=false,this.schedule("interrupt-step")));}schedule(e="step"){console.log("[fiber.schedule]",{fiber:this.id,tag:e,schedulerCtor:this.scheduler?.constructor?.name,schedulerScheduleType:typeof this.scheduler?.schedule}),this.result==null&&(this.scheduled||(this.scheduled=true,this.scheduler.schedule(()=>{console.log("[fiber.task] running",this.id),this.scheduled=false,this.step();},`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.statusValue=this.interrupted?"Interrupted":"Done",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(){if(console.log("[fiber.step] enter",{fiber:this.id,current:this.current?._tag,result:this.result!=null,blockedOnAsync:this.blockedOnAsync,interrupted:this.interrupted,closing:this.closing!=null,finishing:this.finishing,stack:this.stack.length}),this.result!=null){console.log("[fiber.step] early-exit: already has result",{fiber:this.id});return}if(this.blockedOnAsync){console.log("[fiber.step] early-exit: blockedOnAsync",{fiber:this.id});return}if(this.interrupted&&this.closing==null){console.log("[fiber.step] interrupted: failing now",{fiber:this.id}),this.notify({_tag:"Failure",error:{_tag:"Interrupted"}});return}let e=this.current;switch(e._tag){case "Succeed":{console.log("[fiber.step] Succeed",{fiber:this.id}),this.onSuccess(e.value);return}case "Fail":{console.log("[fiber.step] Fail",{fiber:this.id}),this.onFailure(e.error);return}case "Sync":{console.log("[fiber.step] Sync",{fiber:this.id});try{let t=e.thunk(this.env);console.log("[fiber.step] Sync success",{fiber:this.id}),this.onSuccess(t);}catch(t){console.log("[fiber.step] Sync threw",{fiber:this.id,e:t}),this.onFailure(t);}return}case "FlatMap":{console.log("[fiber.step] FlatMap push cont",{fiber:this.id}),this.stack.push({_tag:"SuccessCont",k:e.andThen}),this.current=e.first;return}case "Fold":{console.log("[fiber.step] Fold push cont",{fiber:this.id}),this.stack.push({_tag:"FoldCont",onFailure:e.onFailure,onSuccess:e.onSuccess}),this.current=e.first;return}case "Async":{if(this.finishing)return;this.blockedOnAsync=true;let t=false,r=o=>{if(this.blockedOnAsync=false,!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}o._tag==="Success"?this.onSuccess(o.value):this.onFailure(o.error),this.schedule("async-resume");}},i=o=>{t||(t=true,this.scheduler.schedule(()=>r(o),`fiber#${this.id}.async-resume`));},s=e.register(this.env,i);typeof s=="function"&&this.addFinalizer(()=>{t=true;try{s();}catch{}});return}}}};function f(n,e,t=d){let r=new A(n,e,t);return r.schedule("initial-step"),r}function y(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function q(n,e){return y(n,t=>e(t),t=>l(t))}function w(n,e){return y(n,t=>b(e(t)),t=>l(t))}function P(n){return c((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,u)=>a?s(a):o(u)):n().then(o,s);}catch(a){s(a);}})}function I(){return p(()=>{})}var l=n=>({_tag:"Succeed",value:n}),b=n=>({_tag:"Fail",error:n}),p=n=>({_tag:"Sync",thunk:n}),C=n=>p(()=>n()),c=n=>({_tag:"Async",register:n});function B(n,e){return g(n,t=>l(e(t)))}function g(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function T(n,e){return new Promise((t,r)=>{f(n,e).join(s=>{let o=s;o._tag==="Success"?t(o.value):r(o.error);});})}function z(n,e){return c((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function j(n){return c((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))});}})}var v=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";function O(n){return R((t,r)=>n.length===1?n(r):n(t,r),t=>v(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function R(n,e){return c((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(u=>o({_tag:"Success",value:u})).catch(u=>o({_tag:"Failure",error:e(u)}));}catch(a){o({_tag:"Failure",error:e(a)});}return ()=>{s=true,i.abort();}})}function M(n,e,t){return g(n,r=>(t.addFinalizer(i=>e(r,i)),l(r)))}function N(n){return c(n)}export{h as a,d as b,f as c,y as d,q as e,w as f,P as g,I as h,l as i,b as j,p as k,C as l,c as m,B as n,g as o,T as p,z as q,j as r,O as s,R as t,M as u,N as v};
|
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';var chunk77P3VCG2_js=require('../chunk-77P3VCG2.js');var h=s=>s instanceof DOMException&&s.name==="AbortError"?{_tag:"Abort"}:typeof s=="object"&&s&&"_tag"in s?s:{_tag:"FetchError",message:String(s)};function b(s={}){let p=s.baseUrl??"",d=s.headers??{},n=t=>chunk77P3VCG2_js.t(async e=>{let r;try{r=new URL(t.url,p);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${t.url}`}}let g=performance.now(),o=await fetch(r,{...t,headers:{...d,...t.headers??{}},signal:e}),c=await o.text(),i={};return o.headers.forEach((u,m)=>i[m]=u),{status:o.status,statusText:o.statusText,headers:i,bodyText:c,ms:Math.round(performance.now()-g)}},h);return {get:(t,e)=>n({url:t,method:"GET",...e??{}}),post:(t,e,r)=>n({url:t,method:"POST",body:e&&e.length>0?e:void 0,...r??{}}),getText:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>r.bodyText),getJson:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>JSON.parse(r.bodyText)),postJson:(t,e,r)=>n({url:t,method:"POST",headers:{"content-type":"application/json",...r?.headers??{}},body:JSON.stringify(e),...r??{}})}}exports.makeHttp=b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {t}from'../chunk-EZTDSZ4Y.mjs';var h=s=>s instanceof DOMException&&s.name==="AbortError"?{_tag:"Abort"}:typeof s=="object"&&s&&"_tag"in s?s:{_tag:"FetchError",message:String(s)};function b(s={}){let p=s.baseUrl??"",d=s.headers??{},n=t$1=>t(async e=>{let r;try{r=new URL(t$1.url,p);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${t$1.url}`}}let g=performance.now(),o=await fetch(r,{...t$1,headers:{...d,...t$1.headers??{}},signal:e}),c=await o.text(),i={};return o.headers.forEach((u,m)=>i[m]=u),{status:o.status,statusText:o.statusText,headers:i,bodyText:c,ms:Math.round(performance.now()-g)}},h);return {get:(t,e)=>n({url:t,method:"GET",...e??{}}),post:(t,e,r)=>n({url:t,method:"POST",body:e&&e.length>0?e:void 0,...r??{}}),getText:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>r.bodyText),getJson:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>JSON.parse(r.bodyText)),postJson:(t,e,r)=>n({url:t,method:"POST",headers:{"content-type":"application/json",...r?.headers??{}},body:JSON.stringify(e),...r??{}})}}export{b as makeHttp};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZIO, O as Option, A as Async } from './effect-D4h--Rys.
|
|
2
|
-
export { K as CancelToken, J as Canceler, E as Exit, N as None, H as Scope, G as ScopeId, S as Some, B as acquireRelease, q as async, h as asyncCatchAll, l as asyncFail, t as asyncFlatMap, g as asyncFold, C as asyncInterruptible, r as asyncMap, i as asyncMapError, k as asyncSucceed, n as asyncSync, p as asyncTotal, d as catchAll, e as end, f as fail, b as flatMap, j as from, x as fromCallback, w as fromPromise, z as fromPromiseAbortable, M as linkAbortController, L as makeCancelToken, m as map, c as mapError, D as none, o as orElseOptional, F as some, s as succeed, a as sync, v as toPromise, y as tryPromiseAbortable, u as unit, I as withScope } from './effect-D4h--Rys.
|
|
1
|
+
import { Z as ZIO, O as Option, A as Async } from './effect-D4h--Rys.mjs';
|
|
2
|
+
export { K as CancelToken, J as Canceler, E as Exit, N as None, H as Scope, G as ScopeId, S as Some, B as acquireRelease, q as async, h as asyncCatchAll, l as asyncFail, t as asyncFlatMap, g as asyncFold, C as asyncInterruptible, r as asyncMap, i as asyncMapError, k as asyncSucceed, n as asyncSync, p as asyncTotal, d as catchAll, e as end, f as fail, b as flatMap, j as from, x as fromCallback, w as fromPromise, z as fromPromiseAbortable, M as linkAbortController, L as makeCancelToken, m as map, c as mapError, D as none, o as orElseOptional, F as some, s as succeed, a as sync, v as toPromise, y as tryPromiseAbortable, u as unit, I as withScope } from './effect-D4h--Rys.mjs';
|
|
3
3
|
|
|
4
4
|
type Task = () => void;
|
|
5
5
|
declare class Scheduler {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';var chunk77P3VCG2_js=require('./chunk-77P3VCG2.js');var l={_tag:"None"},y=e=>({_tag:"Some",value:e});var Z=e=>chunk77P3VCG2_js.i(e),u=e=>chunk77P3VCG2_js.j(e),X=e=>chunk77P3VCG2_js.k(t=>e(t)),A=(e,t)=>chunk77P3VCG2_js.n(e,t),_=(e,t)=>chunk77P3VCG2_js.o(e,n=>t(n)),O=(e,t)=>chunk77P3VCG2_js.f(e,t),Y=(e,t)=>chunk77P3VCG2_js.d(e,n=>t(n),n=>chunk77P3VCG2_js.i(n));function x(e,t){return chunk77P3VCG2_js.d(e,n=>n._tag==="Some"?chunk77P3VCG2_js.j(n):t(),n=>chunk77P3VCG2_js.i(n))}var $=()=>u(l);var h=e=>e._tag==="None"?l:y(e.value),g=e=>({_tag:"FromPull",pull:e}),w=()=>({_tag:"Empty"}),F=e=>({_tag:"Emit",value:e}),d=(e,t)=>({_tag:"Concat",left:e,right:t}),v=e=>({_tag:"Flatten",stream:e});function i(e){switch(e._tag){case "Empty":return u(l);case "Emit":return A(O(e.value,t=>y(t)),t=>[t,w()]);case "FromPull":return e.pull;case "Concat":return x(A(i(e.left),([t,n])=>[t,d(n,e.right)]),()=>i(e.right));case "Flatten":return _(i(e.stream),([t,n])=>x(A(i(t),([r,o])=>[r,d(o,v(n))]),()=>i(v(n))))}}function m(e,t){switch(e._tag){case "Empty":return w();case "Emit":return F(A(e.value,t));case "FromPull":return g(A(e.pull,([n,r])=>[t(n),m(r,t)]));case "Concat":return d(m(e.left,t),m(e.right,t));case "Flatten":{let n=m(e.stream,r=>m(r,t));return v(n)}}}function se(e,t){let n=r=>g(r>t?chunk77P3VCG2_js.j(l):chunk77P3VCG2_js.i([r,n(r+1)]));return n(e)}function b(e,t){let n=chunk77P3VCG2_js.d(chunk77P3VCG2_js.f(i(e),r=>h(r)),r=>chunk77P3VCG2_js.j(r),([r,o])=>chunk77P3VCG2_js.d(chunk77P3VCG2_js.f(i(t),E=>h(E)),E=>chunk77P3VCG2_js.j(E),([E,S])=>chunk77P3VCG2_js.i([[r,E],b(o,S)])));return g(n)}function ie(e,t){let n=r=>chunk77P3VCG2_js.d(chunk77P3VCG2_js.f(i(r),o=>h(o)),o=>o._tag==="None"?chunk77P3VCG2_js.i(void 0):chunk77P3VCG2_js.j(o),([o,E])=>chunk77P3VCG2_js.o(chunk77P3VCG2_js.f(t(o),S=>y(S)),()=>n(E)));return chunk77P3VCG2_js.d(n(e),r=>r._tag==="None"?chunk77P3VCG2_js.i(void 0):chunk77P3VCG2_js.j(r.value),()=>chunk77P3VCG2_js.i(void 0))}function pe(e){let t=w();for(let n=e.length-1;n>=0;n--){let r=F(Z(e[n]));t=d(r,t);}return t}function le(e){let t=(n,r)=>chunk77P3VCG2_js.d(i(n),o=>o._tag==="None"?Z(r):u(o),([o,E])=>t(E,[...r,o]));return O(t(e,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}var k=1,I=class e{constructor(t){this.env=t;this.id=k++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(t){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(t);}subScope(){if(this.closed)throw new Error("Scope closed");let t=new e(this.env);return this.subScopes.add(t),t}fork(t,n){if(this.closed)throw new Error("Scope closed");let r=chunk77P3VCG2_js.c(t,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(t={_tag:"Success",value:void 0}){if(!this.closed){this.closed=true;for(let n of this.children)n.interrupt();for(let n of this.subScopes)n.close(t);for(;this.finalizers.length>0;){let r=this.finalizers.pop()(t);chunk77P3VCG2_js.c(r,this.env);}this.children.clear(),this.subScopes.clear();}}isClosed(){return this.closed}};function ue(e){let t=new I({});try{return e(t)}finally{t.close();}}function Se(){let e=false,t=new Set;return {isCancelled:()=>e,onCancel:r=>{if(e){try{r();}catch{}return ()=>{}}return t.add(r),()=>{t.delete(r);}},cancel:()=>{if(!e){e=true;for(let r of t)try{r();}catch{}t.clear();}}}}function fe(e,t){return e.onCancel(()=>t.abort())}Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunk77P3VCG2_js.a}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunk77P3VCG2_js.u}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunk77P3VCG2_js.m}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunk77P3VCG2_js.e}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunk77P3VCG2_js.j}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunk77P3VCG2_js.o}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunk77P3VCG2_js.d}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunk77P3VCG2_js.v}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunk77P3VCG2_js.n}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunk77P3VCG2_js.f}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunk77P3VCG2_js.i}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunk77P3VCG2_js.k}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunk77P3VCG2_js.l}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunk77P3VCG2_js.g}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunk77P3VCG2_js.r}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunk77P3VCG2_js.q}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunk77P3VCG2_js.t}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunk77P3VCG2_js.b}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunk77P3VCG2_js.p}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunk77P3VCG2_js.s}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunk77P3VCG2_js.h}});exports.Scope=I;exports.catchAll=Y;exports.collectStream=le;exports.concatStream=d;exports.emitStream=F;exports.emptyStream=w;exports.end=$;exports.fail=u;exports.flatMap=_;exports.flattenStream=v;exports.foreachStream=ie;exports.fromArray=pe;exports.fromPull=g;exports.linkAbortController=fe;exports.makeCancelToken=Se;exports.map=A;exports.mapError=O;exports.mapStream=m;exports.none=l;exports.orElseOptional=x;exports.rangeStream=se;exports.some=y;exports.succeed=Z;exports.sync=X;exports.uncons=i;exports.withScope=ue;exports.zip=b;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d as d$1,j,o,n,f,i as i$1,k as k$1,c}from'./chunk-EZTDSZ4Y.mjs';export{a as Scheduler,u as acquireRelease,m as async,e as asyncCatchAll,j as asyncFail,o as asyncFlatMap,d as asyncFold,v as asyncInterruptible,n as asyncMap,f as asyncMapError,i as asyncSucceed,k as asyncSync,l as asyncTotal,g as from,r as fromCallback,q as fromPromise,t as fromPromiseAbortable,b as globalScheduler,p as toPromise,s as tryPromiseAbortable,h as unit}from'./chunk-EZTDSZ4Y.mjs';var l={_tag:"None"},y=e=>({_tag:"Some",value:e});var Z=e=>i$1(e),u=e=>j(e),X=e=>k$1(t=>e(t)),A=(e,t)=>n(e,t),_=(e,t)=>o(e,n=>t(n)),O=(e,t)=>f(e,t),Y=(e,t)=>d$1(e,n=>t(n),n=>i$1(n));function x(e,t){return d$1(e,n=>n._tag==="Some"?j(n):t(),n=>i$1(n))}var $=()=>u(l);var h=e=>e._tag==="None"?l:y(e.value),g=e=>({_tag:"FromPull",pull:e}),w=()=>({_tag:"Empty"}),F=e=>({_tag:"Emit",value:e}),d=(e,t)=>({_tag:"Concat",left:e,right:t}),v=e=>({_tag:"Flatten",stream:e});function i(e){switch(e._tag){case "Empty":return u(l);case "Emit":return A(O(e.value,t=>y(t)),t=>[t,w()]);case "FromPull":return e.pull;case "Concat":return x(A(i(e.left),([t,n])=>[t,d(n,e.right)]),()=>i(e.right));case "Flatten":return _(i(e.stream),([t,n])=>x(A(i(t),([r,o])=>[r,d(o,v(n))]),()=>i(v(n))))}}function m(e,t){switch(e._tag){case "Empty":return w();case "Emit":return F(A(e.value,t));case "FromPull":return g(A(e.pull,([n,r])=>[t(n),m(r,t)]));case "Concat":return d(m(e.left,t),m(e.right,t));case "Flatten":{let n=m(e.stream,r=>m(r,t));return v(n)}}}function se(e,t){let n=r=>g(r>t?j(l):i$1([r,n(r+1)]));return n(e)}function b(e,t){let n=d$1(f(i(e),r=>h(r)),r=>j(r),([r,o])=>d$1(f(i(t),E=>h(E)),E=>j(E),([E,S])=>i$1([[r,E],b(o,S)])));return g(n)}function ie(e,t){let n=r=>d$1(f(i(r),o=>h(o)),o=>o._tag==="None"?i$1(void 0):j(o),([o$1,E])=>o(f(t(o$1),S=>y(S)),()=>n(E)));return d$1(n(e),r=>r._tag==="None"?i$1(void 0):j(r.value),()=>i$1(void 0))}function pe(e){let t=w();for(let n=e.length-1;n>=0;n--){let r=F(Z(e[n]));t=d(r,t);}return t}function le(e){let t=(n,r)=>d$1(i(n),o=>o._tag==="None"?Z(r):u(o),([o,E])=>t(E,[...r,o]));return O(t(e,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}var k=1,I=class e{constructor(t){this.env=t;this.id=k++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(t){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(t);}subScope(){if(this.closed)throw new Error("Scope closed");let t=new e(this.env);return this.subScopes.add(t),t}fork(t,n){if(this.closed)throw new Error("Scope closed");let r=c(t,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(t={_tag:"Success",value:void 0}){if(!this.closed){this.closed=true;for(let n of this.children)n.interrupt();for(let n of this.subScopes)n.close(t);for(;this.finalizers.length>0;){let r=this.finalizers.pop()(t);c(r,this.env);}this.children.clear(),this.subScopes.clear();}}isClosed(){return this.closed}};function ue(e){let t=new I({});try{return e(t)}finally{t.close();}}function Se(){let e=false,t=new Set;return {isCancelled:()=>e,onCancel:r=>{if(e){try{r();}catch{}return ()=>{}}return t.add(r),()=>{t.delete(r);}},cancel:()=>{if(!e){e=true;for(let r of t)try{r();}catch{}t.clear();}}}}function fe(e,t){return e.onCancel(()=>t.abort())}export{I as Scope,Y as catchAll,le as collectStream,d as concatStream,F as emitStream,w as emptyStream,$ as end,u as fail,_ as flatMap,v as flattenStream,ie as foreachStream,pe as fromArray,g as fromPull,fe as linkAbortController,Se as makeCancelToken,A as map,O as mapError,m as mapStream,l as none,x as orElseOptional,se as rangeStream,y as some,Z as succeed,X as sync,i as uncons,ue as withScope,b as zip};
|
package/package.json
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brass-runtime",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Effect runtime utilities for TypeScript",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"types": "./dist/types/index.d.ts",
|
|
11
|
-
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
12
10
|
"exports": {
|
|
13
11
|
".": {
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/
|
|
16
|
-
"require": "./dist/
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
17
15
|
},
|
|
18
16
|
"./http": {
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"import": "./dist/
|
|
21
|
-
"require": "./dist/
|
|
17
|
+
"types": "./dist/http/index.d.ts",
|
|
18
|
+
"import": "./dist/http/index.js",
|
|
19
|
+
"require": "./dist/http/index.cjs"
|
|
22
20
|
},
|
|
23
21
|
"./package.json": "./package.json"
|
|
24
22
|
},
|
|
@@ -45,6 +43,7 @@
|
|
|
45
43
|
"runtime"
|
|
46
44
|
],
|
|
47
45
|
"scripts": {
|
|
46
|
+
"dev": "tsx src/examples/index.ts",
|
|
48
47
|
"clean": "rimraf dist",
|
|
49
48
|
"build": "tsup",
|
|
50
49
|
"build:legacy": "npm run clean && npm run build:types && npm run build:esm && npm run build:cjs",
|
package/dist/chunk-ABGJNLHY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var A=class{queue=[];flushing=false;requested=false;schedule(e,t="anonymous"){this.queue.push({tag:t,task:e}),this.requestFlush(),console.log("SCHEDULER",{flushing:this.flushing,q:this.queue.length,next:this.queue[0]?.tag,head:this.queue.slice(0,5).map(r=>r.tag)});}requestFlush(){this.requested||(this.requested=true,queueMicrotask(()=>this.flush()));}flush(){if(!this.flushing){this.flushing=true,this.requested=false;try{for(;this.queue.length>0;){let{task:e}=this.queue.shift();try{e();}catch{}}}finally{this.flushing=false,this.queue.length>0&&this.requestFlush();}}}},d=new A;var g=1,y=class{constructor(e,t,r){this.scheduler=r;this.id=g++,this.current=e,this.env=t;}id;closing=null;finishing=false;statusValue="Running";interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];scheduled=false;finalizersDrained=false;blockedOnAsync=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.statusValue}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.blockedOnAsync=false,this.schedule("interrupt-step")));}schedule(e="step"){this.result==null&&(this.scheduled||(this.scheduled=true,this.scheduler.schedule(()=>{this.scheduled=false,this.step();},`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.statusValue=this.interrupted?"Interrupted":"Done",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(){if(this.result!=null||this.blockedOnAsync)return;if(this.interrupted&&this.closing==null){this.notify({_tag:"Failure",error:{_tag:"Interrupted"}});return}let e=this.current;switch(e._tag){case "Succeed":this.onSuccess(e.value);return;case "Fail":this.onFailure(e.error);return;case "Sync":try{let t=e.thunk(this.env);this.onSuccess(t);}catch(t){this.onFailure(t);}return;case "FlatMap":this.stack.push({_tag:"SuccessCont",k:e.andThen}),this.current=e.first;return;case "Fold":this.stack.push({_tag:"FoldCont",onFailure:e.onFailure,onSuccess:e.onSuccess}),this.current=e.first;return;case "Async":{if(this.finishing)return;this.blockedOnAsync=true;let t=null,r=false,i=()=>{if(!t)return;let a=t;if(t=null,this.blockedOnAsync=false,!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}a._tag==="Success"?this.onSuccess(a.value):this.onFailure(a.error),this.schedule("async-resume");}},s=e.register(this.env,a=>{t=a,r=true;});typeof s=="function"&&this.addFinalizer(a=>{try{s();}catch{}}),r&&this.scheduler.schedule(i,`fiber#${this.id}.async-sync-resume`);return}}}};function h(n,e,t=d){let r=new y(n,e,t);return r.schedule("initial-step"),r}function f(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function w(n,e){return f(n,t=>e(t),t=>l(t))}function P(n,e){return f(n,t=>v(e(t)),t=>l(t))}function I(n){return c((e,t)=>{let r=false,i=o=>{r||(r=true,t(o));},s=o=>i({_tag:"Failure",error:o instanceof Error?o:new Error(String(o))}),a=o=>i({_tag:"Success",value:o});try{typeof n=="function"&&n.length>=1?n((o,u)=>o?s(o):a(u)):n().then(a,s);}catch(o){s(o);}})}function C(){return p(()=>{})}var l=n=>({_tag:"Succeed",value:n}),v=n=>({_tag:"Fail",error:n}),p=n=>({_tag:"Sync",thunk:n}),B=n=>p(()=>n()),c=n=>({_tag:"Async",register:n});function q(n,e){return E(n,t=>l(e(t)))}function E(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function z(n,e){return new Promise((t,r)=>{h(n,e).join(s=>{let a=s;a._tag==="Success"?t(a.value):r(a.error);});})}function j(n,e){return c((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function T(n){return c((e,t)=>{let r=false,i=s=>{r||(r=true,t(s));};try{n((s,a)=>{i(s?{_tag:"Failure",error:s}:{_tag:"Success",value:a});});}catch(s){i({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))});}})}var R=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";function M(n){return b((t,r)=>n.length===1?n(r):n(t,r),t=>R(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function b(n,e){return c((t,r)=>{let i=new AbortController,s=false,a=o=>{s||(s=true,r(o));};try{(n.length===1?n(i.signal):n(t,i.signal)).then(u=>a({_tag:"Success",value:u})).catch(u=>a({_tag:"Failure",error:e(u)}));}catch(o){a({_tag:"Failure",error:e(o)});}return ()=>{s=true,i.abort();}})}function O(n,e,t){return E(n,r=>(t.addFinalizer(i=>e(r,i)),l(r)))}function D(n){return c(n)}export{A as a,d as b,h as c,f as d,w as e,P as f,I as g,C as h,l as i,v as j,p as k,B as l,c as m,q as n,E as o,z as p,j as q,T as r,M as s,b as t,O as u,D as v};
|
package/dist/chunk-C6HOJTND.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var A=class{queue=[];flushing=false;requested=false;schedule(e,t="anonymous"){this.queue.push({tag:t,task:e}),this.requestFlush(),console.log("SCHEDULER",{flushing:this.flushing,q:this.queue.length,next:this.queue[0]?.tag,head:this.queue.slice(0,5).map(r=>r.tag)});}requestFlush(){this.requested||(this.requested=true,queueMicrotask(()=>this.flush()));}flush(){if(!this.flushing){this.flushing=true,this.requested=false;try{for(;this.queue.length>0;){let{task:e}=this.queue.shift();try{e();}catch{}}}finally{this.flushing=false,this.queue.length>0&&this.requestFlush();}}}},d=new A;var g=1,y=class{constructor(e,t,r){this.scheduler=r;this.id=g++,this.current=e,this.env=t;}id;closing=null;finishing=false;statusValue="Running";interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];scheduled=false;finalizersDrained=false;blockedOnAsync=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.statusValue}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.blockedOnAsync=false,this.schedule("interrupt-step")));}schedule(e="step"){this.result==null&&(this.scheduled||(this.scheduled=true,this.scheduler.schedule(()=>{this.scheduled=false,this.step();},`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.statusValue=this.interrupted?"Interrupted":"Done",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(){if(this.result!=null||this.blockedOnAsync)return;if(this.interrupted&&this.closing==null){this.notify({_tag:"Failure",error:{_tag:"Interrupted"}});return}let e=this.current;switch(e._tag){case "Succeed":this.onSuccess(e.value);return;case "Fail":this.onFailure(e.error);return;case "Sync":try{let t=e.thunk(this.env);this.onSuccess(t);}catch(t){this.onFailure(t);}return;case "FlatMap":this.stack.push({_tag:"SuccessCont",k:e.andThen}),this.current=e.first;return;case "Fold":this.stack.push({_tag:"FoldCont",onFailure:e.onFailure,onSuccess:e.onSuccess}),this.current=e.first;return;case "Async":{if(this.finishing)return;this.blockedOnAsync=true;let t=null,r=false,i=()=>{if(!t)return;let a=t;if(t=null,this.blockedOnAsync=false,!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}a._tag==="Success"?this.onSuccess(a.value):this.onFailure(a.error),this.schedule("async-resume");}},s=e.register(this.env,a=>{t=a,r=true;});typeof s=="function"&&this.addFinalizer(a=>{try{s();}catch{}}),r&&this.scheduler.schedule(i,`fiber#${this.id}.async-sync-resume`);return}}}};function h(n,e,t=d){let r=new y(n,e,t);return r.schedule("initial-step"),r}function f(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function w(n,e){return f(n,t=>e(t),t=>l(t))}function P(n,e){return f(n,t=>v(e(t)),t=>l(t))}function I(n){return c((e,t)=>{let r=false,i=o=>{r||(r=true,t(o));},s=o=>i({_tag:"Failure",error:o instanceof Error?o:new Error(String(o))}),a=o=>i({_tag:"Success",value:o});try{typeof n=="function"&&n.length>=1?n((o,u)=>o?s(o):a(u)):n().then(a,s);}catch(o){s(o);}})}function C(){return p(()=>{})}var l=n=>({_tag:"Succeed",value:n}),v=n=>({_tag:"Fail",error:n}),p=n=>({_tag:"Sync",thunk:n}),B=n=>p(()=>n()),c=n=>({_tag:"Async",register:n});function q(n,e){return E(n,t=>l(e(t)))}function E(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function z(n,e){return new Promise((t,r)=>{h(n,e).join(s=>{let a=s;a._tag==="Success"?t(a.value):r(a.error);});})}function j(n,e){return c((t,r)=>{n(t).then(i=>r({_tag:"Success",value:i})).catch(i=>r({_tag:"Failure",error:e(i)}));})}function T(n){return c((e,t)=>{let r=false,i=s=>{r||(r=true,t(s));};try{n((s,a)=>{i(s?{_tag:"Failure",error:s}:{_tag:"Success",value:a});});}catch(s){i({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))});}})}var R=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";function M(n){return b((t,r)=>n.length===1?n(r):n(t,r),t=>R(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function b(n,e){return c((t,r)=>{let i=new AbortController,s=false,a=o=>{s||(s=true,r(o));};try{(n.length===1?n(i.signal):n(t,i.signal)).then(u=>a({_tag:"Success",value:u})).catch(u=>a({_tag:"Failure",error:e(u)}));}catch(o){a({_tag:"Failure",error:e(o)});}return ()=>{s=true,i.abort();}})}function O(n,e,t){return E(n,r=>(t.addFinalizer(i=>e(r,i)),l(r)))}function D(n){return c(n)}exports.a=A;exports.b=d;exports.c=h;exports.d=f;exports.e=w;exports.f=P;exports.g=I;exports.h=C;exports.i=l;exports.j=v;exports.k=p;exports.l=B;exports.m=c;exports.n=q;exports.o=E;exports.p=z;exports.q=j;exports.r=T;exports.s=M;exports.t=b;exports.u=O;exports.v=D;
|
package/dist/http/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkC6HOJTND_cjs=require('../chunk-C6HOJTND.cjs');var h=s=>s instanceof DOMException&&s.name==="AbortError"?{_tag:"Abort"}:typeof s=="object"&&s&&"_tag"in s?s:{_tag:"FetchError",message:String(s)};function b(s={}){let p=s.baseUrl??"",d=s.headers??{},n=t=>chunkC6HOJTND_cjs.t(async e=>{let r;try{r=new URL(t.url,p);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${t.url}`}}let g=performance.now(),o=await fetch(r,{...t,headers:{...d,...t.headers??{}},signal:e}),c=await o.text(),i={};return o.headers.forEach((u,m)=>i[m]=u),{status:o.status,statusText:o.statusText,headers:i,bodyText:c,ms:Math.round(performance.now()-g)}},h);return {get:(t,e)=>n({url:t,method:"GET",...e??{}}),post:(t,e,r)=>n({url:t,method:"POST",body:e&&e.length>0?e:void 0,...r??{}}),getText:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>r.bodyText),getJson:(t,e)=>n({url:t,method:"GET",...e??{}}).map(r=>JSON.parse(r.bodyText)),postJson:(t,e,r)=>n({url:t,method:"POST",headers:{"content-type":"application/json",...r?.headers??{}},body:JSON.stringify(e),...r??{}})}}exports.makeHttp=b;
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkC6HOJTND_cjs=require('./chunk-C6HOJTND.cjs');var l={_tag:"None"},y=e=>({_tag:"Some",value:e});var Z=e=>chunkC6HOJTND_cjs.i(e),u=e=>chunkC6HOJTND_cjs.j(e),X=e=>chunkC6HOJTND_cjs.k(t=>e(t)),A=(e,t)=>chunkC6HOJTND_cjs.n(e,t),_=(e,t)=>chunkC6HOJTND_cjs.o(e,n=>t(n)),O=(e,t)=>chunkC6HOJTND_cjs.f(e,t),Y=(e,t)=>chunkC6HOJTND_cjs.d(e,n=>t(n),n=>chunkC6HOJTND_cjs.i(n));function x(e,t){return chunkC6HOJTND_cjs.d(e,n=>n._tag==="Some"?chunkC6HOJTND_cjs.j(n):t(),n=>chunkC6HOJTND_cjs.i(n))}var $=()=>u(l);var h=e=>e._tag==="None"?l:y(e.value),g=e=>({_tag:"FromPull",pull:e}),w=()=>({_tag:"Empty"}),F=e=>({_tag:"Emit",value:e}),d=(e,t)=>({_tag:"Concat",left:e,right:t}),v=e=>({_tag:"Flatten",stream:e});function i(e){switch(e._tag){case "Empty":return u(l);case "Emit":return A(O(e.value,t=>y(t)),t=>[t,w()]);case "FromPull":return e.pull;case "Concat":return x(A(i(e.left),([t,n])=>[t,d(n,e.right)]),()=>i(e.right));case "Flatten":return _(i(e.stream),([t,n])=>x(A(i(t),([r,o])=>[r,d(o,v(n))]),()=>i(v(n))))}}function m(e,t){switch(e._tag){case "Empty":return w();case "Emit":return F(A(e.value,t));case "FromPull":return g(A(e.pull,([n,r])=>[t(n),m(r,t)]));case "Concat":return d(m(e.left,t),m(e.right,t));case "Flatten":{let n=m(e.stream,r=>m(r,t));return v(n)}}}function se(e,t){let n=r=>g(r>t?chunkC6HOJTND_cjs.j(l):chunkC6HOJTND_cjs.i([r,n(r+1)]));return n(e)}function b(e,t){let n=chunkC6HOJTND_cjs.d(chunkC6HOJTND_cjs.f(i(e),r=>h(r)),r=>chunkC6HOJTND_cjs.j(r),([r,o])=>chunkC6HOJTND_cjs.d(chunkC6HOJTND_cjs.f(i(t),E=>h(E)),E=>chunkC6HOJTND_cjs.j(E),([E,S])=>chunkC6HOJTND_cjs.i([[r,E],b(o,S)])));return g(n)}function ie(e,t){let n=r=>chunkC6HOJTND_cjs.d(chunkC6HOJTND_cjs.f(i(r),o=>h(o)),o=>o._tag==="None"?chunkC6HOJTND_cjs.i(void 0):chunkC6HOJTND_cjs.j(o),([o,E])=>chunkC6HOJTND_cjs.o(chunkC6HOJTND_cjs.f(t(o),S=>y(S)),()=>n(E)));return chunkC6HOJTND_cjs.d(n(e),r=>r._tag==="None"?chunkC6HOJTND_cjs.i(void 0):chunkC6HOJTND_cjs.j(r.value),()=>chunkC6HOJTND_cjs.i(void 0))}function pe(e){let t=w();for(let n=e.length-1;n>=0;n--){let r=F(Z(e[n]));t=d(r,t);}return t}function le(e){let t=(n,r)=>chunkC6HOJTND_cjs.d(i(n),o=>o._tag==="None"?Z(r):u(o),([o,E])=>t(E,[...r,o]));return O(t(e,[]),n=>{if(n._tag==="Some")return n.value;throw new Error("unreachable: stream end handled as success")})}var k=1,I=class e{constructor(t){this.env=t;this.id=k++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(t){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(t);}subScope(){if(this.closed)throw new Error("Scope closed");let t=new e(this.env);return this.subScopes.add(t),t}fork(t,n){if(this.closed)throw new Error("Scope closed");let r=chunkC6HOJTND_cjs.c(t,n);return this.children.add(r),r.join(()=>{this.children.delete(r);}),r}close(t={_tag:"Success",value:void 0}){if(!this.closed){this.closed=true;for(let n of this.children)n.interrupt();for(let n of this.subScopes)n.close(t);for(;this.finalizers.length>0;){let r=this.finalizers.pop()(t);chunkC6HOJTND_cjs.c(r,this.env);}this.children.clear(),this.subScopes.clear();}}isClosed(){return this.closed}};function ue(e){let t=new I({});try{return e(t)}finally{t.close();}}function Se(){let e=false,t=new Set;return {isCancelled:()=>e,onCancel:r=>{if(e){try{r();}catch{}return ()=>{}}return t.add(r),()=>{t.delete(r);}},cancel:()=>{if(!e){e=true;for(let r of t)try{r();}catch{}t.clear();}}}}function fe(e,t){return e.onCancel(()=>t.abort())}Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.a}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.u}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.m}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.e}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.j}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.o}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.d}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.v}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.n}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.f}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.i}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.k}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.l}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.g}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.r}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.q}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.t}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.b}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.p}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.s}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkC6HOJTND_cjs.h}});exports.Scope=I;exports.catchAll=Y;exports.collectStream=le;exports.concatStream=d;exports.emitStream=F;exports.emptyStream=w;exports.end=$;exports.fail=u;exports.flatMap=_;exports.flattenStream=v;exports.foreachStream=ie;exports.fromArray=pe;exports.fromPull=g;exports.linkAbortController=fe;exports.makeCancelToken=Se;exports.map=A;exports.mapError=O;exports.mapStream=m;exports.none=l;exports.orElseOptional=x;exports.rangeStream=se;exports.some=y;exports.succeed=Z;exports.sync=X;exports.uncons=i;exports.withScope=ue;exports.zip=b;
|
|
File without changes
|