clanka 0.16.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +5 -1
- package/dist/Agent.js.map +1 -1
- package/dist/AgentCallerConfig.test.js +5 -3
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/ChunkRepo.d.ts +1 -1
- package/dist/ClaudeAgent.d.ts +111 -0
- package/dist/ClaudeAgent.d.ts.map +1 -0
- package/dist/ClaudeAgent.js +772 -0
- package/dist/ClaudeAgent.js.map +1 -0
- package/dist/ClaudeAgent.test.d.ts +2 -0
- package/dist/ClaudeAgent.test.d.ts.map +1 -0
- package/dist/ClaudeAgent.test.js +416 -0
- package/dist/ClaudeAgent.test.js.map +1 -0
- package/dist/Compaction.test.js +2 -1
- package/dist/Compaction.test.js.map +1 -1
- package/dist/CompactionTokens.test.js +15 -8
- package/dist/CompactionTokens.test.js.map +1 -1
- package/dist/ModelLayer.d.ts +2 -2
- package/dist/ModelLayer.d.ts.map +1 -1
- package/dist/ModelLayer.js +13 -7
- package/dist/ModelLayer.js.map +1 -1
- package/dist/ModelLayer.test.js +3 -0
- package/dist/ModelLayer.test.js.map +1 -1
- package/dist/ModelsRepo.d.ts +7 -6
- package/dist/ModelsRepo.d.ts.map +1 -1
- package/dist/ModelsRepo.js +44 -27
- package/dist/ModelsRepo.js.map +1 -1
- package/dist/ModelsRepo.test.js +47 -3
- package/dist/ModelsRepo.test.js.map +1 -1
- package/dist/bin/{Effect-4B1lzxy4.mjs → Effect-DNYYQ84C.mjs} +467 -365
- package/dist/bin/Effect-DNYYQ84C.mjs.map +1 -0
- package/dist/bin/Latch-BSlIwuxI.mjs +7 -0
- package/dist/bin/Latch-BSlIwuxI.mjs.map +1 -0
- package/dist/bin/{McpClient-DMfHHEx3.mjs → McpClient-C7ctqJWo.mjs} +4 -5
- package/dist/bin/{McpClient-DMfHHEx3.mjs.map → McpClient-C7ctqJWo.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-DRycCEdr.mjs → OutputFormatter-DXej05JW.mjs} +8 -13
- package/dist/bin/{OutputFormatter-DRycCEdr.mjs.map → OutputFormatter-DXej05JW.mjs.map} +1 -1
- package/dist/bin/{Schema-D4fxUgEU.mjs → Schema-CSQN_Zso.mjs} +754 -800
- package/dist/bin/Schema-CSQN_Zso.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-BcLFv9qz.mjs → SemanticSearch-BiwCnpKX.mjs} +241 -148
- package/dist/bin/SemanticSearch-BiwCnpKX.mjs.map +1 -0
- package/dist/bin/{Stream-i37nF1ep.mjs → Stream-Dwvj9X5X.mjs} +244 -120
- package/dist/bin/Stream-Dwvj9X5X.mjs.map +1 -0
- package/dist/bin/cli.mjs +5122 -15959
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/helpers-CljL9OKa.mjs +7157 -0
- package/dist/bin/helpers-CljL9OKa.mjs.map +1 -0
- package/dist/bin/index.min-ClUfQ5ji.mjs +3782 -0
- package/dist/bin/index.min-ClUfQ5ji.mjs.map +1 -0
- package/dist/bin/{rolldown-runtime-zY4HT0JA.mjs → rolldown-runtime-5zChB7MF.mjs} +15 -3
- package/dist/bin/server-HlLriZxF.mjs +319 -0
- package/dist/bin/server-HlLriZxF.mjs.map +1 -0
- package/dist/bin/{turndown.cjs-LntFxFyd.mjs → turndown.cjs-C2WBxeA-.mjs} +56 -110
- package/dist/bin/{turndown.cjs-LntFxFyd.mjs.map → turndown.cjs-C2WBxeA-.mjs.map} +1 -1
- package/dist/bin/types-LcwjLVkt.mjs +5260 -0
- package/dist/bin/types-LcwjLVkt.mjs.map +1 -0
- package/dist/bin/upgrade-BSNjCnra.mjs +342 -0
- package/dist/bin/upgrade-BSNjCnra.mjs.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +15 -13
- package/src/Agent.ts +7 -1
- package/src/AgentCallerConfig.test.ts +5 -3
- package/src/ClaudeAgent.test.ts +526 -0
- package/src/ClaudeAgent.ts +1113 -0
- package/src/Compaction.test.ts +2 -1
- package/src/CompactionTokens.test.ts +15 -11
- package/src/ModelLayer.test.ts +4 -0
- package/src/ModelLayer.ts +21 -15
- package/src/ModelsRepo.test.ts +69 -3
- package/src/ModelsRepo.ts +24 -8
- package/src/cli.ts +4 -0
- package/src/index.ts +5 -0
- package/dist/bin/Effect-4B1lzxy4.mjs.map +0 -1
- package/dist/bin/Schema-D4fxUgEU.mjs.map +0 -1
- package/dist/bin/SemanticSearch-BcLFv9qz.mjs.map +0 -1
- package/dist/bin/Stream-i37nF1ep.mjs.map +0 -1
- package/dist/bin/index.min-Bkz7vIWv.mjs +0 -3300
- package/dist/bin/index.min-Bkz7vIWv.mjs.map +0 -1
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const normalizeNonEmpty = (n) => Math.max(1, normalize(n));
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/String.js
|
|
1
|
+
import { $ as ignoreCause, $o as some, $s as random, $t as tapError$2, A as ensuring$2, Aa as isReadonlyArrayNonEmpty, Ac as constant, At as raceFirst, Bi as findRecoverableError, Bn as doneExitFromCause, Ci as andThen$1, Cs as exitFailCause, Dc as constTrue, Ds as withFiber$1, E as contextWith, Es as makePrimitive, Et as promise, Fa as map$3, Fi as fiberInterrupt, Fs as toJson, G as forkChild, Gn as nextPow2, Ha as headUnsafe, Hn as isDoneCause, Hr as addFinalizer, Ht as scopedWith, Ii as fiberInterruptAll, It as runForkWith, J as forkScoped, Ja as isFailure, Jo as map$4, Jr as makeUnsafe$1, Jt as succeedSome, Ko as isSome, Kr as forkUnsafe, Kt as succeed$3, L as flatMap$2, La as of, Li as fiberInterruptAllAs, Lt as runPromiseWith, M as fail$3, Mi as exitVoid, N as failCause$3, Na as lastNonEmpty, Nc as identity, Ni as exitZipRight, O as die$3, Oa as isArrayNonEmpty, Ot as provideContext$2, Pi as fiberAwait, Qa as succeed$5, Qi as onExitUnsafe, R as flatMapEager, Ri as fiberJoin, Sc as isTagged, So as get$1, Ss as exitFail, St as onInterrupt, T as context, Ta as fromIterable$1, Ti as callback$2, Ts as isExit, U as forEach, Ua as fail$4, Ui as getCurrentFiber, Un as matchEffect, Ur as addFinalizerExit, V as fnUntraced, Vi as flatMap$3, Vn as filterDone, Vr as Scope, W as forever, Wr as close, Xo as none, Xt as sync, Ya as isSuccess$1, Yn as Done$1, Yr as provide, Yt as suspend$2, Z as gen, Zi as onExitPrimitive, Zt as tap$1, _i as isSuccess, _s as PipeInspectableProto, a as andThen, aa as sync$1, bc as isString$1, bs as causeFail, bt as onExit$2, c as as, ca as void_$1, cr as fromReasons, di as fail$5, dn as void_, ea as scope, ei as doneUnsafe, eo as normalize, et as interrupt$2, fi as failCause$4, fn as when, fr as isCause, ft as mapError$2, gi as isFailure$1, gt as matchCauseEffect, hi as isExit$1, hs as Done, ia as suspend$3, ic as hasProperty, ir as done, it as logError, j as exit, jc as dual, ji as exitInterrupt$1, kc as constVoid, kt as provideService$2, li as asVoidAll, lt as map$2, m as catchCause$2, mi as interrupt$1, mn as withFiber, mr as isDone, na as succeed$4, ni as interruptWith, oa as uninterruptibleMask, on as uninterruptible, p as callback$1, pn as whileLoop, q as forkIn, qs as symbol, qt as succeedNone$1, ra as succeedNone, rc as symbol$1, rn as tryPromise, rr as die$2, si as makeUnsafe$2, t as acquireRelease, ta as scopeAddFinalizer, to as normalizeNonEmpty, u as asVoid, ui as die$4, ur as hasInterruptsOnly, vi as succeed$2, vn as yieldNow, vt as never, w as catch_$2, wi as asSome, wr as squash, ws as exitSucceed, xo as empty$2, xs as evaluate, xt as onExitPrimitive$1, yi as void_$2, ys as args, yt as onError, z as flatten$2, zc as pipeArguments, zi as fiberRunIn, zn as catchDone } from "./Effect-DNYYQ84C.mjs";
|
|
2
|
+
import { n as makeUnsafe$3, t as make$5 } from "./Latch-BSlIwuxI.mjs";
|
|
3
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/String.js
|
|
7
4
|
const String = globalThis.String;
|
|
8
5
|
const isString = isString$1;
|
|
9
6
|
const toLowerCase = (self) => self.toLowerCase();
|
|
10
7
|
const camelToSnake = (self) => self.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
11
|
-
|
|
12
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Fiber.js
|
|
8
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Fiber.js
|
|
13
9
|
const await_ = fiberAwait;
|
|
14
10
|
const join = fiberJoin;
|
|
15
11
|
const interrupt = fiberInterrupt;
|
|
16
|
-
const interruptAs = fiberInterruptAs;
|
|
17
12
|
const interruptAll = fiberInterruptAll;
|
|
18
13
|
const interruptAllAs = fiberInterruptAllAs;
|
|
19
14
|
const getCurrent = getCurrentFiber;
|
|
20
15
|
const runIn = fiberRunIn;
|
|
21
|
-
|
|
22
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Latch.js
|
|
23
|
-
const makeUnsafe$1 = makeLatchUnsafe;
|
|
24
|
-
const make$5 = makeLatch;
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableRef.js
|
|
16
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/MutableRef.js
|
|
27
17
|
const TypeId$5 = "~effect/MutableRef";
|
|
28
18
|
const MutableRefProto = {
|
|
29
19
|
[TypeId$5]: TypeId$5,
|
|
30
20
|
...PipeInspectableProto,
|
|
21
|
+
[symbol](that) {
|
|
22
|
+
return this === that;
|
|
23
|
+
},
|
|
24
|
+
[symbol$1]() {
|
|
25
|
+
return random(this);
|
|
26
|
+
},
|
|
31
27
|
toJSON() {
|
|
32
28
|
return {
|
|
33
29
|
_id: "MutableRef",
|
|
@@ -46,8 +42,7 @@ const set = dual(2, (self, value) => {
|
|
|
46
42
|
return self;
|
|
47
43
|
});
|
|
48
44
|
const update = dual(2, (self, f) => set(self, f(get(self))));
|
|
49
|
-
|
|
50
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableList.js
|
|
45
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/MutableList.js
|
|
51
46
|
const Empty = Symbol.for("effect/MutableList/Empty");
|
|
52
47
|
const make$3 = () => ({
|
|
53
48
|
head: void 0,
|
|
@@ -88,7 +83,7 @@ const prepend = (self, message) => {
|
|
|
88
83
|
if (!self.tail) self.tail = self.head;
|
|
89
84
|
self.length++;
|
|
90
85
|
};
|
|
91
|
-
const appendAll = (self, messages) => appendAllUnsafe(self,
|
|
86
|
+
const appendAll = (self, messages) => appendAllUnsafe(self, Array.from(messages), true);
|
|
92
87
|
const appendAllUnsafe = (self, messages, mutable = false) => {
|
|
93
88
|
if (messages.length === 0) return 0;
|
|
94
89
|
const chunk = {
|
|
@@ -170,11 +165,10 @@ const filter$1 = (self, f) => {
|
|
|
170
165
|
self.length = array.length;
|
|
171
166
|
};
|
|
172
167
|
const remove = (self, value) => filter$1(self, (v) => v !== value);
|
|
173
|
-
|
|
174
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/PubSub.js
|
|
168
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/PubSub.js
|
|
175
169
|
const TypeId$4 = "~effect/PubSub";
|
|
176
170
|
const SubscriptionTypeId = "~effect/PubSub/Subscription";
|
|
177
|
-
const make$2 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$
|
|
171
|
+
const make$2 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$1(), makeUnsafe$3(false), make$4(false), options.strategy(), make$4(none())));
|
|
178
172
|
const bounded$1 = (capacity) => make$2({
|
|
179
173
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
180
174
|
strategy: () => new BackPressureStrategy()
|
|
@@ -183,7 +177,7 @@ const dropping = (capacity) => make$2({
|
|
|
183
177
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
184
178
|
strategy: () => new DroppingStrategy()
|
|
185
179
|
});
|
|
186
|
-
const sliding = (capacity) => make$2({
|
|
180
|
+
const sliding$1 = (capacity) => make$2({
|
|
187
181
|
atomicPubSub: () => makeAtomicBounded(capacity),
|
|
188
182
|
strategy: () => new SlidingStrategy()
|
|
189
183
|
});
|
|
@@ -288,7 +282,7 @@ const pollForItem = (self) => callback$1((resume) => {
|
|
|
288
282
|
}
|
|
289
283
|
return resume(succeed$3(self.ended.current.value));
|
|
290
284
|
}
|
|
291
|
-
const deferred = makeUnsafe$
|
|
285
|
+
const deferred = makeUnsafe$2();
|
|
292
286
|
let set = self.subscribers.get(self.subscription);
|
|
293
287
|
if (!set) {
|
|
294
288
|
set = new Set();
|
|
@@ -312,7 +306,7 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
|
|
|
312
306
|
set.delete(pollers);
|
|
313
307
|
if (set.size === 0) subscribers.delete(subscription);
|
|
314
308
|
};
|
|
315
|
-
const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$3(), makeUnsafe$
|
|
309
|
+
const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$3(), makeUnsafe$3(false), make$4(false), strategy, pubsub.replayWindow(), ended);
|
|
316
310
|
var BoundedPubSubArb = class {
|
|
317
311
|
array;
|
|
318
312
|
replayIndices;
|
|
@@ -922,7 +916,7 @@ var BackPressureStrategy = class {
|
|
|
922
916
|
handleSurplus(pubsub, subscribers, elements, isShutdown, ended) {
|
|
923
917
|
return callback$1((resume) => {
|
|
924
918
|
if (isSome(ended.current)) return resume(succeed$3(false));
|
|
925
|
-
const deferred = makeUnsafe$
|
|
919
|
+
const deferred = makeUnsafe$2();
|
|
926
920
|
this.offerUnsafe(elements, deferred);
|
|
927
921
|
this.onPubSubEmptySpaceUnsafe(pubsub, subscribers);
|
|
928
922
|
this.completeSubscribersUnsafe(pubsub, subscribers);
|
|
@@ -941,11 +935,11 @@ var BackPressureStrategy = class {
|
|
|
941
935
|
const publisher = take$3(this.publishers);
|
|
942
936
|
if (publisher === Empty) keepPolling = false;
|
|
943
937
|
else {
|
|
944
|
-
const [value, deferred] = publisher;
|
|
938
|
+
const [value, deferred, last] = publisher;
|
|
945
939
|
const published = pubsub.publish(value);
|
|
946
|
-
if (published
|
|
947
|
-
else if (!published) prepend(this.publishers, publisher);
|
|
940
|
+
if (!published) prepend(this.publishers, publisher);
|
|
948
941
|
this.completeSubscribersUnsafe(pubsub, subscribers);
|
|
942
|
+
if (published && last) doneUnsafe(deferred, succeed$2(true));
|
|
949
943
|
}
|
|
950
944
|
}
|
|
951
945
|
}
|
|
@@ -1082,8 +1076,12 @@ var ReplayBuffer = class {
|
|
|
1082
1076
|
next: null
|
|
1083
1077
|
};
|
|
1084
1078
|
this.tail = this.tail.next;
|
|
1085
|
-
if (this.size === this.capacity)
|
|
1086
|
-
|
|
1079
|
+
if (this.size === this.capacity) {
|
|
1080
|
+
const dropped = this.head;
|
|
1081
|
+
this.head = dropped.next;
|
|
1082
|
+
dropped.next = null;
|
|
1083
|
+
dropped.value = AbsentValue;
|
|
1084
|
+
} else this.size += 1;
|
|
1087
1085
|
return index;
|
|
1088
1086
|
}
|
|
1089
1087
|
offerAll(as) {
|
|
@@ -1156,8 +1154,7 @@ const emptyReplayWindow = {
|
|
|
1156
1154
|
takeAll: () => [],
|
|
1157
1155
|
close: () => void 0
|
|
1158
1156
|
};
|
|
1159
|
-
|
|
1160
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Queue.js
|
|
1157
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Queue.js
|
|
1161
1158
|
const TypeId$3 = "~effect/Queue";
|
|
1162
1159
|
const EnqueueTypeId = "~effect/Queue/Enqueue";
|
|
1163
1160
|
const DequeueTypeId = "~effect/Queue/Dequeue";
|
|
@@ -1194,6 +1191,10 @@ const make$1 = (options) => withFiber$1((fiber) => {
|
|
|
1194
1191
|
return succeed$4(self);
|
|
1195
1192
|
});
|
|
1196
1193
|
const bounded = (capacity) => make$1({ capacity });
|
|
1194
|
+
const sliding = (capacity) => make$1({
|
|
1195
|
+
capacity,
|
|
1196
|
+
strategy: "sliding"
|
|
1197
|
+
});
|
|
1197
1198
|
const unbounded = () => make$1();
|
|
1198
1199
|
const offer = dual(2, (self, message) => suspend$3(() => offerUnsafe(self, message) ? exitTrue : self.state._tag === "Open" && self.strategy === "suspend" ? offerOrWait(self, message) : exitFalse));
|
|
1199
1200
|
const offerUnsafe = (self, message) => {
|
|
@@ -1420,20 +1421,36 @@ const finalize = (self, exit) => {
|
|
|
1420
1421
|
for (const awaiter of openState.awaiters) awaiter(exit);
|
|
1421
1422
|
openState.awaiters.clear();
|
|
1422
1423
|
};
|
|
1423
|
-
|
|
1424
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Semaphore.js
|
|
1424
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Semaphore.js
|
|
1425
1425
|
const makeUnsafe = (permits) => new SemaphoreImpl(permits);
|
|
1426
|
-
const
|
|
1427
|
-
if (self.free
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1426
|
+
const firstAvailableWaiter = (self) => {
|
|
1427
|
+
for (const waiter of self.waiters) if (waiter.permits <= self.free) return waiter;
|
|
1428
|
+
};
|
|
1429
|
+
const takePermits = (self, n, onAcquire, restore = identity) => withFiber$1((fiber) => {
|
|
1430
|
+
if (self.free >= n && firstAvailableWaiter(self) === void 0) {
|
|
1431
|
+
self.taken += n;
|
|
1432
|
+
return onAcquire();
|
|
1433
|
+
}
|
|
1434
|
+
const waiter = {
|
|
1435
|
+
permits: n,
|
|
1436
|
+
resume: void 0
|
|
1432
1437
|
};
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1438
|
+
const remove = () => {
|
|
1439
|
+
if (self.waiters.delete(waiter)) self.releaseUnsafe(fiber, 0);
|
|
1440
|
+
};
|
|
1441
|
+
self.waiters.add(waiter);
|
|
1442
|
+
onExitUnsafe(fiber, remove);
|
|
1443
|
+
const wait = restore(callback$2((resume) => {
|
|
1444
|
+
if (firstAvailableWaiter(self) === waiter) resume(void_$1);
|
|
1445
|
+
else waiter.resume = resume;
|
|
1446
|
+
}));
|
|
1447
|
+
const loop = flatMap$3(wait, () => {
|
|
1448
|
+
if (firstAvailableWaiter(self) !== waiter) return loop;
|
|
1449
|
+
self.taken += n;
|
|
1450
|
+
remove();
|
|
1451
|
+
return onAcquire();
|
|
1436
1452
|
});
|
|
1453
|
+
return loop;
|
|
1437
1454
|
});
|
|
1438
1455
|
var SemaphoreImpl = class {
|
|
1439
1456
|
waiters = new Set();
|
|
@@ -1446,12 +1463,10 @@ var SemaphoreImpl = class {
|
|
|
1446
1463
|
return this.permits - this.taken;
|
|
1447
1464
|
}
|
|
1448
1465
|
take(n) {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
});
|
|
1454
|
-
return take;
|
|
1466
|
+
return takePermits(this, n, () => succeed$4(n));
|
|
1467
|
+
}
|
|
1468
|
+
takeScoped(n) {
|
|
1469
|
+
return uninterruptibleMask((restore) => flatMap$3(scope, (scope) => takePermits(this, n, () => scopeAddFinalizer(scope, this.release(n)), restore)));
|
|
1455
1470
|
}
|
|
1456
1471
|
takeIfAvailable(n) {
|
|
1457
1472
|
return suspend$3(() => {
|
|
@@ -1463,9 +1478,13 @@ var SemaphoreImpl = class {
|
|
|
1463
1478
|
releaseUnsafe(fiber, n) {
|
|
1464
1479
|
this.taken -= n;
|
|
1465
1480
|
if (this.waiters.size > 0) fiber.currentDispatcher.scheduleTask(() => {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1481
|
+
let remaining = this.free;
|
|
1482
|
+
for (const waiter of Array.from(this.waiters)) {
|
|
1483
|
+
if (!this.waiters.has(waiter) || waiter.permits > remaining) continue;
|
|
1484
|
+
remaining -= waiter.permits;
|
|
1485
|
+
const resume = waiter.resume;
|
|
1486
|
+
waiter.resume = void 0;
|
|
1487
|
+
resume?.(void_$1);
|
|
1469
1488
|
}
|
|
1470
1489
|
}, 0);
|
|
1471
1490
|
return this.free;
|
|
@@ -1485,19 +1504,9 @@ var SemaphoreImpl = class {
|
|
|
1485
1504
|
return withFiber$1((fiber) => succeed$4(this.releaseUnsafe(fiber, this.taken)));
|
|
1486
1505
|
}
|
|
1487
1506
|
withPermits(n) {
|
|
1488
|
-
return (self) => uninterruptibleMask((restore) => {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
const wait = waitForPermits(this, n, void_$1);
|
|
1492
|
-
return flatMap$3(restore(wait), () => acquire);
|
|
1493
|
-
}
|
|
1494
|
-
this.taken += n;
|
|
1495
|
-
return onExitPrimitive(restore(self), () => {
|
|
1496
|
-
this.releaseUnsafe(getCurrentFiber(), n);
|
|
1497
|
-
}, true);
|
|
1498
|
-
});
|
|
1499
|
-
return acquire;
|
|
1500
|
-
});
|
|
1507
|
+
return (self) => uninterruptibleMask((restore) => takePermits(this, n, () => onExitPrimitive(restore(self), () => {
|
|
1508
|
+
this.releaseUnsafe(getCurrentFiber(), n);
|
|
1509
|
+
}, true), restore));
|
|
1501
1510
|
}
|
|
1502
1511
|
withPermit = this.withPermits(1);
|
|
1503
1512
|
withPermitsIfAvailable(n) {
|
|
@@ -1511,11 +1520,9 @@ var SemaphoreImpl = class {
|
|
|
1511
1520
|
}
|
|
1512
1521
|
};
|
|
1513
1522
|
const make = (permits) => sync$1(() => new SemaphoreImpl(permits));
|
|
1514
|
-
|
|
1515
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Take.js
|
|
1523
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Take.js
|
|
1516
1524
|
const toPull = (take) => isExit$1(take) ? isSuccess(take) ? done(take.value) : take : succeed$3(take);
|
|
1517
|
-
|
|
1518
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Channel.js
|
|
1525
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Channel.js
|
|
1519
1526
|
const TypeId$2 = "~effect/Channel";
|
|
1520
1527
|
const isChannel = (u) => hasProperty(u, TypeId$2);
|
|
1521
1528
|
const ChannelProto = {
|
|
@@ -1532,7 +1539,7 @@ const ChannelProto = {
|
|
|
1532
1539
|
};
|
|
1533
1540
|
const fromTransform = (transform) => {
|
|
1534
1541
|
const self = Object.create(ChannelProto);
|
|
1535
|
-
self.transform = (upstream, scope) => catchCause$
|
|
1542
|
+
self.transform = (upstream, scope) => catchCause$2(transform(upstream, scope), (cause) => succeed$3(failCause$3(cause)));
|
|
1536
1543
|
return self;
|
|
1537
1544
|
};
|
|
1538
1545
|
const transformPull$1 = (self, f) => fromTransform((upstream, scope) => flatMap$2(toTransform(self)(upstream, scope), (pull) => f(pull, scope)));
|
|
@@ -1548,22 +1555,29 @@ const DefaultChunkSize = 4096;
|
|
|
1548
1555
|
const asyncQueue = (scope, f, options) => make$1({
|
|
1549
1556
|
capacity: options?.bufferSize,
|
|
1550
1557
|
strategy: options?.strategy
|
|
1551
|
-
}).pipe(tap$1((queue) => addFinalizer(scope, shutdown(queue))), tap$1((queue) => provide(f(queue), scope).pipe(catchCause$
|
|
1558
|
+
}).pipe(tap$1((queue) => addFinalizer(scope, shutdown(queue))), tap$1((queue) => provide(f(queue), scope).pipe(catchCause$2((cause) => failCause$2(queue, cause)), forkIn(scope, { startImmediately: true }))));
|
|
1552
1559
|
const callbackArray = (f, options) => fromTransform((_, scope) => map$2(asyncQueue(scope, f, options), takeAll));
|
|
1553
1560
|
const suspend$1 = (evaluate) => fromTransform((upstream, scope) => suspend$2(() => toTransform(evaluate())(upstream, scope)));
|
|
1561
|
+
const fromIterator = (iterator) => fromPull$1(sync(() => {
|
|
1562
|
+
const iter = iterator();
|
|
1563
|
+
return suspend$2(() => {
|
|
1564
|
+
const state = iter.next();
|
|
1565
|
+
return state.done ? done(state.value) : succeed$3(state.value);
|
|
1566
|
+
});
|
|
1567
|
+
}));
|
|
1554
1568
|
const fromIteratorArray = (iterator, chunkSize = DefaultChunkSize) => {
|
|
1555
1569
|
const size = normalizeNonEmpty(chunkSize);
|
|
1556
1570
|
return fromPull$1(sync(() => {
|
|
1557
1571
|
const iter = iterator();
|
|
1558
|
-
let done$
|
|
1572
|
+
let done$9 = none();
|
|
1559
1573
|
return suspend$2(() => {
|
|
1560
|
-
if (done$
|
|
1574
|
+
if (done$9._tag === "Some") return done(done$9.value);
|
|
1561
1575
|
const buffer = [];
|
|
1562
1576
|
while (buffer.length < size) {
|
|
1563
1577
|
const state = iter.next();
|
|
1564
1578
|
if (state.done) {
|
|
1565
1579
|
if (buffer.length === 0) return done(state.value);
|
|
1566
|
-
done$
|
|
1580
|
+
done$9 = some(state.value);
|
|
1567
1581
|
break;
|
|
1568
1582
|
}
|
|
1569
1583
|
buffer.push(state.value);
|
|
@@ -1579,13 +1593,14 @@ const fail$1 = (error) => fromPull$1(succeed$3(fail$3(error)));
|
|
|
1579
1593
|
const failCause$1 = (cause) => fromPull$1(failCause$3(cause));
|
|
1580
1594
|
const die$1 = (defect) => failCause$1(die$2(defect));
|
|
1581
1595
|
const fromEffect$1 = (effect) => fromPull$1(sync(() => {
|
|
1582
|
-
let done$
|
|
1596
|
+
let done$10 = false;
|
|
1583
1597
|
return suspend$2(() => {
|
|
1584
|
-
if (done$
|
|
1585
|
-
done$
|
|
1598
|
+
if (done$10) return done();
|
|
1599
|
+
done$10 = true;
|
|
1586
1600
|
return effect;
|
|
1587
1601
|
});
|
|
1588
1602
|
}));
|
|
1603
|
+
const fromEffectDrain = (effect) => fromPull$1(flatMap$2(effect, () => done()));
|
|
1589
1604
|
const fromEffectTake = (effect) => fromPull$1(succeed$3(flatMap$2(effect, toPull)));
|
|
1590
1605
|
const fromQueueArray = (queue) => fromPull$1(succeed$3(takeAll(queue)));
|
|
1591
1606
|
const fromSubscriptionArray = (subscription) => fromPull$1(succeed$3(onInterrupt(takeAll$1(subscription), () => done())));
|
|
@@ -1607,13 +1622,13 @@ const readableStreamToPullUnsafe = (options) => {
|
|
|
1607
1622
|
catch: options.onError
|
|
1608
1623
|
}), {
|
|
1609
1624
|
onFailure: (cause) => exit.current ?? failCause$3(cause),
|
|
1610
|
-
onSuccess: ({ done: done$
|
|
1625
|
+
onSuccess: ({ done: done$12, value }) => {
|
|
1611
1626
|
if (exit.current) return exit.current;
|
|
1612
|
-
return done$
|
|
1627
|
+
return done$12 ? done() : succeed$3(of(value));
|
|
1613
1628
|
}
|
|
1614
1629
|
});
|
|
1615
1630
|
});
|
|
1616
|
-
return as(addFinalizer(options.scope, options.releaseLockOnEnd ? sync(() => reader.releaseLock()) : promise(() => reader.cancel().catch(constVoid))), pull);
|
|
1631
|
+
return as(addFinalizer(options.scope, options.releaseLockOnEnd ? sync(() => reader.releaseLock()) : promise(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring$2(sync(() => reader.releaseLock())))), pull);
|
|
1617
1632
|
};
|
|
1618
1633
|
const fromAsyncIterable$1 = (iterable, onError) => fromTransform(fnUntraced(function* (_, scope) {
|
|
1619
1634
|
const iter = iterable[Symbol.asyncIterator]();
|
|
@@ -1646,7 +1661,7 @@ const mapEffectSequential = (self, f) => fromTransform((upstream, scope) => {
|
|
|
1646
1661
|
const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
|
|
1647
1662
|
let i = 0;
|
|
1648
1663
|
const pull = yield* toTransform(self)(upstream, scope);
|
|
1649
|
-
const concurrencyN = options.concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : options.concurrency;
|
|
1664
|
+
const concurrencyN = options.concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.min(options.concurrency, Number.MAX_SAFE_INTEGER);
|
|
1650
1665
|
const queue = yield* bounded(0);
|
|
1651
1666
|
yield* addFinalizer(forkedScope, shutdown(queue));
|
|
1652
1667
|
const runFork = runForkWith(yield* context());
|
|
@@ -1662,11 +1677,11 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
|
|
|
1662
1677
|
const index = i++;
|
|
1663
1678
|
trackFiber(runFork(handle(suspend$2(() => f(value, index)))));
|
|
1664
1679
|
return void_;
|
|
1665
|
-
}), forever({ disableYield: true }), catchCause$
|
|
1680
|
+
}), forever({ disableYield: true }), catchCause$2((cause) => semaphore.withPermits(concurrencyN - 1)(failCause$2(queue, cause))), forkIn(forkedScope));
|
|
1666
1681
|
} else {
|
|
1667
1682
|
const effects = yield* bounded(concurrencyN - 2);
|
|
1668
1683
|
yield* addFinalizer(forkedScope, shutdown(effects));
|
|
1669
|
-
yield* take$1(effects).pipe(flatten$
|
|
1684
|
+
yield* take$1(effects).pipe(flatten$2, flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$2((cause) => failCause$2(queue, cause)), forkIn(forkedScope));
|
|
1670
1685
|
let errorCause;
|
|
1671
1686
|
const onExit = (exit) => {
|
|
1672
1687
|
if (exit._tag === "Success") return;
|
|
@@ -1680,7 +1695,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
|
|
|
1680
1695
|
trackFiber(fiber);
|
|
1681
1696
|
fiber.addObserver(onExit);
|
|
1682
1697
|
return offer(effects, join(fiber));
|
|
1683
|
-
}), forever({ disableYield: true }), catchCause$
|
|
1698
|
+
}), forever({ disableYield: true }), catchCause$2((cause) => offer(effects, failCause$4(cause)).pipe(andThen(failCause$2(effects, cause)))), forkIn(forkedScope));
|
|
1684
1699
|
}
|
|
1685
1700
|
return take$1(queue);
|
|
1686
1701
|
}));
|
|
@@ -1705,6 +1720,7 @@ const flatMapSequential = (self, f) => fromTransform((upstream, scope) => map$2(
|
|
|
1705
1720
|
return suspend$2(() => childPull ?? makePull);
|
|
1706
1721
|
}));
|
|
1707
1722
|
const flatMapConcurrent = (self, f, options) => self.pipe(map$1(f), mergeAll$1(options));
|
|
1723
|
+
const flatten$1 = (channels) => flatMap$1(channels, identity);
|
|
1708
1724
|
const flattenArray$1 = (self) => transformPull$1(self, (pull) => {
|
|
1709
1725
|
let array;
|
|
1710
1726
|
let index = 0;
|
|
@@ -1740,10 +1756,10 @@ const filterMapArray = dual(2, (self, filter) => transformPull$1(self, (pull) =>
|
|
|
1740
1756
|
}
|
|
1741
1757
|
return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
|
|
1742
1758
|
}))));
|
|
1743
|
-
const catchCause = dual(2, (self, f) => fromTransform((upstream, scope) => {
|
|
1759
|
+
const catchCause$1 = dual(2, (self, f) => fromTransform((upstream, scope) => {
|
|
1744
1760
|
let forkedScope = forkUnsafe(scope);
|
|
1745
1761
|
return map$2(toTransform(self)(upstream, forkedScope), (pull) => {
|
|
1746
|
-
let currentPull = pull.pipe(catchCause$
|
|
1762
|
+
let currentPull = pull.pipe(catchCause$2((cause) => {
|
|
1747
1763
|
if (isDoneCause(cause)) return failCause$3(cause);
|
|
1748
1764
|
const toClose = forkedScope;
|
|
1749
1765
|
forkedScope = forkUnsafe(scope);
|
|
@@ -1755,11 +1771,12 @@ const catchCause = dual(2, (self, f) => fromTransform((upstream, scope) => {
|
|
|
1755
1771
|
return suspend$2(() => currentPull);
|
|
1756
1772
|
});
|
|
1757
1773
|
}));
|
|
1758
|
-
const catchCauseFilter = dual(3, (self, filter, f) => catchCause(self, (cause) => {
|
|
1774
|
+
const catchCauseFilter = dual(3, (self, filter, f) => catchCause$1(self, (cause) => {
|
|
1759
1775
|
const result = filter(cause);
|
|
1760
1776
|
return isFailure(result) ? failCause$1(result.failure) : f(result.success, cause);
|
|
1761
1777
|
}));
|
|
1762
|
-
const catch_$1 = dual(2, (self, f) => catchCauseFilter(self,
|
|
1778
|
+
const catch_$1 = dual(2, (self, f) => catchCauseFilter(self, findRecoverableError, (e) => f(e)));
|
|
1779
|
+
const tapError$1 = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$3(tapError$2(pull, (err) => isDone(err) ? void_ : asVoid(f(err))))));
|
|
1763
1780
|
const catchIf$1 = dual((args) => isChannel(args[0]), (self, predicate, f, orElse) => catch_$1(self, (err) => {
|
|
1764
1781
|
return predicate(err) ? f(err) : orElse ? orElse(err) : fail$1(err);
|
|
1765
1782
|
}));
|
|
@@ -1775,13 +1792,13 @@ const catchReason$1 = dual((args) => isChannel(args[0]), (self, errorTag, reason
|
|
|
1775
1792
|
}
|
|
1776
1793
|
return fail$1(error);
|
|
1777
1794
|
}));
|
|
1778
|
-
const mapError$1 = dual(2, (self, f) =>
|
|
1795
|
+
const mapError$1 = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$3(mapError$2(pull, (err) => isDone(err) ? err : f(err)))));
|
|
1779
1796
|
const orDie$1 = (self) => catch_$1(self, die$1);
|
|
1780
1797
|
const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: switch_ = false }) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
|
|
1781
1798
|
const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency);
|
|
1782
1799
|
const semaphore = switch_ ? void 0 : makeUnsafe(concurrencyN);
|
|
1783
1800
|
const doneLatch = yield* make$5(true);
|
|
1784
|
-
const fibers = new
|
|
1801
|
+
const fibers = new Map();
|
|
1785
1802
|
const queue = yield* bounded(bufferSize);
|
|
1786
1803
|
yield* addFinalizer(forkedScope, shutdown(queue));
|
|
1787
1804
|
const pull = yield* toTransform(channels)(upstream, scope);
|
|
@@ -1799,10 +1816,11 @@ const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: sw
|
|
|
1799
1816
|
const childScope = forkUnsafe(forkedScope);
|
|
1800
1817
|
const childPull = yield* toTransform(channel)(upstream, childScope);
|
|
1801
1818
|
while (fibers.size >= concurrencyN) {
|
|
1802
|
-
const fiber = headUnsafe(fibers);
|
|
1819
|
+
const [fiber, fiberScope] = headUnsafe(fibers);
|
|
1803
1820
|
fibers.delete(fiber);
|
|
1804
1821
|
if (fibers.size === 0) yield* doneLatch.open;
|
|
1805
1822
|
yield* interrupt(fiber);
|
|
1823
|
+
yield* ignoreCause(close(fiberScope, interrupt$1()));
|
|
1806
1824
|
}
|
|
1807
1825
|
const fiber = yield* childPull.pipe(tap$1(() => yieldNow), flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), onError(fnUntraced(function* (cause) {
|
|
1808
1826
|
const exit$1 = doneExitFromCause(cause);
|
|
@@ -1815,9 +1833,9 @@ const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: sw
|
|
|
1815
1833
|
if (fibers.size === 0) yield* doneLatch.open;
|
|
1816
1834
|
})), forkChild);
|
|
1817
1835
|
doneLatch.closeUnsafe();
|
|
1818
|
-
fibers.
|
|
1836
|
+
fibers.set(fiber, childScope);
|
|
1819
1837
|
}
|
|
1820
|
-
}).pipe(catchCause$
|
|
1838
|
+
}).pipe(catchCause$2((cause) => {
|
|
1821
1839
|
const halt = filterDone(cause);
|
|
1822
1840
|
if (isSuccess$1(halt)) return doneLatch.whenOpen(failCause$2(queue, cause));
|
|
1823
1841
|
return failCause$2(queue, cause);
|
|
@@ -1847,10 +1865,11 @@ const merge$1 = dual((args) => isChannel(args[0]) && isChannel(args[1]), (left,
|
|
|
1847
1865
|
yield* runSide("right", right, forkUnsafe(forkedScope));
|
|
1848
1866
|
return take$1(queue);
|
|
1849
1867
|
})));
|
|
1868
|
+
const mergeEffect$1 = dual(2, (self, effect) => merge$1(self, fromEffectDrain(effect), { haltStrategy: "left" }));
|
|
1850
1869
|
const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
|
|
1851
1870
|
let stringBuilder = "";
|
|
1852
1871
|
let midCRLF = false;
|
|
1853
|
-
let done$
|
|
1872
|
+
let done$11 = none();
|
|
1854
1873
|
function splitLinesArray(chunk) {
|
|
1855
1874
|
const chunkBuilder = [];
|
|
1856
1875
|
function pushLine(segment) {
|
|
@@ -1895,12 +1914,12 @@ const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
|
|
|
1895
1914
|
return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null;
|
|
1896
1915
|
}
|
|
1897
1916
|
const pullOrFlush = suspend$2(() => {
|
|
1898
|
-
if (done$
|
|
1917
|
+
if (done$11._tag === "Some") return done(done$11.value);
|
|
1899
1918
|
return matchEffect(upstream, {
|
|
1900
1919
|
onSuccess: loop,
|
|
1901
1920
|
onFailure: failCause$3,
|
|
1902
1921
|
onDone: (leftover) => {
|
|
1903
|
-
done$
|
|
1922
|
+
done$11 = some(leftover);
|
|
1904
1923
|
if (stringBuilder.length > 0) {
|
|
1905
1924
|
const last = stringBuilder;
|
|
1906
1925
|
stringBuilder = "";
|
|
@@ -1917,7 +1936,22 @@ const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
|
|
|
1917
1936
|
}
|
|
1918
1937
|
return pullOrFlush;
|
|
1919
1938
|
}));
|
|
1939
|
+
const decodeText$1 = (encoding, options) => fromTransform((upstream, _scope) => sync(() => {
|
|
1940
|
+
const decoder = new TextDecoder(encoding, options);
|
|
1941
|
+
const streamOptions = { stream: true };
|
|
1942
|
+
let pull = upstream.pipe(map$2(map$3((bytes) => decoder.decode(bytes, streamOptions))), catchDone((leftover) => {
|
|
1943
|
+
pull = done(leftover);
|
|
1944
|
+
const last = decoder.decode();
|
|
1945
|
+
return last.length > 0 ? succeed$3(of(last)) : pull;
|
|
1946
|
+
}));
|
|
1947
|
+
return suspend$2(() => pull);
|
|
1948
|
+
}));
|
|
1920
1949
|
const pipeTo = dual(2, (self, that) => fromTransform((upstream, scope) => flatMap$2(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))));
|
|
1950
|
+
const isUpstreamFailure = (reason) => reason._tag === "Die" && isDone(reason.defect) && isCause(reason.defect.value);
|
|
1951
|
+
const hasUpstreamFailure = (cause) => cause.reasons.some(isUpstreamFailure);
|
|
1952
|
+
const upstreamFailureToDefect = (pull) => catchCause$2(pull, (cause) => isDoneCause(cause) ? failCause$3(cause) : die$3(Done$1(cause)));
|
|
1953
|
+
const unwrapUpstreamFailure = (cause) => hasUpstreamFailure(cause) ? fromReasons(cause.reasons.flatMap((reason) => isUpstreamFailure(reason) ? reason.defect.value.reasons : [reason])) : cause;
|
|
1954
|
+
const restoreUpstreamFailure = (effect) => catchCause$2(effect, (cause) => failCause$3(unwrapUpstreamFailure(cause)));
|
|
1921
1955
|
const unwrap$1 = (channel) => fromTransform((upstream, scope) => {
|
|
1922
1956
|
let pull;
|
|
1923
1957
|
return succeed$3(suspend$2(() => {
|
|
@@ -1925,13 +1959,13 @@ const unwrap$1 = (channel) => fromTransform((upstream, scope) => {
|
|
|
1925
1959
|
return channel.pipe(provide(scope), flatMap$2((channel) => toTransform(channel)(upstream, scope)), flatMap$2((pull_) => pull = pull_));
|
|
1926
1960
|
}));
|
|
1927
1961
|
});
|
|
1928
|
-
const
|
|
1929
|
-
const
|
|
1930
|
-
const ensuring$1 = dual(2, (self, finalizer) => onExit(self, (_) => finalizer));
|
|
1962
|
+
const scoped$1 = (self) => fromTransformBracket((upstream, scope, forkedScope) => map$2(provide(toTransform(self)(upstream, scope), forkedScope), provide(forkedScope)));
|
|
1963
|
+
const onExit$1 = dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen(toTransform(self)(upstream, scope)))));
|
|
1964
|
+
const ensuring$1 = dual(2, (self, finalizer) => onExit$1(self, (_) => finalizer));
|
|
1931
1965
|
const runWith = (self, f, onHalt) => suspend$2(() => {
|
|
1932
|
-
const scope = makeUnsafe$
|
|
1966
|
+
const scope = makeUnsafe$1();
|
|
1933
1967
|
const makePull = toTransform(self)(done(), scope);
|
|
1934
|
-
return catchDone(flatMap$2(makePull, f), onHalt ? onHalt : succeed$3).pipe(onExit$
|
|
1968
|
+
return catchDone(flatMap$2(makePull, f), onHalt ? onHalt : succeed$3).pipe(onExit$2((exit) => close(scope, exit)));
|
|
1935
1969
|
});
|
|
1936
1970
|
const provideContext$1 = dual(2, (self, context) => fromTransform((upstream, scope) => map$2(provideContext$2(toTransform(self)(upstream, scope), context), provideContext$2(context))));
|
|
1937
1971
|
const provideService$1 = dual(3, (self, key, service) => fromTransform((upstream, scope) => map$2(provideService$2(toTransform(self)(upstream, scope), key, service), provideService$2(key, service))));
|
|
@@ -1956,15 +1990,14 @@ const runFold$1 = dual(3, (self, initial, f) => suspend$2(() => {
|
|
|
1956
1990
|
}), () => succeed$3(state));
|
|
1957
1991
|
}));
|
|
1958
1992
|
const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
|
|
1959
|
-
const makePubSub = (options) => acquireRelease(options.capacity === "unbounded" ? unbounded$1(options) : options.strategy === "dropping" ? dropping(options) : options.strategy === "sliding" ? sliding(options) : bounded$1(options), shutdown$1);
|
|
1993
|
+
const makePubSub = (options) => acquireRelease(options.capacity === "unbounded" ? unbounded$1(options) : options.strategy === "dropping" ? dropping(options) : options.strategy === "sliding" ? sliding$1(options) : bounded$1(options), shutdown$1);
|
|
1960
1994
|
const runIntoPubSubArray = dual((args) => isChannel(args[0]), (self, pubsub, options) => runForEach$1(self, (value) => publishAll(pubsub, value)).pipe(options?.shutdownOnEnd === true ? ensuring$2(shutdown$1(pubsub)) : identity));
|
|
1961
1995
|
const toPubSubTake$1 = dual(2, fnUntraced(function* (self, options) {
|
|
1962
1996
|
const pubsub = yield* makePubSub(options);
|
|
1963
|
-
yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$
|
|
1997
|
+
yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$2((exit) => end$1(pubsub, exit)), forkScoped);
|
|
1964
1998
|
return pubsub;
|
|
1965
1999
|
}));
|
|
1966
|
-
|
|
1967
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/stream.js
|
|
2000
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/internal/stream.js
|
|
1968
2001
|
const TypeId$1 = "~effect/Stream";
|
|
1969
2002
|
const streamVariance = {
|
|
1970
2003
|
_R: identity,
|
|
@@ -1981,8 +2014,7 @@ Stream.prototype = {
|
|
|
1981
2014
|
}
|
|
1982
2015
|
};
|
|
1983
2016
|
const fromChannel$1 = (channel) => new Stream(channel);
|
|
1984
|
-
|
|
1985
|
-
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Stream.js
|
|
2017
|
+
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Stream.js
|
|
1986
2018
|
const TypeId = "~effect/Stream";
|
|
1987
2019
|
const isStream = (u) => hasProperty(u, TypeId);
|
|
1988
2020
|
const fromChannel = fromChannel$1;
|
|
@@ -1993,7 +2025,12 @@ const toChannel = (stream) => stream.channel;
|
|
|
1993
2025
|
const callback = (f, options) => fromChannel(callbackArray(f, options));
|
|
1994
2026
|
const empty = fromChannel(empty$1);
|
|
1995
2027
|
const succeed = (value) => fromChannel(succeed$1(of(value)));
|
|
1996
|
-
const suspend = (stream) =>
|
|
2028
|
+
const suspend = (stream) => {
|
|
2029
|
+
const suspended = fromChannel(suspend$1(() => stream().channel));
|
|
2030
|
+
suspendedStreams.set(suspended, stream);
|
|
2031
|
+
return suspended;
|
|
2032
|
+
};
|
|
2033
|
+
const suspendedStreams = new WeakMap();
|
|
1997
2034
|
const fail = (error) => fromChannel(fail$1(error));
|
|
1998
2035
|
const failCause = (cause) => fromChannel(failCause$1(cause));
|
|
1999
2036
|
const die = (defect) => fromChannel(die$1(defect));
|
|
@@ -2006,6 +2043,7 @@ const fromPubSubTake = (pubsub) => fromChannel(fromPubSubTake$1(pubsub));
|
|
|
2006
2043
|
const fromReadableStream = (options) => fromChannel(fromReadableStream$1(options));
|
|
2007
2044
|
const fromAsyncIterable = (iterable, onError) => fromChannel(fromAsyncIterableArray(iterable, onError));
|
|
2008
2045
|
const unwrap = (effect) => fromChannel(unwrap$1(map$2(effect, toChannel)));
|
|
2046
|
+
const scoped = (self) => fromChannel(scoped$1(self.channel));
|
|
2009
2047
|
const map = dual(2, (self, f) => suspend(() => {
|
|
2010
2048
|
let i = 0;
|
|
2011
2049
|
return fromChannel(map$1(self.channel, map$3((o) => f(o, i++))));
|
|
@@ -2017,12 +2055,44 @@ const tap = dual((args) => isStream(args[0]), (self, f, options) => mapEffect(se
|
|
|
2017
2055
|
const flatMap = dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray$1, flatMap$1((a) => f(a).channel, options), fromChannel));
|
|
2018
2056
|
const flatten = dual((args) => isStream(args[0]), (self, options) => flatMap(self, identity, options));
|
|
2019
2057
|
const flattenArray = (self) => fromChannel(flattenArray$1(self.channel));
|
|
2058
|
+
const drainFork = dual(2, (self, that) => mergeEffect(self, runDrain(that)));
|
|
2020
2059
|
const flattenIterable = (self) => flatMap(self, fromIterable);
|
|
2060
|
+
const concat = dual(2, (self, that) => {
|
|
2061
|
+
const stream = fromChannel(flatten$1(fromIterator(() => concatChannels(self, that))));
|
|
2062
|
+
concatParts.set(stream, [self, that]);
|
|
2063
|
+
return stream;
|
|
2064
|
+
});
|
|
2065
|
+
const concatParts = new WeakMap();
|
|
2066
|
+
function* concatChannels(self, that) {
|
|
2067
|
+
const stack = [that, self];
|
|
2068
|
+
while (stack.length > 0) {
|
|
2069
|
+
const stream = stack.pop();
|
|
2070
|
+
const parts = concatParts.get(stream);
|
|
2071
|
+
if (parts !== void 0) {
|
|
2072
|
+
stack.push(parts[1], parts[0]);
|
|
2073
|
+
continue;
|
|
2074
|
+
}
|
|
2075
|
+
const evaluate = suspendedStreams.get(stream);
|
|
2076
|
+
if (evaluate === void 0) {
|
|
2077
|
+
yield stream.channel;
|
|
2078
|
+
continue;
|
|
2079
|
+
}
|
|
2080
|
+
try {
|
|
2081
|
+
stack.push(evaluate());
|
|
2082
|
+
} catch (defect) {
|
|
2083
|
+
stack.push(die(defect));
|
|
2084
|
+
}
|
|
2085
|
+
yield empty$1;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2021
2088
|
const merge = dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel(merge$1(toChannel(self), toChannel(that), options)));
|
|
2089
|
+
const mergeEffect = dual(2, (self, effect) => self.channel.pipe(mergeEffect$1(effect), fromChannel));
|
|
2022
2090
|
const mergeAll = dual(2, (streams, options) => flatten(fromIterable(streams), options));
|
|
2023
2091
|
const filter = dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
|
|
2024
2092
|
const filterMap = dual(2, (self, filter) => fromChannel(filterMapArray(toChannel(self), filter)));
|
|
2093
|
+
const catchCause = dual(2, (self, f) => self.channel.pipe(catchCause$1((cause) => f(cause).channel), fromChannel));
|
|
2025
2094
|
const catch_ = dual(2, (self, f) => fromChannel(catch_$1(self.channel, (error) => f(error).channel)));
|
|
2095
|
+
const tapError = dual(2, (self, f) => self.channel.pipe(tapError$1(f), fromChannel));
|
|
2026
2096
|
const catchIf = dual((args) => isStream(args[0]), (self, predicate, f, orElse) => fromChannel(catchIf$1(toChannel(self), predicate, (e) => f(e).channel, orElse && ((e) => orElse(e).channel))));
|
|
2027
2097
|
const catchFilter = dual((args) => isStream(args[0]), (self, filter, f, orElse) => fromChannel(catchFilter$1(toChannel(self), filter, (e) => f(e).channel, orElse && ((e) => orElse(e).channel))));
|
|
2028
2098
|
const catchTags = dual((args) => isStream(args[0]), (self, cases, orElse) => {
|
|
@@ -2083,7 +2153,7 @@ const drop = dual(2, (self, n) => {
|
|
|
2083
2153
|
}));
|
|
2084
2154
|
});
|
|
2085
2155
|
const transduce = dual(2, (self, sink) => transformPull(self, (upstream, scope) => sync(() => {
|
|
2086
|
-
let done$
|
|
2156
|
+
let done$8;
|
|
2087
2157
|
let leftover;
|
|
2088
2158
|
const upstreamWithLeftover = suspend$2(() => {
|
|
2089
2159
|
if (leftover !== void 0) {
|
|
@@ -2093,27 +2163,25 @@ const transduce = dual(2, (self, sink) => transformPull(self, (upstream, scope)
|
|
|
2093
2163
|
}
|
|
2094
2164
|
return upstream;
|
|
2095
2165
|
}).pipe(catch_$2((error) => {
|
|
2096
|
-
done$
|
|
2166
|
+
done$8 = fail$5(error);
|
|
2097
2167
|
return done();
|
|
2098
2168
|
}));
|
|
2099
2169
|
const pull = map$2(suspend$2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => {
|
|
2100
2170
|
leftover = leftover_;
|
|
2101
2171
|
return of(value);
|
|
2102
2172
|
});
|
|
2103
|
-
return suspend$2(() => done$
|
|
2173
|
+
return suspend$2(() => done$8 ? done$8 : pull);
|
|
2104
2174
|
})));
|
|
2105
2175
|
const broadcast = dual(2, (self, options) => map$2(toPubSubTake(self, options), fromPubSubTake));
|
|
2106
2176
|
const pipeThroughChannel = dual(2, (self, channel) => fromChannel(pipeTo(self.channel, channel)));
|
|
2107
|
-
const decodeText = dual((args) => isStream(args[0]), (self, options) =>
|
|
2108
|
-
const decoder = new TextDecoder(options?.encoding);
|
|
2109
|
-
return map(self, (chunk) => decoder.decode(chunk, { stream: true }));
|
|
2110
|
-
}));
|
|
2177
|
+
const decodeText = dual((args) => isStream(args[0]), (self, options) => self.channel.pipe(pipeTo(decodeText$1(options?.encoding)), fromChannel));
|
|
2111
2178
|
const splitLines = (self) => self.channel.pipe(pipeTo(splitLines$1()), fromChannel);
|
|
2112
|
-
const
|
|
2179
|
+
const onExit = dual(2, (self, finalizer) => fromChannel(onExit$1(self.channel, finalizer)));
|
|
2113
2180
|
const ensuring = dual(2, (self, finalizer) => fromChannel(ensuring$1(self.channel, finalizer)));
|
|
2114
2181
|
const provideContext = dual(2, (self, context) => fromChannel(provideContext$1(self.channel, context)));
|
|
2115
2182
|
const provideService = dual(3, (self, key, service) => fromChannel(provideService$1(self.channel, key, service)));
|
|
2116
|
-
const run = dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => sink
|
|
2183
|
+
const run = dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => runSink(sink, upstream, scope)), map$2(([a]) => a))));
|
|
2184
|
+
const runSink = (sink, upstream, scope) => restoreUpstreamFailure(sink.transform(upstreamFailureToDefect(upstream), scope));
|
|
2117
2185
|
const runCollect = (self) => runFold$1(self.channel, () => [], (acc, chunk) => {
|
|
2118
2186
|
for (let i = 0; i < chunk.length; i++) acc.push(chunk[i]);
|
|
2119
2187
|
return acc;
|
|
@@ -2134,9 +2202,65 @@ const runForEach = dual(2, (self, f) => runForEach$1(self.channel, (arr) => {
|
|
|
2134
2202
|
const runForEachArray = dual(2, (self, f) => runForEach$1(self.channel, f));
|
|
2135
2203
|
const runDrain = (self) => runDrain$1(self.channel);
|
|
2136
2204
|
const mkString = (self) => runFold$1(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
|
|
2205
|
+
const toAsyncIterableWith = dual(2, (self, context) => ({ [Symbol.asyncIterator]() {
|
|
2206
|
+
const runPromise = runPromiseWith(context);
|
|
2207
|
+
const runFork = runForkWith(context);
|
|
2208
|
+
const scope = makeUnsafe$1();
|
|
2209
|
+
let pull;
|
|
2210
|
+
let currentIter;
|
|
2211
|
+
let currentFiber;
|
|
2212
|
+
let closePromise;
|
|
2213
|
+
const close$1 = (exit) => {
|
|
2214
|
+
if (closePromise) return closePromise;
|
|
2215
|
+
const fiber = currentFiber;
|
|
2216
|
+
closePromise = runPromise(as(andThen(fiber ? interrupt(fiber) : void_, close(scope, exit)), {
|
|
2217
|
+
done: true,
|
|
2218
|
+
value: void 0
|
|
2219
|
+
}));
|
|
2220
|
+
return closePromise;
|
|
2221
|
+
};
|
|
2222
|
+
const closeAndReportError = async (exit) => {
|
|
2223
|
+
try {
|
|
2224
|
+
await close$1(exit);
|
|
2225
|
+
} catch (error) {
|
|
2226
|
+
await runPromise(logError("Suppressed error while closing Stream async iterator", error));
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
return {
|
|
2230
|
+
async next() {
|
|
2231
|
+
if (closePromise) return closePromise;
|
|
2232
|
+
if (currentIter) {
|
|
2233
|
+
const next = currentIter.next();
|
|
2234
|
+
if (!next.done) return next;
|
|
2235
|
+
currentIter = void 0;
|
|
2236
|
+
}
|
|
2237
|
+
const fiber = runFork(pull ?? flatMap$2(toPullScoped(self.channel, scope), (nextPull) => {
|
|
2238
|
+
pull = nextPull;
|
|
2239
|
+
return nextPull;
|
|
2240
|
+
}));
|
|
2241
|
+
currentFiber = fiber;
|
|
2242
|
+
const exit = await runPromise(await_(fiber));
|
|
2243
|
+
if (currentFiber === fiber) currentFiber = void 0;
|
|
2244
|
+
if (isSuccess(exit)) {
|
|
2245
|
+
currentIter = exit.value[Symbol.iterator]();
|
|
2246
|
+
return currentIter.next();
|
|
2247
|
+
} else if (isDoneCause(exit.cause)) return close$1(void_$2);
|
|
2248
|
+
if (closePromise && hasInterruptsOnly(exit.cause)) return closePromise;
|
|
2249
|
+
await closeAndReportError(exit);
|
|
2250
|
+
throw squash(exit.cause);
|
|
2251
|
+
},
|
|
2252
|
+
return() {
|
|
2253
|
+
return close$1(void_$2);
|
|
2254
|
+
},
|
|
2255
|
+
async throw(error) {
|
|
2256
|
+
await closeAndReportError(die$4(error));
|
|
2257
|
+
throw error;
|
|
2258
|
+
}
|
|
2259
|
+
};
|
|
2260
|
+
} }));
|
|
2261
|
+
const toAsyncIterable = (self) => toAsyncIterableWith(self, empty$2());
|
|
2137
2262
|
const runIntoPubSub = dual((args) => isStream(args[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
|
|
2138
2263
|
const toPubSubTake = dual(2, (self, options) => toPubSubTake$1(self.channel, options));
|
|
2139
|
-
|
|
2140
|
-
export { take as $, mapArray as A, makeUnsafe$1 as At, provideContext as B, toLowerCase as Bt, fromEffect as C, shutdownUnsafe as Ct, fromReadableStream as D, make$4 as Dt, fromQueue as E, unbounded$1 as Et, mergeAll as F, interruptAllAs as Ft, runFold as G, run as H, mkString as I, interruptAs as It, runIntoPubSub as J, runForEach as K, onEnd as L, join as Lt, mapEffect as M, getCurrent as Mt, mapError as N, interrupt as Nt, isStream as O, set as Ot, merge as P, interruptAll as Pt, suspend as Q, orDie as R, runIn as Rt, fromChannel as S, poll as St, fromPull as T, unbounded as Tt, runCollect as U, provideService as V, normalizeNonEmpty as Vt, runDrain as W, splitLines as X, runLast as Y, succeed as Z, flattenArray as _, make$1 as _t, catchTags as a, fromTransform as at, fromArrayEffect as b, offerAllUnsafe as bt, die as c, unwrap$1 as ct, ensuring as d, bounded as dt, takeUntil as et, fail as f, end as ft, flatMap as g, failCauseUnsafe as gt, filterMap as h, failCause$2 as ht, catchReason as i, unwrap as it, mapArrayEffect as j, await_ as jt, map as k, update as kt, drop as l, make as lt, filter as m, fail$2 as mt, callback as n, tap as nt, catch_ as o, mapDone as ot, failCause as p, endUnsafe as pt, runForEachArray as q, catchIf as r, transduce as rt, decodeText as s, toTransform as st, broadcast as t, takeWhile as tt, empty as u, makeUnsafe as ut, flattenIterable as v, offer as vt, fromPubSub as w, take$1 as wt, fromAsyncIterable as x, offerUnsafe as xt, fromArray as y, offerAll as yt, pipeThroughChannel as z, camelToSnake as zt };
|
|
2264
|
+
export { runLast as $, fromQueue as A, shutdownUnsafe as At, mkString as B, interrupt as Bt, fromArray as C, failCauseUnsafe as Ct, fromEffect as D, offerAllUnsafe as Dt, fromChannel as E, offerAll as Et, mapArrayEffect as F, make$4 as Ft, provideService as G, camelToSnake as Gt, orDie as H, interruptAllAs as Ht, mapEffect as I, set as It, runDrain as J, run as K, toLowerCase as Kt, mapError as L, update as Lt, isStream as M, take$1 as Mt, map as N, unbounded as Nt, fromPubSub as O, offerUnsafe as Ot, mapArray as P, unbounded$1 as Pt, runIntoPubSub as Q, merge as R, await_ as Rt, flattenIterable as S, failCause$2 as St, fromAsyncIterable as T, offer as Tt, pipeThroughChannel as U, join as Ut, onExit as V, interruptAll as Vt, provideContext as W, runIn as Wt, runForEach as X, runFold as Y, runForEachArray as Z, filter as _, makeUnsafe as _t, catchReason as a, takeUntil as at, flatten as b, endUnsafe as bt, concat as c, tapError as ct, drainFork as d, unwrap as dt, scoped as et, drop as f, fromTransform as ft, failCause as g, make as gt, fail as h, unwrap$1 as ht, catchIf as i, take as it, fromReadableStream as j, sliding as jt, fromPull as k, poll as kt, decodeText as l, toAsyncIterable as lt, ensuring as m, toTransform as mt, callback as n, succeed as nt, catchTags as o, takeWhile as ot, empty as p, mapDone as pt, runCollect as q, catchCause as r, suspend as rt, catch_ as s, tap as st, broadcast as t, splitLines as tt, die as u, transduce as ut, filterMap as v, bounded as vt, fromArrayEffect as w, make$1 as wt, flattenArray as x, fail$2 as xt, flatMap as y, end as yt, mergeAll as z, getCurrent as zt };
|
|
2141
2265
|
|
|
2142
|
-
//# sourceMappingURL=Stream-
|
|
2266
|
+
//# sourceMappingURL=Stream-Dwvj9X5X.mjs.map
|