brass-runtime 1.13.4 → 1.13.6
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/dist/agent/cli/main.cjs +2022 -0
- package/dist/agent/cli/main.js +184 -184
- package/dist/agent/index.cjs +153 -0
- package/dist/agent/index.js +153 -153
- package/dist/chunk-3IF374MG.js +121 -121
- package/dist/chunk-AC4RFFVX.cjs +407 -0
- package/dist/chunk-DB57UZBE.cjs +2879 -0
- package/dist/chunk-HRVX2IYW.js +345 -345
- package/dist/chunk-KT4IKCIU.cjs +2556 -0
- package/dist/chunk-TGOMLZ65.js +317 -317
- package/dist/http/index.cjs +453 -0
- package/dist/http/index.js +74 -74
- package/dist/index.cjs +855 -0
- package/dist/index.js +340 -340
- package/package.json +6 -8
- package/wasm/pkg/brass_runtime_wasm_engine.d.ts +92 -0
- package/wasm/pkg/brass_runtime_wasm_engine.js +657 -0
- package/wasm/pkg/brass_runtime_wasm_engine_bg.wasm +0 -0
- package/wasm/pkg/brass_runtime_wasm_engine_bg.wasm.d.ts +62 -0
- package/wasm/pkg/package.json +13 -0
- package/dist/agent/cli/main.d.mts +0 -1
- package/dist/agent/index.d.mts +0 -688
- package/dist/effect-ISvXPLgc.d.mts +0 -797
- package/dist/http/index.d.mts +0 -154
- package/dist/index.d.mts +0 -258
- package/dist/stream-C0-LWnUP.d.mts +0 -66
package/dist/index.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
import {
|
|
2
|
+
assertNever,
|
|
3
|
+
collectStream,
|
|
4
|
+
concatStream,
|
|
5
|
+
emitStream,
|
|
6
|
+
emptyStream,
|
|
7
|
+
flattenStream,
|
|
8
|
+
foreachStream,
|
|
9
|
+
fromArray,
|
|
10
|
+
fromPull,
|
|
11
|
+
managedStream,
|
|
12
|
+
mapStream,
|
|
13
|
+
merge,
|
|
14
|
+
mergeStream,
|
|
15
|
+
rangeStream,
|
|
16
|
+
streamFromReadableStream,
|
|
17
|
+
uncons,
|
|
18
|
+
unwrapScoped,
|
|
19
|
+
widenOpt,
|
|
20
|
+
zip
|
|
21
|
+
} from "./chunk-3IF374MG.js";
|
|
22
|
+
import {
|
|
23
|
+
Async,
|
|
24
|
+
Cause,
|
|
25
|
+
DefaultHostExecutor,
|
|
26
|
+
EngineFiberHandle,
|
|
27
|
+
Exit,
|
|
28
|
+
HostRegistry,
|
|
29
|
+
JsFiberEngine,
|
|
30
|
+
NoopHooks,
|
|
31
|
+
ProgramBuilder,
|
|
32
|
+
PushStatus,
|
|
33
|
+
ReferenceWasmBridge,
|
|
34
|
+
RingBuffer,
|
|
35
|
+
Runtime,
|
|
36
|
+
RuntimeFiber,
|
|
37
|
+
Scheduler,
|
|
38
|
+
Scope,
|
|
39
|
+
WasmFiberEngine,
|
|
40
|
+
WasmFiberRegistryBridge,
|
|
41
|
+
WasmPackFiberBridge,
|
|
42
|
+
acquireRelease,
|
|
43
|
+
async,
|
|
44
|
+
asyncCatchAll,
|
|
45
|
+
asyncFail,
|
|
46
|
+
asyncFlatMap,
|
|
47
|
+
asyncFold,
|
|
48
|
+
asyncInterruptible,
|
|
49
|
+
asyncMap,
|
|
50
|
+
asyncMapError,
|
|
51
|
+
asyncSucceed,
|
|
52
|
+
asyncSync,
|
|
53
|
+
asyncTotal,
|
|
54
|
+
catchAll,
|
|
55
|
+
collectAllPar,
|
|
56
|
+
end,
|
|
57
|
+
fail,
|
|
58
|
+
flatMap,
|
|
59
|
+
fork,
|
|
60
|
+
fromPromiseAbortable,
|
|
61
|
+
getBenchmarkBudget,
|
|
62
|
+
getCurrentFiber,
|
|
63
|
+
globalScheduler,
|
|
64
|
+
makeBoundedRingBuffer,
|
|
65
|
+
map,
|
|
66
|
+
mapAsync,
|
|
67
|
+
mapError,
|
|
68
|
+
mapTryAsync,
|
|
69
|
+
none,
|
|
70
|
+
orElseOptional,
|
|
71
|
+
race,
|
|
72
|
+
raceWith,
|
|
73
|
+
resolveWasmModule,
|
|
74
|
+
runtimeCapabilities,
|
|
75
|
+
setBenchmarkBudget,
|
|
76
|
+
some,
|
|
77
|
+
succeed,
|
|
78
|
+
sync,
|
|
79
|
+
toPromise,
|
|
80
|
+
unit,
|
|
81
|
+
unsafeGetCurrentRuntime,
|
|
82
|
+
unsafeRunAsync,
|
|
83
|
+
unsafeRunFoldWithEnv,
|
|
84
|
+
withAsyncPromise,
|
|
85
|
+
withCurrentFiber,
|
|
86
|
+
withScope,
|
|
87
|
+
withScopeAsync,
|
|
88
|
+
zipPar
|
|
89
|
+
} from "./chunk-TGOMLZ65.js";
|
|
90
90
|
|
|
91
91
|
// src/core/types/cancel.ts
|
|
92
92
|
function makeCancelToken() {
|
|
@@ -104,7 +104,7 @@ function makeCancelToken() {
|
|
|
104
104
|
if (cancelled) {
|
|
105
105
|
try {
|
|
106
106
|
f();
|
|
107
|
-
} catch
|
|
107
|
+
} catch {
|
|
108
108
|
}
|
|
109
109
|
return () => {
|
|
110
110
|
};
|
|
@@ -122,10 +122,10 @@ function linkAbortController(token, ac) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// src/core/runtime/linkedQueue.ts
|
|
125
|
-
var LinkedQueue =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
var LinkedQueue = class {
|
|
126
|
+
head = null;
|
|
127
|
+
tail = null;
|
|
128
|
+
len = 0;
|
|
129
129
|
get length() {
|
|
130
130
|
return this.len;
|
|
131
131
|
}
|
|
@@ -161,14 +161,14 @@ var LinkedQueue = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
161
161
|
node.prev = null;
|
|
162
162
|
this.len--;
|
|
163
163
|
}
|
|
164
|
-
}
|
|
164
|
+
};
|
|
165
165
|
|
|
166
166
|
// src/core/stream/queue.ts
|
|
167
167
|
function bounded(capacity, strategy = "backpressure", options = {}) {
|
|
168
|
-
return
|
|
168
|
+
return asyncSync(() => makeQueue(capacity, strategy, options));
|
|
169
169
|
}
|
|
170
170
|
function makeQueue(capacity, strategy, options) {
|
|
171
|
-
const items =
|
|
171
|
+
const items = makeBoundedRingBuffer(capacity, capacity, options);
|
|
172
172
|
let closed = false;
|
|
173
173
|
const QueueClosedErr = { _tag: "QueueClosed" };
|
|
174
174
|
const offerWaiters = new LinkedQueue();
|
|
@@ -189,7 +189,7 @@ function makeQueue(capacity, strategy, options) {
|
|
|
189
189
|
return {
|
|
190
190
|
size: () => items.length,
|
|
191
191
|
shutdown,
|
|
192
|
-
offer: (a) =>
|
|
192
|
+
offer: (a) => async((_env, cb) => {
|
|
193
193
|
if (closed) {
|
|
194
194
|
cb({ _tag: "Success", value: false });
|
|
195
195
|
return;
|
|
@@ -224,7 +224,7 @@ function makeQueue(capacity, strategy, options) {
|
|
|
224
224
|
};
|
|
225
225
|
return canceler;
|
|
226
226
|
}),
|
|
227
|
-
take: () =>
|
|
227
|
+
take: () => async((_env, cb) => {
|
|
228
228
|
if (items.length > 0) {
|
|
229
229
|
const a = items.shift();
|
|
230
230
|
cb({ _tag: "Success", value: a });
|
|
@@ -261,34 +261,34 @@ function buffer(stream, capacity, strategy = "backpressure") {
|
|
|
261
261
|
let q = null;
|
|
262
262
|
let producer = null;
|
|
263
263
|
let upstream = stream;
|
|
264
|
-
const onUpstreamFailure = (opt) =>
|
|
264
|
+
const onUpstreamFailure = (opt) => asyncSucceed(
|
|
265
265
|
opt._tag === "None" ? SIGNAL_END : { _tag: "Fail", error: opt.value }
|
|
266
266
|
);
|
|
267
|
-
const onUpstreamSuccess = ([a, tail]) =>
|
|
267
|
+
const onUpstreamSuccess = ([a, tail]) => asyncSync(() => {
|
|
268
268
|
upstream = tail;
|
|
269
269
|
return { _tag: "Elem", value: a };
|
|
270
270
|
});
|
|
271
|
-
const nextSignal = () =>
|
|
272
|
-
|
|
271
|
+
const nextSignal = () => asyncFold(
|
|
272
|
+
uncons(upstream),
|
|
273
273
|
onUpstreamFailure,
|
|
274
274
|
onUpstreamSuccess
|
|
275
275
|
);
|
|
276
|
-
const start = (env) =>
|
|
276
|
+
const start = (env) => asyncFlatMap(bounded(capacity, strategy), (_q) => {
|
|
277
277
|
q = _q;
|
|
278
278
|
let lastSig;
|
|
279
279
|
const afterOffer = () => {
|
|
280
280
|
if (lastSig._tag !== "Elem") {
|
|
281
|
-
return
|
|
281
|
+
return asyncSucceed(void 0);
|
|
282
282
|
}
|
|
283
283
|
return loop();
|
|
284
284
|
};
|
|
285
285
|
const onSignal = (sig) => {
|
|
286
286
|
lastSig = sig;
|
|
287
|
-
return
|
|
287
|
+
return asyncFlatMap(q.offer(sig), afterOffer);
|
|
288
288
|
};
|
|
289
|
-
const loop = () =>
|
|
290
|
-
producer =
|
|
291
|
-
return
|
|
289
|
+
const loop = () => asyncFlatMap(nextSignal(), onSignal);
|
|
290
|
+
producer = fork(loop(), env);
|
|
291
|
+
return asyncSucceed(void 0);
|
|
292
292
|
});
|
|
293
293
|
const pullDown = {
|
|
294
294
|
_tag: "Async",
|
|
@@ -296,7 +296,7 @@ function buffer(stream, capacity, strategy = "backpressure") {
|
|
|
296
296
|
const go = () => {
|
|
297
297
|
if (!started) {
|
|
298
298
|
started = true;
|
|
299
|
-
|
|
299
|
+
unsafeGetCurrentRuntime().fork(start(env)).join(() => {
|
|
300
300
|
pullFromQueue(env, cb);
|
|
301
301
|
});
|
|
302
302
|
return;
|
|
@@ -308,25 +308,25 @@ function buffer(stream, capacity, strategy = "backpressure") {
|
|
|
308
308
|
};
|
|
309
309
|
function pullFromQueue(env, cb) {
|
|
310
310
|
const takeEff = q.take();
|
|
311
|
-
|
|
311
|
+
unsafeGetCurrentRuntime().fork(takeEff).join((ex) => {
|
|
312
312
|
if (ex._tag !== "Success") return;
|
|
313
313
|
const sig = ex.value;
|
|
314
314
|
switch (sig._tag) {
|
|
315
315
|
case "Elem":
|
|
316
|
-
cb({ _tag: "Success", value: [sig.value,
|
|
316
|
+
cb({ _tag: "Success", value: [sig.value, fromPull(pullDown)] });
|
|
317
317
|
return;
|
|
318
318
|
case "End":
|
|
319
|
-
|
|
320
|
-
cb({ _tag: "Failure", cause: { _tag: "Fail", error:
|
|
319
|
+
producer?.interrupt?.();
|
|
320
|
+
cb({ _tag: "Failure", cause: { _tag: "Fail", error: none } });
|
|
321
321
|
return;
|
|
322
322
|
case "Fail":
|
|
323
|
-
|
|
324
|
-
cb({ _tag: "Failure", cause: { _tag: "Fail", error:
|
|
323
|
+
producer?.interrupt?.();
|
|
324
|
+
cb({ _tag: "Failure", cause: { _tag: "Fail", error: some(sig.error) } });
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
-
return
|
|
329
|
+
return fromPull(pullDown);
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// src/core/stream/hub.ts
|
|
@@ -335,45 +335,45 @@ function makeHub(capacity, strategy = "BackPressure") {
|
|
|
335
335
|
const queues = /* @__PURE__ */ new Set();
|
|
336
336
|
let closed = false;
|
|
337
337
|
const publish = (a) => {
|
|
338
|
-
if (closed) return
|
|
338
|
+
if (closed) return asyncSucceed(false);
|
|
339
339
|
const size = queues.size;
|
|
340
|
-
if (size === 0) return
|
|
340
|
+
if (size === 0) return asyncSucceed(true);
|
|
341
341
|
if (size === 1) {
|
|
342
342
|
const q = queues.values().next().value;
|
|
343
343
|
return q.offer(a);
|
|
344
344
|
}
|
|
345
|
-
let eff =
|
|
345
|
+
let eff = asyncSucceed(true);
|
|
346
346
|
for (const q of queues) {
|
|
347
|
-
eff =
|
|
347
|
+
eff = asyncFlatMap(
|
|
348
348
|
eff,
|
|
349
|
-
(okSoFar) =>
|
|
349
|
+
(okSoFar) => asyncFlatMap(q.offer(a), (ok) => asyncSucceed(okSoFar && ok))
|
|
350
350
|
);
|
|
351
351
|
}
|
|
352
352
|
return eff;
|
|
353
353
|
};
|
|
354
354
|
const publishAll = (as) => {
|
|
355
|
-
let eff =
|
|
355
|
+
let eff = asyncSucceed(true);
|
|
356
356
|
const it = as[Symbol.iterator]();
|
|
357
357
|
while (true) {
|
|
358
358
|
const n = it.next();
|
|
359
359
|
if (n.done) break;
|
|
360
360
|
const a = n.value;
|
|
361
|
-
eff =
|
|
361
|
+
eff = asyncFlatMap(
|
|
362
362
|
eff,
|
|
363
|
-
(okSoFar) =>
|
|
363
|
+
(okSoFar) => asyncFlatMap(publish(a), (ok) => asyncSucceed(okSoFar && ok))
|
|
364
364
|
);
|
|
365
365
|
}
|
|
366
366
|
return eff;
|
|
367
367
|
};
|
|
368
368
|
const subscribe = () => {
|
|
369
369
|
if (closed) {
|
|
370
|
-
return
|
|
370
|
+
return asyncTotal(() => {
|
|
371
371
|
throw { _tag: "HubClosed" };
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
|
-
return
|
|
374
|
+
return asyncFlatMap(
|
|
375
375
|
bounded(capacity, toQueueStrategy(strategy)),
|
|
376
|
-
(q) =>
|
|
376
|
+
(q) => asyncSync(() => {
|
|
377
377
|
queues.add(q);
|
|
378
378
|
return {
|
|
379
379
|
...q,
|
|
@@ -386,7 +386,7 @@ function makeHub(capacity, strategy = "BackPressure") {
|
|
|
386
386
|
})
|
|
387
387
|
);
|
|
388
388
|
};
|
|
389
|
-
const shutdown = () =>
|
|
389
|
+
const shutdown = () => asyncSync(() => {
|
|
390
390
|
if (closed) return;
|
|
391
391
|
closed = true;
|
|
392
392
|
for (const q of queues) q.shutdown();
|
|
@@ -401,23 +401,23 @@ function makeHub(capacity, strategy = "BackPressure") {
|
|
|
401
401
|
}
|
|
402
402
|
var broadcast = makeHub;
|
|
403
403
|
function broadcastToHub(stream, hub) {
|
|
404
|
-
return
|
|
404
|
+
return foreachStream(
|
|
405
405
|
stream,
|
|
406
|
-
(a) =>
|
|
406
|
+
(a) => asyncFlatMap(hub.publish(a), () => asyncSucceed(void 0))
|
|
407
407
|
);
|
|
408
408
|
}
|
|
409
409
|
function fromHub(hub) {
|
|
410
|
-
return
|
|
411
|
-
|
|
412
|
-
const loop =
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
(a) =>
|
|
410
|
+
return managedStream(
|
|
411
|
+
asyncFlatMap(hub.subscribe(), (sub) => {
|
|
412
|
+
const loop = fromPull(
|
|
413
|
+
asyncFlatMap(
|
|
414
|
+
asyncMapError(sub.take(), (_queueClosed) => none),
|
|
415
|
+
(a) => asyncSucceed([a, loop])
|
|
416
416
|
)
|
|
417
417
|
);
|
|
418
|
-
return
|
|
418
|
+
return asyncSucceed({
|
|
419
419
|
stream: loop,
|
|
420
|
-
release: (_exit) =>
|
|
420
|
+
release: (_exit) => asyncSync(() => sub.unsubscribe())
|
|
421
421
|
});
|
|
422
422
|
})
|
|
423
423
|
);
|
|
@@ -427,22 +427,22 @@ function fromHub(hub) {
|
|
|
427
427
|
var cachedWasmChunkCtor;
|
|
428
428
|
function resolveWasmChunkBuffer() {
|
|
429
429
|
if (cachedWasmChunkCtor !== void 0) return cachedWasmChunkCtor;
|
|
430
|
-
const mod =
|
|
431
|
-
cachedWasmChunkCtor =
|
|
430
|
+
const mod = resolveWasmModule();
|
|
431
|
+
cachedWasmChunkCtor = mod?.BrassWasmChunkBuffer ?? null;
|
|
432
432
|
return cachedWasmChunkCtor;
|
|
433
433
|
}
|
|
434
|
-
var JsChunker =
|
|
435
|
-
constructor(maxChunkSize, fallbackUsed = false) {
|
|
434
|
+
var JsChunker = class {
|
|
435
|
+
constructor(maxChunkSize, fallbackUsed = false) {
|
|
436
436
|
this.maxChunkSize = maxChunkSize;
|
|
437
437
|
this.fallbackUsed = fallbackUsed;
|
|
438
438
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
439
|
+
maxChunkSize;
|
|
440
|
+
fallbackUsed;
|
|
441
|
+
engine = "js";
|
|
442
|
+
values = [];
|
|
443
|
+
emittedChunks = 0;
|
|
444
|
+
emittedItems = 0;
|
|
445
|
+
flushes = 0;
|
|
446
446
|
get length() {
|
|
447
447
|
return this.values.length;
|
|
448
448
|
}
|
|
@@ -483,12 +483,12 @@ var JsChunker = (_class2 = class {
|
|
|
483
483
|
}
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
}
|
|
487
|
-
var WasmChunker =
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
constructor(maxChunkSize) {
|
|
486
|
+
};
|
|
487
|
+
var WasmChunker = class {
|
|
488
|
+
engine = "wasm";
|
|
489
|
+
fallbackUsed = false;
|
|
490
|
+
inner;
|
|
491
|
+
constructor(maxChunkSize) {
|
|
492
492
|
const Ctor = resolveWasmChunkBuffer();
|
|
493
493
|
if (!Ctor) {
|
|
494
494
|
throw new Error("brass-runtime wasm chunk buffer is not available. Run npm run build:wasm first.");
|
|
@@ -519,29 +519,29 @@ var WasmChunker = (_class3 = class {
|
|
|
519
519
|
stats() {
|
|
520
520
|
return { engine: "wasm", fallbackUsed: false, data: JSON.parse(this.inner.stats_json()) };
|
|
521
521
|
}
|
|
522
|
-
}
|
|
522
|
+
};
|
|
523
523
|
function makeStreamChunker(chunkSize, options = {}) {
|
|
524
524
|
const size = Math.max(1, chunkSize | 0);
|
|
525
|
-
const engine =
|
|
525
|
+
const engine = options.engine ?? "auto";
|
|
526
526
|
if (engine === "js") return new JsChunker(size, false);
|
|
527
527
|
if (engine === "wasm") return new WasmChunker(size);
|
|
528
528
|
return resolveWasmChunkBuffer() ? new WasmChunker(size) : new JsChunker(size, true);
|
|
529
529
|
}
|
|
530
530
|
function chunks(input, chunkSize, options = {}) {
|
|
531
531
|
const size = Math.max(1, chunkSize | 0);
|
|
532
|
-
const loop = (cur) =>
|
|
533
|
-
const fillChunk = (cur, chunker) =>
|
|
534
|
-
|
|
532
|
+
const loop = (cur) => fromPull(fillChunk(cur, makeStreamChunker(size, options)));
|
|
533
|
+
const fillChunk = (cur, chunker) => asyncFold(
|
|
534
|
+
uncons(cur),
|
|
535
535
|
(opt) => {
|
|
536
536
|
if (opt._tag === "None" && !chunker.isEmpty()) {
|
|
537
|
-
return
|
|
537
|
+
return asyncSucceed([chunker.takeChunk(), fromPull(asyncFail(none))]);
|
|
538
538
|
}
|
|
539
|
-
return
|
|
539
|
+
return asyncFail(opt);
|
|
540
540
|
},
|
|
541
541
|
([a, tail]) => {
|
|
542
542
|
chunker.push(a);
|
|
543
543
|
if (chunker.isFull()) {
|
|
544
|
-
return
|
|
544
|
+
return asyncSucceed([chunker.takeChunk(), loop(tail)]);
|
|
545
545
|
}
|
|
546
546
|
return fillChunk(tail, chunker);
|
|
547
547
|
}
|
|
@@ -552,15 +552,15 @@ function mapChunks(input, chunkSize, f, options = {}) {
|
|
|
552
552
|
const pullOne = (pending, rest) => {
|
|
553
553
|
if (pending.length > 0) {
|
|
554
554
|
const [head, ...tail] = pending;
|
|
555
|
-
return
|
|
555
|
+
return fromPull(asyncSucceed([head, pullOne(tail, rest)]));
|
|
556
556
|
}
|
|
557
|
-
return
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
(opt) =>
|
|
557
|
+
return fromPull(
|
|
558
|
+
asyncFold(
|
|
559
|
+
uncons(rest),
|
|
560
|
+
(opt) => asyncFail(opt),
|
|
561
561
|
([chunk, tail]) => {
|
|
562
562
|
const mapped = f(chunk);
|
|
563
|
-
return
|
|
563
|
+
return uncons(pullOne(mapped, tail));
|
|
564
564
|
}
|
|
565
565
|
)
|
|
566
566
|
);
|
|
@@ -573,16 +573,16 @@ function mapChunksEffect(chunkSize, f, options = {}) {
|
|
|
573
573
|
const pullOne = (pending, rest) => {
|
|
574
574
|
if (pending.length > 0) {
|
|
575
575
|
const [head, ...tail] = pending;
|
|
576
|
-
return
|
|
576
|
+
return fromPull(asyncSucceed([head, pullOne(tail, rest)]));
|
|
577
577
|
}
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
(opt) =>
|
|
582
|
-
([chunk, tail]) =>
|
|
583
|
-
|
|
584
|
-
(opt) =>
|
|
585
|
-
(mapped) =>
|
|
578
|
+
return fromPull(
|
|
579
|
+
asyncFold(
|
|
580
|
+
asyncMapError(uncons(rest), (opt) => widenOpt(opt)),
|
|
581
|
+
(opt) => asyncFail(opt),
|
|
582
|
+
([chunk, tail]) => asyncFold(
|
|
583
|
+
asyncMapError(f(chunk), (e) => ({ _tag: "Some", value: e })),
|
|
584
|
+
(opt) => asyncFail(opt),
|
|
585
|
+
(mapped) => uncons(pullOne(mapped, tail))
|
|
586
586
|
)
|
|
587
587
|
)
|
|
588
588
|
);
|
|
@@ -606,35 +606,35 @@ function identity() {
|
|
|
606
606
|
}
|
|
607
607
|
function mapP(f) {
|
|
608
608
|
return ((input) => {
|
|
609
|
-
const onError = (opt) =>
|
|
610
|
-
const onSuccess = ([a, tail]) =>
|
|
611
|
-
const loop = (cur) =>
|
|
612
|
-
|
|
609
|
+
const onError = (opt) => asyncFail(opt);
|
|
610
|
+
const onSuccess = ([a, tail]) => asyncSucceed([f(a), loop(tail)]);
|
|
611
|
+
const loop = (cur) => fromPull(
|
|
612
|
+
asyncFold(uncons(cur), onError, onSuccess)
|
|
613
613
|
);
|
|
614
614
|
return loop(input);
|
|
615
615
|
});
|
|
616
616
|
}
|
|
617
617
|
function filterP(pred) {
|
|
618
618
|
return ((input) => {
|
|
619
|
-
const onError = (opt) =>
|
|
620
|
-
const onSuccess = ([a, tail]) => pred(a) ?
|
|
621
|
-
const next = (cur) =>
|
|
622
|
-
const loop = (cur) =>
|
|
619
|
+
const onError = (opt) => asyncFail(opt);
|
|
620
|
+
const onSuccess = ([a, tail]) => pred(a) ? asyncSucceed([a, loop(tail)]) : next(tail);
|
|
621
|
+
const next = (cur) => asyncFold(uncons(cur), onError, onSuccess);
|
|
622
|
+
const loop = (cur) => fromPull(next(cur));
|
|
623
623
|
return loop(input);
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
626
|
function filterMapP(f) {
|
|
627
627
|
return ((input) => {
|
|
628
|
-
const onError = (opt) =>
|
|
629
|
-
const next = (cur) =>
|
|
630
|
-
|
|
628
|
+
const onError = (opt) => asyncFail(opt);
|
|
629
|
+
const next = (cur) => asyncFold(
|
|
630
|
+
uncons(cur),
|
|
631
631
|
onError,
|
|
632
632
|
([a, tail]) => {
|
|
633
633
|
const ob = f(a);
|
|
634
|
-
return ob._tag === "Some" ?
|
|
634
|
+
return ob._tag === "Some" ? asyncSucceed([ob.value, loop(tail)]) : next(tail);
|
|
635
635
|
}
|
|
636
636
|
);
|
|
637
|
-
const loop = (cur) =>
|
|
637
|
+
const loop = (cur) => fromPull(next(cur));
|
|
638
638
|
return loop(input);
|
|
639
639
|
});
|
|
640
640
|
}
|
|
@@ -642,12 +642,12 @@ function takeP(n) {
|
|
|
642
642
|
const m = Math.max(0, n | 0);
|
|
643
643
|
return ((input) => {
|
|
644
644
|
const loop = (cur, remaining) => {
|
|
645
|
-
if (remaining <= 0) return
|
|
646
|
-
return
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
(opt) =>
|
|
650
|
-
([a, tail]) =>
|
|
645
|
+
if (remaining <= 0) return emptyStream();
|
|
646
|
+
return fromPull(
|
|
647
|
+
asyncFold(
|
|
648
|
+
uncons(cur),
|
|
649
|
+
(opt) => asyncFail(opt),
|
|
650
|
+
([a, tail]) => asyncSucceed([a, loop(tail, remaining - 1)])
|
|
651
651
|
)
|
|
652
652
|
);
|
|
653
653
|
};
|
|
@@ -659,11 +659,11 @@ function dropP(n) {
|
|
|
659
659
|
return ((input) => {
|
|
660
660
|
const skip = (cur, remaining) => {
|
|
661
661
|
if (remaining <= 0) return cur;
|
|
662
|
-
return
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
(opt) =>
|
|
666
|
-
([_a, tail]) =>
|
|
662
|
+
return fromPull(
|
|
663
|
+
asyncFold(
|
|
664
|
+
uncons(cur),
|
|
665
|
+
(opt) => asyncFail(opt),
|
|
666
|
+
([_a, tail]) => uncons(skip(tail, remaining - 1))
|
|
667
667
|
)
|
|
668
668
|
);
|
|
669
669
|
};
|
|
@@ -672,19 +672,19 @@ function dropP(n) {
|
|
|
672
672
|
}
|
|
673
673
|
function mapEffectP(f) {
|
|
674
674
|
return ((input) => {
|
|
675
|
-
const raiseToOpt = (fa) =>
|
|
676
|
-
const loop = (cur) =>
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
(opt) =>
|
|
675
|
+
const raiseToOpt = (fa) => asyncMapError(fa, (e) => some(e));
|
|
676
|
+
const loop = (cur) => fromPull(
|
|
677
|
+
asyncFold(
|
|
678
|
+
asyncMapError(
|
|
679
|
+
uncons(cur),
|
|
680
|
+
(opt) => widenOpt(opt)
|
|
681
681
|
),
|
|
682
|
-
(opt) =>
|
|
683
|
-
([a, tail]) =>
|
|
682
|
+
(opt) => asyncFail(opt),
|
|
683
|
+
([a, tail]) => asyncFold(
|
|
684
684
|
raiseToOpt(f(a)),
|
|
685
685
|
// Async<Rp, ...>
|
|
686
|
-
(opt2) =>
|
|
687
|
-
(b) =>
|
|
686
|
+
(opt2) => asyncFail(opt2),
|
|
687
|
+
(b) => asyncSucceed([b, loop(tail)])
|
|
688
688
|
)
|
|
689
689
|
)
|
|
690
690
|
);
|
|
@@ -692,7 +692,7 @@ function mapEffectP(f) {
|
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
function tapEffectP(f) {
|
|
695
|
-
return mapEffectP((a) =>
|
|
695
|
+
return mapEffectP((a) => asyncFlatMap(f(a), () => asyncSucceed(a)));
|
|
696
696
|
}
|
|
697
697
|
function chunksP(chunkSize, options = {}) {
|
|
698
698
|
return ((input) => chunks(input, chunkSize, options));
|
|
@@ -707,23 +707,23 @@ function groupedP(n) {
|
|
|
707
707
|
const size = Math.max(1, n | 0);
|
|
708
708
|
return ((input) => {
|
|
709
709
|
const gather = (cur, remaining, acc) => {
|
|
710
|
-
if (remaining <= 0) return
|
|
711
|
-
return
|
|
712
|
-
|
|
710
|
+
if (remaining <= 0) return asyncSucceed({ chunk: acc, rest: cur });
|
|
711
|
+
return asyncFold(
|
|
712
|
+
uncons(cur),
|
|
713
713
|
(opt) => {
|
|
714
|
-
if (opt._tag === "None") return
|
|
715
|
-
return
|
|
714
|
+
if (opt._tag === "None") return asyncSucceed({ chunk: acc, rest: emptyStream() });
|
|
715
|
+
return asyncFail(opt);
|
|
716
716
|
},
|
|
717
717
|
([a, tail]) => gather(tail, remaining - 1, [...acc, a])
|
|
718
718
|
);
|
|
719
719
|
};
|
|
720
|
-
const loop = (cur) =>
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
(opt) =>
|
|
724
|
-
([a, tail]) =>
|
|
720
|
+
const loop = (cur) => fromPull(
|
|
721
|
+
asyncFold(
|
|
722
|
+
uncons(cur),
|
|
723
|
+
(opt) => asyncFail(opt),
|
|
724
|
+
([a, tail]) => asyncFlatMap(
|
|
725
725
|
gather(tail, size - 1, [a]),
|
|
726
|
-
({ chunk, rest }) =>
|
|
726
|
+
({ chunk, rest }) => asyncSucceed([chunk, loop(rest)])
|
|
727
727
|
)
|
|
728
728
|
)
|
|
729
729
|
);
|
|
@@ -738,118 +738,118 @@ function engineStats(engine, data, fallbackUsed = false) {
|
|
|
738
738
|
function selectedEngineStats(requested, engine, data) {
|
|
739
739
|
return { requested, engine, data, fallbackUsed: requested === "auto" && engine !== "wasm" };
|
|
740
740
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
741
|
+
export {
|
|
742
|
+
Async,
|
|
743
|
+
Cause,
|
|
744
|
+
DefaultHostExecutor,
|
|
745
|
+
EngineFiberHandle,
|
|
746
|
+
Exit,
|
|
747
|
+
HostRegistry,
|
|
748
|
+
JsFiberEngine,
|
|
749
|
+
NoopHooks,
|
|
750
|
+
ProgramBuilder,
|
|
751
|
+
PushStatus,
|
|
752
|
+
ReferenceWasmBridge,
|
|
753
|
+
RingBuffer,
|
|
754
|
+
Runtime,
|
|
755
|
+
RuntimeFiber,
|
|
756
|
+
Scheduler,
|
|
757
|
+
Scope,
|
|
758
|
+
WasmFiberEngine,
|
|
759
|
+
WasmFiberRegistryBridge,
|
|
760
|
+
WasmPackFiberBridge,
|
|
761
|
+
acquireRelease,
|
|
762
|
+
andThen,
|
|
763
|
+
assertNever,
|
|
764
|
+
async,
|
|
765
|
+
asyncCatchAll,
|
|
766
|
+
asyncFail,
|
|
767
|
+
asyncFlatMap,
|
|
768
|
+
asyncFold,
|
|
769
|
+
asyncInterruptible,
|
|
770
|
+
asyncMap,
|
|
771
|
+
asyncMapError,
|
|
772
|
+
asyncSucceed,
|
|
773
|
+
asyncSync,
|
|
774
|
+
asyncTotal,
|
|
775
|
+
bounded,
|
|
776
|
+
broadcast,
|
|
777
|
+
broadcastToHub,
|
|
778
|
+
buffer,
|
|
779
|
+
bufferP,
|
|
780
|
+
catchAll,
|
|
781
|
+
chunks,
|
|
782
|
+
chunksP,
|
|
783
|
+
collectAllPar,
|
|
784
|
+
collectStream,
|
|
785
|
+
compose,
|
|
786
|
+
concatStream,
|
|
787
|
+
dropP,
|
|
788
|
+
emitStream,
|
|
789
|
+
emptyStream,
|
|
790
|
+
end,
|
|
791
|
+
engineStats,
|
|
792
|
+
fail,
|
|
793
|
+
filterMapP,
|
|
794
|
+
filterP,
|
|
795
|
+
flatMap,
|
|
796
|
+
flattenStream,
|
|
797
|
+
foreachStream,
|
|
798
|
+
fork,
|
|
799
|
+
fromArray,
|
|
800
|
+
fromHub,
|
|
801
|
+
fromPromiseAbortable,
|
|
802
|
+
fromPull,
|
|
803
|
+
getBenchmarkBudget,
|
|
804
|
+
getCurrentFiber,
|
|
805
|
+
globalScheduler,
|
|
806
|
+
groupedP,
|
|
807
|
+
identity,
|
|
808
|
+
linkAbortController,
|
|
809
|
+
makeBoundedRingBuffer,
|
|
810
|
+
makeCancelToken,
|
|
811
|
+
makeHub,
|
|
812
|
+
makeStreamChunker,
|
|
813
|
+
managedStream,
|
|
814
|
+
map,
|
|
815
|
+
mapAsync,
|
|
816
|
+
mapChunks,
|
|
817
|
+
mapChunksEffect,
|
|
818
|
+
mapChunksEffectP,
|
|
819
|
+
mapEffectP,
|
|
820
|
+
mapError,
|
|
821
|
+
mapP,
|
|
822
|
+
mapStream,
|
|
823
|
+
mapTryAsync,
|
|
824
|
+
merge,
|
|
825
|
+
mergeStream,
|
|
826
|
+
none,
|
|
827
|
+
orElseOptional,
|
|
828
|
+
race,
|
|
829
|
+
raceWith,
|
|
830
|
+
rangeStream,
|
|
831
|
+
runtimeCapabilities,
|
|
832
|
+
selectedEngineStats,
|
|
833
|
+
setBenchmarkBudget,
|
|
834
|
+
some,
|
|
835
|
+
streamFromReadableStream,
|
|
836
|
+
succeed,
|
|
837
|
+
sync,
|
|
838
|
+
takeP,
|
|
839
|
+
tapEffectP,
|
|
840
|
+
toPromise,
|
|
841
|
+
uncons,
|
|
842
|
+
unit,
|
|
843
|
+
unsafeGetCurrentRuntime,
|
|
844
|
+
unsafeRunAsync,
|
|
845
|
+
unsafeRunFoldWithEnv,
|
|
846
|
+
unwrapScoped,
|
|
847
|
+
via,
|
|
848
|
+
widenOpt,
|
|
849
|
+
withAsyncPromise,
|
|
850
|
+
withCurrentFiber,
|
|
851
|
+
withScope,
|
|
852
|
+
withScopeAsync,
|
|
853
|
+
zip,
|
|
854
|
+
zipPar
|
|
855
|
+
};
|