brass-runtime 1.4.4 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-LNOZOVUL.mjs → chunk-JLFYFKQ2.mjs} +1 -1
- package/dist/{chunk-T2C7LOTT.js → chunk-REJAVP4D.js} +1 -1
- package/dist/{effect-DAU04-Ha.d.mts → effect-Dt7h2Ttr.d.mts} +39 -1
- package/dist/{effect-DAU04-Ha.d.ts → effect-Dt7h2Ttr.d.ts} +39 -1
- package/dist/http/index.d.mts +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -1
- package/dist/index.d.mts +22 -14
- package/dist/index.d.ts +22 -14
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Branch containing recent work: `feature/buffer-pipes`.
|
|
|
50
50
|
- [x] Structured concurrency: `race`, `zipPar`, `collectAllPar`
|
|
51
51
|
- [x] ZStream-like core (pull-based, resource-aware)
|
|
52
52
|
- [x] Buffering in streams (bounded/backpressure modes)
|
|
53
|
-
- [
|
|
53
|
+
- [x] Merge / zipPar of streams
|
|
54
54
|
- [ ] Hubs / Broadcast / Multicast
|
|
55
55
|
- [ ] Pipelines (`ZPipeline`-style)
|
|
56
56
|
- [ ] Advanced Channels / Sinks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function p(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function
|
|
1
|
+
function p(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function x(n,e){return p(n,t=>e(t),t=>d(t))}function F(n,e){return p(n,t=>R(e(t)),t=>d(t))}function k(){return y(()=>{})}var d=n=>({_tag:"Succeed",value:n}),R=n=>({_tag:"Fail",error:n}),y=n=>({_tag:"Sync",thunk:n}),_=n=>y(()=>n()),l=n=>({_tag:"Async",register:n});function N(n,e){return E(n,t=>d(e(t)))}function E(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function q(n,e,t){return E(n,r=>(t.addFinalizer(o=>e(r,o)),d(r)))}function D(n){return l(n)}var f=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();}}}},g=new f;var u={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},c={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},S=1,A=class{constructor(e,t,r){this.scheduler=r;this.id=S++,this.current=e,this.env=t;}id;closing=null;finishing=false;runState=c.RUNNING;interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];finalizersDrained=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){console.log("[fiber.schedule]",{fiber:this.id,tag:e,runState:this.runState,schedulerCtor:this.scheduler?.constructor?.name,schedulerScheduleType:typeof this.scheduler?.schedule}),!(this.runState===c.DONE||this.runState===c.QUEUED)&&(this.runState=c.QUEUED,this.scheduler.schedule(()=>{if(console.log("[fiber.task] running",this.id),this.runState===c.DONE)return;switch(this.runState=c.RUNNING,this.step()){case u.CONTINUE:this.schedule("continue");return;case u.SUSPEND:this.runState=c.SUSPENDED;return;case u.DONE:this.runState=c.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let t=this.fiberFinalizers.pop();try{t(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let t of this.joiners)t(e);this.joiners.length=0;}}onSuccess(e){let t=this.stack.pop();if(!t){this.notify({_tag:"Success",value:e});return}this.current=t._tag==="SuccessCont"?t.k(e):t.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let t=this.stack.pop();if(t._tag==="FoldCont"){this.current=t.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){console.log("[fiber.step] enter",{fiber:this.id,current:this.current?._tag,result:this.result!=null,interrupted:this.interrupted,closing:this.closing!=null,finishing:this.finishing,stack:this.stack.length});let e=u.CONTINUE;if(this.result!=null)return e=u.DONE,e;if(this.interrupted&&this.closing==null)return console.log("[fiber.step] interrupted: failing now",{fiber:this.id}),this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),e=u.DONE,e;let t=this.current;switch(t._tag){case "Succeed":{console.log("[fiber.step] Succeed",{fiber:this.id}),this.onSuccess(t.value);break}case "Fail":{console.log("[fiber.step] Fail",{fiber:this.id}),this.onFailure(t.error);break}case "Sync":{console.log("[fiber.step] Sync",{fiber:this.id});try{let r=t.thunk(this.env);console.log("[fiber.step] Sync success",{fiber:this.id}),this.onSuccess(r);}catch(r){console.log("[fiber.step] Sync threw",{fiber:this.id,e:r}),this.onFailure(r);}break}case "FlatMap":{console.log("[fiber.step] FlatMap push cont",{fiber:this.id}),this.stack.push({_tag:"SuccessCont",k:t.andThen}),this.current=t.first;break}case "Fold":{console.log("[fiber.step] Fold push cont",{fiber:this.id}),this.stack.push({_tag:"FoldCont",onFailure:t.onFailure,onSuccess:t.onSuccess}),this.current=t.first;break}case "Async":{if(this.finishing)break;let r=false,o=s=>{if(!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}s._tag==="Success"?this.onSuccess(s.value):this.onFailure(s.error),this.schedule("async-resume");}},i=s=>{r||(r=true,this.scheduler.schedule(()=>o(s),`fiber#${this.id}.async-resume`));},a=t.register(this.env,i);typeof a=="function"&&this.addFinalizer(()=>{r=true;try{a();}catch{}}),e=u.SUSPEND;break}}return this.result!=null&&(e=u.DONE),e}};function M(n){return l((e,t)=>{let r=false,o=s=>{r||(r=true,t(s));},i=s=>o({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),a=s=>o({_tag:"Success",value:s});try{typeof n=="function"&&n.length>=1?n((s,h)=>s?i(s):a(h)):n().then(a,i);}catch(s){i(s);}})}function b(n,e,t=g){let r=new A(n,e,t);return r.schedule("initial-step"),r}function Q(n,e,t){b(n,e).join(t);}function G(n,e){return new Promise((t,r)=>{b(n,e).join(i=>{let a=i;a._tag==="Success"?t(a.value):r(a.error);});})}function H(n,e){return l((t,r)=>{n(t).then(o=>r({_tag:"Success",value:o})).catch(o=>r({_tag:"Failure",error:e(o)}));})}function L(n){return l((e,t)=>{let r=false,o=i=>{r||(r=true,t(i));};try{n((i,a)=>{o(i?{_tag:"Failure",error:i}:{_tag:"Success",value:a});});}catch(i){o({_tag:"Failure",error:i instanceof Error?i:new Error(String(i))});}})}function $(n){return v((t,r)=>n.length===1?n(r):n(t,r),t=>m(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function v(n,e){return l((t,r)=>{let o=new AbortController,i=false,a=s=>{i||(i=true,r(s));};try{(n.length===1?n(o.signal):n(t,o.signal)).then(h=>a({_tag:"Success",value:h})).catch(h=>a({_tag:"Failure",error:e(h)}));}catch(s){a({_tag:"Failure",error:e(s)});}return ()=>{i=true,o.abort();}})}var m=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";export{p as a,x as b,F as c,k as d,d as e,R as f,y as g,_ as h,l as i,N as j,E as k,q as l,D as m,f as n,g as o,A as p,M as q,b as r,Q as s,G as t,H as u,L as v,$ as w,v as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function p(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function
|
|
1
|
+
'use strict';function p(n,e,t){return {_tag:"Fold",first:n,onFailure:e,onSuccess:t}}function x(n,e){return p(n,t=>e(t),t=>d(t))}function F(n,e){return p(n,t=>R(e(t)),t=>d(t))}function k(){return y(()=>{})}var d=n=>({_tag:"Succeed",value:n}),R=n=>({_tag:"Fail",error:n}),y=n=>({_tag:"Sync",thunk:n}),_=n=>y(()=>n()),l=n=>({_tag:"Async",register:n});function N(n,e){return E(n,t=>d(e(t)))}function E(n,e){return {_tag:"FlatMap",first:n,andThen:e}}function q(n,e,t){return E(n,r=>(t.addFinalizer(o=>e(r,o)),d(r)))}function D(n){return l(n)}var f=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();}}}},g=new f;var u={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},c={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},S=1,A=class{constructor(e,t,r){this.scheduler=r;this.id=S++,this.current=e,this.env=t;}id;closing=null;finishing=false;runState=c.RUNNING;interrupted=false;result=null;joiners=[];current;env;stack=[];fiberFinalizers=[];finalizersDrained=false;addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.interrupted?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){console.log("[fiber.schedule]",{fiber:this.id,tag:e,runState:this.runState,schedulerCtor:this.scheduler?.constructor?.name,schedulerScheduleType:typeof this.scheduler?.schedule}),!(this.runState===c.DONE||this.runState===c.QUEUED)&&(this.runState=c.QUEUED,this.scheduler.schedule(()=>{if(console.log("[fiber.task] running",this.id),this.runState===c.DONE)return;switch(this.runState=c.RUNNING,this.step()){case u.CONTINUE:this.schedule("continue");return;case u.SUSPEND:this.runState=c.SUSPENDED;return;case u.DONE:this.runState=c.DONE;return}},`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let t=this.fiberFinalizers.pop();try{t(e);}catch{}}}notify(e){if(this.result==null&&this.closing==null){this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;for(let t of this.joiners)t(e);this.joiners.length=0;}}onSuccess(e){let t=this.stack.pop();if(!t){this.notify({_tag:"Success",value:e});return}this.current=t._tag==="SuccessCont"?t.k(e):t.onSuccess(e);}onFailure(e){for(;this.stack.length>0;){let t=this.stack.pop();if(t._tag==="FoldCont"){this.current=t.onFailure(e);return}}this.notify({_tag:"Failure",error:e});}step(){console.log("[fiber.step] enter",{fiber:this.id,current:this.current?._tag,result:this.result!=null,interrupted:this.interrupted,closing:this.closing!=null,finishing:this.finishing,stack:this.stack.length});let e=u.CONTINUE;if(this.result!=null)return e=u.DONE,e;if(this.interrupted&&this.closing==null)return console.log("[fiber.step] interrupted: failing now",{fiber:this.id}),this.notify({_tag:"Failure",error:{_tag:"Interrupted"}}),e=u.DONE,e;let t=this.current;switch(t._tag){case "Succeed":{console.log("[fiber.step] Succeed",{fiber:this.id}),this.onSuccess(t.value);break}case "Fail":{console.log("[fiber.step] Fail",{fiber:this.id}),this.onFailure(t.error);break}case "Sync":{console.log("[fiber.step] Sync",{fiber:this.id});try{let r=t.thunk(this.env);console.log("[fiber.step] Sync success",{fiber:this.id}),this.onSuccess(r);}catch(r){console.log("[fiber.step] Sync threw",{fiber:this.id,e:r}),this.onFailure(r);}break}case "FlatMap":{console.log("[fiber.step] FlatMap push cont",{fiber:this.id}),this.stack.push({_tag:"SuccessCont",k:t.andThen}),this.current=t.first;break}case "Fold":{console.log("[fiber.step] Fold push cont",{fiber:this.id}),this.stack.push({_tag:"FoldCont",onFailure:t.onFailure,onSuccess:t.onSuccess}),this.current=t.first;break}case "Async":{if(this.finishing)break;let r=false,o=s=>{if(!(this.result!=null||this.closing!=null)){if(this.interrupted){this.onFailure({_tag:"Interrupted"});return}s._tag==="Success"?this.onSuccess(s.value):this.onFailure(s.error),this.schedule("async-resume");}},i=s=>{r||(r=true,this.scheduler.schedule(()=>o(s),`fiber#${this.id}.async-resume`));},a=t.register(this.env,i);typeof a=="function"&&this.addFinalizer(()=>{r=true;try{a();}catch{}}),e=u.SUSPEND;break}}return this.result!=null&&(e=u.DONE),e}};function M(n){return l((e,t)=>{let r=false,o=s=>{r||(r=true,t(s));},i=s=>o({_tag:"Failure",error:s instanceof Error?s:new Error(String(s))}),a=s=>o({_tag:"Success",value:s});try{typeof n=="function"&&n.length>=1?n((s,h)=>s?i(s):a(h)):n().then(a,i);}catch(s){i(s);}})}function b(n,e,t=g){let r=new A(n,e,t);return r.schedule("initial-step"),r}function Q(n,e,t){b(n,e).join(t);}function G(n,e){return new Promise((t,r)=>{b(n,e).join(i=>{let a=i;a._tag==="Success"?t(a.value):r(a.error);});})}function H(n,e){return l((t,r)=>{n(t).then(o=>r({_tag:"Success",value:o})).catch(o=>r({_tag:"Failure",error:e(o)}));})}function L(n){return l((e,t)=>{let r=false,o=i=>{r||(r=true,t(i));};try{n((i,a)=>{o(i?{_tag:"Failure",error:i}:{_tag:"Success",value:a});});}catch(i){o({_tag:"Failure",error:i instanceof Error?i:new Error(String(i))});}})}function $(n){return v((t,r)=>n.length===1?n(r):n(t,r),t=>m(t)?{_tag:"Abort"}:{_tag:"PromiseRejected",reason:t})}function v(n,e){return l((t,r)=>{let o=new AbortController,i=false,a=s=>{i||(i=true,r(s));};try{(n.length===1?n(o.signal):n(t,o.signal)).then(h=>a({_tag:"Success",value:h})).catch(h=>a({_tag:"Failure",error:e(h)}));}catch(s){a({_tag:"Failure",error:e(s)});}return ()=>{i=true,o.abort();}})}var m=n=>typeof n=="object"&&n!==null&&"name"in n&&n.name==="AbortError";exports.a=p;exports.b=x;exports.c=F;exports.d=k;exports.e=d;exports.f=R;exports.g=y;exports.h=_;exports.i=l;exports.j=N;exports.k=E;exports.l=q;exports.m=D;exports.n=f;exports.o=g;exports.p=A;exports.q=M;exports.r=b;exports.s=Q;exports.t=G;exports.u=H;exports.v=L;exports.w=$;exports.x=v;
|
|
@@ -19,11 +19,23 @@ declare function makeCancelToken(): CancelToken & {
|
|
|
19
19
|
*/
|
|
20
20
|
declare function linkAbortController(token: CancelToken, ac: AbortController): Canceler;
|
|
21
21
|
|
|
22
|
+
type Task = () => void;
|
|
23
|
+
declare class Scheduler {
|
|
24
|
+
private queue;
|
|
25
|
+
private flushing;
|
|
26
|
+
private requested;
|
|
27
|
+
schedule(task: Task, tag?: string): void;
|
|
28
|
+
private requestFlush;
|
|
29
|
+
private flush;
|
|
30
|
+
}
|
|
31
|
+
declare const globalScheduler: Scheduler;
|
|
32
|
+
|
|
22
33
|
type FiberId = number;
|
|
23
34
|
type Interrupted = {
|
|
24
35
|
readonly _tag: "Interrupted";
|
|
25
36
|
};
|
|
26
37
|
type FiberStatus = "Running" | "Done" | "Interrupted";
|
|
38
|
+
type StepDecision = "Continue" | "Suspend" | "Done";
|
|
27
39
|
type Fiber<E, A> = {
|
|
28
40
|
readonly id: FiberId;
|
|
29
41
|
readonly status: () => FiberStatus;
|
|
@@ -31,6 +43,32 @@ type Fiber<E, A> = {
|
|
|
31
43
|
readonly interrupt: () => void;
|
|
32
44
|
readonly addFinalizer: (f: (exit: Exit<E | Interrupted, A>) => void) => void;
|
|
33
45
|
};
|
|
46
|
+
declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
47
|
+
private readonly scheduler;
|
|
48
|
+
readonly id: FiberId;
|
|
49
|
+
private closing;
|
|
50
|
+
private finishing;
|
|
51
|
+
private runState;
|
|
52
|
+
private interrupted;
|
|
53
|
+
private result;
|
|
54
|
+
private readonly joiners;
|
|
55
|
+
private current;
|
|
56
|
+
private readonly env;
|
|
57
|
+
private readonly stack;
|
|
58
|
+
private readonly fiberFinalizers;
|
|
59
|
+
private finalizersDrained;
|
|
60
|
+
constructor(effect: Async<R, E, A>, env: R, scheduler: Scheduler);
|
|
61
|
+
addFinalizer(f: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
62
|
+
status(): FiberStatus;
|
|
63
|
+
join(cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
64
|
+
interrupt(): void;
|
|
65
|
+
schedule(tag?: string): void;
|
|
66
|
+
private runFinalizersOnce;
|
|
67
|
+
private notify;
|
|
68
|
+
private onSuccess;
|
|
69
|
+
private onFailure;
|
|
70
|
+
step(): StepDecision;
|
|
71
|
+
}
|
|
34
72
|
|
|
35
73
|
type ScopeId = number;
|
|
36
74
|
declare class Scope<R> {
|
|
@@ -121,4 +159,4 @@ declare const catchAll: <R, E, A, R2, E2, B>(fa: ZIO<R, E, A>, handler: (e: E) =
|
|
|
121
159
|
declare function orElseOptional<R, E, A, R2, A2>(fa: ZIO<R, Option<E>, A>, that: () => ZIO<R2, Option<E>, A2>): ZIO<R & R2, Option<E>, A | A2>;
|
|
122
160
|
declare const end: <E>() => ZIO<unknown, Option<E>, never>;
|
|
123
161
|
|
|
124
|
-
export { type Async as A,
|
|
162
|
+
export { type Async as A, makeCancelToken as B, type Canceler as C, linkAbortController as D, type Exit as E, type Fiber as F, type FiberId as G, type FiberStatus as H, type Interrupted as I, type ScopeId as J, Scope as K, withScope as L, globalScheduler as M, type None as N, type Option as O, RuntimeFiber as R, Scheduler as S, type Task as T, type ZIO as Z, sync as a, flatMap as b, mapError as c, catchAll as d, end as e, fail as f, asyncFold as g, asyncCatchAll as h, asyncMapError as i, asyncSucceed as j, asyncFail as k, asyncSync as l, map as m, asyncTotal as n, orElseOptional as o, async as p, asyncMap as q, asyncFlatMap as r, succeed as s, acquireRelease as t, unit as u, asyncInterruptible as v, type Some as w, none as x, some as y, type CancelToken as z };
|
|
@@ -19,11 +19,23 @@ declare function makeCancelToken(): CancelToken & {
|
|
|
19
19
|
*/
|
|
20
20
|
declare function linkAbortController(token: CancelToken, ac: AbortController): Canceler;
|
|
21
21
|
|
|
22
|
+
type Task = () => void;
|
|
23
|
+
declare class Scheduler {
|
|
24
|
+
private queue;
|
|
25
|
+
private flushing;
|
|
26
|
+
private requested;
|
|
27
|
+
schedule(task: Task, tag?: string): void;
|
|
28
|
+
private requestFlush;
|
|
29
|
+
private flush;
|
|
30
|
+
}
|
|
31
|
+
declare const globalScheduler: Scheduler;
|
|
32
|
+
|
|
22
33
|
type FiberId = number;
|
|
23
34
|
type Interrupted = {
|
|
24
35
|
readonly _tag: "Interrupted";
|
|
25
36
|
};
|
|
26
37
|
type FiberStatus = "Running" | "Done" | "Interrupted";
|
|
38
|
+
type StepDecision = "Continue" | "Suspend" | "Done";
|
|
27
39
|
type Fiber<E, A> = {
|
|
28
40
|
readonly id: FiberId;
|
|
29
41
|
readonly status: () => FiberStatus;
|
|
@@ -31,6 +43,32 @@ type Fiber<E, A> = {
|
|
|
31
43
|
readonly interrupt: () => void;
|
|
32
44
|
readonly addFinalizer: (f: (exit: Exit<E | Interrupted, A>) => void) => void;
|
|
33
45
|
};
|
|
46
|
+
declare class RuntimeFiber<R, E, A> implements Fiber<E, A> {
|
|
47
|
+
private readonly scheduler;
|
|
48
|
+
readonly id: FiberId;
|
|
49
|
+
private closing;
|
|
50
|
+
private finishing;
|
|
51
|
+
private runState;
|
|
52
|
+
private interrupted;
|
|
53
|
+
private result;
|
|
54
|
+
private readonly joiners;
|
|
55
|
+
private current;
|
|
56
|
+
private readonly env;
|
|
57
|
+
private readonly stack;
|
|
58
|
+
private readonly fiberFinalizers;
|
|
59
|
+
private finalizersDrained;
|
|
60
|
+
constructor(effect: Async<R, E, A>, env: R, scheduler: Scheduler);
|
|
61
|
+
addFinalizer(f: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
62
|
+
status(): FiberStatus;
|
|
63
|
+
join(cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
64
|
+
interrupt(): void;
|
|
65
|
+
schedule(tag?: string): void;
|
|
66
|
+
private runFinalizersOnce;
|
|
67
|
+
private notify;
|
|
68
|
+
private onSuccess;
|
|
69
|
+
private onFailure;
|
|
70
|
+
step(): StepDecision;
|
|
71
|
+
}
|
|
34
72
|
|
|
35
73
|
type ScopeId = number;
|
|
36
74
|
declare class Scope<R> {
|
|
@@ -121,4 +159,4 @@ declare const catchAll: <R, E, A, R2, E2, B>(fa: ZIO<R, E, A>, handler: (e: E) =
|
|
|
121
159
|
declare function orElseOptional<R, E, A, R2, A2>(fa: ZIO<R, Option<E>, A>, that: () => ZIO<R2, Option<E>, A2>): ZIO<R & R2, Option<E>, A | A2>;
|
|
122
160
|
declare const end: <E>() => ZIO<unknown, Option<E>, never>;
|
|
123
161
|
|
|
124
|
-
export { type Async as A,
|
|
162
|
+
export { type Async as A, makeCancelToken as B, type Canceler as C, linkAbortController as D, type Exit as E, type Fiber as F, type FiberId as G, type FiberStatus as H, type Interrupted as I, type ScopeId as J, Scope as K, withScope as L, globalScheduler as M, type None as N, type Option as O, RuntimeFiber as R, Scheduler as S, type Task as T, type ZIO as Z, sync as a, flatMap as b, mapError as c, catchAll as d, end as e, fail as f, asyncFold as g, asyncCatchAll as h, asyncMapError as i, asyncSucceed as j, asyncFail as k, asyncSync as l, map as m, asyncTotal as n, orElseOptional as o, async as p, asyncMap as q, asyncFlatMap as r, succeed as s, acquireRelease as t, unit as u, asyncInterruptible as v, type Some as w, none as x, some as y, type CancelToken as z };
|
package/dist/http/index.d.mts
CHANGED
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkREJAVP4D_js=require('../chunk-REJAVP4D.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 y(s={}){let p=s.baseUrl??"",d=s.headers??{},n=t=>chunkREJAVP4D_js.x(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((m,u)=>i[u]=m),{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=y;
|
package/dist/http/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {x}from'../chunk-JLFYFKQ2.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 y(s={}){let p=s.baseUrl??"",d=s.headers??{},n=t=>x(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((m,u)=>i[u]=m),{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{y as makeHttp};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Z as ZIO, O as Option, A as Async } from './effect-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
type Task = () => void;
|
|
5
|
-
declare class Scheduler {
|
|
6
|
-
private queue;
|
|
7
|
-
private flushing;
|
|
8
|
-
private requested;
|
|
9
|
-
schedule(task: Task, tag?: string): void;
|
|
10
|
-
private requestFlush;
|
|
11
|
-
private flush;
|
|
12
|
-
}
|
|
13
|
-
declare const globalScheduler: Scheduler;
|
|
1
|
+
import { Z as ZIO, O as Option, A as Async, S as Scheduler, F as Fiber, E as Exit, I as Interrupted } from './effect-Dt7h2Ttr.mjs';
|
|
2
|
+
export { z as CancelToken, C as Canceler, G as FiberId, H as FiberStatus, N as None, R as RuntimeFiber, K as Scope, J as ScopeId, w as Some, T as Task, t as acquireRelease, p as async, h as asyncCatchAll, k as asyncFail, r as asyncFlatMap, g as asyncFold, v as asyncInterruptible, q as asyncMap, i as asyncMapError, j as asyncSucceed, l as asyncSync, n as asyncTotal, d as catchAll, e as end, f as fail, b as flatMap, M as globalScheduler, D as linkAbortController, B as makeCancelToken, m as map, c as mapError, x as none, o as orElseOptional, y as some, s as succeed, a as sync, u as unit, L as withScope } from './effect-Dt7h2Ttr.mjs';
|
|
14
3
|
|
|
15
4
|
type Empty<R, E, A> = {
|
|
16
5
|
readonly _tag: "Empty";
|
|
@@ -54,4 +43,23 @@ declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a:
|
|
|
54
43
|
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
55
44
|
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
56
45
|
|
|
57
|
-
|
|
46
|
+
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
47
|
+
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
48
|
+
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
49
|
+
type BrassError = {
|
|
50
|
+
_tag: "Abort";
|
|
51
|
+
} | {
|
|
52
|
+
_tag: "PromiseRejected";
|
|
53
|
+
reason: unknown;
|
|
54
|
+
};
|
|
55
|
+
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
56
|
+
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
57
|
+
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
58
|
+
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
59
|
+
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
60
|
+
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
61
|
+
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
62
|
+
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
63
|
+
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
64
|
+
|
|
65
|
+
export { Async, type BrassError, type Concat, type Emit, type Empty, Exit, Fiber, type Flatten, type FromPull, Interrupted, type Merge, Option, Scheduler, ZIO, type ZStream, collectStream, concatStream, emitStream, emptyStream, flattenStream, foreachStream, fork, from, fromArray, fromCallback, fromPromise, fromPromiseAbortable, fromPull, mapStream, merge, mergeStream, rangeStream, toPromise, tryPromiseAbortable, uncons, unsafeRunAsync, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Z as ZIO, O as Option, A as Async } from './effect-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
type Task = () => void;
|
|
5
|
-
declare class Scheduler {
|
|
6
|
-
private queue;
|
|
7
|
-
private flushing;
|
|
8
|
-
private requested;
|
|
9
|
-
schedule(task: Task, tag?: string): void;
|
|
10
|
-
private requestFlush;
|
|
11
|
-
private flush;
|
|
12
|
-
}
|
|
13
|
-
declare const globalScheduler: Scheduler;
|
|
1
|
+
import { Z as ZIO, O as Option, A as Async, S as Scheduler, F as Fiber, E as Exit, I as Interrupted } from './effect-Dt7h2Ttr.js';
|
|
2
|
+
export { z as CancelToken, C as Canceler, G as FiberId, H as FiberStatus, N as None, R as RuntimeFiber, K as Scope, J as ScopeId, w as Some, T as Task, t as acquireRelease, p as async, h as asyncCatchAll, k as asyncFail, r as asyncFlatMap, g as asyncFold, v as asyncInterruptible, q as asyncMap, i as asyncMapError, j as asyncSucceed, l as asyncSync, n as asyncTotal, d as catchAll, e as end, f as fail, b as flatMap, M as globalScheduler, D as linkAbortController, B as makeCancelToken, m as map, c as mapError, x as none, o as orElseOptional, y as some, s as succeed, a as sync, u as unit, L as withScope } from './effect-Dt7h2Ttr.js';
|
|
14
3
|
|
|
15
4
|
type Empty<R, E, A> = {
|
|
16
5
|
readonly _tag: "Empty";
|
|
@@ -54,4 +43,23 @@ declare function foreachStream<R, E, A, R2, E2>(stream: ZStream<R, E, A>, f: (a:
|
|
|
54
43
|
declare function fromArray<A>(values: readonly A[]): ZStream<unknown, never, A>;
|
|
55
44
|
declare function collectStream<R, E, A>(stream: ZStream<R, E, A>): ZIO<R, E, A[]>;
|
|
56
45
|
|
|
57
|
-
|
|
46
|
+
type NodeCallback<A> = (err: Error | null, result: A) => void;
|
|
47
|
+
declare function from<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
48
|
+
declare function from<A>(thunk: () => Promise<A>): Async<{}, Error, A>;
|
|
49
|
+
type BrassError = {
|
|
50
|
+
_tag: "Abort";
|
|
51
|
+
} | {
|
|
52
|
+
_tag: "PromiseRejected";
|
|
53
|
+
reason: unknown;
|
|
54
|
+
};
|
|
55
|
+
declare function fork<R, E, A>(effect: Async<R, E, A>, env: R, scheduler?: Scheduler): Fiber<E, A>;
|
|
56
|
+
declare function unsafeRunAsync<R, E, A>(effect: Async<R, E, A>, env: R, cb: (exit: Exit<E | Interrupted, A>) => void): void;
|
|
57
|
+
declare function toPromise<R, E, A>(eff: Async<R, E, A>, env: R): Promise<A>;
|
|
58
|
+
declare function fromPromise<R, E, A>(thunk: (env: R) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
59
|
+
declare function fromCallback<A>(f: (cb: NodeCallback<A>) => void): Async<{}, Error, A>;
|
|
60
|
+
declare function tryPromiseAbortable<A>(thunk: (signal: AbortSignal) => Promise<A>): Async<unknown, BrassError, A>;
|
|
61
|
+
declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>): Async<R, BrassError, A>;
|
|
62
|
+
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
63
|
+
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
64
|
+
|
|
65
|
+
export { Async, type BrassError, type Concat, type Emit, type Empty, Exit, Fiber, type Flatten, type FromPull, Interrupted, type Merge, Option, Scheduler, ZIO, type ZStream, collectStream, concatStream, emitStream, emptyStream, flattenStream, foreachStream, fork, from, fromArray, fromCallback, fromPromise, fromPromiseAbortable, fromPull, mapStream, merge, mergeStream, rangeStream, toPromise, tryPromiseAbortable, uncons, unsafeRunAsync, zip };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkREJAVP4D_js=require('./chunk-REJAVP4D.js');var S={_tag:"None"},b=e=>({_tag:"Some",value:e});var k=e=>chunkREJAVP4D_js.e(e),_=e=>chunkREJAVP4D_js.f(e),Ee=e=>chunkREJAVP4D_js.g(r=>e(r)),g=(e,r)=>chunkREJAVP4D_js.j(e,r),N=(e,r)=>chunkREJAVP4D_js.k(e,t=>r(t)),w=(e,r)=>chunkREJAVP4D_js.c(e,r),ie=(e,r)=>chunkREJAVP4D_js.a(e,t=>r(t),t=>chunkREJAVP4D_js.e(t));function C(e,r){return chunkREJAVP4D_js.a(e,t=>t._tag==="Some"?chunkREJAVP4D_js.f(t):r(),t=>chunkREJAVP4D_js.e(t))}var pe=()=>_(S);function Ae(){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:()=>{if(!e){e=true;for(let n of r)try{n();}catch{}r.clear();}}}}function Re(e,r){return e.onCancel(()=>r.abort())}var H=1,x=class e{constructor(r){this.env=r;this.id=H++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(r){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(r);}subScope(){if(this.closed)throw new Error("Scope closed");let r=new e(this.env);return this.subScopes.add(r),r}fork(r,t){if(this.closed)throw new Error("Scope closed");let n=chunkREJAVP4D_js.r(r,t);return this.children.add(n),n.join(()=>{this.children.delete(n);}),n}close(r={_tag:"Success",value:void 0}){if(!this.closed){for(this.closed=true,this.children.forEach(t=>t.interrupt()),this.subScopes.forEach(t=>t.close(r));this.finalizers.length>0;){let n=this.finalizers.pop()(r);chunkREJAVP4D_js.r(n,this.env);}this.children.clear(),this.subScopes.clear();}}isClosed(){return this.closed}};function de(e){let r=new x({});try{return e(r)}finally{r.close();}}function T(e,r,t,n,o){return chunkREJAVP4D_js.i((a,c)=>{let E=t.subScope(),s=false,R=E.fork(e,a),d=E.fork(r,a),m=u=>{E.fork(u,a).join(f=>{E.close(f),c(f);});};R.join(u=>{s||(s=true,m(n(u,d,E)));}),d.join(u=>{s||(s=true,m(o(u,R,E)));});})}var P=e=>e._tag==="None"?S:b(e.value),Z=e=>({_tag:"FromPull",pull:e}),we=(e,r,t=true)=>({_tag:"Merge",left:e,right:r,flip:t}),$=()=>({_tag:"Empty"}),W=e=>({_tag:"Emit",value:e}),F=(e,r)=>({_tag:"Concat",left:e,right:r}),M=e=>({_tag:"Flatten",stream:e});function L(e,r,t,n,o){return (a,c,E)=>{if(console.log(`[mergePull#${o}] winner=${e} exit=${a._tag}`),a._tag==="Failure"&&console.log(`[mergePull#${o}] failure error=`,a.error),a._tag==="Success"&&console.log(`[mergePull#${o}] success -> interrupt other`),a._tag==="Success"){let[d,m]=a.value;c.interrupt();let u=Z(e==="L"?v(m,t,!n,o):v(r,m,!n,o));return chunkREJAVP4D_js.e([d,u])}let s=a.error;if(typeof s=="object"&&s!==null&&s._tag==="Interrupted")return chunkREJAVP4D_js.f(s);let R=s;return R._tag==="None"?l(e==="L"?t:r):chunkREJAVP4D_js.f(R)}}function v(e,r,t,n){return chunkREJAVP4D_js.i((o,a)=>{let c=++n;console.log(`[mergePull#${c}] start flip=${t}`);let E=new x(o);console.log(`[mergePull#${c}] built pulls`);let s=l(e),R=l(r);console.log(`[mergePull#${c}] built pulls`);let d=L("L",e,r,t,c),m=L("R",e,r,t,c);console.log(`[mergePull#${c}] calling raceWith`);let u=T(s,R,E,d,m);console.log(`[mergePull#${c}] forking handler`),E.fork(u,o).join(f=>{console.log(`[mergePull#${c}] handler joined exit=${f._tag}`),E.close(f),console.log(`[mergePull#${c}] scope closed, calling cb`),a(f);});})}function Ce(e,r){return Z(v(e,r,true,0))}function l(e){switch(e._tag){case "Empty":return _(S);case "Emit":return g(w(e.value,r=>b(r)),r=>[r,$()]);case "FromPull":return console.log("[uncons] FromPull"),e.pull;case "Concat":return C(g(l(e.left),([r,t])=>[r,F(t,e.right)]),()=>l(e.right));case "Flatten":return N(l(e.stream),([r,t])=>C(g(l(r),([n,o])=>[n,F(o,M(t))]),()=>l(M(t))));case "Merge":return console.log("[makeMergePull] defined"),v(e.left,e.right,e.flip,0)}}function h(e,r){switch(e._tag){case "Empty":return $();case "Emit":return W(g(e.value,r));case "FromPull":return Z(g(e.pull,([t,n])=>[r(t),h(n,r)]));case "Concat":return F(h(e.left,r),h(e.right,r));case "Flatten":{let t=h(e.stream,n=>h(n,r));return M(t)}}}function Pe(e,r){let t=n=>Z(n>r?chunkREJAVP4D_js.f(S):chunkREJAVP4D_js.e([n,t(n+1)]));return t(e)}function D(e,r){let t=chunkREJAVP4D_js.a(chunkREJAVP4D_js.c(l(e),n=>P(n)),n=>chunkREJAVP4D_js.f(n),([n,o])=>chunkREJAVP4D_js.a(chunkREJAVP4D_js.c(l(r),a=>P(a)),a=>chunkREJAVP4D_js.f(a),([a,c])=>chunkREJAVP4D_js.e([[n,a],D(o,c)])));return Z(t)}function Me(e,r){let t=n=>chunkREJAVP4D_js.a(chunkREJAVP4D_js.c(l(n),o=>P(o)),o=>o._tag==="None"?chunkREJAVP4D_js.e(void 0):chunkREJAVP4D_js.f(o),([o,a])=>chunkREJAVP4D_js.k(chunkREJAVP4D_js.c(r(o),c=>b(c)),()=>t(a)));return chunkREJAVP4D_js.a(t(e),n=>n._tag==="None"?chunkREJAVP4D_js.e(void 0):chunkREJAVP4D_js.f(n.value),()=>chunkREJAVP4D_js.e(void 0))}function $e(e){let r=$();for(let t=e.length-1;t>=0;t--){let n=W(k(e[t]));r=F(n,r);}return r}function je(e){let r=(t,n)=>chunkREJAVP4D_js.a(l(t),o=>o._tag==="None"?k(n):_(o),([o,a])=>r(a,[...n,o]));return w(r(e,[]),t=>{if(t._tag==="Some")return t.value;throw new Error("unreachable: stream end handled as success")})}Object.defineProperty(exports,"RuntimeFiber",{enumerable:true,get:function(){return chunkREJAVP4D_js.p}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkREJAVP4D_js.n}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkREJAVP4D_js.l}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkREJAVP4D_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkREJAVP4D_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkREJAVP4D_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkREJAVP4D_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkREJAVP4D_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkREJAVP4D_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkREJAVP4D_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkREJAVP4D_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkREJAVP4D_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkREJAVP4D_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkREJAVP4D_js.h}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkREJAVP4D_js.r}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkREJAVP4D_js.q}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkREJAVP4D_js.v}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkREJAVP4D_js.u}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkREJAVP4D_js.x}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkREJAVP4D_js.o}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkREJAVP4D_js.t}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkREJAVP4D_js.w}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkREJAVP4D_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkREJAVP4D_js.s}});exports.Scope=x;exports.catchAll=ie;exports.collectStream=je;exports.concatStream=F;exports.emitStream=W;exports.emptyStream=$;exports.end=pe;exports.fail=_;exports.flatMap=N;exports.flattenStream=M;exports.foreachStream=Me;exports.fromArray=$e;exports.fromPull=Z;exports.linkAbortController=Re;exports.makeCancelToken=Ae;exports.map=g;exports.mapError=w;exports.mapStream=h;exports.merge=Ce;exports.mergeStream=we;exports.none=S;exports.orElseOptional=C;exports.rangeStream=Pe;exports.some=b;exports.succeed=k;exports.sync=Ee;exports.uncons=l;exports.withScope=de;exports.zip=D;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,f,k as k$1,j,c,e,g as g$1,
|
|
1
|
+
import {a,f,k as k$1,j,c,e,g as g$1,r,i}from'./chunk-JLFYFKQ2.mjs';export{p as RuntimeFiber,n as Scheduler,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,r as fork,q as from,v as fromCallback,u as fromPromise,x as fromPromiseAbortable,o as globalScheduler,t as toPromise,w as tryPromiseAbortable,d as unit,s as unsafeRunAsync}from'./chunk-JLFYFKQ2.mjs';var S={_tag:"None"},b=e=>({_tag:"Some",value:e});var k=e$1=>e(e$1),_=e=>f(e),Ee=e=>g$1(r=>e(r)),g=(e,r)=>j(e,r),N=(e,r)=>k$1(e,t=>r(t)),w=(e,r)=>c(e,r),ie=(e$1,r)=>a(e$1,t=>r(t),t=>e(t));function C(e$1,r){return a(e$1,t=>t._tag==="Some"?f(t):r(),t=>e(t))}var pe=()=>_(S);function Ae(){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:()=>{if(!e){e=true;for(let n of r)try{n();}catch{}r.clear();}}}}function Re(e,r){return e.onCancel(()=>r.abort())}var H=1,x=class e{constructor(r){this.env=r;this.id=H++;}id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(r){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(r);}subScope(){if(this.closed)throw new Error("Scope closed");let r=new e(this.env);return this.subScopes.add(r),r}fork(r$1,t){if(this.closed)throw new Error("Scope closed");let n=r(r$1,t);return this.children.add(n),n.join(()=>{this.children.delete(n);}),n}close(r$1={_tag:"Success",value:void 0}){if(!this.closed){for(this.closed=true,this.children.forEach(t=>t.interrupt()),this.subScopes.forEach(t=>t.close(r$1));this.finalizers.length>0;){let n=this.finalizers.pop()(r$1);r(n,this.env);}this.children.clear(),this.subScopes.clear();}}isClosed(){return this.closed}};function de(e){let r=new x({});try{return e(r)}finally{r.close();}}function T(e,r,t,n,o){return i((a,c)=>{let E=t.subScope(),s=false,R=E.fork(e,a),d=E.fork(r,a),m=u=>{E.fork(u,a).join(f=>{E.close(f),c(f);});};R.join(u=>{s||(s=true,m(n(u,d,E)));}),d.join(u=>{s||(s=true,m(o(u,R,E)));});})}var P=e=>e._tag==="None"?S:b(e.value),Z=e=>({_tag:"FromPull",pull:e}),we=(e,r,t=true)=>({_tag:"Merge",left:e,right:r,flip:t}),$=()=>({_tag:"Empty"}),W=e=>({_tag:"Emit",value:e}),F=(e,r)=>({_tag:"Concat",left:e,right:r}),M=e=>({_tag:"Flatten",stream:e});function L(e$1,r,t,n,o){return (a,c,E)=>{if(console.log(`[mergePull#${o}] winner=${e$1} exit=${a._tag}`),a._tag==="Failure"&&console.log(`[mergePull#${o}] failure error=`,a.error),a._tag==="Success"&&console.log(`[mergePull#${o}] success -> interrupt other`),a._tag==="Success"){let[d,m]=a.value;c.interrupt();let u=Z(e$1==="L"?v(m,t,!n,o):v(r,m,!n,o));return e([d,u])}let s=a.error;if(typeof s=="object"&&s!==null&&s._tag==="Interrupted")return f(s);let R=s;return R._tag==="None"?l(e$1==="L"?t:r):f(R)}}function v(e,r,t,n){return i((o,a)=>{let c=++n;console.log(`[mergePull#${c}] start flip=${t}`);let E=new x(o);console.log(`[mergePull#${c}] built pulls`);let s=l(e),R=l(r);console.log(`[mergePull#${c}] built pulls`);let d=L("L",e,r,t,c),m=L("R",e,r,t,c);console.log(`[mergePull#${c}] calling raceWith`);let u=T(s,R,E,d,m);console.log(`[mergePull#${c}] forking handler`),E.fork(u,o).join(f=>{console.log(`[mergePull#${c}] handler joined exit=${f._tag}`),E.close(f),console.log(`[mergePull#${c}] scope closed, calling cb`),a(f);});})}function Ce(e,r){return Z(v(e,r,true,0))}function l(e){switch(e._tag){case "Empty":return _(S);case "Emit":return g(w(e.value,r=>b(r)),r=>[r,$()]);case "FromPull":return console.log("[uncons] FromPull"),e.pull;case "Concat":return C(g(l(e.left),([r,t])=>[r,F(t,e.right)]),()=>l(e.right));case "Flatten":return N(l(e.stream),([r,t])=>C(g(l(r),([n,o])=>[n,F(o,M(t))]),()=>l(M(t))));case "Merge":return console.log("[makeMergePull] defined"),v(e.left,e.right,e.flip,0)}}function h(e,r){switch(e._tag){case "Empty":return $();case "Emit":return W(g(e.value,r));case "FromPull":return Z(g(e.pull,([t,n])=>[r(t),h(n,r)]));case "Concat":return F(h(e.left,r),h(e.right,r));case "Flatten":{let t=h(e.stream,n=>h(n,r));return M(t)}}}function Pe(e$1,r){let t=n=>Z(n>r?f(S):e([n,t(n+1)]));return t(e$1)}function D(e$1,r){let t=a(c(l(e$1),n=>P(n)),n=>f(n),([n,o])=>a(c(l(r),a=>P(a)),a=>f(a),([a,c])=>e([[n,a],D(o,c)])));return Z(t)}function Me(e$1,r){let t=n=>a(c(l(n),o=>P(o)),o=>o._tag==="None"?e(void 0):f(o),([o,a])=>k$1(c(r(o),c=>b(c)),()=>t(a)));return a(t(e$1),n=>n._tag==="None"?e(void 0):f(n.value),()=>e(void 0))}function $e(e){let r=$();for(let t=e.length-1;t>=0;t--){let n=W(k(e[t]));r=F(n,r);}return r}function je(e){let r=(t,n)=>a(l(t),o=>o._tag==="None"?k(n):_(o),([o,a])=>r(a,[...n,o]));return w(r(e,[]),t=>{if(t._tag==="Some")return t.value;throw new Error("unreachable: stream end handled as success")})}export{x as Scope,ie as catchAll,je as collectStream,F as concatStream,W as emitStream,$ as emptyStream,pe as end,_ as fail,N as flatMap,M as flattenStream,Me as foreachStream,$e as fromArray,Z as fromPull,Re as linkAbortController,Ae as makeCancelToken,g as map,w as mapError,h as mapStream,Ce as merge,we as mergeStream,S as none,C as orElseOptional,Pe as rangeStream,b as some,k as succeed,Ee as sync,l as uncons,de as withScope,D as zip};
|