Aktueller Stand

This commit is contained in:
2026-01-23 01:33:35 +01:00
parent 082dc5e110
commit 2766dd12c5
10109 changed files with 1578841 additions and 77685 deletions

13
backend/node_modules/effect/dist/cjs/internal/array.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isNonEmptyArray = void 0;
/**
* @since 2.0.0
*/
/** @internal */
const isNonEmptyArray = self => self.length > 0;
exports.isNonEmptyArray = isNonEmptyArray;
//# sourceMappingURL=array.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"array.js","names":["isNonEmptyArray","self","length","exports"],"sources":["../../../src/internal/array.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA;;;AAMA;AACO,MAAMA,eAAe,GAAOC,IAAsB,IAA+BA,IAAI,CAACC,MAAM,GAAG,CAAC;AAAAC,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}

View File

@@ -0,0 +1,369 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.single = exports.sequentialCollectionToChunk = exports.sequentialCollectionMake = exports.sequentialCollectionKeys = exports.sequentialCollectionIsEmpty = exports.sequentialCollectionCombine = exports.seq = exports.reduce = exports.parallelCollectionToSequentialCollection = exports.parallelCollectionMake = exports.parallelCollectionKeys = exports.parallelCollectionIsEmpty = exports.parallelCollectionEmpty = exports.parallelCollectionCombine = exports.parallelCollectionAdd = exports.par = exports.mapRequestResolvers = exports.makeEntry = exports.isEntry = exports.flatten = exports.empty = exports.SequentialCollectionTypeId = exports.RequestBlockParallelTypeId = exports.MapRequestResolversReducer = exports.EntryTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var Equal = _interopRequireWildcard(require("../Equal.js"));
var HashMap = _interopRequireWildcard(require("../HashMap.js"));
var List = _interopRequireWildcard(require("../List.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var _Predicate = require("../Predicate.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const empty = exports.empty = {
_tag: "Empty"
};
/**
* Combines this collection of blocked requests with the specified collection
* of blocked requests, in parallel.
*
* @internal
*/
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
*/
exports.par = par;
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
*/
exports.seq = seq;
const single = (dataSource, blockedRequest) => ({
_tag: "Single",
dataSource: dataSource,
blockedRequest
});
/** @internal */
exports.single = single;
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
*/
exports.MapRequestResolversReducer = MapRequestResolversReducer;
const mapRequestResolvers = (self, f) => reduce(self, MapRequestResolversReducer(f));
/**
* Folds over the cases of this collection of blocked requests with the
* specified functions.
*
* @internal
*/
exports.mapRequestResolvers = mapRequestResolvers;
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
*/
exports.reduce = reduce;
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.
*/
exports.flatten = flatten;
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 */
const EntryTypeId = exports.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 */
const isEntry = u => (0, _Predicate.hasProperty)(u, EntryTypeId);
/** @internal */
exports.isEntry = isEntry;
const makeEntry = options => new EntryImpl(options.request, options.result, options.listeners, options.ownerId, options.state);
/** @internal */
exports.makeEntry = makeEntry;
const RequestBlockParallelTypeId = exports.RequestBlockParallelTypeId = /*#__PURE__*/Symbol.for("effect/RequestBlock/RequestBlockParallel");
const parallelVariance = {
/* c8 ignore next */
_R: _ => _
};
class ParallelImpl {
map;
[RequestBlockParallelTypeId] = parallelVariance;
constructor(map) {
this.map = map;
}
}
/** @internal */
const parallelCollectionEmpty = () => new ParallelImpl(HashMap.empty());
/** @internal */
exports.parallelCollectionEmpty = parallelCollectionEmpty;
const parallelCollectionMake = (dataSource, blockedRequest) => new ParallelImpl(HashMap.make([dataSource, Chunk.of(blockedRequest)]));
/** @internal */
exports.parallelCollectionMake = parallelCollectionMake;
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 */
exports.parallelCollectionAdd = parallelCollectionAdd;
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 */
exports.parallelCollectionCombine = parallelCollectionCombine;
const parallelCollectionIsEmpty = self => HashMap.isEmpty(self.map);
/** @internal */
exports.parallelCollectionIsEmpty = parallelCollectionIsEmpty;
const parallelCollectionKeys = self => Array.from(HashMap.keys(self.map));
/** @internal */
exports.parallelCollectionKeys = parallelCollectionKeys;
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 */
exports.parallelCollectionToSequentialCollection = parallelCollectionToSequentialCollection;
const SequentialCollectionTypeId = exports.SequentialCollectionTypeId = /*#__PURE__*/Symbol.for("effect/RequestBlock/RequestBlockSequential");
const sequentialVariance = {
/* c8 ignore next */
_R: _ => _
};
class SequentialImpl {
map;
[SequentialCollectionTypeId] = sequentialVariance;
constructor(map) {
this.map = map;
}
}
/** @internal */
const sequentialCollectionMake = map => new SequentialImpl(map);
/** @internal */
exports.sequentialCollectionMake = sequentialCollectionMake;
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 */
exports.sequentialCollectionCombine = sequentialCollectionCombine;
const sequentialCollectionIsEmpty = self => HashMap.isEmpty(self.map);
/** @internal */
exports.sequentialCollectionIsEmpty = sequentialCollectionIsEmpty;
const sequentialCollectionKeys = self => Array.from(HashMap.keys(self.map));
/** @internal */
exports.sequentialCollectionKeys = sequentialCollectionKeys;
const sequentialCollectionToChunk = self => Array.from(self.map);
exports.sequentialCollectionToChunk = sequentialCollectionToChunk;
//# sourceMappingURL=blockedRequests.js.map

File diff suppressed because one or more lines are too long

500
backend/node_modules/effect/dist/cjs/internal/cache.js generated vendored Normal file
View File

@@ -0,0 +1,500 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unsafeMakeWith = exports.refreshing = exports.pending = exports.makeWith = exports.makeMapKey = exports.makeKeySet = exports.makeEntryStats = exports.makeCacheStats = exports.makeCacheState = exports.make = exports.isMapKey = exports.initialCacheState = exports.complete = exports.MapKeyTypeId = exports.ConsumerCacheTypeId = exports.CacheTypeId = void 0;
var Context = _interopRequireWildcard(require("../Context.js"));
var Deferred = _interopRequireWildcard(require("../Deferred.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var Equal = _interopRequireWildcard(require("../Equal.js"));
var Exit = _interopRequireWildcard(require("../Exit.js"));
var _Function = require("../Function.js");
var Hash = _interopRequireWildcard(require("../Hash.js"));
var MutableHashMap = _interopRequireWildcard(require("../MutableHashMap.js"));
var MutableQueue = _interopRequireWildcard(require("../MutableQueue.js"));
var MutableRef = _interopRequireWildcard(require("../MutableRef.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var _Predicate = require("../Predicate.js");
var effect = _interopRequireWildcard(require("./core-effect.js"));
var core = _interopRequireWildcard(require("./core.js"));
var Data = _interopRequireWildcard(require("./data.js"));
var _fiberId = require("./fiberId.js");
var fiberRuntime = _interopRequireWildcard(require("./fiberRuntime.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const complete = (key, exit, entryStats, timeToLiveMillis) => Data.struct({
_tag: "Complete",
key,
exit,
entryStats,
timeToLiveMillis
});
/** @internal */
exports.complete = complete;
const pending = (key, deferred) => Data.struct({
_tag: "Pending",
key,
deferred
});
/** @internal */
exports.pending = pending;
const refreshing = (deferred, complete) => Data.struct({
_tag: "Refreshing",
deferred,
complete
});
/** @internal */
exports.refreshing = refreshing;
const MapKeyTypeId = exports.MapKeyTypeId = /*#__PURE__*/Symbol.for("effect/Cache/MapKey");
class MapKeyImpl {
current;
[MapKeyTypeId] = MapKeyTypeId;
previous = undefined;
next = undefined;
constructor(current) {
this.current = current;
}
[Hash.symbol]() {
return (0, _Function.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 */
const makeMapKey = current => new MapKeyImpl(current);
/** @internal */
exports.makeMapKey = makeMapKey;
const isMapKey = u => (0, _Predicate.hasProperty)(u, MapKeyTypeId);
exports.isMapKey = isMapKey;
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 */
const makeKeySet = () => new KeySetImpl();
/**
* Constructs a new `CacheState` from the specified values.
*
* @internal
*/
exports.makeKeySet = makeKeySet;
const makeCacheState = (map, keys, accesses, updating, hits, misses) => ({
map,
keys,
accesses,
updating,
hits,
misses
});
/**
* Constructs an initial cache state.
*
* @internal
*/
exports.makeCacheState = makeCacheState;
const initialCacheState = () => makeCacheState(MutableHashMap.empty(), makeKeySet(), MutableQueue.unbounded(), MutableRef.make(false), 0, 0);
/** @internal */
exports.initialCacheState = initialCacheState;
const CacheSymbolKey = "effect/Cache";
/** @internal */
const CacheTypeId = exports.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 */
const ConsumerCacheTypeId = exports.ConsumerCacheTypeId = /*#__PURE__*/Symbol.for(ConsumerCacheSymbolKey);
const consumerCacheVariance = {
/* c8 ignore next */
_Key: _ => _,
/* c8 ignore next */
_Error: _ => _,
/* c8 ignore next */
_Value: _ => _
};
/** @internal */
const makeCacheStats = options => options;
/** @internal */
exports.makeCacheStats = makeCacheStats;
const makeEntryStats = loadedMillis => ({
loadedMillis
});
exports.makeEntryStats = makeEntryStats;
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 (0, _Function.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 (0, _Function.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 */
const make = options => {
const timeToLive = Duration.decode(options.timeToLive);
return makeWith({
capacity: options.capacity,
lookup: options.lookup,
timeToLive: () => timeToLive
});
};
/** @internal */
exports.make = make;
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 */
exports.makeWith = makeWith;
const unsafeMakeWith = (capacity, lookup, timeToLive) => new CacheImpl(capacity, Context.empty(), _fiberId.none, lookup, exit => Duration.decode(timeToLive(exit)));
exports.unsafeMakeWith = unsafeMakeWith;
//# sourceMappingURL=cache.js.map

File diff suppressed because one or more lines are too long

867
backend/node_modules/effect/dist/cjs/internal/cause.js generated vendored Normal file
View File

@@ -0,0 +1,867 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stripSomeDefects = exports.stripFailures = exports.spanToTrace = exports.spanSymbol = exports.size = exports.sequential = exports.reduceWithContext = exports.reduce = exports.prettyErrors = exports.prettyErrorMessage = exports.pretty = exports.parallel = exports.match = exports.map = exports.linearize = exports.keepDefectsAndElectFailures = exports.keepDefects = exports.isSequentialType = exports.isParallelType = exports.isInterruptedOnly = exports.isInterrupted = exports.isInterruptType = exports.isFailure = exports.isFailType = exports.isEmptyType = exports.isEmpty = exports.isDieType = exports.isDie = exports.isCause = exports.interruptors = exports.interruptOption = exports.interrupt = exports.flipCauseOption = exports.flatten = exports.flatMap = exports.find = exports.filter = exports.failures = exports.failureOrCause = exports.failureOption = exports.fail = exports.empty = exports.electFailures = exports.dieOption = exports.die = exports.defects = exports.contains = exports.as = exports.andThen = exports.PrettyError = exports.CauseTypeId = void 0;
var Arr = _interopRequireWildcard(require("../Array.js"));
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var Equal = _interopRequireWildcard(require("../Equal.js"));
var _Function = require("../Function.js");
var _GlobalValue = require("../GlobalValue.js");
var Hash = _interopRequireWildcard(require("../Hash.js"));
var HashSet = _interopRequireWildcard(require("../HashSet.js"));
var _Inspectable = require("../Inspectable.js");
var Option = _interopRequireWildcard(require("../Option.js"));
var _Pipeable = require("../Pipeable.js");
var _Predicate = require("../Predicate.js");
var _errors = require("./errors.js");
var OpCodes = _interopRequireWildcard(require("./opCodes/cause.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// -----------------------------------------------------------------------------
// Models
// -----------------------------------------------------------------------------
/** @internal */
const CauseSymbolKey = "effect/Cause";
/** @internal */
const CauseTypeId = exports.CauseTypeId = /*#__PURE__*/Symbol.for(CauseSymbolKey);
const variance = {
/* c8 ignore next */
_E: _ => _
};
/** @internal */
const proto = {
[CauseTypeId]: variance,
[Hash.symbol]() {
return (0, _Function.pipe)(Hash.hash(CauseSymbolKey), Hash.combine(Hash.hash(flattenCause(this))), Hash.cached(this));
},
[Equal.symbol](that) {
return isCause(that) && causeEquals(this, that);
},
pipe() {
return (0, _Pipeable.pipeArguments)(this, arguments);
},
toJSON() {
switch (this._tag) {
case "Empty":
return {
_id: "Cause",
_tag: this._tag
};
case "Die":
return {
_id: "Cause",
_tag: this._tag,
defect: (0, _Inspectable.toJSON)(this.defect)
};
case "Interrupt":
return {
_id: "Cause",
_tag: this._tag,
fiberId: this.fiberId.toJSON()
};
case "Fail":
return {
_id: "Cause",
_tag: this._tag,
failure: (0, _Inspectable.toJSON)(this.error)
};
case "Sequential":
case "Parallel":
return {
_id: "Cause",
_tag: this._tag,
left: (0, _Inspectable.toJSON)(this.left),
right: (0, _Inspectable.toJSON)(this.right)
};
}
},
toString() {
return pretty(this);
},
[_Inspectable.NodeInspectSymbol]() {
return this.toJSON();
}
};
// -----------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------
/** @internal */
const empty = exports.empty = /*#__PURE__*/(() => {
const o = /*#__PURE__*/Object.create(proto);
o._tag = OpCodes.OP_EMPTY;
return o;
})();
/** @internal */
const fail = error => {
const o = Object.create(proto);
o._tag = OpCodes.OP_FAIL;
o.error = error;
return o;
};
/** @internal */
exports.fail = fail;
const die = defect => {
const o = Object.create(proto);
o._tag = OpCodes.OP_DIE;
o.defect = defect;
return o;
};
/** @internal */
exports.die = die;
const interrupt = fiberId => {
const o = Object.create(proto);
o._tag = OpCodes.OP_INTERRUPT;
o.fiberId = fiberId;
return o;
};
/** @internal */
exports.interrupt = interrupt;
const parallel = (left, right) => {
const o = Object.create(proto);
o._tag = OpCodes.OP_PARALLEL;
o.left = left;
o.right = right;
return o;
};
/** @internal */
exports.parallel = parallel;
const sequential = (left, right) => {
const o = Object.create(proto);
o._tag = OpCodes.OP_SEQUENTIAL;
o.left = left;
o.right = right;
return o;
};
// -----------------------------------------------------------------------------
// Refinements
// -----------------------------------------------------------------------------
/** @internal */
exports.sequential = sequential;
const isCause = u => (0, _Predicate.hasProperty)(u, CauseTypeId);
/** @internal */
exports.isCause = isCause;
const isEmptyType = self => self._tag === OpCodes.OP_EMPTY;
/** @internal */
exports.isEmptyType = isEmptyType;
const isFailType = self => self._tag === OpCodes.OP_FAIL;
/** @internal */
exports.isFailType = isFailType;
const isDieType = self => self._tag === OpCodes.OP_DIE;
/** @internal */
exports.isDieType = isDieType;
const isInterruptType = self => self._tag === OpCodes.OP_INTERRUPT;
/** @internal */
exports.isInterruptType = isInterruptType;
const isSequentialType = self => self._tag === OpCodes.OP_SEQUENTIAL;
/** @internal */
exports.isSequentialType = isSequentialType;
const isParallelType = self => self._tag === OpCodes.OP_PARALLEL;
// -----------------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------------
/** @internal */
exports.isParallelType = isParallelType;
const size = self => reduceWithContext(self, void 0, SizeCauseReducer);
/** @internal */
exports.size = size;
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 */
exports.isEmpty = isEmpty;
const isFailure = self => Option.isSome(failureOption(self));
/** @internal */
exports.isFailure = isFailure;
const isDie = self => Option.isSome(dieOption(self));
/** @internal */
exports.isDie = isDie;
const isInterrupted = self => Option.isSome(interruptOption(self));
/** @internal */
exports.isInterrupted = isInterrupted;
const isInterruptedOnly = self => reduceWithContext(undefined, IsInterruptedOnlyCauseReducer)(self);
/** @internal */
exports.isInterruptedOnly = isInterruptedOnly;
const failures = self => Chunk.reverse(reduce(self, Chunk.empty(), (list, cause) => cause._tag === OpCodes.OP_FAIL ? Option.some((0, _Function.pipe)(list, Chunk.prepend(cause.error))) : Option.none()));
/** @internal */
exports.failures = failures;
const defects = self => Chunk.reverse(reduce(self, Chunk.empty(), (list, cause) => cause._tag === OpCodes.OP_DIE ? Option.some((0, _Function.pipe)(list, Chunk.prepend(cause.defect))) : Option.none()));
/** @internal */
exports.defects = defects;
const interruptors = self => reduce(self, HashSet.empty(), (set, cause) => cause._tag === OpCodes.OP_INTERRUPT ? Option.some((0, _Function.pipe)(set, HashSet.add(cause.fiberId))) : Option.none());
/** @internal */
exports.interruptors = interruptors;
const failureOption = self => find(self, cause => cause._tag === OpCodes.OP_FAIL ? Option.some(cause.error) : Option.none());
/** @internal */
exports.failureOption = failureOption;
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 */
exports.failureOrCause = failureOrCause;
const dieOption = self => find(self, cause => cause._tag === OpCodes.OP_DIE ? Option.some(cause.defect) : Option.none());
/** @internal */
exports.dieOption = dieOption;
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 */
exports.flipCauseOption = flipCauseOption;
const interruptOption = self => find(self, cause => cause._tag === OpCodes.OP_INTERRUPT ? Option.some(cause.fiberId) : Option.none());
/** @internal */
exports.interruptOption = interruptOption;
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 */
exports.keepDefects = keepDefects;
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 */
exports.keepDefectsAndElectFailures = keepDefectsAndElectFailures;
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 */
exports.linearize = linearize;
const stripFailures = self => match(self, {
onEmpty: empty,
onFail: () => empty,
onDie: die,
onInterrupt: interrupt,
onSequential: sequential,
onParallel: parallel
});
/** @internal */
exports.stripFailures = stripFailures;
const electFailures = self => match(self, {
onEmpty: empty,
onFail: die,
onDie: die,
onInterrupt: interrupt,
onSequential: sequential,
onParallel: parallel
});
/** @internal */
exports.electFailures = electFailures;
const stripSomeDefects = exports.stripSomeDefects = /*#__PURE__*/(0, _Function.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 */
const as = exports.as = /*#__PURE__*/(0, _Function.dual)(2, (self, error) => map(self, () => error));
/** @internal */
const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => flatMap(self, e => fail(f(e))));
// -----------------------------------------------------------------------------
// Sequencing
// -----------------------------------------------------------------------------
/** @internal */
const flatMap = exports.flatMap = /*#__PURE__*/(0, _Function.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 */
const flatten = self => flatMap(self, _Function.identity);
/** @internal */
exports.flatten = flatten;
const andThen = exports.andThen = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => (0, _Predicate.isFunction)(f) ? flatMap(self, f) : flatMap(self, () => f));
// -----------------------------------------------------------------------------
// Equality
// -----------------------------------------------------------------------------
/** @internal */
const contains = exports.contains = /*#__PURE__*/(0, _Function.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] = (0, _Function.pipe)(Chunk.headNonEmpty(leftStack), reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
const [par, seq] = evaluateCause(cause);
return Option.some([(0, _Function.pipe)(parallel, HashSet.union(par)), (0, _Function.pipe)(sequential, Chunk.appendAll(seq))]);
}));
const [rightParallel, rightSequential] = (0, _Function.pipe)(Chunk.headNonEmpty(rightStack), reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
const [par, seq] = evaluateCause(cause);
return Option.some([(0, _Function.pipe)(parallel, HashSet.union(par)), (0, _Function.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] = (0, _Function.pipe)(causes, Arr.reduce([HashSet.empty(), Chunk.empty()], ([parallel, sequential], cause) => {
const [par, seq] = evaluateCause(cause);
return [(0, _Function.pipe)(parallel, HashSet.union(par)), (0, _Function.pipe)(sequential, Chunk.appendAll(seq))];
}));
const updated = HashSet.size(parallel) > 0 ? (0, _Function.pipe)(flattened, Chunk.prepend(parallel)) : flattened;
if (Chunk.isEmpty(sequential)) {
return Chunk.reverse(updated);
}
causes = sequential;
flattened = updated;
}
throw new Error((0, _errors.getBugErrorMessage)("Cause.flattenCauseLoop"));
};
// -----------------------------------------------------------------------------
// Finding
// -----------------------------------------------------------------------------
/** @internal */
const find = exports.find = /*#__PURE__*/(0, _Function.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 */
const filter = exports.filter = /*#__PURE__*/(0, _Function.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((0, _errors.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: _Function.constTrue,
failCase: _Function.constFalse,
dieCase: _Function.constFalse,
interruptCase: _Function.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 */
const match = exports.match = /*#__PURE__*/(0, _Function.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 */
const reduce = exports.reduce = /*#__PURE__*/(0, _Function.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 */
const reduceWithContext = exports.reduceWithContext = /*#__PURE__*/(0, _Function.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 */
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");
};
exports.pretty = pretty;
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 */
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
*/
exports.PrettyError = PrettyError;
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 ((0, _Predicate.hasProperty)(u, "toString") && (0, _Predicate.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 (0, _Inspectable.stringifyCircular)(u);
};
exports.prettyErrorMessage = prettyErrorMessage;
const locationRegex = /\((.*)\)/g;
/** @internal */
const spanToTrace = exports.spanToTrace = /*#__PURE__*/(0, _GlobalValue.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 */
const spanSymbol = exports.spanSymbol = /*#__PURE__*/Symbol.for("effect/SpanAnnotation");
/** @internal */
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]
});
exports.prettyErrors = prettyErrors;
//# sourceMappingURL=cause.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,738 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zipRight = exports.zipLeft = exports.zip = exports.writeChunk = exports.writeAll = exports.withSpan = exports.updateService = exports.unwrapScopedWith = exports.unwrapScoped = exports.unwrap = exports.toQueue = exports.toPullIn = exports.toPull = exports.toPubSub = exports.splitLines = exports.serviceWithEffect = exports.serviceWithChannel = exports.serviceWith = exports.service = exports.scopedWith = exports.scoped = exports.runScoped = exports.runDrain = exports.runCollect = exports.run = exports.repeated = exports.read = exports.provideSomeLayer = exports.provideService = exports.provideLayer = exports.pipeToOrFail = exports.orElse = exports.orDieWith = exports.orDie = exports.never = exports.mergeWith = exports.mergeOutWith = exports.mergeOut = exports.mergeMap = exports.mergeAllWith = exports.mergeAllUnboundedWith = exports.mergeAllUnbounded = exports.mergeAll = exports.mapOutEffectPar = exports.mapOutEffect = exports.mapOut = exports.mapInputInEffect = exports.mapInputIn = exports.mapInputErrorEffect = exports.mapInputError = exports.mapInputEffect = exports.mapInputContext = exports.mapInput = exports.mapErrorCause = exports.mapError = exports.mapEffect = exports.map = exports.isChannelException = exports.interruptWhenDeferred = exports.interruptWhen = exports.identityChannel = exports.fromQueue = exports.fromPubSubScoped = exports.fromPubSub = exports.fromOption = exports.fromInput = exports.fromEither = exports.foldChannel = exports.flatten = exports.ensuring = exports.emitCollect = exports.drain = exports.doneCollect = exports.contextWithEffect = exports.contextWithChannel = exports.contextWith = exports.context = exports.concatOut = exports.concatMap = exports.collect = exports.catchAll = exports.bufferChunk = exports.buffer = exports.asVoid = exports.as = exports.acquireUseRelease = exports.ChannelExceptionTypeId = exports.ChannelException = void 0;
var Cause = _interopRequireWildcard(require("../Cause.js"));
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Context = _interopRequireWildcard(require("../Context.js"));
var Deferred = _interopRequireWildcard(require("../Deferred.js"));
var Effect = _interopRequireWildcard(require("../Effect.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var Equal = _interopRequireWildcard(require("../Equal.js"));
var Exit = _interopRequireWildcard(require("../Exit.js"));
var Fiber = _interopRequireWildcard(require("../Fiber.js"));
var FiberRef = _interopRequireWildcard(require("../FiberRef.js"));
var _Function = require("../Function.js");
var Layer = _interopRequireWildcard(require("../Layer.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var _Predicate = require("../Predicate.js");
var PubSub = _interopRequireWildcard(require("../PubSub.js"));
var Queue = _interopRequireWildcard(require("../Queue.js"));
var Ref = _interopRequireWildcard(require("../Ref.js"));
var Scope = _interopRequireWildcard(require("../Scope.js"));
var executor = _interopRequireWildcard(require("./channel/channelExecutor.js"));
var mergeDecision = _interopRequireWildcard(require("./channel/mergeDecision.js"));
var mergeState = _interopRequireWildcard(require("./channel/mergeState.js"));
var mergeStrategy_ = _interopRequireWildcard(require("./channel/mergeStrategy.js"));
var singleProducerAsyncInput = _interopRequireWildcard(require("./channel/singleProducerAsyncInput.js"));
var coreEffect = _interopRequireWildcard(require("./core-effect.js"));
var core = _interopRequireWildcard(require("./core-stream.js"));
var MergeDecisionOpCodes = _interopRequireWildcard(require("./opCodes/channelMergeDecision.js"));
var MergeStateOpCodes = _interopRequireWildcard(require("./opCodes/channelMergeState.js"));
var ChannelStateOpCodes = _interopRequireWildcard(require("./opCodes/channelState.js"));
var tracer = _interopRequireWildcard(require("./tracer.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const acquireUseRelease = (acquire, use, release) => core.flatMap(core.fromEffect(Ref.make(() => Effect.void)), ref => (0, _Function.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 */
exports.acquireUseRelease = acquireUseRelease;
const as = exports.as = /*#__PURE__*/(0, _Function.dual)(2, (self, value) => map(self, () => value));
/** @internal */
const asVoid = self => map(self, _Function.constVoid);
/** @internal */
exports.asVoid = asVoid;
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 */
exports.buffer = buffer;
const bufferChunk = ref => buffer({
empty: Chunk.empty(),
isEmpty: Chunk.isEmpty,
ref
});
/** @internal */
exports.bufferChunk = bufferChunk;
const catchAll = exports.catchAll = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.catchAllCause(self, cause => Either.match(Cause.failureOrCause(cause), {
onLeft: f,
onRight: core.failCause
})));
/** @internal */
const concatMap = exports.concatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.concatMapWith(self, f, () => void 0, () => void 0));
/** @internal */
const collect = exports.collect = /*#__PURE__*/(0, _Function.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 */
const concatOut = self => core.concatAll(self);
/** @internal */
exports.concatOut = concatOut;
const mapInput = exports.mapInput = /*#__PURE__*/(0, _Function.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 */
const mapInputEffect = exports.mapInputEffect = /*#__PURE__*/(0, _Function.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 */
const mapInputError = exports.mapInputError = /*#__PURE__*/(0, _Function.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 */
const mapInputErrorEffect = exports.mapInputErrorEffect = /*#__PURE__*/(0, _Function.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 */
const mapInputIn = exports.mapInputIn = /*#__PURE__*/(0, _Function.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 */
const mapInputInEffect = exports.mapInputInEffect = /*#__PURE__*/(0, _Function.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 */
const doneCollect = self => core.suspend(() => {
const builder = [];
return (0, _Function.pipe)(core.pipeTo(self, doneCollectReader(builder)), core.flatMap(outDone => core.succeed([Chunk.unsafeFromArray(builder), outDone])));
});
/** @internal */
exports.doneCollect = doneCollect;
const doneCollectReader = builder => {
return core.readWith({
onInput: outElem => core.flatMap(core.sync(() => {
builder.push(outElem);
}), () => doneCollectReader(builder)),
onFailure: core.fail,
onDone: core.succeed
});
};
/** @internal */
const drain = self => {
const drainer = core.readWithCause({
onInput: () => drainer,
onFailure: core.failCause,
onDone: core.succeed
});
return core.pipeTo(self, drainer);
};
/** @internal */
exports.drain = drain;
const emitCollect = self => core.flatMap(doneCollect(self), core.write);
/** @internal */
exports.emitCollect = emitCollect;
const ensuring = exports.ensuring = /*#__PURE__*/(0, _Function.dual)(2, (self, finalizer) => core.ensuringWith(self, () => finalizer));
/** @internal */
const context = () => core.fromEffect(Effect.context());
/** @internal */
exports.context = context;
const contextWith = f => map(context(), f);
/** @internal */
exports.contextWith = contextWith;
const contextWithChannel = f => core.flatMap(context(), f);
/** @internal */
exports.contextWithChannel = contextWithChannel;
const contextWithEffect = f => mapEffect(context(), f);
/** @internal */
exports.contextWithEffect = contextWithEffect;
const flatten = self => core.flatMap(self, _Function.identity);
/** @internal */
exports.flatten = flatten;
const foldChannel = exports.foldChannel = /*#__PURE__*/(0, _Function.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 */
const fromEither = either => core.suspend(() => Either.match(either, {
onLeft: core.fail,
onRight: core.succeed
}));
/** @internal */
exports.fromEither = fromEither;
const fromInput = input => unwrap(input.takeWith(core.failCause, elem => core.flatMap(core.write(elem), () => fromInput(input)), core.succeed));
/** @internal */
exports.fromInput = fromInput;
const fromPubSub = pubsub => unwrapScoped(Effect.map(PubSub.subscribe(pubsub), fromQueue));
/** @internal */
exports.fromPubSub = fromPubSub;
const fromPubSubScoped = pubsub => Effect.map(PubSub.subscribe(pubsub), fromQueue);
/** @internal */
exports.fromPubSubScoped = fromPubSubScoped;
const fromOption = option => core.suspend(() => Option.match(option, {
onNone: () => core.fail(Option.none()),
onSome: core.succeed
}));
/** @internal */
exports.fromOption = fromOption;
const fromQueue = queue => core.suspend(() => fromQueueInternal(queue));
/** @internal */
exports.fromQueue = fromQueue;
const fromQueueInternal = queue => (0, _Function.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 */
const identityChannel = () => core.readWith({
onInput: input => core.flatMap(core.write(input), () => identityChannel()),
onFailure: core.fail,
onDone: core.succeedNow
});
/** @internal */
exports.identityChannel = identityChannel;
const interruptWhen = exports.interruptWhen = /*#__PURE__*/(0, _Function.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 */
const interruptWhenDeferred = exports.interruptWhenDeferred = /*#__PURE__*/(0, _Function.dual)(2, (self, deferred) => interruptWhen(self, Deferred.await(deferred)));
/** @internal */
const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.flatMap(self, a => core.sync(() => f(a))));
/** @internal */
const mapEffect = exports.mapEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.flatMap(self, z => core.fromEffect(f(z))));
/** @internal */
const mapError = exports.mapError = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => mapErrorCause(self, Cause.map(f)));
/** @internal */
const mapErrorCause = exports.mapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.catchAllCause(self, cause => core.failCause(f(cause))));
/** @internal */
const mapOut = exports.mapOut = /*#__PURE__*/(0, _Function.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 */
const mapOutEffect = exports.mapOutEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
const reader = core.readWithCause({
onInput: outElem => (0, _Function.pipe)(core.fromEffect(f(outElem)), core.flatMap(core.write), core.flatMap(() => reader)),
onFailure: core.failCause,
onDone: core.succeedNow
});
return core.pipeTo(self, reader);
});
/** @internal */
const mapOutEffectPar = exports.mapOutEffectPar = /*#__PURE__*/(0, _Function.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 ? _ => _Function.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(_Function.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 */
const mergeAll = options => {
return channels => mergeAllWith(options)(channels, _Function.constVoid);
};
/** @internal */
exports.mergeAll = mergeAll;
const mergeAllUnbounded = channels => mergeAllWith({
concurrency: "unbounded"
})(channels, _Function.constVoid);
/** @internal */
exports.mergeAllUnbounded = mergeAllUnbounded;
const mergeAllUnboundedWith = (channels, f) => mergeAllWith({
concurrency: "unbounded"
})(channels, f);
/** @internal */
exports.mergeAllUnboundedWith = mergeAllUnboundedWith;
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(_Function.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(_Function.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 = (0, _Function.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 */
exports.mergeAllWith = mergeAllWith;
const mergeMap = exports.mergeMap = /*#__PURE__*/(0, _Function.dual)(3, (self, f, options) => mergeAll(options)(mapOut(self, f)));
/** @internal */
const mergeOut = exports.mergeOut = /*#__PURE__*/(0, _Function.dual)(2, (self, n) => mergeAll({
concurrency: n
})(mapOut(self, _Function.identity)));
/** @internal */
const mergeOutWith = exports.mergeOutWith = /*#__PURE__*/(0, _Function.dual)(3, (self, n, f) => mergeAllWith({
concurrency: n
})(mapOut(self, _Function.identity), f));
/** @internal */
const mergeWith = exports.mergeWith = /*#__PURE__*/(0, _Function.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 */
const never = exports.never = /*#__PURE__*/core.fromEffect(Effect.never);
/** @internal */
const orDie = exports.orDie = /*#__PURE__*/(0, _Function.dual)(2, (self, error) => orDieWith(self, error));
/** @internal */
const orDieWith = exports.orDieWith = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => catchAll(self, e => core.failCauseSync(() => Cause.die(f(e)))));
/** @internal */
const orElse = exports.orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => catchAll(self, that));
/** @internal */
const pipeToOrFail = exports.pipeToOrFail = /*#__PURE__*/(0, _Function.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 => (0, _Function.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 */
const provideService = exports.provideService = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, service) => {
return core.flatMap(context(), context => core.provideContext(self, Context.add(context, tag, service)));
});
/** @internal */
const provideLayer = exports.provideLayer = /*#__PURE__*/(0, _Function.dual)(2, (self, layer) => unwrapScopedWith(scope => Effect.map(Layer.buildWithScope(layer, scope), context => core.provideContext(self, context))));
/** @internal */
const mapInputContext = exports.mapInputContext = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => contextWithChannel(context => core.provideContext(self, f(context))));
/** @internal */
const provideSomeLayer = exports.provideSomeLayer = /*#__PURE__*/(0, _Function.dual)(2, (self, layer) =>
// @ts-expect-error
provideLayer(self, Layer.merge(Layer.context(), layer)));
/** @internal */
const read = () => core.readOrFail(Option.none());
/** @internal */
exports.read = read;
const repeated = self => core.flatMap(self, () => repeated(self));
/** @internal */
exports.repeated = repeated;
const run = self => Effect.scopedWith(scope => executor.runIn(self, scope));
/** @internal */
exports.run = run;
const runCollect = self => run(core.collectElements(self));
/** @internal */
exports.runCollect = runCollect;
const runDrain = self => run(drain(self));
/** @internal */
exports.runDrain = runDrain;
const runScoped = self => Effect.scopeWith(scope => executor.runIn(self, scope));
/** @internal */
exports.runScoped = runScoped;
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 */
exports.scoped = scoped;
const scopedWith = f => unwrapScoped(Effect.map(Effect.scope, scope => core.flatMap(core.fromEffect(f(scope)), core.write)));
/** @internal */
exports.scopedWith = scopedWith;
const service = tag => core.fromEffect(tag);
/** @internal */
exports.service = service;
const serviceWith = tag => f => map(service(tag), f);
/** @internal */
exports.serviceWith = serviceWith;
const serviceWithChannel = tag => f => core.flatMap(service(tag), f);
/** @internal */
exports.serviceWithChannel = serviceWithChannel;
const serviceWithEffect = tag => f => mapEffect(service(tag), f);
/** @internal */
exports.serviceWithEffect = serviceWithEffect;
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 */
exports.splitLines = splitLines;
const toPubSub = pubsub => toQueue(pubsub);
/** @internal */
exports.toPubSub = toPubSub;
const toPull = self => Effect.flatMap(Effect.scope, scope => toPullIn(self, scope));
/** @internal */
exports.toPull = toPull;
const toPullIn = exports.toPullIn = /*#__PURE__*/(0, _Function.dual)(2, (self, scope) => Effect.zip(Effect.sync(() => new executor.ChannelExecutor(self, void 0, _Function.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 (0, _Function.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 */
const toQueue = queue => core.suspend(() => toQueueInternal(queue));
/** @internal */
exports.toQueue = toQueue;
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 */
const unwrap = channel => flatten(core.fromEffect(channel));
/** @internal */
exports.unwrap = unwrap;
const unwrapScoped = self => core.concatAllWith(scoped(self), (d, _) => d, (d, _) => d);
/** @internal */
exports.unwrapScoped = unwrapScoped;
const unwrapScopedWith = f => core.concatAllWith(scopedWith(f), (d, _) => d, (d, _) => d);
/** @internal */
exports.unwrapScopedWith = unwrapScopedWith;
const updateService = exports.updateService = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, f) => mapInputContext(self, context => Context.merge(context, Context.make(tag, f(Context.unsafeGet(context, tag))))));
/** @internal */
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 */
exports.withSpan = withSpan;
const writeAll = (...outs) => writeChunk(Chunk.fromIterable(outs));
/** @internal */
exports.writeAll = writeAll;
const writeChunk = outs => writeChunkWriter(0, outs.length, outs);
/** @internal */
exports.writeChunk = writeChunk;
const writeChunkWriter = (idx, len, chunk) => {
return idx === len ? core.void : (0, _Function.pipe)(core.write((0, _Function.pipe)(chunk, Chunk.unsafeGet(idx))), core.flatMap(() => writeChunkWriter(idx + 1, len, chunk)));
};
/** @internal */
const zip = exports.zip = /*#__PURE__*/(0, _Function.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 */
const zipLeft = exports.zipLeft = /*#__PURE__*/(0, _Function.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 */
const zipRight = exports.zipRight = /*#__PURE__*/(0, _Function.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 */
const ChannelExceptionTypeId = exports.ChannelExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Channel/ChannelException");
/** @internal */
const ChannelException = error => ({
_tag: "ChannelException",
[ChannelExceptionTypeId]: ChannelExceptionTypeId,
error
});
/** @internal */
exports.ChannelException = ChannelException;
const isChannelException = u => (0, _Predicate.hasProperty)(u, ChannelExceptionTypeId);
exports.isChannelException = isChannelException;
//# sourceMappingURL=channel.js.map

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"mergeState.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MergeStateSymbolKey","MergeStateTypeId","exports","Symbol","for","proto","BothRunning","left","right","op","create","_tag","OP_BOTH_RUNNING","LeftDone","OP_LEFT_DONE","RightDone","OP_RIGHT_DONE","isMergeState","u","hasProperty","isBothRunning","self","isLeftDone","isRightDone","match","dual","onBothRunning","onLeftDone","onRightDone"],"sources":["../../../../src/internal/channel/mergeState.ts"],"sourcesContent":[null],"mappings":";;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA0D,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAE1D;AACA,MAAMkB,mBAAmB,GAAG,0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OAAOA,IAAI,CAACV,IAAI,KAAKhC,OAAO,CAACiC,eAAe;AAC9C,CAAC;AAED;AAAAV,OAAA,CAAAkB,aAAA,GAAAA,aAAA;AACO,MAAME,UAAU,GACrBD,IAA2E,IACI;EAC/E,OAAOA,IAAI,CAACV,IAAI,KAAKhC,OAAO,CAACmC,YAAY;AAC3C,CAAC;AAED;AAAAZ,OAAA,CAAAoB,UAAA,GAAAA,UAAA;AACO,MAAMC,WAAW,GACtBF,IAA2E,IACK;EAChF,OAAOA,IAAI,CAACV,IAAI,KAAKhC,OAAO,CAACqC,aAAa;AAC5C,CAAC;AAED;AAAAd,OAAA,CAAAqB,WAAA,GAAAA,WAAA;AACO,MAAMC,KAAK,GAAAtB,OAAA,CAAAsB,KAAA,gBAAG,IAAAC,cAAI,EAsBvB,CAAC,EAAE,CACHJ,IAAI,EACJ;EAAEK,aAAa;EAAEC,UAAU;EAAEC;AAAW,CAAE,KACxC;EACF,QAAQP,IAAI,CAACV,IAAI;IACf,KAAKhC,OAAO,CAACiC,eAAe;MAAE;QAC5B,OAAOc,aAAa,CAACL,IAAI,CAACd,IAAI,EAAEc,IAAI,CAACb,KAAK,CAAC;MAC7C;IACA,KAAK7B,OAAO,CAACmC,YAAY;MAAE;QACzB,OAAOa,UAAU,CAACN,IAAI,CAAChC,CAAC,CAAC;MAC3B;IACA,KAAKV,OAAO,CAACqC,aAAa;MAAE;QAC1B,OAAOY,WAAW,CAACP,IAAI,CAAChC,CAAC,CAAC;MAC5B;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"upstreamPullStrategy.js","names":["_Function","require","_Predicate","OpCodes","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UpstreamPullStrategySymbolKey","UpstreamPullStrategyTypeId","exports","Symbol","for","upstreamPullStrategyVariance","_A","_","proto","PullAfterNext","emitSeparator","op","create","_tag","OP_PULL_AFTER_NEXT","PullAfterAllEnqueued","OP_PULL_AFTER_ALL_ENQUEUED","isUpstreamPullStrategy","u","hasProperty","isPullAfterNext","self","isPullAfterAllEnqueued","match","dual","onAllEnqueued","onNext"],"sources":["../../../../src/internal/channel/upstreamPullStrategy.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAE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E;QAC/B,OAAOY,MAAM,CAACL,IAAI,CAACX,aAAa,CAAC;MACnC;IACA,KAAK/B,OAAO,CAACqC,0BAA0B;MAAE;QACvC,OAAOS,aAAa,CAACJ,IAAI,CAACX,aAAa,CAAC;MAC1C;EACF;AACF,CAAC,CAAC","ignoreList":[]}

85
backend/node_modules/effect/dist/cjs/internal/clock.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.make = exports.globalClockScheduler = exports.clockTag = exports.MAX_TIMER_MILLIS = exports.ClockTypeId = void 0;
var Context = _interopRequireWildcard(require("../Context.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var _Function = require("../Function.js");
var core = _interopRequireWildcard(require("./core.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ClockSymbolKey = "effect/Clock";
/** @internal */
const ClockTypeId = exports.ClockTypeId = /*#__PURE__*/Symbol.for(ClockSymbolKey);
/** @internal */
const clockTag = exports.clockTag = /*#__PURE__*/Context.GenericTag("effect/Clock");
/** @internal */
const MAX_TIMER_MILLIS = exports.MAX_TIMER_MILLIS = 2 ** 31 - 1;
/** @internal */
const globalClockScheduler = exports.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 _Function.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 */
const make = () => new ClockImpl();
exports.make = make;
//# sourceMappingURL=clock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"clock.js","names":["Context","_interopRequireWildcard","require","Duration","_Function","core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ClockSymbolKey","ClockTypeId","exports","Symbol","for","clockTag","GenericTag","MAX_TIMER_MILLIS","globalClockScheduler","unsafeSchedule","task","duration","millis","toMillis","constFalse","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":";;;;;;AACA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,uBAAA,CAAAC,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAAiC,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,C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AAM,IAAI;MACjC,MAAMC,QAAQ,GAAGrC,oBAAoB,CAACC,cAAc,CAAC,MAAMmC,MAAM,CAAChE,IAAI,CAACkE,IAAI,CAAC,EAAEnC,QAAQ,CAAC;MACvF,OAAO/B,IAAI,CAACmE,MAAM,CAACnE,IAAI,CAAC0D,IAAI,CAACO,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC;EACJ;;AAGF;AACO,MAAMG,IAAI,GAAGA,CAAA,KAAmB,IAAId,SAAS,EAAE;AAAAhC,OAAA,CAAA8C,IAAA,GAAAA,IAAA","ignoreList":[]}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.currentRequestMap = void 0;
var _GlobalValue = require("../GlobalValue.js");
var _core = require("./core.js");
/** @internal */
const currentRequestMap = exports.currentRequestMap = /*#__PURE__*/(0, _GlobalValue.globalValue)(/*#__PURE__*/Symbol.for("effect/FiberRef/currentRequestMap"), () => (0, _core.fiberRefUnsafeMake)(new Map()));
//# sourceMappingURL=completedRequestMap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"completedRequestMap.js","names":["_GlobalValue","require","_core","currentRequestMap","exports","globalValue","Symbol","for","fiberRefUnsafeMake","Map"],"sources":["../../../src/internal/completedRequestMap.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA;AACO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,gBAAG,IAAAE,wBAAW,eAC1CC,MAAM,CAACC,GAAG,CAAC,mCAAmC,CAAC,EAC/C,MAAM,IAAAC,wBAAkB,EAAC,IAAIC,GAAG,EAA2B,CAAC,CAC7D","ignoreList":[]}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.matchSimple = exports.match = void 0;
var core = _interopRequireWildcard(require("./core.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const 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 */
exports.match = match;
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();
}
};
exports.matchSimple = matchSimple;
//# sourceMappingURL=concurrency.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"concurrency.js","names":["core","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","match","concurrency","sequential","unbounded","bounded","undefined","fiberRefGetWith","currentConcurrency","exports","matchSimple","concurrent"],"sources":["../../../src/internal/concurrency.ts"],"sourcesContent":[null],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiC,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAA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U,EAAE,CACjB;IACH;MACE,OAAOD,WAAW,GAAG,CAAC,GAAGG,OAAO,CAACH,WAAW,CAAC,GAAGC,UAAU,EAAE;EAChE;AACF,CAAC;AAED;AAAAM,OAAA,CAAAR,KAAA,GAAAA,KAAA;AACO,MAAMS,WAAW,GAAGA,CACzBR,WAAoC,EACpCC,UAAiC,EACjCQ,UAAiC,KACd;EACnB,QAAQT,WAAW;IACjB,KAAKI,SAAS;MACZ,OAAOH,UAAU,EAAE;IACrB,KAAK,WAAW;MACd,OAAOQ,UAAU,EAAE;IACrB,KAAK,SAAS;MACZ,OAAOhC,IAAI,CAAC4B,eAAe,CACzB5B,IAAI,CAAC6B,kBAAkB,EACtBN,WAAW,IACVA,WAAW,KAAK,WAAW,IAAIA,WAAW,GAAG,CAAC,GAC5CS,UAAU,EAAE,GACZR,UAAU,EAAE,CACjB;IACH;MACE,OAAOD,WAAW,GAAG,CAAC,GAAGS,UAAU,EAAE,GAAGR,UAAU,EAAE;EACxD;AACF,CAAC;AAAAM,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}

396
backend/node_modules/effect/dist/cjs/internal/config.js generated vendored Normal file
View File

@@ -0,0 +1,396 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zipWith = exports.zip = exports.withDescription = exports.withDefault = exports.validate = exports.url = exports.unwrap = exports.sync = exports.suspend = exports.succeed = exports.string = exports.secret = exports.repeat = exports.redacted = exports.primitive = exports.port = exports.orElseIf = exports.orElse = exports.option = exports.number = exports.nonEmptyString = exports.nested = exports.mapOrFail = exports.mapAttempt = exports.map = exports.logLevel = exports.literal = exports.isConfig = exports.integer = exports.hashSet = exports.hashMap = exports.fail = exports.duration = exports.date = exports.chunk = exports.branded = exports.boolean = exports.array = exports.all = exports.ConfigTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var ConfigError = _interopRequireWildcard(require("../ConfigError.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var _Function = require("../Function.js");
var HashSet = _interopRequireWildcard(require("../HashSet.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var _Predicate = require("../Predicate.js");
var configError = _interopRequireWildcard(require("./configError.js"));
var core = _interopRequireWildcard(require("./core.js"));
var defaultServices = _interopRequireWildcard(require("./defaultServices.js"));
var effectable = _interopRequireWildcard(require("./effectable.js"));
var OpCodes = _interopRequireWildcard(require("./opCodes/config.js"));
var redacted_ = _interopRequireWildcard(require("./redacted.js"));
var InternalSecret = _interopRequireWildcard(require("./secret.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const ConfigSymbolKey = "effect/Config";
/** @internal */
const ConfigTypeId = exports.ConfigTypeId = /*#__PURE__*/Symbol.for(ConfigSymbolKey);
const configVariance = {
/* c8 ignore next */
_A: _ => _
};
const proto = {
...effectable.CommitPrototype,
[ConfigTypeId]: configVariance,
commit() {
return defaultServices.config(this);
}
};
/** @internal */
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 */
exports.boolean = boolean;
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 */
exports.url = url;
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 */
exports.port = port;
const array = (config, name) => {
return (0, _Function.pipe)(chunk(config, name), map(Chunk.toArray));
};
/** @internal */
exports.array = array;
const chunk = (config, name) => {
return map(name === undefined ? repeat(config) : nested(repeat(config), name), Chunk.unsafeFromArray);
};
/** @internal */
exports.chunk = chunk;
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 */
exports.date = date;
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 */
exports.fail = fail;
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 */
exports.number = number;
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 */
exports.integer = integer;
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 */
exports.literal = literal;
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 */
exports.logLevel = logLevel;
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 */
exports.duration = duration;
const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => mapOrFail(self, a => Either.right(f(a))));
/** @internal */
const mapAttempt = exports.mapAttempt = /*#__PURE__*/(0, _Function.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 */
const mapOrFail = exports.mapOrFail = /*#__PURE__*/(0, _Function.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 */
const nested = exports.nested = /*#__PURE__*/(0, _Function.dual)(2, (self, name) => {
const nested = Object.create(proto);
nested._tag = OpCodes.OP_NESTED;
nested.name = name;
nested.config = self;
return nested;
});
/** @internal */
const orElse = exports.orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => {
const fallback = Object.create(proto);
fallback._tag = OpCodes.OP_FALLBACK;
fallback.first = self;
fallback.second = suspend(that);
fallback.condition = _Function.constTrue;
return fallback;
});
/** @internal */
const orElseIf = exports.orElseIf = /*#__PURE__*/(0, _Function.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 */
const option = self => {
return (0, _Function.pipe)(self, map(Option.some), orElseIf({
orElse: () => succeed(Option.none()),
if: ConfigError.isMissingDataOnly
}));
};
/** @internal */
exports.option = option;
const primitive = (description, parse) => {
const primitive = Object.create(proto);
primitive._tag = OpCodes.OP_PRIMITIVE;
primitive.description = description;
primitive.parse = parse;
return primitive;
};
/** @internal */
exports.primitive = primitive;
const repeat = self => {
const repeat = Object.create(proto);
repeat._tag = OpCodes.OP_SEQUENCE;
repeat.config = self;
return repeat;
};
/** @internal */
exports.repeat = repeat;
const secret = name => {
const config = primitive("a secret property", text => Either.right(InternalSecret.fromString(text)));
return name === undefined ? config : nested(config, name);
};
/** @internal */
exports.secret = secret;
const redacted = nameOrConfig => {
const config = isConfig(nameOrConfig) ? nameOrConfig : string(nameOrConfig);
return map(config, redacted_.make);
};
/** @internal */
exports.redacted = redacted;
const branded = exports.branded = /*#__PURE__*/(0, _Function.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 */
const hashSet = (config, name) => {
const newConfig = map(chunk(config), HashSet.fromIterable);
return name === undefined ? newConfig : nested(newConfig, name);
};
/** @internal */
exports.hashSet = hashSet;
const string = name => {
const config = primitive("a text property", Either.right);
return name === undefined ? config : nested(config, name);
};
/** @internal */
exports.string = string;
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 */
exports.nonEmptyString = nonEmptyString;
const all = arg => {
if (Array.isArray(arg)) {
return tuple(arg);
} else if (Symbol.iterator in arg) {
return tuple([...arg]);
}
return struct(arg);
};
exports.all = all;
const struct = r => {
const entries = Object.entries(r);
let result = (0, _Function.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 = (0, _Function.pipe)(result, zipWith(config, (record, value) => ({
...record,
[key]: value
})));
}
return result;
};
/** @internal */
const succeed = value => {
const constant = Object.create(proto);
constant._tag = OpCodes.OP_CONSTANT;
constant.value = value;
constant.parse = () => Either.right(value);
return constant;
};
/** @internal */
exports.succeed = succeed;
const suspend = config => {
const lazy = Object.create(proto);
lazy._tag = OpCodes.OP_LAZY;
lazy.config = config;
return lazy;
};
/** @internal */
exports.suspend = suspend;
const sync = value => {
return suspend(() => succeed(value()));
};
/** @internal */
exports.sync = sync;
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 */
exports.hashMap = hashMap;
const isConfig = u => (0, _Predicate.hasProperty)(u, ConfigTypeId);
/** @internal */
exports.isConfig = isConfig;
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 = (0, _Function.pipe)(result, zipWith(config, (tuple, value) => [...tuple, value]));
}
return result;
};
/**
* @internal
*/
const unwrap = wrapped => {
if (isConfig(wrapped)) {
return wrapped;
}
return struct(Object.fromEntries(Object.entries(wrapped).map(([k, a]) => [k, unwrap(a)])));
};
/** @internal */
exports.unwrap = unwrap;
const validate = exports.validate = /*#__PURE__*/(0, _Function.dual)(2, (self, {
message,
validation
}) => mapOrFail(self, a => {
if (validation(a)) {
return Either.right(a);
}
return Either.left(configError.InvalidData([], message));
}));
/** @internal */
const withDefault = exports.withDefault = /*#__PURE__*/(0, _Function.dual)(2, (self, def) => orElseIf(self, {
orElse: () => succeed(def),
if: ConfigError.isMissingDataOnly
}));
/** @internal */
const withDescription = exports.withDescription = /*#__PURE__*/(0, _Function.dual)(2, (self, description) => {
const described = Object.create(proto);
described._tag = OpCodes.OP_DESCRIBED;
described.config = self;
described.description = description;
return described;
});
/** @internal */
const zip = exports.zip = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zipWith(self, that, (a, b) => [a, b]));
/** @internal */
const zipWith = exports.zipWith = /*#__PURE__*/(0, _Function.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,284 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reduceWithContext = exports.proto = exports.prefixed = exports.isUnsupported = exports.isSourceUnavailable = exports.isOr = exports.isMissingDataOnly = exports.isMissingData = exports.isInvalidData = exports.isConfigError = exports.isAnd = exports.Unsupported = exports.SourceUnavailable = exports.Or = exports.MissingData = exports.InvalidData = exports.ConfigErrorTypeId = exports.And = void 0;
var RA = _interopRequireWildcard(require("../Array.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var _Function = require("../Function.js");
var _Predicate = require("../Predicate.js");
var OpCodes = _interopRequireWildcard(require("./opCodes/configError.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ConfigErrorSymbolKey = "effect/ConfigError";
/** @internal */
const ConfigErrorTypeId = exports.ConfigErrorTypeId = /*#__PURE__*/Symbol.for(ConfigErrorSymbolKey);
/** @internal */
const proto = exports.proto = {
_tag: "ConfigError",
[ConfigErrorTypeId]: ConfigErrorTypeId
};
/** @internal */
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 */
exports.And = And;
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 */
exports.Or = Or;
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 = (0, _Function.pipe)(this.path, RA.join(options.pathDelim));
return `(Invalid data at ${path}: "${this.message}")`;
}
});
return error;
};
/** @internal */
exports.InvalidData = InvalidData;
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 = (0, _Function.pipe)(this.path, RA.join(options.pathDelim));
return `(Missing data at ${path}: "${this.message}")`;
}
});
return error;
};
/** @internal */
exports.MissingData = MissingData;
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 = (0, _Function.pipe)(this.path, RA.join(options.pathDelim));
return `(Source unavailable at ${path}: "${this.message}")`;
}
});
return error;
};
/** @internal */
exports.SourceUnavailable = SourceUnavailable;
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 = (0, _Function.pipe)(this.path, RA.join(options.pathDelim));
return `(Unsupported operation at ${path}: "${this.message}")`;
}
});
return error;
};
/** @internal */
exports.Unsupported = Unsupported;
const isConfigError = u => (0, _Predicate.hasProperty)(u, ConfigErrorTypeId);
/** @internal */
exports.isConfigError = isConfigError;
const isAnd = self => self._op === OpCodes.OP_AND;
/** @internal */
exports.isAnd = isAnd;
const isOr = self => self._op === OpCodes.OP_OR;
/** @internal */
exports.isOr = isOr;
const isInvalidData = self => self._op === OpCodes.OP_INVALID_DATA;
/** @internal */
exports.isInvalidData = isInvalidData;
const isMissingData = self => self._op === OpCodes.OP_MISSING_DATA;
/** @internal */
exports.isMissingData = isMissingData;
const isSourceUnavailable = self => self._op === OpCodes.OP_SOURCE_UNAVAILABLE;
/** @internal */
exports.isSourceUnavailable = isSourceUnavailable;
const isUnsupported = self => self._op === OpCodes.OP_UNSUPPORTED;
/** @internal */
exports.isUnsupported = isUnsupported;
const prefixed = exports.prefixed = /*#__PURE__*/(0, _Function.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: _Function.constFalse,
missingDataCase: _Function.constTrue,
sourceUnavailableCase: _Function.constFalse,
unsupportedCase: _Function.constFalse
};
/** @internal */
const reduceWithContext = exports.reduceWithContext = /*#__PURE__*/(0, _Function.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 */
const isMissingDataOnly = self => reduceWithContext(self, void 0, IsMissingDataOnlyReducer);
exports.isMissingDataOnly = isMissingDataOnly;
//# sourceMappingURL=configError.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,443 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.within = exports.upperCase = exports.unnested = exports.snakeCase = exports.orElse = exports.nested = exports.mapInputPath = exports.makeFlat = exports.make = exports.lowerCase = exports.kebabCase = exports.fromMap = exports.fromJson = exports.fromFlat = exports.fromEnv = exports.constantCase = exports.configProviderTag = exports.FlatConfigProviderTypeId = exports.ConfigProviderTypeId = void 0;
var Arr = _interopRequireWildcard(require("../Array.js"));
var Context = _interopRequireWildcard(require("../Context.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var _Function = require("../Function.js");
var HashMap = _interopRequireWildcard(require("../HashMap.js"));
var HashSet = _interopRequireWildcard(require("../HashSet.js"));
var number = _interopRequireWildcard(require("../Number.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var _Pipeable = require("../Pipeable.js");
var Predicate = _interopRequireWildcard(require("../Predicate.js"));
var regexp = _interopRequireWildcard(require("../RegExp.js"));
var configError = _interopRequireWildcard(require("./configError.js"));
var pathPatch = _interopRequireWildcard(require("./configProvider/pathPatch.js"));
var core = _interopRequireWildcard(require("./core.js"));
var OpCodes = _interopRequireWildcard(require("./opCodes/config.js"));
var StringUtils = _interopRequireWildcard(require("./string-utils.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const concat = (l, r) => [...l, ...r];
/** @internal */
const ConfigProviderSymbolKey = "effect/ConfigProvider";
/** @internal */
const ConfigProviderTypeId = exports.ConfigProviderTypeId = /*#__PURE__*/Symbol.for(ConfigProviderSymbolKey);
/** @internal */
const configProviderTag = exports.configProviderTag = /*#__PURE__*/Context.GenericTag("effect/ConfigProvider");
/** @internal */
const FlatConfigProviderSymbolKey = "effect/ConfigProviderFlat";
/** @internal */
const FlatConfigProviderTypeId = exports.FlatConfigProviderTypeId = /*#__PURE__*/Symbol.for(FlatConfigProviderSymbolKey);
/** @internal */
const make = options => ({
[ConfigProviderTypeId]: ConfigProviderTypeId,
pipe() {
return (0, _Pipeable.pipeArguments)(this, arguments);
},
...options
});
/** @internal */
exports.make = make;
const makeFlat = options => ({
[FlatConfigProviderTypeId]: FlatConfigProviderTypeId,
patch: options.patch,
load: (path, config, split = true) => options.load(path, config, split),
enumerateChildren: options.enumerateChildren
});
/** @internal */
exports.makeFlat = makeFlat;
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 */
exports.fromFlat = fromFlat;
const fromEnv = options => {
const {
pathDelim,
seqDelim
} = Object.assign({}, {
pathDelim: "_",
seqDelim: ","
}, options);
const makePathString = path => (0, _Function.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 (0, _Function.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 = (0, _Function.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 */
exports.fromEnv = fromEnv;
const fromMap = (map, config) => {
const {
pathDelim,
seqDelim
} = Object.assign({
seqDelim: ",",
pathDelim: "."
}, config);
const makePathString = path => (0, _Function.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 (0, _Function.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 = (0, _Function.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
}));
};
exports.fromMap = fromMap;
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 (0, _Function.pipe)(core.suspend(() => fromFlatLoop(flat, prefix, op.first, split)), core.catchAll(error1 => {
if (op.condition(error1)) {
return (0, _Function.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(() => (0, _Function.pipe)(fromFlatLoop(flat, prefix, op.original, split), core.flatMap(core.forEachSequential(a => (0, _Function.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 (0, _Function.pipe)(pathPatch.patch(prefix, flat.patch), core.flatMap(prefix => (0, _Function.pipe)(flat.load(prefix, op, split), core.flatMap(values => {
if (values.length === 0) {
const name = (0, _Function.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 (0, _Function.pipe)(pathPatch.patch(prefix, flat.patch), core.flatMap(patchedPrefix => (0, _Function.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 (0, _Function.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(() => (0, _Function.pipe)(pathPatch.patch(prefix, flat.patch), core.flatMap(prefix => (0, _Function.pipe)(flat.enumerateChildren(prefix), core.flatMap(keys => {
return (0, _Function.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 (0, _Function.pipe)(transpose(matrix), Arr.map(values => HashMap.fromIterable(Arr.zip(Arr.fromIterable(keys), values))));
}));
})))));
}
case OpCodes.OP_ZIP_WITH:
{
return core.suspend(() => (0, _Function.pipe)(fromFlatLoop(flat, prefix, op.left, split), core.either, core.flatMap(left => (0, _Function.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 = (0, _Function.pipe)(prefix, Arr.join("."));
const fail = fromFlatLoopFail(prefix, path);
const [lefts, rights] = extend(fail, fail, (0, _Function.pipe)(left.right, Arr.map(Either.right)), (0, _Function.pipe)(right.right, Arr.map(Either.right)));
return (0, _Function.pipe)(lefts, Arr.zip(rights), core.forEachSequential(([left, right]) => (0, _Function.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 */
const mapInputPath = exports.mapInputPath = /*#__PURE__*/(0, _Function.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 */
const nested = exports.nested = /*#__PURE__*/(0, _Function.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 */
const unnested = exports.unnested = /*#__PURE__*/(0, _Function.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 */
const orElse = exports.orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => fromFlat(orElseFlat(self.flattened, () => that().flattened)));
const orElseFlat = (self, that) => makeFlat({
load: (path, config, split) => (0, _Function.pipe)(pathPatch.patch(path, self.patch), core.flatMap(patch => self.load(patch, config, split)), core.catchAll(error1 => (0, _Function.pipe)(core.sync(that), core.flatMap(that => (0, _Function.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 => (0, _Function.pipe)(pathPatch.patch(path, self.patch), core.flatMap(patch => self.enumerateChildren(patch)), core.either, core.flatMap(left => (0, _Function.pipe)(core.sync(that), core.flatMap(that => (0, _Function.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((0, _Function.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 */
const constantCase = self => mapInputPath(self, StringUtils.constantCase);
/** @internal */
exports.constantCase = constantCase;
const kebabCase = self => mapInputPath(self, StringUtils.kebabCase);
/** @internal */
exports.kebabCase = kebabCase;
const lowerCase = self => mapInputPath(self, StringUtils.lowerCase);
/** @internal */
exports.lowerCase = lowerCase;
const snakeCase = self => mapInputPath(self, StringUtils.snakeCase);
/** @internal */
exports.snakeCase = snakeCase;
const upperCase = self => mapInputPath(self, StringUtils.upperCase);
/** @internal */
exports.upperCase = upperCase;
const within = exports.within = /*#__PURE__*/(0, _Function.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 (0, _Function.pipe)(primitive.parse(text), core.mapBoth({
onFailure: configError.prefixed(path),
onSuccess: Arr.of
}));
}
return (0, _Function.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 => (0, _Function.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 (0, _Function.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 = (0, _Function.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 = (0, _Function.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 */
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
});
};
exports.fromJson = fromJson;
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unnested = exports.patch = exports.nested = exports.mapName = exports.empty = exports.andThen = void 0;
var RA = _interopRequireWildcard(require("../../Array.js"));
var Either = _interopRequireWildcard(require("../../Either.js"));
var _Function = require("../../Function.js");
var List = _interopRequireWildcard(require("../../List.js"));
var Option = _interopRequireWildcard(require("../../Option.js"));
var configError = _interopRequireWildcard(require("../configError.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const empty = exports.empty = {
_tag: "Empty"
};
/** @internal */
const andThen = exports.andThen = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => ({
_tag: "AndThen",
first: self,
second: that
}));
/** @internal */
const mapName = exports.mapName = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => andThen(self, {
_tag: "MapName",
f
}));
/** @internal */
const nested = exports.nested = /*#__PURE__*/(0, _Function.dual)(2, (self, name) => andThen(self, {
_tag: "Nested",
name
}));
/** @internal */
const unnested = exports.unnested = /*#__PURE__*/(0, _Function.dual)(2, (self, name) => andThen(self, {
_tag: "Unnested",
name
}));
/** @internal */
const patch = exports.patch = /*#__PURE__*/(0, _Function.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 = (0, _Function.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

View File

@@ -0,0 +1 @@
{"version":3,"file":"pathPatch.js","names":["RA","_interopRequireWildcard","require","Either","_Function","List","Option","configError","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","empty","exports","_tag","andThen","dual","self","that","first","second","mapName","nested","name","unnested","patch","path","input","of","output","isCons","head","tail","cons","map","prepend","containsName","pipe","contains","tailNonEmpty","left","MissingData","right"],"sources":["../../../../src/internal/configProvider/pathPatch.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAA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;QAAE;UACdL,KAAK,GAAGrC,IAAI,CAAC2C,IAAI,CAACR,KAAK,CAACN,KAAK,EAAE7B,IAAI,CAAC2C,IAAI,CAACR,KAAK,CAACL,MAAM,EAAEO,KAAK,CAACK,IAAI,CAAC,CAAC;UACnE;QACF;MACA,KAAK,SAAS;QAAE;UACdH,MAAM,GAAG5C,EAAE,CAACiD,GAAG,CAACL,MAAM,EAAEJ,KAAK,CAACxB,CAAC,CAAC;UAChC0B,KAAK,GAAGA,KAAK,CAACK,IAAI;UAClB;QACF;MACA,KAAK,QAAQ;QAAE;UACbH,MAAM,GAAG5C,EAAE,CAACkD,OAAO,CAACN,MAAM,EAAEJ,KAAK,CAACF,IAAI,CAAC;UACvCI,KAAK,GAAGA,KAAK,CAACK,IAAI;UAClB;QACF;MACA,KAAK,UAAU;QAAE;UACf,MAAMI,YAAY,GAAG,IAAAC,cAAI,EACvBpD,EAAE,CAAC8C,IAAI,CAACF,MAAM,CAAC,EACftC,MAAM,CAAC+C,QAAQ,CAACb,KAAK,CAACF,IAAI,CAAC,CAC5B;UACD,IAAIa,YAAY,EAAE;YAChBP,MAAM,GAAG5C,EAAE,CAACsD,YAAY,CAACV,MAAkC,CAAC;YAC5DF,KAAK,GAAGA,KAAK,CAACK,IAAI;UACpB,CAAC,MAAM;YACL,OAAO5C,MAAM,CAACoD,IAAI,CAAChD,WAAW,CAACiD,WAAW,CACxCZ,MAAM,EACN,YAAYJ,KAAK,CAACF,IAAI,2CAA2C,CAClE,CAAC;UACJ;UACA;QACF;IACF;EACF;EACA,OAAOnC,MAAM,CAACsD,KAAK,CAACb,MAAM,CAAC;AAC7B,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withTime = exports.withGroup = exports.withConsoleScoped = exports.withConsole = exports.warn = exports.trace = exports.timeLog = exports.time = exports.table = exports.setConsole = exports.log = exports.info = exports.group = exports.error = exports.dirxml = exports.dir = exports.debug = exports.countReset = exports.count = exports.consoleWith = exports.console = exports.clear = exports.assert = void 0;
var Context = _interopRequireWildcard(require("../Context.js"));
var _Function = require("../Function.js");
var core = _interopRequireWildcard(require("./core.js"));
var defaultServices = _interopRequireWildcard(require("./defaultServices.js"));
var defaultConsole = _interopRequireWildcard(require("./defaultServices/console.js"));
var fiberRuntime = _interopRequireWildcard(require("./fiberRuntime.js"));
var layer = _interopRequireWildcard(require("./layer.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const console = exports.console = /*#__PURE__*/core.map(/*#__PURE__*/core.fiberRefGet(defaultServices.currentServices), /*#__PURE__*/Context.get(defaultConsole.consoleTag));
/** @internal */
const consoleWith = f => core.fiberRefGetWith(defaultServices.currentServices, services => f(Context.get(services, defaultConsole.consoleTag)));
/** @internal */
exports.consoleWith = consoleWith;
const withConsole = exports.withConsole = /*#__PURE__*/(0, _Function.dual)(2, (effect, value) => core.fiberRefLocallyWith(effect, defaultServices.currentServices, Context.add(defaultConsole.consoleTag, value)));
/** @internal */
const withConsoleScoped = console => fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(defaultConsole.consoleTag, console));
/** @internal */
exports.withConsoleScoped = withConsoleScoped;
const setConsole = console => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(defaultConsole.consoleTag, console)));
/** @internal */
exports.setConsole = setConsole;
const assert = (condition, ...args) => consoleWith(_ => _.assert(condition, ...args));
/** @internal */
exports.assert = assert;
const clear = exports.clear = /*#__PURE__*/consoleWith(_ => _.clear);
/** @internal */
const count = label => consoleWith(_ => _.count(label));
/** @internal */
exports.count = count;
const countReset = label => consoleWith(_ => _.countReset(label));
/** @internal */
exports.countReset = countReset;
const debug = (...args) => consoleWith(_ => _.debug(...args));
/** @internal */
exports.debug = debug;
const dir = (item, options) => consoleWith(_ => _.dir(item, options));
/** @internal */
exports.dir = dir;
const dirxml = (...args) => consoleWith(_ => _.dirxml(...args));
/** @internal */
exports.dirxml = dirxml;
const error = (...args) => consoleWith(_ => _.error(...args));
/** @internal */
exports.error = error;
const group = options => consoleWith(_ => fiberRuntime.acquireRelease(_.group(options), () => _.groupEnd));
/** @internal */
exports.group = group;
const info = (...args) => consoleWith(_ => _.info(...args));
/** @internal */
exports.info = info;
const log = (...args) => consoleWith(_ => _.log(...args));
/** @internal */
exports.log = log;
const table = (tabularData, properties) => consoleWith(_ => _.table(tabularData, properties));
/** @internal */
exports.table = table;
const time = label => consoleWith(_ => fiberRuntime.acquireRelease(_.time(label), () => _.timeEnd(label)));
/** @internal */
exports.time = time;
const timeLog = (label, ...args) => consoleWith(_ => _.timeLog(label, ...args));
/** @internal */
exports.timeLog = timeLog;
const trace = (...args) => consoleWith(_ => _.trace(...args));
/** @internal */
exports.trace = trace;
const warn = (...args) => consoleWith(_ => _.warn(...args));
/** @internal */
exports.warn = warn;
const withGroup = exports.withGroup = /*#__PURE__*/(0, _Function.dual)(args => core.isEffect(args[0]), (self, options) => consoleWith(_ => core.acquireUseRelease(_.group(options), () => self, () => _.groupEnd)));
/** @internal */
const withTime = exports.withTime = /*#__PURE__*/(0, _Function.dual)(args => core.isEffect(args[0]), (self, label) => consoleWith(_ => core.acquireUseRelease(_.time(label), () => self, () => _.timeEnd(label))));
//# sourceMappingURL=console.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,273 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unsafeGetReference = exports.unsafeGet = exports.pick = exports.omit = exports.mergeAll = exports.merge = exports.makeGenericTag = exports.makeContext = exports.make = exports.isTag = exports.isReference = exports.isContext = exports.getOrElse = exports.getOption = exports.get = exports.empty = exports.add = exports.TypeId = exports.TagTypeId = exports.TagProto = exports.Tag = exports.STMTypeId = exports.ReferenceTypeId = exports.ReferenceProto = exports.Reference = exports.ContextProto = void 0;
var Equal = _interopRequireWildcard(require("../Equal.js"));
var _Function = require("../Function.js");
var _GlobalValue = require("../GlobalValue.js");
var Hash = _interopRequireWildcard(require("../Hash.js"));
var _Inspectable = require("../Inspectable.js");
var _Pipeable = require("../Pipeable.js");
var _Predicate = require("../Predicate.js");
var _effectable = require("./effectable.js");
var option = _interopRequireWildcard(require("./option.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const TagTypeId = exports.TagTypeId = /*#__PURE__*/Symbol.for("effect/Context/Tag");
/** @internal */
const ReferenceTypeId = exports.ReferenceTypeId = /*#__PURE__*/Symbol.for("effect/Context/Reference");
/** @internal */
const STMSymbolKey = "effect/STM";
/** @internal */
const STMTypeId = exports.STMTypeId = /*#__PURE__*/Symbol.for(STMSymbolKey);
/** @internal */
const TagProto = exports.TagProto = {
..._effectable.EffectPrototype,
_op: "Tag",
[STMTypeId]: _effectable.effectVariance,
[TagTypeId]: {
_Service: _ => _,
_Identifier: _ => _
},
toString() {
return (0, _Inspectable.format)(this.toJSON());
},
toJSON() {
return {
_id: "Tag",
key: this.key,
stack: this.stack
};
},
[_Inspectable.NodeInspectSymbol]() {
return this.toJSON();
},
of(self) {
return self;
},
context(self) {
return make(this, self);
}
};
const ReferenceProto = exports.ReferenceProto = {
...TagProto,
[ReferenceTypeId]: ReferenceTypeId
};
/** @internal */
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 */
exports.makeGenericTag = makeGenericTag;
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 */
exports.Tag = Tag;
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 */
exports.Reference = Reference;
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("effect/Context");
/** @internal */
const ContextProto = exports.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 (0, _Pipeable.pipeArguments)(this, arguments);
},
toString() {
return (0, _Inspectable.format)(this.toJSON());
},
toJSON() {
return {
_id: "Context",
services: Array.from(this.unsafeMap).map(_Inspectable.toJSON)
};
},
[_Inspectable.NodeInspectSymbol]() {
return this.toJSON();
}
};
/** @internal */
const makeContext = unsafeMap => {
const context = Object.create(ContextProto);
context.unsafeMap = unsafeMap;
return context;
};
exports.makeContext = makeContext;
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 */
const isContext = u => (0, _Predicate.hasProperty)(u, TypeId);
/** @internal */
exports.isContext = isContext;
const isTag = u => (0, _Predicate.hasProperty)(u, TagTypeId);
/** @internal */
exports.isTag = isTag;
const isReference = u => (0, _Predicate.hasProperty)(u, ReferenceTypeId);
exports.isReference = isReference;
const _empty = /*#__PURE__*/makeContext(/*#__PURE__*/new Map());
/** @internal */
const empty = () => _empty;
/** @internal */
exports.empty = empty;
const make = (tag, service) => makeContext(new Map([[tag.key, service]]));
/** @internal */
exports.make = make;
const add = exports.add = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, service) => {
const map = new Map(self.unsafeMap);
map.set(tag.key, service);
return makeContext(map);
});
const defaultValueCache = /*#__PURE__*/(0, _GlobalValue.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 */
const unsafeGetReference = (self, tag) => {
return self.unsafeMap.has(tag.key) ? self.unsafeMap.get(tag.key) : getDefaultValue(tag);
};
/** @internal */
exports.unsafeGetReference = unsafeGetReference;
const unsafeGet = exports.unsafeGet = /*#__PURE__*/(0, _Function.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 */
const get = exports.get = unsafeGet;
/** @internal */
const getOrElse = exports.getOrElse = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, orElse) => {
if (!self.unsafeMap.has(tag.key)) {
return isReference(tag) ? getDefaultValue(tag) : orElse();
}
return self.unsafeMap.get(tag.key);
});
/** @internal */
const getOption = exports.getOption = /*#__PURE__*/(0, _Function.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 */
const merge = exports.merge = /*#__PURE__*/(0, _Function.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 */
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 */
exports.mergeAll = mergeAll;
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 */
exports.pick = pick;
const omit = (...tags) => self => {
const newEnv = new Map(self.unsafeMap);
for (const tag of tags) {
newEnv.delete(tag.key);
}
return makeContext(newEnv);
};
exports.omit = omit;
//# sourceMappingURL=context.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,872 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.spanLinks = exports.spanAnnotations = exports.sleep = exports.setFiberRefs = exports.serviceOptional = exports.serviceOption = exports.serviceMembers = exports.serviceFunctions = exports.serviceFunctionEffect = exports.serviceFunction = exports.serviceConstants = exports.sandbox = exports.repeatN = exports.reduceWhile = exports.reduceRight = exports.reduce = exports.random = exports.provideServiceEffect = exports.provideService = exports.promise = exports.patchFiberRefs = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.optionFromOptional = exports.option = exports.once = exports.none = exports.negate = exports.merge = exports.memoize = exports.match = exports.mapErrorCause = exports.mapAccum = exports.makeSpan = exports.loop = exports.logWithLevel = exports.logWarning = exports.logTrace = exports.logInfo = exports.logFatal = exports.logError = exports.logDebug = exports.logAnnotations = exports.log = exports.linkSpans = exports.linkSpanCurrent = exports.liftPredicate = exports.let_ = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.head = exports.functionWithSpan = exports.fromNullable = exports.forever = exports.flipWith = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.fiberRefs = exports.every = exports.eventually = exports.endSpan = exports.dropWhile = exports.dropUntil = exports.diffFiberRefsAndRuntimeFlags = exports.diffFiberRefs = exports.descriptorWith = exports.descriptor = exports.delay = exports.currentSpan = exports.currentParentSpan = exports.contextWith = exports.clockWith = exports.clock = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchAllDefect = exports.bindTo = exports.bind = exports.asSomeError = exports.asSome = exports.annotateSpans = exports.annotateLogs = exports.annotateCurrentSpan = exports.allowInterrupt = exports._catch = exports.Do = void 0;
exports.withSpan = exports.withParentSpan = exports.withMetric = exports.withLogSpan = exports.whenRef = exports.whenFiberRef = exports.when = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unsafeMakeSpan = exports.unlessEffect = exports.unless = exports.try_ = exports.tryPromise = exports.tryMapPromise = exports.tryMap = exports.tracerWith = exports.tracer = exports.timedWith = exports.timed = exports.tapErrorTag = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.takeWhile = exports.takeUntil = exports.tagMetrics = exports.summarized = exports.succeedSome = exports.succeedNone = void 0;
var Arr = _interopRequireWildcard(require("../Array.js"));
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Clock = _interopRequireWildcard(require("../Clock.js"));
var Context = _interopRequireWildcard(require("../Context.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var FiberRefs = _interopRequireWildcard(require("../FiberRefs.js"));
var _Function = require("../Function.js");
var HashMap = _interopRequireWildcard(require("../HashMap.js"));
var HashSet = _interopRequireWildcard(require("../HashSet.js"));
var List = _interopRequireWildcard(require("../List.js"));
var LogLevel = _interopRequireWildcard(require("../LogLevel.js"));
var LogSpan = _interopRequireWildcard(require("../LogSpan.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var Predicate = _interopRequireWildcard(require("../Predicate.js"));
var Ref = _interopRequireWildcard(require("../Ref.js"));
var Tracer = _interopRequireWildcard(require("../Tracer.js"));
var _Utils = require("../Utils.js");
var internalCause = _interopRequireWildcard(require("./cause.js"));
var _clock = require("./clock.js");
var core = _interopRequireWildcard(require("./core.js"));
var defaultServices = _interopRequireWildcard(require("./defaultServices.js"));
var doNotation = _interopRequireWildcard(require("./doNotation.js"));
var fiberRefsPatch = _interopRequireWildcard(require("./fiberRefs/patch.js"));
var metricLabel = _interopRequireWildcard(require("./metric/label.js"));
var runtimeFlags = _interopRequireWildcard(require("./runtimeFlags.js"));
var internalTracer = _interopRequireWildcard(require("./tracer.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/* @internal */
const annotateLogs = exports.annotateLogs = /*#__PURE__*/(0, _Function.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 */
const asSome = self => core.map(self, Option.some);
/* @internal */
exports.asSome = asSome;
const asSomeError = self => core.mapError(self, Option.some);
/* @internal */
exports.asSomeError = asSomeError;
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((0, _Utils.internalCall)(evaluate));
} catch (error) {
return core.fail(onFailure ? (0, _Utils.internalCall)(() => onFailure(error)) : new core.UnknownException(error, "An unknown error occurred in Effect.try"));
}
});
};
/* @internal */
exports.try_ = try_;
const _catch = exports._catch = /*#__PURE__*/(0, _Function.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 */
const catchAllDefect = exports.catchAllDefect = /*#__PURE__*/(0, _Function.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 */
const catchSomeCause = exports.catchSomeCause = /*#__PURE__*/(0, _Function.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 */
const catchSomeDefect = exports.catchSomeDefect = /*#__PURE__*/(0, _Function.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 */
const catchTag = exports.catchTag = /*#__PURE__*/(0, _Function.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 */
const catchTags = exports.catchTags = /*#__PURE__*/(0, _Function.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 */
const cause = self => core.matchCause(self, {
onFailure: _Function.identity,
onSuccess: () => internalCause.empty
});
/* @internal */
exports.cause = cause;
const clockWith = exports.clockWith = Clock.clockWith;
/* @internal */
const clock = exports.clock = /*#__PURE__*/clockWith(core.succeed);
/* @internal */
const delay = exports.delay = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => core.zipRight(Clock.sleep(duration), self));
/* @internal */
const descriptorWith = f => core.withFiberRuntime((state, status) => f({
id: state.id(),
status,
interruptors: internalCause.interruptors(state.getFiberRef(core.currentInterruptedCause))
}));
/* @internal */
exports.descriptorWith = descriptorWith;
const allowInterrupt = exports.allowInterrupt = /*#__PURE__*/descriptorWith(descriptor => HashSet.size(descriptor.interruptors) > 0 ? core.interrupt : core.void);
/* @internal */
const descriptor = exports.descriptor = /*#__PURE__*/descriptorWith(core.succeed);
/* @internal */
const diffFiberRefs = self => summarized(self, fiberRefs, fiberRefsPatch.diff);
/* @internal */
exports.diffFiberRefs = diffFiberRefs;
const diffFiberRefsAndRuntimeFlags = self => summarized(self, core.zip(fiberRefs, core.runtimeFlags), ([refs, flags], [refsNew, flagsNew]) => [fiberRefsPatch.diff(refs, refsNew), runtimeFlags.diff(flags, flagsNew)]);
/* @internal */
exports.diffFiberRefsAndRuntimeFlags = diffFiberRefsAndRuntimeFlags;
const Do = exports.Do = /*#__PURE__*/core.succeed({});
/* @internal */
const bind = exports.bind = /*#__PURE__*/doNotation.bind(core.map, core.flatMap);
/* @internal */
const bindTo = exports.bindTo = /*#__PURE__*/doNotation.bindTo(core.map);
/* @internal */
const let_ = exports.let_ = /*#__PURE__*/doNotation.let_(core.map);
/* @internal */
const dropUntil = exports.dropUntil = /*#__PURE__*/(0, _Function.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 */
const dropWhile = exports.dropWhile = /*#__PURE__*/(0, _Function.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 */
const contextWith = f => core.map(core.context(), f);
/* @internal */
exports.contextWith = contextWith;
const eventually = self => core.orElse(self, () => core.flatMap(core.yieldNow(), () => eventually(self)));
/* @internal */
exports.eventually = eventually;
const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (elements, pf) => core.map(core.forEachSequential(elements, _Function.identity), Arr.filterMap(pf)));
/* @internal */
const filterOrDie = exports.filterOrDie = /*#__PURE__*/(0, _Function.dual)(3, (self, predicate, orDieWith) => filterOrElse(self, predicate, a => core.dieSync(() => orDieWith(a))));
/* @internal */
const filterOrDieMessage = exports.filterOrDieMessage = /*#__PURE__*/(0, _Function.dual)(3, (self, predicate, message) => filterOrElse(self, predicate, () => core.dieMessage(message)));
/* @internal */
const filterOrElse = exports.filterOrElse = /*#__PURE__*/(0, _Function.dual)(3, (self, predicate, orElse) => core.flatMap(self, a => predicate(a) ? core.succeed(a) : orElse(a)));
/** @internal */
const liftPredicate = exports.liftPredicate = /*#__PURE__*/(0, _Function.dual)(3, (self, predicate, orFailWith) => core.suspend(() => predicate(self) ? core.succeed(self) : core.fail(orFailWith(self))));
/* @internal */
const filterOrFail = exports.filterOrFail = /*#__PURE__*/(0, _Function.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 */
const findFirst = exports.findFirst = /*#__PURE__*/(0, _Function.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 */
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 (0, _Function.pipe)(Chunk.tailNonEmpty(list), Arr.reduce(Chunk.headNonEmpty(list), (left, right) => core.orElse(left, () => right)));
});
/* @internal */
exports.firstSuccessOf = firstSuccessOf;
const flipWith = exports.flipWith = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.flip(f(core.flip(self))));
/* @internal */
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => core.matchEffect(self, {
onFailure: e => core.succeed(options.onFailure(e)),
onSuccess: a => core.succeed(options.onSuccess(a))
}));
/* @internal */
const every = exports.every = /*#__PURE__*/(0, _Function.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 */
const forever = self => {
const loop = core.flatMap(core.flatMap(self, () => core.yieldNow()), () => loop);
return loop;
};
/* @internal */
exports.forever = forever;
const fiberRefs = exports.fiberRefs = /*#__PURE__*/core.withFiberRuntime(state => core.succeed(state.getFiberRefs()));
/* @internal */
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 */
exports.head = head;
const ignore = self => match(self, {
onFailure: _Function.constVoid,
onSuccess: _Function.constVoid
});
/* @internal */
exports.ignore = ignore;
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 */
exports.ignoreLogged = ignoreLogged;
const inheritFiberRefs = childFiberRefs => updateFiberRefs((parentFiberId, parentFiberRefs) => FiberRefs.joinAs(parentFiberRefs, parentFiberId, childFiberRefs));
/* @internal */
exports.inheritFiberRefs = inheritFiberRefs;
const isFailure = self => match(self, {
onFailure: _Function.constTrue,
onSuccess: _Function.constFalse
});
/* @internal */
exports.isFailure = isFailure;
const isSuccess = self => match(self, {
onFailure: _Function.constFalse,
onSuccess: _Function.constTrue
});
/* @internal */
exports.isSuccess = isSuccess;
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 */
exports.iterate = iterate;
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 */
exports.logWithLevel = logWithLevel;
const log = exports.log = /*#__PURE__*/logWithLevel();
/** @internal */
const logTrace = exports.logTrace = /*#__PURE__*/logWithLevel(LogLevel.Trace);
/** @internal */
const logDebug = exports.logDebug = /*#__PURE__*/logWithLevel(LogLevel.Debug);
/** @internal */
const logInfo = exports.logInfo = /*#__PURE__*/logWithLevel(LogLevel.Info);
/** @internal */
const logWarning = exports.logWarning = /*#__PURE__*/logWithLevel(LogLevel.Warning);
/** @internal */
const logError = exports.logError = /*#__PURE__*/logWithLevel(LogLevel.Error);
/** @internal */
const logFatal = exports.logFatal = /*#__PURE__*/logWithLevel(LogLevel.Fatal);
/* @internal */
const withLogSpan = exports.withLogSpan = /*#__PURE__*/(0, _Function.dual)(2, (effect, label) => core.flatMap(Clock.currentTimeMillis, now => core.fiberRefLocallyWith(effect, core.currentLogSpan, List.prepend(LogSpan.make(label, now)))));
/* @internal */
const logAnnotations = exports.logAnnotations = /*#__PURE__*/core.fiberRefGet(core.currentLogAnnotations);
/* @internal */
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);
exports.loop = loop;
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 */
const mapAccum = exports.mapAccum = /*#__PURE__*/(0, _Function.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 */
const mapErrorCause = exports.mapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.matchCauseEffect(self, {
onFailure: c => core.failCauseSync(() => f(c)),
onSuccess: core.succeed
}));
/* @internal */
const memoize = self => (0, _Function.pipe)(core.deferredMake(), core.flatMap(deferred => (0, _Function.pipe)(diffFiberRefsAndRuntimeFlags(self), core.intoDeferred(deferred), once, core.map(complete => core.zipRight(complete, (0, _Function.pipe)(core.deferredAwait(deferred), core.flatMap(([patch, a]) => core.as(core.zip(patchFiberRefs(patch[0]), core.updateRuntimeFlags(patch[1])), a))))))));
/* @internal */
exports.memoize = memoize;
const merge = self => core.matchEffect(self, {
onFailure: e => core.succeed(e),
onSuccess: core.succeed
});
/* @internal */
exports.merge = merge;
const negate = self => core.map(self, b => !b);
/* @internal */
exports.negate = negate;
const none = self => core.flatMap(self, option => {
switch (option._tag) {
case "None":
return core.void;
case "Some":
return core.fail(new core.NoSuchElementException());
}
});
/* @internal */
exports.none = none;
const once = self => core.map(Ref.make(true), ref => core.asVoid(core.whenEffect(self, Ref.getAndSet(ref, false))));
/* @internal */
exports.once = once;
const option = self => core.matchEffect(self, {
onFailure: () => core.succeed(Option.none()),
onSuccess: a => core.succeed(Option.some(a))
});
/* @internal */
exports.option = option;
const orElseFail = exports.orElseFail = /*#__PURE__*/(0, _Function.dual)(2, (self, evaluate) => core.orElse(self, () => core.failSync(evaluate)));
/* @internal */
const orElseSucceed = exports.orElseSucceed = /*#__PURE__*/(0, _Function.dual)(2, (self, evaluate) => core.orElse(self, () => core.sync(evaluate)));
/* @internal */
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 */
exports.parallelErrors = parallelErrors;
const patchFiberRefs = patch => updateFiberRefs((fiberId, fiberRefs) => (0, _Function.pipe)(patch, fiberRefsPatch.patch(fiberId, fiberRefs)));
/* @internal */
exports.patchFiberRefs = patchFiberRefs;
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 */
exports.promise = promise;
const provideService = exports.provideService = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, service) => core.contextWithEffect(env => core.provideContext(self, Context.add(env, tag, service))));
/* @internal */
const provideServiceEffect = exports.provideServiceEffect = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, effect) => core.contextWithEffect(env => core.flatMap(effect, service => core.provideContext(self, (0, _Function.pipe)(env, Context.add(tag, service))))));
/* @internal */
const random = exports.random = /*#__PURE__*/defaultServices.randomWith(core.succeed);
/* @internal */
const reduce = exports.reduce = /*#__PURE__*/(0, _Function.dual)(3, (elements, zero, f) => Arr.fromIterable(elements).reduce((acc, el, i) => core.flatMap(acc, a => f(a, el, i)), core.succeed(zero)));
/* @internal */
const reduceRight = exports.reduceRight = /*#__PURE__*/(0, _Function.dual)(3, (elements, zero, f) => Arr.fromIterable(elements).reduceRight((acc, el, i) => core.flatMap(acc, a => f(el, a, i)), core.succeed(zero)));
/* @internal */
const reduceWhile = exports.reduceWhile = /*#__PURE__*/(0, _Function.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 */
const repeatN = exports.repeatN = /*#__PURE__*/(0, _Function.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 */
const sandbox = self => core.matchCauseEffect(self, {
onFailure: core.fail,
onSuccess: core.succeed
});
/* @internal */
exports.sandbox = sandbox;
const setFiberRefs = fiberRefs => core.suspend(() => FiberRefs.setAll(fiberRefs));
/* @internal */
exports.setFiberRefs = setFiberRefs;
const sleep = exports.sleep = Clock.sleep;
/* @internal */
const succeedNone = exports.succeedNone = /*#__PURE__*/core.succeed(/*#__PURE__*/Option.none());
/* @internal */
const succeedSome = value => core.succeed(Option.some(value));
/* @internal */
exports.succeedSome = succeedSome;
const summarized = exports.summarized = /*#__PURE__*/(0, _Function.dual)(3, (self, summary, f) => core.flatMap(summary, start => core.flatMap(self, value => core.map(summary, end => [f(start, end), value]))));
/* @internal */
const tagMetrics = exports.tagMetrics = /*#__PURE__*/(0, _Function.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 */
const labelMetrics = exports.labelMetrics = /*#__PURE__*/(0, _Function.dual)(2, (self, labels) => core.fiberRefLocallyWith(self, core.currentMetricLabels, old => Arr.union(old, labels)));
/* @internal */
const takeUntil = exports.takeUntil = /*#__PURE__*/(0, _Function.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 */
const takeWhile = exports.takeWhile = /*#__PURE__*/(0, _Function.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 => (0, _Function.pipe)(taking ? predicate(a, index) : core.succeed(false), core.map(bool => {
if (bool) {
builder.push(a);
}
return bool;
})));
}
return core.map(taking, () => builder);
}));
/* @internal */
const tapBoth = exports.tapBoth = /*#__PURE__*/(0, _Function.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 */
const tapDefect = exports.tapDefect = /*#__PURE__*/(0, _Function.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 */
const tapError = exports.tapError = /*#__PURE__*/(0, _Function.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 */
const tapErrorTag = exports.tapErrorTag = /*#__PURE__*/(0, _Function.dual)(3, (self, k, f) => tapError(self, e => {
if (Predicate.isTagged(e, k)) {
return f(e);
}
return core.void;
}));
/* @internal */
const tapErrorCause = exports.tapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.matchCauseEffect(self, {
onFailure: cause => core.zipRight(f(cause), core.failCause(cause)),
onSuccess: core.succeed
}));
/* @internal */
const timed = self => timedWith(self, Clock.currentTimeNanos);
/* @internal */
exports.timed = timed;
const timedWith = exports.timedWith = /*#__PURE__*/(0, _Function.dual)(2, (self, nanos) => summarized(self, nanos, (start, end) => Duration.nanos(end - start)));
/* @internal */
const tracerWith = exports.tracerWith = Tracer.tracerWith;
/** @internal */
const tracer = exports.tracer = /*#__PURE__*/tracerWith(core.succeed);
/* @internal */
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 */
exports.tryPromise = tryPromise;
const tryMap = exports.tryMap = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => core.flatMap(self, a => try_({
try: () => options.try(a),
catch: options.catch
})));
/* @internal */
const tryMapPromise = exports.tryMapPromise = /*#__PURE__*/(0, _Function.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 */
const unless = exports.unless = /*#__PURE__*/(0, _Function.dual)(2, (self, condition) => core.suspend(() => condition() ? succeedNone : asSome(self)));
/* @internal */
const unlessEffect = exports.unlessEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, condition) => core.flatMap(condition, b => b ? succeedNone : asSome(self)));
/* @internal */
const unsandbox = self => mapErrorCause(self, internalCause.flatten);
/* @internal */
exports.unsandbox = unsandbox;
const updateFiberRefs = f => core.withFiberRuntime(state => {
state.setFiberRefs(f(state.id(), state.getFiberRefs()));
return core.void;
});
/* @internal */
exports.updateFiberRefs = updateFiberRefs;
const updateService = exports.updateService = /*#__PURE__*/(0, _Function.dual)(3, (self, tag, f) => core.mapInputContext(self, context => Context.add(context, tag, f(Context.unsafeGet(context, tag)))));
/* @internal */
const when = exports.when = /*#__PURE__*/(0, _Function.dual)(2, (self, condition) => core.suspend(() => condition() ? core.map(self, Option.some) : core.succeed(Option.none())));
/* @internal */
const whenFiberRef = exports.whenFiberRef = /*#__PURE__*/(0, _Function.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 */
const whenRef = exports.whenRef = /*#__PURE__*/(0, _Function.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 */
const withMetric = exports.withMetric = /*#__PURE__*/(0, _Function.dual)(2, (self, metric) => metric(self));
/** @internal */
const serviceFunctionEffect = (getService, f) => (...args) => core.flatMap(getService, a => f(a)(...args));
/** @internal */
exports.serviceFunctionEffect = serviceFunctionEffect;
const serviceFunction = (getService, f) => (...args) => core.map(getService, a => f(a)(...args));
/** @internal */
exports.serviceFunction = serviceFunction;
const serviceFunctions = getService => new Proxy({}, {
get(_target, prop, _receiver) {
return (...args) => core.flatMap(getService, s => s[prop](...args));
}
});
/** @internal */
exports.serviceFunctions = serviceFunctions;
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 */
exports.serviceConstants = serviceConstants;
const serviceMembers = getService => ({
functions: serviceFunctions(getService),
constants: serviceConstants(getService)
});
/** @internal */
exports.serviceMembers = serviceMembers;
const serviceOption = tag => core.map(core.context(), Context.getOption(tag));
/** @internal */
exports.serviceOption = serviceOption;
const serviceOptional = tag => core.flatMap(core.context(), Context.getOption(tag));
// -----------------------------------------------------------------------------
// tracing
// -----------------------------------------------------------------------------
/* @internal */
exports.serviceOptional = serviceOptional;
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 */
exports.annotateCurrentSpan = annotateCurrentSpan;
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 */
exports.linkSpanCurrent = linkSpanCurrent;
const annotateSpans = exports.annotateSpans = /*#__PURE__*/(0, _Function.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 */
const currentParentSpan = exports.currentParentSpan = /*#__PURE__*/serviceOptional(internalTracer.spanTag);
/** @internal */
const currentSpan = exports.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 */
const linkSpans = exports.linkSpans = /*#__PURE__*/(0, _Function.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 */
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 */
exports.unsafeMakeSpan = unsafeMakeSpan;
const makeSpan = (name, options) => {
options = internalTracer.addSpanStackTrace(options);
return core.withFiberRuntime(fiber => core.succeed(unsafeMakeSpan(fiber, name, options)));
};
/* @internal */
exports.makeSpan = makeSpan;
const spanAnnotations = exports.spanAnnotations = /*#__PURE__*/core.fiberRefGet(core.currentTracerSpanAnnotations);
/* @internal */
const spanLinks = exports.spanLinks = /*#__PURE__*/core.fiberRefGet(core.currentTracerSpanLinks);
/** @internal */
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 */
exports.endSpan = endSpan;
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), _clock.clockTag);
return core.onExit(evaluate(span), exit => endSpan(span, exit, clock, timingEnabled));
});
};
/** @internal */
exports.useSpan = useSpan;
const withParentSpan = exports.withParentSpan = /*#__PURE__*/(0, _Function.dual)(2, (self, span) => provideService(self, internalTracer.spanTag, span));
/** @internal */
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));
};
exports.withSpan = withSpan;
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(() => (0, _Utils.internalCall)(() => options.body.apply(this, arguments))), opts.name, {
...opts,
captureStackTrace
});
});
};
// -------------------------------------------------------------------------------------
// optionality
// -------------------------------------------------------------------------------------
/* @internal */
exports.functionWithSpan = functionWithSpan;
const fromNullable = value => value == null ? core.fail(new core.NoSuchElementException()) : core.succeed(value);
/* @internal */
exports.fromNullable = fromNullable;
const optionFromOptional = self => core.catchAll(core.map(self, Option.some), error => core.isNoSuchElementException(error) ? succeedNone : core.fail(error));
exports.optionFromOptional = optionFromOptional;
//# sourceMappingURL=core-effect.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,258 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.write = exports.void = exports.sync = exports.suspend = exports.succeedNow = exports.succeed = exports.readWithCause = exports.readWith = exports.readOrFail = exports.provideContext = exports.pipeTo = exports.isChannel = exports.fromEffect = exports.foldCauseChannel = exports.flatMap = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.ensuringWith = exports.embedInput = exports.concatMapWithCustom = exports.concatMapWith = exports.concatAllWith = exports.concatAll = exports.collectElements = exports.catchAllCause = exports.acquireReleaseOut = exports.ChannelTypeId = void 0;
var Cause = _interopRequireWildcard(require("../Cause.js"));
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Effect = _interopRequireWildcard(require("../Effect.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var _Function = require("../Function.js");
var Option = _interopRequireWildcard(require("../Option.js"));
var _Pipeable = require("../Pipeable.js");
var _Predicate = require("../Predicate.js");
var childExecutorDecision = _interopRequireWildcard(require("./channel/childExecutorDecision.js"));
var _continuation = require("./channel/continuation.js");
var upstreamPullStrategy = _interopRequireWildcard(require("./channel/upstreamPullStrategy.js"));
var OpCodes = _interopRequireWildcard(require("./opCodes/channel.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ChannelSymbolKey = "effect/Channel";
/** @internal */
const ChannelTypeId = exports.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 (0, _Pipeable.pipeArguments)(this, arguments);
}
};
/** @internal */
const isChannel = u => (0, _Predicate.hasProperty)(u, ChannelTypeId) || Effect.isEffect(u);
/** @internal */
exports.isChannel = isChannel;
const acquireReleaseOut = exports.acquireReleaseOut = /*#__PURE__*/(0, _Function.dual)(2, (self, release) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_BRACKET_OUT;
op.acquire = () => self;
op.finalizer = release;
return op;
});
/** @internal */
const catchAllCause = exports.catchAllCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FOLD;
op.channel = self;
op.k = new _continuation.ContinuationKImpl(succeed, f);
return op;
});
/** @internal */
const collectElements = self => {
return suspend(() => {
const builder = [];
return flatMap(pipeTo(self, collectElementsReader(builder)), value => sync(() => [Chunk.fromIterable(builder), value]));
});
};
/** @internal */
exports.collectElements = collectElements;
const collectElementsReader = builder => readWith({
onInput: outElem => flatMap(sync(() => {
builder.push(outElem);
}), () => collectElementsReader(builder)),
onFailure: fail,
onDone: succeedNow
});
/** @internal */
const concatAll = channels => concatAllWith(channels, _Function.constVoid, _Function.constVoid);
/** @internal */
exports.concatAll = concatAll;
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 = _Function.identity;
return op;
};
/** @internal */
exports.concatAllWith = concatAllWith;
const concatMapWith = exports.concatMapWith = /*#__PURE__*/(0, _Function.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 */
const concatMapWithCustom = exports.concatMapWithCustom = /*#__PURE__*/(0, _Function.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 */
const embedInput = exports.embedInput = /*#__PURE__*/(0, _Function.dual)(2, (self, input) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_BRIDGE;
op.input = input;
op.channel = self;
return op;
});
/** @internal */
const ensuringWith = exports.ensuringWith = /*#__PURE__*/(0, _Function.dual)(2, (self, finalizer) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_ENSURING;
op.channel = self;
op.finalizer = finalizer;
return op;
});
/** @internal */
const fail = error => failCause(Cause.fail(error));
/** @internal */
exports.fail = fail;
const failSync = evaluate => failCauseSync(() => Cause.fail(evaluate()));
/** @internal */
exports.failSync = failSync;
const failCause = cause => failCauseSync(() => cause);
/** @internal */
exports.failCause = failCause;
const failCauseSync = evaluate => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FAIL;
op.error = evaluate;
return op;
};
/** @internal */
exports.failCauseSync = failCauseSync;
const flatMap = exports.flatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FOLD;
op.channel = self;
op.k = new _continuation.ContinuationKImpl(f, failCause);
return op;
});
/** @internal */
const foldCauseChannel = exports.foldCauseChannel = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FOLD;
op.channel = self;
op.k = new _continuation.ContinuationKImpl(options.onSuccess, options.onFailure);
return op;
});
/** @internal */
const fromEffect = effect => {
const op = Object.create(proto);
op._tag = OpCodes.OP_FROM_EFFECT;
op.effect = () => effect;
return op;
};
/** @internal */
exports.fromEffect = fromEffect;
const pipeTo = exports.pipeTo = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_PIPE_TO;
op.left = () => self;
op.right = () => that;
return op;
});
/** @internal */
const provideContext = exports.provideContext = /*#__PURE__*/(0, _Function.dual)(2, (self, env) => {
const op = Object.create(proto);
op._tag = OpCodes.OP_PROVIDE;
op.context = () => env;
op.inner = self;
return op;
});
/** @internal */
const readOrFail = error => {
const op = Object.create(proto);
op._tag = OpCodes.OP_READ;
op.more = succeed;
op.done = new _continuation.ContinuationKImpl(() => fail(error), () => fail(error));
return op;
};
/** @internal */
exports.readOrFail = readOrFail;
const readWith = options => readWithCause({
onInput: options.onInput,
onFailure: cause => Either.match(Cause.failureOrCause(cause), {
onLeft: options.onFailure,
onRight: failCause
}),
onDone: options.onDone
});
/** @internal */
exports.readWith = readWith;
const readWithCause = options => {
const op = Object.create(proto);
op._tag = OpCodes.OP_READ;
op.more = options.onInput;
op.done = new _continuation.ContinuationKImpl(options.onDone, options.onFailure);
return op;
};
/** @internal */
exports.readWithCause = readWithCause;
const succeed = value => sync(() => value);
/** @internal */
exports.succeed = succeed;
const succeedNow = result => {
const op = Object.create(proto);
op._tag = OpCodes.OP_SUCCEED_NOW;
op.terminal = result;
return op;
};
/** @internal */
exports.succeedNow = succeedNow;
const suspend = evaluate => {
const op = Object.create(proto);
op._tag = OpCodes.OP_SUSPEND;
op.channel = evaluate;
return op;
};
exports.suspend = suspend;
const sync = evaluate => {
const op = Object.create(proto);
op._tag = OpCodes.OP_SUCCEED;
op.evaluate = evaluate;
return op;
};
exports.sync = sync;
const void_ = exports.void = /*#__PURE__*/succeedNow(void 0);
/** @internal */
const write = out => {
const op = Object.create(proto);
op._tag = OpCodes.OP_EMIT;
op.out = out;
return op;
};
exports.write = write;
//# sourceMappingURL=core-stream.js.map

File diff suppressed because one or more lines are too long

1713
backend/node_modules/effect/dist/cjs/internal/core.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

37
backend/node_modules/effect/dist/cjs/internal/data.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.struct = exports.Structural = exports.ArrayProto = void 0;
var Equal = _interopRequireWildcard(require("../Equal.js"));
var Hash = _interopRequireWildcard(require("../Hash.js"));
var _effectable = require("./effectable.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ArrayProto = exports.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 */
const Structural = exports.Structural = /*#__PURE__*/function () {
function Structural(args) {
if (args) {
Object.assign(this, args);
}
}
Structural.prototype = _effectable.StructuralPrototype;
return Structural;
}();
/** @internal */
const struct = as => Object.assign(Object.create(_effectable.StructuralPrototype), as);
exports.struct = struct;
//# sourceMappingURL=data.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"data.js","names":["Equal","_interopRequireWildcard","require","Hash","_effectable","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ArrayProto","exports","assign","create","Array","prototype","symbol","cached","array","that","isArray","length","every","v","equals","Structural","args","StructuralPrototype","struct","as"],"sources":["../../../src/internal/data.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAAqD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CA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Ac,UAAA,gBAGZ;EACT,SAASA,UAAUA,CAAYC,IAAS;IACtC,IAAIA,IAAI,EAAE;MACRnB,MAAM,CAACK,MAAM,CAAC,IAAI,EAAEc,IAAI,CAAC;IAC3B;EACF;EACAD,UAAU,CAACV,SAAS,GAAGY,+BAAmB;EAC1C,OAAOF,UAAiB;AAC1B,CAAC,CAAC,CAAE;AAEJ;AACO,MAAMG,MAAM,GAA8CC,EAAM,IACrEtB,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,MAAM,CAACc,+BAAmB,CAAC,EAAEE,EAAE,CAAC;AAAAlB,OAAA,CAAAiB,MAAA,GAAAA,MAAA","ignoreList":[]}

View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.race = exports.provideContext = exports.never = exports.mapInputContext = exports.makeWithEntry = exports.makeBatched = exports.make = exports.fromFunctionBatched = exports.fromFunction = exports.fromEffectTagged = exports.fromEffect = exports.eitherWith = exports.batchN = exports.aroundRequests = exports.around = void 0;
var RA = _interopRequireWildcard(require("../Array.js"));
var Cause = _interopRequireWildcard(require("../Cause.js"));
var Chunk = _interopRequireWildcard(require("../Chunk.js"));
var Effect = _interopRequireWildcard(require("../Effect.js"));
var _Function = require("../Function.js");
var core = _interopRequireWildcard(require("./core.js"));
var _fiberRuntime = require("./fiberRuntime.js");
var _request = require("./request.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const make = runAll => new core.RequestResolverImpl(requests => runAll(requests.map(_ => _.map(_ => _.request))));
/** @internal */
exports.make = make;
const makeWithEntry = runAll => new core.RequestResolverImpl(requests => runAll(requests));
/** @internal */
exports.makeWithEntry = makeWithEntry;
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 (0, _fiberRuntime.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 */
exports.makeBatched = makeBatched;
const around = exports.around = /*#__PURE__*/(0, _Function.dual)(3, (self, before, after) => new core.RequestResolverImpl(requests => core.acquireUseRelease(before, () => self.runAll(requests), after), Chunk.make("Around", self, before, after)));
/** @internal */
const aroundRequests = exports.aroundRequests = /*#__PURE__*/(0, _Function.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 */
const batchN = exports.batchN = /*#__PURE__*/(0, _Function.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 */
const mapInputContext = exports.mapInputContext = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => new core.RequestResolverImpl(requests => core.mapInputContext(self.runAll(requests), context => f(context)), Chunk.make("MapInputContext", self, f)));
/** @internal */
const eitherWith = exports.eitherWith = /*#__PURE__*/(0, _Function.dual)(3, (self, that, f) => new core.RequestResolverImpl(batch => core.forEachSequential(batch, requests => {
const [as, bs] = (0, _Function.pipe)(requests, RA.partitionMap(f));
return (0, _fiberRuntime.zipWithOptions)(self.runAll(Array.of(as)), that.runAll(Array.of(bs)), () => void 0, {
concurrent: true
});
}), Chunk.make("EitherWith", self, that, f)));
/** @internal */
const fromFunction = f => makeBatched(requests => core.forEachSequentialDiscard(requests, request => (0, _request.complete)(request, core.exitSucceed(f(request))))).identified("FromFunction", f);
/** @internal */
exports.fromFunction = fromFunction;
const fromFunctionBatched = f => makeBatched(as => Effect.forEach(f(as), (res, i) => (0, _request.complete)(as[i], core.exitSucceed(res)), {
discard: true
})).identified("FromFunctionBatched", f);
/** @internal */
exports.fromFunctionBatched = fromFunctionBatched;
const fromEffect = f => makeBatched(requests => Effect.forEach(requests, a => Effect.flatMap(Effect.exit(f(a)), e => (0, _request.complete)(a, e)), {
concurrency: "unbounded",
discard: true
})).identified("FromEffect", f);
/** @internal */
exports.fromEffect = fromEffect;
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 => (0, _request.complete)(req, core.exitFail(cause)), {
discard: true
}),
onSuccess: res => Effect.forEach(grouped[tag], (req, i) => (0, _request.complete)(req, core.exitSucceed(res[i])), {
discard: true
})
}), {
concurrency: "unbounded",
discard: true
});
}).identified("FromEffectTagged", fns);
/** @internal */
exports.fromEffectTagged = fromEffectTagged;
const never = exports.never = /*#__PURE__*/make(() => Effect.never).identified("Never");
/** @internal */
const provideContext = exports.provideContext = /*#__PURE__*/(0, _Function.dual)(2, (self, context) => mapInputContext(self, _ => context).identified("ProvideContext", self, context));
/** @internal */
const race = exports.race = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => new core.RequestResolverImpl(requests => Effect.race(self.runAll(requests), that.runAll(requests))).identified("Race", self, that));
//# sourceMappingURL=dataSource.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,839 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zonedOffsetIso = exports.zonedOffset = exports.zoneUnsafeMakeNamed = exports.zoneToString = exports.zoneMakeOffset = exports.zoneMakeNamedEffect = exports.zoneMakeNamed = exports.zoneMakeLocal = exports.zoneFromString = exports.withDateUtc = exports.withDate = exports.unsafeSetZoneNamed = exports.unsafeNow = exports.unsafeMakeZoned = exports.unsafeMake = exports.unsafeIsPast = exports.unsafeIsFuture = exports.unsafeFromDate = exports.toUtc = exports.toPartsUtc = exports.toParts = exports.toEpochMillis = exports.toDateUtc = exports.toDate = exports.subtractDuration = exports.subtract = exports.startOf = exports.setZoneOffset = exports.setZoneNamed = exports.setZone = exports.setPartsUtc = exports.setParts = exports.removeTime = exports.nowAsDate = exports.now = exports.nearest = exports.mutateUtc = exports.mutate = exports.min = exports.max = exports.match = exports.mapEpochMillis = exports.makeZonedProto = exports.makeZonedFromString = exports.makeZoned = exports.make = exports.lessThanOrEqualTo = exports.lessThan = exports.isZoned = exports.isUtc = exports.isTimeZoneOffset = exports.isTimeZoneNamed = exports.isTimeZone = exports.isPast = exports.isFuture = exports.isDateTime = exports.greaterThanOrEqualTo = exports.greaterThan = exports.getPartUtc = exports.getPart = exports.formatUtc = exports.formatLocal = exports.formatIsoZoned = exports.formatIsoOffset = exports.formatIsoDateUtc = exports.formatIsoDate = exports.formatIso = exports.formatIntl = exports.format = exports.endOf = exports.distanceDurationEither = exports.distanceDuration = exports.distance = exports.clamp = exports.between = exports.addDuration = exports.add = exports.TypeId = exports.TimeZoneTypeId = exports.Order = exports.Equivalence = void 0;
var _Cause = require("../Cause.js");
var Clock = _interopRequireWildcard(require("../Clock.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var Either = _interopRequireWildcard(require("../Either.js"));
var Equal = _interopRequireWildcard(require("../Equal.js"));
var equivalence = _interopRequireWildcard(require("../Equivalence.js"));
var _Function = require("../Function.js");
var _GlobalValue = require("../GlobalValue.js");
var Hash = _interopRequireWildcard(require("../Hash.js"));
var Inspectable = _interopRequireWildcard(require("../Inspectable.js"));
var Option = _interopRequireWildcard(require("../Option.js"));
var order = _interopRequireWildcard(require("../Order.js"));
var _Pipeable = require("../Pipeable.js");
var Predicate = _interopRequireWildcard(require("../Predicate.js"));
var internalEffect = _interopRequireWildcard(require("./core-effect.js"));
var core = _interopRequireWildcard(require("./core.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("effect/DateTime");
/** @internal */
const TimeZoneTypeId = exports.TimeZoneTypeId = /*#__PURE__*/Symbol.for("effect/DateTime/TimeZone");
const Proto = {
[TypeId]: TypeId,
pipe() {
return (0, _Pipeable.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 (0, _Function.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 */
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 */
exports.makeZonedProto = makeZonedProto;
const isDateTime = u => Predicate.hasProperty(u, TypeId);
exports.isDateTime = isDateTime;
const isDateTimeArgs = args => isDateTime(args[0]);
/** @internal */
const isTimeZone = u => Predicate.hasProperty(u, TimeZoneTypeId);
/** @internal */
exports.isTimeZone = isTimeZone;
const isTimeZoneOffset = u => isTimeZone(u) && u._tag === "Offset";
/** @internal */
exports.isTimeZoneOffset = isTimeZoneOffset;
const isTimeZoneNamed = u => isTimeZone(u) && u._tag === "Named";
/** @internal */
exports.isTimeZoneNamed = isTimeZoneNamed;
const isUtc = self => self._tag === "Utc";
/** @internal */
exports.isUtc = isUtc;
const isZoned = self => self._tag === "Zoned";
// =============================================================================
// instances
// =============================================================================
/** @internal */
exports.isZoned = isZoned;
const Equivalence = exports.Equivalence = /*#__PURE__*/equivalence.make((a, b) => a.epochMillis === b.epochMillis);
/** @internal */
const Order = exports.Order = /*#__PURE__*/order.make((self, that) => self.epochMillis < that.epochMillis ? -1 : self.epochMillis > that.epochMillis ? 1 : 0);
/** @internal */
const clamp = exports.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 */
const unsafeFromDate = date => {
const epochMillis = date.getTime();
if (Number.isNaN(epochMillis)) {
throw new _Cause.IllegalArgumentException("Invalid date");
}
return makeUtc(epochMillis);
};
/** @internal */
exports.unsafeFromDate = unsafeFromDate;
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));
};
exports.unsafeMake = unsafeMake;
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 */
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 _Cause.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 */
exports.unsafeMakeZoned = unsafeMakeZoned;
const makeZoned = exports.makeZoned = /*#__PURE__*/Option.liftThrowable(unsafeMakeZoned);
/** @internal */
const make = exports.make = /*#__PURE__*/Option.liftThrowable(unsafeMake);
const zonedStringRegex = /^(.{17,35})\[(.+)\]$/;
/** @internal */
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 */
exports.makeZonedFromString = makeZonedFromString;
const now = exports.now = /*#__PURE__*/core.map(Clock.currentTimeMillis, makeUtc);
/** @internal */
const nowAsDate = exports.nowAsDate = /*#__PURE__*/core.map(Clock.currentTimeMillis, millis => new Date(millis));
/** @internal */
const unsafeNow = () => makeUtc(Date.now());
// =============================================================================
// time zones
// =============================================================================
/** @internal */
exports.unsafeNow = unsafeNow;
const toUtc = self => makeUtc(self.epochMillis);
/** @internal */
exports.toUtc = toUtc;
const setZone = exports.setZone = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, zone, options) => options?.adjustForTimeZone === true ? makeZonedFromAdjusted(self.epochMillis, zone, options?.disambiguation ?? "compatible") : makeZonedProto(self.epochMillis, zone, self.partsUtc));
/** @internal */
const setZoneOffset = exports.setZoneOffset = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, offset, options) => setZone(self, zoneMakeOffset(offset), options));
const validZoneCache = /*#__PURE__*/(0, _GlobalValue.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 */
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 _Cause.IllegalArgumentException(`Invalid time zone: ${zoneId}`);
}
};
/** @internal */
exports.zoneUnsafeMakeNamed = zoneUnsafeMakeNamed;
const zoneMakeOffset = offset => {
const zone = Object.create(ProtoTimeZoneOffset);
zone.offset = offset;
return zone;
};
/** @internal */
exports.zoneMakeOffset = zoneMakeOffset;
const zoneMakeNamed = exports.zoneMakeNamed = /*#__PURE__*/Option.liftThrowable(zoneUnsafeMakeNamed);
/** @internal */
const zoneMakeNamedEffect = zoneId => internalEffect.try_({
try: () => zoneUnsafeMakeNamed(zoneId),
catch: e => e
});
/** @internal */
exports.zoneMakeNamedEffect = zoneMakeNamedEffect;
const zoneMakeLocal = () => zoneMakeIntl(new Intl.DateTimeFormat("en-US", formatOptions));
exports.zoneMakeLocal = zoneMakeLocal;
const offsetZoneRegex = /^(?:GMT|[+-])/;
/** @internal */
const zoneFromString = zone => {
if (offsetZoneRegex.test(zone)) {
const offset = parseOffset(zone);
return offset === null ? Option.none() : Option.some(zoneMakeOffset(offset));
}
return zoneMakeNamed(zone);
};
/** @internal */
exports.zoneFromString = zoneFromString;
const zoneToString = self => {
if (self._tag === "Offset") {
return offsetToString(self.offset);
}
return self.id;
};
/** @internal */
exports.zoneToString = zoneToString;
const setZoneNamed = exports.setZoneNamed = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, zoneId, options) => Option.map(zoneMakeNamed(zoneId), zone => setZone(self, zone, options)));
/** @internal */
const unsafeSetZoneNamed = exports.unsafeSetZoneNamed = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, zoneId, options) => setZone(self, zoneUnsafeMakeNamed(zoneId), options));
// =============================================================================
// comparisons
// =============================================================================
/** @internal */
const distance = exports.distance = /*#__PURE__*/(0, _Function.dual)(2, (self, other) => toEpochMillis(other) - toEpochMillis(self));
/** @internal */
const distanceDurationEither = exports.distanceDurationEither = /*#__PURE__*/(0, _Function.dual)(2, (self, other) => {
const diffMillis = distance(self, other);
return diffMillis > 0 ? Either.right(Duration.millis(diffMillis)) : Either.left(Duration.millis(-diffMillis));
});
/** @internal */
const distanceDuration = exports.distanceDuration = /*#__PURE__*/(0, _Function.dual)(2, (self, other) => Duration.millis(Math.abs(distance(self, other))));
/** @internal */
const min = exports.min = /*#__PURE__*/order.min(Order);
/** @internal */
const max = exports.max = /*#__PURE__*/order.max(Order);
/** @internal */
const greaterThan = exports.greaterThan = /*#__PURE__*/order.greaterThan(Order);
/** @internal */
const greaterThanOrEqualTo = exports.greaterThanOrEqualTo = /*#__PURE__*/order.greaterThanOrEqualTo(Order);
/** @internal */
const lessThan = exports.lessThan = /*#__PURE__*/order.lessThan(Order);
/** @internal */
const lessThanOrEqualTo = exports.lessThanOrEqualTo = /*#__PURE__*/order.lessThanOrEqualTo(Order);
/** @internal */
const between = exports.between = /*#__PURE__*/order.between(Order);
/** @internal */
const isFuture = self => core.map(now, lessThan(self));
/** @internal */
exports.isFuture = isFuture;
const unsafeIsFuture = self => lessThan(unsafeNow(), self);
/** @internal */
exports.unsafeIsFuture = unsafeIsFuture;
const isPast = self => core.map(now, greaterThan(self));
/** @internal */
exports.isPast = isPast;
const unsafeIsPast = self => greaterThan(unsafeNow(), self);
// =============================================================================
// conversions
// =============================================================================
/** @internal */
exports.unsafeIsPast = unsafeIsPast;
const toDateUtc = self => new Date(self.epochMillis);
/** @internal */
exports.toDateUtc = toDateUtc;
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 */
exports.toDate = toDate;
const zonedOffset = self => {
const date = toDate(self);
return date.getTime() - toEpochMillis(self);
};
exports.zonedOffset = zonedOffset;
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 */
const zonedOffsetIso = self => offsetToString(zonedOffset(self));
/** @internal */
exports.zonedOffsetIso = zonedOffsetIso;
const toEpochMillis = self => self.epochMillis;
/** @internal */
exports.toEpochMillis = toEpochMillis;
const removeTime = self => withDate(self, date => {
date.setUTCHours(0, 0, 0, 0);
return makeUtc(date.getTime());
});
// =============================================================================
// parts
// =============================================================================
exports.removeTime = removeTime;
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 */
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 */
exports.toParts = toParts;
const toPartsUtc = self => {
if (self.partsUtc !== undefined) {
return self.partsUtc;
}
self.partsUtc = withDateUtc(self, dateToParts);
return self.partsUtc;
};
/** @internal */
exports.toPartsUtc = toPartsUtc;
const getPartUtc = exports.getPartUtc = /*#__PURE__*/(0, _Function.dual)(2, (self, part) => toPartsUtc(self)[part]);
/** @internal */
const getPart = exports.getPart = /*#__PURE__*/(0, _Function.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 */
const setParts = exports.setParts = /*#__PURE__*/(0, _Function.dual)(2, (self, parts) => mutate(self, date => setPartsDate(date, parts)));
/** @internal */
const setPartsUtc = exports.setPartsUtc = /*#__PURE__*/(0, _Function.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 */
const mutate = exports.mutate = /*#__PURE__*/(0, _Function.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 */
const mutateUtc = exports.mutateUtc = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => mapEpochMillis(self, millis => {
const date = new Date(millis);
f(date);
return date.getTime();
}));
/** @internal */
const mapEpochMillis = exports.mapEpochMillis = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
const millis = f(toEpochMillis(self));
return self._tag === "Utc" ? makeUtc(millis) : makeZonedProto(millis, self.zone);
});
/** @internal */
const withDate = exports.withDate = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => f(toDate(self)));
/** @internal */
const withDateUtc = exports.withDateUtc = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => f(toDateUtc(self)));
/** @internal */
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => self._tag === "Utc" ? options.onUtc(self) : options.onZoned(self));
// =============================================================================
// math
// =============================================================================
/** @internal */
const addDuration = exports.addDuration = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => mapEpochMillis(self, millis => millis + Duration.toMillis(duration)));
/** @internal */
const subtractDuration = exports.subtractDuration = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => mapEpochMillis(self, millis => millis - Duration.toMillis(duration)));
const addMillis = (date, amount) => {
date.setTime(date.getTime() + amount);
};
/** @internal */
const add = exports.add = /*#__PURE__*/(0, _Function.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 */
const subtract = exports.subtract = /*#__PURE__*/(0, _Function.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 */
const startOf = exports.startOf = /*#__PURE__*/(0, _Function.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 */
const endOf = exports.endOf = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, part, options) => mutate(self, date => endOfDate(date, part, options)));
/** @internal */
const nearest = exports.nearest = /*#__PURE__*/(0, _Function.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 */
const format = exports.format = /*#__PURE__*/(0, _Function.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 */
const formatLocal = exports.formatLocal = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, options) => new Intl.DateTimeFormat(options?.locale, options).format(self.epochMillis));
/** @internal */
const formatUtc = exports.formatUtc = /*#__PURE__*/(0, _Function.dual)(isDateTimeArgs, (self, options) => new Intl.DateTimeFormat(options?.locale, {
...options,
timeZone: "UTC"
}).format(self.epochMillis));
/** @internal */
const formatIntl = exports.formatIntl = /*#__PURE__*/(0, _Function.dual)(2, (self, format) => format.format(self.epochMillis));
/** @internal */
const formatIso = self => toDateUtc(self).toISOString();
/** @internal */
exports.formatIso = formatIso;
const formatIsoDate = self => toDate(self).toISOString().slice(0, 10);
/** @internal */
exports.formatIsoDate = formatIsoDate;
const formatIsoDateUtc = self => toDateUtc(self).toISOString().slice(0, 10);
/** @internal */
exports.formatIsoDateUtc = formatIsoDateUtc;
const formatIsoOffset = self => {
const date = toDate(self);
return self._tag === "Utc" ? date.toISOString() : `${date.toISOString().slice(0, -1)}${zonedOffsetIso(self)}`;
};
/** @internal */
exports.formatIsoOffset = formatIsoOffset;
const formatIsoZoned = self => self.zone._tag === "Offset" ? formatIsoOffset(self) : `${formatIsoOffset(self)}[${self.zone.id}]`;
exports.formatIsoZoned = formatIsoZoned;
//# sourceMappingURL=dateTime.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withTracer = exports.withRandom = exports.withConfigProvider = exports.withClock = exports.tracerWith = exports.sleep = exports.shuffle = exports.randomWith = exports.nextRange = exports.nextIntBetween = exports.nextInt = exports.nextBoolean = exports.next = exports.liveServices = exports.defaultServicesWith = exports.currentTimeNanos = exports.currentTimeMillis = exports.currentServices = exports.configProviderWith = exports.configOrDie = exports.config = exports.clockWith = exports.choice = void 0;
var Array = _interopRequireWildcard(require("../Array.js"));
var Context = _interopRequireWildcard(require("../Context.js"));
var Duration = _interopRequireWildcard(require("../Duration.js"));
var _Function = require("../Function.js");
var _GlobalValue = require("../GlobalValue.js");
var clock = _interopRequireWildcard(require("./clock.js"));
var configProvider = _interopRequireWildcard(require("./configProvider.js"));
var core = _interopRequireWildcard(require("./core.js"));
var console_ = _interopRequireWildcard(require("./defaultServices/console.js"));
var random = _interopRequireWildcard(require("./random.js"));
var tracer = _interopRequireWildcard(require("./tracer.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const liveServices = exports.liveServices = /*#__PURE__*/(0, _Function.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
*/
const currentServices = exports.currentServices = /*#__PURE__*/(0, _GlobalValue.globalValue)(/*#__PURE__*/Symbol.for("effect/DefaultServices/currentServices"), () => core.fiberRefUnsafeMakeContext(liveServices));
// circular with Clock
/** @internal */
const sleep = duration => {
const decodedDuration = Duration.decode(duration);
return clockWith(clock => clock.sleep(decodedDuration));
};
/** @internal */
exports.sleep = sleep;
const defaultServicesWith = f => core.withFiberRuntime(fiber => f(fiber.currentDefaultServices));
/** @internal */
exports.defaultServicesWith = defaultServicesWith;
const clockWith = f => defaultServicesWith(services => f(services.unsafeMap.get(clock.clockTag.key)));
/** @internal */
exports.clockWith = clockWith;
const currentTimeMillis = exports.currentTimeMillis = /*#__PURE__*/clockWith(clock => clock.currentTimeMillis);
/** @internal */
const currentTimeNanos = exports.currentTimeNanos = /*#__PURE__*/clockWith(clock => clock.currentTimeNanos);
/** @internal */
const withClock = exports.withClock = /*#__PURE__*/(0, _Function.dual)(2, (effect, c) => core.fiberRefLocallyWith(currentServices, Context.add(clock.clockTag, c))(effect));
// circular with ConfigProvider
/** @internal */
const withConfigProvider = exports.withConfigProvider = /*#__PURE__*/(0, _Function.dual)(2, (self, provider) => core.fiberRefLocallyWith(currentServices, Context.add(configProvider.configProviderTag, provider))(self));
/** @internal */
const configProviderWith = f => defaultServicesWith(services => f(services.unsafeMap.get(configProvider.configProviderTag.key)));
/** @internal */
exports.configProviderWith = configProviderWith;
const config = config => configProviderWith(_ => _.load(config));
/** @internal */
exports.config = config;
const configOrDie = config => core.orDie(configProviderWith(_ => _.load(config)));
// circular with Random
/** @internal */
exports.configOrDie = configOrDie;
const randomWith = f => defaultServicesWith(services => f(services.unsafeMap.get(random.randomTag.key)));
/** @internal */
exports.randomWith = randomWith;
const withRandom = exports.withRandom = /*#__PURE__*/(0, _Function.dual)(2, (effect, value) => core.fiberRefLocallyWith(currentServices, Context.add(random.randomTag, value))(effect));
/** @internal */
const next = exports.next = /*#__PURE__*/randomWith(random => random.next);
/** @internal */
const nextInt = exports.nextInt = /*#__PURE__*/randomWith(random => random.nextInt);
/** @internal */
const nextBoolean = exports.nextBoolean = /*#__PURE__*/randomWith(random => random.nextBoolean);
/** @internal */
const nextRange = (min, max) => randomWith(random => random.nextRange(min, max));
/** @internal */
exports.nextRange = nextRange;
const nextIntBetween = (min, max) => randomWith(random => random.nextIntBetween(min, max));
/** @internal */
exports.nextIntBetween = nextIntBetween;
const shuffle = elements => randomWith(random => random.shuffle(elements));
/** @internal */
exports.shuffle = shuffle;
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 */
exports.choice = choice;
const tracerWith = f => defaultServicesWith(services => f(services.unsafeMap.get(tracer.tracerTag.key)));
/** @internal */
exports.tracerWith = tracerWith;
const withTracer = exports.withTracer = /*#__PURE__*/(0, _Function.dual)(2, (effect, value) => core.fiberRefLocallyWith(currentServices, Context.add(tracer.tracerTag, value))(effect));
//# sourceMappingURL=defaultServices.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultConsole = exports.consoleTag = exports.TypeId = void 0;
var Context = _interopRequireWildcard(require("../../Context.js"));
var core = _interopRequireWildcard(require("../core.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("effect/Console");
/** @internal */
const consoleTag = exports.consoleTag = /*#__PURE__*/Context.GenericTag("effect/Console");
/** @internal */
const defaultConsole = exports.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

View File

@@ -0,0 +1 @@
{"version":3,"file":"console.js","names":["Context","_interopRequireWildcard","require","core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TypeId","exports","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/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ACqB,OAAO,CAAClB,KAAK,CAAC,CAAC;EAChD,CAAC;EACDmB,OAAOA,CAACnB,KAAK,EAAE,GAAGL,IAAI;IACpB,OAAO7B,IAAI,CAAC8B,IAAI,CAAC,MAAK;MACpBC,OAAO,CAACsB,OAAO,CAACnB,KAAK,EAAE,GAAGL,IAAI,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC;EACDyB,KAAKA,CAAC,GAAGzB,IAAI;IACX,OAAO7B,IAAI,CAAC8B,IAAI,CAAC,MAAK;MACpBC,OAAO,CAACuB,KAAK,CAAC,GAAGzB,IAAI,CAAC;IACxB,CAAC,CAAC;EACJ,CAAC;EACD0B,IAAIA,CAAC,GAAG1B,IAAI;IACV,OAAO7B,IAAI,CAAC8B,IAAI,CAAC,MAAK;MACpBC,OAAO,CAACwB,IAAI,CAAC,GAAG1B,IAAI,CAAC;IACvB,CAAC,CAAC;EACJ,CAAC;EACD2B,MAAM,EAAEzB;CACT","ignoreList":[]}

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pending = exports.done = exports.deferredVariance = exports.DeferredTypeId = void 0;
var OpCodes = _interopRequireWildcard(require("./opCodes/deferred.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const DeferredSymbolKey = "effect/Deferred";
/** @internal */
const DeferredTypeId = exports.DeferredTypeId = /*#__PURE__*/Symbol.for(DeferredSymbolKey);
/** @internal */
const deferredVariance = exports.deferredVariance = {
/* c8 ignore next */
_E: _ => _,
/* c8 ignore next */
_A: _ => _
};
/** @internal */
const pending = joiners => {
return {
_tag: OpCodes.OP_STATE_PENDING,
joiners
};
};
/** @internal */
exports.pending = pending;
const done = effect => {
return {
_tag: OpCodes.OP_STATE_DONE,
effect
};
};
exports.done = done;
//# sourceMappingURL=deferred.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"deferred.js","names":["OpCodes","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DeferredSymbolKey","DeferredTypeId","exports","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,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEhD;AACA,MAAMkB,iBAAiB,GAAG,iBAAiB;AAE3C;AACO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,gBAA4BE,MAAM,CAACC,GAAG,CAC/DJ,iBAAiB,CACS;AAE5B;AACO,MAAMK,gBAAgB,GAAAH,OAAA,CAAAG,gBAAA,GAAG;EAC9B;EACAC,EAAE,EAAGC,CAAM,IAAKA,CAAC;EACjB;EACAC,EAAE,EAAGD,CAAM,IAAKA;CACjB;AAiBD;AACO,MAAME,OAAO,GAClBC,OAAqD,IACtC;EACf,OAAO;IAAEC,IAAI,EAAEjC,OAAO,CAACkC,gBAAgB;IAAEF;EAAO,CAAE;AACpD,CAAC;AAED;AAAAR,OAAA,CAAAO,OAAA,GAAAA,OAAA;AACO,MAAMI,IAAI,GAAUC,MAA2B,IAAiB;EACrE,OAAO;IAAEH,IAAI,EAAEjC,OAAO,CAACqC,aAAa;IAAED;EAAM,CAAE;AAChD,CAAC;AAAAZ,OAAA,CAAAW,IAAA,GAAAA,IAAA","ignoreList":[]}

149
backend/node_modules/effect/dist/cjs/internal/differ.js generated vendored Normal file
View File

@@ -0,0 +1,149 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zip = exports.updateWith = exports.update = exports.transform = exports.readonlyArray = exports.orElseEither = exports.make = exports.hashSet = exports.hashMap = exports.environment = exports.chunk = exports.DifferTypeId = exports.DifferProto = void 0;
var Equal = _interopRequireWildcard(require("../Equal.js"));
var _Function = _interopRequireWildcard(require("../Function.js"));
var Dual = _Function;
var _Pipeable = require("../Pipeable.js");
var ChunkPatch = _interopRequireWildcard(require("./differ/chunkPatch.js"));
var ContextPatch = _interopRequireWildcard(require("./differ/contextPatch.js"));
var HashMapPatch = _interopRequireWildcard(require("./differ/hashMapPatch.js"));
var HashSetPatch = _interopRequireWildcard(require("./differ/hashSetPatch.js"));
var OrPatch = _interopRequireWildcard(require("./differ/orPatch.js"));
var ReadonlyArrayPatch = _interopRequireWildcard(require("./differ/readonlyArrayPatch.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const DifferTypeId = exports.DifferTypeId = /*#__PURE__*/Symbol.for("effect/Differ");
/** @internal */
const DifferProto = exports.DifferProto = {
[DifferTypeId]: {
_P: _Function.identity,
_V: _Function.identity
},
pipe() {
return (0, _Pipeable.pipeArguments)(this, arguments);
}
};
/** @internal */
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 */
exports.make = make;
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 */
exports.environment = environment;
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 */
exports.chunk = chunk;
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 */
exports.hashMap = hashMap;
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 */
exports.hashSet = hashSet;
const orElseEither = exports.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 */
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 */
exports.readonlyArray = readonlyArray;
const transform = exports.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 */
const update = () => updateWith((_, a) => a);
/** @internal */
exports.update = update;
const updateWith = f => make({
empty: _Function.identity,
combine: (first, second) => {
if (first === _Function.identity) {
return second;
}
if (second === _Function.identity) {
return first;
}
return a => second(first(a));
},
diff: (oldValue, newValue) => {
if (Equal.equals(oldValue, newValue)) {
return _Function.identity;
}
return (0, _Function.constant)(newValue);
},
patch: (patch, oldValue) => f(oldValue, patch(oldValue))
});
/** @internal */
exports.updateWith = updateWith;
const zip = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,139 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.empty = exports.diff = exports.combine = exports.ChunkPatchTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var _Function = _interopRequireWildcard(require("../../Function.js"));
var Dual = _Function;
var Data = _interopRequireWildcard(require("../data.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ChunkPatchTypeId = exports.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
*/
const empty = () => _empty;
exports.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 */
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 = (0, _Function.pipe)(patch, combine(makeUpdate(i, valuePatch)));
}
i = i + 1;
}
if (i < options.oldValue.length) {
patch = (0, _Function.pipe)(patch, combine(makeSlice(0, i)));
}
if (i < options.newValue.length) {
patch = (0, _Function.pipe)(patch, combine(makeAppend(Chunk.drop(i)(options.newValue))));
}
return patch;
};
/** @internal */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,152 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.empty = exports.diff = exports.combine = exports.ContextPatchTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var Dual = _interopRequireWildcard(require("../../Function.js"));
var _context = require("../context.js");
var _data = require("../data.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ContextPatchTypeId = exports.ContextPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferContextPatch");
function variance(a) {
return a;
}
/** @internal */
const PatchProto = {
..._data.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
*/
const empty = () => _empty;
exports.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 */
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 */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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 (0, _context.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 (0, _context.makeContext)(map);
});
//# sourceMappingURL=contextPatch.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,139 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.empty = exports.diff = exports.combine = exports.HashMapPatchTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var Dual = _interopRequireWildcard(require("../../Function.js"));
var HashMap = _interopRequireWildcard(require("../../HashMap.js"));
var _data = require("../data.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const HashMapPatchTypeId = exports.HashMapPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferHashMapPatch");
function variance(a) {
return a;
}
/** @internal */
const PatchProto = {
..._data.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 */
const empty = () => _empty;
exports.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 */
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 */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.makeRemove = exports.makeAndThen = exports.makeAdd = exports.empty = exports.diff = exports.combine = exports.HashSetPatchTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var Dual = _interopRequireWildcard(require("../../Function.js"));
var HashSet = _interopRequireWildcard(require("../../HashSet.js"));
var _data = require("../data.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const HashSetPatchTypeId = exports.HashSetPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferHashSetPatch");
function variance(a) {
return a;
}
/** @internal */
const PatchProto = {
..._data.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 */
const empty = () => _empty;
exports.empty = empty;
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "AndThen"
});
/** @internal */
const makeAndThen = (first, second) => {
const o = Object.create(AndThenProto);
o.first = first;
o.second = second;
return o;
};
exports.makeAndThen = makeAndThen;
const AddProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "Add"
});
/** @internal */
const makeAdd = value => {
const o = Object.create(AddProto);
o.value = value;
return o;
};
exports.makeAdd = makeAdd;
const RemoveProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "Remove"
});
/** @internal */
const makeRemove = value => {
const o = Object.create(RemoveProto);
o.value = value;
return o;
};
/** @internal */
exports.makeRemove = makeRemove;
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 */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,184 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.makeUpdateRight = exports.makeUpdateLeft = exports.makeSetRight = exports.makeSetLeft = exports.makeAndThen = exports.empty = exports.diff = exports.combine = exports.OrPatchTypeId = void 0;
var Chunk = _interopRequireWildcard(require("../../Chunk.js"));
var E = _interopRequireWildcard(require("../../Either.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var Dual = _interopRequireWildcard(require("../../Function.js"));
var _data = require("../data.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const OrPatchTypeId = exports.OrPatchTypeId = /*#__PURE__*/Symbol.for("effect/DifferOrPatch");
function variance(a) {
return a;
}
/** @internal */
const PatchProto = {
..._data.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 */
const empty = () => _empty;
exports.empty = empty;
const AndThenProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "AndThen"
});
/** @internal */
const makeAndThen = (first, second) => {
const o = Object.create(AndThenProto);
o.first = first;
o.second = second;
return o;
};
exports.makeAndThen = makeAndThen;
const SetLeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "SetLeft"
});
/** @internal */
const makeSetLeft = value => {
const o = Object.create(SetLeftProto);
o.value = value;
return o;
};
exports.makeSetLeft = makeSetLeft;
const SetRightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "SetRight"
});
/** @internal */
const makeSetRight = value => {
const o = Object.create(SetRightProto);
o.value = value;
return o;
};
exports.makeSetRight = makeSetRight;
const UpdateLeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "UpdateLeft"
});
/** @internal */
const makeUpdateLeft = patch => {
const o = Object.create(UpdateLeftProto);
o.patch = patch;
return o;
};
exports.makeUpdateLeft = makeUpdateLeft;
const UpdateRightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(PatchProto), {
_tag: "UpdateRight"
});
/** @internal */
const makeUpdateRight = patch => {
const o = Object.create(UpdateRightProto);
o.patch = patch;
return o;
};
/** @internal */
exports.makeUpdateRight = makeUpdateRight;
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 */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,138 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.patch = exports.empty = exports.diff = exports.combine = exports.ReadonlyArrayPatchTypeId = void 0;
var Arr = _interopRequireWildcard(require("../../Array.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var Dual = _interopRequireWildcard(require("../../Function.js"));
var Data = _interopRequireWildcard(require("../data.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const ReadonlyArrayPatchTypeId = exports.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
*/
const empty = () => _empty;
exports.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 */
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 */
exports.diff = diff;
const combine = exports.combine = /*#__PURE__*/Dual.dual(2, (self, that) => makeAndThen(self, that));
/** @internal */
const patch = exports.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.let_ = exports.bindTo = exports.bind = void 0;
var _Function = require("../Function.js");
/** @internal */
const let_ = map => (0, _Function.dual)(3, (self, name, f) => map(self, a => ({
...a,
[name]: f(a)
})));
/** @internal */
exports.let_ = let_;
const bindTo = map => (0, _Function.dual)(2, (self, name) => map(self, a => ({
[name]: a
})));
/** @internal */
exports.bindTo = bindTo;
const bind = (map, flatMap) => (0, _Function.dual)(3, (self, name, f) => flatMap(self, a => map(f(a), b => ({
...a,
[name]: b
}))));
exports.bind = bind;
//# sourceMappingURL=doNotation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"doNotation.js","names":["_Function","require","let_","map","dual","self","name","f","a","exports","bindTo","bind","flatMap","b"],"sources":["../../../src/internal/doNotation.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAmBA;AACO,MAAMC,IAAI,GACfC,GAAW,IAcX,IAAAC,cAAI,EAAC,CAAC,EAAE,CACNC,IAAyB,EACzBC,IAAyB,EACzBC,CAAuB,KAEvBJ,GAAG,CAACE,IAAI,EAAGG,CAAC,KAAM;EAAE,GAAGA,CAAC;EAAE,CAACF,IAAI,GAAGC,CAAC,CAACC,CAAC;AAAC,CAAE,CAAQ,CAAC,CAAC;AAEtD;AAAAC,OAAA,CAAAP,IAAA,GAAAA,IAAA;AACO,MAAMQ,MAAM,GAA0BP,GAAW,IAStD,IAAAC,cAAI,EAAC,CAAC,EAAE,CACNC,IAAyB,EACzBC,IAAO,KAC+BH,GAAG,CAACE,IAAI,EAAGG,CAAC,KAAM;EAAE,CAACF,IAAI,GAAGE;AAAC,CAAsB,EAAC,CAAC;AAE/F;AAAAC,OAAA,CAAAC,MAAA,GAAAA,MAAA;AACO,MAAMC,IAAI,GAAGA,CAAuBR,GAAW,EAAES,OAAmB,KAazE,IAAAR,cAAI,EAAC,CAAC,EAAE,CACNC,IAA4B,EAC5BC,IAAyB,EACzBC,CAA4C,KAE5CK,OAAO,CACLP,IAAI,EACHG,CAAC,IAAKL,GAAG,CAACI,CAAC,CAACC,CAAC,CAAC,EAAGK,CAAC,KAAM;EAAE,GAAGL,CAAC;EAAE,CAACF,IAAI,GAAGO;AAAC,CAAE,CAAyD,CAAC,CACvG,CAAC;AAAAJ,OAAA,CAAAE,IAAA,GAAAA,IAAA","ignoreList":[]}

View File

@@ -0,0 +1,416 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zipWithFiber = exports.zipRightFiber = exports.zipLeftFiber = exports.zipFiber = exports.updateSomeAndGetEffectSynchronized = exports.unsafeMakeSynchronized = exports.unsafeMakeSemaphore = exports.unsafeMakeLatch = exports.timeoutTo = exports.timeoutOption = exports.timeoutFailCause = exports.timeoutFail = exports.timeout = exports.synchronizedVariance = exports.supervised = exports.raceFirst = exports.makeSynchronized = exports.makeSemaphore = exports.makeLatch = exports.fromFiberEffect = exports.fromFiber = exports.forkScoped = exports.forkIn = exports.forkAll = exports.ensuringChildren = exports.ensuringChild = exports.cachedInvalidateWithTTL = exports.cachedFunction = exports.cached = exports.bindAll = exports.awaitAllChildren = exports.SynchronizedTypeId = void 0;
var Duration = _interopRequireWildcard(require("../../Duration.js"));
var Effectable = _interopRequireWildcard(require("../../Effectable.js"));
var Equal = _interopRequireWildcard(require("../../Equal.js"));
var Exit = _interopRequireWildcard(require("../../Exit.js"));
var FiberId = _interopRequireWildcard(require("../../FiberId.js"));
var _Function = require("../../Function.js");
var Hash = _interopRequireWildcard(require("../../Hash.js"));
var MutableHashMap = _interopRequireWildcard(require("../../MutableHashMap.js"));
var Option = _interopRequireWildcard(require("../../Option.js"));
var _Pipeable = require("../../Pipeable.js");
var Predicate = _interopRequireWildcard(require("../../Predicate.js"));
var Readable = _interopRequireWildcard(require("../../Readable.js"));
var _Scheduler = require("../../Scheduler.js");
var internalCause = _interopRequireWildcard(require("../cause.js"));
var effect = _interopRequireWildcard(require("../core-effect.js"));
var core = _interopRequireWildcard(require("../core.js"));
var internalFiber = _interopRequireWildcard(require("../fiber.js"));
var fiberRuntime = _interopRequireWildcard(require("../fiberRuntime.js"));
var _fiberScope = require("../fiberScope.js");
var internalRef = _interopRequireWildcard(require("../ref.js"));
var supervisor = _interopRequireWildcard(require("../supervisor.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
class 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(_Scheduler.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 */
const unsafeMakeSemaphore = permits => new Semaphore(permits);
/** @internal */
exports.unsafeMakeSemaphore = unsafeMakeSemaphore;
const makeSemaphore = permits => core.sync(() => unsafeMakeSemaphore(permits));
exports.makeSemaphore = makeSemaphore;
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 */
const unsafeMakeLatch = open => new Latch(open ?? false);
/** @internal */
exports.unsafeMakeLatch = unsafeMakeLatch;
const makeLatch = open => core.sync(() => unsafeMakeLatch(open));
/** @internal */
exports.makeLatch = makeLatch;
const awaitAllChildren = self => ensuringChildren(self, fiberRuntime.fiberAwaitAll);
/** @internal */
exports.awaitAllChildren = awaitAllChildren;
const cached = exports.cached = /*#__PURE__*/(0, _Function.dual)(2, (self, timeToLive) => core.map(cachedInvalidateWithTTL(self, timeToLive), tuple => tuple[0]));
/** @internal */
const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = /*#__PURE__*/(0, _Function.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 (0, _Function.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 => (0, _Function.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 */
const ensuringChild = exports.ensuringChild = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => ensuringChildren(self, children => f(fiberRuntime.fiberAll(children))));
/** @internal */
const ensuringChildren = exports.ensuringChildren = /*#__PURE__*/(0, _Function.dual)(2, (self, children) => core.flatMap(supervisor.track, supervisor => (0, _Function.pipe)(supervised(self, supervisor), fiberRuntime.ensuring(core.flatMap(supervisor.value, children)))));
/** @internal */
const forkAll = exports.forkAll = /*#__PURE__*/(0, _Function.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 */
const forkIn = exports.forkIn = /*#__PURE__*/(0, _Function.dual)(2, (self, scope) => core.withFiberRuntime((parent, parentStatus) => {
const scopeImpl = scope;
const fiber = fiberRuntime.unsafeFork(self, parent, parentStatus.runtimeFlags, _fiberScope.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 */
const forkScoped = self => fiberRuntime.scopeWith(scope => forkIn(self, scope));
/** @internal */
exports.forkScoped = forkScoped;
const fromFiber = fiber => internalFiber.join(fiber);
/** @internal */
exports.fromFiber = fromFiber;
const fromFiberEffect = fiber => core.suspend(() => core.flatMap(fiber, internalFiber.join));
exports.fromFiberEffect = fromFiberEffect;
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 */
const cachedFunction = (f, eq) => {
return (0, _Function.pipe)(core.sync(() => MutableHashMap.empty()), core.flatMap(makeSynchronized), core.map(ref => a => (0, _Function.pipe)(ref.modifyEffect(map => {
const result = (0, _Function.pipe)(map, MutableHashMap.get(new Key(a, eq)));
if (Option.isNone(result)) {
return (0, _Function.pipe)(core.deferredMake(), core.tap(deferred => (0, _Function.pipe)(effect.diffFiberRefs(f(a)), core.intoDeferred(deferred), fiberRuntime.fork)), core.map(deferred => [deferred, (0, _Function.pipe)(map, MutableHashMap.set(new Key(a, eq), deferred))]));
}
return core.succeed([result.value, map]);
}), core.flatMap(core.deferredAwait), core.flatMap(([patch, b]) => (0, _Function.pipe)(effect.patchFiberRefs(patch), core.as(b))))));
};
/** @internal */
exports.cachedFunction = cachedFunction;
const raceFirst = exports.raceFirst = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => (0, _Function.pipe)(core.exit(self), fiberRuntime.race(core.exit(that)), effect => core.flatten(effect)));
/** @internal */
const supervised = exports.supervised = /*#__PURE__*/(0, _Function.dual)(2, (self, supervisor) => {
const supervise = core.fiberRefLocallyWith(fiberRuntime.currentSupervisor, s => s.zip(supervisor));
return supervise(self);
});
/** @internal */
const timeout = exports.timeout = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => timeoutFail(self, {
onTimeout: () => core.timeoutExceptionFromDuration(duration),
duration
}));
/** @internal */
const timeoutFail = exports.timeoutFail = /*#__PURE__*/(0, _Function.dual)(2, (self, {
duration,
onTimeout
}) => core.flatten(timeoutTo(self, {
onTimeout: () => core.failSync(onTimeout),
onSuccess: core.succeed,
duration
})));
/** @internal */
const timeoutFailCause = exports.timeoutFailCause = /*#__PURE__*/(0, _Function.dual)(2, (self, {
duration,
onTimeout
}) => core.flatten(timeoutTo(self, {
onTimeout: () => core.failCauseSync(onTimeout),
onSuccess: core.succeed,
duration
})));
/** @internal */
const timeoutOption = exports.timeoutOption = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => timeoutTo(self, {
duration,
onSuccess: Option.some,
onTimeout: Option.none
}));
/** @internal */
const timeoutTo = exports.timeoutTo = /*#__PURE__*/(0, _Function.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: _fiberScope.globalScope
}))));
// circular with Synchronized
/** @internal */
const SynchronizedSymbolKey = "effect/Ref/SynchronizedRef";
/** @internal */
const SynchronizedTypeId = exports.SynchronizedTypeId = /*#__PURE__*/Symbol.for(SynchronizedSymbolKey);
/** @internal */
const synchronizedVariance = exports.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((0, _Function.pipe)(core.flatMap(internalRef.get(this.ref), f), core.flatMap(([b, a]) => core.as(internalRef.set(this.ref, a), b))));
}
}
/** @internal */
const makeSynchronized = value => core.sync(() => unsafeMakeSynchronized(value));
/** @internal */
exports.makeSynchronized = makeSynchronized;
const unsafeMakeSynchronized = value => {
const ref = internalRef.unsafeMake(value);
const sem = unsafeMakeSemaphore(1);
return new SynchronizedImpl(ref, sem.withPermits(1));
};
/** @internal */
exports.unsafeMakeSynchronized = unsafeMakeSynchronized;
const updateSomeAndGetEffectSynchronized = exports.updateSomeAndGetEffectSynchronized = /*#__PURE__*/(0, _Function.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 */
const zipFiber = exports.zipFiber = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zipWithFiber(self, that, (a, b) => [a, b]));
/** @internal */
const zipLeftFiber = exports.zipLeftFiber = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zipWithFiber(self, that, (a, _) => a));
/** @internal */
const zipRightFiber = exports.zipRightFiber = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zipWithFiber(self, that, (_, b) => b));
/** @internal */
const zipWithFiber = exports.zipWithFiber = /*#__PURE__*/(0, _Function.dual)(3, (self, that, f) => ({
...Effectable.CommitPrototype,
commit() {
return internalFiber.join(this);
},
[internalFiber.FiberTypeId]: internalFiber.fiberVariance,
id: () => (0, _Function.pipe)(self.id(), FiberId.getOrElse(that.id())),
await: (0, _Function.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) => (0, _Function.pipe)(optionA, Option.flatMap(exitA => (0, _Function.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 (0, _Pipeable.pipeArguments)(this, arguments);
}
}));
/* @internal */
const bindAll = exports.bindAll = /*#__PURE__*/(0, _Function.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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,120 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.effectVariance = exports.StructuralPrototype = exports.StructuralCommitPrototype = exports.StructuralBase = exports.StreamTypeId = exports.SinkTypeId = exports.EffectTypeId = exports.EffectPrototype = exports.CommitPrototype = exports.ChannelTypeId = exports.Base = void 0;
var Equal = _interopRequireWildcard(require("../Equal.js"));
var Hash = _interopRequireWildcard(require("../Hash.js"));
var _Pipeable = require("../Pipeable.js");
var _Utils = require("../Utils.js");
var OpCodes = _interopRequireWildcard(require("./opCodes/effect.js"));
var version = _interopRequireWildcard(require("./version.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const EffectTypeId = exports.EffectTypeId = /*#__PURE__*/Symbol.for("effect/Effect");
/** @internal */
const StreamTypeId = exports.StreamTypeId = /*#__PURE__*/Symbol.for("effect/Stream");
/** @internal */
const SinkTypeId = exports.SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
/** @internal */
const ChannelTypeId = exports.ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel");
/** @internal */
const effectVariance = exports.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 */
const EffectPrototype = exports.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 _Utils.SingleShotGen(new _Utils.YieldWrap(this));
},
pipe() {
return (0, _Pipeable.pipeArguments)(this, arguments);
}
};
/** @internal */
const StructuralPrototype = exports.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 */
const CommitPrototype = exports.CommitPrototype = {
...EffectPrototype,
_op: OpCodes.OP_COMMIT
};
/** @internal */
const StructuralCommitPrototype = exports.StructuralCommitPrototype = {
...CommitPrototype,
...StructuralPrototype
};
/** @internal */
const Base = exports.Base = /*#__PURE__*/function () {
function Base() {}
Base.prototype = CommitPrototype;
return Base;
}();
/** @internal */
const StructuralBase = exports.StructuralBase = /*#__PURE__*/function () {
function Base() {}
Base.prototype = StructuralCommitPrototype;
return Base;
}();
//# sourceMappingURL=effectable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"effectable.js","names":["Equal","_interopRequireWildcard","require","Hash","_Pipeable","_Utils","OpCodes","version","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","EffectTypeId","exports","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","SingleShotGen","YieldWrap","pipe","pipeArguments","arguments","StructuralPrototype","structure","selfKeys","keys","thatKeys","length","key","equals","CommitPrototype","_op","OP_COMMIT","StructuralCommitPrototype","Base","prototype","StructuralBase"],"sources":["../../../src/internal/effectable.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAL,uBAAA,CAAAC,OAAA;AAC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AAG,EAAElE,OAAO,CAACmE;CACP;AAER;AACO,MAAMC,yBAAyB,GAAA9C,OAAA,CAAA8C,yBAAA,GAAyB;EAC7D,GAAGH,eAAe;EAClB,GAAGR;CACG;AAER;AACO,MAAMY,IAAI,GAAA/C,OAAA,CAAA+C,IAAA,gBAAgC;EAC/C,SAASA,IAAIA,CAAA,GAAI;EACjBA,IAAI,CAACC,SAAS,GAAGL,eAAe;EAChC,OAAOI,IAAW;AACpB,CAAC,CAAC,CAAE;AAEJ;AACO,MAAME,cAAc,GAAAjD,OAAA,CAAAiD,cAAA,gBAAgC;EACzD,SAASF,IAAIA,CAAA,GAAI;EACjBA,IAAI,CAACC,SAAS,GAAGF,yBAAyB;EAC1C,OAAOC,IAAW;AACpB,CAAC,CAAC,CAAE","ignoreList":[]}

100
backend/node_modules/effect/dist/cjs/internal/either.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.right = exports.left = exports.isRight = exports.isLeft = exports.isEither = exports.getRight = exports.getLeft = exports.fromOption = exports.TypeId = void 0;
var Equal = _interopRequireWildcard(require("../Equal.js"));
var _Function = require("../Function.js");
var Hash = _interopRequireWildcard(require("../Hash.js"));
var _Inspectable = require("../Inspectable.js");
var _Predicate = require("../Predicate.js");
var _effectable = require("./effectable.js");
var option = _interopRequireWildcard(require("./option.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
* @since 2.0.0
*/
/**
* @internal
*/
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("effect/Either");
const CommonProto = {
..._effectable.EffectPrototype,
[TypeId]: {
_R: _ => _
},
[_Inspectable.NodeInspectSymbol]() {
return this.toJSON();
},
toString() {
return (0, _Inspectable.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: (0, _Inspectable.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: (0, _Inspectable.toJSON)(this.left)
};
}
});
/** @internal */
const isEither = input => (0, _Predicate.hasProperty)(input, TypeId);
/** @internal */
exports.isEither = isEither;
const isLeft = ma => ma._tag === "Left";
/** @internal */
exports.isLeft = isLeft;
const isRight = ma => ma._tag === "Right";
/** @internal */
exports.isRight = isRight;
const left = left => {
const a = Object.create(LeftProto);
a.left = left;
return a;
};
/** @internal */
exports.left = left;
const right = right => {
const a = Object.create(RightProto);
a.right = right;
return a;
};
/** @internal */
exports.right = right;
const getLeft = self => isRight(self) ? option.none : option.some(self.left);
/** @internal */
exports.getLeft = getLeft;
const getRight = self => isLeft(self) ? option.none : option.some(self.right);
/** @internal */
exports.getRight = getRight;
const fromOption = exports.fromOption = /*#__PURE__*/(0, _Function.dual)(2, (self, onNone) => option.isNone(self) ? left(onNone()) : right(self.value));
//# sourceMappingURL=either.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"either.js","names":["Equal","_interopRequireWildcard","require","_Function","Hash","_Inspectable","_Predicate","_effectable","option","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TypeId","exports","Symbol","for","CommonProto","EffectPrototype","_R","_","NodeInspectSymbol","toJSON","toString","format","RightProto","assign","create","_tag","_op","symbol","that","isEither","isRight","equals","right","combine","hash","_id","LeftProto","isLeft","left","input","hasProperty","ma","a","getLeft","self","none","some","getRight","fromOption","dual","onNone","isNone","value"],"sources":["../../../src/internal/either.ts"],"sourcesContent":[null],"mappings":";;;;;;AAKA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAP,uBAAA,CAAAC,OAAA;AAAqC,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,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I,CAACQ,KAAK,CAAC,CAC3D","ignoreList":[]}

View File

@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stripCrlf = exports.encode = exports.decode = void 0;
var Either = _interopRequireWildcard(require("../../Either.js"));
var _common = require("./common.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const 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 */
exports.encode = encode;
const decode = str => {
const stripped = stripCrlf(str);
const length = stripped.length;
if (length % 4 !== 0) {
return Either.left((0, _common.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((0, _common.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((0, _common.DecodeException)(stripped, e instanceof Error ? e.message : "Invalid input"));
}
};
/** @internal */
exports.decode = decode;
const stripCrlf = str => str.replace(/[\n\r]/g, "");
/** @internal */
exports.stripCrlf = stripCrlf;
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.encode = exports.decode = void 0;
var Either = _interopRequireWildcard(require("../../Either.js"));
var Base64 = _interopRequireWildcard(require("./base64.js"));
var _common = require("./common.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const encode = data => Base64.encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
/** @internal */
exports.encode = encode;
const decode = str => {
const stripped = Base64.stripCrlf(str);
const length = stripped.length;
if (length % 4 === 1) {
return Either.left((0, _common.DecodeException)(stripped, `Length should be a multiple of 4, but is ${length}`));
}
if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) {
return Either.left((0, _common.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);
};
exports.decode = decode;
//# sourceMappingURL=base64Url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base64Url.js","names":["Either","_interopRequireWildcard","require","Base64","_common","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","encode","data","replace","exports","decode","str","stripped","stripCrlf","length","left","DecodeException","test","sanitized"],"sources":["../../../../src/internal/encoding/base64Url.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAA6C,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAA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Module", {
value: true
});
exports.isEncodeException = exports.isDecodeException = exports.encoder = exports.decoder = exports.EncodeExceptionTypeId = exports.EncodeException = exports.DecodeExceptionTypeId = exports.DecodeException = void 0;
var _Predicate = require("../../Predicate.js");
/** @internal */
const DecodeExceptionTypeId = exports.DecodeExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Encoding/errors/Decode");
/** @internal */
const DecodeException = (input, message) => {
const out = {
_tag: "DecodeException",
[DecodeExceptionTypeId]: DecodeExceptionTypeId,
input
};
if ((0, _Predicate.isString)(message)) {
out.message = message;
}
return out;
};
/** @internal */
exports.DecodeException = DecodeException;
const isDecodeException = u => (0, _Predicate.hasProperty)(u, DecodeExceptionTypeId);
/** @internal */
exports.isDecodeException = isDecodeException;
const EncodeExceptionTypeId = exports.EncodeExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Encoding/errors/Encode");
/** @internal */
const EncodeException = (input, message) => {
const out = {
_tag: "EncodeException",
[EncodeExceptionTypeId]: EncodeExceptionTypeId,
input
};
if ((0, _Predicate.isString)(message)) {
out.message = message;
}
return out;
};
/** @internal */
exports.EncodeException = EncodeException;
const isEncodeException = u => (0, _Predicate.hasProperty)(u, EncodeExceptionTypeId);
/** @interal */
exports.isEncodeException = isEncodeException;
const encoder = exports.encoder = /*#__PURE__*/new TextEncoder();
/** @interal */
const decoder = exports.decoder = /*#__PURE__*/new TextDecoder();
//# sourceMappingURL=common.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","names":["_Predicate","require","DecodeExceptionTypeId","exports","Symbol","for","DecodeException","input","message","out","_tag","isString","isDecodeException","u","hasProperty","EncodeExceptionTypeId","EncodeException","isEncodeException","encoder","TextEncoder","decoder","TextDecoder"],"sources":["../../../../src/internal/encoding/common.ts"],"sourcesContent":[null],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGA;AACO,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAAmCE,MAAM,CAACC,GAAG,CAC7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]}

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.encode = exports.decode = void 0;
var Either = _interopRequireWildcard(require("../../Either.js"));
var _common = require("./common.js");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @internal */
const encode = bytes => {
let result = "";
for (let i = 0; i < bytes.length; ++i) {
result += bytesToHex[bytes[i]];
}
return result;
};
/** @internal */
exports.encode = encode;
const decode = str => {
const bytes = new TextEncoder().encode(str);
if (bytes.length % 2 !== 0) {
return Either.left((0, _common.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((0, _common.DecodeException)(str, e instanceof Error ? e.message : "Invalid input"));
}
};
/** @internal */
exports.decode = decode;
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getBugErrorMessage = void 0;
/**
* @since 2.0.0
*/
/** @internal */
const getBugErrorMessage = message => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
exports.getBugErrorMessage = getBugErrorMessage;
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","names":["getBugErrorMessage","message","exports"],"sources":["../../../src/internal/errors.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA;;;AAIA;AACO,MAAMA,kBAAkB,GAAIC,OAAe,IAChD,QAAQA,OAAO,yEAAyE;AAAAC,OAAA,CAAAF,kBAAA,GAAAA,kBAAA","ignoreList":[]}

Some files were not shown because too many files have changed in this diff Show More