Erster Docker-Stand
This commit is contained in:
6
_node_modules/effect/dist/esm/internal/array.js
generated
vendored
Normal file
6
_node_modules/effect/dist/esm/internal/array.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
/** @internal */
|
||||
export const isNonEmptyArray = self => self.length > 0;
|
||||
//# sourceMappingURL=array.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/array.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/array.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"array.js","names":["isNonEmptyArray","self","length"],"sources":["../../../src/internal/array.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAMA;AACA,OAAO,MAAMA,eAAe,GAAOC,IAAsB,IAA+BA,IAAI,CAACC,MAAM,GAAG,CAAC","ignoreList":[]}
|
||||
341
_node_modules/effect/dist/esm/internal/blockedRequests.js
generated
vendored
Normal file
341
_node_modules/effect/dist/esm/internal/blockedRequests.js
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Either from "../Either.js";
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as HashMap from "../HashMap.js";
|
||||
import * as List from "../List.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
/** @internal */
|
||||
export const empty = {
|
||||
_tag: "Empty"
|
||||
};
|
||||
/**
|
||||
* Combines this collection of blocked requests with the specified collection
|
||||
* of blocked requests, in parallel.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const par = (self, that) => ({
|
||||
_tag: "Par",
|
||||
left: self,
|
||||
right: that
|
||||
});
|
||||
/**
|
||||
* Combines this collection of blocked requests with the specified collection
|
||||
* of blocked requests, in sequence.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const seq = (self, that) => ({
|
||||
_tag: "Seq",
|
||||
left: self,
|
||||
right: that
|
||||
});
|
||||
/**
|
||||
* Constructs a collection of blocked requests from the specified blocked
|
||||
* request and data source.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const single = (dataSource, blockedRequest) => ({
|
||||
_tag: "Single",
|
||||
dataSource: dataSource,
|
||||
blockedRequest
|
||||
});
|
||||
/** @internal */
|
||||
export const MapRequestResolversReducer = f => ({
|
||||
emptyCase: () => empty,
|
||||
parCase: (left, right) => par(left, right),
|
||||
seqCase: (left, right) => seq(left, right),
|
||||
singleCase: (dataSource, blockedRequest) => single(f(dataSource), blockedRequest)
|
||||
});
|
||||
/**
|
||||
* Transforms all data sources with the specified data source aspect, which
|
||||
* can change the environment type of data sources but must preserve the
|
||||
* request type of each data source.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const mapRequestResolvers = (self, f) => reduce(self, MapRequestResolversReducer(f));
|
||||
/**
|
||||
* Folds over the cases of this collection of blocked requests with the
|
||||
* specified functions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const reduce = (self, reducer) => {
|
||||
let input = List.of(self);
|
||||
let output = List.empty();
|
||||
while (List.isCons(input)) {
|
||||
const current = input.head;
|
||||
switch (current._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
output = List.cons(Either.right(reducer.emptyCase()), output);
|
||||
input = input.tail;
|
||||
break;
|
||||
}
|
||||
case "Par":
|
||||
{
|
||||
output = List.cons(Either.left({
|
||||
_tag: "ParCase"
|
||||
}), output);
|
||||
input = List.cons(current.left, List.cons(current.right, input.tail));
|
||||
break;
|
||||
}
|
||||
case "Seq":
|
||||
{
|
||||
output = List.cons(Either.left({
|
||||
_tag: "SeqCase"
|
||||
}), output);
|
||||
input = List.cons(current.left, List.cons(current.right, input.tail));
|
||||
break;
|
||||
}
|
||||
case "Single":
|
||||
{
|
||||
const result = reducer.singleCase(current.dataSource, current.blockedRequest);
|
||||
output = List.cons(Either.right(result), output);
|
||||
input = input.tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = List.reduce(output, List.empty(), (acc, current) => {
|
||||
switch (current._tag) {
|
||||
case "Left":
|
||||
{
|
||||
const left = List.unsafeHead(acc);
|
||||
const right = List.unsafeHead(List.unsafeTail(acc));
|
||||
const tail = List.unsafeTail(List.unsafeTail(acc));
|
||||
switch (current.left._tag) {
|
||||
case "ParCase":
|
||||
{
|
||||
return List.cons(reducer.parCase(left, right), tail);
|
||||
}
|
||||
case "SeqCase":
|
||||
{
|
||||
return List.cons(reducer.seqCase(left, right), tail);
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
return List.cons(current.right, acc);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (List.isNil(result)) {
|
||||
throw new Error("BUG: BlockedRequests.reduce - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
}
|
||||
return result.head;
|
||||
};
|
||||
/**
|
||||
* Flattens a collection of blocked requests into a collection of pipelined
|
||||
* and batched requests that can be submitted for execution.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const flatten = self => {
|
||||
let current = List.of(self);
|
||||
let updated = List.empty();
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (1) {
|
||||
const [parallel, sequential] = List.reduce(current, [parallelCollectionEmpty(), List.empty()], ([parallel, sequential], blockedRequest) => {
|
||||
const [par, seq] = step(blockedRequest);
|
||||
return [parallelCollectionCombine(parallel, par), List.appendAll(sequential, seq)];
|
||||
});
|
||||
updated = merge(updated, parallel);
|
||||
if (List.isNil(sequential)) {
|
||||
return List.reverse(updated);
|
||||
}
|
||||
current = sequential;
|
||||
}
|
||||
throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
};
|
||||
/**
|
||||
* Takes one step in evaluating a collection of blocked requests, returning a
|
||||
* collection of blocked requests that can be performed in parallel and a list
|
||||
* of blocked requests that must be performed sequentially after those
|
||||
* requests.
|
||||
*/
|
||||
const step = requests => {
|
||||
let current = requests;
|
||||
let parallel = parallelCollectionEmpty();
|
||||
let stack = List.empty();
|
||||
let sequential = List.empty();
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (1) {
|
||||
switch (current._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
if (List.isNil(stack)) {
|
||||
return [parallel, sequential];
|
||||
}
|
||||
current = stack.head;
|
||||
stack = stack.tail;
|
||||
break;
|
||||
}
|
||||
case "Par":
|
||||
{
|
||||
stack = List.cons(current.right, stack);
|
||||
current = current.left;
|
||||
break;
|
||||
}
|
||||
case "Seq":
|
||||
{
|
||||
const left = current.left;
|
||||
const right = current.right;
|
||||
switch (left._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
current = right;
|
||||
break;
|
||||
}
|
||||
case "Par":
|
||||
{
|
||||
const l = left.left;
|
||||
const r = left.right;
|
||||
current = par(seq(l, right), seq(r, right));
|
||||
break;
|
||||
}
|
||||
case "Seq":
|
||||
{
|
||||
const l = left.left;
|
||||
const r = left.right;
|
||||
current = seq(l, seq(r, right));
|
||||
break;
|
||||
}
|
||||
case "Single":
|
||||
{
|
||||
current = left;
|
||||
sequential = List.cons(right, sequential);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Single":
|
||||
{
|
||||
parallel = parallelCollectionAdd(parallel, current);
|
||||
if (List.isNil(stack)) {
|
||||
return [parallel, sequential];
|
||||
}
|
||||
current = stack.head;
|
||||
stack = stack.tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
};
|
||||
/**
|
||||
* Merges a collection of requests that must be executed sequentially with a
|
||||
* collection of requests that can be executed in parallel. If the collections
|
||||
* are both from the same single data source then the requests can be
|
||||
* pipelined while preserving ordering guarantees.
|
||||
*/
|
||||
const merge = (sequential, parallel) => {
|
||||
if (List.isNil(sequential)) {
|
||||
return List.of(parallelCollectionToSequentialCollection(parallel));
|
||||
}
|
||||
if (parallelCollectionIsEmpty(parallel)) {
|
||||
return sequential;
|
||||
}
|
||||
const seqHeadKeys = sequentialCollectionKeys(sequential.head);
|
||||
const parKeys = parallelCollectionKeys(parallel);
|
||||
if (seqHeadKeys.length === 1 && parKeys.length === 1 && Equal.equals(seqHeadKeys[0], parKeys[0])) {
|
||||
return List.cons(sequentialCollectionCombine(sequential.head, parallelCollectionToSequentialCollection(parallel)), sequential.tail);
|
||||
}
|
||||
return List.cons(parallelCollectionToSequentialCollection(parallel), sequential);
|
||||
};
|
||||
//
|
||||
// circular
|
||||
//
|
||||
/** @internal */
|
||||
export const EntryTypeId = /*#__PURE__*/Symbol.for("effect/RequestBlock/Entry");
|
||||
/** @internal */
|
||||
class EntryImpl {
|
||||
request;
|
||||
result;
|
||||
listeners;
|
||||
ownerId;
|
||||
state;
|
||||
[EntryTypeId] = blockedRequestVariance;
|
||||
constructor(request, result, listeners, ownerId, state) {
|
||||
this.request = request;
|
||||
this.result = result;
|
||||
this.listeners = listeners;
|
||||
this.ownerId = ownerId;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
const blockedRequestVariance = {
|
||||
/* c8 ignore next */
|
||||
_R: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
export const isEntry = u => hasProperty(u, EntryTypeId);
|
||||
/** @internal */
|
||||
export const makeEntry = options => new EntryImpl(options.request, options.result, options.listeners, options.ownerId, options.state);
|
||||
/** @internal */
|
||||
export const RequestBlockParallelTypeId = /*#__PURE__*/Symbol.for("effect/RequestBlock/RequestBlockParallel");
|
||||
const parallelVariance = {
|
||||
/* c8 ignore next */
|
||||
_R: _ => _
|
||||
};
|
||||
class ParallelImpl {
|
||||
map;
|
||||
[RequestBlockParallelTypeId] = parallelVariance;
|
||||
constructor(map) {
|
||||
this.map = map;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const parallelCollectionEmpty = () => new ParallelImpl(HashMap.empty());
|
||||
/** @internal */
|
||||
export const parallelCollectionMake = (dataSource, blockedRequest) => new ParallelImpl(HashMap.make([dataSource, Chunk.of(blockedRequest)]));
|
||||
/** @internal */
|
||||
export const parallelCollectionAdd = (self, blockedRequest) => new ParallelImpl(HashMap.modifyAt(self.map, blockedRequest.dataSource, _ => Option.orElseSome(Option.map(_, Chunk.append(blockedRequest.blockedRequest)), () => Chunk.of(blockedRequest.blockedRequest))));
|
||||
/** @internal */
|
||||
export const parallelCollectionCombine = (self, that) => new ParallelImpl(HashMap.reduce(self.map, that.map, (map, value, key) => HashMap.set(map, key, Option.match(HashMap.get(map, key), {
|
||||
onNone: () => value,
|
||||
onSome: other => Chunk.appendAll(value, other)
|
||||
}))));
|
||||
/** @internal */
|
||||
export const parallelCollectionIsEmpty = self => HashMap.isEmpty(self.map);
|
||||
/** @internal */
|
||||
export const parallelCollectionKeys = self => Array.from(HashMap.keys(self.map));
|
||||
/** @internal */
|
||||
export const parallelCollectionToSequentialCollection = self => sequentialCollectionMake(HashMap.map(self.map, x => Chunk.of(x)));
|
||||
// TODO
|
||||
// /** @internal */
|
||||
// export const parallelCollectionToChunk = <R>(
|
||||
// self: ParallelCollection<R>
|
||||
// ): Array<[RequestResolver.RequestResolver<unknown, R>, Array<Request.Entry<unknown>>]> => Array.from(self.map) as any
|
||||
/** @internal */
|
||||
export const SequentialCollectionTypeId = /*#__PURE__*/Symbol.for("effect/RequestBlock/RequestBlockSequential");
|
||||
const sequentialVariance = {
|
||||
/* c8 ignore next */
|
||||
_R: _ => _
|
||||
};
|
||||
class SequentialImpl {
|
||||
map;
|
||||
[SequentialCollectionTypeId] = sequentialVariance;
|
||||
constructor(map) {
|
||||
this.map = map;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const sequentialCollectionMake = map => new SequentialImpl(map);
|
||||
/** @internal */
|
||||
export const sequentialCollectionCombine = (self, that) => new SequentialImpl(HashMap.reduce(that.map, self.map, (map, value, key) => HashMap.set(map, key, Option.match(HashMap.get(map, key), {
|
||||
onNone: () => Chunk.empty(),
|
||||
onSome: a => Chunk.appendAll(a, value)
|
||||
}))));
|
||||
/** @internal */
|
||||
export const sequentialCollectionIsEmpty = self => HashMap.isEmpty(self.map);
|
||||
/** @internal */
|
||||
export const sequentialCollectionKeys = self => Array.from(HashMap.keys(self.map));
|
||||
/** @internal */
|
||||
export const sequentialCollectionToChunk = self => Array.from(self.map);
|
||||
//# sourceMappingURL=blockedRequests.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/blockedRequests.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/blockedRequests.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
480
_node_modules/effect/dist/esm/internal/cache.js
generated
vendored
Normal file
480
_node_modules/effect/dist/esm/internal/cache.js
generated
vendored
Normal file
@@ -0,0 +1,480 @@
|
||||
import * as Context from "../Context.js";
|
||||
import * as Deferred from "../Deferred.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import * as Either from "../Either.js";
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as Exit from "../Exit.js";
|
||||
import { pipe } from "../Function.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import * as MutableHashMap from "../MutableHashMap.js";
|
||||
import * as MutableQueue from "../MutableQueue.js";
|
||||
import * as MutableRef from "../MutableRef.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import * as effect from "./core-effect.js";
|
||||
import * as core from "./core.js";
|
||||
import * as Data from "./data.js";
|
||||
import { none } from "./fiberId.js";
|
||||
import * as fiberRuntime from "./fiberRuntime.js";
|
||||
/** @internal */
|
||||
export const complete = (key, exit, entryStats, timeToLiveMillis) => Data.struct({
|
||||
_tag: "Complete",
|
||||
key,
|
||||
exit,
|
||||
entryStats,
|
||||
timeToLiveMillis
|
||||
});
|
||||
/** @internal */
|
||||
export const pending = (key, deferred) => Data.struct({
|
||||
_tag: "Pending",
|
||||
key,
|
||||
deferred
|
||||
});
|
||||
/** @internal */
|
||||
export const refreshing = (deferred, complete) => Data.struct({
|
||||
_tag: "Refreshing",
|
||||
deferred,
|
||||
complete
|
||||
});
|
||||
/** @internal */
|
||||
export const MapKeyTypeId = /*#__PURE__*/Symbol.for("effect/Cache/MapKey");
|
||||
class MapKeyImpl {
|
||||
current;
|
||||
[MapKeyTypeId] = MapKeyTypeId;
|
||||
previous = undefined;
|
||||
next = undefined;
|
||||
constructor(current) {
|
||||
this.current = current;
|
||||
}
|
||||
[Hash.symbol]() {
|
||||
return pipe(Hash.hash(this.current), Hash.combine(Hash.hash(this.previous)), Hash.combine(Hash.hash(this.next)), Hash.cached(this));
|
||||
}
|
||||
[Equal.symbol](that) {
|
||||
if (this === that) {
|
||||
return true;
|
||||
}
|
||||
return isMapKey(that) && Equal.equals(this.current, that.current) && Equal.equals(this.previous, that.previous) && Equal.equals(this.next, that.next);
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const makeMapKey = current => new MapKeyImpl(current);
|
||||
/** @internal */
|
||||
export const isMapKey = u => hasProperty(u, MapKeyTypeId);
|
||||
class KeySetImpl {
|
||||
head = undefined;
|
||||
tail = undefined;
|
||||
add(key) {
|
||||
if (key !== this.tail) {
|
||||
if (this.tail === undefined) {
|
||||
this.head = key;
|
||||
this.tail = key;
|
||||
} else {
|
||||
const previous = key.previous;
|
||||
const next = key.next;
|
||||
if (next !== undefined) {
|
||||
key.next = undefined;
|
||||
if (previous !== undefined) {
|
||||
previous.next = next;
|
||||
next.previous = previous;
|
||||
} else {
|
||||
this.head = next;
|
||||
this.head.previous = undefined;
|
||||
}
|
||||
}
|
||||
this.tail.next = key;
|
||||
key.previous = this.tail;
|
||||
this.tail = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
remove() {
|
||||
const key = this.head;
|
||||
if (key !== undefined) {
|
||||
const next = key.next;
|
||||
if (next !== undefined) {
|
||||
key.next = undefined;
|
||||
this.head = next;
|
||||
this.head.previous = undefined;
|
||||
} else {
|
||||
this.head = undefined;
|
||||
this.tail = undefined;
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const makeKeySet = () => new KeySetImpl();
|
||||
/**
|
||||
* Constructs a new `CacheState` from the specified values.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const makeCacheState = (map, keys, accesses, updating, hits, misses) => ({
|
||||
map,
|
||||
keys,
|
||||
accesses,
|
||||
updating,
|
||||
hits,
|
||||
misses
|
||||
});
|
||||
/**
|
||||
* Constructs an initial cache state.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const initialCacheState = () => makeCacheState(MutableHashMap.empty(), makeKeySet(), MutableQueue.unbounded(), MutableRef.make(false), 0, 0);
|
||||
/** @internal */
|
||||
const CacheSymbolKey = "effect/Cache";
|
||||
/** @internal */
|
||||
export const CacheTypeId = /*#__PURE__*/Symbol.for(CacheSymbolKey);
|
||||
const cacheVariance = {
|
||||
/* c8 ignore next */
|
||||
_Key: _ => _,
|
||||
/* c8 ignore next */
|
||||
_Error: _ => _,
|
||||
/* c8 ignore next */
|
||||
_Value: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const ConsumerCacheSymbolKey = "effect/ConsumerCache";
|
||||
/** @internal */
|
||||
export const ConsumerCacheTypeId = /*#__PURE__*/Symbol.for(ConsumerCacheSymbolKey);
|
||||
const consumerCacheVariance = {
|
||||
/* c8 ignore next */
|
||||
_Key: _ => _,
|
||||
/* c8 ignore next */
|
||||
_Error: _ => _,
|
||||
/* c8 ignore next */
|
||||
_Value: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
export const makeCacheStats = options => options;
|
||||
/** @internal */
|
||||
export const makeEntryStats = loadedMillis => ({
|
||||
loadedMillis
|
||||
});
|
||||
class CacheImpl {
|
||||
capacity;
|
||||
context;
|
||||
fiberId;
|
||||
lookup;
|
||||
timeToLive;
|
||||
[CacheTypeId] = cacheVariance;
|
||||
[ConsumerCacheTypeId] = consumerCacheVariance;
|
||||
cacheState;
|
||||
constructor(capacity, context, fiberId, lookup, timeToLive) {
|
||||
this.capacity = capacity;
|
||||
this.context = context;
|
||||
this.fiberId = fiberId;
|
||||
this.lookup = lookup;
|
||||
this.timeToLive = timeToLive;
|
||||
this.cacheState = initialCacheState();
|
||||
}
|
||||
get(key) {
|
||||
return core.map(this.getEither(key), Either.merge);
|
||||
}
|
||||
get cacheStats() {
|
||||
return core.sync(() => makeCacheStats({
|
||||
hits: this.cacheState.hits,
|
||||
misses: this.cacheState.misses,
|
||||
size: MutableHashMap.size(this.cacheState.map)
|
||||
}));
|
||||
}
|
||||
getOption(key) {
|
||||
return core.suspend(() => Option.match(MutableHashMap.get(this.cacheState.map, key), {
|
||||
onNone: () => {
|
||||
const mapKey = makeMapKey(key);
|
||||
this.trackAccess(mapKey);
|
||||
this.trackMiss();
|
||||
return core.succeed(Option.none());
|
||||
},
|
||||
onSome: value => this.resolveMapValue(value)
|
||||
}));
|
||||
}
|
||||
getOptionComplete(key) {
|
||||
return core.suspend(() => Option.match(MutableHashMap.get(this.cacheState.map, key), {
|
||||
onNone: () => {
|
||||
const mapKey = makeMapKey(key);
|
||||
this.trackAccess(mapKey);
|
||||
this.trackMiss();
|
||||
return core.succeed(Option.none());
|
||||
},
|
||||
onSome: value => this.resolveMapValue(value, true)
|
||||
}));
|
||||
}
|
||||
contains(key) {
|
||||
return core.sync(() => MutableHashMap.has(this.cacheState.map, key));
|
||||
}
|
||||
entryStats(key) {
|
||||
return core.sync(() => {
|
||||
const option = MutableHashMap.get(this.cacheState.map, key);
|
||||
if (Option.isSome(option)) {
|
||||
switch (option.value._tag) {
|
||||
case "Complete":
|
||||
{
|
||||
const loaded = option.value.entryStats.loadedMillis;
|
||||
return Option.some(makeEntryStats(loaded));
|
||||
}
|
||||
case "Pending":
|
||||
{
|
||||
return Option.none();
|
||||
}
|
||||
case "Refreshing":
|
||||
{
|
||||
const loaded = option.value.complete.entryStats.loadedMillis;
|
||||
return Option.some(makeEntryStats(loaded));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Option.none();
|
||||
});
|
||||
}
|
||||
getEither(key) {
|
||||
return core.suspend(() => {
|
||||
const k = key;
|
||||
let mapKey = undefined;
|
||||
let deferred = undefined;
|
||||
let value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
if (value === undefined) {
|
||||
deferred = Deferred.unsafeMake(this.fiberId);
|
||||
mapKey = makeMapKey(k);
|
||||
if (MutableHashMap.has(this.cacheState.map, k)) {
|
||||
value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
} else {
|
||||
MutableHashMap.set(this.cacheState.map, k, pending(mapKey, deferred));
|
||||
}
|
||||
}
|
||||
if (value === undefined) {
|
||||
this.trackAccess(mapKey);
|
||||
this.trackMiss();
|
||||
return core.map(this.lookupValueOf(key, deferred), Either.right);
|
||||
} else {
|
||||
return core.flatMap(this.resolveMapValue(value), Option.match({
|
||||
onNone: () => this.getEither(key),
|
||||
onSome: value => core.succeed(Either.left(value))
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
invalidate(key) {
|
||||
return core.sync(() => {
|
||||
MutableHashMap.remove(this.cacheState.map, key);
|
||||
});
|
||||
}
|
||||
invalidateWhen(key, when) {
|
||||
return core.sync(() => {
|
||||
const value = MutableHashMap.get(this.cacheState.map, key);
|
||||
if (Option.isSome(value) && value.value._tag === "Complete") {
|
||||
if (value.value.exit._tag === "Success") {
|
||||
if (when(value.value.exit.value)) {
|
||||
MutableHashMap.remove(this.cacheState.map, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
get invalidateAll() {
|
||||
return core.sync(() => {
|
||||
this.cacheState.map = MutableHashMap.empty();
|
||||
});
|
||||
}
|
||||
refresh(key) {
|
||||
return effect.clockWith(clock => core.suspend(() => {
|
||||
const k = key;
|
||||
const deferred = Deferred.unsafeMake(this.fiberId);
|
||||
let value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
if (value === undefined) {
|
||||
if (MutableHashMap.has(this.cacheState.map, k)) {
|
||||
value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
} else {
|
||||
MutableHashMap.set(this.cacheState.map, k, pending(makeMapKey(k), deferred));
|
||||
}
|
||||
}
|
||||
if (value === undefined) {
|
||||
return core.asVoid(this.lookupValueOf(key, deferred));
|
||||
} else {
|
||||
switch (value._tag) {
|
||||
case "Complete":
|
||||
{
|
||||
if (this.hasExpired(clock, value.timeToLiveMillis)) {
|
||||
const found = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
if (Equal.equals(found, value)) {
|
||||
MutableHashMap.remove(this.cacheState.map, k);
|
||||
}
|
||||
return core.asVoid(this.get(key));
|
||||
}
|
||||
// Only trigger the lookup if we're still the current value, `completedResult`
|
||||
return pipe(this.lookupValueOf(key, deferred), effect.when(() => {
|
||||
const current = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, k));
|
||||
if (Equal.equals(current, value)) {
|
||||
const mapValue = refreshing(deferred, value);
|
||||
MutableHashMap.set(this.cacheState.map, k, mapValue);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}), core.asVoid);
|
||||
}
|
||||
case "Pending":
|
||||
{
|
||||
return Deferred.await(value.deferred);
|
||||
}
|
||||
case "Refreshing":
|
||||
{
|
||||
return Deferred.await(value.deferred);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
set(key, value) {
|
||||
return effect.clockWith(clock => core.sync(() => {
|
||||
const now = clock.unsafeCurrentTimeMillis();
|
||||
const k = key;
|
||||
const lookupResult = Exit.succeed(value);
|
||||
const mapValue = complete(makeMapKey(k), lookupResult, makeEntryStats(now), now + Duration.toMillis(Duration.decode(this.timeToLive(lookupResult))));
|
||||
MutableHashMap.set(this.cacheState.map, k, mapValue);
|
||||
}));
|
||||
}
|
||||
get size() {
|
||||
return core.sync(() => {
|
||||
return MutableHashMap.size(this.cacheState.map);
|
||||
});
|
||||
}
|
||||
get values() {
|
||||
return core.sync(() => {
|
||||
const values = [];
|
||||
for (const entry of this.cacheState.map) {
|
||||
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
||||
values.push(entry[1].exit.value);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
});
|
||||
}
|
||||
get entries() {
|
||||
return core.sync(() => {
|
||||
const values = [];
|
||||
for (const entry of this.cacheState.map) {
|
||||
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
||||
values.push([entry[0], entry[1].exit.value]);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
});
|
||||
}
|
||||
get keys() {
|
||||
return core.sync(() => {
|
||||
const keys = [];
|
||||
for (const entry of this.cacheState.map) {
|
||||
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
||||
keys.push(entry[0]);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
});
|
||||
}
|
||||
resolveMapValue(value, ignorePending = false) {
|
||||
return effect.clockWith(clock => {
|
||||
switch (value._tag) {
|
||||
case "Complete":
|
||||
{
|
||||
this.trackAccess(value.key);
|
||||
if (this.hasExpired(clock, value.timeToLiveMillis)) {
|
||||
MutableHashMap.remove(this.cacheState.map, value.key.current);
|
||||
return core.succeed(Option.none());
|
||||
}
|
||||
this.trackHit();
|
||||
return core.map(value.exit, Option.some);
|
||||
}
|
||||
case "Pending":
|
||||
{
|
||||
this.trackAccess(value.key);
|
||||
this.trackHit();
|
||||
if (ignorePending) {
|
||||
return core.succeed(Option.none());
|
||||
}
|
||||
return core.map(Deferred.await(value.deferred), Option.some);
|
||||
}
|
||||
case "Refreshing":
|
||||
{
|
||||
this.trackAccess(value.complete.key);
|
||||
this.trackHit();
|
||||
if (this.hasExpired(clock, value.complete.timeToLiveMillis)) {
|
||||
if (ignorePending) {
|
||||
return core.succeed(Option.none());
|
||||
}
|
||||
return core.map(Deferred.await(value.deferred), Option.some);
|
||||
}
|
||||
return core.map(value.complete.exit, Option.some);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
trackHit() {
|
||||
this.cacheState.hits = this.cacheState.hits + 1;
|
||||
}
|
||||
trackMiss() {
|
||||
this.cacheState.misses = this.cacheState.misses + 1;
|
||||
}
|
||||
trackAccess(key) {
|
||||
MutableQueue.offer(this.cacheState.accesses, key);
|
||||
if (MutableRef.compareAndSet(this.cacheState.updating, false, true)) {
|
||||
let loop = true;
|
||||
while (loop) {
|
||||
const key = MutableQueue.poll(this.cacheState.accesses, MutableQueue.EmptyMutableQueue);
|
||||
if (key === MutableQueue.EmptyMutableQueue) {
|
||||
loop = false;
|
||||
} else {
|
||||
this.cacheState.keys.add(key);
|
||||
}
|
||||
}
|
||||
let size = MutableHashMap.size(this.cacheState.map);
|
||||
loop = size > this.capacity;
|
||||
while (loop) {
|
||||
const key = this.cacheState.keys.remove();
|
||||
if (key !== undefined) {
|
||||
if (MutableHashMap.has(this.cacheState.map, key.current)) {
|
||||
MutableHashMap.remove(this.cacheState.map, key.current);
|
||||
size = size - 1;
|
||||
loop = size > this.capacity;
|
||||
}
|
||||
} else {
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
MutableRef.set(this.cacheState.updating, false);
|
||||
}
|
||||
}
|
||||
hasExpired(clock, timeToLiveMillis) {
|
||||
return clock.unsafeCurrentTimeMillis() > timeToLiveMillis;
|
||||
}
|
||||
lookupValueOf(input, deferred) {
|
||||
return effect.clockWith(clock => core.suspend(() => {
|
||||
const key = input;
|
||||
return pipe(this.lookup(input), core.provideContext(this.context), core.exit, core.flatMap(exit => {
|
||||
const now = clock.unsafeCurrentTimeMillis();
|
||||
const stats = makeEntryStats(now);
|
||||
const value = complete(makeMapKey(key), exit, stats, now + Duration.toMillis(Duration.decode(this.timeToLive(exit))));
|
||||
MutableHashMap.set(this.cacheState.map, key, value);
|
||||
return core.zipRight(Deferred.done(deferred, exit), exit);
|
||||
}), core.onInterrupt(() => core.zipRight(Deferred.interrupt(deferred), core.sync(() => {
|
||||
MutableHashMap.remove(this.cacheState.map, key);
|
||||
}))));
|
||||
}));
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const make = options => {
|
||||
const timeToLive = Duration.decode(options.timeToLive);
|
||||
return makeWith({
|
||||
capacity: options.capacity,
|
||||
lookup: options.lookup,
|
||||
timeToLive: () => timeToLive
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const makeWith = options => core.map(fiberRuntime.all([core.context(), core.fiberId]), ([context, fiberId]) => new CacheImpl(options.capacity, context, fiberId, options.lookup, exit => Duration.decode(options.timeToLive(exit))));
|
||||
/** @internal */
|
||||
export const unsafeMakeWith = (capacity, lookup, timeToLive) => new CacheImpl(capacity, Context.empty(), none, lookup, exit => Duration.decode(timeToLive(exit)));
|
||||
//# sourceMappingURL=cache.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/cache.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/cache.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
824
_node_modules/effect/dist/esm/internal/cause.js
generated
vendored
Normal file
824
_node_modules/effect/dist/esm/internal/cause.js
generated
vendored
Normal file
@@ -0,0 +1,824 @@
|
||||
import * as Arr from "../Array.js";
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Either from "../Either.js";
|
||||
import * as Equal from "../Equal.js";
|
||||
import { constFalse, constTrue, dual, identity, pipe } from "../Function.js";
|
||||
import { globalValue } from "../GlobalValue.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import * as HashSet from "../HashSet.js";
|
||||
import { NodeInspectSymbol, stringifyCircular, toJSON } from "../Inspectable.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import { hasProperty, isFunction } from "../Predicate.js";
|
||||
import { getBugErrorMessage } from "./errors.js";
|
||||
import * as OpCodes from "./opCodes/cause.js";
|
||||
// -----------------------------------------------------------------------------
|
||||
// Models
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
const CauseSymbolKey = "effect/Cause";
|
||||
/** @internal */
|
||||
export const CauseTypeId = /*#__PURE__*/Symbol.for(CauseSymbolKey);
|
||||
const variance = {
|
||||
/* c8 ignore next */
|
||||
_E: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[CauseTypeId]: variance,
|
||||
[Hash.symbol]() {
|
||||
return pipe(Hash.hash(CauseSymbolKey), Hash.combine(Hash.hash(flattenCause(this))), Hash.cached(this));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
return isCause(that) && causeEquals(this, that);
|
||||
},
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
},
|
||||
toJSON() {
|
||||
switch (this._tag) {
|
||||
case "Empty":
|
||||
return {
|
||||
_id: "Cause",
|
||||
_tag: this._tag
|
||||
};
|
||||
case "Die":
|
||||
return {
|
||||
_id: "Cause",
|
||||
_tag: this._tag,
|
||||
defect: toJSON(this.defect)
|
||||
};
|
||||
case "Interrupt":
|
||||
return {
|
||||
_id: "Cause",
|
||||
_tag: this._tag,
|
||||
fiberId: this.fiberId.toJSON()
|
||||
};
|
||||
case "Fail":
|
||||
return {
|
||||
_id: "Cause",
|
||||
_tag: this._tag,
|
||||
failure: toJSON(this.error)
|
||||
};
|
||||
case "Sequential":
|
||||
case "Parallel":
|
||||
return {
|
||||
_id: "Cause",
|
||||
_tag: this._tag,
|
||||
left: toJSON(this.left),
|
||||
right: toJSON(this.right)
|
||||
};
|
||||
}
|
||||
},
|
||||
toString() {
|
||||
return pretty(this);
|
||||
},
|
||||
[NodeInspectSymbol]() {
|
||||
return this.toJSON();
|
||||
}
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const empty = /*#__PURE__*/(() => {
|
||||
const o = /*#__PURE__*/Object.create(proto);
|
||||
o._tag = OpCodes.OP_EMPTY;
|
||||
return o;
|
||||
})();
|
||||
/** @internal */
|
||||
export const fail = error => {
|
||||
const o = Object.create(proto);
|
||||
o._tag = OpCodes.OP_FAIL;
|
||||
o.error = error;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const die = defect => {
|
||||
const o = Object.create(proto);
|
||||
o._tag = OpCodes.OP_DIE;
|
||||
o.defect = defect;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const interrupt = fiberId => {
|
||||
const o = Object.create(proto);
|
||||
o._tag = OpCodes.OP_INTERRUPT;
|
||||
o.fiberId = fiberId;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const parallel = (left, right) => {
|
||||
const o = Object.create(proto);
|
||||
o._tag = OpCodes.OP_PARALLEL;
|
||||
o.left = left;
|
||||
o.right = right;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const sequential = (left, right) => {
|
||||
const o = Object.create(proto);
|
||||
o._tag = OpCodes.OP_SEQUENTIAL;
|
||||
o.left = left;
|
||||
o.right = right;
|
||||
return o;
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Refinements
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const isCause = u => hasProperty(u, CauseTypeId);
|
||||
/** @internal */
|
||||
export const isEmptyType = self => self._tag === OpCodes.OP_EMPTY;
|
||||
/** @internal */
|
||||
export const isFailType = self => self._tag === OpCodes.OP_FAIL;
|
||||
/** @internal */
|
||||
export const isDieType = self => self._tag === OpCodes.OP_DIE;
|
||||
/** @internal */
|
||||
export const isInterruptType = self => self._tag === OpCodes.OP_INTERRUPT;
|
||||
/** @internal */
|
||||
export const isSequentialType = self => self._tag === OpCodes.OP_SEQUENTIAL;
|
||||
/** @internal */
|
||||
export const isParallelType = self => self._tag === OpCodes.OP_PARALLEL;
|
||||
// -----------------------------------------------------------------------------
|
||||
// Getters
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const size = self => reduceWithContext(self, void 0, SizeCauseReducer);
|
||||
/** @internal */
|
||||
export const isEmpty = self => {
|
||||
if (self._tag === OpCodes.OP_EMPTY) {
|
||||
return true;
|
||||
}
|
||||
return reduce(self, true, (acc, cause) => {
|
||||
switch (cause._tag) {
|
||||
case OpCodes.OP_EMPTY:
|
||||
{
|
||||
return Option.some(acc);
|
||||
}
|
||||
case OpCodes.OP_DIE:
|
||||
case OpCodes.OP_FAIL:
|
||||
case OpCodes.OP_INTERRUPT:
|
||||
{
|
||||
return Option.some(false);
|
||||
}
|
||||
default:
|
||||
{
|
||||
return Option.none();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const isFailure = self => Option.isSome(failureOption(self));
|
||||
/** @internal */
|
||||
export const isDie = self => Option.isSome(dieOption(self));
|
||||
/** @internal */
|
||||
export const isInterrupted = self => Option.isSome(interruptOption(self));
|
||||
/** @internal */
|
||||
export const isInterruptedOnly = self => reduceWithContext(undefined, IsInterruptedOnlyCauseReducer)(self);
|
||||
/** @internal */
|
||||
export const failures = self => Chunk.reverse(reduce(self, Chunk.empty(), (list, cause) => cause._tag === OpCodes.OP_FAIL ? Option.some(pipe(list, Chunk.prepend(cause.error))) : Option.none()));
|
||||
/** @internal */
|
||||
export const defects = self => Chunk.reverse(reduce(self, Chunk.empty(), (list, cause) => cause._tag === OpCodes.OP_DIE ? Option.some(pipe(list, Chunk.prepend(cause.defect))) : Option.none()));
|
||||
/** @internal */
|
||||
export const interruptors = self => reduce(self, HashSet.empty(), (set, cause) => cause._tag === OpCodes.OP_INTERRUPT ? Option.some(pipe(set, HashSet.add(cause.fiberId))) : Option.none());
|
||||
/** @internal */
|
||||
export const failureOption = self => find(self, cause => cause._tag === OpCodes.OP_FAIL ? Option.some(cause.error) : Option.none());
|
||||
/** @internal */
|
||||
export const failureOrCause = self => {
|
||||
const option = failureOption(self);
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
// no `E` inside this `Cause`, so it can be safely cast to `never`
|
||||
return Either.right(self);
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
return Either.left(option.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const dieOption = self => find(self, cause => cause._tag === OpCodes.OP_DIE ? Option.some(cause.defect) : Option.none());
|
||||
/** @internal */
|
||||
export const flipCauseOption = self => match(self, {
|
||||
onEmpty: Option.some(empty),
|
||||
onFail: Option.map(fail),
|
||||
onDie: defect => Option.some(die(defect)),
|
||||
onInterrupt: fiberId => Option.some(interrupt(fiberId)),
|
||||
onSequential: Option.mergeWith(sequential),
|
||||
onParallel: Option.mergeWith(parallel)
|
||||
});
|
||||
/** @internal */
|
||||
export const interruptOption = self => find(self, cause => cause._tag === OpCodes.OP_INTERRUPT ? Option.some(cause.fiberId) : Option.none());
|
||||
/** @internal */
|
||||
export const keepDefects = self => match(self, {
|
||||
onEmpty: Option.none(),
|
||||
onFail: () => Option.none(),
|
||||
onDie: defect => Option.some(die(defect)),
|
||||
onInterrupt: () => Option.none(),
|
||||
onSequential: Option.mergeWith(sequential),
|
||||
onParallel: Option.mergeWith(parallel)
|
||||
});
|
||||
/** @internal */
|
||||
export const keepDefectsAndElectFailures = self => match(self, {
|
||||
onEmpty: Option.none(),
|
||||
onFail: failure => Option.some(die(failure)),
|
||||
onDie: defect => Option.some(die(defect)),
|
||||
onInterrupt: () => Option.none(),
|
||||
onSequential: Option.mergeWith(sequential),
|
||||
onParallel: Option.mergeWith(parallel)
|
||||
});
|
||||
/** @internal */
|
||||
export const linearize = self => match(self, {
|
||||
onEmpty: HashSet.empty(),
|
||||
onFail: error => HashSet.make(fail(error)),
|
||||
onDie: defect => HashSet.make(die(defect)),
|
||||
onInterrupt: fiberId => HashSet.make(interrupt(fiberId)),
|
||||
onSequential: (leftSet, rightSet) => HashSet.flatMap(leftSet, leftCause => HashSet.map(rightSet, rightCause => sequential(leftCause, rightCause))),
|
||||
onParallel: (leftSet, rightSet) => HashSet.flatMap(leftSet, leftCause => HashSet.map(rightSet, rightCause => parallel(leftCause, rightCause)))
|
||||
});
|
||||
/** @internal */
|
||||
export const stripFailures = self => match(self, {
|
||||
onEmpty: empty,
|
||||
onFail: () => empty,
|
||||
onDie: die,
|
||||
onInterrupt: interrupt,
|
||||
onSequential: sequential,
|
||||
onParallel: parallel
|
||||
});
|
||||
/** @internal */
|
||||
export const electFailures = self => match(self, {
|
||||
onEmpty: empty,
|
||||
onFail: die,
|
||||
onDie: die,
|
||||
onInterrupt: interrupt,
|
||||
onSequential: sequential,
|
||||
onParallel: parallel
|
||||
});
|
||||
/** @internal */
|
||||
export const stripSomeDefects = /*#__PURE__*/dual(2, (self, pf) => match(self, {
|
||||
onEmpty: Option.some(empty),
|
||||
onFail: error => Option.some(fail(error)),
|
||||
onDie: defect => {
|
||||
const option = pf(defect);
|
||||
return Option.isSome(option) ? Option.none() : Option.some(die(defect));
|
||||
},
|
||||
onInterrupt: fiberId => Option.some(interrupt(fiberId)),
|
||||
onSequential: Option.mergeWith(sequential),
|
||||
onParallel: Option.mergeWith(parallel)
|
||||
}));
|
||||
// -----------------------------------------------------------------------------
|
||||
// Mapping
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const as = /*#__PURE__*/dual(2, (self, error) => map(self, () => error));
|
||||
/** @internal */
|
||||
export const map = /*#__PURE__*/dual(2, (self, f) => flatMap(self, e => fail(f(e))));
|
||||
// -----------------------------------------------------------------------------
|
||||
// Sequencing
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const flatMap = /*#__PURE__*/dual(2, (self, f) => match(self, {
|
||||
onEmpty: empty,
|
||||
onFail: error => f(error),
|
||||
onDie: defect => die(defect),
|
||||
onInterrupt: fiberId => interrupt(fiberId),
|
||||
onSequential: (left, right) => sequential(left, right),
|
||||
onParallel: (left, right) => parallel(left, right)
|
||||
}));
|
||||
/** @internal */
|
||||
export const flatten = self => flatMap(self, identity);
|
||||
/** @internal */
|
||||
export const andThen = /*#__PURE__*/dual(2, (self, f) => isFunction(f) ? flatMap(self, f) : flatMap(self, () => f));
|
||||
// -----------------------------------------------------------------------------
|
||||
// Equality
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const contains = /*#__PURE__*/dual(2, (self, that) => {
|
||||
if (that._tag === OpCodes.OP_EMPTY || self === that) {
|
||||
return true;
|
||||
}
|
||||
return reduce(self, false, (accumulator, cause) => {
|
||||
return Option.some(accumulator || causeEquals(cause, that));
|
||||
});
|
||||
});
|
||||
/** @internal */
|
||||
const causeEquals = (left, right) => {
|
||||
let leftStack = Chunk.of(left);
|
||||
let rightStack = Chunk.of(right);
|
||||
while (Chunk.isNonEmpty(leftStack) && Chunk.isNonEmpty(rightStack)) {
|
||||
const [leftParallel, leftSequential] = pipe(Chunk.headNonEmpty(leftStack), reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
|
||||
const [par, seq] = evaluateCause(cause);
|
||||
return Option.some([pipe(parallel, HashSet.union(par)), pipe(sequential, Chunk.appendAll(seq))]);
|
||||
}));
|
||||
const [rightParallel, rightSequential] = pipe(Chunk.headNonEmpty(rightStack), reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
|
||||
const [par, seq] = evaluateCause(cause);
|
||||
return Option.some([pipe(parallel, HashSet.union(par)), pipe(sequential, Chunk.appendAll(seq))]);
|
||||
}));
|
||||
if (!Equal.equals(leftParallel, rightParallel)) {
|
||||
return false;
|
||||
}
|
||||
leftStack = leftSequential;
|
||||
rightStack = rightSequential;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Flattening
|
||||
// -----------------------------------------------------------------------------
|
||||
/**
|
||||
* Flattens a cause to a sequence of sets of causes, where each set represents
|
||||
* causes that fail in parallel and sequential sets represent causes that fail
|
||||
* after each other.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const flattenCause = cause => {
|
||||
return flattenCauseLoop(Chunk.of(cause), Chunk.empty());
|
||||
};
|
||||
/** @internal */
|
||||
const flattenCauseLoop = (causes, flattened) => {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (1) {
|
||||
const [parallel, sequential] = pipe(causes, Arr.reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
|
||||
const [par, seq] = evaluateCause(cause);
|
||||
return [pipe(parallel, HashSet.union(par)), pipe(sequential, Chunk.appendAll(seq))];
|
||||
}));
|
||||
const updated = HashSet.size(parallel) > 0 ? pipe(flattened, Chunk.prepend(parallel)) : flattened;
|
||||
if (Chunk.isEmpty(sequential)) {
|
||||
return Chunk.reverse(updated);
|
||||
}
|
||||
causes = sequential;
|
||||
flattened = updated;
|
||||
}
|
||||
throw new Error(getBugErrorMessage("Cause.flattenCauseLoop"));
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Finding
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const find = /*#__PURE__*/dual(2, (self, pf) => {
|
||||
const stack = [self];
|
||||
while (stack.length > 0) {
|
||||
const item = stack.pop();
|
||||
const option = pf(item);
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
switch (item._tag) {
|
||||
case OpCodes.OP_SEQUENTIAL:
|
||||
case OpCodes.OP_PARALLEL:
|
||||
{
|
||||
stack.push(item.right);
|
||||
stack.push(item.left);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
return option;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Option.none();
|
||||
});
|
||||
// -----------------------------------------------------------------------------
|
||||
// Filtering
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const filter = /*#__PURE__*/dual(2, (self, predicate) => reduceWithContext(self, void 0, FilterCauseReducer(predicate)));
|
||||
// -----------------------------------------------------------------------------
|
||||
// Evaluation
|
||||
// -----------------------------------------------------------------------------
|
||||
/**
|
||||
* Takes one step in evaluating a cause, returning a set of causes that fail
|
||||
* in parallel and a list of causes that fail sequentially after those causes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const evaluateCause = self => {
|
||||
let cause = self;
|
||||
const stack = [];
|
||||
let _parallel = HashSet.empty();
|
||||
let _sequential = Chunk.empty();
|
||||
while (cause !== undefined) {
|
||||
switch (cause._tag) {
|
||||
case OpCodes.OP_EMPTY:
|
||||
{
|
||||
if (stack.length === 0) {
|
||||
return [_parallel, _sequential];
|
||||
}
|
||||
cause = stack.pop();
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_FAIL:
|
||||
{
|
||||
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.error));
|
||||
if (stack.length === 0) {
|
||||
return [_parallel, _sequential];
|
||||
}
|
||||
cause = stack.pop();
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_DIE:
|
||||
{
|
||||
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.defect));
|
||||
if (stack.length === 0) {
|
||||
return [_parallel, _sequential];
|
||||
}
|
||||
cause = stack.pop();
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_INTERRUPT:
|
||||
{
|
||||
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.fiberId));
|
||||
if (stack.length === 0) {
|
||||
return [_parallel, _sequential];
|
||||
}
|
||||
cause = stack.pop();
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_SEQUENTIAL:
|
||||
{
|
||||
switch (cause.left._tag) {
|
||||
case OpCodes.OP_EMPTY:
|
||||
{
|
||||
cause = cause.right;
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_SEQUENTIAL:
|
||||
{
|
||||
cause = sequential(cause.left.left, sequential(cause.left.right, cause.right));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_PARALLEL:
|
||||
{
|
||||
cause = parallel(sequential(cause.left.left, cause.right), sequential(cause.left.right, cause.right));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_sequential = Chunk.prepend(_sequential, cause.right);
|
||||
cause = cause.left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_PARALLEL:
|
||||
{
|
||||
stack.push(cause.right);
|
||||
cause = cause.left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(getBugErrorMessage("Cause.evaluateCauseLoop"));
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Reducing
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
const SizeCauseReducer = {
|
||||
emptyCase: () => 0,
|
||||
failCase: () => 1,
|
||||
dieCase: () => 1,
|
||||
interruptCase: () => 1,
|
||||
sequentialCase: (_, left, right) => left + right,
|
||||
parallelCase: (_, left, right) => left + right
|
||||
};
|
||||
/** @internal */
|
||||
const IsInterruptedOnlyCauseReducer = {
|
||||
emptyCase: constTrue,
|
||||
failCase: constFalse,
|
||||
dieCase: constFalse,
|
||||
interruptCase: constTrue,
|
||||
sequentialCase: (_, left, right) => left && right,
|
||||
parallelCase: (_, left, right) => left && right
|
||||
};
|
||||
/** @internal */
|
||||
const FilterCauseReducer = predicate => ({
|
||||
emptyCase: () => empty,
|
||||
failCase: (_, error) => fail(error),
|
||||
dieCase: (_, defect) => die(defect),
|
||||
interruptCase: (_, fiberId) => interrupt(fiberId),
|
||||
sequentialCase: (_, left, right) => {
|
||||
if (predicate(left)) {
|
||||
if (predicate(right)) {
|
||||
return sequential(left, right);
|
||||
}
|
||||
return left;
|
||||
}
|
||||
if (predicate(right)) {
|
||||
return right;
|
||||
}
|
||||
return empty;
|
||||
},
|
||||
parallelCase: (_, left, right) => {
|
||||
if (predicate(left)) {
|
||||
if (predicate(right)) {
|
||||
return parallel(left, right);
|
||||
}
|
||||
return left;
|
||||
}
|
||||
if (predicate(right)) {
|
||||
return right;
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
});
|
||||
const OP_SEQUENTIAL_CASE = "SequentialCase";
|
||||
const OP_PARALLEL_CASE = "ParallelCase";
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/dual(2, (self, {
|
||||
onDie,
|
||||
onEmpty,
|
||||
onFail,
|
||||
onInterrupt,
|
||||
onParallel,
|
||||
onSequential
|
||||
}) => {
|
||||
return reduceWithContext(self, void 0, {
|
||||
emptyCase: () => onEmpty,
|
||||
failCase: (_, error) => onFail(error),
|
||||
dieCase: (_, defect) => onDie(defect),
|
||||
interruptCase: (_, fiberId) => onInterrupt(fiberId),
|
||||
sequentialCase: (_, left, right) => onSequential(left, right),
|
||||
parallelCase: (_, left, right) => onParallel(left, right)
|
||||
});
|
||||
});
|
||||
/** @internal */
|
||||
export const reduce = /*#__PURE__*/dual(3, (self, zero, pf) => {
|
||||
let accumulator = zero;
|
||||
let cause = self;
|
||||
const causes = [];
|
||||
while (cause !== undefined) {
|
||||
const option = pf(accumulator, cause);
|
||||
accumulator = Option.isSome(option) ? option.value : accumulator;
|
||||
switch (cause._tag) {
|
||||
case OpCodes.OP_SEQUENTIAL:
|
||||
{
|
||||
causes.push(cause.right);
|
||||
cause = cause.left;
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_PARALLEL:
|
||||
{
|
||||
causes.push(cause.right);
|
||||
cause = cause.left;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
cause = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cause === undefined && causes.length > 0) {
|
||||
cause = causes.pop();
|
||||
}
|
||||
}
|
||||
return accumulator;
|
||||
});
|
||||
/** @internal */
|
||||
export const reduceWithContext = /*#__PURE__*/dual(3, (self, context, reducer) => {
|
||||
const input = [self];
|
||||
const output = [];
|
||||
while (input.length > 0) {
|
||||
const cause = input.pop();
|
||||
switch (cause._tag) {
|
||||
case OpCodes.OP_EMPTY:
|
||||
{
|
||||
output.push(Either.right(reducer.emptyCase(context)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_FAIL:
|
||||
{
|
||||
output.push(Either.right(reducer.failCase(context, cause.error)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_DIE:
|
||||
{
|
||||
output.push(Either.right(reducer.dieCase(context, cause.defect)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_INTERRUPT:
|
||||
{
|
||||
output.push(Either.right(reducer.interruptCase(context, cause.fiberId)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_SEQUENTIAL:
|
||||
{
|
||||
input.push(cause.right);
|
||||
input.push(cause.left);
|
||||
output.push(Either.left({
|
||||
_tag: OP_SEQUENTIAL_CASE
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_PARALLEL:
|
||||
{
|
||||
input.push(cause.right);
|
||||
input.push(cause.left);
|
||||
output.push(Either.left({
|
||||
_tag: OP_PARALLEL_CASE
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const accumulator = [];
|
||||
while (output.length > 0) {
|
||||
const either = output.pop();
|
||||
switch (either._tag) {
|
||||
case "Left":
|
||||
{
|
||||
switch (either.left._tag) {
|
||||
case OP_SEQUENTIAL_CASE:
|
||||
{
|
||||
const left = accumulator.pop();
|
||||
const right = accumulator.pop();
|
||||
const value = reducer.sequentialCase(context, left, right);
|
||||
accumulator.push(value);
|
||||
break;
|
||||
}
|
||||
case OP_PARALLEL_CASE:
|
||||
{
|
||||
const left = accumulator.pop();
|
||||
const right = accumulator.pop();
|
||||
const value = reducer.parallelCase(context, left, right);
|
||||
accumulator.push(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
accumulator.push(either.right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accumulator.length === 0) {
|
||||
throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
}
|
||||
return accumulator.pop();
|
||||
});
|
||||
// -----------------------------------------------------------------------------
|
||||
// Pretty Printing
|
||||
// -----------------------------------------------------------------------------
|
||||
/** @internal */
|
||||
export const pretty = (cause, options) => {
|
||||
if (isInterruptedOnly(cause)) {
|
||||
return "All fibers interrupted without errors.";
|
||||
}
|
||||
return prettyErrors(cause).map(function (e) {
|
||||
if (options?.renderErrorCause !== true || e.cause === undefined) {
|
||||
return e.stack;
|
||||
}
|
||||
return `${e.stack} {\n${renderErrorCause(e.cause, " ")}\n}`;
|
||||
}).join("\n");
|
||||
};
|
||||
const renderErrorCause = (cause, prefix) => {
|
||||
const lines = cause.stack.split("\n");
|
||||
let stack = `${prefix}[cause]: ${lines[0]}`;
|
||||
for (let i = 1, len = lines.length; i < len; i++) {
|
||||
stack += `\n${prefix}${lines[i]}`;
|
||||
}
|
||||
if (cause.cause) {
|
||||
stack += ` {\n${renderErrorCause(cause.cause, `${prefix} `)}\n${prefix}}`;
|
||||
}
|
||||
return stack;
|
||||
};
|
||||
/** @internal */
|
||||
export class PrettyError extends globalThis.Error {
|
||||
span = undefined;
|
||||
constructor(originalError) {
|
||||
const originalErrorIsObject = typeof originalError === "object" && originalError !== null;
|
||||
const prevLimit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 1;
|
||||
super(prettyErrorMessage(originalError), originalErrorIsObject && "cause" in originalError && typeof originalError.cause !== "undefined" ? {
|
||||
cause: new PrettyError(originalError.cause)
|
||||
} : undefined);
|
||||
if (this.message === "") {
|
||||
this.message = "An error has occurred";
|
||||
}
|
||||
Error.stackTraceLimit = prevLimit;
|
||||
this.name = originalError instanceof Error ? originalError.name : "Error";
|
||||
if (originalErrorIsObject) {
|
||||
if (spanSymbol in originalError) {
|
||||
this.span = originalError[spanSymbol];
|
||||
}
|
||||
Object.keys(originalError).forEach(key => {
|
||||
if (!(key in this)) {
|
||||
// @ts-expect-error
|
||||
this[key] = originalError[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
this.stack = prettyErrorStack(`${this.name}: ${this.message}`, originalError instanceof Error && originalError.stack ? originalError.stack : "", this.span);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A utility function for generating human-readable error messages from a generic error of type `unknown`.
|
||||
*
|
||||
* Rules:
|
||||
*
|
||||
* 1) If the input `u` is already a string, it's considered a message.
|
||||
* 2) If `u` is an Error instance with a message defined, it uses the message.
|
||||
* 3) If `u` has a user-defined `toString()` method, it uses that method.
|
||||
* 4) Otherwise, it uses `Inspectable.stringifyCircular` to produce a string representation and uses it as the error message,
|
||||
* with "Error" added as a prefix.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const prettyErrorMessage = u => {
|
||||
// 1)
|
||||
if (typeof u === "string") {
|
||||
return u;
|
||||
}
|
||||
// 2)
|
||||
if (typeof u === "object" && u !== null && u instanceof Error) {
|
||||
return u.message;
|
||||
}
|
||||
// 3)
|
||||
try {
|
||||
if (hasProperty(u, "toString") && isFunction(u["toString"]) && u["toString"] !== Object.prototype.toString && u["toString"] !== globalThis.Array.prototype.toString) {
|
||||
return u["toString"]();
|
||||
}
|
||||
} catch {
|
||||
// something's off, rollback to json
|
||||
}
|
||||
// 4)
|
||||
return stringifyCircular(u);
|
||||
};
|
||||
const locationRegex = /\((.*)\)/g;
|
||||
/** @internal */
|
||||
export const spanToTrace = /*#__PURE__*/globalValue("effect/Tracer/spanToTrace", () => new WeakMap());
|
||||
const prettyErrorStack = (message, stack, span) => {
|
||||
const out = [message];
|
||||
const lines = stack.startsWith(message) ? stack.slice(message.length).split("\n") : stack.split("\n");
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (lines[i].includes("Generator.next")) {
|
||||
break;
|
||||
}
|
||||
if (lines[i].includes("effect_internal_function")) {
|
||||
break;
|
||||
}
|
||||
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>"));
|
||||
}
|
||||
if (span) {
|
||||
let current = span;
|
||||
let i = 0;
|
||||
while (current && current._tag === "Span" && i < 10) {
|
||||
const stackFn = spanToTrace.get(current);
|
||||
if (typeof stackFn === "function") {
|
||||
const stack = stackFn();
|
||||
if (typeof stack === "string") {
|
||||
const locationMatchAll = stack.matchAll(locationRegex);
|
||||
let match = false;
|
||||
for (const [, location] of locationMatchAll) {
|
||||
match = true;
|
||||
out.push(` at ${current.name} (${location})`);
|
||||
}
|
||||
if (!match) {
|
||||
out.push(` at ${current.name} (${stack.replace(/^at /, "")})`);
|
||||
}
|
||||
} else {
|
||||
out.push(` at ${current.name}`);
|
||||
}
|
||||
} else {
|
||||
out.push(` at ${current.name}`);
|
||||
}
|
||||
current = Option.getOrUndefined(current.parent);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return out.join("\n");
|
||||
};
|
||||
/** @internal */
|
||||
export const spanSymbol = /*#__PURE__*/Symbol.for("effect/SpanAnnotation");
|
||||
/** @internal */
|
||||
export const prettyErrors = cause => reduceWithContext(cause, void 0, {
|
||||
emptyCase: () => [],
|
||||
dieCase: (_, unknownError) => {
|
||||
return [new PrettyError(unknownError)];
|
||||
},
|
||||
failCase: (_, error) => {
|
||||
return [new PrettyError(error)];
|
||||
},
|
||||
interruptCase: () => [],
|
||||
parallelCase: (_, l, r) => [...l, ...r],
|
||||
sequentialCase: (_, l, r) => [...l, ...r]
|
||||
});
|
||||
//# sourceMappingURL=cause.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/cause.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/cause.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
683
_node_modules/effect/dist/esm/internal/channel.js
generated
vendored
Normal file
683
_node_modules/effect/dist/esm/internal/channel.js
generated
vendored
Normal file
@@ -0,0 +1,683 @@
|
||||
import * as Cause from "../Cause.js";
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Context from "../Context.js";
|
||||
import * as Deferred from "../Deferred.js";
|
||||
import * as Effect from "../Effect.js";
|
||||
import * as Either from "../Either.js";
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as Exit from "../Exit.js";
|
||||
import * as Fiber from "../Fiber.js";
|
||||
import * as FiberRef from "../FiberRef.js";
|
||||
import { constVoid, dual, identity, pipe } from "../Function.js";
|
||||
import * as Layer from "../Layer.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import * as PubSub from "../PubSub.js";
|
||||
import * as Queue from "../Queue.js";
|
||||
import * as Ref from "../Ref.js";
|
||||
import * as Scope from "../Scope.js";
|
||||
import * as executor from "./channel/channelExecutor.js";
|
||||
import * as mergeDecision from "./channel/mergeDecision.js";
|
||||
import * as mergeState from "./channel/mergeState.js";
|
||||
import * as mergeStrategy_ from "./channel/mergeStrategy.js";
|
||||
import * as singleProducerAsyncInput from "./channel/singleProducerAsyncInput.js";
|
||||
import * as coreEffect from "./core-effect.js";
|
||||
import * as core from "./core-stream.js";
|
||||
import * as MergeDecisionOpCodes from "./opCodes/channelMergeDecision.js";
|
||||
import * as MergeStateOpCodes from "./opCodes/channelMergeState.js";
|
||||
import * as ChannelStateOpCodes from "./opCodes/channelState.js";
|
||||
import * as tracer from "./tracer.js";
|
||||
/** @internal */
|
||||
export const acquireUseRelease = (acquire, use, release) => core.flatMap(core.fromEffect(Ref.make(() => Effect.void)), ref => pipe(core.fromEffect(Effect.uninterruptible(Effect.tap(acquire, a => Ref.set(ref, exit => release(a, exit))))), core.flatMap(use), core.ensuringWith(exit => Effect.flatMap(Ref.get(ref), f => f(exit)))));
|
||||
/** @internal */
|
||||
export const as = /*#__PURE__*/dual(2, (self, value) => map(self, () => value));
|
||||
/** @internal */
|
||||
export const asVoid = self => map(self, constVoid);
|
||||
/** @internal */
|
||||
export const buffer = options => core.suspend(() => {
|
||||
const doBuffer = (empty, isEmpty, ref) => unwrap(Ref.modify(ref, inElem => isEmpty(inElem) ? [core.readWith({
|
||||
onInput: input => core.flatMap(core.write(input), () => doBuffer(empty, isEmpty, ref)),
|
||||
onFailure: error => core.fail(error),
|
||||
onDone: done => core.succeedNow(done)
|
||||
}), inElem] : [core.flatMap(core.write(inElem), () => doBuffer(empty, isEmpty, ref)), empty]));
|
||||
return doBuffer(options.empty, options.isEmpty, options.ref);
|
||||
});
|
||||
/** @internal */
|
||||
export const bufferChunk = ref => buffer({
|
||||
empty: Chunk.empty(),
|
||||
isEmpty: Chunk.isEmpty,
|
||||
ref
|
||||
});
|
||||
/** @internal */
|
||||
export const catchAll = /*#__PURE__*/dual(2, (self, f) => core.catchAllCause(self, cause => Either.match(Cause.failureOrCause(cause), {
|
||||
onLeft: f,
|
||||
onRight: core.failCause
|
||||
})));
|
||||
/** @internal */
|
||||
export const concatMap = /*#__PURE__*/dual(2, (self, f) => core.concatMapWith(self, f, () => void 0, () => void 0));
|
||||
/** @internal */
|
||||
export const collect = /*#__PURE__*/dual(2, (self, pf) => {
|
||||
const collector = core.readWith({
|
||||
onInput: out => Option.match(pf(out), {
|
||||
onNone: () => collector,
|
||||
onSome: out2 => core.flatMap(core.write(out2), () => collector)
|
||||
}),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(self, collector);
|
||||
});
|
||||
/** @internal */
|
||||
export const concatOut = self => core.concatAll(self);
|
||||
/** @internal */
|
||||
export const mapInput = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.write(inElem), () => reader),
|
||||
onFailure: core.fail,
|
||||
onDone: done => core.succeedNow(f(done))
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapInputEffect = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.write(inElem), () => reader),
|
||||
onFailure: core.fail,
|
||||
onDone: done => core.fromEffect(f(done))
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapInputError = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.write(inElem), () => reader),
|
||||
onFailure: error => core.fail(f(error)),
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapInputErrorEffect = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.write(inElem), () => reader),
|
||||
onFailure: error => core.fromEffect(f(error)),
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapInputIn = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.write(f(inElem)), () => reader),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapInputInEffect = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: inElem => core.flatMap(core.flatMap(core.fromEffect(f(inElem)), core.write), () => reader),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(reader, self);
|
||||
});
|
||||
/** @internal */
|
||||
export const doneCollect = self => core.suspend(() => {
|
||||
const builder = [];
|
||||
return pipe(core.pipeTo(self, doneCollectReader(builder)), core.flatMap(outDone => core.succeed([Chunk.unsafeFromArray(builder), outDone])));
|
||||
});
|
||||
/** @internal */
|
||||
const doneCollectReader = builder => {
|
||||
return core.readWith({
|
||||
onInput: outElem => core.flatMap(core.sync(() => {
|
||||
builder.push(outElem);
|
||||
}), () => doneCollectReader(builder)),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeed
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const drain = self => {
|
||||
const drainer = core.readWithCause({
|
||||
onInput: () => drainer,
|
||||
onFailure: core.failCause,
|
||||
onDone: core.succeed
|
||||
});
|
||||
return core.pipeTo(self, drainer);
|
||||
};
|
||||
/** @internal */
|
||||
export const emitCollect = self => core.flatMap(doneCollect(self), core.write);
|
||||
/** @internal */
|
||||
export const ensuring = /*#__PURE__*/dual(2, (self, finalizer) => core.ensuringWith(self, () => finalizer));
|
||||
/** @internal */
|
||||
export const context = () => core.fromEffect(Effect.context());
|
||||
/** @internal */
|
||||
export const contextWith = f => map(context(), f);
|
||||
/** @internal */
|
||||
export const contextWithChannel = f => core.flatMap(context(), f);
|
||||
/** @internal */
|
||||
export const contextWithEffect = f => mapEffect(context(), f);
|
||||
/** @internal */
|
||||
export const flatten = self => core.flatMap(self, identity);
|
||||
/** @internal */
|
||||
export const foldChannel = /*#__PURE__*/dual(2, (self, options) => core.foldCauseChannel(self, {
|
||||
onFailure: cause => {
|
||||
const either = Cause.failureOrCause(cause);
|
||||
switch (either._tag) {
|
||||
case "Left":
|
||||
{
|
||||
return options.onFailure(either.left);
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
return core.failCause(either.right);
|
||||
}
|
||||
}
|
||||
},
|
||||
onSuccess: options.onSuccess
|
||||
}));
|
||||
/** @internal */
|
||||
export const fromEither = either => core.suspend(() => Either.match(either, {
|
||||
onLeft: core.fail,
|
||||
onRight: core.succeed
|
||||
}));
|
||||
/** @internal */
|
||||
export const fromInput = input => unwrap(input.takeWith(core.failCause, elem => core.flatMap(core.write(elem), () => fromInput(input)), core.succeed));
|
||||
/** @internal */
|
||||
export const fromPubSub = pubsub => unwrapScoped(Effect.map(PubSub.subscribe(pubsub), fromQueue));
|
||||
/** @internal */
|
||||
export const fromPubSubScoped = pubsub => Effect.map(PubSub.subscribe(pubsub), fromQueue);
|
||||
/** @internal */
|
||||
export const fromOption = option => core.suspend(() => Option.match(option, {
|
||||
onNone: () => core.fail(Option.none()),
|
||||
onSome: core.succeed
|
||||
}));
|
||||
/** @internal */
|
||||
export const fromQueue = queue => core.suspend(() => fromQueueInternal(queue));
|
||||
/** @internal */
|
||||
const fromQueueInternal = queue => pipe(core.fromEffect(Queue.take(queue)), core.flatMap(Either.match({
|
||||
onLeft: Exit.match({
|
||||
onFailure: core.failCause,
|
||||
onSuccess: core.succeedNow
|
||||
}),
|
||||
onRight: elem => core.flatMap(core.write(elem), () => fromQueueInternal(queue))
|
||||
})));
|
||||
/** @internal */
|
||||
export const identityChannel = () => core.readWith({
|
||||
onInput: input => core.flatMap(core.write(input), () => identityChannel()),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
/** @internal */
|
||||
export const interruptWhen = /*#__PURE__*/dual(2, (self, effect) => mergeWith(self, {
|
||||
other: core.fromEffect(effect),
|
||||
onSelfDone: selfDone => mergeDecision.Done(Effect.suspend(() => selfDone)),
|
||||
onOtherDone: effectDone => mergeDecision.Done(Effect.suspend(() => effectDone))
|
||||
}));
|
||||
/** @internal */
|
||||
export const interruptWhenDeferred = /*#__PURE__*/dual(2, (self, deferred) => interruptWhen(self, Deferred.await(deferred)));
|
||||
/** @internal */
|
||||
export const map = /*#__PURE__*/dual(2, (self, f) => core.flatMap(self, a => core.sync(() => f(a))));
|
||||
/** @internal */
|
||||
export const mapEffect = /*#__PURE__*/dual(2, (self, f) => core.flatMap(self, z => core.fromEffect(f(z))));
|
||||
/** @internal */
|
||||
export const mapError = /*#__PURE__*/dual(2, (self, f) => mapErrorCause(self, Cause.map(f)));
|
||||
/** @internal */
|
||||
export const mapErrorCause = /*#__PURE__*/dual(2, (self, f) => core.catchAllCause(self, cause => core.failCause(f(cause))));
|
||||
/** @internal */
|
||||
export const mapOut = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWith({
|
||||
onInput: outElem => core.flatMap(core.write(f(outElem)), () => reader),
|
||||
onFailure: core.fail,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(self, reader);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapOutEffect = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const reader = core.readWithCause({
|
||||
onInput: outElem => pipe(core.fromEffect(f(outElem)), core.flatMap(core.write), core.flatMap(() => reader)),
|
||||
onFailure: core.failCause,
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(self, reader);
|
||||
});
|
||||
/** @internal */
|
||||
export const mapOutEffectPar = /*#__PURE__*/dual(3, (self, f, n) => unwrapScopedWith(scope => Effect.gen(function* () {
|
||||
const input = yield* singleProducerAsyncInput.make();
|
||||
const queueReader = fromInput(input);
|
||||
const queue = yield* Queue.bounded(n);
|
||||
yield* Scope.addFinalizer(scope, Queue.shutdown(queue));
|
||||
const errorSignal = yield* Deferred.make();
|
||||
const withPermits = n === Number.POSITIVE_INFINITY ? _ => identity : (yield* Effect.makeSemaphore(n)).withPermits;
|
||||
const pull = yield* queueReader.pipe(core.pipeTo(self), toPullIn(scope));
|
||||
yield* pull.pipe(Effect.matchCauseEffect({
|
||||
onFailure: cause => Queue.offer(queue, Effect.failCause(cause)),
|
||||
onSuccess: Either.match({
|
||||
onLeft: outDone => Effect.zipRight(Effect.interruptible(withPermits(n)(Effect.void)), Effect.asVoid(Queue.offer(queue, Effect.succeed(Either.left(outDone))))),
|
||||
onRight: outElem => Effect.gen(function* () {
|
||||
const deferred = yield* Deferred.make();
|
||||
const latch = yield* Deferred.make();
|
||||
yield* Queue.offer(queue, Effect.map(Deferred.await(deferred), Either.right));
|
||||
yield* Deferred.succeed(latch, void 0).pipe(Effect.zipRight(Effect.uninterruptibleMask(restore => Effect.exit(restore(Deferred.await(errorSignal))).pipe(Effect.raceFirst(Effect.exit(restore(f(outElem)))), Effect.flatMap(identity))).pipe(Effect.tapErrorCause(cause => Deferred.failCause(errorSignal, cause)), Effect.intoDeferred(deferred))), withPermits(1), Effect.forkIn(scope));
|
||||
yield* Deferred.await(latch);
|
||||
})
|
||||
})
|
||||
}), Effect.forever, Effect.interruptible, Effect.forkIn(scope));
|
||||
const consumer = unwrap(Effect.matchCause(Effect.flatten(Queue.take(queue)), {
|
||||
onFailure: core.failCause,
|
||||
onSuccess: Either.match({
|
||||
onLeft: core.succeedNow,
|
||||
onRight: outElem => core.flatMap(core.write(outElem), () => consumer)
|
||||
})
|
||||
}));
|
||||
return core.embedInput(consumer, input);
|
||||
})));
|
||||
/** @internal */
|
||||
export const mergeAll = options => {
|
||||
return channels => mergeAllWith(options)(channels, constVoid);
|
||||
};
|
||||
/** @internal */
|
||||
export const mergeAllUnbounded = channels => mergeAllWith({
|
||||
concurrency: "unbounded"
|
||||
})(channels, constVoid);
|
||||
/** @internal */
|
||||
export const mergeAllUnboundedWith = (channels, f) => mergeAllWith({
|
||||
concurrency: "unbounded"
|
||||
})(channels, f);
|
||||
/** @internal */
|
||||
export const mergeAllWith = ({
|
||||
bufferSize = 16,
|
||||
concurrency,
|
||||
mergeStrategy = mergeStrategy_.BackPressure()
|
||||
}) => (channels, f) => unwrapScopedWith(scope => Effect.gen(function* () {
|
||||
const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : concurrency;
|
||||
const input = yield* singleProducerAsyncInput.make();
|
||||
const queueReader = fromInput(input);
|
||||
const queue = yield* Queue.bounded(bufferSize);
|
||||
yield* Scope.addFinalizer(scope, Queue.shutdown(queue));
|
||||
const cancelers = yield* Queue.unbounded();
|
||||
yield* Scope.addFinalizer(scope, Queue.shutdown(cancelers));
|
||||
const lastDone = yield* Ref.make(Option.none());
|
||||
const errorSignal = yield* Deferred.make();
|
||||
const withPermits = (yield* Effect.makeSemaphore(concurrencyN)).withPermits;
|
||||
const pull = yield* toPullIn(core.pipeTo(queueReader, channels), scope);
|
||||
function evaluatePull(pull) {
|
||||
return pull.pipe(Effect.flatMap(Either.match({
|
||||
onLeft: done => Effect.succeed(Option.some(done)),
|
||||
onRight: outElem => Effect.as(Queue.offer(queue, Effect.succeed(Either.right(outElem))), Option.none())
|
||||
})), Effect.repeat({
|
||||
until: _ => Option.isSome(_)
|
||||
}), Effect.flatMap(outDone => Ref.update(lastDone, Option.match({
|
||||
onNone: () => Option.some(outDone.value),
|
||||
onSome: lastDone => Option.some(f(lastDone, outDone.value))
|
||||
}))), Effect.catchAllCause(cause => Cause.isInterrupted(cause) ? Effect.failCause(cause) : Queue.offer(queue, Effect.failCause(cause)).pipe(Effect.zipRight(Deferred.succeed(errorSignal, void 0)), Effect.asVoid)));
|
||||
}
|
||||
yield* pull.pipe(Effect.matchCauseEffect({
|
||||
onFailure: cause => Queue.offer(queue, Effect.failCause(cause)).pipe(Effect.zipRight(Effect.succeed(false))),
|
||||
onSuccess: Either.match({
|
||||
onLeft: outDone => Effect.raceWith(Effect.interruptible(Deferred.await(errorSignal)), Effect.interruptible(withPermits(concurrencyN)(Effect.void)), {
|
||||
onSelfDone: (_, permitAcquisition) => Effect.as(Fiber.interrupt(permitAcquisition), false),
|
||||
onOtherDone: (_, failureAwait) => Effect.zipRight(Fiber.interrupt(failureAwait), Ref.get(lastDone).pipe(Effect.flatMap(Option.match({
|
||||
onNone: () => Queue.offer(queue, Effect.succeed(Either.left(outDone))),
|
||||
onSome: lastDone => Queue.offer(queue, Effect.succeed(Either.left(f(lastDone, outDone))))
|
||||
})), Effect.as(false)))
|
||||
}),
|
||||
onRight: channel => mergeStrategy_.match(mergeStrategy, {
|
||||
onBackPressure: () => Effect.gen(function* () {
|
||||
const latch = yield* Deferred.make();
|
||||
const raceEffects = Effect.scopedWith(scope => toPullIn(core.pipeTo(queueReader, channel), scope).pipe(Effect.flatMap(pull => Effect.race(Effect.exit(evaluatePull(pull)), Effect.exit(Effect.interruptible(Deferred.await(errorSignal))))), Effect.flatMap(identity)));
|
||||
yield* Deferred.succeed(latch, void 0).pipe(Effect.zipRight(raceEffects), withPermits(1), Effect.forkIn(scope));
|
||||
yield* Deferred.await(latch);
|
||||
const errored = yield* Deferred.isDone(errorSignal);
|
||||
return !errored;
|
||||
}),
|
||||
onBufferSliding: () => Effect.gen(function* () {
|
||||
const canceler = yield* Deferred.make();
|
||||
const latch = yield* Deferred.make();
|
||||
const size = yield* Queue.size(cancelers);
|
||||
yield* Queue.take(cancelers).pipe(Effect.flatMap(canceler => Deferred.succeed(canceler, void 0)), Effect.when(() => size >= concurrencyN));
|
||||
yield* Queue.offer(cancelers, canceler);
|
||||
const raceEffects = Effect.scopedWith(scope => toPullIn(core.pipeTo(queueReader, channel), scope).pipe(Effect.flatMap(pull => Effect.exit(evaluatePull(pull)).pipe(Effect.race(Effect.exit(Effect.interruptible(Deferred.await(errorSignal)))), Effect.race(Effect.exit(Effect.interruptible(Deferred.await(canceler)))))), Effect.flatMap(identity)));
|
||||
yield* Deferred.succeed(latch, void 0).pipe(Effect.zipRight(raceEffects), withPermits(1), Effect.forkIn(scope));
|
||||
yield* Deferred.await(latch);
|
||||
const errored = yield* Deferred.isDone(errorSignal);
|
||||
return !errored;
|
||||
})
|
||||
})
|
||||
})
|
||||
}), Effect.repeat({
|
||||
while: _ => _
|
||||
}), Effect.forkIn(scope));
|
||||
const consumer = pipe(Queue.take(queue), Effect.flatten, Effect.matchCause({
|
||||
onFailure: core.failCause,
|
||||
onSuccess: Either.match({
|
||||
onLeft: core.succeedNow,
|
||||
onRight: outElem => core.flatMap(core.write(outElem), () => consumer)
|
||||
})
|
||||
}), unwrap);
|
||||
return core.embedInput(consumer, input);
|
||||
}));
|
||||
/** @internal */
|
||||
export const mergeMap = /*#__PURE__*/dual(3, (self, f, options) => mergeAll(options)(mapOut(self, f)));
|
||||
/** @internal */
|
||||
export const mergeOut = /*#__PURE__*/dual(2, (self, n) => mergeAll({
|
||||
concurrency: n
|
||||
})(mapOut(self, identity)));
|
||||
/** @internal */
|
||||
export const mergeOutWith = /*#__PURE__*/dual(3, (self, n, f) => mergeAllWith({
|
||||
concurrency: n
|
||||
})(mapOut(self, identity), f));
|
||||
/** @internal */
|
||||
export const mergeWith = /*#__PURE__*/dual(2, (self, options) => {
|
||||
function merge(scope) {
|
||||
return Effect.gen(function* () {
|
||||
const input = yield* singleProducerAsyncInput.make();
|
||||
const queueReader = fromInput(input);
|
||||
const pullL = yield* toPullIn(core.pipeTo(queueReader, self), scope);
|
||||
const pullR = yield* toPullIn(core.pipeTo(queueReader, options.other), scope);
|
||||
function handleSide(exit, fiber, pull) {
|
||||
return (done, both, single) => {
|
||||
function onDecision(decision) {
|
||||
const op = decision;
|
||||
if (op._tag === MergeDecisionOpCodes.OP_DONE) {
|
||||
return Effect.succeed(core.fromEffect(Effect.zipRight(Fiber.interrupt(fiber), op.effect)));
|
||||
}
|
||||
return Effect.map(Fiber.await(fiber), Exit.match({
|
||||
onFailure: cause => core.fromEffect(op.f(Exit.failCause(cause))),
|
||||
onSuccess: Either.match({
|
||||
onLeft: done => core.fromEffect(op.f(Exit.succeed(done))),
|
||||
onRight: elem => zipRight(core.write(elem), go(single(op.f)))
|
||||
})
|
||||
}));
|
||||
}
|
||||
return Exit.match(exit, {
|
||||
onFailure: cause => onDecision(done(Exit.failCause(cause))),
|
||||
onSuccess: Either.match({
|
||||
onLeft: z => onDecision(done(Exit.succeed(z))),
|
||||
onRight: elem => Effect.succeed(core.flatMap(core.write(elem), () => core.flatMap(core.fromEffect(Effect.forkIn(Effect.interruptible(pull), scope)), leftFiber => go(both(leftFiber, fiber)))))
|
||||
})
|
||||
});
|
||||
};
|
||||
}
|
||||
function go(state) {
|
||||
switch (state._tag) {
|
||||
case MergeStateOpCodes.OP_BOTH_RUNNING:
|
||||
{
|
||||
const leftJoin = Effect.interruptible(Fiber.join(state.left));
|
||||
const rightJoin = Effect.interruptible(Fiber.join(state.right));
|
||||
return unwrap(Effect.raceWith(leftJoin, rightJoin, {
|
||||
onSelfDone: (leftExit, rf) => Effect.zipRight(Fiber.interrupt(rf), handleSide(leftExit, state.right, pullL)(options.onSelfDone, mergeState.BothRunning, f => mergeState.LeftDone(f))),
|
||||
onOtherDone: (rightExit, lf) => Effect.zipRight(Fiber.interrupt(lf), handleSide(rightExit, state.left, pullR)(options.onOtherDone, (left, right) => mergeState.BothRunning(right, left), f => mergeState.RightDone(f)))
|
||||
}));
|
||||
}
|
||||
case MergeStateOpCodes.OP_LEFT_DONE:
|
||||
{
|
||||
return unwrap(Effect.map(Effect.exit(pullR), Exit.match({
|
||||
onFailure: cause => core.fromEffect(state.f(Exit.failCause(cause))),
|
||||
onSuccess: Either.match({
|
||||
onLeft: done => core.fromEffect(state.f(Exit.succeed(done))),
|
||||
onRight: elem => core.flatMap(core.write(elem), () => go(mergeState.LeftDone(state.f)))
|
||||
})
|
||||
})));
|
||||
}
|
||||
case MergeStateOpCodes.OP_RIGHT_DONE:
|
||||
{
|
||||
return unwrap(Effect.map(Effect.exit(pullL), Exit.match({
|
||||
onFailure: cause => core.fromEffect(state.f(Exit.failCause(cause))),
|
||||
onSuccess: Either.match({
|
||||
onLeft: done => core.fromEffect(state.f(Exit.succeed(done))),
|
||||
onRight: elem => core.flatMap(core.write(elem), () => go(mergeState.RightDone(state.f)))
|
||||
})
|
||||
})));
|
||||
}
|
||||
}
|
||||
}
|
||||
return core.fromEffect(Effect.withFiberRuntime(parent => {
|
||||
const inherit = Effect.withFiberRuntime(state => {
|
||||
;
|
||||
state.transferChildren(parent.scope());
|
||||
return Effect.void;
|
||||
});
|
||||
const leftFiber = Effect.interruptible(pullL).pipe(Effect.ensuring(inherit), Effect.forkIn(scope));
|
||||
const rightFiber = Effect.interruptible(pullR).pipe(Effect.ensuring(inherit), Effect.forkIn(scope));
|
||||
return Effect.zipWith(leftFiber, rightFiber, (left, right) => mergeState.BothRunning(left, right));
|
||||
})).pipe(core.flatMap(go), core.embedInput(input));
|
||||
});
|
||||
}
|
||||
return unwrapScopedWith(merge);
|
||||
});
|
||||
/** @internal */
|
||||
export const never = /*#__PURE__*/core.fromEffect(Effect.never);
|
||||
/** @internal */
|
||||
export const orDie = /*#__PURE__*/dual(2, (self, error) => orDieWith(self, error));
|
||||
/** @internal */
|
||||
export const orDieWith = /*#__PURE__*/dual(2, (self, f) => catchAll(self, e => core.failCauseSync(() => Cause.die(f(e)))));
|
||||
/** @internal */
|
||||
export const orElse = /*#__PURE__*/dual(2, (self, that) => catchAll(self, that));
|
||||
/** @internal */
|
||||
export const pipeToOrFail = /*#__PURE__*/dual(2, (self, that) => core.suspend(() => {
|
||||
let channelException = undefined;
|
||||
const reader = core.readWith({
|
||||
onInput: outElem => core.flatMap(core.write(outElem), () => reader),
|
||||
onFailure: outErr => {
|
||||
channelException = ChannelException(outErr);
|
||||
return core.failCause(Cause.die(channelException));
|
||||
},
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
const writer = core.readWithCause({
|
||||
onInput: outElem => pipe(core.write(outElem), core.flatMap(() => writer)),
|
||||
onFailure: cause => Cause.isDieType(cause) && isChannelException(cause.defect) && Equal.equals(cause.defect, channelException) ? core.fail(cause.defect.error) : core.failCause(cause),
|
||||
onDone: core.succeedNow
|
||||
});
|
||||
return core.pipeTo(core.pipeTo(core.pipeTo(self, reader), that), writer);
|
||||
}));
|
||||
/** @internal */
|
||||
export const provideService = /*#__PURE__*/dual(3, (self, tag, service) => {
|
||||
return core.flatMap(context(), context => core.provideContext(self, Context.add(context, tag, service)));
|
||||
});
|
||||
/** @internal */
|
||||
export const provideLayer = /*#__PURE__*/dual(2, (self, layer) => unwrapScopedWith(scope => Effect.map(Layer.buildWithScope(layer, scope), context => core.provideContext(self, context))));
|
||||
/** @internal */
|
||||
export const mapInputContext = /*#__PURE__*/dual(2, (self, f) => contextWithChannel(context => core.provideContext(self, f(context))));
|
||||
/** @internal */
|
||||
export const provideSomeLayer = /*#__PURE__*/dual(2, (self, layer) =>
|
||||
// @ts-expect-error
|
||||
provideLayer(self, Layer.merge(Layer.context(), layer)));
|
||||
/** @internal */
|
||||
export const read = () => core.readOrFail(Option.none());
|
||||
/** @internal */
|
||||
export const repeated = self => core.flatMap(self, () => repeated(self));
|
||||
/** @internal */
|
||||
export const run = self => Effect.scopedWith(scope => executor.runIn(self, scope));
|
||||
/** @internal */
|
||||
export const runCollect = self => run(core.collectElements(self));
|
||||
/** @internal */
|
||||
export const runDrain = self => run(drain(self));
|
||||
/** @internal */
|
||||
export const runScoped = self => Effect.scopeWith(scope => executor.runIn(self, scope));
|
||||
/** @internal */
|
||||
export const scoped = effect => unwrap(Effect.uninterruptibleMask(restore => Effect.map(Scope.make(), scope => core.acquireReleaseOut(Effect.tapErrorCause(restore(Scope.extend(effect, scope)), cause => Scope.close(scope, Exit.failCause(cause))), (_, exit) => Scope.close(scope, exit)))));
|
||||
/** @internal */
|
||||
export const scopedWith = f => unwrapScoped(Effect.map(Effect.scope, scope => core.flatMap(core.fromEffect(f(scope)), core.write)));
|
||||
/** @internal */
|
||||
export const service = tag => core.fromEffect(tag);
|
||||
/** @internal */
|
||||
export const serviceWith = tag => f => map(service(tag), f);
|
||||
/** @internal */
|
||||
export const serviceWithChannel = tag => f => core.flatMap(service(tag), f);
|
||||
/** @internal */
|
||||
export const serviceWithEffect = tag => f => mapEffect(service(tag), f);
|
||||
/** @internal */
|
||||
export const splitLines = () => core.suspend(() => {
|
||||
let stringBuilder = "";
|
||||
let midCRLF = false;
|
||||
const splitLinesChunk = chunk => {
|
||||
const chunkBuilder = [];
|
||||
Chunk.map(chunk, str => {
|
||||
if (str.length !== 0) {
|
||||
let from = 0;
|
||||
let indexOfCR = str.indexOf("\r");
|
||||
let indexOfLF = str.indexOf("\n");
|
||||
if (midCRLF) {
|
||||
if (indexOfLF === 0) {
|
||||
chunkBuilder.push(stringBuilder);
|
||||
stringBuilder = "";
|
||||
from = 1;
|
||||
indexOfLF = str.indexOf("\n", from);
|
||||
} else {
|
||||
stringBuilder = stringBuilder + "\r";
|
||||
}
|
||||
midCRLF = false;
|
||||
}
|
||||
while (indexOfCR !== -1 || indexOfLF !== -1) {
|
||||
if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) {
|
||||
if (stringBuilder.length === 0) {
|
||||
chunkBuilder.push(str.substring(from, indexOfLF));
|
||||
} else {
|
||||
chunkBuilder.push(stringBuilder + str.substring(from, indexOfLF));
|
||||
stringBuilder = "";
|
||||
}
|
||||
from = indexOfLF + 1;
|
||||
indexOfLF = str.indexOf("\n", from);
|
||||
} else {
|
||||
if (str.length === indexOfCR + 1) {
|
||||
midCRLF = true;
|
||||
indexOfCR = -1;
|
||||
} else {
|
||||
if (indexOfLF === indexOfCR + 1) {
|
||||
if (stringBuilder.length === 0) {
|
||||
chunkBuilder.push(str.substring(from, indexOfCR));
|
||||
} else {
|
||||
stringBuilder = stringBuilder + str.substring(from, indexOfCR);
|
||||
chunkBuilder.push(stringBuilder);
|
||||
stringBuilder = "";
|
||||
}
|
||||
from = indexOfCR + 2;
|
||||
indexOfCR = str.indexOf("\r", from);
|
||||
indexOfLF = str.indexOf("\n", from);
|
||||
} else {
|
||||
indexOfCR = str.indexOf("\r", indexOfCR + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (midCRLF) {
|
||||
stringBuilder = stringBuilder + str.substring(from, str.length - 1);
|
||||
} else {
|
||||
stringBuilder = stringBuilder + str.substring(from, str.length);
|
||||
}
|
||||
}
|
||||
});
|
||||
return Chunk.unsafeFromArray(chunkBuilder);
|
||||
};
|
||||
const loop = core.readWithCause({
|
||||
onInput: input => {
|
||||
const out = splitLinesChunk(input);
|
||||
return Chunk.isEmpty(out) ? loop : core.flatMap(core.write(out), () => loop);
|
||||
},
|
||||
onFailure: cause => stringBuilder.length === 0 ? core.failCause(cause) : core.flatMap(core.write(Chunk.of(stringBuilder)), () => core.failCause(cause)),
|
||||
onDone: done => stringBuilder.length === 0 ? core.succeed(done) : core.flatMap(core.write(Chunk.of(stringBuilder)), () => core.succeed(done))
|
||||
});
|
||||
return loop;
|
||||
});
|
||||
/** @internal */
|
||||
export const toPubSub = pubsub => toQueue(pubsub);
|
||||
/** @internal */
|
||||
export const toPull = self => Effect.flatMap(Effect.scope, scope => toPullIn(self, scope));
|
||||
/** @internal */
|
||||
export const toPullIn = /*#__PURE__*/dual(2, (self, scope) => Effect.zip(Effect.sync(() => new executor.ChannelExecutor(self, void 0, identity)), Effect.runtime()).pipe(Effect.tap(([executor, runtime]) => Scope.addFinalizerExit(scope, exit => {
|
||||
const finalizer = executor.close(exit);
|
||||
return finalizer !== undefined ? Effect.provide(finalizer, runtime) : Effect.void;
|
||||
})), Effect.uninterruptible, Effect.map(([executor]) => Effect.suspend(() => interpretToPull(executor.run(), executor)))));
|
||||
/** @internal */
|
||||
const interpretToPull = (channelState, exec) => {
|
||||
const state = channelState;
|
||||
switch (state._tag) {
|
||||
case ChannelStateOpCodes.OP_DONE:
|
||||
{
|
||||
return Exit.match(exec.getDone(), {
|
||||
onFailure: Effect.failCause,
|
||||
onSuccess: done => Effect.succeed(Either.left(done))
|
||||
});
|
||||
}
|
||||
case ChannelStateOpCodes.OP_EMIT:
|
||||
{
|
||||
return Effect.succeed(Either.right(exec.getEmit()));
|
||||
}
|
||||
case ChannelStateOpCodes.OP_FROM_EFFECT:
|
||||
{
|
||||
return pipe(state.effect, Effect.flatMap(() => interpretToPull(exec.run(), exec)));
|
||||
}
|
||||
case ChannelStateOpCodes.OP_READ:
|
||||
{
|
||||
return executor.readUpstream(state, () => interpretToPull(exec.run(), exec), cause => Effect.failCause(cause));
|
||||
}
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const toQueue = queue => core.suspend(() => toQueueInternal(queue));
|
||||
/** @internal */
|
||||
const toQueueInternal = queue => {
|
||||
return core.readWithCause({
|
||||
onInput: elem => core.flatMap(core.fromEffect(Queue.offer(queue, Either.right(elem))), () => toQueueInternal(queue)),
|
||||
onFailure: cause => core.fromEffect(Queue.offer(queue, Either.left(Exit.failCause(cause)))),
|
||||
onDone: done => core.fromEffect(Queue.offer(queue, Either.left(Exit.succeed(done))))
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const unwrap = channel => flatten(core.fromEffect(channel));
|
||||
/** @internal */
|
||||
export const unwrapScoped = self => core.concatAllWith(scoped(self), (d, _) => d, (d, _) => d);
|
||||
/** @internal */
|
||||
export const unwrapScopedWith = f => core.concatAllWith(scopedWith(f), (d, _) => d, (d, _) => d);
|
||||
/** @internal */
|
||||
export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => mapInputContext(self, context => Context.merge(context, Context.make(tag, f(Context.unsafeGet(context, tag))))));
|
||||
/** @internal */
|
||||
export const withSpan = function () {
|
||||
const dataFirst = typeof arguments[0] !== "string";
|
||||
const name = dataFirst ? arguments[1] : arguments[0];
|
||||
const options = tracer.addSpanStackTrace(dataFirst ? arguments[2] : arguments[1]);
|
||||
const acquire = Effect.all([Effect.makeSpan(name, options), Effect.context(), Effect.clock, FiberRef.get(FiberRef.currentTracerTimingEnabled)]);
|
||||
if (dataFirst) {
|
||||
const self = arguments[0];
|
||||
return acquireUseRelease(acquire, ([span, context]) => core.provideContext(self, Context.add(context, tracer.spanTag, span)), ([span,, clock, timingEnabled], exit) => coreEffect.endSpan(span, exit, clock, timingEnabled));
|
||||
}
|
||||
return self => acquireUseRelease(acquire, ([span, context]) => core.provideContext(self, Context.add(context, tracer.spanTag, span)), ([span,, clock, timingEnabled], exit) => coreEffect.endSpan(span, exit, clock, timingEnabled));
|
||||
};
|
||||
/** @internal */
|
||||
export const writeAll = (...outs) => writeChunk(Chunk.fromIterable(outs));
|
||||
/** @internal */
|
||||
export const writeChunk = outs => writeChunkWriter(0, outs.length, outs);
|
||||
/** @internal */
|
||||
const writeChunkWriter = (idx, len, chunk) => {
|
||||
return idx === len ? core.void : pipe(core.write(pipe(chunk, Chunk.unsafeGet(idx))), core.flatMap(() => writeChunkWriter(idx + 1, len, chunk)));
|
||||
};
|
||||
/** @internal */
|
||||
export const zip = /*#__PURE__*/dual(args => core.isChannel(args[1]), (self, that, options) => options?.concurrent ? mergeWith(self, {
|
||||
other: that,
|
||||
onSelfDone: exit1 => mergeDecision.Await(exit2 => Effect.suspend(() => Exit.zip(exit1, exit2))),
|
||||
onOtherDone: exit2 => mergeDecision.Await(exit1 => Effect.suspend(() => Exit.zip(exit1, exit2)))
|
||||
}) : core.flatMap(self, a => map(that, b => [a, b])));
|
||||
/** @internal */
|
||||
export const zipLeft = /*#__PURE__*/dual(args => core.isChannel(args[1]), (self, that, options) => options?.concurrent ? map(zip(self, that, {
|
||||
concurrent: true
|
||||
}), tuple => tuple[0]) : core.flatMap(self, z => as(that, z)));
|
||||
/** @internal */
|
||||
export const zipRight = /*#__PURE__*/dual(args => core.isChannel(args[1]), (self, that, options) => options?.concurrent ? map(zip(self, that, {
|
||||
concurrent: true
|
||||
}), tuple => tuple[1]) : core.flatMap(self, () => that));
|
||||
/** @internal */
|
||||
export const ChannelExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Channel/ChannelException");
|
||||
/** @internal */
|
||||
export const ChannelException = error => ({
|
||||
_tag: "ChannelException",
|
||||
[ChannelExceptionTypeId]: ChannelExceptionTypeId,
|
||||
error
|
||||
});
|
||||
/** @internal */
|
||||
export const isChannelException = u => hasProperty(u, ChannelExceptionTypeId);
|
||||
//# sourceMappingURL=channel.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/channel.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
688
_node_modules/effect/dist/esm/internal/channel/channelExecutor.js
generated
vendored
Normal file
688
_node_modules/effect/dist/esm/internal/channel/channelExecutor.js
generated
vendored
Normal file
@@ -0,0 +1,688 @@
|
||||
import * as Cause from "../../Cause.js";
|
||||
import * as Deferred from "../../Deferred.js";
|
||||
import * as Effect from "../../Effect.js";
|
||||
import * as ExecutionStrategy from "../../ExecutionStrategy.js";
|
||||
import * as Exit from "../../Exit.js";
|
||||
import * as Fiber from "../../Fiber.js";
|
||||
import * as FiberId from "../../FiberId.js";
|
||||
import { dual, identity, pipe } from "../../Function.js";
|
||||
import * as HashSet from "../../HashSet.js";
|
||||
import * as Option from "../../Option.js";
|
||||
import * as Scope from "../../Scope.js";
|
||||
import * as core from "../core-stream.js";
|
||||
import * as ChannelOpCodes from "../opCodes/channel.js";
|
||||
import * as ChildExecutorDecisionOpCodes from "../opCodes/channelChildExecutorDecision.js";
|
||||
import * as ChannelStateOpCodes from "../opCodes/channelState.js";
|
||||
import * as UpstreamPullStrategyOpCodes from "../opCodes/channelUpstreamPullStrategy.js";
|
||||
import * as ContinuationOpCodes from "../opCodes/continuation.js";
|
||||
import * as ChannelState from "./channelState.js";
|
||||
import * as Continuation from "./continuation.js";
|
||||
import * as Subexecutor from "./subexecutor.js";
|
||||
import * as upstreamPullRequest from "./upstreamPullRequest.js";
|
||||
/** @internal */
|
||||
export 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 = 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() : 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, 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 = pipe(finalizer, Effect.ensuring(Effect.sync(() => this.clearInProgressFinalizer())));
|
||||
}
|
||||
let closeSelf = undefined;
|
||||
const selfFinalizers = this.popAllFinalizers(exit);
|
||||
if (selfFinalizers !== undefined) {
|
||||
closeSelf = 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 pipe(Effect.exit(ifNotNull(closeSubexecutors)), Effect.zip(Effect.exit(ifNotNull(runInProgressFinalizers))), Effect.zip(Effect.exit(ifNotNull(closeSelf))), Effect.map(([[exit1, exit2], exit3]) => 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 = 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 = 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 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(() => pipe(closeFuncs, Effect.forEach(closeFunc => pipe(Effect.sync(() => closeFunc(subexecutorDone)), Effect.flatMap(closeEffect => closeEffect !== undefined ? closeEffect : Effect.void)), {
|
||||
discard: true
|
||||
})));
|
||||
const state = 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, 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 pipe(this._executeCloseLastSubstream(closeLastSubstream), Effect.zipRight(effect));
|
||||
}, emitted => {
|
||||
if (this._closeLastSubstream !== undefined) {
|
||||
const closeLastSubstream = this._closeLastSubstream;
|
||||
this._closeLastSubstream = undefined;
|
||||
return 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 pipe(this._executeCloseLastSubstream(closeLastSubstream), Effect.map(() => this.replaceSubexecutor(drain)));
|
||||
}
|
||||
this.replaceSubexecutor(drain);
|
||||
return undefined;
|
||||
}
|
||||
const closeLastSubstream = this._closeLastSubstream;
|
||||
const state = this.finishSubexecutorWithCloseEffect(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;
|
||||
}
|
||||
}
|
||||
const ifNotNull = effect => effect !== undefined ? effect : Effect.void;
|
||||
const runFinalizers = (finalizers, exit) => {
|
||||
return pipe(Effect.forEach(finalizers, fin => Effect.exit(fin(exit))), Effect.map(exits => pipe(Exit.all(exits), Option.getOrElse(() => Exit.void))), Effect.flatMap(exit => Effect.suspend(() => exit)));
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export 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 pipe(emitEffect, Effect.matchCauseEffect({
|
||||
onFailure,
|
||||
onSuccess
|
||||
}));
|
||||
}
|
||||
if (emitEffect === undefined) {
|
||||
return Effect.suspend(() => read());
|
||||
}
|
||||
return 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 pipe(doneEffect, Effect.matchCauseEffect({
|
||||
onFailure,
|
||||
onSuccess
|
||||
}));
|
||||
}
|
||||
if (doneEffect === undefined) {
|
||||
return Effect.suspend(() => read());
|
||||
}
|
||||
return pipe(doneEffect, Effect.matchCauseEffect({
|
||||
onFailure,
|
||||
onSuccess: () => read()
|
||||
}));
|
||||
}
|
||||
case ChannelStateOpCodes.OP_FROM_EFFECT:
|
||||
{
|
||||
readStack.push(current);
|
||||
return 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 */
|
||||
export const runIn = /*#__PURE__*/dual(2, (self, scope) => {
|
||||
const run = (channelDeferred, scopeDeferred, scope) => Effect.acquireUseRelease(Effect.sync(() => new ChannelExecutor(self, void 0, 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 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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/channelExecutor.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/channelExecutor.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
59
_node_modules/effect/dist/esm/internal/channel/channelState.js
generated
vendored
Normal file
59
_node_modules/effect/dist/esm/internal/channel/channelState.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import * as Effect from "../../Effect.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelState.js";
|
||||
/** @internal */
|
||||
export const ChannelStateTypeId = /*#__PURE__*/Symbol.for("effect/ChannelState");
|
||||
const channelStateVariance = {
|
||||
/* c8 ignore next */
|
||||
_E: _ => _,
|
||||
/* c8 ignore next */
|
||||
_R: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[ChannelStateTypeId]: channelStateVariance
|
||||
};
|
||||
/** @internal */
|
||||
export const Done = () => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_DONE;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const Emit = () => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_EMIT;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const fromEffect = effect => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FROM_EFFECT;
|
||||
op.effect = effect;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export 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 */
|
||||
export const isChannelState = u => hasProperty(u, ChannelStateTypeId);
|
||||
/** @internal */
|
||||
export const isDone = self => self._tag === OpCodes.OP_DONE;
|
||||
/** @internal */
|
||||
export const isEmit = self => self._tag === OpCodes.OP_EMIT;
|
||||
/** @internal */
|
||||
export const isFromEffect = self => self._tag === OpCodes.OP_FROM_EFFECT;
|
||||
/** @internal */
|
||||
export const isRead = self => self._tag === OpCodes.OP_READ;
|
||||
/** @internal */
|
||||
export const effect = self => isFromEffect(self) ? self.effect : Effect.void;
|
||||
/** @internal */
|
||||
export const effectOrUndefinedIgnored = self => isFromEffect(self) ? Effect.ignore(self.effect) : undefined;
|
||||
//# sourceMappingURL=channelState.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/channel/channelState.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/channelState.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"channelState.js","names":["Effect","hasProperty","OpCodes","ChannelStateTypeId","Symbol","for","channelStateVariance","_E","_","_R","proto","Done","op","Object","create","_tag","OP_DONE","Emit","OP_EMIT","fromEffect","effect","OP_FROM_EFFECT","Read","upstream","onEffect","onEmit","onDone","OP_READ","isChannelState","u","isDone","self","isEmit","isFromEffect","isRead","void","effectOrUndefinedIgnored","ignore","undefined"],"sources":["../../../../src/internal/channel/channelState.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,iBAAiB;AAEzC,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,OAAO,KAAKC,OAAO,MAAM,4BAA4B;AAGrD;AACA,OAAO,MAAMC,kBAAkB,gBAAGC,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAkBnE,MAAMC,oBAAoB,GAAG;EAC3B;EACAC,EAAE,EAAGC,CAAQ,IAAKA,CAAC;EACnB;EACAC,EAAE,EAAGD,CAAQ,IAAKA;CACnB;AAED;AACA,MAAME,KAAK,GAAG;EACZ,CAACP,kBAAkB,GAAGG;CACvB;AAqCD;AACA,OAAO,MAAMK,IAAI,GAAGA,CAAA,KAAiC;EACnD,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACJ,KAAK,CAAC;EAC/BE,EAAE,CAACG,IAAI,GAAGb,OAAO,CAACc,OAAO;EACzB,OAAOJ,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,IAAI,GAAGA,CAAA,KAAiC;EACnD,MAAML,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACJ,KAAK,CAAC;EAC/BE,EAAE,CAACG,IAAI,GAAGb,OAAO,CAACgB,OAAO;EACzB,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMO,UAAU,GAAaC,MAA8B,IAAwB;EACxF,MAAMR,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACJ,KAAK,CAAC;EAC/BE,EAAE,CAACG,IAAI,GAAGb,OAAO,CAACmB,cAAc;EAChCT,EAAE,CAACQ,MAAM,GAAGA,MAAM;EAClB,OAAOR,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMU,IAAI,GAAGA,CAClBC,QAA2B,EAC3BC,QAAkF,EAClFC,MAAqE,EACrEC,MAAwF,KAC9D;EAC1B,MAAMd,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACJ,KAAK,CAAC;EAC/BE,EAAE,CAACG,IAAI,GAAGb,OAAO,CAACyB,OAAO;EACzBf,EAAE,CAACW,QAAQ,GAAGA,QAAQ;EACtBX,EAAE,CAACY,QAAQ,GAAGA,QAAQ;EACtBZ,EAAE,CAACa,MAAM,GAAGA,MAAM;EAClBb,EAAE,CAACc,MAAM,GAAGA,MAAM;EAClB,OAAOd,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMgB,cAAc,GAAIC,CAAU,IAA0C5B,WAAW,CAAC4B,CAAC,EAAE1B,kBAAkB,CAAC;AAErH;AACA,OAAO,MAAM2B,MAAM,GAAUC,IAAwB,IAAoBA,IAAkB,CAAChB,IAAI,KAAKb,OAAO,CAACc,OAAO;AAEpH;AACA,OAAO,MAAMgB,MAAM,GAAUD,IAAwB,IAAoBA,IAAkB,CAAChB,IAAI,KAAKb,OAAO,CAACgB,OAAO;AAEpH;AACA,OAAO,MAAMe,YAAY,GAAUF,IAAwB,IACxDA,IAAkB,CAAChB,IAAI,KAAKb,OAAO,CAACmB,cAAc;AAErD;AACA,OAAO,MAAMa,MAAM,GAAUH,IAAwB,IAAoBA,IAAkB,CAAChB,IAAI,KAAKb,OAAO,CAACyB,OAAO;AAEpH;AACA,OAAO,MAAMP,MAAM,GAAUW,IAAwB,IACnDE,YAAY,CAACF,IAAI,CAAC,GAAGA,IAAI,CAACX,MAAmC,GAAGpB,MAAM,CAACmC,IAAI;AAE7E;AACA,OAAO,MAAMC,wBAAwB,GAAUL,IAAwB,IACrEE,YAAY,CAACF,IAAI,CAAC,GAAG/B,MAAM,CAACqC,MAAM,CAACN,IAAI,CAACX,MAAmC,CAAC,GAAGkB,SAAS","ignoreList":[]}
|
||||
60
_node_modules/effect/dist/esm/internal/channel/childExecutorDecision.js
generated
vendored
Normal file
60
_node_modules/effect/dist/esm/internal/channel/childExecutorDecision.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelChildExecutorDecision.js";
|
||||
/** @internal */
|
||||
const ChildExecutorDecisionSymbolKey = "effect/ChannelChildExecutorDecision";
|
||||
/** @internal */
|
||||
export const ChildExecutorDecisionTypeId = /*#__PURE__*/Symbol.for(ChildExecutorDecisionSymbolKey);
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[ChildExecutorDecisionTypeId]: ChildExecutorDecisionTypeId
|
||||
};
|
||||
/** @internal */
|
||||
export const Continue = _ => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_CONTINUE;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const Close = value => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_CLOSE;
|
||||
op.value = value;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const Yield = _ => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_YIELD;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const isChildExecutorDecision = u => hasProperty(u, ChildExecutorDecisionTypeId);
|
||||
/** @internal */
|
||||
export const isContinue = self => self._tag === OpCodes.OP_CONTINUE;
|
||||
/** @internal */
|
||||
export const isClose = self => self._tag === OpCodes.OP_CLOSE;
|
||||
/** @internal */
|
||||
export const isYield = self => self._tag === OpCodes.OP_YIELD;
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/childExecutorDecision.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/childExecutorDecision.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"childExecutorDecision.js","names":["dual","hasProperty","OpCodes","ChildExecutorDecisionSymbolKey","ChildExecutorDecisionTypeId","Symbol","for","proto","Continue","_","op","Object","create","_tag","OP_CONTINUE","Close","value","OP_CLOSE","Yield","OP_YIELD","isChildExecutorDecision","u","isContinue","self","isClose","isYield","match","onClose","onContinue","onYield"],"sources":["../../../../src/internal/channel/childExecutorDecision.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,IAAI,QAAQ,mBAAmB;AACxC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAO,KAAKC,OAAO,MAAM,4CAA4C;AAErE;AACA,MAAMC,8BAA8B,GAAG,qCAAqC;AAE5E;AACA,OAAO,MAAMC,2BAA2B,gBAAsDC,MAAM,CAACC,GAAG,CACtGH,8BAA8B,CACsB;AAEtD;AACA,MAAMI,KAAK,GAAG;EACZ,CAACH,2BAA2B,GAAGA;CAChC;AAED;AACA,OAAO,MAAMI,QAAQ,GAAIC,CAAO,IAAiD;EAC/E,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGX,OAAO,CAACY,WAAW;EAC7B,OAAOJ,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,KAAK,GAAIC,KAAc,IAAiD;EACnF,MAAMN,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGX,OAAO,CAACe,QAAQ;EAC1BP,EAAE,CAACM,KAAK,GAAGA,KAAK;EAChB,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMQ,KAAK,GAAIT,CAAO,IAAiD;EAC5E,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGX,OAAO,CAACiB,QAAQ;EAC1B,OAAOT,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMU,uBAAuB,GAAIC,CAAU,IAChDpB,WAAW,CAACoB,CAAC,EAAEjB,2BAA2B,CAAC;AAE7C;AACA,OAAO,MAAMkB,UAAU,GACrBC,IAAiD,IACNA,IAAI,CAACV,IAAI,KAAKX,OAAO,CAACY,WAAW;AAE9E;AACA,OAAO,MAAMU,OAAO,GAClBD,IAAiD,IACTA,IAAI,CAACV,IAAI,KAAKX,OAAO,CAACe,QAAQ;AAExE;AACA,OAAO,MAAMQ,OAAO,GAClBF,IAAiD,IACTA,IAAI,CAACV,IAAI,KAAKX,OAAO,CAACiB,QAAQ;AAExE;AACA,OAAO,MAAMO,KAAK,gBAAG1B,IAAI,CAgBvB,CAAC,EAAE,CACHuB,IAAiD,EACjD;EAAEI,OAAO;EAAEC,UAAU;EAAEC;AAAO,CAI7B,KACI;EACL,QAAQN,IAAI,CAACV,IAAI;IACf,KAAKX,OAAO,CAACY,WAAW;MAAE;QACxB,OAAOc,UAAU,EAAE;MACrB;IACA,KAAK1B,OAAO,CAACe,QAAQ;MAAE;QACrB,OAAOU,OAAO,CAACJ,IAAI,CAACP,KAAK,CAAC;MAC5B;IACA,KAAKd,OAAO,CAACiB,QAAQ;MAAE;QACrB,OAAOU,OAAO,EAAE;MAClB;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
48
_node_modules/effect/dist/esm/internal/channel/continuation.js
generated
vendored
Normal file
48
_node_modules/effect/dist/esm/internal/channel/continuation.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as Exit from "../../Exit.js";
|
||||
import * as OpCodes from "../opCodes/continuation.js";
|
||||
/** @internal */
|
||||
export const 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 */
|
||||
export 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 */
|
||||
export class ContinuationFinalizerImpl {
|
||||
finalizer;
|
||||
_tag = OpCodes.OP_CONTINUATION_FINALIZER;
|
||||
[ContinuationTypeId] = continuationVariance;
|
||||
constructor(finalizer) {
|
||||
this.finalizer = finalizer;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=continuation.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/channel/continuation.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/continuation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"continuation.js","names":["Exit","OpCodes","ContinuationTypeId","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,OAAO,KAAKA,IAAI,MAAM,eAAe;AAErC,OAAO,KAAKC,OAAO,MAAM,4BAA4B;AAErD;AACA,OAAO,MAAMC,kBAAkB,gBAAGC,MAAM,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAuH1E,MAAMC,oBAAoB,GAAG;EAC3B;EACAC,IAAI,EAAGC,CAAQ,IAAKA,CAAC;EACrB;EACAC,MAAM,EAAGD,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;AACA,OAAM,MAAOS,iBAAiB;EA2BjBC,SAAA;EAGAC,MAAA;EANFC,IAAI,GAAGlB,OAAO,CAACmB,iBAAiB;EAChC,CAAClB,kBAAkB,IAAIG,oBAAoB;EACpDgB,YACWJ,SAEmE,EACnEC,MAEoE;IALpE,KAAAD,SAAS,GAATA,SAAS;IAGT,KAAAC,MAAM,GAANA,MAAM;EAIjB;EACAI,MAAMA,CACJC,IAAgC;IAEhC,OAAOvB,IAAI,CAACwB,SAAS,CAACD,IAAI,CAAC,GAAG,IAAI,CAACL,MAAM,CAACK,IAAI,CAACE,KAAK,CAAC,GAAG,IAAI,CAACR,SAAS,CAACM,IAAI,CAACG,KAAK,CAAC;EACpF;;AAGF;AACA,OAAM,MAAOC,yBAAyB;EAKfC,SAAA;EAFZT,IAAI,GAAGlB,OAAO,CAAC4B,yBAAyB;EACxC,CAAC3B,kBAAkB,IAAIG,oBAAoB;EACpDgB,YAAqBO,SAAmF;IAAnF,KAAAA,SAAS,GAATA,SAAS;EAC9B","ignoreList":[]}
|
||||
49
_node_modules/effect/dist/esm/internal/channel/mergeDecision.js
generated
vendored
Normal file
49
_node_modules/effect/dist/esm/internal/channel/mergeDecision.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelMergeDecision.js";
|
||||
/** @internal */
|
||||
const MergeDecisionSymbolKey = "effect/ChannelMergeDecision";
|
||||
/** @internal */
|
||||
export const MergeDecisionTypeId = /*#__PURE__*/Symbol.for(MergeDecisionSymbolKey);
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[MergeDecisionTypeId]: {
|
||||
_R: _ => _,
|
||||
_E0: _ => _,
|
||||
_Z0: _ => _,
|
||||
_E: _ => _,
|
||||
_Z: _ => _
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const Done = effect => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_DONE;
|
||||
op.effect = effect;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const Await = f => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_AWAIT;
|
||||
op.f = f;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const AwaitConst = effect => Await(() => effect);
|
||||
/** @internal */
|
||||
export const isMergeDecision = u => hasProperty(u, MergeDecisionTypeId);
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/mergeDecision.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/mergeDecision.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeDecision.js","names":["dual","hasProperty","OpCodes","MergeDecisionSymbolKey","MergeDecisionTypeId","Symbol","for","proto","_R","_","_E0","_Z0","_E","_Z","Done","effect","op","Object","create","_tag","OP_DONE","Await","f","OP_AWAIT","AwaitConst","isMergeDecision","u","match","self","onAwait","onDone"],"sources":["../../../../src/internal/channel/mergeDecision.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,IAAI,QAAQ,mBAAmB;AAExC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAO,KAAKC,OAAO,MAAM,oCAAoC;AAE7D;AACA,MAAMC,sBAAsB,GAAG,6BAA6B;AAE5D;AACA,OAAO,MAAMC,mBAAmB,gBAAsCC,MAAM,CAACC,GAAG,CAC9EH,sBAAsB,CACc;AAEtC;AACA,MAAMI,KAAK,GAAG;EACZ,CAACH,mBAAmB,GAAG;IACrBI,EAAE,EAAGC,CAAQ,IAAKA,CAAC;IACnBC,GAAG,EAAGD,CAAU,IAAKA,CAAC;IACtBE,GAAG,EAAGF,CAAU,IAAKA,CAAC;IACtBG,EAAE,EAAGH,CAAQ,IAAKA,CAAC;IACnBI,EAAE,EAAGJ,CAAQ,IAAKA;;CAErB;AA6BD;AACA,OAAO,MAAMK,IAAI,GACfC,MAA8B,IAC4B;EAC1D,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACX,KAAK,CAAC;EAC/BS,EAAE,CAACG,IAAI,GAAGjB,OAAO,CAACkB,OAAO;EACzBJ,EAAE,CAACD,MAAM,GAAGA,MAAM;EAClB,OAAOC,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,KAAK,GAChBC,CAAsD,IACN;EAChD,MAAMN,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACX,KAAK,CAAC;EAC/BS,EAAE,CAACG,IAAI,GAAGjB,OAAO,CAACqB,QAAQ;EAC1BP,EAAE,CAACM,CAAC,GAAGA,CAAC;EACR,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMQ,UAAU,GACrBT,MAA8B,IAC6BM,KAAK,CAAC,MAAMN,MAAM,CAAC;AAEhF;AACA,OAAO,MAAMU,eAAe,GAC1BC,CAAU,IACwEzB,WAAW,CAACyB,CAAC,EAAEtB,mBAAmB,CAAC;AAEvH;AACA,OAAO,MAAMuB,KAAK,gBAAG3B,IAAI,CAcvB,CAAC,EAAE,CACH4B,IAAkD,EAClD;EAAEC,OAAO;EAAEC;AAAM,CAGhB,KACK;EACN,MAAMd,EAAE,GAAGY,IAAiB;EAC5B,QAAQZ,EAAE,CAACG,IAAI;IACb,KAAKjB,OAAO,CAACkB,OAAO;MAClB,OAAOU,MAAM,CAACd,EAAE,CAACD,MAAM,CAAC;IAC1B,KAAKb,OAAO,CAACqB,QAAQ;MACnB,OAAOM,OAAO,CAACb,EAAE,CAACM,CAAC,CAAC;EACxB;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
69
_node_modules/effect/dist/esm/internal/channel/mergeState.js
generated
vendored
Normal file
69
_node_modules/effect/dist/esm/internal/channel/mergeState.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelMergeState.js";
|
||||
/** @internal */
|
||||
const MergeStateSymbolKey = "effect/ChannelMergeState";
|
||||
/** @internal */
|
||||
export const MergeStateTypeId = /*#__PURE__*/Symbol.for(MergeStateSymbolKey);
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[MergeStateTypeId]: MergeStateTypeId
|
||||
};
|
||||
/** @internal */
|
||||
export const BothRunning = (left, right) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_BOTH_RUNNING;
|
||||
op.left = left;
|
||||
op.right = right;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const LeftDone = f => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_LEFT_DONE;
|
||||
op.f = f;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const RightDone = f => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_RIGHT_DONE;
|
||||
op.f = f;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const isMergeState = u => hasProperty(u, MergeStateTypeId);
|
||||
/** @internal */
|
||||
export const isBothRunning = self => {
|
||||
return self._tag === OpCodes.OP_BOTH_RUNNING;
|
||||
};
|
||||
/** @internal */
|
||||
export const isLeftDone = self => {
|
||||
return self._tag === OpCodes.OP_LEFT_DONE;
|
||||
};
|
||||
/** @internal */
|
||||
export const isRightDone = self => {
|
||||
return self._tag === OpCodes.OP_RIGHT_DONE;
|
||||
};
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/mergeState.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/mergeState.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeState.js","names":["dual","hasProperty","OpCodes","MergeStateSymbolKey","MergeStateTypeId","Symbol","for","proto","BothRunning","left","right","op","Object","create","_tag","OP_BOTH_RUNNING","LeftDone","f","OP_LEFT_DONE","RightDone","OP_RIGHT_DONE","isMergeState","u","isBothRunning","self","isLeftDone","isRightDone","match","onBothRunning","onLeftDone","onRightDone"],"sources":["../../../../src/internal/channel/mergeState.ts"],"sourcesContent":[null],"mappings":"AAIA,SAASA,IAAI,QAAQ,mBAAmB;AAExC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAO,KAAKC,OAAO,MAAM,iCAAiC;AAE1D;AACA,MAAMC,mBAAmB,GAAG,0BAA0B;AAEtD;AACA,OAAO,MAAMC,gBAAgB,gBAAgCC,MAAM,CAACC,GAAG,CACrEH,mBAAmB,CACW;AAEhC;AACA,MAAMI,KAAK,GAAG;EACZ,CAACH,gBAAgB,GAAGA;CACrB;AAED;AACA,OAAO,MAAMI,WAAW,GAAGA,CACzBC,IAAiD,EACjDC,KAAoD,KACqB;EACzE,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACN,KAAK,CAAC;EAC/BI,EAAE,CAACG,IAAI,GAAGZ,OAAO,CAACa,eAAe;EACjCJ,EAAE,CAACF,IAAI,GAAGA,IAAI;EACdE,EAAE,CAACD,KAAK,GAAGA,KAAK;EAChB,OAAOC,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,QAAQ,GACnBC,CAAoE,IACK;EACzE,MAAMN,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACN,KAAK,CAAC;EAC/BI,EAAE,CAACG,IAAI,GAAGZ,OAAO,CAACgB,YAAY;EAC9BP,EAAE,CAACM,CAAC,GAAGA,CAAC;EACR,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMQ,SAAS,GACpBF,CAAkE,IACO;EACzE,MAAMN,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACN,KAAK,CAAC;EAC/BI,EAAE,CAACG,IAAI,GAAGZ,OAAO,CAACkB,aAAa;EAC/BT,EAAE,CAACM,CAAC,GAAGA,CAAC;EACR,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMU,YAAY,GACvBC,CAAU,IAEVrB,WAAW,CAACqB,CAAC,EAAElB,gBAAgB,CAAC;AAElC;AACA,OAAO,MAAMmB,aAAa,GACxBC,IAA2E,IACO;EAClF,OAAOA,IAAI,CAACV,IAAI,KAAKZ,OAAO,CAACa,eAAe;AAC9C,CAAC;AAED;AACA,OAAO,MAAMU,UAAU,GACrBD,IAA2E,IACI;EAC/E,OAAOA,IAAI,CAACV,IAAI,KAAKZ,OAAO,CAACgB,YAAY;AAC3C,CAAC;AAED;AACA,OAAO,MAAMQ,WAAW,GACtBF,IAA2E,IACK;EAChF,OAAOA,IAAI,CAACV,IAAI,KAAKZ,OAAO,CAACkB,aAAa;AAC5C,CAAC;AAED;AACA,OAAO,MAAMO,KAAK,gBAAG3B,IAAI,CAsBvB,CAAC,EAAE,CACHwB,IAAI,EACJ;EAAEI,aAAa;EAAEC,UAAU;EAAEC;AAAW,CAAE,KACxC;EACF,QAAQN,IAAI,CAACV,IAAI;IACf,KAAKZ,OAAO,CAACa,eAAe;MAAE;QAC5B,OAAOa,aAAa,CAACJ,IAAI,CAACf,IAAI,EAAEe,IAAI,CAACd,KAAK,CAAC;MAC7C;IACA,KAAKR,OAAO,CAACgB,YAAY;MAAE;QACzB,OAAOW,UAAU,CAACL,IAAI,CAACP,CAAC,CAAC;MAC3B;IACA,KAAKf,OAAO,CAACkB,aAAa;MAAE;QAC1B,OAAOU,WAAW,CAACN,IAAI,CAACP,CAAC,CAAC;MAC5B;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
46
_node_modules/effect/dist/esm/internal/channel/mergeStrategy.js
generated
vendored
Normal file
46
_node_modules/effect/dist/esm/internal/channel/mergeStrategy.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelMergeStrategy.js";
|
||||
/** @internal */
|
||||
const MergeStrategySymbolKey = "effect/ChannelMergeStrategy";
|
||||
/** @internal */
|
||||
export const MergeStrategyTypeId = /*#__PURE__*/Symbol.for(MergeStrategySymbolKey);
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[MergeStrategyTypeId]: MergeStrategyTypeId
|
||||
};
|
||||
/** @internal */
|
||||
export const BackPressure = _ => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_BACK_PRESSURE;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const BufferSliding = _ => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_BUFFER_SLIDING;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const isMergeStrategy = u => hasProperty(u, MergeStrategyTypeId);
|
||||
/** @internal */
|
||||
export const isBackPressure = self => self._tag === OpCodes.OP_BACK_PRESSURE;
|
||||
/** @internal */
|
||||
export const isBufferSliding = self => self._tag === OpCodes.OP_BUFFER_SLIDING;
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/mergeStrategy.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/mergeStrategy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeStrategy.js","names":["dual","hasProperty","OpCodes","MergeStrategySymbolKey","MergeStrategyTypeId","Symbol","for","proto","BackPressure","_","op","Object","create","_tag","OP_BACK_PRESSURE","BufferSliding","OP_BUFFER_SLIDING","isMergeStrategy","u","isBackPressure","self","isBufferSliding","match","onBackPressure","onBufferSliding"],"sources":["../../../../src/internal/channel/mergeStrategy.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAExC,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAO,KAAKC,OAAO,MAAM,oCAAoC;AAE7D;AACA,MAAMC,sBAAsB,GAAG,6BAA6B;AAE5D;AACA,OAAO,MAAMC,mBAAmB,gBAAsCC,MAAM,CAACC,GAAG,CAC9EH,sBAAsB,CACc;AAEtC;AACA,MAAMI,KAAK,GAAG;EACZ,CAACH,mBAAmB,GAAGA;CACxB;AAED;AACA,OAAO,MAAMI,YAAY,GAAIC,CAAO,IAAiC;EACnE,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGX,OAAO,CAACY,gBAAgB;EAClC,OAAOJ,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,aAAa,GAAIN,CAAO,IAAiC;EACpE,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGX,OAAO,CAACc,iBAAiB;EACnC,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMO,eAAe,GAAIC,CAAU,IAAuCjB,WAAW,CAACiB,CAAC,EAAEd,mBAAmB,CAAC;AAEpH;AACA,OAAO,MAAMe,cAAc,GAAIC,IAAiC,IAC9DA,IAAI,CAACP,IAAI,KAAKX,OAAO,CAACY,gBAAgB;AAExC;AACA,OAAO,MAAMO,eAAe,GAAID,IAAiC,IAC/DA,IAAI,CAACP,IAAI,KAAKX,OAAO,CAACc,iBAAiB;AAEzC;AACA,OAAO,MAAMM,KAAK,gBAAGtB,IAAI,CAYvB,CAAC,EAAE,CACHoB,IAAiC,EACjC;EAAEG,cAAc;EAAEC;AAAe,CAGhC,KACI;EACL,QAAQJ,IAAI,CAACP,IAAI;IACf,KAAKX,OAAO,CAACY,gBAAgB;MAAE;QAC7B,OAAOS,cAAc,EAAE;MACzB;IACA,KAAKrB,OAAO,CAACc,iBAAiB;MAAE;QAC9B,OAAOQ,eAAe,EAAE;MAC1B;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
163
_node_modules/effect/dist/esm/internal/channel/singleProducerAsyncInput.js
generated
vendored
Normal file
163
_node_modules/effect/dist/esm/internal/channel/singleProducerAsyncInput.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
import * as Cause from "../../Cause.js";
|
||||
import * as Deferred from "../../Deferred.js";
|
||||
import * as Effect from "../../Effect.js";
|
||||
import * as Either from "../../Either.js";
|
||||
import * as Exit from "../../Exit.js";
|
||||
import { pipe } from "../../Function.js";
|
||||
import * as Ref from "../../Ref.js";
|
||||
/** @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 */
|
||||
export const make = () => pipe(Deferred.make(), Effect.flatMap(deferred => Ref.make(stateEmpty(deferred))), Effect.map(ref => new SingleProducerAsyncInputImpl(ref)));
|
||||
//# sourceMappingURL=singleProducerAsyncInput.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/channel/singleProducerAsyncInput.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/singleProducerAsyncInput.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
152
_node_modules/effect/dist/esm/internal/channel/subexecutor.js
generated
vendored
Normal file
152
_node_modules/effect/dist/esm/internal/channel/subexecutor.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import * as Effect from "../../Effect.js";
|
||||
import * as Exit from "../../Exit.js";
|
||||
import { pipe } from "../../Function.js";
|
||||
/** @internal */
|
||||
export const OP_PULL_FROM_CHILD = "PullFromChild";
|
||||
/** @internal */
|
||||
export const OP_PULL_FROM_UPSTREAM = "PullFromUpstream";
|
||||
/** @internal */
|
||||
export const OP_DRAIN_CHILD_EXECUTORS = "DrainChildExecutors";
|
||||
/** @internal */
|
||||
export const OP_EMIT = "Emit";
|
||||
/**
|
||||
* Execute the `childExecutor` and on each emitted value, decide what to do by
|
||||
* `onEmit`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export 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) => 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
|
||||
*/
|
||||
export 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
|
||||
*/
|
||||
export 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 */
|
||||
export 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;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=subexecutor.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/channel/subexecutor.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/subexecutor.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
_node_modules/effect/dist/esm/internal/channel/upstreamPullRequest.js
generated
vendored
Normal file
52
_node_modules/effect/dist/esm/internal/channel/upstreamPullRequest.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelUpstreamPullRequest.js";
|
||||
/** @internal */
|
||||
const UpstreamPullRequestSymbolKey = "effect/ChannelUpstreamPullRequest";
|
||||
/** @internal */
|
||||
export const UpstreamPullRequestTypeId = /*#__PURE__*/Symbol.for(UpstreamPullRequestSymbolKey);
|
||||
const upstreamPullRequestVariance = {
|
||||
/* c8 ignore next */
|
||||
_A: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[UpstreamPullRequestTypeId]: upstreamPullRequestVariance
|
||||
};
|
||||
/** @internal */
|
||||
export const Pulled = value => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_PULLED;
|
||||
op.value = value;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const NoUpstream = activeDownstreamCount => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_NO_UPSTREAM;
|
||||
op.activeDownstreamCount = activeDownstreamCount;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const isUpstreamPullRequest = u => hasProperty(u, UpstreamPullRequestTypeId);
|
||||
/** @internal */
|
||||
export const isPulled = self => self._tag === OpCodes.OP_PULLED;
|
||||
/** @internal */
|
||||
export const isNoUpstream = self => self._tag === OpCodes.OP_NO_UPSTREAM;
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/upstreamPullRequest.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/upstreamPullRequest.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"upstreamPullRequest.js","names":["dual","hasProperty","OpCodes","UpstreamPullRequestSymbolKey","UpstreamPullRequestTypeId","Symbol","for","upstreamPullRequestVariance","_A","_","proto","Pulled","value","op","Object","create","_tag","OP_PULLED","NoUpstream","activeDownstreamCount","OP_NO_UPSTREAM","isUpstreamPullRequest","u","isPulled","self","isNoUpstream","match","onNoUpstream","onPulled"],"sources":["../../../../src/internal/channel/upstreamPullRequest.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AACxC,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,OAAO,KAAKC,OAAO,MAAM,0CAA0C;AAEnE;AACA,MAAMC,4BAA4B,GAAG,mCAAmC;AAExE;AACA,OAAO,MAAMC,yBAAyB,gBAAkDC,MAAM,CAACC,GAAG,CAChGH,4BAA4B,CACoB;AAElD,MAAMI,2BAA2B,GAAG;EAClC;EACAC,EAAE,EAAGC,CAAQ,IAAKA;CACnB;AAED;AACA,MAAMC,KAAK,GAAG;EACZ,CAACN,yBAAyB,GAAGG;CAC9B;AAED;AACA,OAAO,MAAMI,MAAM,GAAOC,KAAQ,IAAgD;EAChF,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGd,OAAO,CAACe,SAAS;EAC3BJ,EAAE,CAACD,KAAK,GAAGA,KAAK;EAChB,OAAOC,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,UAAU,GAAIC,qBAA6B,IAAoD;EAC1G,MAAMN,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGd,OAAO,CAACkB,cAAc;EAChCP,EAAE,CAACM,qBAAqB,GAAGA,qBAAqB;EAChD,OAAON,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMQ,qBAAqB,GAAIC,CAAU,IAC9CrB,WAAW,CAACqB,CAAC,EAAElB,yBAAyB,CAAC;AAE3C;AACA,OAAO,MAAMmB,QAAQ,GACnBC,IAAgD,IACNA,IAAI,CAACR,IAAI,KAAKd,OAAO,CAACe,SAAS;AAE3E;AACA,OAAO,MAAMQ,YAAY,GACvBD,IAAgD,IACLA,IAAI,CAACR,IAAI,KAAKd,OAAO,CAACkB,cAAc;AAEjF;AACA,OAAO,MAAMM,KAAK,gBAAG1B,IAAI,CAcvB,CAAC,EAAE,CACHwB,IAAgD,EAChD;EAAEG,YAAY;EAAEC;AAAQ,CAGvB,KACI;EACL,QAAQJ,IAAI,CAACR,IAAI;IACf,KAAKd,OAAO,CAACe,SAAS;MAAE;QACtB,OAAOW,QAAQ,CAACJ,IAAI,CAACZ,KAAK,CAAC;MAC7B;IACA,KAAKV,OAAO,CAACkB,cAAc;MAAE;QAC3B,OAAOO,YAAY,CAACH,IAAI,CAACL,qBAAqB,CAAC;MACjD;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
52
_node_modules/effect/dist/esm/internal/channel/upstreamPullStrategy.js
generated
vendored
Normal file
52
_node_modules/effect/dist/esm/internal/channel/upstreamPullStrategy.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { dual } from "../../Function.js";
|
||||
import { hasProperty } from "../../Predicate.js";
|
||||
import * as OpCodes from "../opCodes/channelUpstreamPullStrategy.js";
|
||||
/** @internal */
|
||||
const UpstreamPullStrategySymbolKey = "effect/ChannelUpstreamPullStrategy";
|
||||
/** @internal */
|
||||
export const UpstreamPullStrategyTypeId = /*#__PURE__*/Symbol.for(UpstreamPullStrategySymbolKey);
|
||||
const upstreamPullStrategyVariance = {
|
||||
/* c8 ignore next */
|
||||
_A: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[UpstreamPullStrategyTypeId]: upstreamPullStrategyVariance
|
||||
};
|
||||
/** @internal */
|
||||
export const PullAfterNext = emitSeparator => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_PULL_AFTER_NEXT;
|
||||
op.emitSeparator = emitSeparator;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const PullAfterAllEnqueued = emitSeparator => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_PULL_AFTER_ALL_ENQUEUED;
|
||||
op.emitSeparator = emitSeparator;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const isUpstreamPullStrategy = u => hasProperty(u, UpstreamPullStrategyTypeId);
|
||||
/** @internal */
|
||||
export const isPullAfterNext = self => self._tag === OpCodes.OP_PULL_AFTER_NEXT;
|
||||
/** @internal */
|
||||
export const isPullAfterAllEnqueued = self => self._tag === OpCodes.OP_PULL_AFTER_ALL_ENQUEUED;
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/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
|
||||
1
_node_modules/effect/dist/esm/internal/channel/upstreamPullStrategy.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/channel/upstreamPullStrategy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"upstreamPullStrategy.js","names":["dual","hasProperty","OpCodes","UpstreamPullStrategySymbolKey","UpstreamPullStrategyTypeId","Symbol","for","upstreamPullStrategyVariance","_A","_","proto","PullAfterNext","emitSeparator","op","Object","create","_tag","OP_PULL_AFTER_NEXT","PullAfterAllEnqueued","OP_PULL_AFTER_ALL_ENQUEUED","isUpstreamPullStrategy","u","isPullAfterNext","self","isPullAfterAllEnqueued","match","onAllEnqueued","onNext"],"sources":["../../../../src/internal/channel/upstreamPullStrategy.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAExC,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,OAAO,KAAKC,OAAO,MAAM,2CAA2C;AAEpE;AACA,MAAMC,6BAA6B,GAAG,oCAAoC;AAE1E;AACA,OAAO,MAAMC,0BAA0B,gBAAoDC,MAAM,CAACC,GAAG,CACnGH,6BAA6B,CACqB;AAEpD,MAAMI,4BAA4B,GAAG;EACnC;EACAC,EAAE,EAAGC,CAAQ,IAAKA;CACnB;AAED;AACA,MAAMC,KAAK,GAAG;EACZ,CAACN,0BAA0B,GAAGG;CAC/B;AAED;AACA,OAAO,MAAMI,aAAa,GAAOC,aAA+B,IAAkD;EAChH,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGd,OAAO,CAACe,kBAAkB;EACpCJ,EAAE,CAACD,aAAa,GAAGA,aAAa;EAChC,OAAOC,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMK,oBAAoB,GAC/BN,aAA+B,IACiB;EAChD,MAAMC,EAAE,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAK,CAAC;EAC/BG,EAAE,CAACG,IAAI,GAAGd,OAAO,CAACiB,0BAA0B;EAC5CN,EAAE,CAACD,aAAa,GAAGA,aAAa;EAChC,OAAOC,EAAE;AACX,CAAC;AAED;AACA,OAAO,MAAMO,sBAAsB,GAAIC,CAAU,IAC/CpB,WAAW,CAACoB,CAAC,EAAEjB,0BAA0B,CAAC;AAE5C;AACA,OAAO,MAAMkB,eAAe,GAC1BC,IAAkD,IACAA,IAAI,CAACP,IAAI,KAAKd,OAAO,CAACe,kBAAkB;AAE5F;AACA,OAAO,MAAMO,sBAAsB,GACjCD,IAAkD,IACOA,IAAI,CAACP,IAAI,KAAKd,OAAO,CAACiB,0BAA0B;AAE3G;AACA,OAAO,MAAMM,KAAK,gBAAGzB,IAAI,CAcvB,CAAC,EAAE,CACHuB,IAAkD,EAClD;EAAEG,aAAa;EAAEC;AAAM,CAGtB,KACI;EACL,QAAQJ,IAAI,CAACP,IAAI;IACf,KAAKd,OAAO,CAACe,kBAAkB;MAAE;QAC/B,OAAOU,MAAM,CAACJ,IAAI,CAACX,aAAa,CAAC;MACnC;IACA,KAAKV,OAAO,CAACiB,0BAA0B;MAAE;QACvC,OAAOO,aAAa,CAACH,IAAI,CAACX,aAAa,CAAC;MAC1C;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
||||
77
_node_modules/effect/dist/esm/internal/clock.js
generated
vendored
Normal file
77
_node_modules/effect/dist/esm/internal/clock.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import * as Context from "../Context.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import { constFalse } from "../Function.js";
|
||||
import * as core from "./core.js";
|
||||
/** @internal */
|
||||
const ClockSymbolKey = "effect/Clock";
|
||||
/** @internal */
|
||||
export const ClockTypeId = /*#__PURE__*/Symbol.for(ClockSymbolKey);
|
||||
/** @internal */
|
||||
export const clockTag = /*#__PURE__*/Context.GenericTag("effect/Clock");
|
||||
/** @internal */
|
||||
export const MAX_TIMER_MILLIS = 2 ** 31 - 1;
|
||||
/** @internal */
|
||||
export const globalClockScheduler = {
|
||||
unsafeSchedule(task, duration) {
|
||||
const millis = Duration.toMillis(duration);
|
||||
// If the duration is greater than the value allowable by the JS timer
|
||||
// functions, treat the value as an infinite duration
|
||||
if (millis > MAX_TIMER_MILLIS) {
|
||||
return constFalse;
|
||||
}
|
||||
let completed = false;
|
||||
const handle = setTimeout(() => {
|
||||
completed = true;
|
||||
task();
|
||||
}, millis);
|
||||
return () => {
|
||||
clearTimeout(handle);
|
||||
return !completed;
|
||||
};
|
||||
}
|
||||
};
|
||||
const performanceNowNanos = /*#__PURE__*/function () {
|
||||
const bigint1e6 = /*#__PURE__*/BigInt(1_000_000);
|
||||
if (typeof performance === "undefined") {
|
||||
return () => BigInt(Date.now()) * bigint1e6;
|
||||
}
|
||||
let origin;
|
||||
return () => {
|
||||
if (origin === undefined) {
|
||||
origin = BigInt(Date.now()) * bigint1e6 - BigInt(Math.round(performance.now() * 1_000_000));
|
||||
}
|
||||
return origin + BigInt(Math.round(performance.now() * 1000000));
|
||||
};
|
||||
}();
|
||||
const processOrPerformanceNow = /*#__PURE__*/function () {
|
||||
const processHrtime = typeof process === "object" && "hrtime" in process && typeof process.hrtime.bigint === "function" ? process.hrtime : undefined;
|
||||
if (!processHrtime) {
|
||||
return performanceNowNanos;
|
||||
}
|
||||
const origin = /*#__PURE__*/performanceNowNanos() - /*#__PURE__*/processHrtime.bigint();
|
||||
return () => origin + processHrtime.bigint();
|
||||
}();
|
||||
/** @internal */
|
||||
class ClockImpl {
|
||||
[ClockTypeId] = ClockTypeId;
|
||||
unsafeCurrentTimeMillis() {
|
||||
return Date.now();
|
||||
}
|
||||
unsafeCurrentTimeNanos() {
|
||||
return processOrPerformanceNow();
|
||||
}
|
||||
currentTimeMillis = /*#__PURE__*/core.sync(() => this.unsafeCurrentTimeMillis());
|
||||
currentTimeNanos = /*#__PURE__*/core.sync(() => this.unsafeCurrentTimeNanos());
|
||||
scheduler() {
|
||||
return core.succeed(globalClockScheduler);
|
||||
}
|
||||
sleep(duration) {
|
||||
return core.async(resume => {
|
||||
const canceler = globalClockScheduler.unsafeSchedule(() => resume(core.void), duration);
|
||||
return core.asVoid(core.sync(canceler));
|
||||
});
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const make = () => new ClockImpl();
|
||||
//# sourceMappingURL=clock.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/clock.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/clock.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clock.js","names":["Context","Duration","constFalse","core","ClockSymbolKey","ClockTypeId","Symbol","for","clockTag","GenericTag","MAX_TIMER_MILLIS","globalClockScheduler","unsafeSchedule","task","duration","millis","toMillis","completed","handle","setTimeout","clearTimeout","performanceNowNanos","bigint1e6","BigInt","performance","Date","now","origin","undefined","Math","round","processOrPerformanceNow","processHrtime","process","hrtime","bigint","ClockImpl","unsafeCurrentTimeMillis","unsafeCurrentTimeNanos","currentTimeMillis","sync","currentTimeNanos","scheduler","succeed","sleep","async","resume","canceler","void","asVoid","make"],"sources":["../../../src/internal/clock.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
5
_node_modules/effect/dist/esm/internal/completedRequestMap.js
generated
vendored
Normal file
5
_node_modules/effect/dist/esm/internal/completedRequestMap.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { globalValue } from "../GlobalValue.js";
|
||||
import { fiberRefUnsafeMake } from "./core.js";
|
||||
/** @internal */
|
||||
export const currentRequestMap = /*#__PURE__*/globalValue(/*#__PURE__*/Symbol.for("effect/FiberRef/currentRequestMap"), () => fiberRefUnsafeMake(new Map()));
|
||||
//# sourceMappingURL=completedRequestMap.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/completedRequestMap.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/completedRequestMap.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"completedRequestMap.js","names":["globalValue","fiberRefUnsafeMake","currentRequestMap","Symbol","for","Map"],"sources":["../../../src/internal/completedRequestMap.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,mBAAmB;AAE/C,SAASC,kBAAkB,QAAQ,WAAW;AAE9C;AACA,OAAO,MAAMC,iBAAiB,gBAAGF,WAAW,cAC1CG,MAAM,CAACC,GAAG,CAAC,mCAAmC,CAAC,EAC/C,MAAMH,kBAAkB,CAAC,IAAII,GAAG,EAA2B,CAAC,CAC7D","ignoreList":[]}
|
||||
28
_node_modules/effect/dist/esm/internal/concurrency.js
generated
vendored
Normal file
28
_node_modules/effect/dist/esm/internal/concurrency.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as core from "./core.js";
|
||||
/** @internal */
|
||||
export const match = (concurrency, sequential, unbounded, bounded) => {
|
||||
switch (concurrency) {
|
||||
case undefined:
|
||||
return sequential();
|
||||
case "unbounded":
|
||||
return unbounded();
|
||||
case "inherit":
|
||||
return core.fiberRefGetWith(core.currentConcurrency, concurrency => concurrency === "unbounded" ? unbounded() : concurrency > 1 ? bounded(concurrency) : sequential());
|
||||
default:
|
||||
return concurrency > 1 ? bounded(concurrency) : sequential();
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const matchSimple = (concurrency, sequential, concurrent) => {
|
||||
switch (concurrency) {
|
||||
case undefined:
|
||||
return sequential();
|
||||
case "unbounded":
|
||||
return concurrent();
|
||||
case "inherit":
|
||||
return core.fiberRefGetWith(core.currentConcurrency, concurrency => concurrency === "unbounded" || concurrency > 1 ? concurrent() : sequential());
|
||||
default:
|
||||
return concurrency > 1 ? concurrent() : sequential();
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=concurrency.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/concurrency.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/concurrency.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"concurrency.js","names":["core","match","concurrency","sequential","unbounded","bounded","undefined","fiberRefGetWith","currentConcurrency","matchSimple","concurrent"],"sources":["../../../src/internal/concurrency.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAKA,IAAI,MAAM,WAAW;AAEjC;AACA,OAAO,MAAMC,KAAK,GAAGA,CACnBC,WAAoC,EACpCC,UAAiC,EACjCC,SAAgC,EAChCC,OAA2C,KACxB;EACnB,QAAQH,WAAW;IACjB,KAAKI,SAAS;MACZ,OAAOH,UAAU,EAAE;IACrB,KAAK,WAAW;MACd,OAAOC,SAAS,EAAE;IACpB,KAAK,SAAS;MACZ,OAAOJ,IAAI,CAACO,eAAe,CACzBP,IAAI,CAACQ,kBAAkB,EACtBN,WAAW,IACVA,WAAW,KAAK,WAAW,GACzBE,SAAS,EAAE,GACXF,WAAW,GAAG,CAAC,GACfG,OAAO,CAACH,WAAW,CAAC,GACpBC,UAAU,EAAE,CACjB;IACH;MACE,OAAOD,WAAW,GAAG,CAAC,GAAGG,OAAO,CAACH,WAAW,CAAC,GAAGC,UAAU,EAAE;EAChE;AACF,CAAC;AAED;AACA,OAAO,MAAMM,WAAW,GAAGA,CACzBP,WAAoC,EACpCC,UAAiC,EACjCO,UAAiC,KACd;EACnB,QAAQR,WAAW;IACjB,KAAKI,SAAS;MACZ,OAAOH,UAAU,EAAE;IACrB,KAAK,WAAW;MACd,OAAOO,UAAU,EAAE;IACrB,KAAK,SAAS;MACZ,OAAOV,IAAI,CAACO,eAAe,CACzBP,IAAI,CAACQ,kBAAkB,EACtBN,WAAW,IACVA,WAAW,KAAK,WAAW,IAAIA,WAAW,GAAG,CAAC,GAC5CQ,UAAU,EAAE,GACZP,UAAU,EAAE,CACjB;IACH;MACE,OAAOD,WAAW,GAAG,CAAC,GAAGQ,UAAU,EAAE,GAAGP,UAAU,EAAE;EACxD;AACF,CAAC","ignoreList":[]}
|
||||
362
_node_modules/effect/dist/esm/internal/config.js
generated
vendored
Normal file
362
_node_modules/effect/dist/esm/internal/config.js
generated
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as ConfigError from "../ConfigError.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import * as Either from "../Either.js";
|
||||
import { constTrue, dual, pipe } from "../Function.js";
|
||||
import * as HashSet from "../HashSet.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import * as configError from "./configError.js";
|
||||
import * as core from "./core.js";
|
||||
import * as defaultServices from "./defaultServices.js";
|
||||
import * as effectable from "./effectable.js";
|
||||
import * as OpCodes from "./opCodes/config.js";
|
||||
import * as redacted_ from "./redacted.js";
|
||||
import * as InternalSecret from "./secret.js";
|
||||
const ConfigSymbolKey = "effect/Config";
|
||||
/** @internal */
|
||||
export const ConfigTypeId = /*#__PURE__*/Symbol.for(ConfigSymbolKey);
|
||||
const configVariance = {
|
||||
/* c8 ignore next */
|
||||
_A: _ => _
|
||||
};
|
||||
const proto = {
|
||||
...effectable.CommitPrototype,
|
||||
[ConfigTypeId]: configVariance,
|
||||
commit() {
|
||||
return defaultServices.config(this);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const boolean = name => {
|
||||
const config = primitive("a boolean property", text => {
|
||||
switch (text) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "on":
|
||||
case "1":
|
||||
{
|
||||
return Either.right(true);
|
||||
}
|
||||
case "false":
|
||||
case "no":
|
||||
case "off":
|
||||
case "0":
|
||||
{
|
||||
return Either.right(false);
|
||||
}
|
||||
default:
|
||||
{
|
||||
const error = configError.InvalidData([], `Expected a boolean value but received ${text}`);
|
||||
return Either.left(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const url = name => {
|
||||
const config = primitive("an URL property", text => Either.try({
|
||||
try: () => new URL(text),
|
||||
catch: _ => configError.InvalidData([], `Expected an URL value but received ${text}`)
|
||||
}));
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const port = name => {
|
||||
const config = primitive("a network port property", text => {
|
||||
const result = Number(text);
|
||||
if (Number.isNaN(result) || result.toString() !== text.toString() || !Number.isInteger(result) || result < 1 || result > 65535) {
|
||||
return Either.left(configError.InvalidData([], `Expected a network port value but received ${text}`));
|
||||
}
|
||||
return Either.right(result);
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const array = (config, name) => {
|
||||
return pipe(chunk(config, name), map(Chunk.toArray));
|
||||
};
|
||||
/** @internal */
|
||||
export const chunk = (config, name) => {
|
||||
return map(name === undefined ? repeat(config) : nested(repeat(config), name), Chunk.unsafeFromArray);
|
||||
};
|
||||
/** @internal */
|
||||
export const date = name => {
|
||||
const config = primitive("a date property", text => {
|
||||
const result = Date.parse(text);
|
||||
if (Number.isNaN(result)) {
|
||||
return Either.left(configError.InvalidData([], `Expected a Date value but received ${text}`));
|
||||
}
|
||||
return Either.right(new Date(result));
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const fail = message => {
|
||||
const fail = Object.create(proto);
|
||||
fail._tag = OpCodes.OP_FAIL;
|
||||
fail.message = message;
|
||||
fail.parse = () => Either.left(configError.Unsupported([], message));
|
||||
return fail;
|
||||
};
|
||||
/** @internal */
|
||||
export const number = name => {
|
||||
const config = primitive("a number property", text => {
|
||||
const result = Number(text);
|
||||
if (Number.isNaN(result)) {
|
||||
return Either.left(configError.InvalidData([], `Expected a number value but received ${text}`));
|
||||
}
|
||||
return Either.right(result);
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const integer = name => {
|
||||
const config = primitive("an integer property", text => {
|
||||
const result = Number(text);
|
||||
if (!Number.isInteger(result)) {
|
||||
return Either.left(configError.InvalidData([], `Expected an integer value but received ${text}`));
|
||||
}
|
||||
return Either.right(result);
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const literal = (...literals) => name => {
|
||||
const valuesString = literals.map(String).join(", ");
|
||||
const config = primitive(`one of (${valuesString})`, text => {
|
||||
const found = literals.find(value => String(value) === text);
|
||||
if (found === undefined) {
|
||||
return Either.left(configError.InvalidData([], `Expected one of (${valuesString}) but received ${text}`));
|
||||
}
|
||||
return Either.right(found);
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const logLevel = name => {
|
||||
const config = mapOrFail(string(), value => {
|
||||
const label = value.toUpperCase();
|
||||
const level = core.allLogLevels.find(level => level.label === label);
|
||||
return level === undefined ? Either.left(configError.InvalidData([], `Expected a log level but received ${value}`)) : Either.right(level);
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const duration = name => {
|
||||
const config = mapOrFail(string(), value => {
|
||||
const duration = Duration.decodeUnknown(value);
|
||||
return Either.fromOption(duration, () => configError.InvalidData([], `Expected a duration but received ${value}`));
|
||||
});
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const map = /*#__PURE__*/dual(2, (self, f) => mapOrFail(self, a => Either.right(f(a))));
|
||||
/** @internal */
|
||||
export const mapAttempt = /*#__PURE__*/dual(2, (self, f) => mapOrFail(self, a => {
|
||||
try {
|
||||
return Either.right(f(a));
|
||||
} catch (error) {
|
||||
return Either.left(configError.InvalidData([], error instanceof Error ? error.message : `${error}`));
|
||||
}
|
||||
}));
|
||||
/** @internal */
|
||||
export const mapOrFail = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const mapOrFail = Object.create(proto);
|
||||
mapOrFail._tag = OpCodes.OP_MAP_OR_FAIL;
|
||||
mapOrFail.original = self;
|
||||
mapOrFail.mapOrFail = f;
|
||||
return mapOrFail;
|
||||
});
|
||||
/** @internal */
|
||||
export const nested = /*#__PURE__*/dual(2, (self, name) => {
|
||||
const nested = Object.create(proto);
|
||||
nested._tag = OpCodes.OP_NESTED;
|
||||
nested.name = name;
|
||||
nested.config = self;
|
||||
return nested;
|
||||
});
|
||||
/** @internal */
|
||||
export const orElse = /*#__PURE__*/dual(2, (self, that) => {
|
||||
const fallback = Object.create(proto);
|
||||
fallback._tag = OpCodes.OP_FALLBACK;
|
||||
fallback.first = self;
|
||||
fallback.second = suspend(that);
|
||||
fallback.condition = constTrue;
|
||||
return fallback;
|
||||
});
|
||||
/** @internal */
|
||||
export const orElseIf = /*#__PURE__*/dual(2, (self, options) => {
|
||||
const fallback = Object.create(proto);
|
||||
fallback._tag = OpCodes.OP_FALLBACK;
|
||||
fallback.first = self;
|
||||
fallback.second = suspend(options.orElse);
|
||||
fallback.condition = options.if;
|
||||
return fallback;
|
||||
});
|
||||
/** @internal */
|
||||
export const option = self => {
|
||||
return pipe(self, map(Option.some), orElseIf({
|
||||
orElse: () => succeed(Option.none()),
|
||||
if: ConfigError.isMissingDataOnly
|
||||
}));
|
||||
};
|
||||
/** @internal */
|
||||
export const primitive = (description, parse) => {
|
||||
const primitive = Object.create(proto);
|
||||
primitive._tag = OpCodes.OP_PRIMITIVE;
|
||||
primitive.description = description;
|
||||
primitive.parse = parse;
|
||||
return primitive;
|
||||
};
|
||||
/** @internal */
|
||||
export const repeat = self => {
|
||||
const repeat = Object.create(proto);
|
||||
repeat._tag = OpCodes.OP_SEQUENCE;
|
||||
repeat.config = self;
|
||||
return repeat;
|
||||
};
|
||||
/** @internal */
|
||||
export const secret = name => {
|
||||
const config = primitive("a secret property", text => Either.right(InternalSecret.fromString(text)));
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const redacted = nameOrConfig => {
|
||||
const config = isConfig(nameOrConfig) ? nameOrConfig : string(nameOrConfig);
|
||||
return map(config, redacted_.make);
|
||||
};
|
||||
/** @internal */
|
||||
export const branded = /*#__PURE__*/dual(2, (nameOrConfig, constructor) => {
|
||||
const config = isConfig(nameOrConfig) ? nameOrConfig : string(nameOrConfig);
|
||||
return mapOrFail(config, a => constructor.either(a).pipe(Either.mapLeft(brandErrors => configError.InvalidData([], brandErrors.map(brandError => brandError.message).join("\n")))));
|
||||
});
|
||||
/** @internal */
|
||||
export const hashSet = (config, name) => {
|
||||
const newConfig = map(chunk(config), HashSet.fromIterable);
|
||||
return name === undefined ? newConfig : nested(newConfig, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const string = name => {
|
||||
const config = primitive("a text property", Either.right);
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const nonEmptyString = name => {
|
||||
const config = primitive("a non-empty text property", Either.liftPredicate(text => text.length > 0, () => configError.MissingData([], "Expected a non-empty string")));
|
||||
return name === undefined ? config : nested(config, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const all = arg => {
|
||||
if (Array.isArray(arg)) {
|
||||
return tuple(arg);
|
||||
} else if (Symbol.iterator in arg) {
|
||||
return tuple([...arg]);
|
||||
}
|
||||
return struct(arg);
|
||||
};
|
||||
const struct = r => {
|
||||
const entries = Object.entries(r);
|
||||
let result = pipe(entries[0][1], map(value => ({
|
||||
[entries[0][0]]: value
|
||||
})));
|
||||
if (entries.length === 1) {
|
||||
return result;
|
||||
}
|
||||
const rest = entries.slice(1);
|
||||
for (const [key, config] of rest) {
|
||||
result = pipe(result, zipWith(config, (record, value) => ({
|
||||
...record,
|
||||
[key]: value
|
||||
})));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/** @internal */
|
||||
export const succeed = value => {
|
||||
const constant = Object.create(proto);
|
||||
constant._tag = OpCodes.OP_CONSTANT;
|
||||
constant.value = value;
|
||||
constant.parse = () => Either.right(value);
|
||||
return constant;
|
||||
};
|
||||
/** @internal */
|
||||
export const suspend = config => {
|
||||
const lazy = Object.create(proto);
|
||||
lazy._tag = OpCodes.OP_LAZY;
|
||||
lazy.config = config;
|
||||
return lazy;
|
||||
};
|
||||
/** @internal */
|
||||
export const sync = value => {
|
||||
return suspend(() => succeed(value()));
|
||||
};
|
||||
/** @internal */
|
||||
export const hashMap = (config, name) => {
|
||||
const table = Object.create(proto);
|
||||
table._tag = OpCodes.OP_HASHMAP;
|
||||
table.valueConfig = config;
|
||||
return name === undefined ? table : nested(table, name);
|
||||
};
|
||||
/** @internal */
|
||||
export const isConfig = u => hasProperty(u, ConfigTypeId);
|
||||
/** @internal */
|
||||
const tuple = tuple => {
|
||||
if (tuple.length === 0) {
|
||||
return succeed([]);
|
||||
}
|
||||
if (tuple.length === 1) {
|
||||
return map(tuple[0], x => [x]);
|
||||
}
|
||||
let result = map(tuple[0], x => [x]);
|
||||
for (let i = 1; i < tuple.length; i++) {
|
||||
const config = tuple[i];
|
||||
result = pipe(result, zipWith(config, (tuple, value) => [...tuple, value]));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const unwrap = wrapped => {
|
||||
if (isConfig(wrapped)) {
|
||||
return wrapped;
|
||||
}
|
||||
return struct(Object.fromEntries(Object.entries(wrapped).map(([k, a]) => [k, unwrap(a)])));
|
||||
};
|
||||
/** @internal */
|
||||
export const validate = /*#__PURE__*/dual(2, (self, {
|
||||
message,
|
||||
validation
|
||||
}) => mapOrFail(self, a => {
|
||||
if (validation(a)) {
|
||||
return Either.right(a);
|
||||
}
|
||||
return Either.left(configError.InvalidData([], message));
|
||||
}));
|
||||
/** @internal */
|
||||
export const withDefault = /*#__PURE__*/dual(2, (self, def) => orElseIf(self, {
|
||||
orElse: () => succeed(def),
|
||||
if: ConfigError.isMissingDataOnly
|
||||
}));
|
||||
/** @internal */
|
||||
export const withDescription = /*#__PURE__*/dual(2, (self, description) => {
|
||||
const described = Object.create(proto);
|
||||
described._tag = OpCodes.OP_DESCRIBED;
|
||||
described.config = self;
|
||||
described.description = description;
|
||||
return described;
|
||||
});
|
||||
/** @internal */
|
||||
export const zip = /*#__PURE__*/dual(2, (self, that) => zipWith(self, that, (a, b) => [a, b]));
|
||||
/** @internal */
|
||||
export const zipWith = /*#__PURE__*/dual(3, (self, that, f) => {
|
||||
const zipWith = Object.create(proto);
|
||||
zipWith._tag = OpCodes.OP_ZIP_WITH;
|
||||
zipWith.left = self;
|
||||
zipWith.right = that;
|
||||
zipWith.zip = f;
|
||||
return zipWith;
|
||||
});
|
||||
//# sourceMappingURL=config.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/config.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/config.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
263
_node_modules/effect/dist/esm/internal/configError.js
generated
vendored
Normal file
263
_node_modules/effect/dist/esm/internal/configError.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
import * as RA from "../Array.js";
|
||||
import * as Either from "../Either.js";
|
||||
import { constFalse, constTrue, dual, pipe } from "../Function.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import * as OpCodes from "./opCodes/configError.js";
|
||||
/** @internal */
|
||||
const ConfigErrorSymbolKey = "effect/ConfigError";
|
||||
/** @internal */
|
||||
export const ConfigErrorTypeId = /*#__PURE__*/Symbol.for(ConfigErrorSymbolKey);
|
||||
/** @internal */
|
||||
export const proto = {
|
||||
_tag: "ConfigError",
|
||||
[ConfigErrorTypeId]: ConfigErrorTypeId
|
||||
};
|
||||
/** @internal */
|
||||
export const And = (self, that) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_AND;
|
||||
error.left = self;
|
||||
error.right = that;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
return `${this.left} and ${this.right}`;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(error, "message", {
|
||||
enumerable: false,
|
||||
get() {
|
||||
return this.toString();
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const Or = (self, that) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_OR;
|
||||
error.left = self;
|
||||
error.right = that;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
return `${this.left} or ${this.right}`;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(error, "message", {
|
||||
enumerable: false,
|
||||
get() {
|
||||
return this.toString();
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const InvalidData = (path, message, options = {
|
||||
pathDelim: "."
|
||||
}) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_INVALID_DATA;
|
||||
error.path = path;
|
||||
error.message = message;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
const path = pipe(this.path, RA.join(options.pathDelim));
|
||||
return `(Invalid data at ${path}: "${this.message}")`;
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const MissingData = (path, message, options = {
|
||||
pathDelim: "."
|
||||
}) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_MISSING_DATA;
|
||||
error.path = path;
|
||||
error.message = message;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
const path = pipe(this.path, RA.join(options.pathDelim));
|
||||
return `(Missing data at ${path}: "${this.message}")`;
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const SourceUnavailable = (path, message, cause, options = {
|
||||
pathDelim: "."
|
||||
}) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_SOURCE_UNAVAILABLE;
|
||||
error.path = path;
|
||||
error.message = message;
|
||||
error.cause = cause;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
const path = pipe(this.path, RA.join(options.pathDelim));
|
||||
return `(Source unavailable at ${path}: "${this.message}")`;
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const Unsupported = (path, message, options = {
|
||||
pathDelim: "."
|
||||
}) => {
|
||||
const error = Object.create(proto);
|
||||
error._op = OpCodes.OP_UNSUPPORTED;
|
||||
error.path = path;
|
||||
error.message = message;
|
||||
Object.defineProperty(error, "toString", {
|
||||
enumerable: false,
|
||||
value() {
|
||||
const path = pipe(this.path, RA.join(options.pathDelim));
|
||||
return `(Unsupported operation at ${path}: "${this.message}")`;
|
||||
}
|
||||
});
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const isConfigError = u => hasProperty(u, ConfigErrorTypeId);
|
||||
/** @internal */
|
||||
export const isAnd = self => self._op === OpCodes.OP_AND;
|
||||
/** @internal */
|
||||
export const isOr = self => self._op === OpCodes.OP_OR;
|
||||
/** @internal */
|
||||
export const isInvalidData = self => self._op === OpCodes.OP_INVALID_DATA;
|
||||
/** @internal */
|
||||
export const isMissingData = self => self._op === OpCodes.OP_MISSING_DATA;
|
||||
/** @internal */
|
||||
export const isSourceUnavailable = self => self._op === OpCodes.OP_SOURCE_UNAVAILABLE;
|
||||
/** @internal */
|
||||
export const isUnsupported = self => self._op === OpCodes.OP_UNSUPPORTED;
|
||||
/** @internal */
|
||||
export const prefixed = /*#__PURE__*/dual(2, (self, prefix) => {
|
||||
switch (self._op) {
|
||||
case OpCodes.OP_AND:
|
||||
{
|
||||
return And(prefixed(self.left, prefix), prefixed(self.right, prefix));
|
||||
}
|
||||
case OpCodes.OP_OR:
|
||||
{
|
||||
return Or(prefixed(self.left, prefix), prefixed(self.right, prefix));
|
||||
}
|
||||
case OpCodes.OP_INVALID_DATA:
|
||||
{
|
||||
return InvalidData([...prefix, ...self.path], self.message);
|
||||
}
|
||||
case OpCodes.OP_MISSING_DATA:
|
||||
{
|
||||
return MissingData([...prefix, ...self.path], self.message);
|
||||
}
|
||||
case OpCodes.OP_SOURCE_UNAVAILABLE:
|
||||
{
|
||||
return SourceUnavailable([...prefix, ...self.path], self.message, self.cause);
|
||||
}
|
||||
case OpCodes.OP_UNSUPPORTED:
|
||||
{
|
||||
return Unsupported([...prefix, ...self.path], self.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
const IsMissingDataOnlyReducer = {
|
||||
andCase: (_, left, right) => left && right,
|
||||
orCase: (_, left, right) => left && right,
|
||||
invalidDataCase: constFalse,
|
||||
missingDataCase: constTrue,
|
||||
sourceUnavailableCase: constFalse,
|
||||
unsupportedCase: constFalse
|
||||
};
|
||||
/** @internal */
|
||||
export const reduceWithContext = /*#__PURE__*/dual(3, (self, context, reducer) => {
|
||||
const input = [self];
|
||||
const output = [];
|
||||
while (input.length > 0) {
|
||||
const error = input.pop();
|
||||
switch (error._op) {
|
||||
case OpCodes.OP_AND:
|
||||
{
|
||||
input.push(error.right);
|
||||
input.push(error.left);
|
||||
output.push(Either.left({
|
||||
_op: "AndCase"
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_OR:
|
||||
{
|
||||
input.push(error.right);
|
||||
input.push(error.left);
|
||||
output.push(Either.left({
|
||||
_op: "OrCase"
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_INVALID_DATA:
|
||||
{
|
||||
output.push(Either.right(reducer.invalidDataCase(context, error.path, error.message)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_MISSING_DATA:
|
||||
{
|
||||
output.push(Either.right(reducer.missingDataCase(context, error.path, error.message)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_SOURCE_UNAVAILABLE:
|
||||
{
|
||||
output.push(Either.right(reducer.sourceUnavailableCase(context, error.path, error.message, error.cause)));
|
||||
break;
|
||||
}
|
||||
case OpCodes.OP_UNSUPPORTED:
|
||||
{
|
||||
output.push(Either.right(reducer.unsupportedCase(context, error.path, error.message)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const accumulator = [];
|
||||
while (output.length > 0) {
|
||||
const either = output.pop();
|
||||
switch (either._op) {
|
||||
case "Left":
|
||||
{
|
||||
switch (either.left._op) {
|
||||
case "AndCase":
|
||||
{
|
||||
const left = accumulator.pop();
|
||||
const right = accumulator.pop();
|
||||
const value = reducer.andCase(context, left, right);
|
||||
accumulator.push(value);
|
||||
break;
|
||||
}
|
||||
case "OrCase":
|
||||
{
|
||||
const left = accumulator.pop();
|
||||
const right = accumulator.pop();
|
||||
const value = reducer.orCase(context, left, right);
|
||||
accumulator.push(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
accumulator.push(either.right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accumulator.length === 0) {
|
||||
throw new Error("BUG: ConfigError.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
}
|
||||
return accumulator.pop();
|
||||
});
|
||||
/** @internal */
|
||||
export const isMissingDataOnly = self => reduceWithContext(self, void 0, IsMissingDataOnlyReducer);
|
||||
//# sourceMappingURL=configError.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/configError.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/configError.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
425
_node_modules/effect/dist/esm/internal/configProvider.js
generated
vendored
Normal file
425
_node_modules/effect/dist/esm/internal/configProvider.js
generated
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
import * as Arr from "../Array.js";
|
||||
import * as Context from "../Context.js";
|
||||
import * as Either from "../Either.js";
|
||||
import { dual, pipe } from "../Function.js";
|
||||
import * as HashMap from "../HashMap.js";
|
||||
import * as HashSet from "../HashSet.js";
|
||||
import * as number from "../Number.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import * as Predicate from "../Predicate.js";
|
||||
import * as regexp from "../RegExp.js";
|
||||
import * as configError from "./configError.js";
|
||||
import * as pathPatch from "./configProvider/pathPatch.js";
|
||||
import * as core from "./core.js";
|
||||
import * as OpCodes from "./opCodes/config.js";
|
||||
import * as StringUtils from "./string-utils.js";
|
||||
const concat = (l, r) => [...l, ...r];
|
||||
/** @internal */
|
||||
const ConfigProviderSymbolKey = "effect/ConfigProvider";
|
||||
/** @internal */
|
||||
export const ConfigProviderTypeId = /*#__PURE__*/Symbol.for(ConfigProviderSymbolKey);
|
||||
/** @internal */
|
||||
export const configProviderTag = /*#__PURE__*/Context.GenericTag("effect/ConfigProvider");
|
||||
/** @internal */
|
||||
const FlatConfigProviderSymbolKey = "effect/ConfigProviderFlat";
|
||||
/** @internal */
|
||||
export const FlatConfigProviderTypeId = /*#__PURE__*/Symbol.for(FlatConfigProviderSymbolKey);
|
||||
/** @internal */
|
||||
export const make = options => ({
|
||||
[ConfigProviderTypeId]: ConfigProviderTypeId,
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
},
|
||||
...options
|
||||
});
|
||||
/** @internal */
|
||||
export const makeFlat = options => ({
|
||||
[FlatConfigProviderTypeId]: FlatConfigProviderTypeId,
|
||||
patch: options.patch,
|
||||
load: (path, config, split = true) => options.load(path, config, split),
|
||||
enumerateChildren: options.enumerateChildren
|
||||
});
|
||||
/** @internal */
|
||||
export const fromFlat = flat => make({
|
||||
load: config => core.flatMap(fromFlatLoop(flat, Arr.empty(), config, false), chunk => Option.match(Arr.head(chunk), {
|
||||
onNone: () => core.fail(configError.MissingData(Arr.empty(), `Expected a single value having structure: ${config}`)),
|
||||
onSome: core.succeed
|
||||
})),
|
||||
flattened: flat
|
||||
});
|
||||
/** @internal */
|
||||
export const fromEnv = options => {
|
||||
const {
|
||||
pathDelim,
|
||||
seqDelim
|
||||
} = Object.assign({}, {
|
||||
pathDelim: "_",
|
||||
seqDelim: ","
|
||||
}, options);
|
||||
const makePathString = path => pipe(path, Arr.join(pathDelim));
|
||||
const unmakePathString = pathString => pathString.split(pathDelim);
|
||||
const getEnv = () => typeof process !== "undefined" && "env" in process && typeof process.env === "object" ? process.env : {};
|
||||
const load = (path, primitive, split = true) => {
|
||||
const pathString = makePathString(path);
|
||||
const current = getEnv();
|
||||
const valueOpt = pathString in current ? Option.some(current[pathString]) : Option.none();
|
||||
return pipe(valueOpt, core.mapError(() => configError.MissingData(path, `Expected ${pathString} to exist in the process context`)), core.flatMap(value => parsePrimitive(value, path, primitive, seqDelim, split)));
|
||||
};
|
||||
const enumerateChildren = path => core.sync(() => {
|
||||
const current = getEnv();
|
||||
const keys = Object.keys(current);
|
||||
const keyPaths = keys.map(value => unmakePathString(value.toUpperCase()));
|
||||
const filteredKeyPaths = keyPaths.filter(keyPath => {
|
||||
for (let i = 0; i < path.length; i++) {
|
||||
const pathComponent = pipe(path, Arr.unsafeGet(i));
|
||||
const currentElement = keyPath[i];
|
||||
if (currentElement === undefined || pathComponent !== currentElement) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).flatMap(keyPath => keyPath.slice(path.length, path.length + 1));
|
||||
return HashSet.fromIterable(filteredKeyPaths);
|
||||
});
|
||||
return fromFlat(makeFlat({
|
||||
load,
|
||||
enumerateChildren,
|
||||
patch: pathPatch.empty
|
||||
}));
|
||||
};
|
||||
/** @internal */
|
||||
export const fromMap = (map, config) => {
|
||||
const {
|
||||
pathDelim,
|
||||
seqDelim
|
||||
} = Object.assign({
|
||||
seqDelim: ",",
|
||||
pathDelim: "."
|
||||
}, config);
|
||||
const makePathString = path => pipe(path, Arr.join(pathDelim));
|
||||
const unmakePathString = pathString => pathString.split(pathDelim);
|
||||
const mapWithIndexSplit = splitIndexInKeys(map, str => unmakePathString(str), makePathString);
|
||||
const load = (path, primitive, split = true) => {
|
||||
const pathString = makePathString(path);
|
||||
const valueOpt = mapWithIndexSplit.has(pathString) ? Option.some(mapWithIndexSplit.get(pathString)) : Option.none();
|
||||
return pipe(valueOpt, core.mapError(() => configError.MissingData(path, `Expected ${pathString} to exist in the provided map`)), core.flatMap(value => parsePrimitive(value, path, primitive, seqDelim, split)));
|
||||
};
|
||||
const enumerateChildren = path => core.sync(() => {
|
||||
const keyPaths = Arr.fromIterable(mapWithIndexSplit.keys()).map(unmakePathString);
|
||||
const filteredKeyPaths = keyPaths.filter(keyPath => {
|
||||
for (let i = 0; i < path.length; i++) {
|
||||
const pathComponent = pipe(path, Arr.unsafeGet(i));
|
||||
const currentElement = keyPath[i];
|
||||
if (currentElement === undefined || pathComponent !== currentElement) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).flatMap(keyPath => keyPath.slice(path.length, path.length + 1));
|
||||
return HashSet.fromIterable(filteredKeyPaths);
|
||||
});
|
||||
return fromFlat(makeFlat({
|
||||
load,
|
||||
enumerateChildren,
|
||||
patch: pathPatch.empty
|
||||
}));
|
||||
};
|
||||
const extend = (leftDef, rightDef, left, right) => {
|
||||
const leftPad = Arr.unfold(left.length, index => index >= right.length ? Option.none() : Option.some([leftDef(index), index + 1]));
|
||||
const rightPad = Arr.unfold(right.length, index => index >= left.length ? Option.none() : Option.some([rightDef(index), index + 1]));
|
||||
const leftExtension = concat(left, leftPad);
|
||||
const rightExtension = concat(right, rightPad);
|
||||
return [leftExtension, rightExtension];
|
||||
};
|
||||
const appendConfigPath = (path, config) => {
|
||||
let op = config;
|
||||
if (op._tag === "Nested") {
|
||||
const out = path.slice();
|
||||
while (op._tag === "Nested") {
|
||||
out.push(op.name);
|
||||
op = op.config;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
const fromFlatLoop = (flat, prefix, config, split) => {
|
||||
const op = config;
|
||||
switch (op._tag) {
|
||||
case OpCodes.OP_CONSTANT:
|
||||
{
|
||||
return core.succeed(Arr.of(op.value));
|
||||
}
|
||||
case OpCodes.OP_DESCRIBED:
|
||||
{
|
||||
return core.suspend(() => fromFlatLoop(flat, prefix, op.config, split));
|
||||
}
|
||||
case OpCodes.OP_FAIL:
|
||||
{
|
||||
return core.fail(configError.MissingData(prefix, op.message));
|
||||
}
|
||||
case OpCodes.OP_FALLBACK:
|
||||
{
|
||||
return pipe(core.suspend(() => fromFlatLoop(flat, prefix, op.first, split)), core.catchAll(error1 => {
|
||||
if (op.condition(error1)) {
|
||||
return pipe(fromFlatLoop(flat, prefix, op.second, split), core.catchAll(error2 => core.fail(configError.Or(error1, error2))));
|
||||
}
|
||||
return core.fail(error1);
|
||||
}));
|
||||
}
|
||||
case OpCodes.OP_LAZY:
|
||||
{
|
||||
return core.suspend(() => fromFlatLoop(flat, prefix, op.config(), split));
|
||||
}
|
||||
case OpCodes.OP_MAP_OR_FAIL:
|
||||
{
|
||||
return core.suspend(() => pipe(fromFlatLoop(flat, prefix, op.original, split), core.flatMap(core.forEachSequential(a => pipe(op.mapOrFail(a), core.mapError(configError.prefixed(appendConfigPath(prefix, op.original))))))));
|
||||
}
|
||||
case OpCodes.OP_NESTED:
|
||||
{
|
||||
return core.suspend(() => fromFlatLoop(flat, concat(prefix, Arr.of(op.name)), op.config, split));
|
||||
}
|
||||
case OpCodes.OP_PRIMITIVE:
|
||||
{
|
||||
return pipe(pathPatch.patch(prefix, flat.patch), core.flatMap(prefix => pipe(flat.load(prefix, op, split), core.flatMap(values => {
|
||||
if (values.length === 0) {
|
||||
const name = pipe(Arr.last(prefix), Option.getOrElse(() => "<n/a>"));
|
||||
return core.fail(configError.MissingData([], `Expected ${op.description} with name ${name}`));
|
||||
}
|
||||
return core.succeed(values);
|
||||
}))));
|
||||
}
|
||||
case OpCodes.OP_SEQUENCE:
|
||||
{
|
||||
return pipe(pathPatch.patch(prefix, flat.patch), core.flatMap(patchedPrefix => pipe(flat.enumerateChildren(patchedPrefix), core.flatMap(indicesFrom), core.flatMap(indices => {
|
||||
if (indices.length === 0) {
|
||||
return core.suspend(() => core.map(fromFlatLoop(flat, prefix, op.config, true), Arr.of));
|
||||
}
|
||||
return pipe(core.forEachSequential(indices, index => fromFlatLoop(flat, Arr.append(prefix, `[${index}]`), op.config, true)), core.map(chunkChunk => {
|
||||
const flattened = Arr.flatten(chunkChunk);
|
||||
if (flattened.length === 0) {
|
||||
return Arr.of(Arr.empty());
|
||||
}
|
||||
return Arr.of(flattened);
|
||||
}));
|
||||
}))));
|
||||
}
|
||||
case OpCodes.OP_HASHMAP:
|
||||
{
|
||||
return core.suspend(() => pipe(pathPatch.patch(prefix, flat.patch), core.flatMap(prefix => pipe(flat.enumerateChildren(prefix), core.flatMap(keys => {
|
||||
return pipe(keys, core.forEachSequential(key => fromFlatLoop(flat, concat(prefix, Arr.of(key)), op.valueConfig, split)), core.map(matrix => {
|
||||
if (matrix.length === 0) {
|
||||
return Arr.of(HashMap.empty());
|
||||
}
|
||||
return pipe(transpose(matrix), Arr.map(values => HashMap.fromIterable(Arr.zip(Arr.fromIterable(keys), values))));
|
||||
}));
|
||||
})))));
|
||||
}
|
||||
case OpCodes.OP_ZIP_WITH:
|
||||
{
|
||||
return core.suspend(() => pipe(fromFlatLoop(flat, prefix, op.left, split), core.either, core.flatMap(left => pipe(fromFlatLoop(flat, prefix, op.right, split), core.either, core.flatMap(right => {
|
||||
if (Either.isLeft(left) && Either.isLeft(right)) {
|
||||
return core.fail(configError.And(left.left, right.left));
|
||||
}
|
||||
if (Either.isLeft(left) && Either.isRight(right)) {
|
||||
return core.fail(left.left);
|
||||
}
|
||||
if (Either.isRight(left) && Either.isLeft(right)) {
|
||||
return core.fail(right.left);
|
||||
}
|
||||
if (Either.isRight(left) && Either.isRight(right)) {
|
||||
const path = pipe(prefix, Arr.join("."));
|
||||
const fail = fromFlatLoopFail(prefix, path);
|
||||
const [lefts, rights] = extend(fail, fail, pipe(left.right, Arr.map(Either.right)), pipe(right.right, Arr.map(Either.right)));
|
||||
return pipe(lefts, Arr.zip(rights), core.forEachSequential(([left, right]) => pipe(core.zip(left, right), core.map(([left, right]) => op.zip(left, right)))));
|
||||
}
|
||||
throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
})))));
|
||||
}
|
||||
}
|
||||
};
|
||||
const fromFlatLoopFail = (prefix, path) => index => Either.left(configError.MissingData(prefix, `The element at index ${index} in a sequence at path "${path}" was missing`));
|
||||
/** @internal */
|
||||
export const mapInputPath = /*#__PURE__*/dual(2, (self, f) => fromFlat(mapInputPathFlat(self.flattened, f)));
|
||||
const mapInputPathFlat = (self, f) => makeFlat({
|
||||
load: (path, config, split = true) => self.load(path, config, split),
|
||||
enumerateChildren: path => self.enumerateChildren(path),
|
||||
patch: pathPatch.mapName(self.patch, f)
|
||||
});
|
||||
/** @internal */
|
||||
export const nested = /*#__PURE__*/dual(2, (self, name) => fromFlat(makeFlat({
|
||||
load: (path, config) => self.flattened.load(path, config, true),
|
||||
enumerateChildren: path => self.flattened.enumerateChildren(path),
|
||||
patch: pathPatch.nested(self.flattened.patch, name)
|
||||
})));
|
||||
/** @internal */
|
||||
export const unnested = /*#__PURE__*/dual(2, (self, name) => fromFlat(makeFlat({
|
||||
load: (path, config) => self.flattened.load(path, config, true),
|
||||
enumerateChildren: path => self.flattened.enumerateChildren(path),
|
||||
patch: pathPatch.unnested(self.flattened.patch, name)
|
||||
})));
|
||||
/** @internal */
|
||||
export const orElse = /*#__PURE__*/dual(2, (self, that) => fromFlat(orElseFlat(self.flattened, () => that().flattened)));
|
||||
const orElseFlat = (self, that) => makeFlat({
|
||||
load: (path, config, split) => pipe(pathPatch.patch(path, self.patch), core.flatMap(patch => self.load(patch, config, split)), core.catchAll(error1 => pipe(core.sync(that), core.flatMap(that => pipe(pathPatch.patch(path, that.patch), core.flatMap(patch => that.load(patch, config, split)), core.catchAll(error2 => core.fail(configError.Or(error1, error2)))))))),
|
||||
enumerateChildren: path => pipe(pathPatch.patch(path, self.patch), core.flatMap(patch => self.enumerateChildren(patch)), core.either, core.flatMap(left => pipe(core.sync(that), core.flatMap(that => pipe(pathPatch.patch(path, that.patch), core.flatMap(patch => that.enumerateChildren(patch)), core.either, core.flatMap(right => {
|
||||
if (Either.isLeft(left) && Either.isLeft(right)) {
|
||||
return core.fail(configError.And(left.left, right.left));
|
||||
}
|
||||
if (Either.isLeft(left) && Either.isRight(right)) {
|
||||
return core.succeed(right.right);
|
||||
}
|
||||
if (Either.isRight(left) && Either.isLeft(right)) {
|
||||
return core.succeed(left.right);
|
||||
}
|
||||
if (Either.isRight(left) && Either.isRight(right)) {
|
||||
return core.succeed(pipe(left.right, HashSet.union(right.right)));
|
||||
}
|
||||
throw new Error("BUG: ConfigProvider.orElseFlat - please report an issue at https://github.com/Effect-TS/effect/issues");
|
||||
})))))),
|
||||
patch: pathPatch.empty
|
||||
});
|
||||
/** @internal */
|
||||
export const constantCase = self => mapInputPath(self, StringUtils.constantCase);
|
||||
/** @internal */
|
||||
export const kebabCase = self => mapInputPath(self, StringUtils.kebabCase);
|
||||
/** @internal */
|
||||
export const lowerCase = self => mapInputPath(self, StringUtils.lowerCase);
|
||||
/** @internal */
|
||||
export const snakeCase = self => mapInputPath(self, StringUtils.snakeCase);
|
||||
/** @internal */
|
||||
export const upperCase = self => mapInputPath(self, StringUtils.upperCase);
|
||||
/** @internal */
|
||||
export const within = /*#__PURE__*/dual(3, (self, path, f) => {
|
||||
const unnest = Arr.reduce(path, self, (provider, name) => unnested(provider, name));
|
||||
const nest = Arr.reduceRight(path, f(unnest), (provider, name) => nested(provider, name));
|
||||
return orElse(nest, () => self);
|
||||
});
|
||||
const splitPathString = (text, delim) => {
|
||||
const split = text.split(new RegExp(`\\s*${regexp.escape(delim)}\\s*`));
|
||||
return split;
|
||||
};
|
||||
const parsePrimitive = (text, path, primitive, delimiter, split) => {
|
||||
if (!split) {
|
||||
return pipe(primitive.parse(text), core.mapBoth({
|
||||
onFailure: configError.prefixed(path),
|
||||
onSuccess: Arr.of
|
||||
}));
|
||||
}
|
||||
return pipe(splitPathString(text, delimiter), core.forEachSequential(char => primitive.parse(char.trim())), core.mapError(configError.prefixed(path)));
|
||||
};
|
||||
const transpose = array => {
|
||||
return Object.keys(array[0]).map(column => array.map(row => row[column]));
|
||||
};
|
||||
const indicesFrom = quotedIndices => pipe(core.forEachSequential(quotedIndices, parseQuotedIndex), core.mapBoth({
|
||||
onFailure: () => Arr.empty(),
|
||||
onSuccess: Arr.sort(number.Order)
|
||||
}), core.either, core.map(Either.merge));
|
||||
const STR_INDEX_REGEX = /(^.+)(\[(\d+)\])$/;
|
||||
const QUOTED_INDEX_REGEX = /^(\[(\d+)\])$/;
|
||||
const parseQuotedIndex = str => {
|
||||
const match = str.match(QUOTED_INDEX_REGEX);
|
||||
if (match !== null) {
|
||||
const matchedIndex = match[2];
|
||||
return pipe(matchedIndex !== undefined && matchedIndex.length > 0 ? Option.some(matchedIndex) : Option.none(), Option.flatMap(parseInteger));
|
||||
}
|
||||
return Option.none();
|
||||
};
|
||||
const splitIndexInKeys = (map, unmakePathString, makePathString) => {
|
||||
const newMap = new Map();
|
||||
for (const [pathString, value] of map) {
|
||||
const keyWithIndex = pipe(unmakePathString(pathString), Arr.flatMap(key => Option.match(splitIndexFrom(key), {
|
||||
onNone: () => Arr.of(key),
|
||||
onSome: ([key, index]) => Arr.make(key, `[${index}]`)
|
||||
})));
|
||||
newMap.set(makePathString(keyWithIndex), value);
|
||||
}
|
||||
return newMap;
|
||||
};
|
||||
const splitIndexFrom = key => {
|
||||
const match = key.match(STR_INDEX_REGEX);
|
||||
if (match !== null) {
|
||||
const matchedString = match[1];
|
||||
const matchedIndex = match[3];
|
||||
const optionalString = matchedString !== undefined && matchedString.length > 0 ? Option.some(matchedString) : Option.none();
|
||||
const optionalIndex = pipe(matchedIndex !== undefined && matchedIndex.length > 0 ? Option.some(matchedIndex) : Option.none(), Option.flatMap(parseInteger));
|
||||
return Option.all([optionalString, optionalIndex]);
|
||||
}
|
||||
return Option.none();
|
||||
};
|
||||
const parseInteger = str => {
|
||||
const parsedIndex = Number.parseInt(str);
|
||||
return Number.isNaN(parsedIndex) ? Option.none() : Option.some(parsedIndex);
|
||||
};
|
||||
const keyName = name => ({
|
||||
_tag: "KeyName",
|
||||
name
|
||||
});
|
||||
const keyIndex = index => ({
|
||||
_tag: "KeyIndex",
|
||||
index
|
||||
});
|
||||
/** @internal */
|
||||
export const fromJson = json => {
|
||||
const hiddenDelimiter = "\ufeff";
|
||||
const indexedEntries = Arr.map(getIndexedEntries(json), ([key, value]) => [configPathToString(key).join(hiddenDelimiter), value]);
|
||||
return fromMap(new Map(indexedEntries), {
|
||||
pathDelim: hiddenDelimiter,
|
||||
seqDelim: hiddenDelimiter
|
||||
});
|
||||
};
|
||||
const configPathToString = path => {
|
||||
const output = [];
|
||||
let i = 0;
|
||||
while (i < path.length) {
|
||||
const component = path[i];
|
||||
if (component._tag === "KeyName") {
|
||||
if (i + 1 < path.length) {
|
||||
const nextComponent = path[i + 1];
|
||||
if (nextComponent._tag === "KeyIndex") {
|
||||
output.push(`${component.name}[${nextComponent.index}]`);
|
||||
i += 2;
|
||||
} else {
|
||||
output.push(component.name);
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
output.push(component.name);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
const getIndexedEntries = config => {
|
||||
const loopAny = (path, value) => {
|
||||
if (typeof value === "string") {
|
||||
return Arr.make([path, value]);
|
||||
}
|
||||
if (typeof value === "number" || typeof value === "boolean") {
|
||||
return Arr.make([path, String(value)]);
|
||||
}
|
||||
if (Arr.isArray(value)) {
|
||||
return loopArray(path, value);
|
||||
}
|
||||
if (typeof value === "object" && value !== null) {
|
||||
return loopObject(path, value);
|
||||
}
|
||||
return Arr.empty();
|
||||
};
|
||||
const loopArray = (path, values) => Arr.match(values, {
|
||||
onEmpty: () => Arr.make([path, "<nil>"]),
|
||||
onNonEmpty: Arr.flatMap((value, index) => loopAny(Arr.append(path, keyIndex(index)), value))
|
||||
});
|
||||
const loopObject = (path, value) => Object.entries(value).filter(([, value]) => Predicate.isNotNullable(value)).flatMap(([key, value]) => {
|
||||
const newPath = Arr.append(path, keyName(key));
|
||||
const result = loopAny(newPath, value);
|
||||
if (Arr.isEmptyReadonlyArray(result)) {
|
||||
return Arr.make([newPath, ""]);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
return loopObject(Arr.empty(), config);
|
||||
};
|
||||
//# sourceMappingURL=configProvider.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/configProvider.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/configProvider.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
76
_node_modules/effect/dist/esm/internal/configProvider/pathPatch.js
generated
vendored
Normal file
76
_node_modules/effect/dist/esm/internal/configProvider/pathPatch.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import * as RA from "../../Array.js";
|
||||
import * as Either from "../../Either.js";
|
||||
import { dual, pipe } from "../../Function.js";
|
||||
import * as List from "../../List.js";
|
||||
import * as Option from "../../Option.js";
|
||||
import * as configError from "../configError.js";
|
||||
/** @internal */
|
||||
export const empty = {
|
||||
_tag: "Empty"
|
||||
};
|
||||
/** @internal */
|
||||
export const andThen = /*#__PURE__*/dual(2, (self, that) => ({
|
||||
_tag: "AndThen",
|
||||
first: self,
|
||||
second: that
|
||||
}));
|
||||
/** @internal */
|
||||
export const mapName = /*#__PURE__*/dual(2, (self, f) => andThen(self, {
|
||||
_tag: "MapName",
|
||||
f
|
||||
}));
|
||||
/** @internal */
|
||||
export const nested = /*#__PURE__*/dual(2, (self, name) => andThen(self, {
|
||||
_tag: "Nested",
|
||||
name
|
||||
}));
|
||||
/** @internal */
|
||||
export const unnested = /*#__PURE__*/dual(2, (self, name) => andThen(self, {
|
||||
_tag: "Unnested",
|
||||
name
|
||||
}));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/dual(2, (path, patch) => {
|
||||
let input = List.of(patch);
|
||||
let output = path;
|
||||
while (List.isCons(input)) {
|
||||
const patch = input.head;
|
||||
switch (patch._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
input = input.tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
input = List.cons(patch.first, List.cons(patch.second, input.tail));
|
||||
break;
|
||||
}
|
||||
case "MapName":
|
||||
{
|
||||
output = RA.map(output, patch.f);
|
||||
input = input.tail;
|
||||
break;
|
||||
}
|
||||
case "Nested":
|
||||
{
|
||||
output = RA.prepend(output, patch.name);
|
||||
input = input.tail;
|
||||
break;
|
||||
}
|
||||
case "Unnested":
|
||||
{
|
||||
const containsName = pipe(RA.head(output), Option.contains(patch.name));
|
||||
if (containsName) {
|
||||
output = RA.tailNonEmpty(output);
|
||||
input = input.tail;
|
||||
} else {
|
||||
return Either.left(configError.MissingData(output, `Expected ${patch.name} to be in path in ConfigProvider#unnested`));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Either.right(output);
|
||||
});
|
||||
//# sourceMappingURL=pathPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/configProvider/pathPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/configProvider/pathPatch.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pathPatch.js","names":["RA","Either","dual","pipe","List","Option","configError","empty","_tag","andThen","self","that","first","second","mapName","f","nested","name","unnested","patch","path","input","of","output","isCons","head","tail","cons","map","prepend","containsName","contains","tailNonEmpty","left","MissingData","right"],"sources":["../../../../src/internal/configProvider/pathPatch.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
54
_node_modules/effect/dist/esm/internal/console.js
generated
vendored
Normal file
54
_node_modules/effect/dist/esm/internal/console.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import * as Context from "../Context.js";
|
||||
import { dual } from "../Function.js";
|
||||
import * as core from "./core.js";
|
||||
import * as defaultServices from "./defaultServices.js";
|
||||
import * as defaultConsole from "./defaultServices/console.js";
|
||||
import * as fiberRuntime from "./fiberRuntime.js";
|
||||
import * as layer from "./layer.js";
|
||||
/** @internal */
|
||||
export const console = /*#__PURE__*/core.map(/*#__PURE__*/core.fiberRefGet(defaultServices.currentServices), /*#__PURE__*/Context.get(defaultConsole.consoleTag));
|
||||
/** @internal */
|
||||
export const consoleWith = f => core.fiberRefGetWith(defaultServices.currentServices, services => f(Context.get(services, defaultConsole.consoleTag)));
|
||||
/** @internal */
|
||||
export const withConsole = /*#__PURE__*/dual(2, (effect, value) => core.fiberRefLocallyWith(effect, defaultServices.currentServices, Context.add(defaultConsole.consoleTag, value)));
|
||||
/** @internal */
|
||||
export const withConsoleScoped = console => fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(defaultConsole.consoleTag, console));
|
||||
/** @internal */
|
||||
export const setConsole = console => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(defaultConsole.consoleTag, console)));
|
||||
/** @internal */
|
||||
export const assert = (condition, ...args) => consoleWith(_ => _.assert(condition, ...args));
|
||||
/** @internal */
|
||||
export const clear = /*#__PURE__*/consoleWith(_ => _.clear);
|
||||
/** @internal */
|
||||
export const count = label => consoleWith(_ => _.count(label));
|
||||
/** @internal */
|
||||
export const countReset = label => consoleWith(_ => _.countReset(label));
|
||||
/** @internal */
|
||||
export const debug = (...args) => consoleWith(_ => _.debug(...args));
|
||||
/** @internal */
|
||||
export const dir = (item, options) => consoleWith(_ => _.dir(item, options));
|
||||
/** @internal */
|
||||
export const dirxml = (...args) => consoleWith(_ => _.dirxml(...args));
|
||||
/** @internal */
|
||||
export const error = (...args) => consoleWith(_ => _.error(...args));
|
||||
/** @internal */
|
||||
export const group = options => consoleWith(_ => fiberRuntime.acquireRelease(_.group(options), () => _.groupEnd));
|
||||
/** @internal */
|
||||
export const info = (...args) => consoleWith(_ => _.info(...args));
|
||||
/** @internal */
|
||||
export const log = (...args) => consoleWith(_ => _.log(...args));
|
||||
/** @internal */
|
||||
export const table = (tabularData, properties) => consoleWith(_ => _.table(tabularData, properties));
|
||||
/** @internal */
|
||||
export const time = label => consoleWith(_ => fiberRuntime.acquireRelease(_.time(label), () => _.timeEnd(label)));
|
||||
/** @internal */
|
||||
export const timeLog = (label, ...args) => consoleWith(_ => _.timeLog(label, ...args));
|
||||
/** @internal */
|
||||
export const trace = (...args) => consoleWith(_ => _.trace(...args));
|
||||
/** @internal */
|
||||
export const warn = (...args) => consoleWith(_ => _.warn(...args));
|
||||
/** @internal */
|
||||
export const withGroup = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, options) => consoleWith(_ => core.acquireUseRelease(_.group(options), () => self, () => _.groupEnd)));
|
||||
/** @internal */
|
||||
export const withTime = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, label) => consoleWith(_ => core.acquireUseRelease(_.time(label), () => self, () => _.timeEnd(label))));
|
||||
//# sourceMappingURL=console.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/console.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/console.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"console.js","names":["Context","dual","core","defaultServices","defaultConsole","fiberRuntime","layer","console","map","fiberRefGet","currentServices","get","consoleTag","consoleWith","f","fiberRefGetWith","services","withConsole","effect","value","fiberRefLocallyWith","add","withConsoleScoped","fiberRefLocallyScopedWith","setConsole","scopedDiscard","assert","condition","args","_","clear","count","label","countReset","debug","dir","item","options","dirxml","error","group","acquireRelease","groupEnd","info","log","table","tabularData","properties","time","timeEnd","timeLog","trace","warn","withGroup","isEffect","self","acquireUseRelease","withTime"],"sources":["../../../src/internal/console.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
253
_node_modules/effect/dist/esm/internal/context.js
generated
vendored
Normal file
253
_node_modules/effect/dist/esm/internal/context.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
import * as Equal from "../Equal.js";
|
||||
import { dual } from "../Function.js";
|
||||
import { globalValue } from "../GlobalValue.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import { EffectPrototype, effectVariance } from "./effectable.js";
|
||||
import * as option from "./option.js";
|
||||
/** @internal */
|
||||
export const TagTypeId = /*#__PURE__*/Symbol.for("effect/Context/Tag");
|
||||
/** @internal */
|
||||
export const ReferenceTypeId = /*#__PURE__*/Symbol.for("effect/Context/Reference");
|
||||
/** @internal */
|
||||
const STMSymbolKey = "effect/STM";
|
||||
/** @internal */
|
||||
export const STMTypeId = /*#__PURE__*/Symbol.for(STMSymbolKey);
|
||||
/** @internal */
|
||||
export const TagProto = {
|
||||
...EffectPrototype,
|
||||
_op: "Tag",
|
||||
[STMTypeId]: effectVariance,
|
||||
[TagTypeId]: {
|
||||
_Service: _ => _,
|
||||
_Identifier: _ => _
|
||||
},
|
||||
toString() {
|
||||
return format(this.toJSON());
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "Tag",
|
||||
key: this.key,
|
||||
stack: this.stack
|
||||
};
|
||||
},
|
||||
[NodeInspectSymbol]() {
|
||||
return this.toJSON();
|
||||
},
|
||||
of(self) {
|
||||
return self;
|
||||
},
|
||||
context(self) {
|
||||
return make(this, self);
|
||||
}
|
||||
};
|
||||
export const ReferenceProto = {
|
||||
...TagProto,
|
||||
[ReferenceTypeId]: ReferenceTypeId
|
||||
};
|
||||
/** @internal */
|
||||
export const makeGenericTag = key => {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 2;
|
||||
const creationError = new Error();
|
||||
Error.stackTraceLimit = limit;
|
||||
const tag = Object.create(TagProto);
|
||||
Object.defineProperty(tag, "stack", {
|
||||
get() {
|
||||
return creationError.stack;
|
||||
}
|
||||
});
|
||||
tag.key = key;
|
||||
return tag;
|
||||
};
|
||||
/** @internal */
|
||||
export const Tag = id => () => {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 2;
|
||||
const creationError = new Error();
|
||||
Error.stackTraceLimit = limit;
|
||||
function TagClass() {}
|
||||
Object.setPrototypeOf(TagClass, TagProto);
|
||||
TagClass.key = id;
|
||||
Object.defineProperty(TagClass, "stack", {
|
||||
get() {
|
||||
return creationError.stack;
|
||||
}
|
||||
});
|
||||
return TagClass;
|
||||
};
|
||||
/** @internal */
|
||||
export const Reference = () => (id, options) => {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 2;
|
||||
const creationError = new Error();
|
||||
Error.stackTraceLimit = limit;
|
||||
function ReferenceClass() {}
|
||||
Object.setPrototypeOf(ReferenceClass, ReferenceProto);
|
||||
ReferenceClass.key = id;
|
||||
ReferenceClass.defaultValue = options.defaultValue;
|
||||
Object.defineProperty(ReferenceClass, "stack", {
|
||||
get() {
|
||||
return creationError.stack;
|
||||
}
|
||||
});
|
||||
return ReferenceClass;
|
||||
};
|
||||
/** @internal */
|
||||
export const TypeId = /*#__PURE__*/Symbol.for("effect/Context");
|
||||
/** @internal */
|
||||
export const ContextProto = {
|
||||
[TypeId]: {
|
||||
_Services: _ => _
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
if (isContext(that)) {
|
||||
if (this.unsafeMap.size === that.unsafeMap.size) {
|
||||
for (const k of this.unsafeMap.keys()) {
|
||||
if (!that.unsafeMap.has(k) || !Equal.equals(this.unsafeMap.get(k), that.unsafeMap.get(k))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.number(this.unsafeMap.size));
|
||||
},
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
},
|
||||
toString() {
|
||||
return format(this.toJSON());
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "Context",
|
||||
services: Array.from(this.unsafeMap).map(toJSON)
|
||||
};
|
||||
},
|
||||
[NodeInspectSymbol]() {
|
||||
return this.toJSON();
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const makeContext = unsafeMap => {
|
||||
const context = Object.create(ContextProto);
|
||||
context.unsafeMap = unsafeMap;
|
||||
return context;
|
||||
};
|
||||
const serviceNotFoundError = tag => {
|
||||
const error = new Error(`Service not found${tag.key ? `: ${String(tag.key)}` : ""}`);
|
||||
if (tag.stack) {
|
||||
const lines = tag.stack.split("\n");
|
||||
if (lines.length > 2) {
|
||||
const afterAt = lines[2].match(/at (.*)/);
|
||||
if (afterAt) {
|
||||
error.message = error.message + ` (defined at ${afterAt[1]})`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error.stack) {
|
||||
const lines = error.stack.split("\n");
|
||||
lines.splice(1, 3);
|
||||
error.stack = lines.join("\n");
|
||||
}
|
||||
return error;
|
||||
};
|
||||
/** @internal */
|
||||
export const isContext = u => hasProperty(u, TypeId);
|
||||
/** @internal */
|
||||
export const isTag = u => hasProperty(u, TagTypeId);
|
||||
/** @internal */
|
||||
export const isReference = u => hasProperty(u, ReferenceTypeId);
|
||||
const _empty = /*#__PURE__*/makeContext(/*#__PURE__*/new Map());
|
||||
/** @internal */
|
||||
export const empty = () => _empty;
|
||||
/** @internal */
|
||||
export const make = (tag, service) => makeContext(new Map([[tag.key, service]]));
|
||||
/** @internal */
|
||||
export const add = /*#__PURE__*/dual(3, (self, tag, service) => {
|
||||
const map = new Map(self.unsafeMap);
|
||||
map.set(tag.key, service);
|
||||
return makeContext(map);
|
||||
});
|
||||
const defaultValueCache = /*#__PURE__*/globalValue("effect/Context/defaultValueCache", () => new Map());
|
||||
const getDefaultValue = tag => {
|
||||
if (defaultValueCache.has(tag.key)) {
|
||||
return defaultValueCache.get(tag.key);
|
||||
}
|
||||
const value = tag.defaultValue();
|
||||
defaultValueCache.set(tag.key, value);
|
||||
return value;
|
||||
};
|
||||
/** @internal */
|
||||
export const unsafeGetReference = (self, tag) => {
|
||||
return self.unsafeMap.has(tag.key) ? self.unsafeMap.get(tag.key) : getDefaultValue(tag);
|
||||
};
|
||||
/** @internal */
|
||||
export const unsafeGet = /*#__PURE__*/dual(2, (self, tag) => {
|
||||
if (!self.unsafeMap.has(tag.key)) {
|
||||
if (ReferenceTypeId in tag) return getDefaultValue(tag);
|
||||
throw serviceNotFoundError(tag);
|
||||
}
|
||||
return self.unsafeMap.get(tag.key);
|
||||
});
|
||||
/** @internal */
|
||||
export const get = unsafeGet;
|
||||
/** @internal */
|
||||
export const getOrElse = /*#__PURE__*/dual(3, (self, tag, orElse) => {
|
||||
if (!self.unsafeMap.has(tag.key)) {
|
||||
return isReference(tag) ? getDefaultValue(tag) : orElse();
|
||||
}
|
||||
return self.unsafeMap.get(tag.key);
|
||||
});
|
||||
/** @internal */
|
||||
export const getOption = /*#__PURE__*/dual(2, (self, tag) => {
|
||||
if (!self.unsafeMap.has(tag.key)) {
|
||||
return isReference(tag) ? option.some(getDefaultValue(tag)) : option.none;
|
||||
}
|
||||
return option.some(self.unsafeMap.get(tag.key));
|
||||
});
|
||||
/** @internal */
|
||||
export const merge = /*#__PURE__*/dual(2, (self, that) => {
|
||||
const map = new Map(self.unsafeMap);
|
||||
for (const [tag, s] of that.unsafeMap) {
|
||||
map.set(tag, s);
|
||||
}
|
||||
return makeContext(map);
|
||||
});
|
||||
/** @internal */
|
||||
export const mergeAll = (...ctxs) => {
|
||||
const map = new Map();
|
||||
for (const ctx of ctxs) {
|
||||
for (const [tag, s] of ctx.unsafeMap) {
|
||||
map.set(tag, s);
|
||||
}
|
||||
}
|
||||
return makeContext(map);
|
||||
};
|
||||
/** @internal */
|
||||
export const pick = (...tags) => self => {
|
||||
const tagSet = new Set(tags.map(_ => _.key));
|
||||
const newEnv = new Map();
|
||||
for (const [tag, s] of self.unsafeMap.entries()) {
|
||||
if (tagSet.has(tag)) {
|
||||
newEnv.set(tag, s);
|
||||
}
|
||||
}
|
||||
return makeContext(newEnv);
|
||||
};
|
||||
/** @internal */
|
||||
export const omit = (...tags) => self => {
|
||||
const newEnv = new Map(self.unsafeMap);
|
||||
for (const tag of tags) {
|
||||
newEnv.delete(tag.key);
|
||||
}
|
||||
return makeContext(newEnv);
|
||||
};
|
||||
//# sourceMappingURL=context.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/context.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/context.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
811
_node_modules/effect/dist/esm/internal/core-effect.js
generated
vendored
Normal file
811
_node_modules/effect/dist/esm/internal/core-effect.js
generated
vendored
Normal file
@@ -0,0 +1,811 @@
|
||||
import * as Arr from "../Array.js";
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Clock from "../Clock.js";
|
||||
import * as Context from "../Context.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import * as FiberRefs from "../FiberRefs.js";
|
||||
import { constFalse, constTrue, constVoid, dual, identity, pipe } from "../Function.js";
|
||||
import * as HashMap from "../HashMap.js";
|
||||
import * as HashSet from "../HashSet.js";
|
||||
import * as List from "../List.js";
|
||||
import * as LogLevel from "../LogLevel.js";
|
||||
import * as LogSpan from "../LogSpan.js";
|
||||
import * as Option from "../Option.js";
|
||||
import * as Predicate from "../Predicate.js";
|
||||
import * as Ref from "../Ref.js";
|
||||
import * as Tracer from "../Tracer.js";
|
||||
import { internalCall } from "../Utils.js";
|
||||
import * as internalCause from "./cause.js";
|
||||
import { clockTag } from "./clock.js";
|
||||
import * as core from "./core.js";
|
||||
import * as defaultServices from "./defaultServices.js";
|
||||
import * as doNotation from "./doNotation.js";
|
||||
import * as fiberRefsPatch from "./fiberRefs/patch.js";
|
||||
import * as metricLabel from "./metric/label.js";
|
||||
import * as runtimeFlags from "./runtimeFlags.js";
|
||||
import * as internalTracer from "./tracer.js";
|
||||
/* @internal */
|
||||
export const annotateLogs = /*#__PURE__*/dual(args => core.isEffect(args[0]), function () {
|
||||
const args = arguments;
|
||||
return core.fiberRefLocallyWith(args[0], core.currentLogAnnotations, typeof args[1] === "string" ? HashMap.set(args[1], args[2]) : annotations => Object.entries(args[1]).reduce((acc, [key, value]) => HashMap.set(acc, key, value), annotations));
|
||||
});
|
||||
/* @internal */
|
||||
export const asSome = self => core.map(self, Option.some);
|
||||
/* @internal */
|
||||
export const asSomeError = self => core.mapError(self, Option.some);
|
||||
/* @internal */
|
||||
export const try_ = arg => {
|
||||
let evaluate;
|
||||
let onFailure = undefined;
|
||||
if (typeof arg === "function") {
|
||||
evaluate = arg;
|
||||
} else {
|
||||
evaluate = arg.try;
|
||||
onFailure = arg.catch;
|
||||
}
|
||||
return core.suspend(() => {
|
||||
try {
|
||||
return core.succeed(internalCall(evaluate));
|
||||
} catch (error) {
|
||||
return core.fail(onFailure ? internalCall(() => onFailure(error)) : new core.UnknownException(error, "An unknown error occurred in Effect.try"));
|
||||
}
|
||||
});
|
||||
};
|
||||
/* @internal */
|
||||
export const _catch = /*#__PURE__*/dual(3, (self, tag, options) => core.catchAll(self, e => {
|
||||
if (Predicate.hasProperty(e, tag) && e[tag] === options.failure) {
|
||||
return options.onFailure(e);
|
||||
}
|
||||
return core.fail(e);
|
||||
}));
|
||||
/* @internal */
|
||||
export const catchAllDefect = /*#__PURE__*/dual(2, (self, f) => core.catchAllCause(self, cause => {
|
||||
const option = internalCause.find(cause, _ => internalCause.isDieType(_) ? Option.some(_) : Option.none());
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
return core.failCause(cause);
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
return f(option.value.defect);
|
||||
}
|
||||
}
|
||||
}));
|
||||
/* @internal */
|
||||
export const catchSomeCause = /*#__PURE__*/dual(2, (self, f) => core.matchCauseEffect(self, {
|
||||
onFailure: cause => {
|
||||
const option = f(cause);
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
return core.failCause(cause);
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
return option.value;
|
||||
}
|
||||
}
|
||||
},
|
||||
onSuccess: core.succeed
|
||||
}));
|
||||
/* @internal */
|
||||
export const catchSomeDefect = /*#__PURE__*/dual(2, (self, pf) => core.catchAllCause(self, cause => {
|
||||
const option = internalCause.find(cause, _ => internalCause.isDieType(_) ? Option.some(_) : Option.none());
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
return core.failCause(cause);
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
const optionEffect = pf(option.value.defect);
|
||||
return optionEffect._tag === "Some" ? optionEffect.value : core.failCause(cause);
|
||||
}
|
||||
}
|
||||
}));
|
||||
/* @internal */
|
||||
export const catchTag = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, ...args) => {
|
||||
const f = args[args.length - 1];
|
||||
let predicate;
|
||||
if (args.length === 2) {
|
||||
predicate = Predicate.isTagged(args[0]);
|
||||
} else {
|
||||
predicate = e => {
|
||||
const tag = Predicate.hasProperty(e, "_tag") ? e["_tag"] : undefined;
|
||||
if (!tag) return false;
|
||||
for (let i = 0; i < args.length - 1; i++) {
|
||||
if (args[i] === tag) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return core.catchIf(self, predicate, f);
|
||||
});
|
||||
/** @internal */
|
||||
export const catchTags = /*#__PURE__*/dual(2, (self, cases) => {
|
||||
let keys;
|
||||
return core.catchIf(self, e => {
|
||||
keys ??= Object.keys(cases);
|
||||
return Predicate.hasProperty(e, "_tag") && Predicate.isString(e["_tag"]) && keys.includes(e["_tag"]);
|
||||
}, e => cases[e["_tag"]](e));
|
||||
});
|
||||
/* @internal */
|
||||
export const cause = self => core.matchCause(self, {
|
||||
onFailure: identity,
|
||||
onSuccess: () => internalCause.empty
|
||||
});
|
||||
/* @internal */
|
||||
export const clockWith = Clock.clockWith;
|
||||
/* @internal */
|
||||
export const clock = /*#__PURE__*/clockWith(core.succeed);
|
||||
/* @internal */
|
||||
export const delay = /*#__PURE__*/dual(2, (self, duration) => core.zipRight(Clock.sleep(duration), self));
|
||||
/* @internal */
|
||||
export const descriptorWith = f => core.withFiberRuntime((state, status) => f({
|
||||
id: state.id(),
|
||||
status,
|
||||
interruptors: internalCause.interruptors(state.getFiberRef(core.currentInterruptedCause))
|
||||
}));
|
||||
/* @internal */
|
||||
export const allowInterrupt = /*#__PURE__*/descriptorWith(descriptor => HashSet.size(descriptor.interruptors) > 0 ? core.interrupt : core.void);
|
||||
/* @internal */
|
||||
export const descriptor = /*#__PURE__*/descriptorWith(core.succeed);
|
||||
/* @internal */
|
||||
export const diffFiberRefs = self => summarized(self, fiberRefs, fiberRefsPatch.diff);
|
||||
/* @internal */
|
||||
export const diffFiberRefsAndRuntimeFlags = self => summarized(self, core.zip(fiberRefs, core.runtimeFlags), ([refs, flags], [refsNew, flagsNew]) => [fiberRefsPatch.diff(refs, refsNew), runtimeFlags.diff(flags, flagsNew)]);
|
||||
/* @internal */
|
||||
export const Do = /*#__PURE__*/core.succeed({});
|
||||
/* @internal */
|
||||
export const bind = /*#__PURE__*/doNotation.bind(core.map, core.flatMap);
|
||||
/* @internal */
|
||||
export const bindTo = /*#__PURE__*/doNotation.bindTo(core.map);
|
||||
/* @internal */
|
||||
export const let_ = /*#__PURE__*/doNotation.let_(core.map);
|
||||
/* @internal */
|
||||
export const dropUntil = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const builder = [];
|
||||
let next;
|
||||
let dropping = core.succeed(false);
|
||||
let i = 0;
|
||||
while ((next = iterator.next()) && !next.done) {
|
||||
const a = next.value;
|
||||
const index = i++;
|
||||
dropping = core.flatMap(dropping, bool => {
|
||||
if (bool) {
|
||||
builder.push(a);
|
||||
return core.succeed(true);
|
||||
}
|
||||
return predicate(a, index);
|
||||
});
|
||||
}
|
||||
return core.map(dropping, () => builder);
|
||||
}));
|
||||
/* @internal */
|
||||
export const dropWhile = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const builder = [];
|
||||
let next;
|
||||
let dropping = core.succeed(true);
|
||||
let i = 0;
|
||||
while ((next = iterator.next()) && !next.done) {
|
||||
const a = next.value;
|
||||
const index = i++;
|
||||
dropping = core.flatMap(dropping, d => core.map(d ? predicate(a, index) : core.succeed(false), b => {
|
||||
if (!b) {
|
||||
builder.push(a);
|
||||
}
|
||||
return b;
|
||||
}));
|
||||
}
|
||||
return core.map(dropping, () => builder);
|
||||
}));
|
||||
/* @internal */
|
||||
export const contextWith = f => core.map(core.context(), f);
|
||||
/* @internal */
|
||||
export const eventually = self => core.orElse(self, () => core.flatMap(core.yieldNow(), () => eventually(self)));
|
||||
/* @internal */
|
||||
export const filterMap = /*#__PURE__*/dual(2, (elements, pf) => core.map(core.forEachSequential(elements, identity), Arr.filterMap(pf)));
|
||||
/* @internal */
|
||||
export const filterOrDie = /*#__PURE__*/dual(3, (self, predicate, orDieWith) => filterOrElse(self, predicate, a => core.dieSync(() => orDieWith(a))));
|
||||
/* @internal */
|
||||
export const filterOrDieMessage = /*#__PURE__*/dual(3, (self, predicate, message) => filterOrElse(self, predicate, () => core.dieMessage(message)));
|
||||
/* @internal */
|
||||
export const filterOrElse = /*#__PURE__*/dual(3, (self, predicate, orElse) => core.flatMap(self, a => predicate(a) ? core.succeed(a) : orElse(a)));
|
||||
/** @internal */
|
||||
export const liftPredicate = /*#__PURE__*/dual(3, (self, predicate, orFailWith) => core.suspend(() => predicate(self) ? core.succeed(self) : core.fail(orFailWith(self))));
|
||||
/* @internal */
|
||||
export const filterOrFail = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, a => orFailWith === undefined ? core.fail(new core.NoSuchElementException()) : core.failSync(() => orFailWith(a))));
|
||||
/* @internal */
|
||||
export const findFirst = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const next = iterator.next();
|
||||
if (!next.done) {
|
||||
return findLoop(iterator, 0, predicate, next.value);
|
||||
}
|
||||
return core.succeed(Option.none());
|
||||
}));
|
||||
const findLoop = (iterator, index, f, value) => core.flatMap(f(value, index), result => {
|
||||
if (result) {
|
||||
return core.succeed(Option.some(value));
|
||||
}
|
||||
const next = iterator.next();
|
||||
if (!next.done) {
|
||||
return findLoop(iterator, index + 1, f, next.value);
|
||||
}
|
||||
return core.succeed(Option.none());
|
||||
});
|
||||
/* @internal */
|
||||
export const firstSuccessOf = effects => core.suspend(() => {
|
||||
const list = Chunk.fromIterable(effects);
|
||||
if (!Chunk.isNonEmpty(list)) {
|
||||
return core.dieSync(() => new core.IllegalArgumentException(`Received an empty collection of effects`));
|
||||
}
|
||||
return pipe(Chunk.tailNonEmpty(list), Arr.reduce(Chunk.headNonEmpty(list), (left, right) => core.orElse(left, () => right)));
|
||||
});
|
||||
/* @internal */
|
||||
export const flipWith = /*#__PURE__*/dual(2, (self, f) => core.flip(f(core.flip(self))));
|
||||
/* @internal */
|
||||
export const match = /*#__PURE__*/dual(2, (self, options) => core.matchEffect(self, {
|
||||
onFailure: e => core.succeed(options.onFailure(e)),
|
||||
onSuccess: a => core.succeed(options.onSuccess(a))
|
||||
}));
|
||||
/* @internal */
|
||||
export const every = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => forAllLoop(elements[Symbol.iterator](), 0, predicate)));
|
||||
const forAllLoop = (iterator, index, f) => {
|
||||
const next = iterator.next();
|
||||
return next.done ? core.succeed(true) : core.flatMap(f(next.value, index), b => b ? forAllLoop(iterator, index + 1, f) : core.succeed(b));
|
||||
};
|
||||
/* @internal */
|
||||
export const forever = self => {
|
||||
const loop = core.flatMap(core.flatMap(self, () => core.yieldNow()), () => loop);
|
||||
return loop;
|
||||
};
|
||||
/* @internal */
|
||||
export const fiberRefs = /*#__PURE__*/core.withFiberRuntime(state => core.succeed(state.getFiberRefs()));
|
||||
/* @internal */
|
||||
export const head = self => core.flatMap(self, as => {
|
||||
const iterator = as[Symbol.iterator]();
|
||||
const next = iterator.next();
|
||||
if (next.done) {
|
||||
return core.fail(new core.NoSuchElementException());
|
||||
}
|
||||
return core.succeed(next.value);
|
||||
});
|
||||
/* @internal */
|
||||
export const ignore = self => match(self, {
|
||||
onFailure: constVoid,
|
||||
onSuccess: constVoid
|
||||
});
|
||||
/* @internal */
|
||||
export const ignoreLogged = self => core.matchCauseEffect(self, {
|
||||
onFailure: cause => logDebug(cause, "An error was silently ignored because it is not anticipated to be useful"),
|
||||
onSuccess: () => core.void
|
||||
});
|
||||
/* @internal */
|
||||
export const inheritFiberRefs = childFiberRefs => updateFiberRefs((parentFiberId, parentFiberRefs) => FiberRefs.joinAs(parentFiberRefs, parentFiberId, childFiberRefs));
|
||||
/* @internal */
|
||||
export const isFailure = self => match(self, {
|
||||
onFailure: constTrue,
|
||||
onSuccess: constFalse
|
||||
});
|
||||
/* @internal */
|
||||
export const isSuccess = self => match(self, {
|
||||
onFailure: constFalse,
|
||||
onSuccess: constTrue
|
||||
});
|
||||
/* @internal */
|
||||
export const iterate = (initial, options) => core.suspend(() => {
|
||||
if (options.while(initial)) {
|
||||
return core.flatMap(options.body(initial), z2 => iterate(z2, options));
|
||||
}
|
||||
return core.succeed(initial);
|
||||
});
|
||||
/** @internal */
|
||||
export const logWithLevel = level => (...message) => {
|
||||
const levelOption = Option.fromNullable(level);
|
||||
let cause = undefined;
|
||||
for (let i = 0, len = message.length; i < len; i++) {
|
||||
const msg = message[i];
|
||||
if (internalCause.isCause(msg)) {
|
||||
if (cause !== undefined) {
|
||||
cause = internalCause.sequential(cause, msg);
|
||||
} else {
|
||||
cause = msg;
|
||||
}
|
||||
message = [...message.slice(0, i), ...message.slice(i + 1)];
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (cause === undefined) {
|
||||
cause = internalCause.empty;
|
||||
}
|
||||
return core.withFiberRuntime(fiberState => {
|
||||
fiberState.log(message, cause, levelOption);
|
||||
return core.void;
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const log = /*#__PURE__*/logWithLevel();
|
||||
/** @internal */
|
||||
export const logTrace = /*#__PURE__*/logWithLevel(LogLevel.Trace);
|
||||
/** @internal */
|
||||
export const logDebug = /*#__PURE__*/logWithLevel(LogLevel.Debug);
|
||||
/** @internal */
|
||||
export const logInfo = /*#__PURE__*/logWithLevel(LogLevel.Info);
|
||||
/** @internal */
|
||||
export const logWarning = /*#__PURE__*/logWithLevel(LogLevel.Warning);
|
||||
/** @internal */
|
||||
export const logError = /*#__PURE__*/logWithLevel(LogLevel.Error);
|
||||
/** @internal */
|
||||
export const logFatal = /*#__PURE__*/logWithLevel(LogLevel.Fatal);
|
||||
/* @internal */
|
||||
export const withLogSpan = /*#__PURE__*/dual(2, (effect, label) => core.flatMap(Clock.currentTimeMillis, now => core.fiberRefLocallyWith(effect, core.currentLogSpan, List.prepend(LogSpan.make(label, now)))));
|
||||
/* @internal */
|
||||
export const logAnnotations = /*#__PURE__*/core.fiberRefGet(core.currentLogAnnotations);
|
||||
/* @internal */
|
||||
export const loop = (initial, options) => options.discard ? loopDiscard(initial, options.while, options.step, options.body) : core.map(loopInternal(initial, options.while, options.step, options.body), Arr.fromIterable);
|
||||
const loopInternal = (initial, cont, inc, body) => core.suspend(() => cont(initial) ? core.flatMap(body(initial), a => core.map(loopInternal(inc(initial), cont, inc, body), List.prepend(a))) : core.sync(() => List.empty()));
|
||||
const loopDiscard = (initial, cont, inc, body) => core.suspend(() => cont(initial) ? core.flatMap(body(initial), () => loopDiscard(inc(initial), cont, inc, body)) : core.void);
|
||||
/* @internal */
|
||||
export const mapAccum = /*#__PURE__*/dual(3, (elements, initial, f) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const builder = [];
|
||||
let result = core.succeed(initial);
|
||||
let next;
|
||||
let i = 0;
|
||||
while (!(next = iterator.next()).done) {
|
||||
const index = i++;
|
||||
const value = next.value;
|
||||
result = core.flatMap(result, state => core.map(f(state, value, index), ([z, b]) => {
|
||||
builder.push(b);
|
||||
return z;
|
||||
}));
|
||||
}
|
||||
return core.map(result, z => [z, builder]);
|
||||
}));
|
||||
/* @internal */
|
||||
export const mapErrorCause = /*#__PURE__*/dual(2, (self, f) => core.matchCauseEffect(self, {
|
||||
onFailure: c => core.failCauseSync(() => f(c)),
|
||||
onSuccess: core.succeed
|
||||
}));
|
||||
/* @internal */
|
||||
export const memoize = self => pipe(core.deferredMake(), core.flatMap(deferred => pipe(diffFiberRefsAndRuntimeFlags(self), core.intoDeferred(deferred), once, core.map(complete => core.zipRight(complete, pipe(core.deferredAwait(deferred), core.flatMap(([patch, a]) => core.as(core.zip(patchFiberRefs(patch[0]), core.updateRuntimeFlags(patch[1])), a))))))));
|
||||
/* @internal */
|
||||
export const merge = self => core.matchEffect(self, {
|
||||
onFailure: e => core.succeed(e),
|
||||
onSuccess: core.succeed
|
||||
});
|
||||
/* @internal */
|
||||
export const negate = self => core.map(self, b => !b);
|
||||
/* @internal */
|
||||
export const none = self => core.flatMap(self, option => {
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
return core.void;
|
||||
case "Some":
|
||||
return core.fail(new core.NoSuchElementException());
|
||||
}
|
||||
});
|
||||
/* @internal */
|
||||
export const once = self => core.map(Ref.make(true), ref => core.asVoid(core.whenEffect(self, Ref.getAndSet(ref, false))));
|
||||
/* @internal */
|
||||
export const option = self => core.matchEffect(self, {
|
||||
onFailure: () => core.succeed(Option.none()),
|
||||
onSuccess: a => core.succeed(Option.some(a))
|
||||
});
|
||||
/* @internal */
|
||||
export const orElseFail = /*#__PURE__*/dual(2, (self, evaluate) => core.orElse(self, () => core.failSync(evaluate)));
|
||||
/* @internal */
|
||||
export const orElseSucceed = /*#__PURE__*/dual(2, (self, evaluate) => core.orElse(self, () => core.sync(evaluate)));
|
||||
/* @internal */
|
||||
export const parallelErrors = self => core.matchCauseEffect(self, {
|
||||
onFailure: cause => {
|
||||
const errors = Arr.fromIterable(internalCause.failures(cause));
|
||||
return errors.length === 0 ? core.failCause(cause) : core.fail(errors);
|
||||
},
|
||||
onSuccess: core.succeed
|
||||
});
|
||||
/* @internal */
|
||||
export const patchFiberRefs = patch => updateFiberRefs((fiberId, fiberRefs) => pipe(patch, fiberRefsPatch.patch(fiberId, fiberRefs)));
|
||||
/* @internal */
|
||||
export const promise = evaluate => evaluate.length >= 1 ? core.async((resolve, signal) => {
|
||||
try {
|
||||
evaluate(signal).then(a => resolve(core.succeed(a)), e => resolve(core.die(e)));
|
||||
} catch (e) {
|
||||
resolve(core.die(e));
|
||||
}
|
||||
}) : core.async(resolve => {
|
||||
try {
|
||||
;
|
||||
evaluate().then(a => resolve(core.succeed(a)), e => resolve(core.die(e)));
|
||||
} catch (e) {
|
||||
resolve(core.die(e));
|
||||
}
|
||||
});
|
||||
/* @internal */
|
||||
export const provideService = /*#__PURE__*/dual(3, (self, tag, service) => core.contextWithEffect(env => core.provideContext(self, Context.add(env, tag, service))));
|
||||
/* @internal */
|
||||
export const provideServiceEffect = /*#__PURE__*/dual(3, (self, tag, effect) => core.contextWithEffect(env => core.flatMap(effect, service => core.provideContext(self, pipe(env, Context.add(tag, service))))));
|
||||
/* @internal */
|
||||
export const random = /*#__PURE__*/defaultServices.randomWith(core.succeed);
|
||||
/* @internal */
|
||||
export const reduce = /*#__PURE__*/dual(3, (elements, zero, f) => Arr.fromIterable(elements).reduce((acc, el, i) => core.flatMap(acc, a => f(a, el, i)), core.succeed(zero)));
|
||||
/* @internal */
|
||||
export const reduceRight = /*#__PURE__*/dual(3, (elements, zero, f) => Arr.fromIterable(elements).reduceRight((acc, el, i) => core.flatMap(acc, a => f(el, a, i)), core.succeed(zero)));
|
||||
/* @internal */
|
||||
export const reduceWhile = /*#__PURE__*/dual(3, (elements, zero, options) => core.flatMap(core.sync(() => elements[Symbol.iterator]()), iterator => reduceWhileLoop(iterator, 0, zero, options.while, options.body)));
|
||||
const reduceWhileLoop = (iterator, index, state, predicate, f) => {
|
||||
const next = iterator.next();
|
||||
if (!next.done && predicate(state)) {
|
||||
return core.flatMap(f(state, next.value, index), nextState => reduceWhileLoop(iterator, index + 1, nextState, predicate, f));
|
||||
}
|
||||
return core.succeed(state);
|
||||
};
|
||||
/* @internal */
|
||||
export const repeatN = /*#__PURE__*/dual(2, (self, n) => core.suspend(() => repeatNLoop(self, n)));
|
||||
/* @internal */
|
||||
const repeatNLoop = (self, n) => core.flatMap(self, a => n <= 0 ? core.succeed(a) : core.zipRight(core.yieldNow(), repeatNLoop(self, n - 1)));
|
||||
/* @internal */
|
||||
export const sandbox = self => core.matchCauseEffect(self, {
|
||||
onFailure: core.fail,
|
||||
onSuccess: core.succeed
|
||||
});
|
||||
/* @internal */
|
||||
export const setFiberRefs = fiberRefs => core.suspend(() => FiberRefs.setAll(fiberRefs));
|
||||
/* @internal */
|
||||
export const sleep = Clock.sleep;
|
||||
/* @internal */
|
||||
export const succeedNone = /*#__PURE__*/core.succeed(/*#__PURE__*/Option.none());
|
||||
/* @internal */
|
||||
export const succeedSome = value => core.succeed(Option.some(value));
|
||||
/* @internal */
|
||||
export const summarized = /*#__PURE__*/dual(3, (self, summary, f) => core.flatMap(summary, start => core.flatMap(self, value => core.map(summary, end => [f(start, end), value]))));
|
||||
/* @internal */
|
||||
export const tagMetrics = /*#__PURE__*/dual(args => core.isEffect(args[0]), function () {
|
||||
return labelMetrics(arguments[0], typeof arguments[1] === "string" ? [metricLabel.make(arguments[1], arguments[2])] : Object.entries(arguments[1]).map(([k, v]) => metricLabel.make(k, v)));
|
||||
});
|
||||
/* @internal */
|
||||
export const labelMetrics = /*#__PURE__*/dual(2, (self, labels) => core.fiberRefLocallyWith(self, core.currentMetricLabels, old => Arr.union(old, labels)));
|
||||
/* @internal */
|
||||
export const takeUntil = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const builder = [];
|
||||
let next;
|
||||
let effect = core.succeed(false);
|
||||
let i = 0;
|
||||
while ((next = iterator.next()) && !next.done) {
|
||||
const a = next.value;
|
||||
const index = i++;
|
||||
effect = core.flatMap(effect, bool => {
|
||||
if (bool) {
|
||||
return core.succeed(true);
|
||||
}
|
||||
builder.push(a);
|
||||
return predicate(a, index);
|
||||
});
|
||||
}
|
||||
return core.map(effect, () => builder);
|
||||
}));
|
||||
/* @internal */
|
||||
export const takeWhile = /*#__PURE__*/dual(2, (elements, predicate) => core.suspend(() => {
|
||||
const iterator = elements[Symbol.iterator]();
|
||||
const builder = [];
|
||||
let next;
|
||||
let taking = core.succeed(true);
|
||||
let i = 0;
|
||||
while ((next = iterator.next()) && !next.done) {
|
||||
const a = next.value;
|
||||
const index = i++;
|
||||
taking = core.flatMap(taking, taking => pipe(taking ? predicate(a, index) : core.succeed(false), core.map(bool => {
|
||||
if (bool) {
|
||||
builder.push(a);
|
||||
}
|
||||
return bool;
|
||||
})));
|
||||
}
|
||||
return core.map(taking, () => builder);
|
||||
}));
|
||||
/* @internal */
|
||||
export const tapBoth = /*#__PURE__*/dual(2, (self, {
|
||||
onFailure,
|
||||
onSuccess
|
||||
}) => core.matchCauseEffect(self, {
|
||||
onFailure: cause => {
|
||||
const either = internalCause.failureOrCause(cause);
|
||||
switch (either._tag) {
|
||||
case "Left":
|
||||
{
|
||||
return core.zipRight(onFailure(either.left), core.failCause(cause));
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
return core.failCause(cause);
|
||||
}
|
||||
}
|
||||
},
|
||||
onSuccess: a => core.as(onSuccess(a), a)
|
||||
}));
|
||||
/* @internal */
|
||||
export const tapDefect = /*#__PURE__*/dual(2, (self, f) => core.catchAllCause(self, cause => Option.match(internalCause.keepDefects(cause), {
|
||||
onNone: () => core.failCause(cause),
|
||||
onSome: a => core.zipRight(f(a), core.failCause(cause))
|
||||
})));
|
||||
/* @internal */
|
||||
export const tapError = /*#__PURE__*/dual(2, (self, f) => core.matchCauseEffect(self, {
|
||||
onFailure: cause => {
|
||||
const either = internalCause.failureOrCause(cause);
|
||||
switch (either._tag) {
|
||||
case "Left":
|
||||
return core.zipRight(f(either.left), core.failCause(cause));
|
||||
case "Right":
|
||||
return core.failCause(cause);
|
||||
}
|
||||
},
|
||||
onSuccess: core.succeed
|
||||
}));
|
||||
/* @internal */
|
||||
export const tapErrorTag = /*#__PURE__*/dual(3, (self, k, f) => tapError(self, e => {
|
||||
if (Predicate.isTagged(e, k)) {
|
||||
return f(e);
|
||||
}
|
||||
return core.void;
|
||||
}));
|
||||
/* @internal */
|
||||
export const tapErrorCause = /*#__PURE__*/dual(2, (self, f) => core.matchCauseEffect(self, {
|
||||
onFailure: cause => core.zipRight(f(cause), core.failCause(cause)),
|
||||
onSuccess: core.succeed
|
||||
}));
|
||||
/* @internal */
|
||||
export const timed = self => timedWith(self, Clock.currentTimeNanos);
|
||||
/* @internal */
|
||||
export const timedWith = /*#__PURE__*/dual(2, (self, nanos) => summarized(self, nanos, (start, end) => Duration.nanos(end - start)));
|
||||
/* @internal */
|
||||
export const tracerWith = Tracer.tracerWith;
|
||||
/** @internal */
|
||||
export const tracer = /*#__PURE__*/tracerWith(core.succeed);
|
||||
/* @internal */
|
||||
export const tryPromise = arg => {
|
||||
let evaluate;
|
||||
let catcher = undefined;
|
||||
if (typeof arg === "function") {
|
||||
evaluate = arg;
|
||||
} else {
|
||||
evaluate = arg.try;
|
||||
catcher = arg.catch;
|
||||
}
|
||||
const fail = e => catcher ? core.failSync(() => catcher(e)) : core.fail(new core.UnknownException(e, "An unknown error occurred in Effect.tryPromise"));
|
||||
if (evaluate.length >= 1) {
|
||||
return core.async((resolve, signal) => {
|
||||
try {
|
||||
evaluate(signal).then(a => resolve(core.succeed(a)), e => resolve(fail(e)));
|
||||
} catch (e) {
|
||||
resolve(fail(e));
|
||||
}
|
||||
});
|
||||
}
|
||||
return core.async(resolve => {
|
||||
try {
|
||||
evaluate().then(a => resolve(core.succeed(a)), e => resolve(fail(e)));
|
||||
} catch (e) {
|
||||
resolve(fail(e));
|
||||
}
|
||||
});
|
||||
};
|
||||
/* @internal */
|
||||
export const tryMap = /*#__PURE__*/dual(2, (self, options) => core.flatMap(self, a => try_({
|
||||
try: () => options.try(a),
|
||||
catch: options.catch
|
||||
})));
|
||||
/* @internal */
|
||||
export const tryMapPromise = /*#__PURE__*/dual(2, (self, options) => core.flatMap(self, a => tryPromise({
|
||||
try: options.try.length >= 1 ? signal => options.try(a, signal) : () => options.try(a),
|
||||
catch: options.catch
|
||||
})));
|
||||
/* @internal */
|
||||
export const unless = /*#__PURE__*/dual(2, (self, condition) => core.suspend(() => condition() ? succeedNone : asSome(self)));
|
||||
/* @internal */
|
||||
export const unlessEffect = /*#__PURE__*/dual(2, (self, condition) => core.flatMap(condition, b => b ? succeedNone : asSome(self)));
|
||||
/* @internal */
|
||||
export const unsandbox = self => mapErrorCause(self, internalCause.flatten);
|
||||
/* @internal */
|
||||
export const updateFiberRefs = f => core.withFiberRuntime(state => {
|
||||
state.setFiberRefs(f(state.id(), state.getFiberRefs()));
|
||||
return core.void;
|
||||
});
|
||||
/* @internal */
|
||||
export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => core.mapInputContext(self, context => Context.add(context, tag, f(Context.unsafeGet(context, tag)))));
|
||||
/* @internal */
|
||||
export const when = /*#__PURE__*/dual(2, (self, condition) => core.suspend(() => condition() ? core.map(self, Option.some) : core.succeed(Option.none())));
|
||||
/* @internal */
|
||||
export const whenFiberRef = /*#__PURE__*/dual(3, (self, fiberRef, predicate) => core.flatMap(core.fiberRefGet(fiberRef), s => predicate(s) ? core.map(self, a => [s, Option.some(a)]) : core.succeed([s, Option.none()])));
|
||||
/* @internal */
|
||||
export const whenRef = /*#__PURE__*/dual(3, (self, ref, predicate) => core.flatMap(Ref.get(ref), s => predicate(s) ? core.map(self, a => [s, Option.some(a)]) : core.succeed([s, Option.none()])));
|
||||
/* @internal */
|
||||
export const withMetric = /*#__PURE__*/dual(2, (self, metric) => metric(self));
|
||||
/** @internal */
|
||||
export const serviceFunctionEffect = (getService, f) => (...args) => core.flatMap(getService, a => f(a)(...args));
|
||||
/** @internal */
|
||||
export const serviceFunction = (getService, f) => (...args) => core.map(getService, a => f(a)(...args));
|
||||
/** @internal */
|
||||
export const serviceFunctions = getService => new Proxy({}, {
|
||||
get(_target, prop, _receiver) {
|
||||
return (...args) => core.flatMap(getService, s => s[prop](...args));
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
export const serviceConstants = getService => new Proxy({}, {
|
||||
get(_target, prop, _receiver) {
|
||||
return core.flatMap(getService, s => core.isEffect(s[prop]) ? s[prop] : core.succeed(s[prop]));
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
export const serviceMembers = getService => ({
|
||||
functions: serviceFunctions(getService),
|
||||
constants: serviceConstants(getService)
|
||||
});
|
||||
/** @internal */
|
||||
export const serviceOption = tag => core.map(core.context(), Context.getOption(tag));
|
||||
/** @internal */
|
||||
export const serviceOptional = tag => core.flatMap(core.context(), Context.getOption(tag));
|
||||
// -----------------------------------------------------------------------------
|
||||
// tracing
|
||||
// -----------------------------------------------------------------------------
|
||||
/* @internal */
|
||||
export const annotateCurrentSpan = function () {
|
||||
const args = arguments;
|
||||
return ignore(core.flatMap(currentSpan, span => core.sync(() => {
|
||||
if (typeof args[0] === "string") {
|
||||
span.attribute(args[0], args[1]);
|
||||
} else {
|
||||
for (const key in args[0]) {
|
||||
span.attribute(key, args[0][key]);
|
||||
}
|
||||
}
|
||||
})));
|
||||
};
|
||||
/* @internal */
|
||||
export const linkSpanCurrent = function () {
|
||||
const args = arguments;
|
||||
const links = Array.isArray(args[0]) ? args[0] : [{
|
||||
_tag: "SpanLink",
|
||||
span: args[0],
|
||||
attributes: args[1] ?? {}
|
||||
}];
|
||||
return ignore(core.flatMap(currentSpan, span => core.sync(() => span.addLinks(links))));
|
||||
};
|
||||
/* @internal */
|
||||
export const annotateSpans = /*#__PURE__*/dual(args => core.isEffect(args[0]), function () {
|
||||
const args = arguments;
|
||||
return core.fiberRefLocallyWith(args[0], core.currentTracerSpanAnnotations, typeof args[1] === "string" ? HashMap.set(args[1], args[2]) : annotations => Object.entries(args[1]).reduce((acc, [key, value]) => HashMap.set(acc, key, value), annotations));
|
||||
});
|
||||
/** @internal */
|
||||
export const currentParentSpan = /*#__PURE__*/serviceOptional(internalTracer.spanTag);
|
||||
/** @internal */
|
||||
export const currentSpan = /*#__PURE__*/core.flatMap(/*#__PURE__*/core.context(), context => {
|
||||
const span = context.unsafeMap.get(internalTracer.spanTag.key);
|
||||
return span !== undefined && span._tag === "Span" ? core.succeed(span) : core.fail(new core.NoSuchElementException());
|
||||
});
|
||||
/* @internal */
|
||||
export const linkSpans = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, span, attributes) => core.fiberRefLocallyWith(self, core.currentTracerSpanLinks, Chunk.append({
|
||||
_tag: "SpanLink",
|
||||
span,
|
||||
attributes: attributes ?? {}
|
||||
})));
|
||||
const bigint0 = /*#__PURE__*/BigInt(0);
|
||||
const filterDisablePropagation = /*#__PURE__*/Option.flatMap(span => Context.get(span.context, internalTracer.DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(span.parent) : Option.none() : Option.some(span));
|
||||
/** @internal */
|
||||
export const unsafeMakeSpan = (fiber, name, options) => {
|
||||
const disablePropagation = !fiber.getFiberRef(core.currentTracerEnabled) || options.context && Context.get(options.context, internalTracer.DisablePropagation);
|
||||
const context = fiber.getFiberRef(core.currentContext);
|
||||
const parent = options.parent ? Option.some(options.parent) : options.root ? Option.none() : filterDisablePropagation(Context.getOption(context, internalTracer.spanTag));
|
||||
let span;
|
||||
if (disablePropagation) {
|
||||
span = core.noopSpan({
|
||||
name,
|
||||
parent,
|
||||
context: Context.add(options.context ?? Context.empty(), internalTracer.DisablePropagation, true)
|
||||
});
|
||||
} else {
|
||||
const services = fiber.getFiberRef(defaultServices.currentServices);
|
||||
const tracer = Context.get(services, internalTracer.tracerTag);
|
||||
const clock = Context.get(services, Clock.Clock);
|
||||
const timingEnabled = fiber.getFiberRef(core.currentTracerTimingEnabled);
|
||||
const fiberRefs = fiber.getFiberRefs();
|
||||
const annotationsFromEnv = FiberRefs.get(fiberRefs, core.currentTracerSpanAnnotations);
|
||||
const linksFromEnv = FiberRefs.get(fiberRefs, core.currentTracerSpanLinks);
|
||||
const links = linksFromEnv._tag === "Some" ? options.links !== undefined ? [...Chunk.toReadonlyArray(linksFromEnv.value), ...(options.links ?? [])] : Chunk.toReadonlyArray(linksFromEnv.value) : options.links ?? Arr.empty();
|
||||
span = tracer.span(name, parent, options.context ?? Context.empty(), links, timingEnabled ? clock.unsafeCurrentTimeNanos() : bigint0, options.kind ?? "internal", options);
|
||||
if (annotationsFromEnv._tag === "Some") {
|
||||
HashMap.forEach(annotationsFromEnv.value, (value, key) => span.attribute(key, value));
|
||||
}
|
||||
if (options.attributes !== undefined) {
|
||||
Object.entries(options.attributes).forEach(([k, v]) => span.attribute(k, v));
|
||||
}
|
||||
}
|
||||
if (typeof options.captureStackTrace === "function") {
|
||||
internalCause.spanToTrace.set(span, options.captureStackTrace);
|
||||
}
|
||||
return span;
|
||||
};
|
||||
/** @internal */
|
||||
export const makeSpan = (name, options) => {
|
||||
options = internalTracer.addSpanStackTrace(options);
|
||||
return core.withFiberRuntime(fiber => core.succeed(unsafeMakeSpan(fiber, name, options)));
|
||||
};
|
||||
/* @internal */
|
||||
export const spanAnnotations = /*#__PURE__*/core.fiberRefGet(core.currentTracerSpanAnnotations);
|
||||
/* @internal */
|
||||
export const spanLinks = /*#__PURE__*/core.fiberRefGet(core.currentTracerSpanLinks);
|
||||
/** @internal */
|
||||
export const endSpan = (span, exit, clock, timingEnabled) => core.sync(() => {
|
||||
if (span.status._tag === "Ended") {
|
||||
return;
|
||||
}
|
||||
if (core.exitIsFailure(exit) && internalCause.spanToTrace.has(span)) {
|
||||
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/code/#code-stacktrace
|
||||
span.attribute("code.stacktrace", internalCause.spanToTrace.get(span)());
|
||||
}
|
||||
span.end(timingEnabled ? clock.unsafeCurrentTimeNanos() : bigint0, exit);
|
||||
});
|
||||
/** @internal */
|
||||
export const useSpan = (name, ...args) => {
|
||||
const options = internalTracer.addSpanStackTrace(args.length === 1 ? undefined : args[0]);
|
||||
const evaluate = args[args.length - 1];
|
||||
return core.withFiberRuntime(fiber => {
|
||||
const span = unsafeMakeSpan(fiber, name, options);
|
||||
const timingEnabled = fiber.getFiberRef(core.currentTracerTimingEnabled);
|
||||
const clock = Context.get(fiber.getFiberRef(defaultServices.currentServices), clockTag);
|
||||
return core.onExit(evaluate(span), exit => endSpan(span, exit, clock, timingEnabled));
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const withParentSpan = /*#__PURE__*/dual(2, (self, span) => provideService(self, internalTracer.spanTag, span));
|
||||
/** @internal */
|
||||
export const withSpan = function () {
|
||||
const dataFirst = typeof arguments[0] !== "string";
|
||||
const name = dataFirst ? arguments[1] : arguments[0];
|
||||
const options = internalTracer.addSpanStackTrace(dataFirst ? arguments[2] : arguments[1]);
|
||||
if (dataFirst) {
|
||||
const self = arguments[0];
|
||||
return useSpan(name, options, span => withParentSpan(self, span));
|
||||
}
|
||||
return self => useSpan(name, options, span => withParentSpan(self, span));
|
||||
};
|
||||
export const functionWithSpan = options => function () {
|
||||
let captureStackTrace = options.captureStackTrace ?? false;
|
||||
if (options.captureStackTrace !== false) {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 2;
|
||||
const error = new Error();
|
||||
Error.stackTraceLimit = limit;
|
||||
let cache = false;
|
||||
captureStackTrace = () => {
|
||||
if (cache !== false) {
|
||||
return cache;
|
||||
}
|
||||
if (error.stack) {
|
||||
const stack = error.stack.trim().split("\n");
|
||||
cache = stack.slice(2).join("\n").trim();
|
||||
return cache;
|
||||
}
|
||||
};
|
||||
}
|
||||
return core.suspend(() => {
|
||||
const opts = typeof options.options === "function" ? options.options.apply(null, arguments) : options.options;
|
||||
return withSpan(core.suspend(() => internalCall(() => options.body.apply(this, arguments))), opts.name, {
|
||||
...opts,
|
||||
captureStackTrace
|
||||
});
|
||||
});
|
||||
};
|
||||
// -------------------------------------------------------------------------------------
|
||||
// optionality
|
||||
// -------------------------------------------------------------------------------------
|
||||
/* @internal */
|
||||
export const fromNullable = value => value == null ? core.fail(new core.NoSuchElementException()) : core.succeed(value);
|
||||
/* @internal */
|
||||
export const optionFromOptional = self => core.catchAll(core.map(self, Option.some), error => core.isNoSuchElementException(error) ? succeedNone : core.fail(error));
|
||||
//# sourceMappingURL=core-effect.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/core-effect.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/core-effect.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
236
_node_modules/effect/dist/esm/internal/core-stream.js
generated
vendored
Normal file
236
_node_modules/effect/dist/esm/internal/core-stream.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
import * as Cause from "../Cause.js";
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Effect from "../Effect.js";
|
||||
import * as Either from "../Either.js";
|
||||
import { constVoid, dual, identity } from "../Function.js";
|
||||
import * as Option from "../Option.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import * as childExecutorDecision from "./channel/childExecutorDecision.js";
|
||||
import { ContinuationKImpl } from "./channel/continuation.js";
|
||||
import * as upstreamPullStrategy from "./channel/upstreamPullStrategy.js";
|
||||
import * as OpCodes from "./opCodes/channel.js";
|
||||
/** @internal */
|
||||
const ChannelSymbolKey = "effect/Channel";
|
||||
/** @internal */
|
||||
export const ChannelTypeId = /*#__PURE__*/Symbol.for(ChannelSymbolKey);
|
||||
const channelVariance = {
|
||||
/* c8 ignore next */
|
||||
_Env: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InErr: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InElem: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InDone: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutErr: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutElem: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutDone: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
const proto = {
|
||||
[ChannelTypeId]: channelVariance,
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const isChannel = u => hasProperty(u, ChannelTypeId) || Effect.isEffect(u);
|
||||
/** @internal */
|
||||
export const acquireReleaseOut = /*#__PURE__*/dual(2, (self, release) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_BRACKET_OUT;
|
||||
op.acquire = () => self;
|
||||
op.finalizer = release;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const catchAllCause = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FOLD;
|
||||
op.channel = self;
|
||||
op.k = new ContinuationKImpl(succeed, f);
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const collectElements = self => {
|
||||
return suspend(() => {
|
||||
const builder = [];
|
||||
return flatMap(pipeTo(self, collectElementsReader(builder)), value => sync(() => [Chunk.fromIterable(builder), value]));
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
const collectElementsReader = builder => readWith({
|
||||
onInput: outElem => flatMap(sync(() => {
|
||||
builder.push(outElem);
|
||||
}), () => collectElementsReader(builder)),
|
||||
onFailure: fail,
|
||||
onDone: succeedNow
|
||||
});
|
||||
/** @internal */
|
||||
export const concatAll = channels => concatAllWith(channels, constVoid, constVoid);
|
||||
/** @internal */
|
||||
export const concatAllWith = (channels, f, g) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_CONCAT_ALL;
|
||||
op.combineInners = f;
|
||||
op.combineAll = g;
|
||||
op.onPull = () => upstreamPullStrategy.PullAfterNext(Option.none());
|
||||
op.onEmit = () => childExecutorDecision.Continue;
|
||||
op.value = () => channels;
|
||||
op.k = identity;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const concatMapWith = /*#__PURE__*/dual(4, (self, f, g, h) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_CONCAT_ALL;
|
||||
op.combineInners = g;
|
||||
op.combineAll = h;
|
||||
op.onPull = () => upstreamPullStrategy.PullAfterNext(Option.none());
|
||||
op.onEmit = () => childExecutorDecision.Continue;
|
||||
op.value = () => self;
|
||||
op.k = f;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const concatMapWithCustom = /*#__PURE__*/dual(6, (self, f, g, h, onPull, onEmit) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_CONCAT_ALL;
|
||||
op.combineInners = g;
|
||||
op.combineAll = h;
|
||||
op.onPull = onPull;
|
||||
op.onEmit = onEmit;
|
||||
op.value = () => self;
|
||||
op.k = f;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const embedInput = /*#__PURE__*/dual(2, (self, input) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_BRIDGE;
|
||||
op.input = input;
|
||||
op.channel = self;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const ensuringWith = /*#__PURE__*/dual(2, (self, finalizer) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_ENSURING;
|
||||
op.channel = self;
|
||||
op.finalizer = finalizer;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const fail = error => failCause(Cause.fail(error));
|
||||
/** @internal */
|
||||
export const failSync = evaluate => failCauseSync(() => Cause.fail(evaluate()));
|
||||
/** @internal */
|
||||
export const failCause = cause => failCauseSync(() => cause);
|
||||
/** @internal */
|
||||
export const failCauseSync = evaluate => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FAIL;
|
||||
op.error = evaluate;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const flatMap = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FOLD;
|
||||
op.channel = self;
|
||||
op.k = new ContinuationKImpl(f, failCause);
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const foldCauseChannel = /*#__PURE__*/dual(2, (self, options) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FOLD;
|
||||
op.channel = self;
|
||||
op.k = new ContinuationKImpl(options.onSuccess, options.onFailure);
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const fromEffect = effect => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_FROM_EFFECT;
|
||||
op.effect = () => effect;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const pipeTo = /*#__PURE__*/dual(2, (self, that) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_PIPE_TO;
|
||||
op.left = () => self;
|
||||
op.right = () => that;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const provideContext = /*#__PURE__*/dual(2, (self, env) => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_PROVIDE;
|
||||
op.context = () => env;
|
||||
op.inner = self;
|
||||
return op;
|
||||
});
|
||||
/** @internal */
|
||||
export const readOrFail = error => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_READ;
|
||||
op.more = succeed;
|
||||
op.done = new ContinuationKImpl(() => fail(error), () => fail(error));
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const readWith = options => readWithCause({
|
||||
onInput: options.onInput,
|
||||
onFailure: cause => Either.match(Cause.failureOrCause(cause), {
|
||||
onLeft: options.onFailure,
|
||||
onRight: failCause
|
||||
}),
|
||||
onDone: options.onDone
|
||||
});
|
||||
/** @internal */
|
||||
export const readWithCause = options => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_READ;
|
||||
op.more = options.onInput;
|
||||
op.done = new ContinuationKImpl(options.onDone, options.onFailure);
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const succeed = value => sync(() => value);
|
||||
/** @internal */
|
||||
export const succeedNow = result => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_SUCCEED_NOW;
|
||||
op.terminal = result;
|
||||
return op;
|
||||
};
|
||||
/** @internal */
|
||||
export const suspend = evaluate => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_SUSPEND;
|
||||
op.channel = evaluate;
|
||||
return op;
|
||||
};
|
||||
export const sync = evaluate => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_SUCCEED;
|
||||
op.evaluate = evaluate;
|
||||
return op;
|
||||
};
|
||||
const void_ = /*#__PURE__*/succeedNow(void 0);
|
||||
export { /** @internal */
|
||||
void_ as void };
|
||||
/** @internal */
|
||||
export const write = out => {
|
||||
const op = Object.create(proto);
|
||||
op._tag = OpCodes.OP_EMIT;
|
||||
op.out = out;
|
||||
return op;
|
||||
};
|
||||
//# sourceMappingURL=core-stream.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/core-stream.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/core-stream.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1610
_node_modules/effect/dist/esm/internal/core.js
generated
vendored
Normal file
1610
_node_modules/effect/dist/esm/internal/core.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
_node_modules/effect/dist/esm/internal/core.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/core.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
_node_modules/effect/dist/esm/internal/data.js
generated
vendored
Normal file
29
_node_modules/effect/dist/esm/internal/data.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import { StructuralPrototype } from "./effectable.js";
|
||||
/** @internal */
|
||||
export const ArrayProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(Array.prototype), {
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.array(this));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
if (Array.isArray(that) && this.length === that.length) {
|
||||
return this.every((v, i) => Equal.equals(v, that[i]));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
export const Structural = /*#__PURE__*/function () {
|
||||
function Structural(args) {
|
||||
if (args) {
|
||||
Object.assign(this, args);
|
||||
}
|
||||
}
|
||||
Structural.prototype = StructuralPrototype;
|
||||
return Structural;
|
||||
}();
|
||||
/** @internal */
|
||||
export const struct = as => Object.assign(Object.create(StructuralPrototype), as);
|
||||
//# sourceMappingURL=data.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/data.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/data.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"data.js","names":["Equal","Hash","StructuralPrototype","ArrayProto","Object","assign","create","Array","prototype","symbol","cached","array","that","isArray","length","every","v","i","equals","Structural","args","struct","as"],"sources":["../../../src/internal/data.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,aAAa;AACpC,OAAO,KAAKC,IAAI,MAAM,YAAY;AAElC,SAASC,mBAAmB,QAAQ,iBAAiB;AAErD;AACA,OAAO,MAAMC,UAAU,gBAAgBC,MAAM,CAACC,MAAM,cAACD,MAAM,CAACE,MAAM,CAACC,KAAK,CAACC,SAAS,CAAC,EAAE;EACnF,CAACP,IAAI,CAACQ,MAAM,IAAC;IACX,OAAOR,IAAI,CAACS,MAAM,CAAC,IAAI,EAAET,IAAI,CAACU,KAAK,CAAC,IAAI,CAAC,CAAC;EAC5C,CAAC;EACD,CAACX,KAAK,CAACS,MAAM,EAAoBG,IAAiB;IAChD,IAAIL,KAAK,CAACM,OAAO,CAACD,IAAI,CAAC,IAAI,IAAI,CAACE,MAAM,KAAKF,IAAI,CAACE,MAAM,EAAE;MACtD,OAAO,IAAI,CAACC,KAAK,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKjB,KAAK,CAACkB,MAAM,CAACF,CAAC,EAAGJ,IAAmB,CAACK,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC,MAAM;MACL,OAAO,KAAK;IACd;EACF;CACD,CAAC;AAEF;AACA,OAAO,MAAME,UAAU,gBAGZ;EACT,SAASA,UAAUA,CAAYC,IAAS;IACtC,IAAIA,IAAI,EAAE;MACRhB,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEe,IAAI,CAAC;IAC3B;EACF;EACAD,UAAU,CAACX,SAAS,GAAGN,mBAAmB;EAC1C,OAAOiB,UAAiB;AAC1B,CAAC,CAAC,CAAE;AAEJ;AACA,OAAO,MAAME,MAAM,GAA8CC,EAAM,IACrElB,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACJ,mBAAmB,CAAC,EAAEoB,EAAE,CAAC","ignoreList":[]}
|
||||
93
_node_modules/effect/dist/esm/internal/dataSource.js
generated
vendored
Normal file
93
_node_modules/effect/dist/esm/internal/dataSource.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import * as RA from "../Array.js";
|
||||
import * as Cause from "../Cause.js";
|
||||
import * as Chunk from "../Chunk.js";
|
||||
import * as Effect from "../Effect.js";
|
||||
import { dual, pipe } from "../Function.js";
|
||||
import * as core from "./core.js";
|
||||
import { invokeWithInterrupt, zipWithOptions } from "./fiberRuntime.js";
|
||||
import { complete } from "./request.js";
|
||||
/** @internal */
|
||||
export const make = runAll => new core.RequestResolverImpl(requests => runAll(requests.map(_ => _.map(_ => _.request))));
|
||||
/** @internal */
|
||||
export const makeWithEntry = runAll => new core.RequestResolverImpl(requests => runAll(requests));
|
||||
/** @internal */
|
||||
export const makeBatched = run => new core.RequestResolverImpl(requests => {
|
||||
if (requests.length > 1) {
|
||||
return core.forEachSequentialDiscard(requests, block => {
|
||||
const filtered = block.filter(_ => !_.state.completed).map(_ => _.request);
|
||||
if (!RA.isNonEmptyArray(filtered)) {
|
||||
return core.void;
|
||||
}
|
||||
return invokeWithInterrupt(run(filtered), block);
|
||||
});
|
||||
} else if (requests.length === 1) {
|
||||
const filtered = requests[0].filter(_ => !_.state.completed).map(_ => _.request);
|
||||
if (!RA.isNonEmptyArray(filtered)) {
|
||||
return core.void;
|
||||
}
|
||||
return run(filtered);
|
||||
}
|
||||
return core.void;
|
||||
});
|
||||
/** @internal */
|
||||
export const around = /*#__PURE__*/dual(3, (self, before, after) => new core.RequestResolverImpl(requests => core.acquireUseRelease(before, () => self.runAll(requests), after), Chunk.make("Around", self, before, after)));
|
||||
/** @internal */
|
||||
export const aroundRequests = /*#__PURE__*/dual(3, (self, before, after) => new core.RequestResolverImpl(requests => {
|
||||
const flatRequests = requests.flatMap(chunk => chunk.map(entry => entry.request));
|
||||
return core.acquireUseRelease(before(flatRequests), () => self.runAll(requests), a2 => after(flatRequests, a2));
|
||||
}, Chunk.make("AroundRequests", self, before, after)));
|
||||
/** @internal */
|
||||
export const batchN = /*#__PURE__*/dual(2, (self, n) => new core.RequestResolverImpl(requests => {
|
||||
return n < 1 ? core.die(new Cause.IllegalArgumentException("RequestResolver.batchN: n must be at least 1")) : self.runAll(Array.from(Chunk.map(RA.reduce(requests, Chunk.empty(), (acc, chunk) => Chunk.appendAll(acc, Chunk.chunksOf(Chunk.unsafeFromArray(chunk), n))), chunk => Array.from(chunk))));
|
||||
}, Chunk.make("BatchN", self, n)));
|
||||
/** @internal */
|
||||
export const mapInputContext = /*#__PURE__*/dual(2, (self, f) => new core.RequestResolverImpl(requests => core.mapInputContext(self.runAll(requests), context => f(context)), Chunk.make("MapInputContext", self, f)));
|
||||
/** @internal */
|
||||
export const eitherWith = /*#__PURE__*/dual(3, (self, that, f) => new core.RequestResolverImpl(batch => core.forEachSequential(batch, requests => {
|
||||
const [as, bs] = pipe(requests, RA.partitionMap(f));
|
||||
return zipWithOptions(self.runAll(Array.of(as)), that.runAll(Array.of(bs)), () => void 0, {
|
||||
concurrent: true
|
||||
});
|
||||
}), Chunk.make("EitherWith", self, that, f)));
|
||||
/** @internal */
|
||||
export const fromFunction = f => makeBatched(requests => core.forEachSequentialDiscard(requests, request => complete(request, core.exitSucceed(f(request))))).identified("FromFunction", f);
|
||||
/** @internal */
|
||||
export const fromFunctionBatched = f => makeBatched(as => Effect.forEach(f(as), (res, i) => complete(as[i], core.exitSucceed(res)), {
|
||||
discard: true
|
||||
})).identified("FromFunctionBatched", f);
|
||||
/** @internal */
|
||||
export const fromEffect = f => makeBatched(requests => Effect.forEach(requests, a => Effect.flatMap(Effect.exit(f(a)), e => complete(a, e)), {
|
||||
concurrency: "unbounded",
|
||||
discard: true
|
||||
})).identified("FromEffect", f);
|
||||
/** @internal */
|
||||
export const fromEffectTagged = () => fns => makeBatched(requests => {
|
||||
const grouped = {};
|
||||
const tags = [];
|
||||
for (let i = 0, len = requests.length; i < len; i++) {
|
||||
if (tags.includes(requests[i]._tag)) {
|
||||
grouped[requests[i]._tag].push(requests[i]);
|
||||
} else {
|
||||
grouped[requests[i]._tag] = [requests[i]];
|
||||
tags.push(requests[i]._tag);
|
||||
}
|
||||
}
|
||||
return Effect.forEach(tags, tag => Effect.matchCauseEffect(fns[tag](grouped[tag]), {
|
||||
onFailure: cause => Effect.forEach(grouped[tag], req => complete(req, core.exitFail(cause)), {
|
||||
discard: true
|
||||
}),
|
||||
onSuccess: res => Effect.forEach(grouped[tag], (req, i) => complete(req, core.exitSucceed(res[i])), {
|
||||
discard: true
|
||||
})
|
||||
}), {
|
||||
concurrency: "unbounded",
|
||||
discard: true
|
||||
});
|
||||
}).identified("FromEffectTagged", fns);
|
||||
/** @internal */
|
||||
export const never = /*#__PURE__*/make(() => Effect.never).identified("Never");
|
||||
/** @internal */
|
||||
export const provideContext = /*#__PURE__*/dual(2, (self, context) => mapInputContext(self, _ => context).identified("ProvideContext", self, context));
|
||||
/** @internal */
|
||||
export const race = /*#__PURE__*/dual(2, (self, that) => new core.RequestResolverImpl(requests => Effect.race(self.runAll(requests), that.runAll(requests))).identified("Race", self, that));
|
||||
//# sourceMappingURL=dataSource.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/dataSource.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/dataSource.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
796
_node_modules/effect/dist/esm/internal/dateTime.js
generated
vendored
Normal file
796
_node_modules/effect/dist/esm/internal/dateTime.js
generated
vendored
Normal file
@@ -0,0 +1,796 @@
|
||||
import { IllegalArgumentException } from "../Cause.js";
|
||||
import * as Clock from "../Clock.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import * as Either from "../Either.js";
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as equivalence from "../Equivalence.js";
|
||||
import { dual, pipe } from "../Function.js";
|
||||
import { globalValue } from "../GlobalValue.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import * as Inspectable from "../Inspectable.js";
|
||||
import * as Option from "../Option.js";
|
||||
import * as order from "../Order.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import * as Predicate from "../Predicate.js";
|
||||
import * as internalEffect from "./core-effect.js";
|
||||
import * as core from "./core.js";
|
||||
/** @internal */
|
||||
export const TypeId = /*#__PURE__*/Symbol.for("effect/DateTime");
|
||||
/** @internal */
|
||||
export const TimeZoneTypeId = /*#__PURE__*/Symbol.for("effect/DateTime/TimeZone");
|
||||
const Proto = {
|
||||
[TypeId]: TypeId,
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
},
|
||||
[Inspectable.NodeInspectSymbol]() {
|
||||
return this.toString();
|
||||
},
|
||||
toJSON() {
|
||||
return toDateUtc(this).toJSON();
|
||||
}
|
||||
};
|
||||
const ProtoUtc = {
|
||||
...Proto,
|
||||
_tag: "Utc",
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.number(this.epochMillis));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
return isDateTime(that) && that._tag === "Utc" && this.epochMillis === that.epochMillis;
|
||||
},
|
||||
toString() {
|
||||
return `DateTime.Utc(${toDateUtc(this).toJSON()})`;
|
||||
}
|
||||
};
|
||||
const ProtoZoned = {
|
||||
...Proto,
|
||||
_tag: "Zoned",
|
||||
[Hash.symbol]() {
|
||||
return pipe(Hash.number(this.epochMillis), Hash.combine(Hash.hash(this.zone)), Hash.cached(this));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
return isDateTime(that) && that._tag === "Zoned" && this.epochMillis === that.epochMillis && Equal.equals(this.zone, that.zone);
|
||||
},
|
||||
toString() {
|
||||
return `DateTime.Zoned(${formatIsoZoned(this)})`;
|
||||
}
|
||||
};
|
||||
const ProtoTimeZone = {
|
||||
[TimeZoneTypeId]: TimeZoneTypeId,
|
||||
[Inspectable.NodeInspectSymbol]() {
|
||||
return this.toString();
|
||||
}
|
||||
};
|
||||
const ProtoTimeZoneNamed = {
|
||||
...ProtoTimeZone,
|
||||
_tag: "Named",
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.string(`Named:${this.id}`));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
return isTimeZone(that) && that._tag === "Named" && this.id === that.id;
|
||||
},
|
||||
toString() {
|
||||
return `TimeZone.Named(${this.id})`;
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "TimeZone",
|
||||
_tag: "Named",
|
||||
id: this.id
|
||||
};
|
||||
}
|
||||
};
|
||||
const ProtoTimeZoneOffset = {
|
||||
...ProtoTimeZone,
|
||||
_tag: "Offset",
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.string(`Offset:${this.offset}`));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
return isTimeZone(that) && that._tag === "Offset" && this.offset === that.offset;
|
||||
},
|
||||
toString() {
|
||||
return `TimeZone.Offset(${offsetToString(this.offset)})`;
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "TimeZone",
|
||||
_tag: "Offset",
|
||||
offset: this.offset
|
||||
};
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const makeZonedProto = (epochMillis, zone, partsUtc) => {
|
||||
const self = Object.create(ProtoZoned);
|
||||
self.epochMillis = epochMillis;
|
||||
self.zone = zone;
|
||||
Object.defineProperty(self, "partsUtc", {
|
||||
value: partsUtc,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(self, "adjustedEpochMillis", {
|
||||
value: undefined,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(self, "partsAdjusted", {
|
||||
value: undefined,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
return self;
|
||||
};
|
||||
// =============================================================================
|
||||
// guards
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const isDateTime = u => Predicate.hasProperty(u, TypeId);
|
||||
const isDateTimeArgs = args => isDateTime(args[0]);
|
||||
/** @internal */
|
||||
export const isTimeZone = u => Predicate.hasProperty(u, TimeZoneTypeId);
|
||||
/** @internal */
|
||||
export const isTimeZoneOffset = u => isTimeZone(u) && u._tag === "Offset";
|
||||
/** @internal */
|
||||
export const isTimeZoneNamed = u => isTimeZone(u) && u._tag === "Named";
|
||||
/** @internal */
|
||||
export const isUtc = self => self._tag === "Utc";
|
||||
/** @internal */
|
||||
export const isZoned = self => self._tag === "Zoned";
|
||||
// =============================================================================
|
||||
// instances
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const Equivalence = /*#__PURE__*/equivalence.make((a, b) => a.epochMillis === b.epochMillis);
|
||||
/** @internal */
|
||||
export const Order = /*#__PURE__*/order.make((self, that) => self.epochMillis < that.epochMillis ? -1 : self.epochMillis > that.epochMillis ? 1 : 0);
|
||||
/** @internal */
|
||||
export const clamp = /*#__PURE__*/order.clamp(Order);
|
||||
// =============================================================================
|
||||
// constructors
|
||||
// =============================================================================
|
||||
const makeUtc = epochMillis => {
|
||||
const self = Object.create(ProtoUtc);
|
||||
self.epochMillis = epochMillis;
|
||||
Object.defineProperty(self, "partsUtc", {
|
||||
value: undefined,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
return self;
|
||||
};
|
||||
/** @internal */
|
||||
export const unsafeFromDate = date => {
|
||||
const epochMillis = date.getTime();
|
||||
if (Number.isNaN(epochMillis)) {
|
||||
throw new IllegalArgumentException("Invalid date");
|
||||
}
|
||||
return makeUtc(epochMillis);
|
||||
};
|
||||
/** @internal */
|
||||
export const unsafeMake = input => {
|
||||
if (isDateTime(input)) {
|
||||
return input;
|
||||
} else if (input instanceof Date) {
|
||||
return unsafeFromDate(input);
|
||||
} else if (typeof input === "object") {
|
||||
const date = new Date(0);
|
||||
setPartsDate(date, input);
|
||||
return unsafeFromDate(date);
|
||||
} else if (typeof input === "string" && !hasZone(input)) {
|
||||
return unsafeFromDate(new Date(input + "Z"));
|
||||
}
|
||||
return unsafeFromDate(new Date(input));
|
||||
};
|
||||
const hasZone = input => /Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(input);
|
||||
const minEpochMillis = -8640000000000000 + 12 * 60 * 60 * 1000;
|
||||
const maxEpochMillis = 8640000000000000 - 14 * 60 * 60 * 1000;
|
||||
/** @internal */
|
||||
export const unsafeMakeZoned = (input, options) => {
|
||||
if (options?.timeZone === undefined && isDateTime(input) && isZoned(input)) {
|
||||
return input;
|
||||
}
|
||||
const self = unsafeMake(input);
|
||||
if (self.epochMillis < minEpochMillis || self.epochMillis > maxEpochMillis) {
|
||||
throw new RangeError(`Epoch millis out of range: ${self.epochMillis}`);
|
||||
}
|
||||
let zone;
|
||||
if (options?.timeZone === undefined) {
|
||||
const offset = new Date(self.epochMillis).getTimezoneOffset() * -60 * 1000;
|
||||
zone = zoneMakeOffset(offset);
|
||||
} else if (isTimeZone(options?.timeZone)) {
|
||||
zone = options.timeZone;
|
||||
} else if (typeof options?.timeZone === "number") {
|
||||
zone = zoneMakeOffset(options.timeZone);
|
||||
} else {
|
||||
const parsedZone = zoneFromString(options.timeZone);
|
||||
if (Option.isNone(parsedZone)) {
|
||||
throw new IllegalArgumentException(`Invalid time zone: ${options.timeZone}`);
|
||||
}
|
||||
zone = parsedZone.value;
|
||||
}
|
||||
if (options?.adjustForTimeZone !== true) {
|
||||
return makeZonedProto(self.epochMillis, zone, self.partsUtc);
|
||||
}
|
||||
return makeZonedFromAdjusted(self.epochMillis, zone, options?.disambiguation ?? "compatible");
|
||||
};
|
||||
/** @internal */
|
||||
export const makeZoned = /*#__PURE__*/Option.liftThrowable(unsafeMakeZoned);
|
||||
/** @internal */
|
||||
export const make = /*#__PURE__*/Option.liftThrowable(unsafeMake);
|
||||
const zonedStringRegex = /^(.{17,35})\[(.+)\]$/;
|
||||
/** @internal */
|
||||
export const makeZonedFromString = input => {
|
||||
const match = zonedStringRegex.exec(input);
|
||||
if (match === null) {
|
||||
const offset = parseOffset(input);
|
||||
return offset !== null ? makeZoned(input, {
|
||||
timeZone: offset
|
||||
}) : Option.none();
|
||||
}
|
||||
const [, isoString, timeZone] = match;
|
||||
return makeZoned(isoString, {
|
||||
timeZone
|
||||
});
|
||||
};
|
||||
/** @internal */
|
||||
export const now = /*#__PURE__*/core.map(Clock.currentTimeMillis, makeUtc);
|
||||
/** @internal */
|
||||
export const nowAsDate = /*#__PURE__*/core.map(Clock.currentTimeMillis, millis => new Date(millis));
|
||||
/** @internal */
|
||||
export const unsafeNow = () => makeUtc(Date.now());
|
||||
// =============================================================================
|
||||
// time zones
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const toUtc = self => makeUtc(self.epochMillis);
|
||||
/** @internal */
|
||||
export const setZone = /*#__PURE__*/dual(isDateTimeArgs, (self, zone, options) => options?.adjustForTimeZone === true ? makeZonedFromAdjusted(self.epochMillis, zone, options?.disambiguation ?? "compatible") : makeZonedProto(self.epochMillis, zone, self.partsUtc));
|
||||
/** @internal */
|
||||
export const setZoneOffset = /*#__PURE__*/dual(isDateTimeArgs, (self, offset, options) => setZone(self, zoneMakeOffset(offset), options));
|
||||
const validZoneCache = /*#__PURE__*/globalValue("effect/DateTime/validZoneCache", () => new Map());
|
||||
const formatOptions = {
|
||||
day: "numeric",
|
||||
month: "numeric",
|
||||
year: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
second: "numeric",
|
||||
timeZoneName: "longOffset",
|
||||
fractionalSecondDigits: 3,
|
||||
hourCycle: "h23"
|
||||
};
|
||||
const zoneMakeIntl = format => {
|
||||
const zoneId = format.resolvedOptions().timeZone;
|
||||
if (validZoneCache.has(zoneId)) {
|
||||
return validZoneCache.get(zoneId);
|
||||
}
|
||||
const zone = Object.create(ProtoTimeZoneNamed);
|
||||
zone.id = zoneId;
|
||||
zone.format = format;
|
||||
validZoneCache.set(zoneId, zone);
|
||||
return zone;
|
||||
};
|
||||
/** @internal */
|
||||
export const zoneUnsafeMakeNamed = zoneId => {
|
||||
if (validZoneCache.has(zoneId)) {
|
||||
return validZoneCache.get(zoneId);
|
||||
}
|
||||
try {
|
||||
return zoneMakeIntl(new Intl.DateTimeFormat("en-US", {
|
||||
...formatOptions,
|
||||
timeZone: zoneId
|
||||
}));
|
||||
} catch {
|
||||
throw new IllegalArgumentException(`Invalid time zone: ${zoneId}`);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const zoneMakeOffset = offset => {
|
||||
const zone = Object.create(ProtoTimeZoneOffset);
|
||||
zone.offset = offset;
|
||||
return zone;
|
||||
};
|
||||
/** @internal */
|
||||
export const zoneMakeNamed = /*#__PURE__*/Option.liftThrowable(zoneUnsafeMakeNamed);
|
||||
/** @internal */
|
||||
export const zoneMakeNamedEffect = zoneId => internalEffect.try_({
|
||||
try: () => zoneUnsafeMakeNamed(zoneId),
|
||||
catch: e => e
|
||||
});
|
||||
/** @internal */
|
||||
export const zoneMakeLocal = () => zoneMakeIntl(new Intl.DateTimeFormat("en-US", formatOptions));
|
||||
const offsetZoneRegex = /^(?:GMT|[+-])/;
|
||||
/** @internal */
|
||||
export const zoneFromString = zone => {
|
||||
if (offsetZoneRegex.test(zone)) {
|
||||
const offset = parseOffset(zone);
|
||||
return offset === null ? Option.none() : Option.some(zoneMakeOffset(offset));
|
||||
}
|
||||
return zoneMakeNamed(zone);
|
||||
};
|
||||
/** @internal */
|
||||
export const zoneToString = self => {
|
||||
if (self._tag === "Offset") {
|
||||
return offsetToString(self.offset);
|
||||
}
|
||||
return self.id;
|
||||
};
|
||||
/** @internal */
|
||||
export const setZoneNamed = /*#__PURE__*/dual(isDateTimeArgs, (self, zoneId, options) => Option.map(zoneMakeNamed(zoneId), zone => setZone(self, zone, options)));
|
||||
/** @internal */
|
||||
export const unsafeSetZoneNamed = /*#__PURE__*/dual(isDateTimeArgs, (self, zoneId, options) => setZone(self, zoneUnsafeMakeNamed(zoneId), options));
|
||||
// =============================================================================
|
||||
// comparisons
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const distance = /*#__PURE__*/dual(2, (self, other) => toEpochMillis(other) - toEpochMillis(self));
|
||||
/** @internal */
|
||||
export const distanceDurationEither = /*#__PURE__*/dual(2, (self, other) => {
|
||||
const diffMillis = distance(self, other);
|
||||
return diffMillis > 0 ? Either.right(Duration.millis(diffMillis)) : Either.left(Duration.millis(-diffMillis));
|
||||
});
|
||||
/** @internal */
|
||||
export const distanceDuration = /*#__PURE__*/dual(2, (self, other) => Duration.millis(Math.abs(distance(self, other))));
|
||||
/** @internal */
|
||||
export const min = /*#__PURE__*/order.min(Order);
|
||||
/** @internal */
|
||||
export const max = /*#__PURE__*/order.max(Order);
|
||||
/** @internal */
|
||||
export const greaterThan = /*#__PURE__*/order.greaterThan(Order);
|
||||
/** @internal */
|
||||
export const greaterThanOrEqualTo = /*#__PURE__*/order.greaterThanOrEqualTo(Order);
|
||||
/** @internal */
|
||||
export const lessThan = /*#__PURE__*/order.lessThan(Order);
|
||||
/** @internal */
|
||||
export const lessThanOrEqualTo = /*#__PURE__*/order.lessThanOrEqualTo(Order);
|
||||
/** @internal */
|
||||
export const between = /*#__PURE__*/order.between(Order);
|
||||
/** @internal */
|
||||
export const isFuture = self => core.map(now, lessThan(self));
|
||||
/** @internal */
|
||||
export const unsafeIsFuture = self => lessThan(unsafeNow(), self);
|
||||
/** @internal */
|
||||
export const isPast = self => core.map(now, greaterThan(self));
|
||||
/** @internal */
|
||||
export const unsafeIsPast = self => greaterThan(unsafeNow(), self);
|
||||
// =============================================================================
|
||||
// conversions
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const toDateUtc = self => new Date(self.epochMillis);
|
||||
/** @internal */
|
||||
export const toDate = self => {
|
||||
if (self._tag === "Utc") {
|
||||
return new Date(self.epochMillis);
|
||||
} else if (self.zone._tag === "Offset") {
|
||||
return new Date(self.epochMillis + self.zone.offset);
|
||||
} else if (self.adjustedEpochMillis !== undefined) {
|
||||
return new Date(self.adjustedEpochMillis);
|
||||
}
|
||||
const parts = self.zone.format.formatToParts(self.epochMillis).filter(_ => _.type !== "literal");
|
||||
const date = new Date(0);
|
||||
date.setUTCFullYear(Number(parts[2].value), Number(parts[0].value) - 1, Number(parts[1].value));
|
||||
date.setUTCHours(Number(parts[3].value), Number(parts[4].value), Number(parts[5].value), Number(parts[6].value));
|
||||
self.adjustedEpochMillis = date.getTime();
|
||||
return date;
|
||||
};
|
||||
/** @internal */
|
||||
export const zonedOffset = self => {
|
||||
const date = toDate(self);
|
||||
return date.getTime() - toEpochMillis(self);
|
||||
};
|
||||
const offsetToString = offset => {
|
||||
const abs = Math.abs(offset);
|
||||
let hours = Math.floor(abs / (60 * 60 * 1000));
|
||||
let minutes = Math.round(abs % (60 * 60 * 1000) / (60 * 1000));
|
||||
if (minutes === 60) {
|
||||
hours += 1;
|
||||
minutes = 0;
|
||||
}
|
||||
return `${offset < 0 ? "-" : "+"}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
|
||||
};
|
||||
/** @internal */
|
||||
export const zonedOffsetIso = self => offsetToString(zonedOffset(self));
|
||||
/** @internal */
|
||||
export const toEpochMillis = self => self.epochMillis;
|
||||
/** @internal */
|
||||
export const removeTime = self => withDate(self, date => {
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
return makeUtc(date.getTime());
|
||||
});
|
||||
// =============================================================================
|
||||
// parts
|
||||
// =============================================================================
|
||||
const dateToParts = date => ({
|
||||
millis: date.getUTCMilliseconds(),
|
||||
seconds: date.getUTCSeconds(),
|
||||
minutes: date.getUTCMinutes(),
|
||||
hours: date.getUTCHours(),
|
||||
day: date.getUTCDate(),
|
||||
weekDay: date.getUTCDay(),
|
||||
month: date.getUTCMonth() + 1,
|
||||
year: date.getUTCFullYear()
|
||||
});
|
||||
/** @internal */
|
||||
export const toParts = self => {
|
||||
if (self._tag === "Utc") {
|
||||
return toPartsUtc(self);
|
||||
} else if (self.partsAdjusted !== undefined) {
|
||||
return self.partsAdjusted;
|
||||
}
|
||||
self.partsAdjusted = withDate(self, dateToParts);
|
||||
return self.partsAdjusted;
|
||||
};
|
||||
/** @internal */
|
||||
export const toPartsUtc = self => {
|
||||
if (self.partsUtc !== undefined) {
|
||||
return self.partsUtc;
|
||||
}
|
||||
self.partsUtc = withDateUtc(self, dateToParts);
|
||||
return self.partsUtc;
|
||||
};
|
||||
/** @internal */
|
||||
export const getPartUtc = /*#__PURE__*/dual(2, (self, part) => toPartsUtc(self)[part]);
|
||||
/** @internal */
|
||||
export const getPart = /*#__PURE__*/dual(2, (self, part) => toParts(self)[part]);
|
||||
const setPartsDate = (date, parts) => {
|
||||
if (parts.year !== undefined) {
|
||||
date.setUTCFullYear(parts.year);
|
||||
}
|
||||
if (parts.month !== undefined) {
|
||||
date.setUTCMonth(parts.month - 1);
|
||||
}
|
||||
if (parts.day !== undefined) {
|
||||
date.setUTCDate(parts.day);
|
||||
}
|
||||
if (parts.weekDay !== undefined) {
|
||||
const diff = parts.weekDay - date.getUTCDay();
|
||||
date.setUTCDate(date.getUTCDate() + diff);
|
||||
}
|
||||
if (parts.hours !== undefined) {
|
||||
date.setUTCHours(parts.hours);
|
||||
}
|
||||
if (parts.minutes !== undefined) {
|
||||
date.setUTCMinutes(parts.minutes);
|
||||
}
|
||||
if (parts.seconds !== undefined) {
|
||||
date.setUTCSeconds(parts.seconds);
|
||||
}
|
||||
if (parts.millis !== undefined) {
|
||||
date.setUTCMilliseconds(parts.millis);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const setParts = /*#__PURE__*/dual(2, (self, parts) => mutate(self, date => setPartsDate(date, parts)));
|
||||
/** @internal */
|
||||
export const setPartsUtc = /*#__PURE__*/dual(2, (self, parts) => mutateUtc(self, date => setPartsDate(date, parts)));
|
||||
// =============================================================================
|
||||
// mapping
|
||||
// =============================================================================
|
||||
const constDayMillis = 24 * 60 * 60 * 1000;
|
||||
const makeZonedFromAdjusted = (adjustedMillis, zone, disambiguation) => {
|
||||
if (zone._tag === "Offset") {
|
||||
return makeZonedProto(adjustedMillis - zone.offset, zone);
|
||||
}
|
||||
const beforeOffset = calculateNamedOffset(adjustedMillis - constDayMillis, adjustedMillis, zone);
|
||||
const afterOffset = calculateNamedOffset(adjustedMillis + constDayMillis, adjustedMillis, zone);
|
||||
// If there is no transition, we can return early
|
||||
if (beforeOffset === afterOffset) {
|
||||
return makeZonedProto(adjustedMillis - beforeOffset, zone);
|
||||
}
|
||||
const isForwards = beforeOffset < afterOffset;
|
||||
const transitionMillis = beforeOffset - afterOffset;
|
||||
// If the transition is forwards, we only need to check if we should move the
|
||||
// local wall clock time forward if it is inside the gap
|
||||
if (isForwards) {
|
||||
const currentAfterOffset = calculateNamedOffset(adjustedMillis - afterOffset, adjustedMillis, zone);
|
||||
if (currentAfterOffset === afterOffset) {
|
||||
return makeZonedProto(adjustedMillis - afterOffset, zone);
|
||||
}
|
||||
const before = makeZonedProto(adjustedMillis - beforeOffset, zone);
|
||||
const beforeAdjustedMillis = toDate(before).getTime();
|
||||
// If the wall clock time has changed, we are inside the gap
|
||||
if (adjustedMillis !== beforeAdjustedMillis) {
|
||||
switch (disambiguation) {
|
||||
case "reject":
|
||||
{
|
||||
const formatted = new Date(adjustedMillis).toISOString();
|
||||
throw new RangeError(`Gap time: ${formatted} does not exist in time zone ${zone.id}`);
|
||||
}
|
||||
case "earlier":
|
||||
return makeZonedProto(adjustedMillis - afterOffset, zone);
|
||||
case "compatible":
|
||||
case "later":
|
||||
return before;
|
||||
}
|
||||
}
|
||||
// The wall clock time is in the earlier offset, so we use that
|
||||
return before;
|
||||
}
|
||||
const currentBeforeOffset = calculateNamedOffset(adjustedMillis - beforeOffset, adjustedMillis, zone);
|
||||
// The wall clock time is in the earlier offset, so we use that
|
||||
if (currentBeforeOffset === beforeOffset) {
|
||||
if (disambiguation === "earlier" || disambiguation === "compatible") {
|
||||
return makeZonedProto(adjustedMillis - beforeOffset, zone);
|
||||
}
|
||||
const laterOffset = calculateNamedOffset(adjustedMillis - beforeOffset + transitionMillis, adjustedMillis + transitionMillis, zone);
|
||||
if (laterOffset === beforeOffset) {
|
||||
return makeZonedProto(adjustedMillis - beforeOffset, zone);
|
||||
}
|
||||
// If the offset changed in this period, then we are inside the period where
|
||||
// the wall clock time occurs twice, once in the earlier offset and once in
|
||||
// the later offset.
|
||||
if (disambiguation === "reject") {
|
||||
const formatted = new Date(adjustedMillis).toISOString();
|
||||
throw new RangeError(`Ambiguous time: ${formatted} occurs twice in time zone ${zone.id}`);
|
||||
}
|
||||
// If the disambiguation is "later", we return the later offset below
|
||||
}
|
||||
return makeZonedProto(adjustedMillis - afterOffset, zone);
|
||||
};
|
||||
const offsetRegex = /([+-])(\d{2}):(\d{2})$/;
|
||||
const parseOffset = offset => {
|
||||
const match = offsetRegex.exec(offset);
|
||||
if (match === null) {
|
||||
return null;
|
||||
}
|
||||
const [, sign, hours, minutes] = match;
|
||||
return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes)) * 60 * 1000;
|
||||
};
|
||||
const calculateNamedOffset = (utcMillis, adjustedMillis, zone) => {
|
||||
const offset = zone.format.formatToParts(utcMillis).find(_ => _.type === "timeZoneName")?.value ?? "";
|
||||
if (offset === "GMT") {
|
||||
return 0;
|
||||
}
|
||||
const result = parseOffset(offset);
|
||||
if (result === null) {
|
||||
// fallback to using the adjusted date
|
||||
return zonedOffset(makeZonedProto(adjustedMillis, zone));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/** @internal */
|
||||
export const mutate = /*#__PURE__*/dual(isDateTimeArgs, (self, f, options) => {
|
||||
if (self._tag === "Utc") {
|
||||
const date = toDateUtc(self);
|
||||
f(date);
|
||||
return makeUtc(date.getTime());
|
||||
}
|
||||
const adjustedDate = toDate(self);
|
||||
const newAdjustedDate = new Date(adjustedDate.getTime());
|
||||
f(newAdjustedDate);
|
||||
return makeZonedFromAdjusted(newAdjustedDate.getTime(), self.zone, options?.disambiguation ?? "compatible");
|
||||
});
|
||||
/** @internal */
|
||||
export const mutateUtc = /*#__PURE__*/dual(2, (self, f) => mapEpochMillis(self, millis => {
|
||||
const date = new Date(millis);
|
||||
f(date);
|
||||
return date.getTime();
|
||||
}));
|
||||
/** @internal */
|
||||
export const mapEpochMillis = /*#__PURE__*/dual(2, (self, f) => {
|
||||
const millis = f(toEpochMillis(self));
|
||||
return self._tag === "Utc" ? makeUtc(millis) : makeZonedProto(millis, self.zone);
|
||||
});
|
||||
/** @internal */
|
||||
export const withDate = /*#__PURE__*/dual(2, (self, f) => f(toDate(self)));
|
||||
/** @internal */
|
||||
export const withDateUtc = /*#__PURE__*/dual(2, (self, f) => f(toDateUtc(self)));
|
||||
/** @internal */
|
||||
export const match = /*#__PURE__*/dual(2, (self, options) => self._tag === "Utc" ? options.onUtc(self) : options.onZoned(self));
|
||||
// =============================================================================
|
||||
// math
|
||||
// =============================================================================
|
||||
/** @internal */
|
||||
export const addDuration = /*#__PURE__*/dual(2, (self, duration) => mapEpochMillis(self, millis => millis + Duration.toMillis(duration)));
|
||||
/** @internal */
|
||||
export const subtractDuration = /*#__PURE__*/dual(2, (self, duration) => mapEpochMillis(self, millis => millis - Duration.toMillis(duration)));
|
||||
const addMillis = (date, amount) => {
|
||||
date.setTime(date.getTime() + amount);
|
||||
};
|
||||
/** @internal */
|
||||
export const add = /*#__PURE__*/dual(2, (self, parts) => mutate(self, date => {
|
||||
if (parts.millis) {
|
||||
addMillis(date, parts.millis);
|
||||
}
|
||||
if (parts.seconds) {
|
||||
addMillis(date, parts.seconds * 1000);
|
||||
}
|
||||
if (parts.minutes) {
|
||||
addMillis(date, parts.minutes * 60 * 1000);
|
||||
}
|
||||
if (parts.hours) {
|
||||
addMillis(date, parts.hours * 60 * 60 * 1000);
|
||||
}
|
||||
if (parts.days) {
|
||||
date.setUTCDate(date.getUTCDate() + parts.days);
|
||||
}
|
||||
if (parts.weeks) {
|
||||
date.setUTCDate(date.getUTCDate() + parts.weeks * 7);
|
||||
}
|
||||
if (parts.months) {
|
||||
const day = date.getUTCDate();
|
||||
date.setUTCMonth(date.getUTCMonth() + parts.months + 1, 0);
|
||||
if (day < date.getUTCDate()) {
|
||||
date.setUTCDate(day);
|
||||
}
|
||||
}
|
||||
if (parts.years) {
|
||||
const day = date.getUTCDate();
|
||||
const month = date.getUTCMonth();
|
||||
date.setUTCFullYear(date.getUTCFullYear() + parts.years, month + 1, 0);
|
||||
if (day < date.getUTCDate()) {
|
||||
date.setUTCDate(day);
|
||||
}
|
||||
}
|
||||
}));
|
||||
/** @internal */
|
||||
export const subtract = /*#__PURE__*/dual(2, (self, parts) => {
|
||||
const newParts = {};
|
||||
for (const key in parts) {
|
||||
newParts[key] = -1 * parts[key];
|
||||
}
|
||||
return add(self, newParts);
|
||||
});
|
||||
const startOfDate = (date, part, options) => {
|
||||
switch (part) {
|
||||
case "second":
|
||||
{
|
||||
date.setUTCMilliseconds(0);
|
||||
break;
|
||||
}
|
||||
case "minute":
|
||||
{
|
||||
date.setUTCSeconds(0, 0);
|
||||
break;
|
||||
}
|
||||
case "hour":
|
||||
{
|
||||
date.setUTCMinutes(0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case "day":
|
||||
{
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case "week":
|
||||
{
|
||||
const weekStartsOn = options?.weekStartsOn ?? 0;
|
||||
const day = date.getUTCDay();
|
||||
const diff = (day - weekStartsOn + 7) % 7;
|
||||
date.setUTCDate(date.getUTCDate() - diff);
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case "month":
|
||||
{
|
||||
date.setUTCDate(1);
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case "year":
|
||||
{
|
||||
date.setUTCMonth(0, 1);
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const startOf = /*#__PURE__*/dual(isDateTimeArgs, (self, part, options) => mutate(self, date => startOfDate(date, part, options)));
|
||||
const endOfDate = (date, part, options) => {
|
||||
switch (part) {
|
||||
case "second":
|
||||
{
|
||||
date.setUTCMilliseconds(999);
|
||||
break;
|
||||
}
|
||||
case "minute":
|
||||
{
|
||||
date.setUTCSeconds(59, 999);
|
||||
break;
|
||||
}
|
||||
case "hour":
|
||||
{
|
||||
date.setUTCMinutes(59, 59, 999);
|
||||
break;
|
||||
}
|
||||
case "day":
|
||||
{
|
||||
date.setUTCHours(23, 59, 59, 999);
|
||||
break;
|
||||
}
|
||||
case "week":
|
||||
{
|
||||
const weekStartsOn = options?.weekStartsOn ?? 0;
|
||||
const day = date.getUTCDay();
|
||||
const diff = (day - weekStartsOn + 7) % 7;
|
||||
date.setUTCDate(date.getUTCDate() - diff + 6);
|
||||
date.setUTCHours(23, 59, 59, 999);
|
||||
break;
|
||||
}
|
||||
case "month":
|
||||
{
|
||||
date.setUTCMonth(date.getUTCMonth() + 1, 0);
|
||||
date.setUTCHours(23, 59, 59, 999);
|
||||
break;
|
||||
}
|
||||
case "year":
|
||||
{
|
||||
date.setUTCMonth(11, 31);
|
||||
date.setUTCHours(23, 59, 59, 999);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const endOf = /*#__PURE__*/dual(isDateTimeArgs, (self, part, options) => mutate(self, date => endOfDate(date, part, options)));
|
||||
/** @internal */
|
||||
export const nearest = /*#__PURE__*/dual(isDateTimeArgs, (self, part, options) => mutate(self, date => {
|
||||
if (part === "milli") return;
|
||||
const millis = date.getTime();
|
||||
const start = new Date(millis);
|
||||
startOfDate(start, part, options);
|
||||
const startMillis = start.getTime();
|
||||
const end = new Date(millis);
|
||||
endOfDate(end, part, options);
|
||||
const endMillis = end.getTime() + 1;
|
||||
const diffStart = millis - startMillis;
|
||||
const diffEnd = endMillis - millis;
|
||||
if (diffStart < diffEnd) {
|
||||
date.setTime(startMillis);
|
||||
} else {
|
||||
date.setTime(endMillis);
|
||||
}
|
||||
}));
|
||||
// =============================================================================
|
||||
// formatting
|
||||
// =============================================================================
|
||||
const intlTimeZone = self => {
|
||||
if (self._tag === "Named") {
|
||||
return self.id;
|
||||
}
|
||||
return offsetToString(self.offset);
|
||||
};
|
||||
/** @internal */
|
||||
export const format = /*#__PURE__*/dual(isDateTimeArgs, (self, options) => {
|
||||
try {
|
||||
return new Intl.DateTimeFormat(options?.locale, {
|
||||
timeZone: self._tag === "Utc" ? "UTC" : intlTimeZone(self.zone),
|
||||
...options
|
||||
}).format(self.epochMillis);
|
||||
} catch {
|
||||
return new Intl.DateTimeFormat(options?.locale, {
|
||||
timeZone: "UTC",
|
||||
...options
|
||||
}).format(toDate(self));
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
export const formatLocal = /*#__PURE__*/dual(isDateTimeArgs, (self, options) => new Intl.DateTimeFormat(options?.locale, options).format(self.epochMillis));
|
||||
/** @internal */
|
||||
export const formatUtc = /*#__PURE__*/dual(isDateTimeArgs, (self, options) => new Intl.DateTimeFormat(options?.locale, {
|
||||
...options,
|
||||
timeZone: "UTC"
|
||||
}).format(self.epochMillis));
|
||||
/** @internal */
|
||||
export const formatIntl = /*#__PURE__*/dual(2, (self, format) => format.format(self.epochMillis));
|
||||
/** @internal */
|
||||
export const formatIso = self => toDateUtc(self).toISOString();
|
||||
/** @internal */
|
||||
export const formatIsoDate = self => toDate(self).toISOString().slice(0, 10);
|
||||
/** @internal */
|
||||
export const formatIsoDateUtc = self => toDateUtc(self).toISOString().slice(0, 10);
|
||||
/** @internal */
|
||||
export const formatIsoOffset = self => {
|
||||
const date = toDate(self);
|
||||
return self._tag === "Utc" ? date.toISOString() : `${date.toISOString().slice(0, -1)}${zonedOffsetIso(self)}`;
|
||||
};
|
||||
/** @internal */
|
||||
export const formatIsoZoned = self => self.zone._tag === "Offset" ? formatIsoOffset(self) : `${formatIsoOffset(self)}[${self.zone.id}]`;
|
||||
//# sourceMappingURL=dateTime.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/dateTime.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/dateTime.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
73
_node_modules/effect/dist/esm/internal/defaultServices.js
generated
vendored
Normal file
73
_node_modules/effect/dist/esm/internal/defaultServices.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import * as Array from "../Array.js";
|
||||
import * as Context from "../Context.js";
|
||||
import * as Duration from "../Duration.js";
|
||||
import { dual, pipe } from "../Function.js";
|
||||
import { globalValue } from "../GlobalValue.js";
|
||||
import * as clock from "./clock.js";
|
||||
import * as configProvider from "./configProvider.js";
|
||||
import * as core from "./core.js";
|
||||
import * as console_ from "./defaultServices/console.js";
|
||||
import * as random from "./random.js";
|
||||
import * as tracer from "./tracer.js";
|
||||
/** @internal */
|
||||
export const liveServices = /*#__PURE__*/pipe(/*#__PURE__*/Context.empty(), /*#__PURE__*/Context.add(clock.clockTag, /*#__PURE__*/clock.make()), /*#__PURE__*/Context.add(console_.consoleTag, console_.defaultConsole), /*#__PURE__*/Context.add(random.randomTag, /*#__PURE__*/random.make(/*#__PURE__*/Math.random())), /*#__PURE__*/Context.add(configProvider.configProviderTag, /*#__PURE__*/configProvider.fromEnv()), /*#__PURE__*/Context.add(tracer.tracerTag, tracer.nativeTracer));
|
||||
/**
|
||||
* The `FiberRef` holding the default `Effect` services.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @category fiberRefs
|
||||
*/
|
||||
export const currentServices = /*#__PURE__*/globalValue(/*#__PURE__*/Symbol.for("effect/DefaultServices/currentServices"), () => core.fiberRefUnsafeMakeContext(liveServices));
|
||||
// circular with Clock
|
||||
/** @internal */
|
||||
export const sleep = duration => {
|
||||
const decodedDuration = Duration.decode(duration);
|
||||
return clockWith(clock => clock.sleep(decodedDuration));
|
||||
};
|
||||
/** @internal */
|
||||
export const defaultServicesWith = f => core.withFiberRuntime(fiber => f(fiber.currentDefaultServices));
|
||||
/** @internal */
|
||||
export const clockWith = f => defaultServicesWith(services => f(services.unsafeMap.get(clock.clockTag.key)));
|
||||
/** @internal */
|
||||
export const currentTimeMillis = /*#__PURE__*/clockWith(clock => clock.currentTimeMillis);
|
||||
/** @internal */
|
||||
export const currentTimeNanos = /*#__PURE__*/clockWith(clock => clock.currentTimeNanos);
|
||||
/** @internal */
|
||||
export const withClock = /*#__PURE__*/dual(2, (effect, c) => core.fiberRefLocallyWith(currentServices, Context.add(clock.clockTag, c))(effect));
|
||||
// circular with ConfigProvider
|
||||
/** @internal */
|
||||
export const withConfigProvider = /*#__PURE__*/dual(2, (self, provider) => core.fiberRefLocallyWith(currentServices, Context.add(configProvider.configProviderTag, provider))(self));
|
||||
/** @internal */
|
||||
export const configProviderWith = f => defaultServicesWith(services => f(services.unsafeMap.get(configProvider.configProviderTag.key)));
|
||||
/** @internal */
|
||||
export const config = config => configProviderWith(_ => _.load(config));
|
||||
/** @internal */
|
||||
export const configOrDie = config => core.orDie(configProviderWith(_ => _.load(config)));
|
||||
// circular with Random
|
||||
/** @internal */
|
||||
export const randomWith = f => defaultServicesWith(services => f(services.unsafeMap.get(random.randomTag.key)));
|
||||
/** @internal */
|
||||
export const withRandom = /*#__PURE__*/dual(2, (effect, value) => core.fiberRefLocallyWith(currentServices, Context.add(random.randomTag, value))(effect));
|
||||
/** @internal */
|
||||
export const next = /*#__PURE__*/randomWith(random => random.next);
|
||||
/** @internal */
|
||||
export const nextInt = /*#__PURE__*/randomWith(random => random.nextInt);
|
||||
/** @internal */
|
||||
export const nextBoolean = /*#__PURE__*/randomWith(random => random.nextBoolean);
|
||||
/** @internal */
|
||||
export const nextRange = (min, max) => randomWith(random => random.nextRange(min, max));
|
||||
/** @internal */
|
||||
export const nextIntBetween = (min, max) => randomWith(random => random.nextIntBetween(min, max));
|
||||
/** @internal */
|
||||
export const shuffle = elements => randomWith(random => random.shuffle(elements));
|
||||
/** @internal */
|
||||
export const choice = elements => {
|
||||
const array = Array.fromIterable(elements);
|
||||
return core.map(array.length === 0 ? core.fail(new core.NoSuchElementException("Cannot select a random element from an empty array")) : randomWith(random => random.nextIntBetween(0, array.length)), i => array[i]);
|
||||
};
|
||||
// circular with Tracer
|
||||
/** @internal */
|
||||
export const tracerWith = f => defaultServicesWith(services => f(services.unsafeMap.get(tracer.tracerTag.key)));
|
||||
/** @internal */
|
||||
export const withTracer = /*#__PURE__*/dual(2, (effect, value) => core.fiberRefLocallyWith(currentServices, Context.add(tracer.tracerTag, value))(effect));
|
||||
//# sourceMappingURL=defaultServices.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/defaultServices.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/defaultServices.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
92
_node_modules/effect/dist/esm/internal/defaultServices/console.js
generated
vendored
Normal file
92
_node_modules/effect/dist/esm/internal/defaultServices/console.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import * as Context from "../../Context.js";
|
||||
import * as core from "../core.js";
|
||||
/** @internal */
|
||||
export const TypeId = /*#__PURE__*/Symbol.for("effect/Console");
|
||||
/** @internal */
|
||||
export const consoleTag = /*#__PURE__*/Context.GenericTag("effect/Console");
|
||||
/** @internal */
|
||||
export const defaultConsole = {
|
||||
[TypeId]: TypeId,
|
||||
assert(condition, ...args) {
|
||||
return core.sync(() => {
|
||||
console.assert(condition, ...args);
|
||||
});
|
||||
},
|
||||
clear: /*#__PURE__*/core.sync(() => {
|
||||
console.clear();
|
||||
}),
|
||||
count(label) {
|
||||
return core.sync(() => {
|
||||
console.count(label);
|
||||
});
|
||||
},
|
||||
countReset(label) {
|
||||
return core.sync(() => {
|
||||
console.countReset(label);
|
||||
});
|
||||
},
|
||||
debug(...args) {
|
||||
return core.sync(() => {
|
||||
console.debug(...args);
|
||||
});
|
||||
},
|
||||
dir(item, options) {
|
||||
return core.sync(() => {
|
||||
console.dir(item, options);
|
||||
});
|
||||
},
|
||||
dirxml(...args) {
|
||||
return core.sync(() => {
|
||||
console.dirxml(...args);
|
||||
});
|
||||
},
|
||||
error(...args) {
|
||||
return core.sync(() => {
|
||||
console.error(...args);
|
||||
});
|
||||
},
|
||||
group(options) {
|
||||
return options?.collapsed ? core.sync(() => console.groupCollapsed(options?.label)) : core.sync(() => console.group(options?.label));
|
||||
},
|
||||
groupEnd: /*#__PURE__*/core.sync(() => {
|
||||
console.groupEnd();
|
||||
}),
|
||||
info(...args) {
|
||||
return core.sync(() => {
|
||||
console.info(...args);
|
||||
});
|
||||
},
|
||||
log(...args) {
|
||||
return core.sync(() => {
|
||||
console.log(...args);
|
||||
});
|
||||
},
|
||||
table(tabularData, properties) {
|
||||
return core.sync(() => {
|
||||
console.table(tabularData, properties);
|
||||
});
|
||||
},
|
||||
time(label) {
|
||||
return core.sync(() => console.time(label));
|
||||
},
|
||||
timeEnd(label) {
|
||||
return core.sync(() => console.timeEnd(label));
|
||||
},
|
||||
timeLog(label, ...args) {
|
||||
return core.sync(() => {
|
||||
console.timeLog(label, ...args);
|
||||
});
|
||||
},
|
||||
trace(...args) {
|
||||
return core.sync(() => {
|
||||
console.trace(...args);
|
||||
});
|
||||
},
|
||||
warn(...args) {
|
||||
return core.sync(() => {
|
||||
console.warn(...args);
|
||||
});
|
||||
},
|
||||
unsafe: console
|
||||
};
|
||||
//# sourceMappingURL=console.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/defaultServices/console.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/defaultServices/console.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"console.js","names":["Context","core","TypeId","Symbol","for","consoleTag","GenericTag","defaultConsole","assert","condition","args","sync","console","clear","count","label","countReset","debug","dir","item","options","dirxml","error","group","collapsed","groupCollapsed","groupEnd","info","log","table","tabularData","properties","time","timeEnd","timeLog","trace","warn","unsafe"],"sources":["../../../../src/internal/defaultServices/console.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
27
_node_modules/effect/dist/esm/internal/deferred.js
generated
vendored
Normal file
27
_node_modules/effect/dist/esm/internal/deferred.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as OpCodes from "./opCodes/deferred.js";
|
||||
/** @internal */
|
||||
const DeferredSymbolKey = "effect/Deferred";
|
||||
/** @internal */
|
||||
export const DeferredTypeId = /*#__PURE__*/Symbol.for(DeferredSymbolKey);
|
||||
/** @internal */
|
||||
export const deferredVariance = {
|
||||
/* c8 ignore next */
|
||||
_E: _ => _,
|
||||
/* c8 ignore next */
|
||||
_A: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
export const pending = joiners => {
|
||||
return {
|
||||
_tag: OpCodes.OP_STATE_PENDING,
|
||||
joiners
|
||||
};
|
||||
};
|
||||
/** @internal */
|
||||
export const done = effect => {
|
||||
return {
|
||||
_tag: OpCodes.OP_STATE_DONE,
|
||||
effect
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=deferred.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/deferred.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/deferred.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deferred.js","names":["OpCodes","DeferredSymbolKey","DeferredTypeId","Symbol","for","deferredVariance","_E","_","_A","pending","joiners","_tag","OP_STATE_PENDING","done","effect","OP_STATE_DONE"],"sources":["../../../src/internal/deferred.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAKA,OAAO,MAAM,uBAAuB;AAEhD;AACA,MAAMC,iBAAiB,GAAG,iBAAiB;AAE3C;AACA,OAAO,MAAMC,cAAc,gBAA4BC,MAAM,CAACC,GAAG,CAC/DH,iBAAiB,CACS;AAE5B;AACA,OAAO,MAAMI,gBAAgB,GAAG;EAC9B;EACAC,EAAE,EAAGC,CAAM,IAAKA,CAAC;EACjB;EACAC,EAAE,EAAGD,CAAM,IAAKA;CACjB;AAiBD;AACA,OAAO,MAAME,OAAO,GAClBC,OAAqD,IACtC;EACf,OAAO;IAAEC,IAAI,EAAEX,OAAO,CAACY,gBAAgB;IAAEF;EAAO,CAAE;AACpD,CAAC;AAED;AACA,OAAO,MAAMG,IAAI,GAAUC,MAA2B,IAAiB;EACrE,OAAO;IAAEH,IAAI,EAAEX,OAAO,CAACe,aAAa;IAAED;EAAM,CAAE;AAChD,CAAC","ignoreList":[]}
|
||||
134
_node_modules/effect/dist/esm/internal/differ.js
generated
vendored
Normal file
134
_node_modules/effect/dist/esm/internal/differ.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as Dual from "../Function.js";
|
||||
import { constant, identity } from "../Function.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import * as ChunkPatch from "./differ/chunkPatch.js";
|
||||
import * as ContextPatch from "./differ/contextPatch.js";
|
||||
import * as HashMapPatch from "./differ/hashMapPatch.js";
|
||||
import * as HashSetPatch from "./differ/hashSetPatch.js";
|
||||
import * as OrPatch from "./differ/orPatch.js";
|
||||
import * as ReadonlyArrayPatch from "./differ/readonlyArrayPatch.js";
|
||||
/** @internal */
|
||||
export const DifferTypeId = /*#__PURE__*/Symbol.for("effect/Differ");
|
||||
/** @internal */
|
||||
export const DifferProto = {
|
||||
[DifferTypeId]: {
|
||||
_P: identity,
|
||||
_V: identity
|
||||
},
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const make = params => {
|
||||
const differ = Object.create(DifferProto);
|
||||
differ.empty = params.empty;
|
||||
differ.diff = params.diff;
|
||||
differ.combine = params.combine;
|
||||
differ.patch = params.patch;
|
||||
return differ;
|
||||
};
|
||||
/** @internal */
|
||||
export const environment = () => make({
|
||||
empty: ContextPatch.empty(),
|
||||
combine: (first, second) => ContextPatch.combine(second)(first),
|
||||
diff: (oldValue, newValue) => ContextPatch.diff(oldValue, newValue),
|
||||
patch: (patch, oldValue) => ContextPatch.patch(oldValue)(patch)
|
||||
});
|
||||
/** @internal */
|
||||
export const chunk = differ => make({
|
||||
empty: ChunkPatch.empty(),
|
||||
combine: (first, second) => ChunkPatch.combine(second)(first),
|
||||
diff: (oldValue, newValue) => ChunkPatch.diff({
|
||||
oldValue,
|
||||
newValue,
|
||||
differ
|
||||
}),
|
||||
patch: (patch, oldValue) => ChunkPatch.patch(oldValue, differ)(patch)
|
||||
});
|
||||
/** @internal */
|
||||
export const hashMap = differ => make({
|
||||
empty: HashMapPatch.empty(),
|
||||
combine: (first, second) => HashMapPatch.combine(second)(first),
|
||||
diff: (oldValue, newValue) => HashMapPatch.diff({
|
||||
oldValue,
|
||||
newValue,
|
||||
differ
|
||||
}),
|
||||
patch: (patch, oldValue) => HashMapPatch.patch(oldValue, differ)(patch)
|
||||
});
|
||||
/** @internal */
|
||||
export const hashSet = () => make({
|
||||
empty: HashSetPatch.empty(),
|
||||
combine: (first, second) => HashSetPatch.combine(second)(first),
|
||||
diff: (oldValue, newValue) => HashSetPatch.diff(oldValue, newValue),
|
||||
patch: (patch, oldValue) => HashSetPatch.patch(oldValue)(patch)
|
||||
});
|
||||
/** @internal */
|
||||
export const orElseEither = /*#__PURE__*/Dual.dual(2, (self, that) => make({
|
||||
empty: OrPatch.empty(),
|
||||
combine: (first, second) => OrPatch.combine(first, second),
|
||||
diff: (oldValue, newValue) => OrPatch.diff({
|
||||
oldValue,
|
||||
newValue,
|
||||
left: self,
|
||||
right: that
|
||||
}),
|
||||
patch: (patch, oldValue) => OrPatch.patch(patch, {
|
||||
oldValue,
|
||||
left: self,
|
||||
right: that
|
||||
})
|
||||
}));
|
||||
/** @internal */
|
||||
export const readonlyArray = differ => make({
|
||||
empty: ReadonlyArrayPatch.empty(),
|
||||
combine: (first, second) => ReadonlyArrayPatch.combine(first, second),
|
||||
diff: (oldValue, newValue) => ReadonlyArrayPatch.diff({
|
||||
oldValue,
|
||||
newValue,
|
||||
differ
|
||||
}),
|
||||
patch: (patch, oldValue) => ReadonlyArrayPatch.patch(patch, oldValue, differ)
|
||||
});
|
||||
/** @internal */
|
||||
export const transform = /*#__PURE__*/Dual.dual(2, (self, {
|
||||
toNew,
|
||||
toOld
|
||||
}) => make({
|
||||
empty: self.empty,
|
||||
combine: (first, second) => self.combine(first, second),
|
||||
diff: (oldValue, newValue) => self.diff(toOld(oldValue), toOld(newValue)),
|
||||
patch: (patch, oldValue) => toNew(self.patch(patch, toOld(oldValue)))
|
||||
}));
|
||||
/** @internal */
|
||||
export const update = () => updateWith((_, a) => a);
|
||||
/** @internal */
|
||||
export const updateWith = f => make({
|
||||
empty: identity,
|
||||
combine: (first, second) => {
|
||||
if (first === identity) {
|
||||
return second;
|
||||
}
|
||||
if (second === identity) {
|
||||
return first;
|
||||
}
|
||||
return a => second(first(a));
|
||||
},
|
||||
diff: (oldValue, newValue) => {
|
||||
if (Equal.equals(oldValue, newValue)) {
|
||||
return identity;
|
||||
}
|
||||
return constant(newValue);
|
||||
},
|
||||
patch: (patch, oldValue) => f(oldValue, patch(oldValue))
|
||||
});
|
||||
/** @internal */
|
||||
export const zip = /*#__PURE__*/Dual.dual(2, (self, that) => make({
|
||||
empty: [self.empty, that.empty],
|
||||
combine: (first, second) => [self.combine(first[0], second[0]), that.combine(first[1], second[1])],
|
||||
diff: (oldValue, newValue) => [self.diff(oldValue[0], newValue[0]), that.diff(oldValue[1], newValue[1])],
|
||||
patch: (patch, oldValue) => [self.patch(patch[0], oldValue[0]), that.patch(patch[1], oldValue[1])]
|
||||
}));
|
||||
//# sourceMappingURL=differ.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
130
_node_modules/effect/dist/esm/internal/differ/chunkPatch.js
generated
vendored
Normal file
130
_node_modules/effect/dist/esm/internal/differ/chunkPatch.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import * as Chunk from "../../Chunk.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import { pipe } from "../../Function.js";
|
||||
import * as Data from "../data.js";
|
||||
/** @internal */
|
||||
export const ChunkPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferChunkPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
const PatchProto = {
|
||||
...Data.Structural.prototype,
|
||||
[ChunkPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const AppendProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Append"
|
||||
});
|
||||
const makeAppend = values => {
|
||||
const o = Object.create(AppendProto);
|
||||
o.values = values;
|
||||
return o;
|
||||
};
|
||||
const SliceProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Slice"
|
||||
});
|
||||
const makeSlice = (from, until) => {
|
||||
const o = Object.create(SliceProto);
|
||||
o.from = from;
|
||||
o.until = until;
|
||||
return o;
|
||||
};
|
||||
const UpdateProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Update"
|
||||
});
|
||||
const makeUpdate = (index, patch) => {
|
||||
const o = Object.create(UpdateProto);
|
||||
o.index = index;
|
||||
o.patch = patch;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = options => {
|
||||
let i = 0;
|
||||
let patch = empty();
|
||||
while (i < options.oldValue.length && i < options.newValue.length) {
|
||||
const oldElement = Chunk.unsafeGet(i)(options.oldValue);
|
||||
const newElement = Chunk.unsafeGet(i)(options.newValue);
|
||||
const valuePatch = options.differ.diff(oldElement, newElement);
|
||||
if (!Equal.equals(valuePatch, options.differ.empty)) {
|
||||
patch = pipe(patch, combine(makeUpdate(i, valuePatch)));
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
if (i < options.oldValue.length) {
|
||||
patch = pipe(patch, combine(makeSlice(0, i)));
|
||||
}
|
||||
if (i < options.newValue.length) {
|
||||
patch = pipe(patch, combine(makeAppend(Chunk.drop(i)(options.newValue))));
|
||||
}
|
||||
return patch;
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(3, (self, oldValue, differ) => {
|
||||
if (self._tag === "Empty") {
|
||||
return oldValue;
|
||||
}
|
||||
let chunk = oldValue;
|
||||
let patches = Chunk.of(self);
|
||||
while (Chunk.isNonEmpty(patches)) {
|
||||
const head = Chunk.headNonEmpty(patches);
|
||||
const tail = Chunk.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
patches = Chunk.prepend(head.first)(Chunk.prepend(head.second)(tail));
|
||||
break;
|
||||
}
|
||||
case "Append":
|
||||
{
|
||||
chunk = Chunk.appendAll(head.values)(chunk);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Slice":
|
||||
{
|
||||
const array = Chunk.toReadonlyArray(chunk);
|
||||
chunk = Chunk.unsafeFromArray(array.slice(head.from, head.until));
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Update":
|
||||
{
|
||||
const array = Chunk.toReadonlyArray(chunk);
|
||||
array[head.index] = differ.patch(head.patch, array[head.index]);
|
||||
chunk = Chunk.unsafeFromArray(array);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
});
|
||||
//# sourceMappingURL=chunkPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/chunkPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/chunkPatch.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
143
_node_modules/effect/dist/esm/internal/differ/contextPatch.js
generated
vendored
Normal file
143
_node_modules/effect/dist/esm/internal/differ/contextPatch.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import * as Chunk from "../../Chunk.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import { makeContext } from "../context.js";
|
||||
import { Structural } from "../data.js";
|
||||
/** @internal */
|
||||
export const ContextPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferContextPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
/** @internal */
|
||||
const PatchProto = {
|
||||
...Structural.prototype,
|
||||
[ContextPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const AddServiceProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AddService"
|
||||
});
|
||||
const makeAddService = (key, service) => {
|
||||
const o = Object.create(AddServiceProto);
|
||||
o.key = key;
|
||||
o.service = service;
|
||||
return o;
|
||||
};
|
||||
const RemoveServiceProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "RemoveService"
|
||||
});
|
||||
const makeRemoveService = key => {
|
||||
const o = Object.create(RemoveServiceProto);
|
||||
o.key = key;
|
||||
return o;
|
||||
};
|
||||
const UpdateServiceProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "UpdateService"
|
||||
});
|
||||
const makeUpdateService = (key, update) => {
|
||||
const o = Object.create(UpdateServiceProto);
|
||||
o.key = key;
|
||||
o.update = update;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = (oldValue, newValue) => {
|
||||
const missingServices = new Map(oldValue.unsafeMap);
|
||||
let patch = empty();
|
||||
for (const [tag, newService] of newValue.unsafeMap.entries()) {
|
||||
if (missingServices.has(tag)) {
|
||||
const old = missingServices.get(tag);
|
||||
missingServices.delete(tag);
|
||||
if (!Equal.equals(old, newService)) {
|
||||
patch = combine(makeUpdateService(tag, () => newService))(patch);
|
||||
}
|
||||
} else {
|
||||
missingServices.delete(tag);
|
||||
patch = combine(makeAddService(tag, newService))(patch);
|
||||
}
|
||||
}
|
||||
for (const [tag] of missingServices.entries()) {
|
||||
patch = combine(makeRemoveService(tag))(patch);
|
||||
}
|
||||
return patch;
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(2, (self, context) => {
|
||||
if (self._tag === "Empty") {
|
||||
return context;
|
||||
}
|
||||
let wasServiceUpdated = false;
|
||||
let patches = Chunk.of(self);
|
||||
const updatedContext = new Map(context.unsafeMap);
|
||||
while (Chunk.isNonEmpty(patches)) {
|
||||
const head = Chunk.headNonEmpty(patches);
|
||||
const tail = Chunk.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AddService":
|
||||
{
|
||||
updatedContext.set(head.key, head.service);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
patches = Chunk.prepend(Chunk.prepend(tail, head.second), head.first);
|
||||
break;
|
||||
}
|
||||
case "RemoveService":
|
||||
{
|
||||
updatedContext.delete(head.key);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "UpdateService":
|
||||
{
|
||||
updatedContext.set(head.key, head.update(updatedContext.get(head.key)));
|
||||
wasServiceUpdated = true;
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wasServiceUpdated) {
|
||||
return makeContext(updatedContext);
|
||||
}
|
||||
const map = new Map();
|
||||
for (const [tag] of context.unsafeMap) {
|
||||
if (updatedContext.has(tag)) {
|
||||
map.set(tag, updatedContext.get(tag));
|
||||
updatedContext.delete(tag);
|
||||
}
|
||||
}
|
||||
for (const [tag, s] of updatedContext) {
|
||||
map.set(tag, s);
|
||||
}
|
||||
return makeContext(map);
|
||||
});
|
||||
//# sourceMappingURL=contextPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/contextPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/contextPatch.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
130
_node_modules/effect/dist/esm/internal/differ/hashMapPatch.js
generated
vendored
Normal file
130
_node_modules/effect/dist/esm/internal/differ/hashMapPatch.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import * as Chunk from "../../Chunk.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import * as HashMap from "../../HashMap.js";
|
||||
import { Structural } from "../data.js";
|
||||
/** @internal */
|
||||
export const HashMapPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferHashMapPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
/** @internal */
|
||||
const PatchProto = {
|
||||
...Structural.prototype,
|
||||
[HashMapPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Key: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/** @internal */
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const AddProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Add"
|
||||
});
|
||||
const makeAdd = (key, value) => {
|
||||
const o = Object.create(AddProto);
|
||||
o.key = key;
|
||||
o.value = value;
|
||||
return o;
|
||||
};
|
||||
const RemoveProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Remove"
|
||||
});
|
||||
const makeRemove = key => {
|
||||
const o = Object.create(RemoveProto);
|
||||
o.key = key;
|
||||
return o;
|
||||
};
|
||||
const UpdateProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Update"
|
||||
});
|
||||
const makeUpdate = (key, patch) => {
|
||||
const o = Object.create(UpdateProto);
|
||||
o.key = key;
|
||||
o.patch = patch;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = options => {
|
||||
const [removed, patch] = HashMap.reduce([options.oldValue, empty()], ([map, patch], newValue, key) => {
|
||||
const option = HashMap.get(key)(map);
|
||||
switch (option._tag) {
|
||||
case "Some":
|
||||
{
|
||||
const valuePatch = options.differ.diff(option.value, newValue);
|
||||
if (Equal.equals(valuePatch, options.differ.empty)) {
|
||||
return [HashMap.remove(key)(map), patch];
|
||||
}
|
||||
return [HashMap.remove(key)(map), combine(makeUpdate(key, valuePatch))(patch)];
|
||||
}
|
||||
case "None":
|
||||
{
|
||||
return [map, combine(makeAdd(key, newValue))(patch)];
|
||||
}
|
||||
}
|
||||
})(options.newValue);
|
||||
return HashMap.reduce(patch, (patch, _, key) => combine(makeRemove(key))(patch))(removed);
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(3, (self, oldValue, differ) => {
|
||||
if (self._tag === "Empty") {
|
||||
return oldValue;
|
||||
}
|
||||
let map = oldValue;
|
||||
let patches = Chunk.of(self);
|
||||
while (Chunk.isNonEmpty(patches)) {
|
||||
const head = Chunk.headNonEmpty(patches);
|
||||
const tail = Chunk.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
patches = Chunk.prepend(head.first)(Chunk.prepend(head.second)(tail));
|
||||
break;
|
||||
}
|
||||
case "Add":
|
||||
{
|
||||
map = HashMap.set(head.key, head.value)(map);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Remove":
|
||||
{
|
||||
map = HashMap.remove(head.key)(map);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Update":
|
||||
{
|
||||
const option = HashMap.get(head.key)(map);
|
||||
if (option._tag === "Some") {
|
||||
map = HashMap.set(head.key, differ.patch(head.patch, option.value))(map);
|
||||
}
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
//# sourceMappingURL=hashMapPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/hashMapPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/hashMapPatch.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
101
_node_modules/effect/dist/esm/internal/differ/hashSetPatch.js
generated
vendored
Normal file
101
_node_modules/effect/dist/esm/internal/differ/hashSetPatch.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import * as Chunk from "../../Chunk.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import * as HashSet from "../../HashSet.js";
|
||||
import { Structural } from "../data.js";
|
||||
/** @internal */
|
||||
export const HashSetPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferHashSetPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
/** @internal */
|
||||
const PatchProto = {
|
||||
...Structural.prototype,
|
||||
[HashSetPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Key: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/** @internal */
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const AddProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Add"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeAdd = value => {
|
||||
const o = Object.create(AddProto);
|
||||
o.value = value;
|
||||
return o;
|
||||
};
|
||||
const RemoveProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Remove"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeRemove = value => {
|
||||
const o = Object.create(RemoveProto);
|
||||
o.value = value;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = (oldValue, newValue) => {
|
||||
const [removed, patch] = HashSet.reduce([oldValue, empty()], ([set, patch], value) => {
|
||||
if (HashSet.has(value)(set)) {
|
||||
return [HashSet.remove(value)(set), patch];
|
||||
}
|
||||
return [set, combine(makeAdd(value))(patch)];
|
||||
})(newValue);
|
||||
return HashSet.reduce(patch, (patch, value) => combine(makeRemove(value))(patch))(removed);
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(2, (self, oldValue) => {
|
||||
if (self._tag === "Empty") {
|
||||
return oldValue;
|
||||
}
|
||||
let set = oldValue;
|
||||
let patches = Chunk.of(self);
|
||||
while (Chunk.isNonEmpty(patches)) {
|
||||
const head = Chunk.headNonEmpty(patches);
|
||||
const tail = Chunk.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
patches = Chunk.prepend(head.first)(Chunk.prepend(head.second)(tail));
|
||||
break;
|
||||
}
|
||||
case "Add":
|
||||
{
|
||||
set = HashSet.add(head.value)(set);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Remove":
|
||||
{
|
||||
set = HashSet.remove(head.value)(set);
|
||||
patches = tail;
|
||||
}
|
||||
}
|
||||
}
|
||||
return set;
|
||||
});
|
||||
//# sourceMappingURL=hashSetPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/hashSetPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/hashSetPatch.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hashSetPatch.js","names":["Chunk","Dual","HashSet","Structural","HashSetPatchTypeId","Symbol","for","variance","a","PatchProto","prototype","_Value","_Key","_Patch","EmptyProto","Object","assign","create","_tag","_empty","empty","AndThenProto","makeAndThen","first","second","o","AddProto","makeAdd","value","RemoveProto","makeRemove","diff","oldValue","newValue","removed","patch","reduce","set","has","remove","combine","dual","self","that","patches","of","isNonEmpty","head","headNonEmpty","tail","tailNonEmpty","prepend","add"],"sources":["../../../../src/internal/differ/hashSetPatch.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
170
_node_modules/effect/dist/esm/internal/differ/orPatch.js
generated
vendored
Normal file
170
_node_modules/effect/dist/esm/internal/differ/orPatch.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
import * as Chunk from "../../Chunk.js";
|
||||
import * as E from "../../Either.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import { Structural } from "../data.js";
|
||||
/** @internal */
|
||||
export const OrPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferOrPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
/** @internal */
|
||||
const PatchProto = {
|
||||
...Structural.prototype,
|
||||
[OrPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Key: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/** @internal */
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const SetLeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "SetLeft"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeSetLeft = value => {
|
||||
const o = Object.create(SetLeftProto);
|
||||
o.value = value;
|
||||
return o;
|
||||
};
|
||||
const SetRightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "SetRight"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeSetRight = value => {
|
||||
const o = Object.create(SetRightProto);
|
||||
o.value = value;
|
||||
return o;
|
||||
};
|
||||
const UpdateLeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "UpdateLeft"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeUpdateLeft = patch => {
|
||||
const o = Object.create(UpdateLeftProto);
|
||||
o.patch = patch;
|
||||
return o;
|
||||
};
|
||||
const UpdateRightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "UpdateRight"
|
||||
});
|
||||
/** @internal */
|
||||
export const makeUpdateRight = patch => {
|
||||
const o = Object.create(UpdateRightProto);
|
||||
o.patch = patch;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = options => {
|
||||
switch (options.oldValue._tag) {
|
||||
case "Left":
|
||||
{
|
||||
switch (options.newValue._tag) {
|
||||
case "Left":
|
||||
{
|
||||
const valuePatch = options.left.diff(options.oldValue.left, options.newValue.left);
|
||||
if (Equal.equals(valuePatch, options.left.empty)) {
|
||||
return empty();
|
||||
}
|
||||
return makeUpdateLeft(valuePatch);
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
return makeSetRight(options.newValue.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
switch (options.newValue._tag) {
|
||||
case "Left":
|
||||
{
|
||||
return makeSetLeft(options.newValue.left);
|
||||
}
|
||||
case "Right":
|
||||
{
|
||||
const valuePatch = options.right.diff(options.oldValue.right, options.newValue.right);
|
||||
if (Equal.equals(valuePatch, options.right.empty)) {
|
||||
return empty();
|
||||
}
|
||||
return makeUpdateRight(valuePatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(2, (self, {
|
||||
left,
|
||||
oldValue,
|
||||
right
|
||||
}) => {
|
||||
if (self._tag === "Empty") {
|
||||
return oldValue;
|
||||
}
|
||||
let patches = Chunk.of(self);
|
||||
let result = oldValue;
|
||||
while (Chunk.isNonEmpty(patches)) {
|
||||
const head = Chunk.headNonEmpty(patches);
|
||||
const tail = Chunk.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
patches = Chunk.prepend(head.first)(Chunk.prepend(head.second)(tail));
|
||||
break;
|
||||
}
|
||||
case "UpdateLeft":
|
||||
{
|
||||
if (result._tag === "Left") {
|
||||
result = E.left(left.patch(head.patch, result.left));
|
||||
}
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "UpdateRight":
|
||||
{
|
||||
if (result._tag === "Right") {
|
||||
result = E.right(right.patch(head.patch, result.right));
|
||||
}
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "SetLeft":
|
||||
{
|
||||
result = E.left(head.value);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "SetRight":
|
||||
{
|
||||
result = E.right(head.value);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
//# sourceMappingURL=orPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/orPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/orPatch.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
129
_node_modules/effect/dist/esm/internal/differ/readonlyArrayPatch.js
generated
vendored
Normal file
129
_node_modules/effect/dist/esm/internal/differ/readonlyArrayPatch.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import * as Arr from "../../Array.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Dual from "../../Function.js";
|
||||
import * as Data from "../data.js";
|
||||
/** @internal */
|
||||
export const ReadonlyArrayPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferReadonlyArrayPatch");
|
||||
function variance(a) {
|
||||
return a;
|
||||
}
|
||||
const PatchProto = {
|
||||
...Data.Structural.prototype,
|
||||
[ReadonlyArrayPatchTypeId]: {
|
||||
_Value: variance,
|
||||
_Patch: variance
|
||||
}
|
||||
};
|
||||
const EmptyProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Empty"
|
||||
});
|
||||
const _empty = /*#__PURE__*/Object.create(EmptyProto);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const empty = () => _empty;
|
||||
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "AndThen"
|
||||
});
|
||||
const makeAndThen = (first, second) => {
|
||||
const o = Object.create(AndThenProto);
|
||||
o.first = first;
|
||||
o.second = second;
|
||||
return o;
|
||||
};
|
||||
const AppendProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Append"
|
||||
});
|
||||
const makeAppend = values => {
|
||||
const o = Object.create(AppendProto);
|
||||
o.values = values;
|
||||
return o;
|
||||
};
|
||||
const SliceProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Slice"
|
||||
});
|
||||
const makeSlice = (from, until) => {
|
||||
const o = Object.create(SliceProto);
|
||||
o.from = from;
|
||||
o.until = until;
|
||||
return o;
|
||||
};
|
||||
const UpdateProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
|
||||
_tag: "Update"
|
||||
});
|
||||
const makeUpdate = (index, patch) => {
|
||||
const o = Object.create(UpdateProto);
|
||||
o.index = index;
|
||||
o.patch = patch;
|
||||
return o;
|
||||
};
|
||||
/** @internal */
|
||||
export const diff = options => {
|
||||
let i = 0;
|
||||
let patch = empty();
|
||||
while (i < options.oldValue.length && i < options.newValue.length) {
|
||||
const oldElement = options.oldValue[i];
|
||||
const newElement = options.newValue[i];
|
||||
const valuePatch = options.differ.diff(oldElement, newElement);
|
||||
if (!Equal.equals(valuePatch, options.differ.empty)) {
|
||||
patch = combine(patch, makeUpdate(i, valuePatch));
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
if (i < options.oldValue.length) {
|
||||
patch = combine(patch, makeSlice(0, i));
|
||||
}
|
||||
if (i < options.newValue.length) {
|
||||
patch = combine(patch, makeAppend(Arr.drop(i)(options.newValue)));
|
||||
}
|
||||
return patch;
|
||||
};
|
||||
/** @internal */
|
||||
export const combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
|
||||
/** @internal */
|
||||
export const patch = /*#__PURE__*/Dual.dual(3, (self, oldValue, differ) => {
|
||||
if (self._tag === "Empty") {
|
||||
return oldValue;
|
||||
}
|
||||
let readonlyArray = oldValue.slice();
|
||||
let patches = Arr.of(self);
|
||||
while (Arr.isNonEmptyArray(patches)) {
|
||||
const head = Arr.headNonEmpty(patches);
|
||||
const tail = Arr.tailNonEmpty(patches);
|
||||
switch (head._tag) {
|
||||
case "Empty":
|
||||
{
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "AndThen":
|
||||
{
|
||||
tail.unshift(head.first, head.second);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Append":
|
||||
{
|
||||
for (const value of head.values) {
|
||||
readonlyArray.push(value);
|
||||
}
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Slice":
|
||||
{
|
||||
readonlyArray = readonlyArray.slice(head.from, head.until);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
case "Update":
|
||||
{
|
||||
readonlyArray[head.index] = differ.patch(head.patch, readonlyArray[head.index]);
|
||||
patches = tail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return readonlyArray;
|
||||
});
|
||||
//# sourceMappingURL=readonlyArrayPatch.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/differ/readonlyArrayPatch.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/differ/readonlyArrayPatch.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"readonlyArrayPatch.js","names":["Arr","Equal","Dual","Data","ReadonlyArrayPatchTypeId","Symbol","for","variance","a","PatchProto","Structural","prototype","_Value","_Patch","EmptyProto","Object","assign","create","_tag","_empty","empty","AndThenProto","makeAndThen","first","second","o","AppendProto","makeAppend","values","SliceProto","makeSlice","from","until","UpdateProto","makeUpdate","index","patch","diff","options","i","oldValue","length","newValue","oldElement","newElement","valuePatch","differ","equals","combine","drop","dual","self","that","readonlyArray","slice","patches","of","isNonEmptyArray","head","headNonEmpty","tail","tailNonEmpty","unshift","value","push"],"sources":["../../../../src/internal/differ/readonlyArrayPatch.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
16
_node_modules/effect/dist/esm/internal/doNotation.js
generated
vendored
Normal file
16
_node_modules/effect/dist/esm/internal/doNotation.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { dual } from "../Function.js";
|
||||
/** @internal */
|
||||
export const let_ = map => dual(3, (self, name, f) => map(self, a => ({
|
||||
...a,
|
||||
[name]: f(a)
|
||||
})));
|
||||
/** @internal */
|
||||
export const bindTo = map => dual(2, (self, name) => map(self, a => ({
|
||||
[name]: a
|
||||
})));
|
||||
/** @internal */
|
||||
export const bind = (map, flatMap) => dual(3, (self, name, f) => flatMap(self, a => map(f(a), b => ({
|
||||
...a,
|
||||
[name]: b
|
||||
}))));
|
||||
//# sourceMappingURL=doNotation.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/doNotation.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/doNotation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"doNotation.js","names":["dual","let_","map","self","name","f","a","bindTo","bind","flatMap","b"],"sources":["../../../src/internal/doNotation.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAgB;AAmBrC;AACA,OAAO,MAAMC,IAAI,GACfC,GAAW,IAcXF,IAAI,CAAC,CAAC,EAAE,CACNG,IAAyB,EACzBC,IAAyB,EACzBC,CAAuB,KAEvBH,GAAG,CAACC,IAAI,EAAGG,CAAC,KAAM;EAAE,GAAGA,CAAC;EAAE,CAACF,IAAI,GAAGC,CAAC,CAACC,CAAC;AAAC,CAAE,CAAQ,CAAC,CAAC;AAEtD;AACA,OAAO,MAAMC,MAAM,GAA0BL,GAAW,IAStDF,IAAI,CAAC,CAAC,EAAE,CACNG,IAAyB,EACzBC,IAAO,KAC+BF,GAAG,CAACC,IAAI,EAAGG,CAAC,KAAM;EAAE,CAACF,IAAI,GAAGE;AAAC,CAAsB,EAAC,CAAC;AAE/F;AACA,OAAO,MAAME,IAAI,GAAGA,CAAuBN,GAAW,EAAEO,OAAmB,KAazET,IAAI,CAAC,CAAC,EAAE,CACNG,IAA4B,EAC5BC,IAAyB,EACzBC,CAA4C,KAE5CI,OAAO,CACLN,IAAI,EACHG,CAAC,IAAKJ,GAAG,CAACG,CAAC,CAACC,CAAC,CAAC,EAAGI,CAAC,KAAM;EAAE,GAAGJ,CAAC;EAAE,CAACF,IAAI,GAAGM;AAAC,CAAE,CAAyD,CAAC,CACvG,CAAC","ignoreList":[]}
|
||||
398
_node_modules/effect/dist/esm/internal/effect/circular.js
generated
vendored
Normal file
398
_node_modules/effect/dist/esm/internal/effect/circular.js
generated
vendored
Normal file
@@ -0,0 +1,398 @@
|
||||
import * as Duration from "../../Duration.js";
|
||||
import * as Effectable from "../../Effectable.js";
|
||||
import * as Equal from "../../Equal.js";
|
||||
import * as Exit from "../../Exit.js";
|
||||
import * as FiberId from "../../FiberId.js";
|
||||
import { dual, pipe } from "../../Function.js";
|
||||
import * as Hash from "../../Hash.js";
|
||||
import * as MutableHashMap from "../../MutableHashMap.js";
|
||||
import * as Option from "../../Option.js";
|
||||
import { pipeArguments } from "../../Pipeable.js";
|
||||
import * as Predicate from "../../Predicate.js";
|
||||
import * as Readable from "../../Readable.js";
|
||||
import { currentScheduler } from "../../Scheduler.js";
|
||||
import * as internalCause from "../cause.js";
|
||||
import * as effect from "../core-effect.js";
|
||||
import * as core from "../core.js";
|
||||
import * as internalFiber from "../fiber.js";
|
||||
import * as fiberRuntime from "../fiberRuntime.js";
|
||||
import { globalScope } from "../fiberScope.js";
|
||||
import * as internalRef from "../ref.js";
|
||||
import * as supervisor from "../supervisor.js";
|
||||
/** @internal */
|
||||
class Semaphore {
|
||||
permits;
|
||||
waiters = /*#__PURE__*/new Set();
|
||||
taken = 0;
|
||||
constructor(permits) {
|
||||
this.permits = permits;
|
||||
}
|
||||
get free() {
|
||||
return this.permits - this.taken;
|
||||
}
|
||||
take = n => core.asyncInterrupt(resume => {
|
||||
if (this.free < n) {
|
||||
const observer = () => {
|
||||
if (this.free < n) {
|
||||
return;
|
||||
}
|
||||
this.waiters.delete(observer);
|
||||
this.taken += n;
|
||||
resume(core.succeed(n));
|
||||
};
|
||||
this.waiters.add(observer);
|
||||
return core.sync(() => {
|
||||
this.waiters.delete(observer);
|
||||
});
|
||||
}
|
||||
this.taken += n;
|
||||
return resume(core.succeed(n));
|
||||
});
|
||||
updateTakenUnsafe(fiber, f) {
|
||||
this.taken = f(this.taken);
|
||||
if (this.waiters.size > 0) {
|
||||
fiber.getFiberRef(currentScheduler).scheduleTask(() => {
|
||||
const iter = this.waiters.values();
|
||||
let item = iter.next();
|
||||
while (item.done === false && this.free > 0) {
|
||||
item.value();
|
||||
item = iter.next();
|
||||
}
|
||||
}, fiber.getFiberRef(core.currentSchedulingPriority));
|
||||
}
|
||||
return core.succeed(this.free);
|
||||
}
|
||||
updateTaken(f) {
|
||||
return core.withFiberRuntime(fiber => this.updateTakenUnsafe(fiber, f));
|
||||
}
|
||||
resize = permits => core.asVoid(core.withFiberRuntime(fiber => {
|
||||
this.permits = permits;
|
||||
if (this.free < 0) {
|
||||
return core.void;
|
||||
}
|
||||
return this.updateTakenUnsafe(fiber, taken => taken);
|
||||
}));
|
||||
release = n => this.updateTaken(taken => taken - n);
|
||||
releaseAll = /*#__PURE__*/this.updateTaken(_ => 0);
|
||||
withPermits = n => self => core.uninterruptibleMask(restore => core.flatMap(restore(this.take(n)), permits => fiberRuntime.ensuring(restore(self), this.release(permits))));
|
||||
withPermitsIfAvailable = n => self => core.uninterruptibleMask(restore => core.suspend(() => {
|
||||
if (this.free < n) {
|
||||
return effect.succeedNone;
|
||||
}
|
||||
this.taken += n;
|
||||
return fiberRuntime.ensuring(restore(effect.asSome(self)), this.release(n));
|
||||
}));
|
||||
}
|
||||
/** @internal */
|
||||
export const unsafeMakeSemaphore = permits => new Semaphore(permits);
|
||||
/** @internal */
|
||||
export const makeSemaphore = permits => core.sync(() => unsafeMakeSemaphore(permits));
|
||||
class Latch extends Effectable.Class {
|
||||
isOpen;
|
||||
waiters = [];
|
||||
scheduled = false;
|
||||
constructor(isOpen) {
|
||||
super();
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
commit() {
|
||||
return this.await;
|
||||
}
|
||||
unsafeSchedule(fiber) {
|
||||
if (this.scheduled || this.waiters.length === 0) {
|
||||
return core.void;
|
||||
}
|
||||
this.scheduled = true;
|
||||
fiber.currentScheduler.scheduleTask(this.flushWaiters, fiber.getFiberRef(core.currentSchedulingPriority));
|
||||
return core.void;
|
||||
}
|
||||
flushWaiters = () => {
|
||||
this.scheduled = false;
|
||||
const waiters = this.waiters;
|
||||
this.waiters = [];
|
||||
for (let i = 0; i < waiters.length; i++) {
|
||||
waiters[i](core.exitVoid);
|
||||
}
|
||||
};
|
||||
open = /*#__PURE__*/core.withFiberRuntime(fiber => {
|
||||
if (this.isOpen) {
|
||||
return core.void;
|
||||
}
|
||||
this.isOpen = true;
|
||||
return this.unsafeSchedule(fiber);
|
||||
});
|
||||
unsafeOpen() {
|
||||
if (this.isOpen) return;
|
||||
this.isOpen = true;
|
||||
this.flushWaiters();
|
||||
}
|
||||
release = /*#__PURE__*/core.withFiberRuntime(fiber => {
|
||||
if (this.isOpen) {
|
||||
return core.void;
|
||||
}
|
||||
return this.unsafeSchedule(fiber);
|
||||
});
|
||||
await = /*#__PURE__*/core.asyncInterrupt(resume => {
|
||||
if (this.isOpen) {
|
||||
return resume(core.void);
|
||||
}
|
||||
this.waiters.push(resume);
|
||||
return core.sync(() => {
|
||||
const index = this.waiters.indexOf(resume);
|
||||
if (index !== -1) {
|
||||
this.waiters.splice(index, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
unsafeClose() {
|
||||
this.isOpen = false;
|
||||
}
|
||||
close = /*#__PURE__*/core.sync(() => {
|
||||
this.isOpen = false;
|
||||
});
|
||||
whenOpen = self => {
|
||||
return core.zipRight(this.await, self);
|
||||
};
|
||||
}
|
||||
/** @internal */
|
||||
export const unsafeMakeLatch = open => new Latch(open ?? false);
|
||||
/** @internal */
|
||||
export const makeLatch = open => core.sync(() => unsafeMakeLatch(open));
|
||||
/** @internal */
|
||||
export const awaitAllChildren = self => ensuringChildren(self, fiberRuntime.fiberAwaitAll);
|
||||
/** @internal */
|
||||
export const cached = /*#__PURE__*/dual(2, (self, timeToLive) => core.map(cachedInvalidateWithTTL(self, timeToLive), tuple => tuple[0]));
|
||||
/** @internal */
|
||||
export const cachedInvalidateWithTTL = /*#__PURE__*/dual(2, (self, timeToLive) => {
|
||||
const duration = Duration.decode(timeToLive);
|
||||
return core.flatMap(core.context(), env => core.map(makeSynchronized(Option.none()), cache => [core.provideContext(getCachedValue(self, duration, cache), env), invalidateCache(cache)]));
|
||||
});
|
||||
/** @internal */
|
||||
const computeCachedValue = (self, timeToLive, start) => {
|
||||
const timeToLiveMillis = Duration.toMillis(Duration.decode(timeToLive));
|
||||
return pipe(core.deferredMake(), core.tap(deferred => core.intoDeferred(self, deferred)), core.map(deferred => Option.some([start + timeToLiveMillis, deferred])));
|
||||
};
|
||||
/** @internal */
|
||||
const getCachedValue = (self, timeToLive, cache) => core.uninterruptibleMask(restore => pipe(effect.clockWith(clock => clock.currentTimeMillis), core.flatMap(time => updateSomeAndGetEffectSynchronized(cache, option => {
|
||||
switch (option._tag) {
|
||||
case "None":
|
||||
{
|
||||
return Option.some(computeCachedValue(self, timeToLive, time));
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
const [end] = option.value;
|
||||
return end - time <= 0 ? Option.some(computeCachedValue(self, timeToLive, time)) : Option.none();
|
||||
}
|
||||
}
|
||||
})), core.flatMap(option => Option.isNone(option) ? core.dieMessage("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues") : restore(core.deferredAwait(option.value[1])))));
|
||||
/** @internal */
|
||||
const invalidateCache = cache => internalRef.set(cache, Option.none());
|
||||
/** @internal */
|
||||
export const ensuringChild = /*#__PURE__*/dual(2, (self, f) => ensuringChildren(self, children => f(fiberRuntime.fiberAll(children))));
|
||||
/** @internal */
|
||||
export const ensuringChildren = /*#__PURE__*/dual(2, (self, children) => core.flatMap(supervisor.track, supervisor => pipe(supervised(self, supervisor), fiberRuntime.ensuring(core.flatMap(supervisor.value, children)))));
|
||||
/** @internal */
|
||||
export const forkAll = /*#__PURE__*/dual(args => Predicate.isIterable(args[0]), (effects, options) => options?.discard ? core.forEachSequentialDiscard(effects, fiberRuntime.fork) : core.map(core.forEachSequential(effects, fiberRuntime.fork), fiberRuntime.fiberAll));
|
||||
/** @internal */
|
||||
export const forkIn = /*#__PURE__*/dual(2, (self, scope) => core.withFiberRuntime((parent, parentStatus) => {
|
||||
const scopeImpl = scope;
|
||||
const fiber = fiberRuntime.unsafeFork(self, parent, parentStatus.runtimeFlags, globalScope);
|
||||
if (scopeImpl.state._tag === "Open") {
|
||||
const finalizer = () => core.fiberIdWith(fiberId => Equal.equals(fiberId, fiber.id()) ? core.void : core.asVoid(core.interruptFiber(fiber)));
|
||||
const key = {};
|
||||
scopeImpl.state.finalizers.set(key, finalizer);
|
||||
fiber.addObserver(() => {
|
||||
if (scopeImpl.state._tag === "Closed") return;
|
||||
scopeImpl.state.finalizers.delete(key);
|
||||
});
|
||||
} else {
|
||||
fiber.unsafeInterruptAsFork(parent.id());
|
||||
}
|
||||
return core.succeed(fiber);
|
||||
}));
|
||||
/** @internal */
|
||||
export const forkScoped = self => fiberRuntime.scopeWith(scope => forkIn(self, scope));
|
||||
/** @internal */
|
||||
export const fromFiber = fiber => internalFiber.join(fiber);
|
||||
/** @internal */
|
||||
export const fromFiberEffect = fiber => core.suspend(() => core.flatMap(fiber, internalFiber.join));
|
||||
const memoKeySymbol = /*#__PURE__*/Symbol.for("effect/Effect/memoizeFunction.key");
|
||||
class Key {
|
||||
a;
|
||||
eq;
|
||||
[memoKeySymbol] = memoKeySymbol;
|
||||
constructor(a, eq) {
|
||||
this.a = a;
|
||||
this.eq = eq;
|
||||
}
|
||||
[Equal.symbol](that) {
|
||||
if (Predicate.hasProperty(that, memoKeySymbol)) {
|
||||
if (this.eq) {
|
||||
return this.eq(this.a, that.a);
|
||||
} else {
|
||||
return Equal.equals(this.a, that.a);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[Hash.symbol]() {
|
||||
return this.eq ? 0 : Hash.cached(this, Hash.hash(this.a));
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const cachedFunction = (f, eq) => {
|
||||
return pipe(core.sync(() => MutableHashMap.empty()), core.flatMap(makeSynchronized), core.map(ref => a => pipe(ref.modifyEffect(map => {
|
||||
const result = pipe(map, MutableHashMap.get(new Key(a, eq)));
|
||||
if (Option.isNone(result)) {
|
||||
return pipe(core.deferredMake(), core.tap(deferred => pipe(effect.diffFiberRefs(f(a)), core.intoDeferred(deferred), fiberRuntime.fork)), core.map(deferred => [deferred, pipe(map, MutableHashMap.set(new Key(a, eq), deferred))]));
|
||||
}
|
||||
return core.succeed([result.value, map]);
|
||||
}), core.flatMap(core.deferredAwait), core.flatMap(([patch, b]) => pipe(effect.patchFiberRefs(patch), core.as(b))))));
|
||||
};
|
||||
/** @internal */
|
||||
export const raceFirst = /*#__PURE__*/dual(2, (self, that) => pipe(core.exit(self), fiberRuntime.race(core.exit(that)), effect => core.flatten(effect)));
|
||||
/** @internal */
|
||||
export const supervised = /*#__PURE__*/dual(2, (self, supervisor) => {
|
||||
const supervise = core.fiberRefLocallyWith(fiberRuntime.currentSupervisor, s => s.zip(supervisor));
|
||||
return supervise(self);
|
||||
});
|
||||
/** @internal */
|
||||
export const timeout = /*#__PURE__*/dual(2, (self, duration) => timeoutFail(self, {
|
||||
onTimeout: () => core.timeoutExceptionFromDuration(duration),
|
||||
duration
|
||||
}));
|
||||
/** @internal */
|
||||
export const timeoutFail = /*#__PURE__*/dual(2, (self, {
|
||||
duration,
|
||||
onTimeout
|
||||
}) => core.flatten(timeoutTo(self, {
|
||||
onTimeout: () => core.failSync(onTimeout),
|
||||
onSuccess: core.succeed,
|
||||
duration
|
||||
})));
|
||||
/** @internal */
|
||||
export const timeoutFailCause = /*#__PURE__*/dual(2, (self, {
|
||||
duration,
|
||||
onTimeout
|
||||
}) => core.flatten(timeoutTo(self, {
|
||||
onTimeout: () => core.failCauseSync(onTimeout),
|
||||
onSuccess: core.succeed,
|
||||
duration
|
||||
})));
|
||||
/** @internal */
|
||||
export const timeoutOption = /*#__PURE__*/dual(2, (self, duration) => timeoutTo(self, {
|
||||
duration,
|
||||
onSuccess: Option.some,
|
||||
onTimeout: Option.none
|
||||
}));
|
||||
/** @internal */
|
||||
export const timeoutTo = /*#__PURE__*/dual(2, (self, {
|
||||
duration,
|
||||
onSuccess,
|
||||
onTimeout
|
||||
}) => core.fiberIdWith(parentFiberId => core.uninterruptibleMask(restore => fiberRuntime.raceFibersWith(restore(self), core.interruptible(effect.sleep(duration)), {
|
||||
onSelfWin: (winner, loser) => core.flatMap(winner.await, exit => {
|
||||
if (exit._tag === "Success") {
|
||||
return core.flatMap(winner.inheritAll, () => core.as(core.interruptAsFiber(loser, parentFiberId), onSuccess(exit.value)));
|
||||
} else {
|
||||
return core.flatMap(core.interruptAsFiber(loser, parentFiberId), () => core.exitFailCause(exit.cause));
|
||||
}
|
||||
}),
|
||||
onOtherWin: (winner, loser) => core.flatMap(winner.await, exit => {
|
||||
if (exit._tag === "Success") {
|
||||
return core.flatMap(winner.inheritAll, () => core.as(core.interruptAsFiber(loser, parentFiberId), onTimeout()));
|
||||
} else {
|
||||
return core.flatMap(core.interruptAsFiber(loser, parentFiberId), () => core.exitFailCause(exit.cause));
|
||||
}
|
||||
}),
|
||||
otherScope: globalScope
|
||||
}))));
|
||||
// circular with Synchronized
|
||||
/** @internal */
|
||||
const SynchronizedSymbolKey = "effect/Ref/SynchronizedRef";
|
||||
/** @internal */
|
||||
export const SynchronizedTypeId = /*#__PURE__*/Symbol.for(SynchronizedSymbolKey);
|
||||
/** @internal */
|
||||
export const synchronizedVariance = {
|
||||
/* c8 ignore next */
|
||||
_A: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
class SynchronizedImpl extends Effectable.Class {
|
||||
ref;
|
||||
withLock;
|
||||
[SynchronizedTypeId] = synchronizedVariance;
|
||||
[internalRef.RefTypeId] = internalRef.refVariance;
|
||||
[Readable.TypeId] = Readable.TypeId;
|
||||
constructor(ref, withLock) {
|
||||
super();
|
||||
this.ref = ref;
|
||||
this.withLock = withLock;
|
||||
this.get = internalRef.get(this.ref);
|
||||
}
|
||||
get;
|
||||
commit() {
|
||||
return this.get;
|
||||
}
|
||||
modify(f) {
|
||||
return this.modifyEffect(a => core.succeed(f(a)));
|
||||
}
|
||||
modifyEffect(f) {
|
||||
return this.withLock(pipe(core.flatMap(internalRef.get(this.ref), f), core.flatMap(([b, a]) => core.as(internalRef.set(this.ref, a), b))));
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const makeSynchronized = value => core.sync(() => unsafeMakeSynchronized(value));
|
||||
/** @internal */
|
||||
export const unsafeMakeSynchronized = value => {
|
||||
const ref = internalRef.unsafeMake(value);
|
||||
const sem = unsafeMakeSemaphore(1);
|
||||
return new SynchronizedImpl(ref, sem.withPermits(1));
|
||||
};
|
||||
/** @internal */
|
||||
export const updateSomeAndGetEffectSynchronized = /*#__PURE__*/dual(2, (self, pf) => self.modifyEffect(value => {
|
||||
const result = pf(value);
|
||||
switch (result._tag) {
|
||||
case "None":
|
||||
{
|
||||
return core.succeed([value, value]);
|
||||
}
|
||||
case "Some":
|
||||
{
|
||||
return core.map(result.value, a => [a, a]);
|
||||
}
|
||||
}
|
||||
}));
|
||||
// circular with Fiber
|
||||
/** @internal */
|
||||
export const zipFiber = /*#__PURE__*/dual(2, (self, that) => zipWithFiber(self, that, (a, b) => [a, b]));
|
||||
/** @internal */
|
||||
export const zipLeftFiber = /*#__PURE__*/dual(2, (self, that) => zipWithFiber(self, that, (a, _) => a));
|
||||
/** @internal */
|
||||
export const zipRightFiber = /*#__PURE__*/dual(2, (self, that) => zipWithFiber(self, that, (_, b) => b));
|
||||
/** @internal */
|
||||
export const zipWithFiber = /*#__PURE__*/dual(3, (self, that, f) => ({
|
||||
...Effectable.CommitPrototype,
|
||||
commit() {
|
||||
return internalFiber.join(this);
|
||||
},
|
||||
[internalFiber.FiberTypeId]: internalFiber.fiberVariance,
|
||||
id: () => pipe(self.id(), FiberId.getOrElse(that.id())),
|
||||
await: pipe(self.await, core.flatten, fiberRuntime.zipWithOptions(core.flatten(that.await), f, {
|
||||
concurrent: true
|
||||
}), core.exit),
|
||||
children: self.children,
|
||||
inheritAll: core.zipRight(that.inheritAll, self.inheritAll),
|
||||
poll: core.zipWith(self.poll, that.poll, (optionA, optionB) => pipe(optionA, Option.flatMap(exitA => pipe(optionB, Option.map(exitB => Exit.zipWith(exitA, exitB, {
|
||||
onSuccess: f,
|
||||
onFailure: internalCause.parallel
|
||||
})))))),
|
||||
interruptAsFork: id => core.zipRight(self.interruptAsFork(id), that.interruptAsFork(id)),
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
}
|
||||
}));
|
||||
/* @internal */
|
||||
export const bindAll = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, f, options) => core.flatMap(self, a => fiberRuntime.all(f(a), options).pipe(core.map(record => Object.assign({}, a, record)))));
|
||||
//# sourceMappingURL=circular.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/effect/circular.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/effect/circular.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
113
_node_modules/effect/dist/esm/internal/effectable.js
generated
vendored
Normal file
113
_node_modules/effect/dist/esm/internal/effectable.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import * as Equal from "../Equal.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import { pipeArguments } from "../Pipeable.js";
|
||||
import { SingleShotGen, YieldWrap } from "../Utils.js";
|
||||
import * as OpCodes from "./opCodes/effect.js";
|
||||
import * as version from "./version.js";
|
||||
/** @internal */
|
||||
export const EffectTypeId = /*#__PURE__*/Symbol.for("effect/Effect");
|
||||
/** @internal */
|
||||
export const StreamTypeId = /*#__PURE__*/Symbol.for("effect/Stream");
|
||||
/** @internal */
|
||||
export const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
|
||||
/** @internal */
|
||||
export const ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel");
|
||||
/** @internal */
|
||||
export const effectVariance = {
|
||||
/* c8 ignore next */
|
||||
_R: _ => _,
|
||||
/* c8 ignore next */
|
||||
_E: _ => _,
|
||||
/* c8 ignore next */
|
||||
_A: _ => _,
|
||||
_V: /*#__PURE__*/version.getCurrentVersion()
|
||||
};
|
||||
const sinkVariance = {
|
||||
/* c8 ignore next */
|
||||
_A: _ => _,
|
||||
/* c8 ignore next */
|
||||
_In: _ => _,
|
||||
/* c8 ignore next */
|
||||
_L: _ => _,
|
||||
/* c8 ignore next */
|
||||
_E: _ => _,
|
||||
/* c8 ignore next */
|
||||
_R: _ => _
|
||||
};
|
||||
const channelVariance = {
|
||||
/* c8 ignore next */
|
||||
_Env: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InErr: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InElem: _ => _,
|
||||
/* c8 ignore next */
|
||||
_InDone: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutErr: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutElem: _ => _,
|
||||
/* c8 ignore next */
|
||||
_OutDone: _ => _
|
||||
};
|
||||
/** @internal */
|
||||
export const EffectPrototype = {
|
||||
[EffectTypeId]: effectVariance,
|
||||
[StreamTypeId]: effectVariance,
|
||||
[SinkTypeId]: sinkVariance,
|
||||
[ChannelTypeId]: channelVariance,
|
||||
[Equal.symbol](that) {
|
||||
return this === that;
|
||||
},
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.random(this));
|
||||
},
|
||||
[Symbol.iterator]() {
|
||||
return new SingleShotGen(new YieldWrap(this));
|
||||
},
|
||||
pipe() {
|
||||
return pipeArguments(this, arguments);
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const StructuralPrototype = {
|
||||
[Hash.symbol]() {
|
||||
return Hash.cached(this, Hash.structure(this));
|
||||
},
|
||||
[Equal.symbol](that) {
|
||||
const selfKeys = Object.keys(this);
|
||||
const thatKeys = Object.keys(that);
|
||||
if (selfKeys.length !== thatKeys.length) {
|
||||
return false;
|
||||
}
|
||||
for (const key of selfKeys) {
|
||||
if (!(key in that && Equal.equals(this[key], that[key]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const CommitPrototype = {
|
||||
...EffectPrototype,
|
||||
_op: OpCodes.OP_COMMIT
|
||||
};
|
||||
/** @internal */
|
||||
export const StructuralCommitPrototype = {
|
||||
...CommitPrototype,
|
||||
...StructuralPrototype
|
||||
};
|
||||
/** @internal */
|
||||
export const Base = /*#__PURE__*/function () {
|
||||
function Base() {}
|
||||
Base.prototype = CommitPrototype;
|
||||
return Base;
|
||||
}();
|
||||
/** @internal */
|
||||
export const StructuralBase = /*#__PURE__*/function () {
|
||||
function Base() {}
|
||||
Base.prototype = StructuralCommitPrototype;
|
||||
return Base;
|
||||
}();
|
||||
//# sourceMappingURL=effectable.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/effectable.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/effectable.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"effectable.js","names":["Equal","Hash","pipeArguments","SingleShotGen","YieldWrap","OpCodes","version","EffectTypeId","Symbol","for","StreamTypeId","SinkTypeId","ChannelTypeId","effectVariance","_R","_","_E","_A","_V","getCurrentVersion","sinkVariance","_In","_L","channelVariance","_Env","_InErr","_InElem","_InDone","_OutErr","_OutElem","_OutDone","EffectPrototype","symbol","that","cached","random","iterator","pipe","arguments","StructuralPrototype","structure","selfKeys","Object","keys","thatKeys","length","key","equals","CommitPrototype","_op","OP_COMMIT","StructuralCommitPrototype","Base","prototype","StructuralBase"],"sources":["../../../src/internal/effectable.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
85
_node_modules/effect/dist/esm/internal/either.js
generated
vendored
Normal file
85
_node_modules/effect/dist/esm/internal/either.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
import * as Equal from "../Equal.js";
|
||||
import { dual } from "../Function.js";
|
||||
import * as Hash from "../Hash.js";
|
||||
import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js";
|
||||
import { hasProperty } from "../Predicate.js";
|
||||
import { EffectPrototype } from "./effectable.js";
|
||||
import * as option from "./option.js";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const TypeId = /*#__PURE__*/Symbol.for("effect/Either");
|
||||
const CommonProto = {
|
||||
...EffectPrototype,
|
||||
[TypeId]: {
|
||||
_R: _ => _
|
||||
},
|
||||
[NodeInspectSymbol]() {
|
||||
return this.toJSON();
|
||||
},
|
||||
toString() {
|
||||
return format(this.toJSON());
|
||||
}
|
||||
};
|
||||
const RightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto), {
|
||||
_tag: "Right",
|
||||
_op: "Right",
|
||||
[Equal.symbol](that) {
|
||||
return isEither(that) && isRight(that) && Equal.equals(this.right, that.right);
|
||||
},
|
||||
[Hash.symbol]() {
|
||||
return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.right));
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "Either",
|
||||
_tag: this._tag,
|
||||
right: toJSON(this.right)
|
||||
};
|
||||
}
|
||||
});
|
||||
const LeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto), {
|
||||
_tag: "Left",
|
||||
_op: "Left",
|
||||
[Equal.symbol](that) {
|
||||
return isEither(that) && isLeft(that) && Equal.equals(this.left, that.left);
|
||||
},
|
||||
[Hash.symbol]() {
|
||||
return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.left));
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
_id: "Either",
|
||||
_tag: this._tag,
|
||||
left: toJSON(this.left)
|
||||
};
|
||||
}
|
||||
});
|
||||
/** @internal */
|
||||
export const isEither = input => hasProperty(input, TypeId);
|
||||
/** @internal */
|
||||
export const isLeft = ma => ma._tag === "Left";
|
||||
/** @internal */
|
||||
export const isRight = ma => ma._tag === "Right";
|
||||
/** @internal */
|
||||
export const left = left => {
|
||||
const a = Object.create(LeftProto);
|
||||
a.left = left;
|
||||
return a;
|
||||
};
|
||||
/** @internal */
|
||||
export const right = right => {
|
||||
const a = Object.create(RightProto);
|
||||
a.right = right;
|
||||
return a;
|
||||
};
|
||||
/** @internal */
|
||||
export const getLeft = self => isRight(self) ? option.none : option.some(self.left);
|
||||
/** @internal */
|
||||
export const getRight = self => isLeft(self) ? option.none : option.some(self.right);
|
||||
/** @internal */
|
||||
export const fromOption = /*#__PURE__*/dual(2, (self, onNone) => option.isNone(self) ? left(onNone()) : right(self.value));
|
||||
//# sourceMappingURL=either.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/either.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/either.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"either.js","names":["Equal","dual","Hash","format","NodeInspectSymbol","toJSON","hasProperty","EffectPrototype","option","TypeId","Symbol","for","CommonProto","_R","_","toString","RightProto","Object","assign","create","_tag","_op","symbol","that","isEither","isRight","equals","right","combine","hash","_id","LeftProto","isLeft","left","input","ma","a","getLeft","self","none","some","getRight","fromOption","onNone","isNone","value"],"sources":["../../../src/internal/either.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
||||
71
_node_modules/effect/dist/esm/internal/encoding/base64.js
generated
vendored
Normal file
71
_node_modules/effect/dist/esm/internal/encoding/base64.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import * as Either from "../../Either.js";
|
||||
import { DecodeException } from "./common.js";
|
||||
/** @internal */
|
||||
export const encode = bytes => {
|
||||
const length = bytes.length;
|
||||
let result = "";
|
||||
let i;
|
||||
for (i = 2; i < length; i += 3) {
|
||||
result += base64abc[bytes[i - 2] >> 2];
|
||||
result += base64abc[(bytes[i - 2] & 0x03) << 4 | bytes[i - 1] >> 4];
|
||||
result += base64abc[(bytes[i - 1] & 0x0f) << 2 | bytes[i] >> 6];
|
||||
result += base64abc[bytes[i] & 0x3f];
|
||||
}
|
||||
if (i === length + 1) {
|
||||
// 1 octet yet to write
|
||||
result += base64abc[bytes[i - 2] >> 2];
|
||||
result += base64abc[(bytes[i - 2] & 0x03) << 4];
|
||||
result += "==";
|
||||
}
|
||||
if (i === length) {
|
||||
// 2 octets yet to write
|
||||
result += base64abc[bytes[i - 2] >> 2];
|
||||
result += base64abc[(bytes[i - 2] & 0x03) << 4 | bytes[i - 1] >> 4];
|
||||
result += base64abc[(bytes[i - 1] & 0x0f) << 2];
|
||||
result += "=";
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/** @internal */
|
||||
export const decode = str => {
|
||||
const stripped = stripCrlf(str);
|
||||
const length = stripped.length;
|
||||
if (length % 4 !== 0) {
|
||||
return Either.left(DecodeException(stripped, `Length must be a multiple of 4, but is ${length}`));
|
||||
}
|
||||
const index = stripped.indexOf("=");
|
||||
if (index !== -1 && (index < length - 2 || index === length - 2 && stripped[length - 1] !== "=")) {
|
||||
return Either.left(DecodeException(stripped, "Found a '=' character, but it is not at the end"));
|
||||
}
|
||||
try {
|
||||
const missingOctets = stripped.endsWith("==") ? 2 : stripped.endsWith("=") ? 1 : 0;
|
||||
const result = new Uint8Array(3 * (length / 4) - missingOctets);
|
||||
for (let i = 0, j = 0; i < length; i += 4, j += 3) {
|
||||
const buffer = getBase64Code(stripped.charCodeAt(i)) << 18 | getBase64Code(stripped.charCodeAt(i + 1)) << 12 | getBase64Code(stripped.charCodeAt(i + 2)) << 6 | getBase64Code(stripped.charCodeAt(i + 3));
|
||||
result[j] = buffer >> 16;
|
||||
result[j + 1] = buffer >> 8 & 0xff;
|
||||
result[j + 2] = buffer & 0xff;
|
||||
}
|
||||
return Either.right(result);
|
||||
} catch (e) {
|
||||
return Either.left(DecodeException(stripped, e instanceof Error ? e.message : "Invalid input"));
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
export const stripCrlf = str => str.replace(/[\n\r]/g, "");
|
||||
/** @internal */
|
||||
function getBase64Code(charCode) {
|
||||
if (charCode >= base64codes.length) {
|
||||
throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`);
|
||||
}
|
||||
const code = base64codes[charCode];
|
||||
if (code === 255) {
|
||||
throw new TypeError(`Invalid character ${String.fromCharCode(charCode)}`);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
/** @internal */
|
||||
const base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
||||
/** @internal */
|
||||
const base64codes = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 0, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51];
|
||||
//# sourceMappingURL=base64.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/encoding/base64.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/encoding/base64.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
21
_node_modules/effect/dist/esm/internal/encoding/base64Url.js
generated
vendored
Normal file
21
_node_modules/effect/dist/esm/internal/encoding/base64Url.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as Either from "../../Either.js";
|
||||
import * as Base64 from "./base64.js";
|
||||
import { DecodeException } from "./common.js";
|
||||
/** @internal */
|
||||
export const encode = data => Base64.encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
||||
/** @internal */
|
||||
export const decode = str => {
|
||||
const stripped = Base64.stripCrlf(str);
|
||||
const length = stripped.length;
|
||||
if (length % 4 === 1) {
|
||||
return Either.left(DecodeException(stripped, `Length should be a multiple of 4, but is ${length}`));
|
||||
}
|
||||
if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) {
|
||||
return Either.left(DecodeException(stripped, "Invalid input"));
|
||||
}
|
||||
// Some variants allow or require omitting the padding '=' signs
|
||||
let sanitized = length % 4 === 2 ? `${stripped}==` : length % 4 === 3 ? `${stripped}=` : stripped;
|
||||
sanitized = sanitized.replace(/-/g, "+").replace(/_/g, "/");
|
||||
return Base64.decode(sanitized);
|
||||
};
|
||||
//# sourceMappingURL=base64Url.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/encoding/base64Url.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/encoding/base64Url.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"base64Url.js","names":["Either","Base64","DecodeException","encode","data","replace","decode","str","stripped","stripCrlf","length","left","test","sanitized"],"sources":["../../../../src/internal/encoding/base64Url.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,iBAAiB;AAEzC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,SAASC,eAAe,QAAQ,aAAa;AAE7C;AACA,OAAO,MAAMC,MAAM,GAAIC,IAAgB,IACrCH,MAAM,CAACE,MAAM,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAE/E;AACA,OAAO,MAAMC,MAAM,GAAIC,GAAW,IAAyD;EACzF,MAAMC,QAAQ,GAAGP,MAAM,CAACQ,SAAS,CAACF,GAAG,CAAC;EACtC,MAAMG,MAAM,GAAGF,QAAQ,CAACE,MAAM;EAC9B,IAAIA,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;IACpB,OAAOV,MAAM,CAACW,IAAI,CAChBT,eAAe,CAACM,QAAQ,EAAE,4CAA4CE,MAAM,EAAE,CAAC,CAChF;EACH;EAEA,IAAI,CAAC,uBAAuB,CAACE,IAAI,CAACJ,QAAQ,CAAC,EAAE;IAC3C,OAAOR,MAAM,CAACW,IAAI,CAACT,eAAe,CAACM,QAAQ,EAAE,eAAe,CAAC,CAAC;EAChE;EAEA;EACA,IAAIK,SAAS,GAAGH,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,GAAGF,QAAQ,IAAI,GAAGE,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,GAAGF,QAAQ,GAAG,GAAGA,QAAQ;EACjGK,SAAS,GAAGA,SAAS,CAACR,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EAE3D,OAAOJ,MAAM,CAACK,MAAM,CAACO,SAAS,CAAC;AACjC,CAAC","ignoreList":[]}
|
||||
38
_node_modules/effect/dist/esm/internal/encoding/common.js
generated
vendored
Normal file
38
_node_modules/effect/dist/esm/internal/encoding/common.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { hasProperty, isString } from "../../Predicate.js";
|
||||
/** @internal */
|
||||
export const DecodeExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Encoding/errors/Decode");
|
||||
/** @internal */
|
||||
export const DecodeException = (input, message) => {
|
||||
const out = {
|
||||
_tag: "DecodeException",
|
||||
[DecodeExceptionTypeId]: DecodeExceptionTypeId,
|
||||
input
|
||||
};
|
||||
if (isString(message)) {
|
||||
out.message = message;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
/** @internal */
|
||||
export const isDecodeException = u => hasProperty(u, DecodeExceptionTypeId);
|
||||
/** @internal */
|
||||
export const EncodeExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Encoding/errors/Encode");
|
||||
/** @internal */
|
||||
export const EncodeException = (input, message) => {
|
||||
const out = {
|
||||
_tag: "EncodeException",
|
||||
[EncodeExceptionTypeId]: EncodeExceptionTypeId,
|
||||
input
|
||||
};
|
||||
if (isString(message)) {
|
||||
out.message = message;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
/** @internal */
|
||||
export const isEncodeException = u => hasProperty(u, EncodeExceptionTypeId);
|
||||
/** @interal */
|
||||
export const encoder = /*#__PURE__*/new TextEncoder();
|
||||
/** @interal */
|
||||
export const decoder = /*#__PURE__*/new TextDecoder();
|
||||
//# sourceMappingURL=common.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/encoding/common.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/encoding/common.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.js","names":["hasProperty","isString","DecodeExceptionTypeId","Symbol","for","DecodeException","input","message","out","_tag","isDecodeException","u","EncodeExceptionTypeId","EncodeException","isEncodeException","encoder","TextEncoder","decoder","TextDecoder"],"sources":["../../../../src/internal/encoding/common.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAG1D;AACA,OAAO,MAAMC,qBAAqB,gBAAmCC,MAAM,CAACC,GAAG,CAC7E,+BAA+B,CACE;AAEnC;AACA,OAAO,MAAMC,eAAe,GAAGA,CAACC,KAAa,EAAEC,OAAgB,KAA8B;EAC3F,MAAMC,GAAG,GAAsC;IAC7CC,IAAI,EAAE,iBAAiB;IACvB,CAACP,qBAAqB,GAAGA,qBAAqB;IAC9CI;GACD;EACD,IAAIL,QAAQ,CAACM,OAAO,CAAC,EAAE;IACrBC,GAAG,CAACD,OAAO,GAAGA,OAAO;EACvB;EACA,OAAOC,GAAG;AACZ,CAAC;AAED;AACA,OAAO,MAAME,iBAAiB,GAAIC,CAAU,IAAoCX,WAAW,CAACW,CAAC,EAAET,qBAAqB,CAAC;AAErH;AACA,OAAO,MAAMU,qBAAqB,gBAAmCT,MAAM,CAACC,GAAG,CAC7E,+BAA+B,CACE;AAEnC;AACA,OAAO,MAAMS,eAAe,GAAGA,CAACP,KAAa,EAAEC,OAAgB,KAA8B;EAC3F,MAAMC,GAAG,GAAsC;IAC7CC,IAAI,EAAE,iBAAiB;IACvB,CAACG,qBAAqB,GAAGA,qBAAqB;IAC9CN;GACD;EACD,IAAIL,QAAQ,CAACM,OAAO,CAAC,EAAE;IACrBC,GAAG,CAACD,OAAO,GAAGA,OAAO;EACvB;EACA,OAAOC,GAAG;AACZ,CAAC;AAED;AACA,OAAO,MAAMM,iBAAiB,GAAIH,CAAU,IAAoCX,WAAW,CAACW,CAAC,EAAEC,qBAAqB,CAAC;AAErH;AACA,OAAO,MAAMG,OAAO,gBAAG,IAAIC,WAAW,EAAE;AAExC;AACA,OAAO,MAAMC,OAAO,gBAAG,IAAIC,WAAW,EAAE","ignoreList":[]}
|
||||
48
_node_modules/effect/dist/esm/internal/encoding/hex.js
generated
vendored
Normal file
48
_node_modules/effect/dist/esm/internal/encoding/hex.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as Either from "../../Either.js";
|
||||
import { DecodeException } from "./common.js";
|
||||
/** @internal */
|
||||
export const encode = bytes => {
|
||||
let result = "";
|
||||
for (let i = 0; i < bytes.length; ++i) {
|
||||
result += bytesToHex[bytes[i]];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/** @internal */
|
||||
export const decode = str => {
|
||||
const bytes = new TextEncoder().encode(str);
|
||||
if (bytes.length % 2 !== 0) {
|
||||
return Either.left(DecodeException(str, `Length must be a multiple of 2, but is ${bytes.length}`));
|
||||
}
|
||||
try {
|
||||
const length = bytes.length / 2;
|
||||
const result = new Uint8Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
const a = fromHexChar(bytes[i * 2]);
|
||||
const b = fromHexChar(bytes[i * 2 + 1]);
|
||||
result[i] = a << 4 | b;
|
||||
}
|
||||
return Either.right(result);
|
||||
} catch (e) {
|
||||
return Either.left(DecodeException(str, e instanceof Error ? e.message : "Invalid input"));
|
||||
}
|
||||
};
|
||||
/** @internal */
|
||||
const bytesToHex = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
|
||||
/** @internal */
|
||||
const fromHexChar = byte => {
|
||||
// '0' <= byte && byte <= '9'
|
||||
if (48 <= byte && byte <= 57) {
|
||||
return byte - 48;
|
||||
}
|
||||
// 'a' <= byte && byte <= 'f'
|
||||
if (97 <= byte && byte <= 102) {
|
||||
return byte - 97 + 10;
|
||||
}
|
||||
// 'A' <= byte && byte <= 'F'
|
||||
if (65 <= byte && byte <= 70) {
|
||||
return byte - 65 + 10;
|
||||
}
|
||||
throw new TypeError("Invalid input");
|
||||
};
|
||||
//# sourceMappingURL=hex.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/encoding/hex.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/encoding/hex.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hex.js","names":["Either","DecodeException","encode","bytes","result","i","length","bytesToHex","decode","str","TextEncoder","left","Uint8Array","a","fromHexChar","b","right","e","Error","message","byte","TypeError"],"sources":["../../../../src/internal/encoding/hex.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,iBAAiB;AAEzC,SAASC,eAAe,QAAQ,aAAa;AAE7C;AACA,OAAO,MAAMC,MAAM,GAAIC,KAAiB,IAAI;EAC1C,IAAIC,MAAM,GAAG,EAAE;EACf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,KAAK,CAACG,MAAM,EAAE,EAAED,CAAC,EAAE;IACrCD,MAAM,IAAIG,UAAU,CAACJ,KAAK,CAACE,CAAC,CAAC,CAAC;EAChC;EAEA,OAAOD,MAAM;AACf,CAAC;AAED;AACA,OAAO,MAAMI,MAAM,GAAIC,GAAW,IAAyD;EACzF,MAAMN,KAAK,GAAG,IAAIO,WAAW,EAAE,CAACR,MAAM,CAACO,GAAG,CAAC;EAC3C,IAAIN,KAAK,CAACG,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;IAC1B,OAAON,MAAM,CAACW,IAAI,CAACV,eAAe,CAACQ,GAAG,EAAE,0CAA0CN,KAAK,CAACG,MAAM,EAAE,CAAC,CAAC;EACpG;EAEA,IAAI;IACF,MAAMA,MAAM,GAAGH,KAAK,CAACG,MAAM,GAAG,CAAC;IAC/B,MAAMF,MAAM,GAAG,IAAIQ,UAAU,CAACN,MAAM,CAAC;IACrC,KAAK,IAAID,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGC,MAAM,EAAED,CAAC,EAAE,EAAE;MAC/B,MAAMQ,CAAC,GAAGC,WAAW,CAACX,KAAK,CAACE,CAAC,GAAG,CAAC,CAAC,CAAC;MACnC,MAAMU,CAAC,GAAGD,WAAW,CAACX,KAAK,CAACE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;MACvCD,MAAM,CAACC,CAAC,CAAC,GAAIQ,CAAC,IAAI,CAAC,GAAIE,CAAC;IAC1B;IAEA,OAAOf,MAAM,CAACgB,KAAK,CAACZ,MAAM,CAAC;EAC7B,CAAC,CAAC,OAAOa,CAAC,EAAE;IACV,OAAOjB,MAAM,CAACW,IAAI,CAACV,eAAe,CAACQ,GAAG,EAAEQ,CAAC,YAAYC,KAAK,GAAGD,CAAC,CAACE,OAAO,GAAG,eAAe,CAAC,CAAC;EAC5F;AACF,CAAC;AAED;AACA,MAAMZ,UAAU,GAAG,CACjB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACL;AAED;AACA,MAAMO,WAAW,GAAIM,IAAY,IAAI;EACnC;EACA,IAAI,EAAE,IAAIA,IAAI,IAAIA,IAAI,IAAI,EAAE,EAAE;IAC5B,OAAOA,IAAI,GAAG,EAAE;EAClB;EAEA;EACA,IAAI,EAAE,IAAIA,IAAI,IAAIA,IAAI,IAAI,GAAG,EAAE;IAC7B,OAAOA,IAAI,GAAG,EAAE,GAAG,EAAE;EACvB;EAEA;EACA,IAAI,EAAE,IAAIA,IAAI,IAAIA,IAAI,IAAI,EAAE,EAAE;IAC5B,OAAOA,IAAI,GAAG,EAAE,GAAG,EAAE;EACvB;EAEA,MAAM,IAAIC,SAAS,CAAC,eAAe,CAAC;AACtC,CAAC","ignoreList":[]}
|
||||
6
_node_modules/effect/dist/esm/internal/errors.js
generated
vendored
Normal file
6
_node_modules/effect/dist/esm/internal/errors.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
/** @internal */
|
||||
export const getBugErrorMessage = message => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
||||
//# sourceMappingURL=errors.js.map
|
||||
1
_node_modules/effect/dist/esm/internal/errors.js.map
generated
vendored
Normal file
1
_node_modules/effect/dist/esm/internal/errors.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.js","names":["getBugErrorMessage","message"],"sources":["../../../src/internal/errors.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AACA,OAAO,MAAMA,kBAAkB,GAAIC,OAAe,IAChD,QAAQA,OAAO,yEAAyE","ignoreList":[]}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user