brass-runtime 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/index.mjs +1 -1
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-OETP4M4Z.js → chunk-JKG47VM5.js} +0 -0
- /package/dist/{chunk-HYS5U72G.mjs → chunk-Z2JVOS2Q.mjs} +0 -0
package/README.md
CHANGED
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkJKG47VM5_js=require('../chunk-JKG47VM5.js');var h=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)};function b(t={}){let e=t.baseUrl??"",s=t.headers??{};return r=>chunkJKG47VM5_js.x(async y=>{let a;try{a=new URL(r.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${r.url}`}}let g=performance.now(),n=await fetch(a,{...r.init??{},method:r.method,headers:{...s,...r.headers??{}},body:r.body,signal:y}),m=await n.text(),p={};return n.headers.forEach((u,E)=>p[E]=u),{status:n.status,statusText:n.statusText,headers:p,bodyText:m,ms:Math.round(performance.now()-g)}},h)}var l=(t,e)=>chunkJKG47VM5_js.k(t,s=>chunkJKG47VM5_js.e(e(s))),x=(t,e)=>chunkJKG47VM5_js.k(t,s=>chunkJKG47VM5_js.g(()=>e(s)));exports.makeHttp=b;exports.mapAsync=l;exports.mapTryAsync=x;
|
package/dist/http/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {k,x as x$1,e,g}from'../chunk-
|
|
1
|
+
import {k,x as x$1,e,g}from'../chunk-Z2JVOS2Q.mjs';var h=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)};function b(t={}){let e=t.baseUrl??"",s=t.headers??{};return r=>x$1(async y=>{let a;try{a=new URL(r.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${r.url}`}}let g=performance.now(),n=await fetch(a,{...r.init??{},method:r.method,headers:{...s,...r.headers??{}},body:r.body,signal:y}),m=await n.text(),p={};return n.headers.forEach((u,E)=>p[E]=u),{status:n.status,statusText:n.statusText,headers:p,bodyText:m,ms:Math.round(performance.now()-g)}},h)}var l=(t,e$1)=>k(t,s=>e(e$1(s))),x=(t,e)=>k(t,s=>g(()=>e(s)));export{b as makeHttp,l as mapAsync,x as mapTryAsync};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Z as ZIO, O as Option, A as Async, S as Scheduler, F as Fiber,
|
|
1
|
+
import { Z as ZIO, O as Option, E as Exit, A as Async, S as Scheduler, F as Fiber, I as Interrupted } from './effect-Dt7h2Ttr.mjs';
|
|
2
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';
|
|
3
3
|
|
|
4
4
|
type Empty<R, E, A> = {
|
|
@@ -27,8 +27,18 @@ type Merge<R, E, A> = {
|
|
|
27
27
|
readonly right: ZStream<R, E, A>;
|
|
28
28
|
readonly flip: boolean;
|
|
29
29
|
};
|
|
30
|
-
type
|
|
30
|
+
type Scoped<R, E, A> = {
|
|
31
|
+
readonly _tag: "Scoped";
|
|
32
|
+
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
33
|
+
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
34
|
+
};
|
|
35
|
+
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
31
36
|
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
37
|
+
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
38
|
+
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
39
|
+
stream: ZStream<R, E, A>;
|
|
40
|
+
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
41
|
+
}>) => ZStream<R, E, A>;
|
|
32
42
|
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
33
43
|
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
34
44
|
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
@@ -62,4 +72,4 @@ declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal)
|
|
|
62
72
|
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
63
73
|
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
64
74
|
|
|
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 };
|
|
75
|
+
export { Async, type BrassError, type Concat, type Emit, type Empty, Exit, Fiber, type Flatten, type FromPull, Interrupted, type Merge, Option, Scheduler, type Scoped, ZIO, type ZStream, collectStream, concatStream, emitStream, emptyStream, flattenStream, foreachStream, fork, from, fromArray, fromCallback, fromPromise, fromPromiseAbortable, fromPull, managedStream, mapStream, merge, mergeStream, rangeStream, toPromise, tryPromiseAbortable, uncons, unsafeRunAsync, unwrapScoped, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Z as ZIO, O as Option, A as Async, S as Scheduler, F as Fiber,
|
|
1
|
+
import { Z as ZIO, O as Option, E as Exit, A as Async, S as Scheduler, F as Fiber, I as Interrupted } from './effect-Dt7h2Ttr.js';
|
|
2
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';
|
|
3
3
|
|
|
4
4
|
type Empty<R, E, A> = {
|
|
@@ -27,8 +27,18 @@ type Merge<R, E, A> = {
|
|
|
27
27
|
readonly right: ZStream<R, E, A>;
|
|
28
28
|
readonly flip: boolean;
|
|
29
29
|
};
|
|
30
|
-
type
|
|
30
|
+
type Scoped<R, E, A> = {
|
|
31
|
+
readonly _tag: "Scoped";
|
|
32
|
+
readonly acquire: ZIO<R, E, ZStream<R, E, A>>;
|
|
33
|
+
readonly release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
34
|
+
};
|
|
35
|
+
type ZStream<R, E, A> = Empty<R, E, A> | Emit<R, E, A> | Concat<R, E, A> | FromPull<R, E, A> | Flatten<R, E, A> | Merge<R, E, A> | Scoped<R, E, A>;
|
|
31
36
|
declare const fromPull: <R, E, A>(pull: ZIO<R, Option<E>, [A, ZStream<R, E, A>]>) => ZStream<R, E, A>;
|
|
37
|
+
declare const unwrapScoped: <R, E, A>(acquire: ZIO<R, E, ZStream<R, E, A>>, release: (exit: Exit<any, any>) => Async<R, any, void>) => ZStream<R, E, A>;
|
|
38
|
+
declare const managedStream: <R, E, A>(acquire: Async<R, E, {
|
|
39
|
+
stream: ZStream<R, E, A>;
|
|
40
|
+
release: (exit: Exit<any, any>) => Async<R, any, void>;
|
|
41
|
+
}>) => ZStream<R, E, A>;
|
|
32
42
|
declare const mergeStream: <R, E, A>(left: ZStream<R, E, A>, right: ZStream<R, E, A>, flip?: boolean) => ZStream<R, E, A>;
|
|
33
43
|
declare const emptyStream: <R, E, A>() => ZStream<R, E, A>;
|
|
34
44
|
declare const emitStream: <R, E, A>(value: ZIO<R, E, A>) => ZStream<R, E, A>;
|
|
@@ -62,4 +72,4 @@ declare function tryPromiseAbortable<R, A>(thunk: (env: R, signal: AbortSignal)
|
|
|
62
72
|
declare function fromPromiseAbortable<E, A>(thunk: (signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<unknown, E, A>;
|
|
63
73
|
declare function fromPromiseAbortable<R, E, A>(thunk: (env: R, signal: AbortSignal) => Promise<A>, onError: (e: unknown) => E): Async<R, E, A>;
|
|
64
74
|
|
|
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 };
|
|
75
|
+
export { Async, type BrassError, type Concat, type Emit, type Empty, Exit, Fiber, type Flatten, type FromPull, Interrupted, type Merge, Option, Scheduler, type Scoped, ZIO, type ZStream, collectStream, concatStream, emitStream, emptyStream, flattenStream, foreachStream, fork, from, fromArray, fromCallback, fromPromise, fromPromiseAbortable, fromPull, managedStream, mapStream, merge, mergeStream, rangeStream, toPromise, tryPromiseAbortable, uncons, unsafeRunAsync, unwrapScoped, zip };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkJKG47VM5_js=require('./chunk-JKG47VM5.js');var g={_tag:"None"},I=e=>({_tag:"Some",value:e});var k=e=>chunkJKG47VM5_js.e(e),b=e=>chunkJKG47VM5_js.f(e),Ee=e=>chunkJKG47VM5_js.g(r=>e(r)),Z=(e,r)=>chunkJKG47VM5_js.j(e,r),N=(e,r)=>chunkJKG47VM5_js.k(e,t=>r(t)),w=(e,r)=>chunkJKG47VM5_js.c(e,r),ie=(e,r)=>chunkJKG47VM5_js.a(e,t=>r(t),t=>chunkJKG47VM5_js.e(t));function C(e,r){return chunkJKG47VM5_js.a(e,t=>t._tag==="Some"?chunkJKG47VM5_js.f(t):r(),t=>chunkJKG47VM5_js.e(t))}var pe=()=>b(g);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:()=>{e||(e=true,r.forEach(n=>n()),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=chunkJKG47VM5_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);chunkJKG47VM5_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 chunkJKG47VM5_js.i((a,c)=>{let s=t.subScope(),E=false,R=s.fork(e,a),d=s.fork(r,a),m=u=>{s.fork(u,a).join(S=>{s.close(S),c(S);});};R.join(u=>{E||(E=true,m(n(u,d,s)));}),d.join(u=>{E||(E=true,m(o(u,R,s)));});})}var P=e=>e._tag==="None"?g:I(e.value),h=e=>({_tag:"FromPull",pull:e}),we=(e,r)=>({_tag:"Scoped",acquire:e,release:r}),Ce=e=>({_tag:"Scoped",acquire:chunkJKG47VM5_js.k(e,r=>chunkJKG47VM5_js.e(r.stream)),release:r=>chunkJKG47VM5_js.k(e,t=>t.release(r))}),Pe=(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,s)=>{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=h(e==="L"?v(m,t,!n,o):v(r,m,!n,o));return chunkJKG47VM5_js.e([d,u])}let E=a.error;if(typeof E=="object"&&E!==null&&E._tag==="Interrupted")return chunkJKG47VM5_js.f(E);let R=E;return R._tag==="None"?l(e==="L"?t:r):chunkJKG47VM5_js.f(R)}}function v(e,r,t,n){return chunkJKG47VM5_js.i((o,a)=>{let c=++n;console.log(`[mergePull#${c}] start flip=${t}`);let s=new x(o);console.log(`[mergePull#${c}] built pulls`);let E=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(E,R,s,d,m);console.log(`[mergePull#${c}] forking handler`),s.fork(u,o).join(S=>{console.log(`[mergePull#${c}] handler joined exit=${S._tag}`),s.close(S),console.log(`[mergePull#${c}] scope closed, calling cb`),a(S);});})}function Me(e,r){return h(v(e,r,true,0))}function l(e){switch(e._tag){case "Empty":return b(g);case "Emit":return Z(w(e.value,r=>I(r)),r=>[r,$()]);case "FromPull":return console.log("[uncons] FromPull"),e.pull;case "Concat":return C(Z(l(e.left),([r,t])=>[r,F(t,e.right)]),()=>l(e.right));case "Flatten":return N(l(e.stream),([r,t])=>C(Z(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);case "Scoped":return chunkJKG47VM5_js.i((r,t)=>{let n=new x(r);n.addFinalizer(o=>e.release(o)),n.fork(e.acquire,r).join(o=>{if(o._tag==="Failure"){n.close(o),t({_tag:"Failure",error:I(o.error)});return}let a=o.value;l(a)(r,s=>{n.close(s),t(s);});});})}}function _(e,r){switch(e._tag){case "Empty":return $();case "Emit":return W(Z(e.value,r));case "FromPull":return h(Z(e.pull,([t,n])=>[r(t),_(n,r)]));case "Concat":return F(_(e.left,r),_(e.right,r));case "Flatten":{let t=_(e.stream,n=>_(n,r));return M(t)}}}function $e(e,r){let t=n=>h(n>r?chunkJKG47VM5_js.f(g):chunkJKG47VM5_js.e([n,t(n+1)]));return t(e)}function q(e,r){let t=chunkJKG47VM5_js.a(chunkJKG47VM5_js.c(l(e),n=>P(n)),n=>chunkJKG47VM5_js.f(n),([n,o])=>chunkJKG47VM5_js.a(chunkJKG47VM5_js.c(l(r),a=>P(a)),a=>chunkJKG47VM5_js.f(a),([a,c])=>chunkJKG47VM5_js.e([[n,a],q(o,c)])));return h(t)}function je(e,r){let t=n=>chunkJKG47VM5_js.a(chunkJKG47VM5_js.c(l(n),o=>P(o)),o=>o._tag==="None"?chunkJKG47VM5_js.e(void 0):chunkJKG47VM5_js.f(o),([o,a])=>chunkJKG47VM5_js.k(chunkJKG47VM5_js.c(r(o),c=>I(c)),()=>t(a)));return chunkJKG47VM5_js.a(t(e),n=>n._tag==="None"?chunkJKG47VM5_js.e(void 0):chunkJKG47VM5_js.f(n.value),()=>chunkJKG47VM5_js.e(void 0))}function ze(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 Ne(e){let r=(t,n)=>chunkJKG47VM5_js.a(l(t),o=>o._tag==="None"?k(n):b(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 chunkJKG47VM5_js.p}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkJKG47VM5_js.n}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkJKG47VM5_js.l}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkJKG47VM5_js.i}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkJKG47VM5_js.b}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkJKG47VM5_js.f}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkJKG47VM5_js.k}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkJKG47VM5_js.a}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkJKG47VM5_js.m}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkJKG47VM5_js.j}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkJKG47VM5_js.c}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkJKG47VM5_js.e}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkJKG47VM5_js.g}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkJKG47VM5_js.h}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkJKG47VM5_js.r}});Object.defineProperty(exports,"from",{enumerable:true,get:function(){return chunkJKG47VM5_js.q}});Object.defineProperty(exports,"fromCallback",{enumerable:true,get:function(){return chunkJKG47VM5_js.v}});Object.defineProperty(exports,"fromPromise",{enumerable:true,get:function(){return chunkJKG47VM5_js.u}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkJKG47VM5_js.x}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkJKG47VM5_js.o}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkJKG47VM5_js.t}});Object.defineProperty(exports,"tryPromiseAbortable",{enumerable:true,get:function(){return chunkJKG47VM5_js.w}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkJKG47VM5_js.d}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkJKG47VM5_js.s}});exports.Scope=x;exports.catchAll=ie;exports.collectStream=Ne;exports.concatStream=F;exports.emitStream=W;exports.emptyStream=$;exports.end=pe;exports.fail=b;exports.flatMap=N;exports.flattenStream=M;exports.foreachStream=je;exports.fromArray=ze;exports.fromPull=h;exports.linkAbortController=Re;exports.makeCancelToken=Ae;exports.managedStream=Ce;exports.map=Z;exports.mapError=w;exports.mapStream=_;exports.merge=Me;exports.mergeStream=Pe;exports.none=g;exports.orElseOptional=C;exports.rangeStream=$e;exports.some=I;exports.succeed=k;exports.sync=Ee;exports.uncons=l;exports.unwrapScoped=we;exports.withScope=de;exports.zip=q;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,f,k as k$1,j,c,e,g as g$1,r,i}from'./chunk-
|
|
1
|
+
import {a,f,k as k$1,j,c,e,g as g$1,r,i}from'./chunk-Z2JVOS2Q.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-Z2JVOS2Q.mjs';var g={_tag:"None"},I=e=>({_tag:"Some",value:e});var k=e$1=>e(e$1),b=e=>f(e),Ee=e=>g$1(r=>e(r)),Z=(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=()=>b(g);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:()=>{e||(e=true,r.forEach(n=>n()),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 s=t.subScope(),E=false,R=s.fork(e,a),d=s.fork(r,a),m=u=>{s.fork(u,a).join(S=>{s.close(S),c(S);});};R.join(u=>{E||(E=true,m(n(u,d,s)));}),d.join(u=>{E||(E=true,m(o(u,R,s)));});})}var P=e=>e._tag==="None"?g:I(e.value),h=e=>({_tag:"FromPull",pull:e}),we=(e,r)=>({_tag:"Scoped",acquire:e,release:r}),Ce=e$1=>({_tag:"Scoped",acquire:k$1(e$1,r=>e(r.stream)),release:r=>k$1(e$1,t=>t.release(r))}),Pe=(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,s)=>{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=h(e$1==="L"?v(m,t,!n,o):v(r,m,!n,o));return e([d,u])}let E=a.error;if(typeof E=="object"&&E!==null&&E._tag==="Interrupted")return f(E);let R=E;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 s=new x(o);console.log(`[mergePull#${c}] built pulls`);let E=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(E,R,s,d,m);console.log(`[mergePull#${c}] forking handler`),s.fork(u,o).join(S=>{console.log(`[mergePull#${c}] handler joined exit=${S._tag}`),s.close(S),console.log(`[mergePull#${c}] scope closed, calling cb`),a(S);});})}function Me(e,r){return h(v(e,r,true,0))}function l(e){switch(e._tag){case "Empty":return b(g);case "Emit":return Z(w(e.value,r=>I(r)),r=>[r,$()]);case "FromPull":return console.log("[uncons] FromPull"),e.pull;case "Concat":return C(Z(l(e.left),([r,t])=>[r,F(t,e.right)]),()=>l(e.right));case "Flatten":return N(l(e.stream),([r,t])=>C(Z(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);case "Scoped":return i((r,t)=>{let n=new x(r);n.addFinalizer(o=>e.release(o)),n.fork(e.acquire,r).join(o=>{if(o._tag==="Failure"){n.close(o),t({_tag:"Failure",error:I(o.error)});return}let a=o.value;l(a)(r,s=>{n.close(s),t(s);});});})}}function _(e,r){switch(e._tag){case "Empty":return $();case "Emit":return W(Z(e.value,r));case "FromPull":return h(Z(e.pull,([t,n])=>[r(t),_(n,r)]));case "Concat":return F(_(e.left,r),_(e.right,r));case "Flatten":{let t=_(e.stream,n=>_(n,r));return M(t)}}}function $e(e$1,r){let t=n=>h(n>r?f(g):e([n,t(n+1)]));return t(e$1)}function q(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],q(o,c)])));return h(t)}function je(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=>I(c)),()=>t(a)));return a(t(e$1),n=>n._tag==="None"?e(void 0):f(n.value),()=>e(void 0))}function ze(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 Ne(e){let r=(t,n)=>a(l(t),o=>o._tag==="None"?k(n):b(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,Ne as collectStream,F as concatStream,W as emitStream,$ as emptyStream,pe as end,b as fail,N as flatMap,M as flattenStream,je as foreachStream,ze as fromArray,h as fromPull,Re as linkAbortController,Ae as makeCancelToken,Ce as managedStream,Z as map,w as mapError,_ as mapStream,Me as merge,Pe as mergeStream,g as none,C as orElseOptional,$e as rangeStream,I as some,k as succeed,Ee as sync,l as uncons,we as unwrapScoped,de as withScope,q as zip};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|