Erster Docker-Stand

This commit is contained in:
Ali
2026-02-20 16:06:40 +09:00
commit f31e2e8ed3
8818 changed files with 1605323 additions and 0 deletions

View File

@@ -0,0 +1,697 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.runIn = exports.readUpstream = exports.ChannelExecutor = void 0;
var Cause = _interopRequireWildcard(require("../../Cause.js"));
var Deferred = _interopRequireWildcard(require("../../Deferred.js"));
var Effect = _interopRequireWildcard(require("../../Effect.js"));
var ExecutionStrategy = _interopRequireWildcard(require("../../ExecutionStrategy.js"));
var Exit = _interopRequireWildcard(require("../../Exit.js"));
var Fiber = _interopRequireWildcard(require("../../Fiber.js"));
var FiberId = _interopRequireWildcard(require("../../FiberId.js"));
var _Function = require("../../Function.js");
var HashSet = _interopRequireWildcard(require("../../HashSet.js"));
var Option = _interopRequireWildcard(require("../../Option.js"));
var Scope = _interopRequireWildcard(require("../../Scope.js"));
var core = _interopRequireWildcard(require("../core-stream.js"));
var ChannelOpCodes = _interopRequireWildcard(require("../opCodes/channel.js"));
var ChildExecutorDecisionOpCodes = _interopRequireWildcard(require("../opCodes/channelChildExecutorDecision.js"));
var ChannelStateOpCodes = _interopRequireWildcard(require("../opCodes/channelState.js"));
var UpstreamPullStrategyOpCodes = _interopRequireWildcard(require("../opCodes/channelUpstreamPullStrategy.js"));
var ContinuationOpCodes = _interopRequireWildcard(require("../opCodes/continuation.js"));
var ChannelState = _interopRequireWildcard(require("./channelState.js"));
var Continuation = _interopRequireWildcard(require("./continuation.js"));
var Subexecutor = _interopRequireWildcard(require("./subexecutor.js"));
var upstreamPullRequest = _interopRequireWildcard(require("./upstreamPullRequest.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
class ChannelExecutor {
_activeSubexecutor = undefined;
_cancelled = undefined;
_closeLastSubstream = undefined;
_currentChannel;
_done = undefined;
_doneStack = [];
_emitted = undefined;
_executeCloseLastSubstream;
_input = undefined;
_inProgressFinalizer = undefined;
_providedEnv;
constructor(initialChannel, providedEnv, executeCloseLastSubstream) {
this._currentChannel = initialChannel;
this._executeCloseLastSubstream = executeCloseLastSubstream;
this._providedEnv = providedEnv;
}
run() {
let result = undefined;
while (result === undefined) {
if (this._cancelled !== undefined) {
result = this.processCancellation();
} else if (this._activeSubexecutor !== undefined) {
result = this.runSubexecutor();
} else {
try {
if (this._currentChannel === undefined) {
result = ChannelState.Done();
} else {
if (Effect.isEffect(this._currentChannel)) {
this._currentChannel = core.fromEffect(this._currentChannel);
}
switch (this._currentChannel._tag) {
case ChannelOpCodes.OP_BRACKET_OUT:
{
result = this.runBracketOut(this._currentChannel);
break;
}
case ChannelOpCodes.OP_BRIDGE:
{
const bridgeInput = this._currentChannel.input;
// PipeTo(left, Bridge(queue, channel))
// In a fiber: repeatedly run left and push its outputs to the queue
// Add a finalizer to interrupt the fiber and close the executor
this._currentChannel = this._currentChannel.channel;
if (this._input !== undefined) {
const inputExecutor = this._input;
this._input = undefined;
const drainer = () => Effect.flatMap(bridgeInput.awaitRead(), () => Effect.suspend(() => {
const state = inputExecutor.run();
switch (state._tag) {
case ChannelStateOpCodes.OP_DONE:
{
return Exit.match(inputExecutor.getDone(), {
onFailure: cause => bridgeInput.error(cause),
onSuccess: value => bridgeInput.done(value)
});
}
case ChannelStateOpCodes.OP_EMIT:
{
return Effect.flatMap(bridgeInput.emit(inputExecutor.getEmit()), () => drainer());
}
case ChannelStateOpCodes.OP_FROM_EFFECT:
{
return Effect.matchCauseEffect(state.effect, {
onFailure: cause => bridgeInput.error(cause),
onSuccess: () => drainer()
});
}
case ChannelStateOpCodes.OP_READ:
{
return readUpstream(state, () => drainer(), cause => bridgeInput.error(cause));
}
}
}));
result = ChannelState.fromEffect(Effect.flatMap(Effect.forkDaemon(Effect.interruptible(drainer())), fiber => Effect.sync(() => this.addFinalizer(exit => Effect.flatMap(Fiber.interrupt(fiber), () => Effect.suspend(() => {
const effect = this.restorePipe(exit, inputExecutor);
return effect !== undefined ? effect : Effect.void;
}))))));
}
break;
}
case ChannelOpCodes.OP_CONCAT_ALL:
{
const executor = new ChannelExecutor(this._currentChannel.value(), this._providedEnv, effect => Effect.sync(() => {
const prevLastClose = this._closeLastSubstream === undefined ? Effect.void : this._closeLastSubstream;
this._closeLastSubstream = (0, _Function.pipe)(prevLastClose, Effect.zipRight(effect));
}));
executor._input = this._input;
const channel = this._currentChannel;
this._activeSubexecutor = new Subexecutor.PullFromUpstream(executor, value => channel.k(value), undefined, [], (x, y) => channel.combineInners(x, y), (x, y) => channel.combineAll(x, y), request => channel.onPull(request), value => channel.onEmit(value));
this._closeLastSubstream = undefined;
this._currentChannel = undefined;
break;
}
case ChannelOpCodes.OP_EMIT:
{
this._emitted = this._currentChannel.out;
this._currentChannel = this._activeSubexecutor !== undefined ? undefined : core.void;
result = ChannelState.Emit();
break;
}
case ChannelOpCodes.OP_ENSURING:
{
this.runEnsuring(this._currentChannel);
break;
}
case ChannelOpCodes.OP_FAIL:
{
result = this.doneHalt(this._currentChannel.error());
break;
}
case ChannelOpCodes.OP_FOLD:
{
this._doneStack.push(this._currentChannel.k);
this._currentChannel = this._currentChannel.channel;
break;
}
case ChannelOpCodes.OP_FROM_EFFECT:
{
const effect = this._providedEnv === undefined ? this._currentChannel.effect() : (0, _Function.pipe)(this._currentChannel.effect(), Effect.provide(this._providedEnv));
result = ChannelState.fromEffect(Effect.matchCauseEffect(effect, {
onFailure: cause => {
const state = this.doneHalt(cause);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.void;
},
onSuccess: value => {
const state = this.doneSucceed(value);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.void;
}
}));
break;
}
case ChannelOpCodes.OP_PIPE_TO:
{
const previousInput = this._input;
const leftExec = new ChannelExecutor(this._currentChannel.left(), this._providedEnv, effect => this._executeCloseLastSubstream(effect));
leftExec._input = previousInput;
this._input = leftExec;
this.addFinalizer(exit => {
const effect = this.restorePipe(exit, previousInput);
return effect !== undefined ? effect : Effect.void;
});
this._currentChannel = this._currentChannel.right();
break;
}
case ChannelOpCodes.OP_PROVIDE:
{
const previousEnv = this._providedEnv;
this._providedEnv = this._currentChannel.context();
this._currentChannel = this._currentChannel.inner;
this.addFinalizer(() => Effect.sync(() => {
this._providedEnv = previousEnv;
}));
break;
}
case ChannelOpCodes.OP_READ:
{
const read = this._currentChannel;
result = ChannelState.Read(this._input, _Function.identity, emitted => {
try {
this._currentChannel = read.more(emitted);
} catch (error) {
this._currentChannel = read.done.onExit(Exit.die(error));
}
return undefined;
}, exit => {
const onExit = exit => {
return read.done.onExit(exit);
};
this._currentChannel = onExit(exit);
return undefined;
});
break;
}
case ChannelOpCodes.OP_SUCCEED:
{
result = this.doneSucceed(this._currentChannel.evaluate());
break;
}
case ChannelOpCodes.OP_SUCCEED_NOW:
{
result = this.doneSucceed(this._currentChannel.terminal);
break;
}
case ChannelOpCodes.OP_SUSPEND:
{
this._currentChannel = this._currentChannel.channel();
break;
}
}
}
} catch (error) {
this._currentChannel = core.failCause(Cause.die(error));
}
}
}
return result;
}
getDone() {
return this._done;
}
getEmit() {
return this._emitted;
}
cancelWith(exit) {
this._cancelled = exit;
}
clearInProgressFinalizer() {
this._inProgressFinalizer = undefined;
}
storeInProgressFinalizer(finalizer) {
this._inProgressFinalizer = finalizer;
}
popAllFinalizers(exit) {
const finalizers = [];
let next = this._doneStack.pop();
while (next) {
if (next._tag === "ContinuationFinalizer") {
finalizers.push(next.finalizer);
}
next = this._doneStack.pop();
}
const effect = finalizers.length === 0 ? Effect.void : runFinalizers(finalizers, exit);
this.storeInProgressFinalizer(effect);
return effect;
}
popNextFinalizers() {
const builder = [];
while (this._doneStack.length !== 0) {
const cont = this._doneStack[this._doneStack.length - 1];
if (cont._tag === ContinuationOpCodes.OP_CONTINUATION_K) {
return builder;
}
builder.push(cont);
this._doneStack.pop();
}
return builder;
}
restorePipe(exit, prev) {
const currInput = this._input;
this._input = prev;
if (currInput !== undefined) {
const effect = currInput.close(exit);
return effect;
}
return Effect.void;
}
close(exit) {
let runInProgressFinalizers = undefined;
const finalizer = this._inProgressFinalizer;
if (finalizer !== undefined) {
runInProgressFinalizers = (0, _Function.pipe)(finalizer, Effect.ensuring(Effect.sync(() => this.clearInProgressFinalizer())));
}
let closeSelf = undefined;
const selfFinalizers = this.popAllFinalizers(exit);
if (selfFinalizers !== undefined) {
closeSelf = (0, _Function.pipe)(selfFinalizers, Effect.ensuring(Effect.sync(() => this.clearInProgressFinalizer())));
}
const closeSubexecutors = this._activeSubexecutor === undefined ? undefined : this._activeSubexecutor.close(exit);
if (closeSubexecutors === undefined && runInProgressFinalizers === undefined && closeSelf === undefined) {
return undefined;
}
return (0, _Function.pipe)(Effect.exit(ifNotNull(closeSubexecutors)), Effect.zip(Effect.exit(ifNotNull(runInProgressFinalizers))), Effect.zip(Effect.exit(ifNotNull(closeSelf))), Effect.map(([[exit1, exit2], exit3]) => (0, _Function.pipe)(exit1, Exit.zipRight(exit2), Exit.zipRight(exit3))), Effect.uninterruptible,
// TODO: remove
Effect.flatMap(exit => Effect.suspend(() => exit)));
}
doneSucceed(value) {
if (this._doneStack.length === 0) {
this._done = Exit.succeed(value);
this._currentChannel = undefined;
return ChannelState.Done();
}
const head = this._doneStack[this._doneStack.length - 1];
if (head._tag === ContinuationOpCodes.OP_CONTINUATION_K) {
this._doneStack.pop();
this._currentChannel = head.onSuccess(value);
return undefined;
}
const finalizers = this.popNextFinalizers();
if (this._doneStack.length === 0) {
this._doneStack = finalizers.reverse();
this._done = Exit.succeed(value);
this._currentChannel = undefined;
return ChannelState.Done();
}
const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), Exit.succeed(value));
this.storeInProgressFinalizer(finalizerEffect);
const effect = (0, _Function.pipe)(finalizerEffect, Effect.ensuring(Effect.sync(() => this.clearInProgressFinalizer())), Effect.uninterruptible, Effect.flatMap(() => Effect.sync(() => this.doneSucceed(value))));
return ChannelState.fromEffect(effect);
}
doneHalt(cause) {
if (this._doneStack.length === 0) {
this._done = Exit.failCause(cause);
this._currentChannel = undefined;
return ChannelState.Done();
}
const head = this._doneStack[this._doneStack.length - 1];
if (head._tag === ContinuationOpCodes.OP_CONTINUATION_K) {
this._doneStack.pop();
try {
this._currentChannel = head.onHalt(cause);
} catch (error) {
this._currentChannel = core.failCause(Cause.die(error));
}
return undefined;
}
const finalizers = this.popNextFinalizers();
if (this._doneStack.length === 0) {
this._doneStack = finalizers.reverse();
this._done = Exit.failCause(cause);
this._currentChannel = undefined;
return ChannelState.Done();
}
const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), Exit.failCause(cause));
this.storeInProgressFinalizer(finalizerEffect);
const effect = (0, _Function.pipe)(finalizerEffect, Effect.ensuring(Effect.sync(() => this.clearInProgressFinalizer())), Effect.uninterruptible, Effect.flatMap(() => Effect.sync(() => this.doneHalt(cause))));
return ChannelState.fromEffect(effect);
}
processCancellation() {
this._currentChannel = undefined;
this._done = this._cancelled;
this._cancelled = undefined;
return ChannelState.Done();
}
runBracketOut(bracketOut) {
const effect = Effect.uninterruptible(Effect.matchCauseEffect(this.provide(bracketOut.acquire()), {
onFailure: cause => Effect.sync(() => {
this._currentChannel = core.failCause(cause);
}),
onSuccess: out => Effect.sync(() => {
this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
this._currentChannel = core.write(out);
})
}));
return ChannelState.fromEffect(effect);
}
provide(effect) {
if (this._providedEnv === undefined) {
return effect;
}
return (0, _Function.pipe)(effect, Effect.provide(this._providedEnv));
}
runEnsuring(ensuring) {
this.addFinalizer(ensuring.finalizer);
this._currentChannel = ensuring.channel;
}
addFinalizer(f) {
this._doneStack.push(new Continuation.ContinuationFinalizerImpl(f));
}
runSubexecutor() {
const subexecutor = this._activeSubexecutor;
switch (subexecutor._tag) {
case Subexecutor.OP_PULL_FROM_CHILD:
{
return this.pullFromChild(subexecutor.childExecutor, subexecutor.parentSubexecutor, subexecutor.onEmit, subexecutor);
}
case Subexecutor.OP_PULL_FROM_UPSTREAM:
{
return this.pullFromUpstream(subexecutor);
}
case Subexecutor.OP_DRAIN_CHILD_EXECUTORS:
{
return this.drainChildExecutors(subexecutor);
}
case Subexecutor.OP_EMIT:
{
this._emitted = subexecutor.value;
this._activeSubexecutor = subexecutor.next;
return ChannelState.Emit();
}
}
}
replaceSubexecutor(nextSubExec) {
this._currentChannel = undefined;
this._activeSubexecutor = nextSubExec;
}
finishWithExit(exit) {
const state = Exit.match(exit, {
onFailure: cause => this.doneHalt(cause),
onSuccess: value => this.doneSucceed(value)
});
this._activeSubexecutor = undefined;
return state === undefined ? Effect.void : ChannelState.effect(state);
}
finishSubexecutorWithCloseEffect(subexecutorDone, ...closeFuncs) {
this.addFinalizer(() => (0, _Function.pipe)(closeFuncs, Effect.forEach(closeFunc => (0, _Function.pipe)(Effect.sync(() => closeFunc(subexecutorDone)), Effect.flatMap(closeEffect => closeEffect !== undefined ? closeEffect : Effect.void)), {
discard: true
})));
const state = (0, _Function.pipe)(subexecutorDone, Exit.match({
onFailure: cause => this.doneHalt(cause),
onSuccess: value => this.doneSucceed(value)
}));
this._activeSubexecutor = undefined;
return state;
}
applyUpstreamPullStrategy(upstreamFinished, queue, strategy) {
switch (strategy._tag) {
case UpstreamPullStrategyOpCodes.OP_PULL_AFTER_NEXT:
{
const shouldPrepend = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
return [strategy.emitSeparator, shouldPrepend ? [undefined, ...queue] : queue];
}
case UpstreamPullStrategyOpCodes.OP_PULL_AFTER_ALL_ENQUEUED:
{
const shouldEnqueue = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
return [strategy.emitSeparator, shouldEnqueue ? [...queue, undefined] : queue];
}
}
}
pullFromChild(childExecutor, parentSubexecutor, onEmitted, subexecutor) {
return ChannelState.Read(childExecutor, _Function.identity, emitted => {
const childExecutorDecision = onEmitted(emitted);
switch (childExecutorDecision._tag) {
case ChildExecutorDecisionOpCodes.OP_CONTINUE:
{
break;
}
case ChildExecutorDecisionOpCodes.OP_CLOSE:
{
this.finishWithDoneValue(childExecutor, parentSubexecutor, childExecutorDecision.value);
break;
}
case ChildExecutorDecisionOpCodes.OP_YIELD:
{
const modifiedParent = parentSubexecutor.enqueuePullFromChild(subexecutor);
this.replaceSubexecutor(modifiedParent);
break;
}
}
this._activeSubexecutor = new Subexecutor.Emit(emitted, this._activeSubexecutor);
return undefined;
}, Exit.match({
onFailure: cause => {
const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
return state === undefined ? undefined : ChannelState.effectOrUndefinedIgnored(state);
},
onSuccess: doneValue => {
this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
return undefined;
}
}));
}
finishWithDoneValue(childExecutor, parentSubexecutor, doneValue) {
const subexecutor = parentSubexecutor;
switch (subexecutor._tag) {
case Subexecutor.OP_PULL_FROM_UPSTREAM:
{
const modifiedParent = new Subexecutor.PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
this._closeLastSubstream = childExecutor.close(Exit.succeed(doneValue));
this.replaceSubexecutor(modifiedParent);
break;
}
case Subexecutor.OP_DRAIN_CHILD_EXECUTORS:
{
const modifiedParent = new Subexecutor.DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
this._closeLastSubstream = childExecutor.close(Exit.succeed(doneValue));
this.replaceSubexecutor(modifiedParent);
break;
}
default:
{
break;
}
}
}
handleSubexecutorFailure(childExecutor, parentSubexecutor, cause) {
return this.finishSubexecutorWithCloseEffect(Exit.failCause(cause), exit => parentSubexecutor.close(exit), exit => childExecutor.close(exit));
}
pullFromUpstream(subexecutor) {
if (subexecutor.activeChildExecutors.length === 0) {
return this.performPullFromUpstream(subexecutor);
}
const activeChild = subexecutor.activeChildExecutors[0];
const parentSubexecutor = new Subexecutor.PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, subexecutor.activeChildExecutors.slice(1), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
if (activeChild === undefined) {
return this.performPullFromUpstream(parentSubexecutor);
}
this.replaceSubexecutor(new Subexecutor.PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
return undefined;
}
performPullFromUpstream(subexecutor) {
return ChannelState.Read(subexecutor.upstreamExecutor, effect => {
const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.void : this._closeLastSubstream;
this._closeLastSubstream = undefined;
return (0, _Function.pipe)(this._executeCloseLastSubstream(closeLastSubstream), Effect.zipRight(effect));
}, emitted => {
if (this._closeLastSubstream !== undefined) {
const closeLastSubstream = this._closeLastSubstream;
this._closeLastSubstream = undefined;
return (0, _Function.pipe)(this._executeCloseLastSubstream(closeLastSubstream), Effect.map(() => {
const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
childExecutor._input = this._input;
const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(upstreamPullRequest.Pulled(emitted)));
this._activeSubexecutor = new Subexecutor.PullFromChild(childExecutor, new Subexecutor.PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
if (Option.isSome(emitSeparator)) {
this._activeSubexecutor = new Subexecutor.Emit(emitSeparator.value, this._activeSubexecutor);
}
return undefined;
}));
}
const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
childExecutor._input = this._input;
const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(upstreamPullRequest.Pulled(emitted)));
this._activeSubexecutor = new Subexecutor.PullFromChild(childExecutor, new Subexecutor.PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
if (Option.isSome(emitSeparator)) {
this._activeSubexecutor = new Subexecutor.Emit(emitSeparator.value, this._activeSubexecutor);
}
return undefined;
}, exit => {
if (subexecutor.activeChildExecutors.some(subexecutor => subexecutor !== undefined)) {
const drain = new Subexecutor.DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, [undefined, ...subexecutor.activeChildExecutors], subexecutor.upstreamExecutor.getDone(), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
if (this._closeLastSubstream !== undefined) {
const closeLastSubstream = this._closeLastSubstream;
this._closeLastSubstream = undefined;
return (0, _Function.pipe)(this._executeCloseLastSubstream(closeLastSubstream), Effect.map(() => this.replaceSubexecutor(drain)));
}
this.replaceSubexecutor(drain);
return undefined;
}
const closeLastSubstream = this._closeLastSubstream;
const state = this.finishSubexecutorWithCloseEffect((0, _Function.pipe)(exit, Exit.map(a => subexecutor.combineWithChildResult(subexecutor.lastDone, a))), () => closeLastSubstream, exit => subexecutor.upstreamExecutor.close(exit));
return state === undefined ? undefined :
// NOTE: assuming finalizers cannot fail
ChannelState.effectOrUndefinedIgnored(state);
});
}
drainChildExecutors(subexecutor) {
if (subexecutor.activeChildExecutors.length === 0) {
const lastClose = this._closeLastSubstream;
if (lastClose !== undefined) {
this.addFinalizer(() => Effect.succeed(lastClose));
}
return this.finishSubexecutorWithCloseEffect(subexecutor.upstreamDone, () => lastClose, exit => subexecutor.upstreamExecutor.close(exit));
}
const activeChild = subexecutor.activeChildExecutors[0];
const rest = subexecutor.activeChildExecutors.slice(1);
if (activeChild === undefined) {
const [emitSeparator, remainingExecutors] = this.applyUpstreamPullStrategy(true, rest, subexecutor.onPull(upstreamPullRequest.NoUpstream(rest.reduce((n, curr) => curr !== undefined ? n + 1 : n, 0))));
this.replaceSubexecutor(new Subexecutor.DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, remainingExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull));
if (Option.isSome(emitSeparator)) {
this._emitted = emitSeparator.value;
return ChannelState.Emit();
}
return undefined;
}
const parentSubexecutor = new Subexecutor.DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, rest, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
this.replaceSubexecutor(new Subexecutor.PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
return undefined;
}
}
exports.ChannelExecutor = ChannelExecutor;
const ifNotNull = effect => effect !== undefined ? effect : Effect.void;
const runFinalizers = (finalizers, exit) => {
return (0, _Function.pipe)(Effect.forEach(finalizers, fin => Effect.exit(fin(exit))), Effect.map(exits => (0, _Function.pipe)(Exit.all(exits), Option.getOrElse(() => Exit.void))), Effect.flatMap(exit => Effect.suspend(() => exit)));
};
/**
* @internal
*/
const readUpstream = (r, onSuccess, onFailure) => {
const readStack = [r];
const read = () => {
const current = readStack.pop();
if (current === undefined || current.upstream === undefined) {
return Effect.dieMessage("Unexpected end of input for channel execution");
}
const state = current.upstream.run();
switch (state._tag) {
case ChannelStateOpCodes.OP_EMIT:
{
const emitEffect = current.onEmit(current.upstream.getEmit());
if (readStack.length === 0) {
if (emitEffect === undefined) {
return Effect.suspend(onSuccess);
}
return (0, _Function.pipe)(emitEffect, Effect.matchCauseEffect({
onFailure,
onSuccess
}));
}
if (emitEffect === undefined) {
return Effect.suspend(() => read());
}
return (0, _Function.pipe)(emitEffect, Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
}));
}
case ChannelStateOpCodes.OP_DONE:
{
const doneEffect = current.onDone(current.upstream.getDone());
if (readStack.length === 0) {
if (doneEffect === undefined) {
return Effect.suspend(onSuccess);
}
return (0, _Function.pipe)(doneEffect, Effect.matchCauseEffect({
onFailure,
onSuccess
}));
}
if (doneEffect === undefined) {
return Effect.suspend(() => read());
}
return (0, _Function.pipe)(doneEffect, Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
}));
}
case ChannelStateOpCodes.OP_FROM_EFFECT:
{
readStack.push(current);
return (0, _Function.pipe)(current.onEffect(state.effect), Effect.catchAllCause(cause => Effect.suspend(() => {
const doneEffect = current.onDone(Exit.failCause(cause));
return doneEffect === undefined ? Effect.void : doneEffect;
})), Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
}));
}
case ChannelStateOpCodes.OP_READ:
{
readStack.push(current);
readStack.push(state);
return Effect.suspend(() => read());
}
}
};
return read();
};
/** @internal */
exports.readUpstream = readUpstream;
const runIn = exports.runIn = /*#__PURE__*/(0, _Function.dual)(2, (self, scope) => {
const run = (channelDeferred, scopeDeferred, scope) => Effect.acquireUseRelease(Effect.sync(() => new ChannelExecutor(self, void 0, _Function.identity)), exec => Effect.suspend(() => runScopedInterpret(exec.run(), exec).pipe(Effect.intoDeferred(channelDeferred), Effect.zipRight(Deferred.await(channelDeferred)), Effect.zipLeft(Deferred.await(scopeDeferred)))), (exec, exit) => {
const finalize = exec.close(exit);
if (finalize === undefined) {
return Effect.void;
}
return Effect.tapErrorCause(finalize, cause => Scope.addFinalizer(scope, Effect.failCause(cause)));
});
return Effect.uninterruptibleMask(restore => Effect.all([Scope.fork(scope, ExecutionStrategy.sequential), Deferred.make(), Deferred.make()]).pipe(Effect.flatMap(([child, channelDeferred, scopeDeferred]) => restore(run(channelDeferred, scopeDeferred, child)).pipe(Effect.forkIn(scope), Effect.flatMap(fiber => scope.addFinalizer(exit => {
const interruptors = Exit.isFailure(exit) ? Cause.interruptors(exit.cause) : undefined;
return Deferred.isDone(channelDeferred).pipe(Effect.flatMap(isDone => isDone ? Deferred.succeed(scopeDeferred, void 0).pipe(Effect.zipRight(Fiber.await(fiber)), Effect.zipRight(Fiber.inheritAll(fiber))) : Deferred.succeed(scopeDeferred, void 0).pipe(Effect.zipRight(interruptors && HashSet.size(interruptors) > 0 ? Fiber.interruptAs(fiber, FiberId.combineAll(interruptors)) : Fiber.interrupt(fiber)), Effect.zipRight(Fiber.inheritAll(fiber)))));
}).pipe(Effect.zipRight(restore(Deferred.await(channelDeferred)))))))));
});
/** @internal */
const runScopedInterpret = (channelState, exec) => {
const op = channelState;
switch (op._tag) {
case ChannelStateOpCodes.OP_FROM_EFFECT:
{
return (0, _Function.pipe)(op.effect, Effect.flatMap(() => runScopedInterpret(exec.run(), exec)));
}
case ChannelStateOpCodes.OP_EMIT:
{
// Can't really happen because Out <:< Nothing. So just skip ahead.
return runScopedInterpret(exec.run(), exec);
}
case ChannelStateOpCodes.OP_DONE:
{
return Effect.suspend(() => exec.getDone());
}
case ChannelStateOpCodes.OP_READ:
{
return readUpstream(op, () => runScopedInterpret(exec.run(), exec), Effect.failCause);
}
}
};
//# sourceMappingURL=channelExecutor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isRead = exports.isFromEffect = exports.isEmit = exports.isDone = exports.isChannelState = exports.fromEffect = exports.effectOrUndefinedIgnored = exports.effect = exports.Read = exports.Emit = exports.Done = exports.ChannelStateTypeId = void 0;
var Effect = _interopRequireWildcard(require("../../Effect.js"));
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelState.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ChannelStateTypeId = exports.ChannelStateTypeId = /*#__PURE__*/Symbol.for("effect/ChannelState");
const channelStateVariance = {
/* c8 ignore next */
_E: _ => _,
/* c8 ignore next */
_R: _ => _
};
/** @internal */
const proto = {
[ChannelStateTypeId]: channelStateVariance
};
/** @internal */
const Done = () => {
const op = Object.create(proto);
op._tag = OpCodes.OP_DONE;
return op;
};
/** @internal */
exports.Done = Done;
const Emit = () => {
const op = Object.create(proto);
op._tag = OpCodes.OP_EMIT;
return op;
};
/** @internal */
exports.Emit = Emit;
const fromEffect = effect => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FROM_EFFECT;
op.effect = effect;
return op;
};
/** @internal */
exports.fromEffect = fromEffect;
const Read = (upstream, onEffect, onEmit, onDone) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_READ;
op.upstream = upstream;
op.onEffect = onEffect;
op.onEmit = onEmit;
op.onDone = onDone;
return op;
};
/** @internal */
exports.Read = Read;
const isChannelState = u => (0, _Predicate.hasProperty)(u, ChannelStateTypeId);
/** @internal */
exports.isChannelState = isChannelState;
const isDone = self => self._tag === OpCodes.OP_DONE;
/** @internal */
exports.isDone = isDone;
const isEmit = self => self._tag === OpCodes.OP_EMIT;
/** @internal */
exports.isEmit = isEmit;
const isFromEffect = self => self._tag === OpCodes.OP_FROM_EFFECT;
/** @internal */
exports.isFromEffect = isFromEffect;
const isRead = self => self._tag === OpCodes.OP_READ;
/** @internal */
exports.isRead = isRead;
const effect = self => isFromEffect(self) ? self.effect : Effect.void;
/** @internal */
exports.effect = effect;
const effectOrUndefinedIgnored = self => isFromEffect(self) ? Effect.ignore(self.effect) : undefined;
exports.effectOrUndefinedIgnored = effectOrUndefinedIgnored;
//# sourceMappingURL=channelState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"channelState.js","names":["Effect","_interopRequireWildcard","require","_Predicate","OpCodes","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ChannelStateTypeId","exports","Symbol","for","channelStateVariance","_E","_","_R","proto","Done","op","create","_tag","OP_DONE","Emit","OP_EMIT","fromEffect","effect","OP_FROM_EFFECT","Read","upstream","onEffect","onEmit","onDone","OP_READ","isChannelState","u","hasProperty","isDone","self","isEmit","isFromEffect","isRead","void","effectOrUndefinedIgnored","ignore","undefined"],"sources":["../../../../src/internal/channel/channelState.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAH,uBAAA,CAAAC,OAAA;AAAqD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAA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AA,GAAAA,MAAA;AACO,MAAMC,YAAY,GAAUF,IAAwB,IACxDA,IAAkB,CAACjB,IAAI,KAAKhC,OAAO,CAACsC,cAAc;AAErD;AAAAjB,OAAA,CAAA8B,YAAA,GAAAA,YAAA;AACO,MAAMC,MAAM,GAAUH,IAAwB,IAAoBA,IAAkB,CAACjB,IAAI,KAAKhC,OAAO,CAAC4C,OAAO;AAEpH;AAAAvB,OAAA,CAAA+B,MAAA,GAAAA,MAAA;AACO,MAAMf,MAAM,GAAUY,IAAwB,IACnDE,YAAY,CAACF,IAAI,CAAC,GAAGA,IAAI,CAACZ,MAAmC,GAAGzC,MAAM,CAACyD,IAAI;AAE7E;AAAAhC,OAAA,CAAAgB,MAAA,GAAAA,MAAA;AACO,MAAMiB,wBAAwB,GAAUL,IAAwB,IACrEE,YAAY,CAACF,IAAI,CAAC,GAAGrD,MAAM,CAAC2D,MAAM,CAACN,IAAI,CAACZ,MAAmC,CAAC,GAAGmB,SAAS;AAAAnC,OAAA,CAAAiC,wBAAA,GAAAA,wBAAA","ignoreList":[]}

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isYield = exports.isContinue = exports.isClose = exports.isChildExecutorDecision = exports.Yield = exports.Continue = exports.Close = exports.ChildExecutorDecisionTypeId = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelChildExecutorDecision.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ChildExecutorDecisionSymbolKey = "effect/ChannelChildExecutorDecision";
/** @internal */
const ChildExecutorDecisionTypeId = exports.ChildExecutorDecisionTypeId = /*#__PURE__*/Symbol.for(ChildExecutorDecisionSymbolKey);
/** @internal */
const proto = {
[ChildExecutorDecisionTypeId]: ChildExecutorDecisionTypeId
};
/** @internal */
const Continue = _ => {
const op = Object.create(proto);
op._tag = OpCodes.OP_CONTINUE;
return op;
};
/** @internal */
exports.Continue = Continue;
const Close = value => {
const op = Object.create(proto);
op._tag = OpCodes.OP_CLOSE;
op.value = value;
return op;
};
/** @internal */
exports.Close = Close;
const Yield = _ => {
const op = Object.create(proto);
op._tag = OpCodes.OP_YIELD;
return op;
};
/** @internal */
exports.Yield = Yield;
const isChildExecutorDecision = u => (0, _Predicate.hasProperty)(u, ChildExecutorDecisionTypeId);
/** @internal */
exports.isChildExecutorDecision = isChildExecutorDecision;
const isContinue = self => self._tag === OpCodes.OP_CONTINUE;
/** @internal */
exports.isContinue = isContinue;
const isClose = self => self._tag === OpCodes.OP_CLOSE;
/** @internal */
exports.isClose = isClose;
const isYield = self => self._tag === OpCodes.OP_YIELD;
/** @internal */
exports.isYield = isYield;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onClose,
onContinue,
onYield
}) => {
switch (self._tag) {
case OpCodes.OP_CONTINUE:
{
return onContinue();
}
case OpCodes.OP_CLOSE:
{
return onClose(self.value);
}
case OpCodes.OP_YIELD:
{
return onYield();
}
}
});
//# sourceMappingURL=childExecutorDecision.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"childExecutorDecision.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ChildExecutorDecisionSymbolKey","ChildExecutorDecisionTypeId","exports","Symbol","for","proto","Continue","_","op","create","_tag","OP_CONTINUE","Close","value","OP_CLOSE","Yield","OP_YIELD","isChildExecutorDecision","u","hasProperty","isContinue","self","isClose","isYield","match","dual","onClose","onContinue","onYield"],"sources":["../../../../src/internal/channel/childExecutorDecision.ts"],"sourcesContent":[null],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAqE,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAErE;A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OAAO,GAClBD,IAAiD,IACTA,IAAI,CAACX,IAAI,KAAK/B,OAAO,CAACmC,QAAQ;AAExE;AAAAZ,OAAA,CAAAoB,OAAA,GAAAA,OAAA;AACO,MAAMC,OAAO,GAClBF,IAAiD,IACTA,IAAI,CAACX,IAAI,KAAK/B,OAAO,CAACqC,QAAQ;AAExE;AAAAd,OAAA,CAAAqB,OAAA,GAAAA,OAAA;AACO,MAAMC,KAAK,GAAAtB,OAAA,CAAAsB,KAAA,gBAAG,IAAAC,cAAI,EAgBvB,CAAC,EAAE,CACHJ,IAAiD,EACjD;EAAEK,OAAO;EAAEC,UAAU;EAAEC;AAAO,CAI7B,KACI;EACL,QAAQP,IAAI,CAACX,IAAI;IACf,KAAK/B,OAAO,CAACgC,WAAW;MAAE;QACxB,OAAOgB,UAAU,EAAE;MACrB;IACA,KAAKhD,OAAO,CAACmC,QAAQ;MAAE;QACrB,OAAOY,OAAO,CAACL,IAAI,CAACR,KAAK,CAAC;MAC5B;IACA,KAAKlC,OAAO,CAACqC,QAAQ;MAAE;QACrB,OAAOY,OAAO,EAAE;MAClB;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ContinuationTypeId = exports.ContinuationKImpl = exports.ContinuationFinalizerImpl = void 0;
var Exit = _interopRequireWildcard(require("../../Exit.js"));
var OpCodes = _interopRequireWildcard(require("../opCodes/continuation.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ContinuationTypeId = exports.ContinuationTypeId = /*#__PURE__*/Symbol.for("effect/ChannelContinuation");
const continuationVariance = {
/* c8 ignore next */
_Env: _ => _,
/* c8 ignore next */
_InErr: _ => _,
/* c8 ignore next */
_InElem: _ => _,
/* c8 ignore next */
_InDone: _ => _,
/* c8 ignore next */
_OutErr: _ => _,
/* c8 ignore next */
_OutDone: _ => _,
/* c8 ignore next */
_OutErr2: _ => _,
/* c8 ignore next */
_OutElem: _ => _,
/* c8 ignore next */
_OutDone2: _ => _
};
/** @internal */
class ContinuationKImpl {
onSuccess;
onHalt;
_tag = OpCodes.OP_CONTINUATION_K;
[ContinuationTypeId] = continuationVariance;
constructor(onSuccess, onHalt) {
this.onSuccess = onSuccess;
this.onHalt = onHalt;
}
onExit(exit) {
return Exit.isFailure(exit) ? this.onHalt(exit.cause) : this.onSuccess(exit.value);
}
}
/** @internal */
exports.ContinuationKImpl = ContinuationKImpl;
class ContinuationFinalizerImpl {
finalizer;
_tag = OpCodes.OP_CONTINUATION_FINALIZER;
[ContinuationTypeId] = continuationVariance;
constructor(finalizer) {
this.finalizer = finalizer;
}
}
exports.ContinuationFinalizerImpl = ContinuationFinalizerImpl;
//# sourceMappingURL=continuation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"continuation.js","names":["Exit","_interopRequireWildcard","require","OpCodes","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ContinuationTypeId","exports","Symbol","for","continuationVariance","_Env","_","_InErr","_InElem","_InDone","_OutErr","_OutDone","_OutErr2","_OutElem","_OutDone2","ContinuationKImpl","onSuccess","onHalt","_tag","OP_CONTINUATION_K","constructor","onExit","exit","isFailure","cause","value","ContinuationFinalizerImpl","finalizer","OP_CONTINUATION_FINALIZER"],"sources":["../../../../src/internal/channel/continuation.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,IA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,CAAU,IAAKA,CAAC;EACzB;EACAE,OAAO,EAAGF,CAAU,IAAKA,CAAC;EAC1B;EACAG,OAAO,EAAGH,CAAU,IAAKA,CAAC;EAC1B;EACAI,OAAO,EAAGJ,CAAQ,IAAKA,CAAC;EACxB;EACAK,QAAQ,EAAGL,CAAQ,IAAKA,CAAC;EACzB;EACAM,QAAQ,EAAGN,CAAQ,IAAKA,CAAC;EACzB;EACAO,QAAQ,EAAGP,CAAQ,IAAKA,CAAC;EACzB;EACAQ,SAAS,EAAGR,CAAQ,IAAKA;CAC1B;AAED;AACM,MAAOS,iBAAiB;EA2BjBC,SAAA;EAGAC,MAAA;EANFC,IAAI,GAAGtC,OAAO,CAACuC,iBAAiB;EAChC,CAACnB,kBAAkB,IAAII,oBAAoB;EACpDgB,YACWJ,SAEmE,EACnEC,MAEoE;IALpE,KAAAD,SAAS,GAATA,SAAS;IAGT,KAAAC,MAAM,GAANA,MAAM;EAIjB;EACAI,MAAMA,CACJC,IAAgC;IAEhC,OAAO7C,IAAI,CAAC8C,SAAS,CAACD,IAAI,CAAC,GAAG,IAAI,CAACL,MAAM,CAACK,IAAI,CAACE,KAAK,CAAC,GAAG,IAAI,CAACR,SAAS,CAACM,IAAI,CAACG,KAAK,CAAC;EACpF;;AAGF;AAAAxB,OAAA,CAAAc,iBAAA,GAAAA,iBAAA;AACM,MAAOW,yBAAyB;EAKfC,SAAA;EAFZT,IAAI,GAAGtC,OAAO,CAACgD,yBAAyB;EACxC,CAAC5B,kBAAkB,IAAII,oBAAoB;EACpDgB,YAAqBO,SAAmF;IAAnF,KAAAA,SAAS,GAATA,SAAS;EAC9B","ignoreList":[]}

View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isMergeDecision = exports.MergeDecisionTypeId = exports.Done = exports.AwaitConst = exports.Await = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelMergeDecision.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const MergeDecisionSymbolKey = "effect/ChannelMergeDecision";
/** @internal */
const MergeDecisionTypeId = exports.MergeDecisionTypeId = /*#__PURE__*/Symbol.for(MergeDecisionSymbolKey);
/** @internal */
const proto = {
[MergeDecisionTypeId]: {
_R: _ => _,
_E0: _ => _,
_Z0: _ => _,
_E: _ => _,
_Z: _ => _
}
};
/** @internal */
const Done = effect => {
const op = Object.create(proto);
op._tag = OpCodes.OP_DONE;
op.effect = effect;
return op;
};
/** @internal */
exports.Done = Done;
const Await = f => {
const op = Object.create(proto);
op._tag = OpCodes.OP_AWAIT;
op.f = f;
return op;
};
/** @internal */
exports.Await = Await;
const AwaitConst = effect => Await(() => effect);
/** @internal */
exports.AwaitConst = AwaitConst;
const isMergeDecision = u => (0, _Predicate.hasProperty)(u, MergeDecisionTypeId);
/** @internal */
exports.isMergeDecision = isMergeDecision;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onAwait,
onDone
}) => {
const op = self;
switch (op._tag) {
case OpCodes.OP_DONE:
return onDone(op.effect);
case OpCodes.OP_AWAIT:
return onAwait(op.f);
}
});
//# sourceMappingURL=mergeDecision.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mergeDecision.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MergeDecisionSymbolKey","MergeDecisionTypeId","exports","Symbol","for","proto","_R","_","_E0","_Z0","_E","_Z","Done","effect","op","create","_tag","OP_DONE","Await","OP_AWAIT","AwaitConst","isMergeDecision","u","hasProperty","match","dual","self","onAwait","onDone"],"sources":["../../../../src/internal/channel/mergeDecision.ts"],"sourcesContent":[null],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA6D,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD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AC;AAEvH;AAAAC,OAAA,CAAAmB,eAAA,GAAAA,eAAA;AACO,MAAMG,KAAK,GAAAtB,OAAA,CAAAsB,KAAA,gBAAG,IAAAC,cAAI,EAcvB,CAAC,EAAE,CACHC,IAAkD,EAClD;EAAEC,OAAO;EAAEC;AAAM,CAGhB,KACK;EACN,MAAMd,EAAE,GAAGY,IAAiB;EAC5B,QAAQZ,EAAE,CAACE,IAAI;IACb,KAAKrC,OAAO,CAACsC,OAAO;MAClB,OAAOW,MAAM,CAACd,EAAE,CAACD,MAAM,CAAC;IAC1B,KAAKlC,OAAO,CAACwC,QAAQ;MACnB,OAAOQ,OAAO,CAACb,EAAE,CAACzB,CAAC,CAAC;EACxB;AACF,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isRightDone = exports.isMergeState = exports.isLeftDone = exports.isBothRunning = exports.RightDone = exports.MergeStateTypeId = exports.LeftDone = exports.BothRunning = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelMergeState.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const MergeStateSymbolKey = "effect/ChannelMergeState";
/** @internal */
const MergeStateTypeId = exports.MergeStateTypeId = /*#__PURE__*/Symbol.for(MergeStateSymbolKey);
/** @internal */
const proto = {
[MergeStateTypeId]: MergeStateTypeId
};
/** @internal */
const BothRunning = (left, right) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_BOTH_RUNNING;
op.left = left;
op.right = right;
return op;
};
/** @internal */
exports.BothRunning = BothRunning;
const LeftDone = f => {
const op = Object.create(proto);
op._tag = OpCodes.OP_LEFT_DONE;
op.f = f;
return op;
};
/** @internal */
exports.LeftDone = LeftDone;
const RightDone = f => {
const op = Object.create(proto);
op._tag = OpCodes.OP_RIGHT_DONE;
op.f = f;
return op;
};
/** @internal */
exports.RightDone = RightDone;
const isMergeState = u => (0, _Predicate.hasProperty)(u, MergeStateTypeId);
/** @internal */
exports.isMergeState = isMergeState;
const isBothRunning = self => {
return self._tag === OpCodes.OP_BOTH_RUNNING;
};
/** @internal */
exports.isBothRunning = isBothRunning;
const isLeftDone = self => {
return self._tag === OpCodes.OP_LEFT_DONE;
};
/** @internal */
exports.isLeftDone = isLeftDone;
const isRightDone = self => {
return self._tag === OpCodes.OP_RIGHT_DONE;
};
/** @internal */
exports.isRightDone = isRightDone;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onBothRunning,
onLeftDone,
onRightDone
}) => {
switch (self._tag) {
case OpCodes.OP_BOTH_RUNNING:
{
return onBothRunning(self.left, self.right);
}
case OpCodes.OP_LEFT_DONE:
{
return onLeftDone(self.f);
}
case OpCodes.OP_RIGHT_DONE:
{
return onRightDone(self.f);
}
}
});
//# sourceMappingURL=mergeState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mergeState.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MergeStateSymbolKey","MergeStateTypeId","exports","Symbol","for","proto","BothRunning","left","right","op","create","_tag","OP_BOTH_RUNNING","LeftDone","OP_LEFT_DONE","RightDone","OP_RIGHT_DONE","isMergeState","u","hasProperty","isBothRunning","self","isLeftDone","isRightDone","match","dual","onBothRunning","onLeftDone","on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;AAAAV,OAAA,CAAAkB,aAAA,GAAAA,aAAA;AACO,MAAME,UAAU,GACrBD,IAA2E,IACI;EAC/E,OAAOA,IAAI,CAACV,IAAI,KAAKhC,OAAO,CAACmC,YAAY;AAC3C,CAAC;AAED;AAAAZ,OAAA,CAAAoB,UAAA,GAAAA,UAAA;AACO,MAAMC,WAAW,GACtBF,IAA2E,IACK;EAChF,OAAOA,IAAI,CAACV,IAAI,KAAKhC,OAAO,CAACqC,aAAa;AAC5C,CAAC;AAED;AAAAd,OAAA,CAAAqB,WAAA,GAAAA,WAAA;AACO,MAAMC,KAAK,GAAAtB,OAAA,CAAAsB,KAAA,gBAAG,IAAAC,cAAI,EAsBvB,CAAC,EAAE,CACHJ,IAAI,EACJ;EAAEK,aAAa;EAAEC,UAAU;EAAEC;AAAW,CAAE,KACxC;EACF,QAAQP,IAAI,CAACV,IAAI;IACf,KAAKhC,OAAO,CAACiC,eAAe;MAAE;QAC5B,OAAOc,aAAa,CAACL,IAAI,CAACd,IAAI,EAAEc,IAAI,CAACb,KAAK,CAAC;MAC7C;IACA,KAAK7B,OAAO,CAACmC,YAAY;MAAE;QACzB,OAAOa,UAAU,CAACN,IAAI,CAAChC,CAAC,CAAC;MAC3B;IACA,KAAKV,OAAO,CAACqC,aAAa;MAAE;QAC1B,OAAOY,WAAW,CAACP,IAAI,CAAChC,CAAC,CAAC;MAC5B;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isMergeStrategy = exports.isBufferSliding = exports.isBackPressure = exports.MergeStrategyTypeId = exports.BufferSliding = exports.BackPressure = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelMergeStrategy.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const MergeStrategySymbolKey = "effect/ChannelMergeStrategy";
/** @internal */
const MergeStrategyTypeId = exports.MergeStrategyTypeId = /*#__PURE__*/Symbol.for(MergeStrategySymbolKey);
/** @internal */
const proto = {
[MergeStrategyTypeId]: MergeStrategyTypeId
};
/** @internal */
const BackPressure = _ => {
const op = Object.create(proto);
op._tag = OpCodes.OP_BACK_PRESSURE;
return op;
};
/** @internal */
exports.BackPressure = BackPressure;
const BufferSliding = _ => {
const op = Object.create(proto);
op._tag = OpCodes.OP_BUFFER_SLIDING;
return op;
};
/** @internal */
exports.BufferSliding = BufferSliding;
const isMergeStrategy = u => (0, _Predicate.hasProperty)(u, MergeStrategyTypeId);
/** @internal */
exports.isMergeStrategy = isMergeStrategy;
const isBackPressure = self => self._tag === OpCodes.OP_BACK_PRESSURE;
/** @internal */
exports.isBackPressure = isBackPressure;
const isBufferSliding = self => self._tag === OpCodes.OP_BUFFER_SLIDING;
/** @internal */
exports.isBufferSliding = isBufferSliding;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onBackPressure,
onBufferSliding
}) => {
switch (self._tag) {
case OpCodes.OP_BACK_PRESSURE:
{
return onBackPressure();
}
case OpCodes.OP_BUFFER_SLIDING:
{
return onBufferSliding();
}
}
});
//# sourceMappingURL=mergeStrategy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mergeStrategy.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MergeStrategySymbolKey","MergeStrategyTypeId","exports","Symbol","for","proto","BackPressure","_","op","create","_tag","OP_BACK_PRESSURE","BufferSliding","OP_BUFFER_SLIDING","isMergeStrategy","u","hasProperty","isBackPressure","self","isBufferSliding","match","dual","onBackPressure","onBufferSliding"],"sources":["../../../../src/internal/channel/mergeStrategy.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA6D,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,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AC,EAAE,CACHH,IAAiC,EACjC;EAAEI,cAAc;EAAEC;AAAe,CAGhC,KACI;EACL,QAAQL,IAAI,CAACR,IAAI;IACf,KAAK/B,OAAO,CAACgC,gBAAgB;MAAE;QAC7B,OAAOW,cAAc,EAAE;MACzB;IACA,KAAK3C,OAAO,CAACkC,iBAAiB;MAAE;QAC9B,OAAOU,eAAe,EAAE;MAC1B;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,171 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.make = void 0;
var Cause = _interopRequireWildcard(require("../../Cause.js"));
var Deferred = _interopRequireWildcard(require("../../Deferred.js"));
var Effect = _interopRequireWildcard(require("../../Effect.js"));
var Either = _interopRequireWildcard(require("../../Either.js"));
var Exit = _interopRequireWildcard(require("../../Exit.js"));
var _Function = require("../../Function.js");
var Ref = _interopRequireWildcard(require("../../Ref.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const OP_STATE_EMPTY = "Empty";
/** @internal */
const OP_STATE_EMIT = "Emit";
/** @internal */
const OP_STATE_ERROR = "Error";
/** @internal */
const OP_STATE_DONE = "Done";
/** @internal */
const stateEmpty = notifyProducer => ({
_tag: OP_STATE_EMPTY,
notifyProducer
});
/** @internal */
const stateEmit = notifyConsumers => ({
_tag: OP_STATE_EMIT,
notifyConsumers
});
/** @internal */
const stateError = cause => ({
_tag: OP_STATE_ERROR,
cause
});
/** @internal */
const stateDone = done => ({
_tag: OP_STATE_DONE,
done
});
/** @internal */
class SingleProducerAsyncInputImpl {
ref;
constructor(ref) {
this.ref = ref;
}
awaitRead() {
return Effect.flatten(Ref.modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [Deferred.await(state.notifyProducer), state] : [Effect.void, state]));
}
get close() {
return Effect.fiberIdWith(fiberId => this.error(Cause.interrupt(fiberId)));
}
done(value) {
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEach(state.notifyConsumers, deferred => Deferred.succeed(deferred, Either.left(value)), {
discard: true
}), stateDone(value)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
}));
}
emit(element) {
return Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
const notifyConsumer = state.notifyConsumers[0];
const notifyConsumers = state.notifyConsumers.slice(1);
if (notifyConsumer !== undefined) {
return [Deferred.succeed(notifyConsumer, Either.right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
}
throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues");
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
})));
}
error(cause) {
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEach(state.notifyConsumers, deferred => Deferred.failCause(deferred, cause), {
discard: true
}), stateError(cause)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
}));
}
get take() {
return this.takeWith(cause => Exit.failCause(Cause.map(cause, Either.left)), elem => Exit.succeed(elem), done => Exit.fail(Either.right(done)));
}
takeWith(onError, onElement, onDone) {
return Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Effect.zipRight(Deferred.succeed(state.notifyProducer, void 0), Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({
onLeft: onDone,
onRight: onElement
})
})), stateEmit([deferred])];
}
case OP_STATE_EMIT:
{
return [Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({
onLeft: onDone,
onRight: onElement
})
}), stateEmit([...state.notifyConsumers, deferred])];
}
case OP_STATE_ERROR:
{
return [Effect.succeed(onError(state.cause)), state];
}
case OP_STATE_DONE:
{
return [Effect.succeed(onDone(state.done)), state];
}
}
})));
}
}
/** @internal */
const make = () => (0, _Function.pipe)(Deferred.make(), Effect.flatMap(deferred => Ref.make(stateEmpty(deferred))), Effect.map(ref => new SingleProducerAsyncInputImpl(ref)));
exports.make = make;
//# sourceMappingURL=singleProducerAsyncInput.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,163 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PullFromUpstream = exports.PullFromChild = exports.OP_PULL_FROM_UPSTREAM = exports.OP_PULL_FROM_CHILD = exports.OP_EMIT = exports.OP_DRAIN_CHILD_EXECUTORS = exports.Emit = exports.DrainChildExecutors = void 0;
var Effect = _interopRequireWildcard(require("../../Effect.js"));
var Exit = _interopRequireWildcard(require("../../Exit.js"));
var _Function = require("../../Function.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const OP_PULL_FROM_CHILD = exports.OP_PULL_FROM_CHILD = "PullFromChild";
/** @internal */
const OP_PULL_FROM_UPSTREAM = exports.OP_PULL_FROM_UPSTREAM = "PullFromUpstream";
/** @internal */
const OP_DRAIN_CHILD_EXECUTORS = exports.OP_DRAIN_CHILD_EXECUTORS = "DrainChildExecutors";
/** @internal */
const OP_EMIT = exports.OP_EMIT = "Emit";
/**
* Execute the `childExecutor` and on each emitted value, decide what to do by
* `onEmit`.
*
* @internal
*/
class PullFromChild {
childExecutor;
parentSubexecutor;
onEmit;
_tag = OP_PULL_FROM_CHILD;
constructor(childExecutor, parentSubexecutor, onEmit) {
this.childExecutor = childExecutor;
this.parentSubexecutor = parentSubexecutor;
this.onEmit = onEmit;
}
close(exit) {
const fin1 = this.childExecutor.close(exit);
const fin2 = this.parentSubexecutor.close(exit);
if (fin1 !== undefined && fin2 !== undefined) {
return Effect.zipWith(Effect.exit(fin1), Effect.exit(fin2), (exit1, exit2) => (0, _Function.pipe)(exit1, Exit.zipRight(exit2)));
} else if (fin1 !== undefined) {
return fin1;
} else if (fin2 !== undefined) {
return fin2;
} else {
return undefined;
}
}
enqueuePullFromChild(_child) {
return this;
}
}
/**
* Execute `upstreamExecutor` and for each emitted element, spawn a child
* channel and continue with processing it by `PullFromChild`.
*
* @internal
*/
exports.PullFromChild = PullFromChild;
class PullFromUpstream {
upstreamExecutor;
createChild;
lastDone;
activeChildExecutors;
combineChildResults;
combineWithChildResult;
onPull;
onEmit;
_tag = OP_PULL_FROM_UPSTREAM;
constructor(upstreamExecutor, createChild, lastDone, activeChildExecutors, combineChildResults, combineWithChildResult, onPull, onEmit) {
this.upstreamExecutor = upstreamExecutor;
this.createChild = createChild;
this.lastDone = lastDone;
this.activeChildExecutors = activeChildExecutors;
this.combineChildResults = combineChildResults;
this.combineWithChildResult = combineWithChildResult;
this.onPull = onPull;
this.onEmit = onEmit;
}
close(exit) {
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(acc, Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit1, exit2));
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result;
}
enqueuePullFromChild(child) {
return new PullFromUpstream(this.upstreamExecutor, this.createChild, this.lastDone, [...this.activeChildExecutors, child], this.combineChildResults, this.combineWithChildResult, this.onPull, this.onEmit);
}
}
/**
* Transformed from `PullFromUpstream` when upstream has finished but there
* are still active child executors.
*
* @internal
*/
exports.PullFromUpstream = PullFromUpstream;
class DrainChildExecutors {
upstreamExecutor;
lastDone;
activeChildExecutors;
upstreamDone;
combineChildResults;
combineWithChildResult;
onPull;
_tag = OP_DRAIN_CHILD_EXECUTORS;
constructor(upstreamExecutor, lastDone, activeChildExecutors, upstreamDone, combineChildResults, combineWithChildResult, onPull) {
this.upstreamExecutor = upstreamExecutor;
this.lastDone = lastDone;
this.activeChildExecutors = activeChildExecutors;
this.upstreamDone = upstreamDone;
this.combineChildResults = combineChildResults;
this.combineWithChildResult = combineWithChildResult;
this.onPull = onPull;
}
close(exit) {
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(acc, Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit1, exit2));
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result;
}
enqueuePullFromChild(child) {
return new DrainChildExecutors(this.upstreamExecutor, this.lastDone, [...this.activeChildExecutors, child], this.upstreamDone, this.combineChildResults, this.combineWithChildResult, this.onPull);
}
}
/** @internal */
exports.DrainChildExecutors = DrainChildExecutors;
class Emit {
value;
next;
_tag = OP_EMIT;
constructor(value, next) {
this.value = value;
this.next = next;
}
close(exit) {
const result = this.next.close(exit);
return result === undefined ? result : result;
}
enqueuePullFromChild(_child) {
return this;
}
}
exports.Emit = Emit;
//# sourceMappingURL=subexecutor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isUpstreamPullRequest = exports.isPulled = exports.isNoUpstream = exports.UpstreamPullRequestTypeId = exports.Pulled = exports.NoUpstream = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelUpstreamPullRequest.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const UpstreamPullRequestSymbolKey = "effect/ChannelUpstreamPullRequest";
/** @internal */
const UpstreamPullRequestTypeId = exports.UpstreamPullRequestTypeId = /*#__PURE__*/Symbol.for(UpstreamPullRequestSymbolKey);
const upstreamPullRequestVariance = {
/* c8 ignore next */
_A: _ => _
};
/** @internal */
const proto = {
[UpstreamPullRequestTypeId]: upstreamPullRequestVariance
};
/** @internal */
const Pulled = value => {
const op = Object.create(proto);
op._tag = OpCodes.OP_PULLED;
op.value = value;
return op;
};
/** @internal */
exports.Pulled = Pulled;
const NoUpstream = activeDownstreamCount => {
const op = Object.create(proto);
op._tag = OpCodes.OP_NO_UPSTREAM;
op.activeDownstreamCount = activeDownstreamCount;
return op;
};
/** @internal */
exports.NoUpstream = NoUpstream;
const isUpstreamPullRequest = u => (0, _Predicate.hasProperty)(u, UpstreamPullRequestTypeId);
/** @internal */
exports.isUpstreamPullRequest = isUpstreamPullRequest;
const isPulled = self => self._tag === OpCodes.OP_PULLED;
/** @internal */
exports.isPulled = isPulled;
const isNoUpstream = self => self._tag === OpCodes.OP_NO_UPSTREAM;
/** @internal */
exports.isNoUpstream = isNoUpstream;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onNoUpstream,
onPulled
}) => {
switch (self._tag) {
case OpCodes.OP_PULLED:
{
return onPulled(self.value);
}
case OpCodes.OP_NO_UPSTREAM:
{
return onNoUpstream(self.activeDownstreamCount);
}
}
});
//# sourceMappingURL=upstreamPullRequest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"upstreamPullRequest.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UpstreamPullRequestSymbolKey","UpstreamPullRequestTypeId","exports","Symbol","for","upstreamPullRequestVariance","_A","_","proto","Pulled","value","op","create","_tag","OP_PULLED","NoUpstream","activeDownstreamCount","OP_NO_UPSTREAM","isUpstreamPullRequest","u","hasProperty","isPulled","self","isNoUpstream","match","dual","onNoUpstream","onPulled"],"sources":["../../../../src/internal/channel/upstreamPullRequest.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAm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ACA,KAAK/B,OAAO,CAACsC,cAAc;MAAE;QAC3B,OAAOS,YAAY,CAACJ,IAAI,CAACN,qBAAqB,CAAC;MACjD;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.match = exports.isUpstreamPullStrategy = exports.isPullAfterNext = exports.isPullAfterAllEnqueued = exports.UpstreamPullStrategyTypeId = exports.PullAfterNext = exports.PullAfterAllEnqueued = void 0;
var _Function = require("../../Function.js");
var _Predicate = require("../../Predicate.js");
var OpCodes = _interopRequireWildcard(require("../opCodes/channelUpstreamPullStrategy.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const UpstreamPullStrategySymbolKey = "effect/ChannelUpstreamPullStrategy";
/** @internal */
const UpstreamPullStrategyTypeId = exports.UpstreamPullStrategyTypeId = /*#__PURE__*/Symbol.for(UpstreamPullStrategySymbolKey);
const upstreamPullStrategyVariance = {
/* c8 ignore next */
_A: _ => _
};
/** @internal */
const proto = {
[UpstreamPullStrategyTypeId]: upstreamPullStrategyVariance
};
/** @internal */
const PullAfterNext = emitSeparator => {
const op = Object.create(proto);
op._tag = OpCodes.OP_PULL_AFTER_NEXT;
op.emitSeparator = emitSeparator;
return op;
};
/** @internal */
exports.PullAfterNext = PullAfterNext;
const PullAfterAllEnqueued = emitSeparator => {
const op = Object.create(proto);
op._tag = OpCodes.OP_PULL_AFTER_ALL_ENQUEUED;
op.emitSeparator = emitSeparator;
return op;
};
/** @internal */
exports.PullAfterAllEnqueued = PullAfterAllEnqueued;
const isUpstreamPullStrategy = u => (0, _Predicate.hasProperty)(u, UpstreamPullStrategyTypeId);
/** @internal */
exports.isUpstreamPullStrategy = isUpstreamPullStrategy;
const isPullAfterNext = self => self._tag === OpCodes.OP_PULL_AFTER_NEXT;
/** @internal */
exports.isPullAfterNext = isPullAfterNext;
const isPullAfterAllEnqueued = self => self._tag === OpCodes.OP_PULL_AFTER_ALL_ENQUEUED;
/** @internal */
exports.isPullAfterAllEnqueued = isPullAfterAllEnqueued;
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onAllEnqueued,
onNext
}) => {
switch (self._tag) {
case OpCodes.OP_PULL_AFTER_NEXT:
{
return onNext(self.emitSeparator);
}
case OpCodes.OP_PULL_AFTER_ALL_ENQUEUED:
{
return onAllEnqueued(self.emitSeparator);
}
}
});
//# sourceMappingURL=upstreamPullStrategy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"upstreamPullStrategy.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UpstreamPullStrategySymbolKey","UpstreamPullStrategyTypeId","exports","Symbol","for","upstreamPullStrategyVariance","_A","_","proto","PullAfterNext","emitSeparator","op","create","_tag","OP_PULL_AFTER_NEXT","PullAfterAllEnqueued","OP_PULL_AFTER_ALL_ENQUEUED","isUpstreamPullStrategy","u","hasProperty","isPullAfterNext","self","isPullAfterAllEnqueued","match","dual","onAllEnqueued","onNext"],"sources":["../../../../src/internal/channel/upstreamPullStrategy.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAoE,SAAAG,wBAAAC,CAA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